viewer.js 608 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2020 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. /******/ (() => { // webpackBootstrap
  23. /******/ "use strict";
  24. /******/ var __webpack_modules__ = ([
  25. /* 0 */
  26. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  27. Object.defineProperty(exports, "__esModule", ({
  28. value: true
  29. }));
  30. Object.defineProperty(exports, "PDFViewerApplicationOptions", ({
  31. enumerable: true,
  32. get: function get() {
  33. return _app_options.AppOptions;
  34. }
  35. }));
  36. Object.defineProperty(exports, "PDFViewerApplication", ({
  37. enumerable: true,
  38. get: function get() {
  39. return _app.PDFViewerApplication;
  40. }
  41. }));
  42. var _app_options = __webpack_require__(1);
  43. var _app = __webpack_require__(3);
  44. var pdfjsVersion = '2.7.570';
  45. var pdfjsBuild = 'f2c7338b0';
  46. window.PDFViewerApplication = _app.PDFViewerApplication;
  47. window.PDFViewerApplicationOptions = _app_options.AppOptions;
  48. ;
  49. ;
  50. {
  51. __webpack_require__(37);
  52. }
  53. ;
  54. {
  55. __webpack_require__(43);
  56. }
  57. function getViewerConfiguration() {
  58. return {
  59. appContainer: document.body,
  60. mainContainer: document.getElementById("viewerContainer"),
  61. viewerContainer: document.getElementById("viewer"),
  62. eventBus: null,
  63. toolbar: {
  64. container: document.getElementById("toolbarViewer"),
  65. numPages: document.getElementById("numPages"),
  66. pageNumber: document.getElementById("pageNumber"),
  67. scaleSelectContainer: document.getElementById("scaleSelectContainer"),
  68. scaleSelect: document.getElementById("scaleSelect"),
  69. customScaleOption: document.getElementById("customScaleOption"),
  70. previous: document.getElementById("previous"),
  71. next: document.getElementById("next"),
  72. zoomIn: document.getElementById("zoomIn"),
  73. zoomOut: document.getElementById("zoomOut"),
  74. viewFind: document.getElementById("viewFind"),
  75. openFile: document.getElementById("openFile"),
  76. print: document.getElementById("print"),
  77. presentationModeButton: document.getElementById("presentationMode"),
  78. download: document.getElementById("download"),
  79. viewBookmark: document.getElementById("viewBookmark")
  80. },
  81. secondaryToolbar: {
  82. toolbar: document.getElementById("secondaryToolbar"),
  83. toggleButton: document.getElementById("secondaryToolbarToggle"),
  84. toolbarButtonContainer: document.getElementById("secondaryToolbarButtonContainer"),
  85. presentationModeButton: document.getElementById("secondaryPresentationMode"),
  86. openFileButton: document.getElementById("secondaryOpenFile"),
  87. printButton: document.getElementById("secondaryPrint"),
  88. downloadButton: document.getElementById("secondaryDownload"),
  89. viewBookmarkButton: document.getElementById("secondaryViewBookmark"),
  90. firstPageButton: document.getElementById("firstPage"),
  91. lastPageButton: document.getElementById("lastPage"),
  92. pageRotateCwButton: document.getElementById("pageRotateCw"),
  93. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  94. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  95. cursorHandToolButton: document.getElementById("cursorHandTool"),
  96. scrollVerticalButton: document.getElementById("scrollVertical"),
  97. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  98. scrollWrappedButton: document.getElementById("scrollWrapped"),
  99. spreadNoneButton: document.getElementById("spreadNone"),
  100. spreadOddButton: document.getElementById("spreadOdd"),
  101. spreadEvenButton: document.getElementById("spreadEven"),
  102. documentPropertiesButton: document.getElementById("documentProperties")
  103. },
  104. fullscreen: {
  105. contextFirstPage: document.getElementById("contextFirstPage"),
  106. contextLastPage: document.getElementById("contextLastPage"),
  107. contextPageRotateCw: document.getElementById("contextPageRotateCw"),
  108. contextPageRotateCcw: document.getElementById("contextPageRotateCcw")
  109. },
  110. sidebar: {
  111. outerContainer: document.getElementById("outerContainer"),
  112. viewerContainer: document.getElementById("viewerContainer"),
  113. toggleButton: document.getElementById("sidebarToggle"),
  114. thumbnailButton: document.getElementById("viewThumbnail"),
  115. outlineButton: document.getElementById("viewOutline"),
  116. attachmentsButton: document.getElementById("viewAttachments"),
  117. layersButton: document.getElementById("viewLayers"),
  118. thumbnailView: document.getElementById("thumbnailView"),
  119. outlineView: document.getElementById("outlineView"),
  120. attachmentsView: document.getElementById("attachmentsView"),
  121. layersView: document.getElementById("layersView"),
  122. outlineOptionsContainer: document.getElementById("outlineOptionsContainer"),
  123. currentOutlineItemButton: document.getElementById("currentOutlineItem")
  124. },
  125. sidebarResizer: {
  126. outerContainer: document.getElementById("outerContainer"),
  127. resizer: document.getElementById("sidebarResizer")
  128. },
  129. findBar: {
  130. bar: document.getElementById("findbar"),
  131. toggleButton: document.getElementById("viewFind"),
  132. findField: document.getElementById("findInput"),
  133. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  134. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  135. entireWordCheckbox: document.getElementById("findEntireWord"),
  136. findMsg: document.getElementById("findMsg"),
  137. findResultsCount: document.getElementById("findResultsCount"),
  138. findPreviousButton: document.getElementById("findPrevious"),
  139. findNextButton: document.getElementById("findNext")
  140. },
  141. passwordOverlay: {
  142. overlayName: "passwordOverlay",
  143. container: document.getElementById("passwordOverlay"),
  144. label: document.getElementById("passwordText"),
  145. input: document.getElementById("password"),
  146. submitButton: document.getElementById("passwordSubmit"),
  147. cancelButton: document.getElementById("passwordCancel")
  148. },
  149. documentProperties: {
  150. overlayName: "documentPropertiesOverlay",
  151. container: document.getElementById("documentPropertiesOverlay"),
  152. closeButton: document.getElementById("documentPropertiesClose"),
  153. fields: {
  154. fileName: document.getElementById("fileNameField"),
  155. fileSize: document.getElementById("fileSizeField"),
  156. title: document.getElementById("titleField"),
  157. author: document.getElementById("authorField"),
  158. subject: document.getElementById("subjectField"),
  159. keywords: document.getElementById("keywordsField"),
  160. creationDate: document.getElementById("creationDateField"),
  161. modificationDate: document.getElementById("modificationDateField"),
  162. creator: document.getElementById("creatorField"),
  163. producer: document.getElementById("producerField"),
  164. version: document.getElementById("versionField"),
  165. pageCount: document.getElementById("pageCountField"),
  166. pageSize: document.getElementById("pageSizeField"),
  167. linearized: document.getElementById("linearizedField")
  168. }
  169. },
  170. errorWrapper: {
  171. container: document.getElementById("errorWrapper"),
  172. errorMessage: document.getElementById("errorMessage"),
  173. closeButton: document.getElementById("errorClose"),
  174. errorMoreInfo: document.getElementById("errorMoreInfo"),
  175. moreInfoButton: document.getElementById("errorShowMore"),
  176. lessInfoButton: document.getElementById("errorShowLess")
  177. },
  178. printContainer: document.getElementById("printContainer"),
  179. openFileInputName: "fileInput",
  180. debuggerScriptPath: "./debugger.js"
  181. };
  182. }
  183. function webViewerLoad() {
  184. var config = getViewerConfiguration();
  185. var event = document.createEvent("CustomEvent");
  186. event.initCustomEvent("webviewerloaded", true, true, {
  187. source: window
  188. });
  189. try {
  190. parent.document.dispatchEvent(event);
  191. } catch (ex) {
  192. console.error("webviewerloaded: ".concat(ex));
  193. document.dispatchEvent(event);
  194. }
  195. _app.PDFViewerApplication.run(config);
  196. }
  197. if (document.readyState === "interactive" || document.readyState === "complete") {
  198. webViewerLoad();
  199. } else {
  200. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  201. }
  202. /***/ }),
  203. /* 1 */
  204. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  205. Object.defineProperty(exports, "__esModule", ({
  206. value: true
  207. }));
  208. exports.OptionKind = exports.AppOptions = void 0;
  209. var _viewer_compatibility = __webpack_require__(2);
  210. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  211. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  212. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  213. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  214. var OptionKind = {
  215. VIEWER: 0x02,
  216. API: 0x04,
  217. WORKER: 0x08,
  218. PREFERENCE: 0x80
  219. };
  220. exports.OptionKind = OptionKind;
  221. var defaultOptions = {
  222. cursorToolOnLoad: {
  223. value: 0,
  224. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  225. },
  226. defaultUrl: {
  227. value: "compressed.tracemonkey-pldi-09.pdf",
  228. kind: OptionKind.VIEWER
  229. },
  230. defaultZoomValue: {
  231. value: "",
  232. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  233. },
  234. disableHistory: {
  235. value: false,
  236. kind: OptionKind.VIEWER
  237. },
  238. disablePageLabels: {
  239. value: false,
  240. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  241. },
  242. enablePermissions: {
  243. value: false,
  244. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  245. },
  246. enablePrintAutoRotate: {
  247. value: false,
  248. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  249. },
  250. enableScripting: {
  251. value: false,
  252. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  253. },
  254. enableWebGL: {
  255. value: false,
  256. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  257. },
  258. externalLinkRel: {
  259. value: "noopener noreferrer nofollow",
  260. kind: OptionKind.VIEWER
  261. },
  262. externalLinkTarget: {
  263. value: 0,
  264. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  265. },
  266. historyUpdateUrl: {
  267. value: false,
  268. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  269. },
  270. ignoreDestinationZoom: {
  271. value: false,
  272. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  273. },
  274. imageResourcesPath: {
  275. value: "./images/",
  276. kind: OptionKind.VIEWER
  277. },
  278. maxCanvasPixels: {
  279. value: 16777216,
  280. compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
  281. kind: OptionKind.VIEWER
  282. },
  283. pdfBugEnabled: {
  284. value: false,
  285. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  286. },
  287. printResolution: {
  288. value: 150,
  289. kind: OptionKind.VIEWER
  290. },
  291. renderer: {
  292. value: "canvas",
  293. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  294. },
  295. renderInteractiveForms: {
  296. value: true,
  297. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  298. },
  299. sidebarViewOnLoad: {
  300. value: -1,
  301. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  302. },
  303. scrollModeOnLoad: {
  304. value: -1,
  305. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  306. },
  307. spreadModeOnLoad: {
  308. value: -1,
  309. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  310. },
  311. textLayerMode: {
  312. value: 1,
  313. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  314. },
  315. useOnlyCssZoom: {
  316. value: false,
  317. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  318. },
  319. viewerCssTheme: {
  320. value: 0,
  321. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  322. },
  323. viewOnLoad: {
  324. value: 0,
  325. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  326. },
  327. cMapPacked: {
  328. value: true,
  329. kind: OptionKind.API
  330. },
  331. cMapUrl: {
  332. value: "../web/cmaps/",
  333. kind: OptionKind.API
  334. },
  335. disableAutoFetch: {
  336. value: false,
  337. kind: OptionKind.API + OptionKind.PREFERENCE
  338. },
  339. disableFontFace: {
  340. value: false,
  341. kind: OptionKind.API + OptionKind.PREFERENCE
  342. },
  343. disableRange: {
  344. value: false,
  345. kind: OptionKind.API + OptionKind.PREFERENCE
  346. },
  347. disableStream: {
  348. value: false,
  349. kind: OptionKind.API + OptionKind.PREFERENCE
  350. },
  351. docBaseUrl: {
  352. value: "",
  353. kind: OptionKind.API
  354. },
  355. fontExtraProperties: {
  356. value: false,
  357. kind: OptionKind.API
  358. },
  359. isEvalSupported: {
  360. value: true,
  361. kind: OptionKind.API
  362. },
  363. maxImageSize: {
  364. value: -1,
  365. kind: OptionKind.API
  366. },
  367. pdfBug: {
  368. value: false,
  369. kind: OptionKind.API
  370. },
  371. verbosity: {
  372. value: 1,
  373. kind: OptionKind.API
  374. },
  375. workerPort: {
  376. value: null,
  377. kind: OptionKind.WORKER
  378. },
  379. workerSrc: {
  380. value: "../build/pdf.worker.js",
  381. kind: OptionKind.WORKER
  382. }
  383. };
  384. {
  385. defaultOptions.disablePreferences = {
  386. value: false,
  387. kind: OptionKind.VIEWER
  388. };
  389. defaultOptions.locale = {
  390. value: typeof navigator !== "undefined" ? navigator.language : "en-US",
  391. kind: OptionKind.VIEWER
  392. };
  393. defaultOptions.sandboxBundleSrc = {
  394. value: "../build/pdf.sandbox.js",
  395. kind: OptionKind.VIEWER
  396. };
  397. }
  398. var userOptions = Object.create(null);
  399. var AppOptions = /*#__PURE__*/function () {
  400. function AppOptions() {
  401. _classCallCheck(this, AppOptions);
  402. throw new Error("Cannot initialize AppOptions.");
  403. }
  404. _createClass(AppOptions, null, [{
  405. key: "get",
  406. value: function get(name) {
  407. var userOption = userOptions[name];
  408. if (userOption !== undefined) {
  409. return userOption;
  410. }
  411. var defaultOption = defaultOptions[name];
  412. if (defaultOption !== undefined) {
  413. return defaultOption.compatibility || defaultOption.value;
  414. }
  415. return undefined;
  416. }
  417. }, {
  418. key: "getAll",
  419. value: function getAll() {
  420. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  421. var options = Object.create(null);
  422. for (var name in defaultOptions) {
  423. var defaultOption = defaultOptions[name];
  424. if (kind) {
  425. if ((kind & defaultOption.kind) === 0) {
  426. continue;
  427. }
  428. if (kind === OptionKind.PREFERENCE) {
  429. var value = defaultOption.value,
  430. valueType = _typeof(value);
  431. if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
  432. options[name] = value;
  433. continue;
  434. }
  435. throw new Error("Invalid type for preference: ".concat(name));
  436. }
  437. }
  438. var userOption = userOptions[name];
  439. options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
  440. }
  441. return options;
  442. }
  443. }, {
  444. key: "set",
  445. value: function set(name, value) {
  446. userOptions[name] = value;
  447. }
  448. }, {
  449. key: "setAll",
  450. value: function setAll(options) {
  451. for (var name in options) {
  452. userOptions[name] = options[name];
  453. }
  454. }
  455. }, {
  456. key: "remove",
  457. value: function remove(name) {
  458. delete userOptions[name];
  459. }
  460. }]);
  461. return AppOptions;
  462. }();
  463. exports.AppOptions = AppOptions;
  464. /***/ }),
  465. /* 2 */
  466. /***/ ((__unused_webpack_module, exports) => {
  467. Object.defineProperty(exports, "__esModule", ({
  468. value: true
  469. }));
  470. exports.viewerCompatibilityParams = void 0;
  471. var compatibilityParams = Object.create(null);
  472. {
  473. var userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
  474. var platform = typeof navigator !== "undefined" && navigator.platform || "";
  475. var maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
  476. var isAndroid = /Android/.test(userAgent);
  477. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  478. var isIOSChrome = /CriOS/.test(userAgent);
  479. (function checkOnBlobSupport() {
  480. if (isIOSChrome) {
  481. compatibilityParams.disableCreateObjectURL = true;
  482. }
  483. })();
  484. (function checkCanvasSizeLimitation() {
  485. if (isIOS || isAndroid) {
  486. compatibilityParams.maxCanvasPixels = 5242880;
  487. }
  488. })();
  489. }
  490. var viewerCompatibilityParams = Object.freeze(compatibilityParams);
  491. exports.viewerCompatibilityParams = viewerCompatibilityParams;
  492. /***/ }),
  493. /* 3 */
  494. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  495. Object.defineProperty(exports, "__esModule", ({
  496. value: true
  497. }));
  498. exports.PDFViewerApplication = exports.PDFPrintServiceFactory = exports.DefaultExternalServices = void 0;
  499. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  500. var _ui_utils = __webpack_require__(6);
  501. var _app_options = __webpack_require__(1);
  502. var _pdfjsLib = __webpack_require__(7);
  503. var _pdf_cursor_tools = __webpack_require__(8);
  504. var _pdf_rendering_queue = __webpack_require__(10);
  505. var _overlay_manager = __webpack_require__(11);
  506. var _password_prompt = __webpack_require__(12);
  507. var _pdf_attachment_viewer = __webpack_require__(13);
  508. var _pdf_document_properties = __webpack_require__(15);
  509. var _pdf_find_bar = __webpack_require__(16);
  510. var _pdf_find_controller = __webpack_require__(17);
  511. var _pdf_history = __webpack_require__(19);
  512. var _pdf_layer_viewer = __webpack_require__(20);
  513. var _pdf_link_service = __webpack_require__(21);
  514. var _pdf_outline_viewer = __webpack_require__(22);
  515. var _pdf_presentation_mode = __webpack_require__(23);
  516. var _pdf_sidebar = __webpack_require__(24);
  517. var _pdf_sidebar_resizer = __webpack_require__(25);
  518. var _pdf_thumbnail_viewer = __webpack_require__(26);
  519. var _pdf_viewer = __webpack_require__(28);
  520. var _secondary_toolbar = __webpack_require__(33);
  521. var _toolbar = __webpack_require__(35);
  522. var _viewer_compatibility = __webpack_require__(2);
  523. var _view_history = __webpack_require__(36);
  524. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  525. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  526. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  527. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  528. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  529. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  530. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  531. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  532. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  533. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  534. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  535. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  536. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  537. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  538. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  539. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  540. var DEFAULT_SCALE_DELTA = 1.1;
  541. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  542. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  543. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  544. var ENABLE_PERMISSIONS_CLASS = "enablePermissions";
  545. var ViewOnLoad = {
  546. UNKNOWN: -1,
  547. PREVIOUS: 0,
  548. INITIAL: 1
  549. };
  550. var ViewerCssTheme = {
  551. AUTOMATIC: 0,
  552. LIGHT: 1,
  553. DARK: 2
  554. };
  555. var KNOWN_VERSIONS = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2.0", "2.1", "2.2", "2.3"];
  556. var KNOWN_GENERATORS = ["acrobat distiller", "acrobat pdfwriter", "adobe livecycle", "adobe pdf library", "adobe photoshop", "ghostscript", "tcpdf", "cairo", "dvipdfm", "dvips", "pdftex", "pdfkit", "itext", "prince", "quarkxpress", "mac os x", "microsoft", "openoffice", "oracle", "luradocument", "pdf-xchange", "antenna house", "aspose.cells", "fpdf"];
  557. var DefaultExternalServices = /*#__PURE__*/function () {
  558. function DefaultExternalServices() {
  559. _classCallCheck(this, DefaultExternalServices);
  560. throw new Error("Cannot initialize DefaultExternalServices.");
  561. }
  562. _createClass(DefaultExternalServices, null, [{
  563. key: "updateFindControlState",
  564. value: function updateFindControlState(data) {}
  565. }, {
  566. key: "updateFindMatchesCount",
  567. value: function updateFindMatchesCount(data) {}
  568. }, {
  569. key: "initPassiveLoading",
  570. value: function initPassiveLoading(callbacks) {}
  571. }, {
  572. key: "fallback",
  573. value: function () {
  574. var _fallback = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(data) {
  575. return _regenerator["default"].wrap(function _callee$(_context) {
  576. while (1) {
  577. switch (_context.prev = _context.next) {
  578. case 0:
  579. case "end":
  580. return _context.stop();
  581. }
  582. }
  583. }, _callee);
  584. }));
  585. function fallback(_x) {
  586. return _fallback.apply(this, arguments);
  587. }
  588. return fallback;
  589. }()
  590. }, {
  591. key: "reportTelemetry",
  592. value: function reportTelemetry(data) {}
  593. }, {
  594. key: "createDownloadManager",
  595. value: function createDownloadManager(options) {
  596. throw new Error("Not implemented: createDownloadManager");
  597. }
  598. }, {
  599. key: "createPreferences",
  600. value: function createPreferences() {
  601. throw new Error("Not implemented: createPreferences");
  602. }
  603. }, {
  604. key: "createL10n",
  605. value: function createL10n(options) {
  606. throw new Error("Not implemented: createL10n");
  607. }
  608. }, {
  609. key: "createScripting",
  610. value: function createScripting(options) {
  611. throw new Error("Not implemented: createScripting");
  612. }
  613. }, {
  614. key: "supportsIntegratedFind",
  615. get: function get() {
  616. return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false);
  617. }
  618. }, {
  619. key: "supportsDocumentFonts",
  620. get: function get() {
  621. return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts", true);
  622. }
  623. }, {
  624. key: "supportedMouseWheelZoomModifierKeys",
  625. get: function get() {
  626. return (0, _pdfjsLib.shadow)(this, "supportedMouseWheelZoomModifierKeys", {
  627. ctrlKey: true,
  628. metaKey: true
  629. });
  630. }
  631. }, {
  632. key: "isInAutomation",
  633. get: function get() {
  634. return (0, _pdfjsLib.shadow)(this, "isInAutomation", false);
  635. }
  636. }]);
  637. return DefaultExternalServices;
  638. }();
  639. exports.DefaultExternalServices = DefaultExternalServices;
  640. var PDFViewerApplication = {
  641. initialBookmark: document.location.hash.substring(1),
  642. _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(),
  643. fellback: false,
  644. appConfig: null,
  645. pdfDocument: null,
  646. pdfLoadingTask: null,
  647. printService: null,
  648. pdfViewer: null,
  649. pdfThumbnailViewer: null,
  650. pdfRenderingQueue: null,
  651. pdfPresentationMode: null,
  652. pdfDocumentProperties: null,
  653. pdfLinkService: null,
  654. pdfHistory: null,
  655. pdfSidebar: null,
  656. pdfSidebarResizer: null,
  657. pdfOutlineViewer: null,
  658. pdfAttachmentViewer: null,
  659. pdfLayerViewer: null,
  660. pdfCursorTools: null,
  661. store: null,
  662. downloadManager: null,
  663. overlayManager: null,
  664. preferences: null,
  665. toolbar: null,
  666. secondaryToolbar: null,
  667. eventBus: null,
  668. l10n: null,
  669. isInitialViewSet: false,
  670. downloadComplete: false,
  671. isViewerEmbedded: window.parent !== window,
  672. url: "",
  673. baseUrl: "",
  674. externalServices: DefaultExternalServices,
  675. _boundEvents: Object.create(null),
  676. documentInfo: null,
  677. metadata: null,
  678. _contentDispositionFilename: null,
  679. _contentLength: null,
  680. triggerDelayedFallback: null,
  681. _saveInProgress: false,
  682. _wheelUnusedTicks: 0,
  683. _idleCallbacks: new Set(),
  684. _scriptingInstance: null,
  685. _mouseState: Object.create(null),
  686. initialize: function initialize(appConfig) {
  687. var _this = this;
  688. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  689. var appContainer;
  690. return _regenerator["default"].wrap(function _callee2$(_context2) {
  691. while (1) {
  692. switch (_context2.prev = _context2.next) {
  693. case 0:
  694. _this.preferences = _this.externalServices.createPreferences();
  695. _this.appConfig = appConfig;
  696. _context2.next = 4;
  697. return _this._readPreferences();
  698. case 4:
  699. _context2.next = 6;
  700. return _this._parseHashParameters();
  701. case 6:
  702. _this._forceCssTheme();
  703. _context2.next = 9;
  704. return _this._initializeL10n();
  705. case 9:
  706. if (_this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdfjsLib.LinkTarget.NONE) {
  707. _app_options.AppOptions.set("externalLinkTarget", _pdfjsLib.LinkTarget.TOP);
  708. }
  709. _context2.next = 12;
  710. return _this._initializeViewerComponents();
  711. case 12:
  712. _this.bindEvents();
  713. _this.bindWindowEvents();
  714. appContainer = appConfig.appContainer || document.documentElement;
  715. _this.l10n.translate(appContainer).then(function () {
  716. _this.eventBus.dispatch("localized", {
  717. source: _this
  718. });
  719. });
  720. _this._initializedCapability.resolve();
  721. case 17:
  722. case "end":
  723. return _context2.stop();
  724. }
  725. }
  726. }, _callee2);
  727. }))();
  728. },
  729. _readPreferences: function _readPreferences() {
  730. var _this2 = this;
  731. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  732. return _regenerator["default"].wrap(function _callee3$(_context3) {
  733. while (1) {
  734. switch (_context3.prev = _context3.next) {
  735. case 0:
  736. if (!_app_options.AppOptions.get("disablePreferences")) {
  737. _context3.next = 2;
  738. break;
  739. }
  740. return _context3.abrupt("return");
  741. case 2:
  742. _context3.prev = 2;
  743. _context3.t0 = _app_options.AppOptions;
  744. _context3.next = 6;
  745. return _this2.preferences.getAll();
  746. case 6:
  747. _context3.t1 = _context3.sent;
  748. _context3.t0.setAll.call(_context3.t0, _context3.t1);
  749. _context3.next = 13;
  750. break;
  751. case 10:
  752. _context3.prev = 10;
  753. _context3.t2 = _context3["catch"](2);
  754. console.error("_readPreferences: \"".concat(_context3.t2 === null || _context3.t2 === void 0 ? void 0 : _context3.t2.message, "\"."));
  755. case 13:
  756. case "end":
  757. return _context3.stop();
  758. }
  759. }
  760. }, _callee3, null, [[2, 10]]);
  761. }))();
  762. },
  763. _parseHashParameters: function _parseHashParameters() {
  764. var _this3 = this;
  765. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  766. var hash, hashParams, waitOn, viewer, enabled;
  767. return _regenerator["default"].wrap(function _callee4$(_context4) {
  768. while (1) {
  769. switch (_context4.prev = _context4.next) {
  770. case 0:
  771. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  772. _context4.next = 2;
  773. break;
  774. }
  775. return _context4.abrupt("return", undefined);
  776. case 2:
  777. hash = document.location.hash.substring(1);
  778. if (hash) {
  779. _context4.next = 5;
  780. break;
  781. }
  782. return _context4.abrupt("return", undefined);
  783. case 5:
  784. hashParams = (0, _ui_utils.parseQueryString)(hash), waitOn = [];
  785. if ("disableworker" in hashParams && hashParams.disableworker === "true") {
  786. waitOn.push(loadFakeWorker());
  787. }
  788. if ("disablerange" in hashParams) {
  789. _app_options.AppOptions.set("disableRange", hashParams.disablerange === "true");
  790. }
  791. if ("disablestream" in hashParams) {
  792. _app_options.AppOptions.set("disableStream", hashParams.disablestream === "true");
  793. }
  794. if ("disableautofetch" in hashParams) {
  795. _app_options.AppOptions.set("disableAutoFetch", hashParams.disableautofetch === "true");
  796. }
  797. if ("disablefontface" in hashParams) {
  798. _app_options.AppOptions.set("disableFontFace", hashParams.disablefontface === "true");
  799. }
  800. if ("disablehistory" in hashParams) {
  801. _app_options.AppOptions.set("disableHistory", hashParams.disablehistory === "true");
  802. }
  803. if ("webgl" in hashParams) {
  804. _app_options.AppOptions.set("enableWebGL", hashParams.webgl === "true");
  805. }
  806. if ("verbosity" in hashParams) {
  807. _app_options.AppOptions.set("verbosity", hashParams.verbosity | 0);
  808. }
  809. if (!("textlayer" in hashParams)) {
  810. _context4.next = 23;
  811. break;
  812. }
  813. _context4.t0 = hashParams.textlayer;
  814. _context4.next = _context4.t0 === "off" ? 18 : _context4.t0 === "visible" ? 20 : _context4.t0 === "shadow" ? 20 : _context4.t0 === "hover" ? 20 : 23;
  815. break;
  816. case 18:
  817. _app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
  818. return _context4.abrupt("break", 23);
  819. case 20:
  820. viewer = _this3.appConfig.viewerContainer;
  821. viewer.classList.add("textLayer-" + hashParams.textlayer);
  822. return _context4.abrupt("break", 23);
  823. case 23:
  824. if ("pdfbug" in hashParams) {
  825. _app_options.AppOptions.set("pdfBug", true);
  826. _app_options.AppOptions.set("fontExtraProperties", true);
  827. enabled = hashParams.pdfbug.split(",");
  828. waitOn.push(loadAndEnablePDFBug(enabled));
  829. }
  830. if ("locale" in hashParams) {
  831. _app_options.AppOptions.set("locale", hashParams.locale);
  832. }
  833. if (!(waitOn.length === 0)) {
  834. _context4.next = 27;
  835. break;
  836. }
  837. return _context4.abrupt("return", undefined);
  838. case 27:
  839. return _context4.abrupt("return", Promise.all(waitOn)["catch"](function (reason) {
  840. console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
  841. }));
  842. case 28:
  843. case "end":
  844. return _context4.stop();
  845. }
  846. }
  847. }, _callee4);
  848. }))();
  849. },
  850. _initializeL10n: function _initializeL10n() {
  851. var _this4 = this;
  852. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
  853. var dir;
  854. return _regenerator["default"].wrap(function _callee5$(_context5) {
  855. while (1) {
  856. switch (_context5.prev = _context5.next) {
  857. case 0:
  858. _this4.l10n = _this4.externalServices.createL10n({
  859. locale: _app_options.AppOptions.get("locale")
  860. });
  861. _context5.next = 3;
  862. return _this4.l10n.getDirection();
  863. case 3:
  864. dir = _context5.sent;
  865. document.getElementsByTagName("html")[0].dir = dir;
  866. case 5:
  867. case "end":
  868. return _context5.stop();
  869. }
  870. }
  871. }, _callee5);
  872. }))();
  873. },
  874. _forceCssTheme: function _forceCssTheme() {
  875. var cssTheme = _app_options.AppOptions.get("viewerCssTheme");
  876. if (cssTheme === ViewerCssTheme.AUTOMATIC || !Object.values(ViewerCssTheme).includes(cssTheme)) {
  877. return;
  878. }
  879. try {
  880. var styleSheet = document.styleSheets[0];
  881. var cssRules = (styleSheet === null || styleSheet === void 0 ? void 0 : styleSheet.cssRules) || [];
  882. for (var i = 0, ii = cssRules.length; i < ii; i++) {
  883. var _rule$media;
  884. var rule = cssRules[i];
  885. if (rule instanceof CSSMediaRule && ((_rule$media = rule.media) === null || _rule$media === void 0 ? void 0 : _rule$media[0]) === "(prefers-color-scheme: dark)") {
  886. if (cssTheme === ViewerCssTheme.LIGHT) {
  887. styleSheet.deleteRule(i);
  888. return;
  889. }
  890. var darkRules = /^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/.exec(rule.cssText);
  891. if (darkRules !== null && darkRules !== void 0 && darkRules[1]) {
  892. styleSheet.deleteRule(i);
  893. styleSheet.insertRule(darkRules[1], i);
  894. }
  895. return;
  896. }
  897. }
  898. } catch (reason) {
  899. console.error("_forceCssTheme: \"".concat(reason === null || reason === void 0 ? void 0 : reason.message, "\"."));
  900. }
  901. },
  902. _initializeViewerComponents: function _initializeViewerComponents() {
  903. var _this5 = this;
  904. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  905. var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer;
  906. return _regenerator["default"].wrap(function _callee6$(_context6) {
  907. while (1) {
  908. switch (_context6.prev = _context6.next) {
  909. case 0:
  910. appConfig = _this5.appConfig;
  911. eventBus = appConfig.eventBus || new _ui_utils.EventBus({
  912. isInAutomation: _this5.externalServices.isInAutomation
  913. });
  914. _this5.eventBus = eventBus;
  915. _this5.overlayManager = new _overlay_manager.OverlayManager();
  916. pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  917. pdfRenderingQueue.onIdle = _this5.cleanup.bind(_this5);
  918. _this5.pdfRenderingQueue = pdfRenderingQueue;
  919. pdfLinkService = new _pdf_link_service.PDFLinkService({
  920. eventBus: eventBus,
  921. externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"),
  922. externalLinkRel: _app_options.AppOptions.get("externalLinkRel"),
  923. ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom")
  924. });
  925. _this5.pdfLinkService = pdfLinkService;
  926. downloadManager = _this5.externalServices.createDownloadManager();
  927. _this5.downloadManager = downloadManager;
  928. findController = new _pdf_find_controller.PDFFindController({
  929. linkService: pdfLinkService,
  930. eventBus: eventBus
  931. });
  932. _this5.findController = findController;
  933. container = appConfig.mainContainer;
  934. viewer = appConfig.viewerContainer;
  935. _this5.pdfViewer = new _pdf_viewer.PDFViewer({
  936. container: container,
  937. viewer: viewer,
  938. eventBus: eventBus,
  939. renderingQueue: pdfRenderingQueue,
  940. linkService: pdfLinkService,
  941. downloadManager: downloadManager,
  942. findController: findController,
  943. renderer: _app_options.AppOptions.get("renderer"),
  944. enableWebGL: _app_options.AppOptions.get("enableWebGL"),
  945. l10n: _this5.l10n,
  946. textLayerMode: _app_options.AppOptions.get("textLayerMode"),
  947. imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"),
  948. renderInteractiveForms: _app_options.AppOptions.get("renderInteractiveForms"),
  949. enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"),
  950. useOnlyCssZoom: _app_options.AppOptions.get("useOnlyCssZoom"),
  951. maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels"),
  952. enableScripting: _app_options.AppOptions.get("enableScripting"),
  953. mouseState: _this5._mouseState
  954. });
  955. pdfRenderingQueue.setViewer(_this5.pdfViewer);
  956. pdfLinkService.setViewer(_this5.pdfViewer);
  957. _this5.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  958. container: appConfig.sidebar.thumbnailView,
  959. eventBus: eventBus,
  960. renderingQueue: pdfRenderingQueue,
  961. linkService: pdfLinkService,
  962. l10n: _this5.l10n
  963. });
  964. pdfRenderingQueue.setThumbnailViewer(_this5.pdfThumbnailViewer);
  965. _this5.pdfHistory = new _pdf_history.PDFHistory({
  966. linkService: pdfLinkService,
  967. eventBus: eventBus
  968. });
  969. pdfLinkService.setHistory(_this5.pdfHistory);
  970. if (!_this5.supportsIntegratedFind) {
  971. _this5.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, _this5.l10n);
  972. }
  973. _this5.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this5.overlayManager, eventBus, _this5.l10n);
  974. _this5.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  975. container: container,
  976. eventBus: eventBus,
  977. cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad")
  978. });
  979. _this5.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, _this5.l10n);
  980. _this5.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  981. if (_this5.supportsFullscreen) {
  982. _this5.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  983. container: container,
  984. pdfViewer: _this5.pdfViewer,
  985. eventBus: eventBus,
  986. contextMenuItems: appConfig.fullscreen
  987. });
  988. }
  989. _this5.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this5.overlayManager, _this5.l10n);
  990. _this5.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  991. container: appConfig.sidebar.outlineView,
  992. eventBus: eventBus,
  993. linkService: pdfLinkService
  994. });
  995. _this5.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  996. container: appConfig.sidebar.attachmentsView,
  997. eventBus: eventBus,
  998. downloadManager: downloadManager
  999. });
  1000. _this5.pdfLayerViewer = new _pdf_layer_viewer.PDFLayerViewer({
  1001. container: appConfig.sidebar.layersView,
  1002. eventBus: eventBus,
  1003. l10n: _this5.l10n
  1004. });
  1005. _this5.pdfSidebar = new _pdf_sidebar.PDFSidebar({
  1006. elements: appConfig.sidebar,
  1007. pdfViewer: _this5.pdfViewer,
  1008. pdfThumbnailViewer: _this5.pdfThumbnailViewer,
  1009. eventBus: eventBus,
  1010. l10n: _this5.l10n
  1011. });
  1012. _this5.pdfSidebar.onToggled = _this5.forceRendering.bind(_this5);
  1013. _this5.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, _this5.l10n);
  1014. case 35:
  1015. case "end":
  1016. return _context6.stop();
  1017. }
  1018. }
  1019. }, _callee6);
  1020. }))();
  1021. },
  1022. run: function run(config) {
  1023. this.initialize(config).then(webViewerInitialized);
  1024. },
  1025. get initialized() {
  1026. return this._initializedCapability.settled;
  1027. },
  1028. get initializedPromise() {
  1029. return this._initializedCapability.promise;
  1030. },
  1031. zoomIn: function zoomIn(ticks) {
  1032. if (this.pdfViewer.isInPresentationMode) {
  1033. return;
  1034. }
  1035. var newScale = this.pdfViewer.currentScale;
  1036. do {
  1037. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  1038. newScale = Math.ceil(newScale * 10) / 10;
  1039. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  1040. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  1041. this.pdfViewer.currentScaleValue = newScale;
  1042. },
  1043. zoomOut: function zoomOut(ticks) {
  1044. if (this.pdfViewer.isInPresentationMode) {
  1045. return;
  1046. }
  1047. var newScale = this.pdfViewer.currentScale;
  1048. do {
  1049. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  1050. newScale = Math.floor(newScale * 10) / 10;
  1051. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  1052. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  1053. this.pdfViewer.currentScaleValue = newScale;
  1054. },
  1055. zoomReset: function zoomReset() {
  1056. if (this.pdfViewer.isInPresentationMode) {
  1057. return;
  1058. }
  1059. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1060. },
  1061. get pagesCount() {
  1062. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  1063. },
  1064. get page() {
  1065. return this.pdfViewer.currentPageNumber;
  1066. },
  1067. set page(val) {
  1068. this.pdfViewer.currentPageNumber = val;
  1069. },
  1070. get supportsPrinting() {
  1071. return PDFPrintServiceFactory.instance.supportsPrinting;
  1072. },
  1073. get supportsFullscreen() {
  1074. var support;
  1075. var doc = document.documentElement;
  1076. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen);
  1077. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false) {
  1078. support = false;
  1079. }
  1080. return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", support);
  1081. },
  1082. get supportsIntegratedFind() {
  1083. return this.externalServices.supportsIntegratedFind;
  1084. },
  1085. get supportsDocumentFonts() {
  1086. return this.externalServices.supportsDocumentFonts;
  1087. },
  1088. get loadingBar() {
  1089. var bar = new _ui_utils.ProgressBar("#loadingBar");
  1090. return (0, _pdfjsLib.shadow)(this, "loadingBar", bar);
  1091. },
  1092. get supportedMouseWheelZoomModifierKeys() {
  1093. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  1094. },
  1095. initPassiveLoading: function initPassiveLoading() {
  1096. throw new Error("Not implemented: initPassiveLoading");
  1097. },
  1098. setTitleUsingUrl: function setTitleUsingUrl() {
  1099. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  1100. this.url = url;
  1101. this.baseUrl = url.split("#")[0];
  1102. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, "");
  1103. if (!title) {
  1104. try {
  1105. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  1106. } catch (ex) {
  1107. title = url;
  1108. }
  1109. }
  1110. this.setTitle(title);
  1111. },
  1112. setTitle: function setTitle(title) {
  1113. if (this.isViewerEmbedded) {
  1114. return;
  1115. }
  1116. document.title = title;
  1117. },
  1118. get _docFilename() {
  1119. return this._contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  1120. },
  1121. _cancelIdleCallbacks: function _cancelIdleCallbacks() {
  1122. if (!this._idleCallbacks.size) {
  1123. return;
  1124. }
  1125. var _iterator = _createForOfIteratorHelper(this._idleCallbacks),
  1126. _step;
  1127. try {
  1128. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  1129. var callback = _step.value;
  1130. window.cancelIdleCallback(callback);
  1131. }
  1132. } catch (err) {
  1133. _iterator.e(err);
  1134. } finally {
  1135. _iterator.f();
  1136. }
  1137. this._idleCallbacks.clear();
  1138. },
  1139. _destroyScriptingInstance: function _destroyScriptingInstance() {
  1140. var _this6 = this;
  1141. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
  1142. var _this6$_scriptingInst, scripting, internalEvents, domEvents, _iterator2, _step2, _step2$value, name, listener, _iterator3, _step3, _step3$value, _name, _listener;
  1143. return _regenerator["default"].wrap(function _callee7$(_context7) {
  1144. while (1) {
  1145. switch (_context7.prev = _context7.next) {
  1146. case 0:
  1147. if (_this6._scriptingInstance) {
  1148. _context7.next = 2;
  1149. break;
  1150. }
  1151. return _context7.abrupt("return");
  1152. case 2:
  1153. _this6$_scriptingInst = _this6._scriptingInstance, scripting = _this6$_scriptingInst.scripting, internalEvents = _this6$_scriptingInst.internalEvents, domEvents = _this6$_scriptingInst.domEvents;
  1154. _context7.prev = 3;
  1155. _context7.next = 6;
  1156. return scripting.destroySandbox();
  1157. case 6:
  1158. _context7.next = 10;
  1159. break;
  1160. case 8:
  1161. _context7.prev = 8;
  1162. _context7.t0 = _context7["catch"](3);
  1163. case 10:
  1164. _iterator2 = _createForOfIteratorHelper(internalEvents);
  1165. try {
  1166. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  1167. _step2$value = _slicedToArray(_step2.value, 2), name = _step2$value[0], listener = _step2$value[1];
  1168. _this6.eventBus._off(name, listener);
  1169. }
  1170. } catch (err) {
  1171. _iterator2.e(err);
  1172. } finally {
  1173. _iterator2.f();
  1174. }
  1175. internalEvents.clear();
  1176. _iterator3 = _createForOfIteratorHelper(domEvents);
  1177. try {
  1178. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  1179. _step3$value = _slicedToArray(_step3.value, 2), _name = _step3$value[0], _listener = _step3$value[1];
  1180. window.removeEventListener(_name, _listener);
  1181. }
  1182. } catch (err) {
  1183. _iterator3.e(err);
  1184. } finally {
  1185. _iterator3.f();
  1186. }
  1187. domEvents.clear();
  1188. delete _this6._mouseState.isDown;
  1189. _this6._scriptingInstance = null;
  1190. case 18:
  1191. case "end":
  1192. return _context7.stop();
  1193. }
  1194. }
  1195. }, _callee7, null, [[3, 8]]);
  1196. }))();
  1197. },
  1198. close: function close() {
  1199. var _this7 = this;
  1200. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
  1201. var errorWrapper, promises;
  1202. return _regenerator["default"].wrap(function _callee8$(_context8) {
  1203. while (1) {
  1204. switch (_context8.prev = _context8.next) {
  1205. case 0:
  1206. errorWrapper = _this7.appConfig.errorWrapper.container;
  1207. errorWrapper.setAttribute("hidden", "true");
  1208. if (_this7.pdfLoadingTask) {
  1209. _context8.next = 4;
  1210. break;
  1211. }
  1212. return _context8.abrupt("return", undefined);
  1213. case 4:
  1214. promises = [];
  1215. promises.push(_this7.pdfLoadingTask.destroy());
  1216. _this7.pdfLoadingTask = null;
  1217. if (_this7.pdfDocument) {
  1218. _this7.pdfDocument = null;
  1219. _this7.pdfThumbnailViewer.setDocument(null);
  1220. _this7.pdfViewer.setDocument(null);
  1221. _this7.pdfLinkService.setDocument(null);
  1222. _this7.pdfDocumentProperties.setDocument(null);
  1223. }
  1224. webViewerResetPermissions();
  1225. _this7.store = null;
  1226. _this7.isInitialViewSet = false;
  1227. _this7.downloadComplete = false;
  1228. _this7.url = "";
  1229. _this7.baseUrl = "";
  1230. _this7.documentInfo = null;
  1231. _this7.metadata = null;
  1232. _this7._contentDispositionFilename = null;
  1233. _this7._contentLength = null;
  1234. _this7.triggerDelayedFallback = null;
  1235. _this7._saveInProgress = false;
  1236. _this7._cancelIdleCallbacks();
  1237. promises.push(_this7._destroyScriptingInstance());
  1238. _this7.pdfSidebar.reset();
  1239. _this7.pdfOutlineViewer.reset();
  1240. _this7.pdfAttachmentViewer.reset();
  1241. _this7.pdfLayerViewer.reset();
  1242. if (_this7.pdfHistory) {
  1243. _this7.pdfHistory.reset();
  1244. }
  1245. if (_this7.findBar) {
  1246. _this7.findBar.reset();
  1247. }
  1248. _this7.toolbar.reset();
  1249. _this7.secondaryToolbar.reset();
  1250. if (typeof PDFBug !== "undefined") {
  1251. PDFBug.cleanup();
  1252. }
  1253. _context8.next = 33;
  1254. return Promise.all(promises);
  1255. case 33:
  1256. return _context8.abrupt("return", undefined);
  1257. case 34:
  1258. case "end":
  1259. return _context8.stop();
  1260. }
  1261. }
  1262. }, _callee8);
  1263. }))();
  1264. },
  1265. open: function open(file, args) {
  1266. var _this8 = this;
  1267. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
  1268. var workerParameters, key, parameters, apiParameters, _key, value, _key2, loadingTask;
  1269. return _regenerator["default"].wrap(function _callee9$(_context9) {
  1270. while (1) {
  1271. switch (_context9.prev = _context9.next) {
  1272. case 0:
  1273. if (!_this8.pdfLoadingTask) {
  1274. _context9.next = 3;
  1275. break;
  1276. }
  1277. _context9.next = 3;
  1278. return _this8.close();
  1279. case 3:
  1280. workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
  1281. for (key in workerParameters) {
  1282. _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key];
  1283. }
  1284. parameters = Object.create(null);
  1285. if (typeof file === "string") {
  1286. _this8.setTitleUsingUrl(file);
  1287. parameters.url = file;
  1288. } else if (file && "byteLength" in file) {
  1289. parameters.data = file;
  1290. } else if (file.url && file.originalUrl) {
  1291. _this8.setTitleUsingUrl(file.originalUrl);
  1292. parameters.url = file.url;
  1293. }
  1294. apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
  1295. for (_key in apiParameters) {
  1296. value = apiParameters[_key];
  1297. if (_key === "docBaseUrl" && !value) {}
  1298. parameters[_key] = value;
  1299. }
  1300. if (args) {
  1301. for (_key2 in args) {
  1302. parameters[_key2] = args[_key2];
  1303. }
  1304. }
  1305. loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  1306. _this8.pdfLoadingTask = loadingTask;
  1307. loadingTask.onPassword = function (updateCallback, reason) {
  1308. _this8.pdfLinkService.externalLinkEnabled = false;
  1309. _this8.passwordPrompt.setUpdateCallback(updateCallback, reason);
  1310. _this8.passwordPrompt.open();
  1311. };
  1312. loadingTask.onProgress = function (_ref) {
  1313. var loaded = _ref.loaded,
  1314. total = _ref.total;
  1315. _this8.progress(loaded / total);
  1316. };
  1317. loadingTask.onUnsupportedFeature = _this8.fallback.bind(_this8);
  1318. return _context9.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
  1319. _this8.load(pdfDocument);
  1320. }, function (exception) {
  1321. if (loadingTask !== _this8.pdfLoadingTask) {
  1322. return undefined;
  1323. }
  1324. var message = exception === null || exception === void 0 ? void 0 : exception.message;
  1325. var loadingErrorMessage;
  1326. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  1327. loadingErrorMessage = _this8.l10n.get("invalid_file_error", null, "Invalid or corrupted PDF file.");
  1328. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  1329. loadingErrorMessage = _this8.l10n.get("missing_file_error", null, "Missing PDF file.");
  1330. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  1331. loadingErrorMessage = _this8.l10n.get("unexpected_response_error", null, "Unexpected server response.");
  1332. } else {
  1333. loadingErrorMessage = _this8.l10n.get("loading_error", null, "An error occurred while loading the PDF.");
  1334. }
  1335. return loadingErrorMessage.then(function (msg) {
  1336. _this8.error(msg, {
  1337. message: message
  1338. });
  1339. throw exception;
  1340. });
  1341. }));
  1342. case 16:
  1343. case "end":
  1344. return _context9.stop();
  1345. }
  1346. }
  1347. }, _callee9);
  1348. }))();
  1349. },
  1350. download: function download() {
  1351. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  1352. _ref2$sourceEventType = _ref2.sourceEventType,
  1353. sourceEventType = _ref2$sourceEventType === void 0 ? "download" : _ref2$sourceEventType;
  1354. function downloadByUrl() {
  1355. downloadManager.downloadUrl(url, filename);
  1356. }
  1357. var downloadManager = this.downloadManager,
  1358. url = this.baseUrl,
  1359. filename = this._docFilename;
  1360. if (!this.pdfDocument || !this.downloadComplete) {
  1361. downloadByUrl();
  1362. return;
  1363. }
  1364. this.pdfDocument.getData().then(function (data) {
  1365. var blob = new Blob([data], {
  1366. type: "application/pdf"
  1367. });
  1368. downloadManager.download(blob, url, filename, sourceEventType);
  1369. })["catch"](downloadByUrl);
  1370. },
  1371. save: function save() {
  1372. var _arguments = arguments,
  1373. _this9 = this;
  1374. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
  1375. var _this9$_scriptingInst;
  1376. var _ref3, _ref3$sourceEventType, sourceEventType, downloadManager, url, filename;
  1377. return _regenerator["default"].wrap(function _callee11$(_context11) {
  1378. while (1) {
  1379. switch (_context11.prev = _context11.next) {
  1380. case 0:
  1381. _ref3 = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {}, _ref3$sourceEventType = _ref3.sourceEventType, sourceEventType = _ref3$sourceEventType === void 0 ? "download" : _ref3$sourceEventType;
  1382. if (!_this9._saveInProgress) {
  1383. _context11.next = 3;
  1384. break;
  1385. }
  1386. return _context11.abrupt("return");
  1387. case 3:
  1388. downloadManager = _this9.downloadManager, url = _this9.baseUrl, filename = _this9._docFilename;
  1389. if (!(!_this9.pdfDocument || !_this9.downloadComplete)) {
  1390. _context11.next = 7;
  1391. break;
  1392. }
  1393. _this9.download({
  1394. sourceEventType: sourceEventType
  1395. });
  1396. return _context11.abrupt("return");
  1397. case 7:
  1398. _this9._saveInProgress = true;
  1399. _context11.next = 10;
  1400. return (_this9$_scriptingInst = _this9._scriptingInstance) === null || _this9$_scriptingInst === void 0 ? void 0 : _this9$_scriptingInst.scripting.dispatchEventInSandbox({
  1401. id: "doc",
  1402. name: "WillSave"
  1403. });
  1404. case 10:
  1405. _this9.pdfDocument.saveDocument(_this9.pdfDocument.annotationStorage).then(function (data) {
  1406. var blob = new Blob([data], {
  1407. type: "application/pdf"
  1408. });
  1409. downloadManager.download(blob, url, filename, sourceEventType);
  1410. })["catch"](function () {
  1411. _this9.download({
  1412. sourceEventType: sourceEventType
  1413. });
  1414. })["finally"]( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee10() {
  1415. var _this9$_scriptingInst2;
  1416. return _regenerator["default"].wrap(function _callee10$(_context10) {
  1417. while (1) {
  1418. switch (_context10.prev = _context10.next) {
  1419. case 0:
  1420. _context10.next = 2;
  1421. return (_this9$_scriptingInst2 = _this9._scriptingInstance) === null || _this9$_scriptingInst2 === void 0 ? void 0 : _this9$_scriptingInst2.scripting.dispatchEventInSandbox({
  1422. id: "doc",
  1423. name: "DidSave"
  1424. });
  1425. case 2:
  1426. _this9._saveInProgress = false;
  1427. case 3:
  1428. case "end":
  1429. return _context10.stop();
  1430. }
  1431. }
  1432. }, _callee10);
  1433. })));
  1434. case 11:
  1435. case "end":
  1436. return _context11.stop();
  1437. }
  1438. }
  1439. }, _callee11);
  1440. }))();
  1441. },
  1442. downloadOrSave: function downloadOrSave(options) {
  1443. var _this$pdfDocument;
  1444. if (((_this$pdfDocument = this.pdfDocument) === null || _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage.size) > 0) {
  1445. this.save(options);
  1446. } else {
  1447. this.download(options);
  1448. }
  1449. },
  1450. _delayedFallback: function _delayedFallback(featureId) {
  1451. var _this10 = this;
  1452. this.externalServices.reportTelemetry({
  1453. type: "unsupportedFeature",
  1454. featureId: featureId
  1455. });
  1456. if (!this.triggerDelayedFallback) {
  1457. this.triggerDelayedFallback = function () {
  1458. _this10.fallback(featureId);
  1459. _this10.triggerDelayedFallback = null;
  1460. };
  1461. }
  1462. },
  1463. fallback: function fallback(featureId) {
  1464. var _this11 = this;
  1465. this.externalServices.reportTelemetry({
  1466. type: "unsupportedFeature",
  1467. featureId: featureId
  1468. });
  1469. if (this.fellback) {
  1470. return;
  1471. }
  1472. this.fellback = true;
  1473. this.externalServices.fallback({
  1474. featureId: featureId,
  1475. url: this.baseUrl
  1476. }).then(function (download) {
  1477. if (!download) {
  1478. return;
  1479. }
  1480. _this11.download({
  1481. sourceEventType: "download"
  1482. });
  1483. });
  1484. },
  1485. error: function error(message, moreInfo) {
  1486. var moreInfoText = [this.l10n.get("error_version_info", {
  1487. version: _pdfjsLib.version || "?",
  1488. build: _pdfjsLib.build || "?"
  1489. }, "PDF.js v{{version}} (build: {{build}})")];
  1490. if (moreInfo) {
  1491. moreInfoText.push(this.l10n.get("error_message", {
  1492. message: moreInfo.message
  1493. }, "Message: {{message}}"));
  1494. if (moreInfo.stack) {
  1495. moreInfoText.push(this.l10n.get("error_stack", {
  1496. stack: moreInfo.stack
  1497. }, "Stack: {{stack}}"));
  1498. } else {
  1499. if (moreInfo.filename) {
  1500. moreInfoText.push(this.l10n.get("error_file", {
  1501. file: moreInfo.filename
  1502. }, "File: {{file}}"));
  1503. }
  1504. if (moreInfo.lineNumber) {
  1505. moreInfoText.push(this.l10n.get("error_line", {
  1506. line: moreInfo.lineNumber
  1507. }, "Line: {{line}}"));
  1508. }
  1509. }
  1510. }
  1511. var errorWrapperConfig = this.appConfig.errorWrapper;
  1512. var errorWrapper = errorWrapperConfig.container;
  1513. errorWrapper.removeAttribute("hidden");
  1514. var errorMessage = errorWrapperConfig.errorMessage;
  1515. errorMessage.textContent = message;
  1516. var closeButton = errorWrapperConfig.closeButton;
  1517. closeButton.onclick = function () {
  1518. errorWrapper.setAttribute("hidden", "true");
  1519. };
  1520. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  1521. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  1522. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  1523. moreInfoButton.onclick = function () {
  1524. errorMoreInfo.removeAttribute("hidden");
  1525. moreInfoButton.setAttribute("hidden", "true");
  1526. lessInfoButton.removeAttribute("hidden");
  1527. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + "px";
  1528. };
  1529. lessInfoButton.onclick = function () {
  1530. errorMoreInfo.setAttribute("hidden", "true");
  1531. moreInfoButton.removeAttribute("hidden");
  1532. lessInfoButton.setAttribute("hidden", "true");
  1533. };
  1534. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1535. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1536. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1537. moreInfoButton.removeAttribute("hidden");
  1538. lessInfoButton.setAttribute("hidden", "true");
  1539. Promise.all(moreInfoText).then(function (parts) {
  1540. errorMoreInfo.value = parts.join("\n");
  1541. });
  1542. },
  1543. progress: function progress(level) {
  1544. var _this12 = this;
  1545. if (this.downloadComplete) {
  1546. return;
  1547. }
  1548. var percent = Math.round(level * 100);
  1549. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1550. this.loadingBar.percent = percent;
  1551. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams.disableAutoFetch : _app_options.AppOptions.get("disableAutoFetch");
  1552. if (disableAutoFetch && percent) {
  1553. if (this.disableAutoFetchLoadingBarTimeout) {
  1554. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1555. this.disableAutoFetchLoadingBarTimeout = null;
  1556. }
  1557. this.loadingBar.show();
  1558. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  1559. _this12.loadingBar.hide();
  1560. document.querySelector('#m_loading').style.display = 'none'
  1561. _this12.disableAutoFetchLoadingBarTimeout = null;
  1562. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1563. }
  1564. }
  1565. },
  1566. load: function load(pdfDocument) {
  1567. var _this13 = this;
  1568. this.pdfDocument = pdfDocument;
  1569. pdfDocument.getDownloadInfo().then(function (_ref5) {
  1570. var length = _ref5.length;
  1571. _this13._contentLength = length;
  1572. _this13.downloadComplete = true;
  1573. _this13.loadingBar.hide();
  1574. document.querySelector('#m_loading').style.display = 'none'
  1575. firstPagePromise.then(function () {
  1576. _this13.eventBus.dispatch("documentloaded", {
  1577. source: _this13
  1578. });
  1579. });
  1580. });
  1581. var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function () {});
  1582. var pageModePromise = pdfDocument.getPageMode()["catch"](function () {});
  1583. var openActionPromise = pdfDocument.getOpenAction()["catch"](function () {});
  1584. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1585. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1586. var baseDocumentUrl;
  1587. baseDocumentUrl = null;
  1588. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1589. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1590. var pdfViewer = this.pdfViewer;
  1591. pdfViewer.setDocument(pdfDocument);
  1592. var firstPagePromise = pdfViewer.firstPagePromise,
  1593. onePageRendered = pdfViewer.onePageRendered,
  1594. pagesPromise = pdfViewer.pagesPromise;
  1595. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1596. pdfThumbnailViewer.setDocument(pdfDocument);
  1597. var storedPromise = (this.store = new _view_history.ViewHistory(pdfDocument.fingerprint)).getMultiple({
  1598. page: null,
  1599. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1600. scrollLeft: "0",
  1601. scrollTop: "0",
  1602. rotation: null,
  1603. sidebarView: _ui_utils.SidebarView.UNKNOWN,
  1604. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  1605. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  1606. })["catch"](function () {
  1607. return Object.create(null);
  1608. });
  1609. firstPagePromise.then(function (pdfPage) {
  1610. _this13.loadingBar.setWidth(_this13.appConfig.viewerContainer);
  1611. _this13._initializeAnnotationStorageCallbacks(pdfDocument);
  1612. Promise.all([_ui_utils.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then( /*#__PURE__*/function () {
  1613. var _ref7 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee12(_ref6) {
  1614. var _ref8, timeStamp, stored, pageLayout, pageMode, openAction, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
  1615. return _regenerator["default"].wrap(function _callee12$(_context12) {
  1616. while (1) {
  1617. switch (_context12.prev = _context12.next) {
  1618. case 0:
  1619. _ref8 = _slicedToArray(_ref6, 5), timeStamp = _ref8[0], stored = _ref8[1], pageLayout = _ref8[2], pageMode = _ref8[3], openAction = _ref8[4];
  1620. viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
  1621. _this13._initializePdfHistory({
  1622. fingerprint: pdfDocument.fingerprint,
  1623. viewOnLoad: viewOnLoad,
  1624. initialDest: openAction && openAction.dest
  1625. });
  1626. initialBookmark = _this13.initialBookmark;
  1627. zoom = _app_options.AppOptions.get("defaultZoomValue");
  1628. hash = zoom ? "zoom=".concat(zoom) : null;
  1629. rotation = null;
  1630. sidebarView = _app_options.AppOptions.get("sidebarViewOnLoad");
  1631. scrollMode = _app_options.AppOptions.get("scrollModeOnLoad");
  1632. spreadMode = _app_options.AppOptions.get("spreadModeOnLoad");
  1633. if (stored.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  1634. hash = "page=".concat(stored.page, "&zoom=").concat(zoom || stored.zoom, ",") + "".concat(stored.scrollLeft, ",").concat(stored.scrollTop);
  1635. rotation = parseInt(stored.rotation, 10);
  1636. if (sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  1637. sidebarView = stored.sidebarView | 0;
  1638. }
  1639. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  1640. scrollMode = stored.scrollMode | 0;
  1641. }
  1642. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1643. spreadMode = stored.spreadMode | 0;
  1644. }
  1645. }
  1646. if (pageMode && sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  1647. sidebarView = apiPageModeToSidebarView(pageMode);
  1648. }
  1649. if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1650. spreadMode = apiPageLayoutToSpreadMode(pageLayout);
  1651. }
  1652. _this13.setInitialView(hash, {
  1653. rotation: rotation,
  1654. sidebarView: sidebarView,
  1655. scrollMode: scrollMode,
  1656. spreadMode: spreadMode
  1657. });
  1658. _this13.eventBus.dispatch("documentinit", {
  1659. source: _this13
  1660. });
  1661. if (!_this13.isViewerEmbedded) {
  1662. pdfViewer.focus();
  1663. }
  1664. _this13._initializePermissions(pdfDocument);
  1665. _context12.next = 19;
  1666. return Promise.race([pagesPromise, new Promise(function (resolve) {
  1667. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  1668. })]);
  1669. case 19:
  1670. if (!(!initialBookmark && !hash)) {
  1671. _context12.next = 21;
  1672. break;
  1673. }
  1674. return _context12.abrupt("return");
  1675. case 21:
  1676. if (!pdfViewer.hasEqualPageSizes) {
  1677. _context12.next = 23;
  1678. break;
  1679. }
  1680. return _context12.abrupt("return");
  1681. case 23:
  1682. _this13.initialBookmark = initialBookmark;
  1683. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  1684. _this13.setInitialView(hash);
  1685. case 26:
  1686. case "end":
  1687. return _context12.stop();
  1688. }
  1689. }
  1690. }, _callee12);
  1691. }));
  1692. return function (_x2) {
  1693. return _ref7.apply(this, arguments);
  1694. };
  1695. }())["catch"](function () {
  1696. _this13.setInitialView();
  1697. }).then(function () {
  1698. pdfViewer.update();
  1699. });
  1700. });
  1701. pagesPromise.then(function () {
  1702. _this13._initializeAutoPrint(pdfDocument, openActionPromise);
  1703. });
  1704. onePageRendered.then(function () {
  1705. pdfDocument.getOutline().then(function (outline) {
  1706. _this13.pdfOutlineViewer.render({
  1707. outline: outline,
  1708. pdfDocument: pdfDocument
  1709. });
  1710. });
  1711. pdfDocument.getAttachments().then(function (attachments) {
  1712. _this13.pdfAttachmentViewer.render({
  1713. attachments: attachments
  1714. });
  1715. });
  1716. pdfViewer.optionalContentConfigPromise.then(function (optionalContentConfig) {
  1717. _this13.pdfLayerViewer.render({
  1718. optionalContentConfig: optionalContentConfig,
  1719. pdfDocument: pdfDocument
  1720. });
  1721. });
  1722. if ("requestIdleCallback" in window) {
  1723. var callback = window.requestIdleCallback(function () {
  1724. _this13._collectTelemetry(pdfDocument);
  1725. _this13._idleCallbacks["delete"](callback);
  1726. }, {
  1727. timeout: 1000
  1728. });
  1729. _this13._idleCallbacks.add(callback);
  1730. }
  1731. _this13._initializeJavaScript(pdfDocument);
  1732. });
  1733. this._initializePageLabels(pdfDocument);
  1734. this._initializeMetadata(pdfDocument);
  1735. },
  1736. _initializeJavaScript: function _initializeJavaScript(pdfDocument) {
  1737. var _this14 = this;
  1738. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee15() {
  1739. var _yield$Promise$all, _yield$Promise$all2, objects, calculationOrder, docActions, scripting, internalEvents, domEvents, updateFromSandbox, visitedPages, pageOpen, pageClose, dispatchEventInSandbox, mouseDown, mouseUp, _iterator4, _step4, _step4$value, name, listener, _iterator5, _step5, _step5$value, _name2, _listener2, _this14$metadata, _this14$metadata2;
  1740. return _regenerator["default"].wrap(function _callee15$(_context15) {
  1741. while (1) {
  1742. switch (_context15.prev = _context15.next) {
  1743. case 0:
  1744. if (_app_options.AppOptions.get("enableScripting")) {
  1745. _context15.next = 2;
  1746. break;
  1747. }
  1748. return _context15.abrupt("return");
  1749. case 2:
  1750. _context15.next = 4;
  1751. return Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
  1752. case 4:
  1753. _yield$Promise$all = _context15.sent;
  1754. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
  1755. objects = _yield$Promise$all2[0];
  1756. calculationOrder = _yield$Promise$all2[1];
  1757. docActions = _yield$Promise$all2[2];
  1758. if (!(!objects && !docActions)) {
  1759. _context15.next = 11;
  1760. break;
  1761. }
  1762. return _context15.abrupt("return");
  1763. case 11:
  1764. if (!(pdfDocument !== _this14.pdfDocument)) {
  1765. _context15.next = 13;
  1766. break;
  1767. }
  1768. return _context15.abrupt("return");
  1769. case 13:
  1770. scripting = _this14.externalServices.createScripting({
  1771. sandboxBundleSrc: _app_options.AppOptions.get("sandboxBundleSrc")
  1772. });
  1773. internalEvents = new Map(), domEvents = new Map();
  1774. _this14._scriptingInstance = {
  1775. scripting: scripting,
  1776. ready: false,
  1777. internalEvents: internalEvents,
  1778. domEvents: domEvents
  1779. };
  1780. if (_this14.documentInfo) {
  1781. _context15.next = 21;
  1782. break;
  1783. }
  1784. _context15.next = 19;
  1785. return new Promise(function (resolve) {
  1786. _this14.eventBus._on("metadataloaded", function (evt) {
  1787. resolve();
  1788. }, {
  1789. once: true
  1790. });
  1791. });
  1792. case 19:
  1793. if (!(pdfDocument !== _this14.pdfDocument)) {
  1794. _context15.next = 21;
  1795. break;
  1796. }
  1797. return _context15.abrupt("return");
  1798. case 21:
  1799. if (_this14._contentLength) {
  1800. _context15.next = 26;
  1801. break;
  1802. }
  1803. _context15.next = 24;
  1804. return new Promise(function (resolve) {
  1805. _this14.eventBus._on("documentloaded", function (evt) {
  1806. resolve();
  1807. }, {
  1808. once: true
  1809. });
  1810. });
  1811. case 24:
  1812. if (!(pdfDocument !== _this14.pdfDocument)) {
  1813. _context15.next = 26;
  1814. break;
  1815. }
  1816. return _context15.abrupt("return");
  1817. case 26:
  1818. updateFromSandbox = function updateFromSandbox(_ref9) {
  1819. var detail = _ref9.detail;
  1820. var id = detail.id,
  1821. command = detail.command,
  1822. value = detail.value;
  1823. if (!id) {
  1824. switch (command) {
  1825. case "clear":
  1826. console.clear();
  1827. break;
  1828. case "error":
  1829. console.error(value);
  1830. break;
  1831. case "layout":
  1832. _this14.pdfViewer.spreadMode = apiPageLayoutToSpreadMode(value);
  1833. break;
  1834. case "page-num":
  1835. _this14.pdfViewer.currentPageNumber = value + 1;
  1836. break;
  1837. case "print":
  1838. _this14.pdfViewer.pagesPromise.then(function () {
  1839. _this14.triggerPrinting();
  1840. });
  1841. break;
  1842. case "println":
  1843. console.log(value);
  1844. break;
  1845. case "zoom":
  1846. _this14.pdfViewer.currentScaleValue = value;
  1847. break;
  1848. }
  1849. return;
  1850. }
  1851. var element = document.getElementById(id);
  1852. if (element) {
  1853. element.dispatchEvent(new CustomEvent("updatefromsandbox", {
  1854. detail: detail
  1855. }));
  1856. } else {
  1857. if (value !== undefined && value !== null) {
  1858. pdfDocument.annotationStorage.setValue(id, value);
  1859. }
  1860. }
  1861. };
  1862. internalEvents.set("updatefromsandbox", updateFromSandbox);
  1863. visitedPages = new Map();
  1864. pageOpen = function pageOpen(_ref10) {
  1865. var pageNumber = _ref10.pageNumber,
  1866. actionsPromise = _ref10.actionsPromise;
  1867. visitedPages.set(pageNumber, _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
  1868. var _this14$_scriptingIns;
  1869. var actions;
  1870. return _regenerator["default"].wrap(function _callee13$(_context13) {
  1871. while (1) {
  1872. switch (_context13.prev = _context13.next) {
  1873. case 0:
  1874. actions = null;
  1875. if (visitedPages.has(pageNumber)) {
  1876. _context13.next = 7;
  1877. break;
  1878. }
  1879. _context13.next = 4;
  1880. return actionsPromise;
  1881. case 4:
  1882. actions = _context13.sent;
  1883. if (!(pdfDocument !== _this14.pdfDocument)) {
  1884. _context13.next = 7;
  1885. break;
  1886. }
  1887. return _context13.abrupt("return");
  1888. case 7:
  1889. _context13.next = 9;
  1890. return (_this14$_scriptingIns = _this14._scriptingInstance) === null || _this14$_scriptingIns === void 0 ? void 0 : _this14$_scriptingIns.scripting.dispatchEventInSandbox({
  1891. id: "page",
  1892. name: "PageOpen",
  1893. pageNumber: pageNumber,
  1894. actions: actions
  1895. });
  1896. case 9:
  1897. case "end":
  1898. return _context13.stop();
  1899. }
  1900. }
  1901. }, _callee13);
  1902. }))());
  1903. };
  1904. pageClose = /*#__PURE__*/function () {
  1905. var _ref13 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee14(_ref12) {
  1906. var _this14$_scriptingIns2;
  1907. var pageNumber, actionsPromise;
  1908. return _regenerator["default"].wrap(function _callee14$(_context14) {
  1909. while (1) {
  1910. switch (_context14.prev = _context14.next) {
  1911. case 0:
  1912. pageNumber = _ref12.pageNumber;
  1913. actionsPromise = visitedPages.get(pageNumber);
  1914. if (actionsPromise) {
  1915. _context14.next = 4;
  1916. break;
  1917. }
  1918. return _context14.abrupt("return");
  1919. case 4:
  1920. visitedPages.set(pageNumber, null);
  1921. _context14.next = 7;
  1922. return actionsPromise;
  1923. case 7:
  1924. if (!(pdfDocument !== _this14.pdfDocument)) {
  1925. _context14.next = 9;
  1926. break;
  1927. }
  1928. return _context14.abrupt("return");
  1929. case 9:
  1930. _context14.next = 11;
  1931. return (_this14$_scriptingIns2 = _this14._scriptingInstance) === null || _this14$_scriptingIns2 === void 0 ? void 0 : _this14$_scriptingIns2.scripting.dispatchEventInSandbox({
  1932. id: "page",
  1933. name: "PageClose",
  1934. pageNumber: pageNumber
  1935. });
  1936. case 11:
  1937. case "end":
  1938. return _context14.stop();
  1939. }
  1940. }
  1941. }, _callee14);
  1942. }));
  1943. return function pageClose(_x3) {
  1944. return _ref13.apply(this, arguments);
  1945. };
  1946. }();
  1947. internalEvents.set("pageopen", pageOpen);
  1948. internalEvents.set("pageclose", pageClose);
  1949. dispatchEventInSandbox = function dispatchEventInSandbox(_ref14) {
  1950. var detail = _ref14.detail;
  1951. scripting.dispatchEventInSandbox(detail);
  1952. };
  1953. internalEvents.set("dispatcheventinsandbox", dispatchEventInSandbox);
  1954. mouseDown = function mouseDown(event) {
  1955. _this14._mouseState.isDown = true;
  1956. };
  1957. domEvents.set("mousedown", mouseDown);
  1958. mouseUp = function mouseUp(event) {
  1959. _this14._mouseState.isDown = false;
  1960. };
  1961. domEvents.set("mouseup", mouseUp);
  1962. _iterator4 = _createForOfIteratorHelper(internalEvents);
  1963. try {
  1964. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  1965. _step4$value = _slicedToArray(_step4.value, 2), name = _step4$value[0], listener = _step4$value[1];
  1966. _this14.eventBus._on(name, listener);
  1967. }
  1968. } catch (err) {
  1969. _iterator4.e(err);
  1970. } finally {
  1971. _iterator4.f();
  1972. }
  1973. _iterator5 = _createForOfIteratorHelper(domEvents);
  1974. try {
  1975. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  1976. _step5$value = _slicedToArray(_step5.value, 2), _name2 = _step5$value[0], _listener2 = _step5$value[1];
  1977. window.addEventListener(_name2, _listener2);
  1978. }
  1979. } catch (err) {
  1980. _iterator5.e(err);
  1981. } finally {
  1982. _iterator5.f();
  1983. }
  1984. _context15.prev = 43;
  1985. _context15.next = 46;
  1986. return scripting.createSandbox({
  1987. objects: objects,
  1988. calculationOrder: calculationOrder,
  1989. appInfo: {
  1990. platform: navigator.platform,
  1991. language: navigator.language
  1992. },
  1993. docInfo: _objectSpread(_objectSpread({}, _this14.documentInfo), {}, {
  1994. baseURL: _this14.baseUrl,
  1995. filesize: _this14._contentLength,
  1996. filename: _this14._docFilename,
  1997. metadata: (_this14$metadata = _this14.metadata) === null || _this14$metadata === void 0 ? void 0 : _this14$metadata.getRaw(),
  1998. authors: (_this14$metadata2 = _this14.metadata) === null || _this14$metadata2 === void 0 ? void 0 : _this14$metadata2.get("dc:creator"),
  1999. numPages: pdfDocument.numPages,
  2000. URL: _this14.url,
  2001. actions: docActions
  2002. })
  2003. });
  2004. case 46:
  2005. if (_this14.externalServices.isInAutomation) {
  2006. _this14.eventBus.dispatch("sandboxcreated", {
  2007. source: _this14
  2008. });
  2009. }
  2010. _context15.next = 54;
  2011. break;
  2012. case 49:
  2013. _context15.prev = 49;
  2014. _context15.t0 = _context15["catch"](43);
  2015. console.error("_initializeJavaScript: \"".concat(_context15.t0 === null || _context15.t0 === void 0 ? void 0 : _context15.t0.message, "\"."));
  2016. _this14._destroyScriptingInstance();
  2017. return _context15.abrupt("return");
  2018. case 54:
  2019. _context15.next = 56;
  2020. return scripting.dispatchEventInSandbox({
  2021. id: "doc",
  2022. name: "Open"
  2023. });
  2024. case 56:
  2025. _context15.next = 58;
  2026. return _this14.pdfViewer.initializeScriptingEvents();
  2027. case 58:
  2028. Promise.resolve().then(function () {
  2029. if (_this14._scriptingInstance) {
  2030. _this14._scriptingInstance.ready = true;
  2031. }
  2032. });
  2033. case 59:
  2034. case "end":
  2035. return _context15.stop();
  2036. }
  2037. }
  2038. }, _callee15, null, [[43, 49]]);
  2039. }))();
  2040. },
  2041. _collectTelemetry: function _collectTelemetry(pdfDocument) {
  2042. var _this15 = this;
  2043. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee16() {
  2044. var markInfo, tagged;
  2045. return _regenerator["default"].wrap(function _callee16$(_context16) {
  2046. while (1) {
  2047. switch (_context16.prev = _context16.next) {
  2048. case 0:
  2049. _context16.next = 2;
  2050. return _this15.pdfDocument.getMarkInfo();
  2051. case 2:
  2052. markInfo = _context16.sent;
  2053. if (!(pdfDocument !== _this15.pdfDocument)) {
  2054. _context16.next = 5;
  2055. break;
  2056. }
  2057. return _context16.abrupt("return");
  2058. case 5:
  2059. tagged = (markInfo === null || markInfo === void 0 ? void 0 : markInfo.Marked) || false;
  2060. _this15.externalServices.reportTelemetry({
  2061. type: "tagged",
  2062. tagged: tagged
  2063. });
  2064. case 7:
  2065. case "end":
  2066. return _context16.stop();
  2067. }
  2068. }
  2069. }, _callee16);
  2070. }))();
  2071. },
  2072. _initializeAutoPrint: function _initializeAutoPrint(pdfDocument, openActionPromise) {
  2073. var _this16 = this;
  2074. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee17() {
  2075. var _yield$Promise$all3, _yield$Promise$all4, openAction, javaScript, triggerAutoPrint, _iterator6, _step6, js;
  2076. return _regenerator["default"].wrap(function _callee17$(_context17) {
  2077. while (1) {
  2078. switch (_context17.prev = _context17.next) {
  2079. case 0:
  2080. _context17.next = 2;
  2081. return Promise.all([openActionPromise, !_app_options.AppOptions.get("enableScripting") ? pdfDocument.getJavaScript() : null]);
  2082. case 2:
  2083. _yield$Promise$all3 = _context17.sent;
  2084. _yield$Promise$all4 = _slicedToArray(_yield$Promise$all3, 2);
  2085. openAction = _yield$Promise$all4[0];
  2086. javaScript = _yield$Promise$all4[1];
  2087. if (!(pdfDocument !== _this16.pdfDocument)) {
  2088. _context17.next = 8;
  2089. break;
  2090. }
  2091. return _context17.abrupt("return");
  2092. case 8:
  2093. triggerAutoPrint = false;
  2094. if ((openAction === null || openAction === void 0 ? void 0 : openAction.action) === "Print") {
  2095. triggerAutoPrint = true;
  2096. }
  2097. if (!javaScript) {
  2098. _context17.next = 31;
  2099. break;
  2100. }
  2101. javaScript.some(function (js) {
  2102. if (!js) {
  2103. return false;
  2104. }
  2105. console.warn("Warning: JavaScript is not supported");
  2106. _this16._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  2107. return true;
  2108. });
  2109. if (triggerAutoPrint) {
  2110. _context17.next = 31;
  2111. break;
  2112. }
  2113. _iterator6 = _createForOfIteratorHelper(javaScript);
  2114. _context17.prev = 14;
  2115. _iterator6.s();
  2116. case 16:
  2117. if ((_step6 = _iterator6.n()).done) {
  2118. _context17.next = 23;
  2119. break;
  2120. }
  2121. js = _step6.value;
  2122. if (!(js && _ui_utils.AutoPrintRegExp.test(js))) {
  2123. _context17.next = 21;
  2124. break;
  2125. }
  2126. triggerAutoPrint = true;
  2127. return _context17.abrupt("break", 23);
  2128. case 21:
  2129. _context17.next = 16;
  2130. break;
  2131. case 23:
  2132. _context17.next = 28;
  2133. break;
  2134. case 25:
  2135. _context17.prev = 25;
  2136. _context17.t0 = _context17["catch"](14);
  2137. _iterator6.e(_context17.t0);
  2138. case 28:
  2139. _context17.prev = 28;
  2140. _iterator6.f();
  2141. return _context17.finish(28);
  2142. case 31:
  2143. if (triggerAutoPrint) {
  2144. _this16.triggerPrinting();
  2145. }
  2146. case 32:
  2147. case "end":
  2148. return _context17.stop();
  2149. }
  2150. }
  2151. }, _callee17, null, [[14, 25, 28, 31]]);
  2152. }))();
  2153. },
  2154. _initializeMetadata: function _initializeMetadata(pdfDocument) {
  2155. var _this17 = this;
  2156. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee18() {
  2157. var _this17$_contentLengt;
  2158. var _yield$pdfDocument$ge, info, metadata, contentDispositionFilename, contentLength, pdfTitle, infoTitle, metadataTitle, versionId, generatorId, producer, formType;
  2159. return _regenerator["default"].wrap(function _callee18$(_context18) {
  2160. while (1) {
  2161. switch (_context18.prev = _context18.next) {
  2162. case 0:
  2163. _context18.next = 2;
  2164. return pdfDocument.getMetadata();
  2165. case 2:
  2166. _yield$pdfDocument$ge = _context18.sent;
  2167. info = _yield$pdfDocument$ge.info;
  2168. metadata = _yield$pdfDocument$ge.metadata;
  2169. contentDispositionFilename = _yield$pdfDocument$ge.contentDispositionFilename;
  2170. contentLength = _yield$pdfDocument$ge.contentLength;
  2171. if (!(pdfDocument !== _this17.pdfDocument)) {
  2172. _context18.next = 9;
  2173. break;
  2174. }
  2175. return _context18.abrupt("return");
  2176. case 9:
  2177. _this17.documentInfo = info;
  2178. _this17.metadata = metadata;
  2179. _this17._contentDispositionFilename = contentDispositionFilename;
  2180. (_this17$_contentLengt = _this17._contentLength) !== null && _this17$_contentLengt !== void 0 ? _this17$_contentLengt : _this17._contentLength = contentLength;
  2181. console.log("PDF ".concat(pdfDocument.fingerprint, " [").concat(info.PDFFormatVersion, " ") + "".concat((info.Producer || "-").trim(), " / ").concat((info.Creator || "-").trim(), "] ") + "(PDF.js: ".concat(_pdfjsLib.version || "-") + "".concat(_this17.pdfViewer.enableWebGL ? " [WebGL]" : "", ")"));
  2182. infoTitle = info && info.Title;
  2183. if (infoTitle) {
  2184. pdfTitle = infoTitle;
  2185. }
  2186. metadataTitle = metadata && metadata.get("dc:title");
  2187. if (metadataTitle) {
  2188. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
  2189. pdfTitle = metadataTitle;
  2190. }
  2191. }
  2192. if (pdfTitle) {
  2193. _this17.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
  2194. } else if (contentDispositionFilename) {
  2195. _this17.setTitle(contentDispositionFilename);
  2196. }
  2197. if (info.IsXFAPresent && !info.IsAcroFormPresent) {
  2198. console.warn("Warning: XFA is not supported");
  2199. _this17._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  2200. } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !_this17.pdfViewer.renderInteractiveForms) {
  2201. console.warn("Warning: Interactive form support is not enabled");
  2202. _this17._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  2203. }
  2204. versionId = "other";
  2205. if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
  2206. versionId = "v".concat(info.PDFFormatVersion.replace(".", "_"));
  2207. }
  2208. generatorId = "other";
  2209. if (info.Producer) {
  2210. producer = info.Producer.toLowerCase();
  2211. KNOWN_GENERATORS.some(function (generator) {
  2212. if (!producer.includes(generator)) {
  2213. return false;
  2214. }
  2215. generatorId = generator.replace(/[ .-]/g, "_");
  2216. return true;
  2217. });
  2218. }
  2219. formType = null;
  2220. if (info.IsXFAPresent) {
  2221. formType = "xfa";
  2222. } else if (info.IsAcroFormPresent) {
  2223. formType = "acroform";
  2224. }
  2225. _this17.externalServices.reportTelemetry({
  2226. type: "documentInfo",
  2227. version: versionId,
  2228. generator: generatorId,
  2229. formType: formType
  2230. });
  2231. _this17.eventBus.dispatch("metadataloaded", {
  2232. source: _this17
  2233. });
  2234. case 28:
  2235. case "end":
  2236. return _context18.stop();
  2237. }
  2238. }
  2239. }, _callee18);
  2240. }))();
  2241. },
  2242. _initializePageLabels: function _initializePageLabels(pdfDocument) {
  2243. var _this18 = this;
  2244. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee19() {
  2245. var labels, numLabels, i, pdfViewer, pdfThumbnailViewer, toolbar;
  2246. return _regenerator["default"].wrap(function _callee19$(_context19) {
  2247. while (1) {
  2248. switch (_context19.prev = _context19.next) {
  2249. case 0:
  2250. _context19.next = 2;
  2251. return pdfDocument.getPageLabels();
  2252. case 2:
  2253. labels = _context19.sent;
  2254. if (!(pdfDocument !== _this18.pdfDocument)) {
  2255. _context19.next = 5;
  2256. break;
  2257. }
  2258. return _context19.abrupt("return");
  2259. case 5:
  2260. if (!(!labels || _app_options.AppOptions.get("disablePageLabels"))) {
  2261. _context19.next = 7;
  2262. break;
  2263. }
  2264. return _context19.abrupt("return");
  2265. case 7:
  2266. numLabels = labels.length;
  2267. if (!(numLabels !== _this18.pagesCount)) {
  2268. _context19.next = 11;
  2269. break;
  2270. }
  2271. console.error("The number of Page Labels does not match the number of pages in the document.");
  2272. return _context19.abrupt("return");
  2273. case 11:
  2274. i = 0;
  2275. while (i < numLabels && labels[i] === (i + 1).toString()) {
  2276. i++;
  2277. }
  2278. if (!(i === numLabels)) {
  2279. _context19.next = 15;
  2280. break;
  2281. }
  2282. return _context19.abrupt("return");
  2283. case 15:
  2284. pdfViewer = _this18.pdfViewer, pdfThumbnailViewer = _this18.pdfThumbnailViewer, toolbar = _this18.toolbar;
  2285. pdfViewer.setPageLabels(labels);
  2286. pdfThumbnailViewer.setPageLabels(labels);
  2287. toolbar.setPagesCount(numLabels, true);
  2288. toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  2289. case 20:
  2290. case "end":
  2291. return _context19.stop();
  2292. }
  2293. }
  2294. }, _callee19);
  2295. }))();
  2296. },
  2297. _initializePdfHistory: function _initializePdfHistory(_ref15) {
  2298. var fingerprint = _ref15.fingerprint,
  2299. viewOnLoad = _ref15.viewOnLoad,
  2300. _ref15$initialDest = _ref15.initialDest,
  2301. initialDest = _ref15$initialDest === void 0 ? null : _ref15$initialDest;
  2302. if (this.isViewerEmbedded || _app_options.AppOptions.get("disableHistory")) {
  2303. return;
  2304. }
  2305. this.pdfHistory.initialize({
  2306. fingerprint: fingerprint,
  2307. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  2308. updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
  2309. });
  2310. if (this.pdfHistory.initialBookmark) {
  2311. this.initialBookmark = this.pdfHistory.initialBookmark;
  2312. this.initialRotation = this.pdfHistory.initialRotation;
  2313. }
  2314. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  2315. this.initialBookmark = JSON.stringify(initialDest);
  2316. this.pdfHistory.push({
  2317. explicitDest: initialDest,
  2318. pageNumber: null
  2319. });
  2320. }
  2321. },
  2322. _initializePermissions: function _initializePermissions(pdfDocument) {
  2323. var _this19 = this;
  2324. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee20() {
  2325. var permissions;
  2326. return _regenerator["default"].wrap(function _callee20$(_context20) {
  2327. while (1) {
  2328. switch (_context20.prev = _context20.next) {
  2329. case 0:
  2330. _context20.next = 2;
  2331. return pdfDocument.getPermissions();
  2332. case 2:
  2333. permissions = _context20.sent;
  2334. if (!(pdfDocument !== _this19.pdfDocument)) {
  2335. _context20.next = 5;
  2336. break;
  2337. }
  2338. return _context20.abrupt("return");
  2339. case 5:
  2340. if (!(!permissions || !_app_options.AppOptions.get("enablePermissions"))) {
  2341. _context20.next = 7;
  2342. break;
  2343. }
  2344. return _context20.abrupt("return");
  2345. case 7:
  2346. if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY)) {
  2347. _this19.appConfig.viewerContainer.classList.add(ENABLE_PERMISSIONS_CLASS);
  2348. }
  2349. case 8:
  2350. case "end":
  2351. return _context20.stop();
  2352. }
  2353. }
  2354. }, _callee20);
  2355. }))();
  2356. },
  2357. _initializeAnnotationStorageCallbacks: function _initializeAnnotationStorageCallbacks(pdfDocument) {
  2358. if (pdfDocument !== this.pdfDocument) {
  2359. return;
  2360. }
  2361. var annotationStorage = pdfDocument.annotationStorage;
  2362. annotationStorage.onSetModified = function () {
  2363. window.addEventListener("beforeunload", beforeUnload);
  2364. };
  2365. annotationStorage.onResetModified = function () {
  2366. window.removeEventListener("beforeunload", beforeUnload);
  2367. };
  2368. },
  2369. setInitialView: function setInitialView(storedHash) {
  2370. var _this20 = this;
  2371. var _ref16 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  2372. rotation = _ref16.rotation,
  2373. sidebarView = _ref16.sidebarView,
  2374. scrollMode = _ref16.scrollMode,
  2375. spreadMode = _ref16.spreadMode;
  2376. var setRotation = function setRotation(angle) {
  2377. if ((0, _ui_utils.isValidRotation)(angle)) {
  2378. _this20.pdfViewer.pagesRotation = angle;
  2379. }
  2380. };
  2381. var setViewerModes = function setViewerModes(scroll, spread) {
  2382. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  2383. _this20.pdfViewer.scrollMode = scroll;
  2384. }
  2385. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  2386. _this20.pdfViewer.spreadMode = spread;
  2387. }
  2388. };
  2389. this.isInitialViewSet = true;
  2390. this.pdfSidebar.setInitialView(sidebarView);
  2391. setViewerModes(scrollMode, spreadMode);
  2392. if (this.initialBookmark) {
  2393. setRotation(this.initialRotation);
  2394. delete this.initialRotation;
  2395. this.pdfLinkService.setHash(this.initialBookmark);
  2396. this.initialBookmark = null;
  2397. } else if (storedHash) {
  2398. setRotation(rotation);
  2399. this.pdfLinkService.setHash(storedHash);
  2400. }
  2401. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  2402. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  2403. if (!this.pdfViewer.currentScaleValue) {
  2404. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2405. }
  2406. },
  2407. cleanup: function cleanup() {
  2408. if (!this.pdfDocument) {
  2409. return;
  2410. }
  2411. this.pdfViewer.cleanup();
  2412. this.pdfThumbnailViewer.cleanup();
  2413. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  2414. this.pdfDocument.cleanup();
  2415. }
  2416. },
  2417. forceRendering: function forceRendering() {
  2418. this.pdfRenderingQueue.printing = !!this.printService;
  2419. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  2420. this.pdfRenderingQueue.renderHighestPriority();
  2421. },
  2422. beforePrint: function beforePrint() {
  2423. var _this$_scriptingInsta,
  2424. _this21 = this;
  2425. (_this$_scriptingInsta = this._scriptingInstance) === null || _this$_scriptingInsta === void 0 ? void 0 : _this$_scriptingInsta.scripting.dispatchEventInSandbox({
  2426. id: "doc",
  2427. name: "WillPrint"
  2428. });
  2429. if (this.printService) {
  2430. return;
  2431. }
  2432. if (!this.supportsPrinting) {
  2433. this.l10n.get("printing_not_supported", null, "Warning: Printing is not fully supported by this browser.").then(function (printMessage) {
  2434. _this21.error(printMessage);
  2435. });
  2436. return;
  2437. }
  2438. if (!this.pdfViewer.pageViewsReady) {
  2439. this.l10n.get("printing_not_ready", null, "Warning: The PDF is not fully loaded for printing.").then(function (notReadyMessage) {
  2440. window.alert(notReadyMessage);
  2441. });
  2442. return;
  2443. }
  2444. var pagesOverview = this.pdfViewer.getPagesOverview();
  2445. var printContainer = this.appConfig.printContainer;
  2446. var printResolution = _app_options.AppOptions.get("printResolution");
  2447. var optionalContentConfigPromise = this.pdfViewer.optionalContentConfigPromise;
  2448. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, this.l10n);
  2449. this.printService = printService;
  2450. this.forceRendering();
  2451. printService.layout();
  2452. this.externalServices.reportTelemetry({
  2453. type: "print"
  2454. });
  2455. },
  2456. afterPrint: function afterPrint() {
  2457. var _this$_scriptingInsta2;
  2458. (_this$_scriptingInsta2 = this._scriptingInstance) === null || _this$_scriptingInsta2 === void 0 ? void 0 : _this$_scriptingInsta2.scripting.dispatchEventInSandbox({
  2459. id: "doc",
  2460. name: "DidPrint"
  2461. });
  2462. if (this.printService) {
  2463. this.printService.destroy();
  2464. this.printService = null;
  2465. if (this.pdfDocument) {
  2466. this.pdfDocument.annotationStorage.resetModified();
  2467. }
  2468. }
  2469. this.forceRendering();
  2470. },
  2471. rotatePages: function rotatePages(delta) {
  2472. if (!this.pdfDocument) {
  2473. return;
  2474. }
  2475. var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
  2476. this.pdfViewer.pagesRotation = newRotation;
  2477. },
  2478. requestPresentationMode: function requestPresentationMode() {
  2479. if (!this.pdfPresentationMode) {
  2480. return;
  2481. }
  2482. this.pdfPresentationMode.request();
  2483. },
  2484. triggerPrinting: function triggerPrinting() {
  2485. if (!this.supportsPrinting) {
  2486. return;
  2487. }
  2488. window.print();
  2489. },
  2490. bindEvents: function bindEvents() {
  2491. var eventBus = this.eventBus,
  2492. _boundEvents = this._boundEvents;
  2493. _boundEvents.beforePrint = this.beforePrint.bind(this);
  2494. _boundEvents.afterPrint = this.afterPrint.bind(this);
  2495. eventBus._on("resize", webViewerResize);
  2496. eventBus._on("hashchange", webViewerHashchange);
  2497. eventBus._on("beforeprint", _boundEvents.beforePrint);
  2498. eventBus._on("afterprint", _boundEvents.afterPrint);
  2499. eventBus._on("pagerendered", webViewerPageRendered);
  2500. eventBus._on("updateviewarea", webViewerUpdateViewarea);
  2501. eventBus._on("pagechanging", webViewerPageChanging);
  2502. eventBus._on("scalechanging", webViewerScaleChanging);
  2503. eventBus._on("rotationchanging", webViewerRotationChanging);
  2504. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
  2505. eventBus._on("pagemode", webViewerPageMode);
  2506. eventBus._on("namedaction", webViewerNamedAction);
  2507. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
  2508. eventBus._on("presentationmode", webViewerPresentationMode);
  2509. eventBus._on("print", webViewerPrint);
  2510. eventBus._on("download", webViewerDownload);
  2511. eventBus._on("save", webViewerSave);
  2512. eventBus._on("firstpage", webViewerFirstPage);
  2513. eventBus._on("lastpage", webViewerLastPage);
  2514. eventBus._on("nextpage", webViewerNextPage);
  2515. eventBus._on("previouspage", webViewerPreviousPage);
  2516. eventBus._on("zoomin", webViewerZoomIn);
  2517. eventBus._on("zoomout", webViewerZoomOut);
  2518. eventBus._on("zoomreset", webViewerZoomReset);
  2519. eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
  2520. eventBus._on("scalechanged", webViewerScaleChanged);
  2521. eventBus._on("rotatecw", webViewerRotateCw);
  2522. eventBus._on("rotateccw", webViewerRotateCcw);
  2523. eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig);
  2524. eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
  2525. eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
  2526. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
  2527. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
  2528. eventBus._on("documentproperties", webViewerDocumentProperties);
  2529. eventBus._on("find", webViewerFind);
  2530. eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
  2531. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2532. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
  2533. if (_app_options.AppOptions.get("pdfBug")) {
  2534. _boundEvents.reportPageStatsPDFBug = reportPageStatsPDFBug;
  2535. eventBus._on("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2536. eventBus._on("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2537. }
  2538. eventBus._on("fileinputchange", webViewerFileInputChange);
  2539. eventBus._on("openfile", webViewerOpenFile);
  2540. },
  2541. bindWindowEvents: function bindWindowEvents() {
  2542. var eventBus = this.eventBus,
  2543. _boundEvents = this._boundEvents;
  2544. _boundEvents.windowResize = function () {
  2545. eventBus.dispatch("resize", {
  2546. source: window
  2547. });
  2548. };
  2549. _boundEvents.windowHashChange = function () {
  2550. eventBus.dispatch("hashchange", {
  2551. source: window,
  2552. hash: document.location.hash.substring(1)
  2553. });
  2554. };
  2555. _boundEvents.windowBeforePrint = function () {
  2556. eventBus.dispatch("beforeprint", {
  2557. source: window
  2558. });
  2559. };
  2560. _boundEvents.windowAfterPrint = function () {
  2561. eventBus.dispatch("afterprint", {
  2562. source: window
  2563. });
  2564. };
  2565. _boundEvents.windowUpdateFromSandbox = function (event) {
  2566. eventBus.dispatch("updatefromsandbox", {
  2567. source: window,
  2568. detail: event.detail
  2569. });
  2570. };
  2571. window.addEventListener("visibilitychange", webViewerVisibilityChange);
  2572. window.addEventListener("wheel", webViewerWheel, {
  2573. passive: false
  2574. });
  2575. window.addEventListener("touchstart", webViewerTouchStart, {
  2576. passive: false
  2577. });
  2578. window.addEventListener("click", webViewerClick);
  2579. window.addEventListener("keydown", webViewerKeyDown);
  2580. window.addEventListener("keyup", webViewerKeyUp);
  2581. window.addEventListener("resize", _boundEvents.windowResize);
  2582. window.addEventListener("hashchange", _boundEvents.windowHashChange);
  2583. window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2584. window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
  2585. window.addEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  2586. },
  2587. unbindEvents: function unbindEvents() {
  2588. var eventBus = this.eventBus,
  2589. _boundEvents = this._boundEvents;
  2590. eventBus._off("resize", webViewerResize);
  2591. eventBus._off("hashchange", webViewerHashchange);
  2592. eventBus._off("beforeprint", _boundEvents.beforePrint);
  2593. eventBus._off("afterprint", _boundEvents.afterPrint);
  2594. eventBus._off("pagerendered", webViewerPageRendered);
  2595. eventBus._off("updateviewarea", webViewerUpdateViewarea);
  2596. eventBus._off("pagechanging", webViewerPageChanging);
  2597. eventBus._off("scalechanging", webViewerScaleChanging);
  2598. eventBus._off("rotationchanging", webViewerRotationChanging);
  2599. eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
  2600. eventBus._off("pagemode", webViewerPageMode);
  2601. eventBus._off("namedaction", webViewerNamedAction);
  2602. eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
  2603. eventBus._off("presentationmode", webViewerPresentationMode);
  2604. eventBus._off("print", webViewerPrint);
  2605. eventBus._off("download", webViewerDownload);
  2606. eventBus._off("save", webViewerSave);
  2607. eventBus._off("firstpage", webViewerFirstPage);
  2608. eventBus._off("lastpage", webViewerLastPage);
  2609. eventBus._off("nextpage", webViewerNextPage);
  2610. eventBus._off("previouspage", webViewerPreviousPage);
  2611. eventBus._off("zoomin", webViewerZoomIn);
  2612. eventBus._off("zoomout", webViewerZoomOut);
  2613. eventBus._off("zoomreset", webViewerZoomReset);
  2614. eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
  2615. eventBus._off("scalechanged", webViewerScaleChanged);
  2616. eventBus._off("rotatecw", webViewerRotateCw);
  2617. eventBus._off("rotateccw", webViewerRotateCcw);
  2618. eventBus._off("optionalcontentconfig", webViewerOptionalContentConfig);
  2619. eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
  2620. eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
  2621. eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
  2622. eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
  2623. eventBus._off("documentproperties", webViewerDocumentProperties);
  2624. eventBus._off("find", webViewerFind);
  2625. eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
  2626. eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2627. eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
  2628. if (_boundEvents.reportPageStatsPDFBug) {
  2629. eventBus._off("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2630. eventBus._off("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2631. _boundEvents.reportPageStatsPDFBug = null;
  2632. }
  2633. eventBus._off("fileinputchange", webViewerFileInputChange);
  2634. eventBus._off("openfile", webViewerOpenFile);
  2635. _boundEvents.beforePrint = null;
  2636. _boundEvents.afterPrint = null;
  2637. },
  2638. unbindWindowEvents: function unbindWindowEvents() {
  2639. var _boundEvents = this._boundEvents;
  2640. window.removeEventListener("visibilitychange", webViewerVisibilityChange);
  2641. window.removeEventListener("wheel", webViewerWheel, {
  2642. passive: false
  2643. });
  2644. window.removeEventListener("touchstart", webViewerTouchStart, {
  2645. passive: false
  2646. });
  2647. window.removeEventListener("click", webViewerClick);
  2648. window.removeEventListener("keydown", webViewerKeyDown);
  2649. window.removeEventListener("keyup", webViewerKeyUp);
  2650. window.removeEventListener("resize", _boundEvents.windowResize);
  2651. window.removeEventListener("hashchange", _boundEvents.windowHashChange);
  2652. window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2653. window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
  2654. window.removeEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  2655. _boundEvents.windowResize = null;
  2656. _boundEvents.windowHashChange = null;
  2657. _boundEvents.windowBeforePrint = null;
  2658. _boundEvents.windowAfterPrint = null;
  2659. _boundEvents.windowUpdateFromSandbox = null;
  2660. },
  2661. accumulateWheelTicks: function accumulateWheelTicks(ticks) {
  2662. if (this._wheelUnusedTicks > 0 && ticks < 0 || this._wheelUnusedTicks < 0 && ticks > 0) {
  2663. this._wheelUnusedTicks = 0;
  2664. }
  2665. this._wheelUnusedTicks += ticks;
  2666. var wholeTicks = Math.sign(this._wheelUnusedTicks) * Math.floor(Math.abs(this._wheelUnusedTicks));
  2667. this._wheelUnusedTicks -= wholeTicks;
  2668. return wholeTicks;
  2669. },
  2670. get scriptingReady() {
  2671. var _this$_scriptingInsta3;
  2672. return ((_this$_scriptingInsta3 = this._scriptingInstance) === null || _this$_scriptingInsta3 === void 0 ? void 0 : _this$_scriptingInsta3.ready) || false;
  2673. }
  2674. };
  2675. exports.PDFViewerApplication = PDFViewerApplication;
  2676. var validateFileURL;
  2677. {
  2678. var HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
  2679. validateFileURL = function validateFileURL(file) {
  2680. if (file === undefined) {
  2681. return;
  2682. }
  2683. try {
  2684. var viewerOrigin = new URL(window.location.href).origin || "null";
  2685. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  2686. return;
  2687. }
  2688. var _URL = new URL(file, window.location.href),
  2689. origin = _URL.origin,
  2690. protocol = _URL.protocol;
  2691. // if (origin !== viewerOrigin && protocol !== "blob:") {
  2692. // throw new Error("file origin does not match viewer's");
  2693. // }
  2694. } catch (ex) {
  2695. var message = ex && ex.message;
  2696. PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(function (loadingErrorMessage) {
  2697. PDFViewerApplication.error(loadingErrorMessage, {
  2698. message: message
  2699. });
  2700. });
  2701. throw ex;
  2702. }
  2703. };
  2704. }
  2705. function loadFakeWorker() {
  2706. return _loadFakeWorker.apply(this, arguments);
  2707. }
  2708. function _loadFakeWorker() {
  2709. _loadFakeWorker = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee21() {
  2710. return _regenerator["default"].wrap(function _callee21$(_context21) {
  2711. while (1) {
  2712. switch (_context21.prev = _context21.next) {
  2713. case 0:
  2714. if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
  2715. _pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get("workerSrc");
  2716. }
  2717. return _context21.abrupt("return", (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc()));
  2718. case 2:
  2719. case "end":
  2720. return _context21.stop();
  2721. }
  2722. }
  2723. }, _callee21);
  2724. }));
  2725. return _loadFakeWorker.apply(this, arguments);
  2726. }
  2727. function loadAndEnablePDFBug(enabledTabs) {
  2728. var appConfig = PDFViewerApplication.appConfig;
  2729. return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function () {
  2730. PDFBug.enable(enabledTabs);
  2731. PDFBug.init({
  2732. OPS: _pdfjsLib.OPS
  2733. }, appConfig.mainContainer);
  2734. });
  2735. }
  2736. function reportPageStatsPDFBug(_ref17) {
  2737. var pageNumber = _ref17.pageNumber;
  2738. if (typeof Stats === "undefined" || !Stats.enabled) {
  2739. return;
  2740. }
  2741. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  2742. var pageStats = pageView && pageView.pdfPage && pageView.pdfPage.stats;
  2743. if (!pageStats) {
  2744. return;
  2745. }
  2746. Stats.add(pageNumber, pageStats);
  2747. }
  2748. function webViewerInitialized() {
  2749. var appConfig = PDFViewerApplication.appConfig;
  2750. var file;
  2751. var queryString = document.location.search.substring(1);
  2752. var params = (0, _ui_utils.parseQueryString)(queryString);
  2753. file = "file" in params ? params.file : _app_options.AppOptions.get("defaultUrl");
  2754. validateFileURL(file);
  2755. var fileInput = document.createElement("input");
  2756. fileInput.id = appConfig.openFileInputName;
  2757. fileInput.className = "fileInput";
  2758. fileInput.setAttribute("type", "file");
  2759. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  2760. document.body.appendChild(fileInput);
  2761. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  2762. appConfig.toolbar.openFile.setAttribute("hidden", "true");
  2763. appConfig.secondaryToolbar.openFileButton.setAttribute("hidden", "true");
  2764. } else {
  2765. fileInput.value = null;
  2766. }
  2767. fileInput.addEventListener("change", function (evt) {
  2768. var files = evt.target.files;
  2769. if (!files || files.length === 0) {
  2770. return;
  2771. }
  2772. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  2773. source: this,
  2774. fileInput: evt.target
  2775. });
  2776. });
  2777. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  2778. evt.preventDefault();
  2779. evt.dataTransfer.dropEffect = "move";
  2780. });
  2781. appConfig.mainContainer.addEventListener("drop", function (evt) {
  2782. evt.preventDefault();
  2783. var files = evt.dataTransfer.files;
  2784. if (!files || files.length === 0) {
  2785. return;
  2786. }
  2787. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  2788. source: this,
  2789. fileInput: evt.dataTransfer
  2790. });
  2791. });
  2792. if (!PDFViewerApplication.supportsDocumentFonts) {
  2793. _app_options.AppOptions.set("disableFontFace", true);
  2794. PDFViewerApplication.l10n.get("web_fonts_disabled", null, "Web fonts are disabled: unable to use embedded PDF fonts.").then(function (msg) {
  2795. console.warn(msg);
  2796. });
  2797. }
  2798. if (!PDFViewerApplication.supportsPrinting) {
  2799. appConfig.toolbar.print.classList.add("hidden");
  2800. appConfig.secondaryToolbar.printButton.classList.add("hidden");
  2801. }
  2802. if (!PDFViewerApplication.supportsFullscreen) {
  2803. appConfig.toolbar.presentationModeButton.classList.add("hidden");
  2804. appConfig.secondaryToolbar.presentationModeButton.classList.add("hidden");
  2805. }
  2806. if (PDFViewerApplication.supportsIntegratedFind) {
  2807. appConfig.toolbar.viewFind.classList.add("hidden");
  2808. }
  2809. appConfig.mainContainer.addEventListener("transitionend", function (evt) {
  2810. if (evt.target === this) {
  2811. PDFViewerApplication.eventBus.dispatch("resize", {
  2812. source: this
  2813. });
  2814. }
  2815. }, true);
  2816. try {
  2817. webViewerOpenFileViaURL(file);
  2818. } catch (reason) {
  2819. PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(function (msg) {
  2820. PDFViewerApplication.error(msg, reason);
  2821. });
  2822. }
  2823. }
  2824. var webViewerOpenFileViaURL;
  2825. {
  2826. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  2827. if (file && file.lastIndexOf("file:", 0) === 0) {
  2828. PDFViewerApplication.setTitleUsingUrl(file);
  2829. var xhr = new XMLHttpRequest();
  2830. xhr.onload = function () {
  2831. PDFViewerApplication.open(new Uint8Array(xhr.response));
  2832. };
  2833. xhr.open("GET", file);
  2834. xhr.responseType = "arraybuffer";
  2835. xhr.send();
  2836. return;
  2837. }
  2838. if (file) {
  2839. PDFViewerApplication.open(file);
  2840. }
  2841. };
  2842. }
  2843. function webViewerResetPermissions() {
  2844. var appConfig = PDFViewerApplication.appConfig;
  2845. if (!appConfig) {
  2846. return;
  2847. }
  2848. appConfig.viewerContainer.classList.remove(ENABLE_PERMISSIONS_CLASS);
  2849. }
  2850. function webViewerPageRendered(_ref18) {
  2851. var pageNumber = _ref18.pageNumber,
  2852. timestamp = _ref18.timestamp,
  2853. error = _ref18.error;
  2854. if (pageNumber === PDFViewerApplication.page) {
  2855. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  2856. }
  2857. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2858. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  2859. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageNumber - 1);
  2860. if (pageView && thumbnailView) {
  2861. thumbnailView.setImage(pageView);
  2862. }
  2863. }
  2864. if (error) {
  2865. PDFViewerApplication.l10n.get("rendering_error", null, "An error occurred while rendering the page.").then(function (msg) {
  2866. PDFViewerApplication.error(msg, error);
  2867. });
  2868. }
  2869. PDFViewerApplication.externalServices.reportTelemetry({
  2870. type: "pageInfo",
  2871. timestamp: timestamp
  2872. });
  2873. PDFViewerApplication.pdfDocument.getStats().then(function (stats) {
  2874. PDFViewerApplication.externalServices.reportTelemetry({
  2875. type: "documentStats",
  2876. stats: stats
  2877. });
  2878. });
  2879. }
  2880. function webViewerPageMode(_ref19) {
  2881. var mode = _ref19.mode;
  2882. var view;
  2883. switch (mode) {
  2884. case "thumbs":
  2885. view = _ui_utils.SidebarView.THUMBS;
  2886. break;
  2887. case "bookmarks":
  2888. case "outline":
  2889. view = _ui_utils.SidebarView.OUTLINE;
  2890. break;
  2891. case "attachments":
  2892. view = _ui_utils.SidebarView.ATTACHMENTS;
  2893. break;
  2894. case "layers":
  2895. view = _ui_utils.SidebarView.LAYERS;
  2896. break;
  2897. case "none":
  2898. view = _ui_utils.SidebarView.NONE;
  2899. break;
  2900. default:
  2901. console.error('Invalid "pagemode" hash parameter: ' + mode);
  2902. return;
  2903. }
  2904. PDFViewerApplication.pdfSidebar.switchView(view, true);
  2905. }
  2906. function webViewerNamedAction(evt) {
  2907. switch (evt.action) {
  2908. case "GoToPage":
  2909. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2910. break;
  2911. case "Find":
  2912. if (!PDFViewerApplication.supportsIntegratedFind) {
  2913. PDFViewerApplication.findBar.toggle();
  2914. }
  2915. break;
  2916. case "Print":
  2917. PDFViewerApplication.triggerPrinting();
  2918. break;
  2919. case "SaveAs":
  2920. webViewerSave();
  2921. break;
  2922. }
  2923. }
  2924. function webViewerPresentationModeChanged(evt) {
  2925. PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
  2926. }
  2927. function webViewerSidebarViewChanged(evt) {
  2928. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  2929. var store = PDFViewerApplication.store;
  2930. if (store && PDFViewerApplication.isInitialViewSet) {
  2931. store.set("sidebarView", evt.view)["catch"](function () {});
  2932. }
  2933. }
  2934. function webViewerUpdateViewarea(evt) {
  2935. var location = evt.location,
  2936. store = PDFViewerApplication.store;
  2937. if (store && PDFViewerApplication.isInitialViewSet) {
  2938. store.setMultiple({
  2939. page: location.pageNumber,
  2940. zoom: location.scale,
  2941. scrollLeft: location.left,
  2942. scrollTop: location.top,
  2943. rotation: location.rotation
  2944. })["catch"](function () {});
  2945. }
  2946. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  2947. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  2948. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  2949. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  2950. var loading = (currentPage && currentPage.renderingState) !== _pdf_rendering_queue.RenderingStates.FINISHED;
  2951. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  2952. }
  2953. function webViewerScrollModeChanged(evt) {
  2954. var store = PDFViewerApplication.store;
  2955. if (store && PDFViewerApplication.isInitialViewSet) {
  2956. store.set("scrollMode", evt.mode)["catch"](function () {});
  2957. }
  2958. }
  2959. function webViewerSpreadModeChanged(evt) {
  2960. var store = PDFViewerApplication.store;
  2961. if (store && PDFViewerApplication.isInitialViewSet) {
  2962. store.set("spreadMode", evt.mode)["catch"](function () {});
  2963. }
  2964. }
  2965. function webViewerResize() {
  2966. var pdfDocument = PDFViewerApplication.pdfDocument,
  2967. pdfViewer = PDFViewerApplication.pdfViewer;
  2968. if (!pdfDocument) {
  2969. return;
  2970. }
  2971. var currentScaleValue = pdfViewer.currentScaleValue;
  2972. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  2973. pdfViewer.currentScaleValue = currentScaleValue;
  2974. }
  2975. pdfViewer.update();
  2976. }
  2977. function webViewerHashchange(evt) {
  2978. var hash = evt.hash;
  2979. if (!hash) {
  2980. return;
  2981. }
  2982. if (!PDFViewerApplication.isInitialViewSet) {
  2983. PDFViewerApplication.initialBookmark = hash;
  2984. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  2985. PDFViewerApplication.pdfLinkService.setHash(hash);
  2986. }
  2987. }
  2988. var webViewerFileInputChange, webViewerOpenFile;
  2989. {
  2990. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  2991. if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
  2992. return;
  2993. }
  2994. var file = evt.fileInput.files[0];
  2995. if (!_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  2996. var url = URL.createObjectURL(file);
  2997. if (file.name) {
  2998. url = {
  2999. url: url,
  3000. originalUrl: file.name
  3001. };
  3002. }
  3003. PDFViewerApplication.open(url);
  3004. } else {
  3005. PDFViewerApplication.setTitleUsingUrl(file.name);
  3006. var fileReader = new FileReader();
  3007. fileReader.onload = function webViewerChangeFileReaderOnload(event) {
  3008. var buffer = event.target.result;
  3009. PDFViewerApplication.open(new Uint8Array(buffer));
  3010. };
  3011. fileReader.readAsArrayBuffer(file);
  3012. }
  3013. var appConfig = PDFViewerApplication.appConfig;
  3014. appConfig.toolbar.viewBookmark.setAttribute("hidden", "true");
  3015. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute("hidden", "true");
  3016. appConfig.toolbar.download.setAttribute("hidden", "true");
  3017. appConfig.secondaryToolbar.downloadButton.setAttribute("hidden", "true");
  3018. };
  3019. webViewerOpenFile = function webViewerOpenFile(evt) {
  3020. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  3021. document.getElementById(openFileInputName).click();
  3022. };
  3023. }
  3024. function webViewerPresentationMode() {
  3025. PDFViewerApplication.requestPresentationMode();
  3026. }
  3027. function webViewerPrint() {
  3028. PDFViewerApplication.triggerPrinting();
  3029. }
  3030. function webViewerDownload() {
  3031. PDFViewerApplication.downloadOrSave({
  3032. sourceEventType: "download"
  3033. });
  3034. }
  3035. function webViewerSave() {
  3036. PDFViewerApplication.downloadOrSave({
  3037. sourceEventType: "save"
  3038. });
  3039. }
  3040. function webViewerFirstPage() {
  3041. if (PDFViewerApplication.pdfDocument) {
  3042. PDFViewerApplication.page = 1;
  3043. }
  3044. }
  3045. function webViewerLastPage() {
  3046. if (PDFViewerApplication.pdfDocument) {
  3047. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3048. }
  3049. }
  3050. function webViewerNextPage() {
  3051. PDFViewerApplication.pdfViewer.nextPage();
  3052. }
  3053. function webViewerPreviousPage() {
  3054. PDFViewerApplication.pdfViewer.previousPage();
  3055. }
  3056. function webViewerZoomIn() {
  3057. PDFViewerApplication.zoomIn();
  3058. }
  3059. function webViewerZoomOut() {
  3060. PDFViewerApplication.zoomOut();
  3061. }
  3062. function webViewerZoomReset() {
  3063. PDFViewerApplication.zoomReset();
  3064. }
  3065. function webViewerPageNumberChanged(evt) {
  3066. var pdfViewer = PDFViewerApplication.pdfViewer;
  3067. if (evt.value !== "") {
  3068. PDFViewerApplication.pdfLinkService.goToPage(evt.value);
  3069. }
  3070. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  3071. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  3072. }
  3073. }
  3074. function webViewerScaleChanged(evt) {
  3075. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  3076. }
  3077. function webViewerRotateCw() {
  3078. PDFViewerApplication.rotatePages(90);
  3079. }
  3080. function webViewerRotateCcw() {
  3081. PDFViewerApplication.rotatePages(-90);
  3082. }
  3083. function webViewerOptionalContentConfig(evt) {
  3084. PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
  3085. }
  3086. function webViewerSwitchScrollMode(evt) {
  3087. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  3088. }
  3089. function webViewerSwitchSpreadMode(evt) {
  3090. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  3091. }
  3092. function webViewerDocumentProperties() {
  3093. PDFViewerApplication.pdfDocumentProperties.open();
  3094. }
  3095. function webViewerFind(evt) {
  3096. PDFViewerApplication.findController.executeCommand("find" + evt.type, {
  3097. query: evt.query,
  3098. phraseSearch: evt.phraseSearch,
  3099. caseSensitive: evt.caseSensitive,
  3100. entireWord: evt.entireWord,
  3101. highlightAll: evt.highlightAll,
  3102. findPrevious: evt.findPrevious
  3103. });
  3104. }
  3105. function webViewerFindFromUrlHash(evt) {
  3106. PDFViewerApplication.findController.executeCommand("find", {
  3107. query: evt.query,
  3108. phraseSearch: evt.phraseSearch,
  3109. caseSensitive: false,
  3110. entireWord: false,
  3111. highlightAll: true,
  3112. findPrevious: false
  3113. });
  3114. }
  3115. function webViewerUpdateFindMatchesCount(_ref20) {
  3116. var matchesCount = _ref20.matchesCount;
  3117. if (PDFViewerApplication.supportsIntegratedFind) {
  3118. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  3119. } else {
  3120. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  3121. }
  3122. }
  3123. function webViewerUpdateFindControlState(_ref21) {
  3124. var state = _ref21.state,
  3125. previous = _ref21.previous,
  3126. matchesCount = _ref21.matchesCount,
  3127. rawQuery = _ref21.rawQuery;
  3128. if (PDFViewerApplication.supportsIntegratedFind) {
  3129. PDFViewerApplication.externalServices.updateFindControlState({
  3130. result: state,
  3131. findPrevious: previous,
  3132. matchesCount: matchesCount,
  3133. rawQuery: rawQuery
  3134. });
  3135. } else {
  3136. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  3137. }
  3138. }
  3139. function webViewerScaleChanging(evt) {
  3140. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  3141. PDFViewerApplication.pdfViewer.update();
  3142. }
  3143. function webViewerRotationChanging(evt) {
  3144. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  3145. PDFViewerApplication.forceRendering();
  3146. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  3147. }
  3148. function webViewerPageChanging(_ref22) {
  3149. var pageNumber = _ref22.pageNumber,
  3150. pageLabel = _ref22.pageLabel;
  3151. PDFViewerApplication.toolbar.setPageNumber(pageNumber, pageLabel);
  3152. PDFViewerApplication.secondaryToolbar.setPageNumber(pageNumber);
  3153. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  3154. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(pageNumber);
  3155. }
  3156. }
  3157. function webViewerVisibilityChange(evt) {
  3158. if (document.visibilityState === "visible") {
  3159. setZoomDisabledTimeout();
  3160. }
  3161. }
  3162. var zoomDisabledTimeout = null;
  3163. function setZoomDisabledTimeout() {
  3164. if (zoomDisabledTimeout) {
  3165. clearTimeout(zoomDisabledTimeout);
  3166. }
  3167. zoomDisabledTimeout = setTimeout(function () {
  3168. zoomDisabledTimeout = null;
  3169. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  3170. }
  3171. function webViewerWheel(evt) {
  3172. var pdfViewer = PDFViewerApplication.pdfViewer,
  3173. supportedMouseWheelZoomModifierKeys = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  3174. if (pdfViewer.isInPresentationMode) {
  3175. return;
  3176. }
  3177. if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
  3178. evt.preventDefault();
  3179. if (zoomDisabledTimeout || document.visibilityState === "hidden") {
  3180. return;
  3181. }
  3182. var previousScale = pdfViewer.currentScale;
  3183. var delta = (0, _ui_utils.normalizeWheelEventDirection)(evt);
  3184. var ticks = 0;
  3185. if (evt.deltaMode === WheelEvent.DOM_DELTA_LINE || evt.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
  3186. if (Math.abs(delta) >= 1) {
  3187. ticks = Math.sign(delta);
  3188. } else {
  3189. ticks = PDFViewerApplication.accumulateWheelTicks(delta);
  3190. }
  3191. } else {
  3192. var PIXELS_PER_LINE_SCALE = 30;
  3193. ticks = PDFViewerApplication.accumulateWheelTicks(delta / PIXELS_PER_LINE_SCALE);
  3194. }
  3195. if (ticks < 0) {
  3196. PDFViewerApplication.zoomOut(-ticks);
  3197. } else if (ticks > 0) {
  3198. PDFViewerApplication.zoomIn(ticks);
  3199. }
  3200. var currentScale = pdfViewer.currentScale;
  3201. if (previousScale !== currentScale) {
  3202. var scaleCorrectionFactor = currentScale / previousScale - 1;
  3203. var rect = pdfViewer.container.getBoundingClientRect();
  3204. var dx = evt.clientX - rect.left;
  3205. var dy = evt.clientY - rect.top;
  3206. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  3207. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  3208. }
  3209. } else {
  3210. setZoomDisabledTimeout();
  3211. }
  3212. }
  3213. function webViewerTouchStart(evt) {
  3214. if (evt.touches.length > 1) {
  3215. evt.preventDefault();
  3216. }
  3217. }
  3218. function webViewerClick(evt) {
  3219. if (PDFViewerApplication.triggerDelayedFallback && PDFViewerApplication.pdfViewer.containsElement(evt.target)) {
  3220. PDFViewerApplication.triggerDelayedFallback();
  3221. }
  3222. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  3223. return;
  3224. }
  3225. var appConfig = PDFViewerApplication.appConfig;
  3226. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  3227. PDFViewerApplication.secondaryToolbar.close();
  3228. }
  3229. }
  3230. function webViewerKeyUp(evt) {
  3231. if (evt.keyCode === 9) {
  3232. if (PDFViewerApplication.triggerDelayedFallback) {
  3233. PDFViewerApplication.triggerDelayedFallback();
  3234. }
  3235. }
  3236. }
  3237. function webViewerKeyDown(evt) {
  3238. if (PDFViewerApplication.overlayManager.active) {
  3239. return;
  3240. }
  3241. var handled = false,
  3242. ensureViewerFocused = false;
  3243. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  3244. var pdfViewer = PDFViewerApplication.pdfViewer;
  3245. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  3246. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  3247. switch (evt.keyCode) {
  3248. case 70:
  3249. if (!PDFViewerApplication.supportsIntegratedFind && !evt.shiftKey) {
  3250. PDFViewerApplication.findBar.open();
  3251. handled = true;
  3252. }
  3253. break;
  3254. case 71:
  3255. if (!PDFViewerApplication.supportsIntegratedFind) {
  3256. var findState = PDFViewerApplication.findController.state;
  3257. if (findState) {
  3258. PDFViewerApplication.findController.executeCommand("findagain", {
  3259. query: findState.query,
  3260. phraseSearch: findState.phraseSearch,
  3261. caseSensitive: findState.caseSensitive,
  3262. entireWord: findState.entireWord,
  3263. highlightAll: findState.highlightAll,
  3264. findPrevious: cmd === 5 || cmd === 12
  3265. });
  3266. }
  3267. handled = true;
  3268. }
  3269. break;
  3270. case 61:
  3271. case 107:
  3272. case 187:
  3273. case 171:
  3274. if (!isViewerInPresentationMode) {
  3275. PDFViewerApplication.zoomIn();
  3276. }
  3277. handled = true;
  3278. break;
  3279. case 173:
  3280. case 109:
  3281. case 189:
  3282. if (!isViewerInPresentationMode) {
  3283. PDFViewerApplication.zoomOut();
  3284. }
  3285. handled = true;
  3286. break;
  3287. case 48:
  3288. case 96:
  3289. if (!isViewerInPresentationMode) {
  3290. setTimeout(function () {
  3291. PDFViewerApplication.zoomReset();
  3292. });
  3293. handled = false;
  3294. }
  3295. break;
  3296. case 38:
  3297. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3298. PDFViewerApplication.page = 1;
  3299. handled = true;
  3300. ensureViewerFocused = true;
  3301. }
  3302. break;
  3303. case 40:
  3304. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  3305. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3306. handled = true;
  3307. ensureViewerFocused = true;
  3308. }
  3309. break;
  3310. }
  3311. }
  3312. var eventBus = PDFViewerApplication.eventBus;
  3313. if (cmd === 1 || cmd === 8) {
  3314. switch (evt.keyCode) {
  3315. case 83:
  3316. eventBus.dispatch("download", {
  3317. source: window
  3318. });
  3319. handled = true;
  3320. break;
  3321. case 79:
  3322. {
  3323. eventBus.dispatch("openfile", {
  3324. source: window
  3325. });
  3326. handled = true;
  3327. }
  3328. break;
  3329. }
  3330. }
  3331. if (cmd === 3 || cmd === 10) {
  3332. switch (evt.keyCode) {
  3333. case 80:
  3334. PDFViewerApplication.requestPresentationMode();
  3335. handled = true;
  3336. break;
  3337. case 71:
  3338. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  3339. handled = true;
  3340. break;
  3341. }
  3342. }
  3343. if (handled) {
  3344. if (ensureViewerFocused && !isViewerInPresentationMode) {
  3345. pdfViewer.focus();
  3346. }
  3347. evt.preventDefault();
  3348. return;
  3349. }
  3350. var curElement = (0, _ui_utils.getActiveOrFocusedElement)();
  3351. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  3352. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement && curElement.isContentEditable) {
  3353. if (evt.keyCode !== 27) {
  3354. return;
  3355. }
  3356. }
  3357. if (cmd === 0) {
  3358. var turnPage = 0,
  3359. turnOnlyIfPageFit = false;
  3360. switch (evt.keyCode) {
  3361. case 38:
  3362. case 33:
  3363. if (pdfViewer.isVerticalScrollbarEnabled) {
  3364. turnOnlyIfPageFit = true;
  3365. }
  3366. turnPage = -1;
  3367. break;
  3368. case 8:
  3369. if (!isViewerInPresentationMode) {
  3370. turnOnlyIfPageFit = true;
  3371. }
  3372. turnPage = -1;
  3373. break;
  3374. case 37:
  3375. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3376. turnOnlyIfPageFit = true;
  3377. }
  3378. case 75:
  3379. case 80:
  3380. turnPage = -1;
  3381. break;
  3382. case 27:
  3383. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  3384. PDFViewerApplication.secondaryToolbar.close();
  3385. handled = true;
  3386. }
  3387. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  3388. PDFViewerApplication.findBar.close();
  3389. handled = true;
  3390. }
  3391. break;
  3392. case 40:
  3393. case 34:
  3394. if (pdfViewer.isVerticalScrollbarEnabled) {
  3395. turnOnlyIfPageFit = true;
  3396. }
  3397. turnPage = 1;
  3398. break;
  3399. case 13:
  3400. case 32:
  3401. if (!isViewerInPresentationMode) {
  3402. turnOnlyIfPageFit = true;
  3403. }
  3404. turnPage = 1;
  3405. break;
  3406. case 39:
  3407. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3408. turnOnlyIfPageFit = true;
  3409. }
  3410. case 74:
  3411. case 78:
  3412. turnPage = 1;
  3413. break;
  3414. case 36:
  3415. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3416. PDFViewerApplication.page = 1;
  3417. handled = true;
  3418. ensureViewerFocused = true;
  3419. }
  3420. break;
  3421. case 35:
  3422. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  3423. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3424. handled = true;
  3425. ensureViewerFocused = true;
  3426. }
  3427. break;
  3428. case 83:
  3429. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  3430. break;
  3431. case 72:
  3432. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  3433. break;
  3434. case 82:
  3435. PDFViewerApplication.rotatePages(90);
  3436. break;
  3437. case 115:
  3438. PDFViewerApplication.pdfSidebar.toggle();
  3439. break;
  3440. }
  3441. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  3442. if (turnPage > 0) {
  3443. pdfViewer.nextPage();
  3444. } else {
  3445. pdfViewer.previousPage();
  3446. }
  3447. handled = true;
  3448. }
  3449. }
  3450. if (cmd === 4) {
  3451. switch (evt.keyCode) {
  3452. case 13:
  3453. case 32:
  3454. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  3455. break;
  3456. }
  3457. if (PDFViewerApplication.page > 1) {
  3458. PDFViewerApplication.page--;
  3459. }
  3460. handled = true;
  3461. break;
  3462. case 82:
  3463. PDFViewerApplication.rotatePages(-90);
  3464. break;
  3465. }
  3466. }
  3467. if (!handled && !isViewerInPresentationMode) {
  3468. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  3469. ensureViewerFocused = true;
  3470. }
  3471. }
  3472. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  3473. pdfViewer.focus();
  3474. }
  3475. if (handled) {
  3476. evt.preventDefault();
  3477. }
  3478. }
  3479. function beforeUnload(evt) {
  3480. evt.preventDefault();
  3481. evt.returnValue = "";
  3482. return false;
  3483. }
  3484. function apiPageLayoutToSpreadMode(layout) {
  3485. switch (layout) {
  3486. case "SinglePage":
  3487. case "OneColumn":
  3488. return _ui_utils.SpreadMode.NONE;
  3489. case "TwoColumnLeft":
  3490. case "TwoPageLeft":
  3491. return _ui_utils.SpreadMode.ODD;
  3492. case "TwoColumnRight":
  3493. case "TwoPageRight":
  3494. return _ui_utils.SpreadMode.EVEN;
  3495. }
  3496. return _ui_utils.SpreadMode.NONE;
  3497. }
  3498. function apiPageModeToSidebarView(mode) {
  3499. switch (mode) {
  3500. case "UseNone":
  3501. return _ui_utils.SidebarView.NONE;
  3502. case "UseThumbs":
  3503. return _ui_utils.SidebarView.THUMBS;
  3504. case "UseOutlines":
  3505. return _ui_utils.SidebarView.OUTLINE;
  3506. case "UseAttachments":
  3507. return _ui_utils.SidebarView.ATTACHMENTS;
  3508. case "UseOC":
  3509. return _ui_utils.SidebarView.LAYERS;
  3510. }
  3511. return _ui_utils.SidebarView.NONE;
  3512. }
  3513. var PDFPrintServiceFactory = {
  3514. instance: {
  3515. supportsPrinting: false,
  3516. createPrintService: function createPrintService() {
  3517. throw new Error("Not implemented: createPrintService");
  3518. }
  3519. }
  3520. };
  3521. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  3522. /***/ }),
  3523. /* 4 */
  3524. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3525. module.exports = __webpack_require__(5);
  3526. /***/ }),
  3527. /* 5 */
  3528. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3529. /* module decorator */ module = __webpack_require__.nmd(module);
  3530. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3531. var runtime = function (exports) {
  3532. "use strict";
  3533. var Op = Object.prototype;
  3534. var hasOwn = Op.hasOwnProperty;
  3535. var undefined;
  3536. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  3537. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  3538. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  3539. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  3540. function define(obj, key, value) {
  3541. Object.defineProperty(obj, key, {
  3542. value: value,
  3543. enumerable: true,
  3544. configurable: true,
  3545. writable: true
  3546. });
  3547. return obj[key];
  3548. }
  3549. try {
  3550. define({}, "");
  3551. } catch (err) {
  3552. define = function define(obj, key, value) {
  3553. return obj[key] = value;
  3554. };
  3555. }
  3556. function wrap(innerFn, outerFn, self, tryLocsList) {
  3557. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  3558. var generator = Object.create(protoGenerator.prototype);
  3559. var context = new Context(tryLocsList || []);
  3560. generator._invoke = makeInvokeMethod(innerFn, self, context);
  3561. return generator;
  3562. }
  3563. exports.wrap = wrap;
  3564. function tryCatch(fn, obj, arg) {
  3565. try {
  3566. return {
  3567. type: "normal",
  3568. arg: fn.call(obj, arg)
  3569. };
  3570. } catch (err) {
  3571. return {
  3572. type: "throw",
  3573. arg: err
  3574. };
  3575. }
  3576. }
  3577. var GenStateSuspendedStart = "suspendedStart";
  3578. var GenStateSuspendedYield = "suspendedYield";
  3579. var GenStateExecuting = "executing";
  3580. var GenStateCompleted = "completed";
  3581. var ContinueSentinel = {};
  3582. function Generator() {}
  3583. function GeneratorFunction() {}
  3584. function GeneratorFunctionPrototype() {}
  3585. var IteratorPrototype = {};
  3586. IteratorPrototype[iteratorSymbol] = function () {
  3587. return this;
  3588. };
  3589. var getProto = Object.getPrototypeOf;
  3590. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  3591. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  3592. IteratorPrototype = NativeIteratorPrototype;
  3593. }
  3594. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  3595. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  3596. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  3597. GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
  3598. function defineIteratorMethods(prototype) {
  3599. ["next", "throw", "return"].forEach(function (method) {
  3600. define(prototype, method, function (arg) {
  3601. return this._invoke(method, arg);
  3602. });
  3603. });
  3604. }
  3605. exports.isGeneratorFunction = function (genFun) {
  3606. var ctor = typeof genFun === "function" && genFun.constructor;
  3607. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  3608. };
  3609. exports.mark = function (genFun) {
  3610. if (Object.setPrototypeOf) {
  3611. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  3612. } else {
  3613. genFun.__proto__ = GeneratorFunctionPrototype;
  3614. define(genFun, toStringTagSymbol, "GeneratorFunction");
  3615. }
  3616. genFun.prototype = Object.create(Gp);
  3617. return genFun;
  3618. };
  3619. exports.awrap = function (arg) {
  3620. return {
  3621. __await: arg
  3622. };
  3623. };
  3624. function AsyncIterator(generator, PromiseImpl) {
  3625. function invoke(method, arg, resolve, reject) {
  3626. var record = tryCatch(generator[method], generator, arg);
  3627. if (record.type === "throw") {
  3628. reject(record.arg);
  3629. } else {
  3630. var result = record.arg;
  3631. var value = result.value;
  3632. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  3633. return PromiseImpl.resolve(value.__await).then(function (value) {
  3634. invoke("next", value, resolve, reject);
  3635. }, function (err) {
  3636. invoke("throw", err, resolve, reject);
  3637. });
  3638. }
  3639. return PromiseImpl.resolve(value).then(function (unwrapped) {
  3640. result.value = unwrapped;
  3641. resolve(result);
  3642. }, function (error) {
  3643. return invoke("throw", error, resolve, reject);
  3644. });
  3645. }
  3646. }
  3647. var previousPromise;
  3648. function enqueue(method, arg) {
  3649. function callInvokeWithMethodAndArg() {
  3650. return new PromiseImpl(function (resolve, reject) {
  3651. invoke(method, arg, resolve, reject);
  3652. });
  3653. }
  3654. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  3655. }
  3656. this._invoke = enqueue;
  3657. }
  3658. defineIteratorMethods(AsyncIterator.prototype);
  3659. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  3660. return this;
  3661. };
  3662. exports.AsyncIterator = AsyncIterator;
  3663. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  3664. if (PromiseImpl === void 0) PromiseImpl = Promise;
  3665. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  3666. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  3667. return result.done ? result.value : iter.next();
  3668. });
  3669. };
  3670. function makeInvokeMethod(innerFn, self, context) {
  3671. var state = GenStateSuspendedStart;
  3672. return function invoke(method, arg) {
  3673. if (state === GenStateExecuting) {
  3674. throw new Error("Generator is already running");
  3675. }
  3676. if (state === GenStateCompleted) {
  3677. if (method === "throw") {
  3678. throw arg;
  3679. }
  3680. return doneResult();
  3681. }
  3682. context.method = method;
  3683. context.arg = arg;
  3684. while (true) {
  3685. var delegate = context.delegate;
  3686. if (delegate) {
  3687. var delegateResult = maybeInvokeDelegate(delegate, context);
  3688. if (delegateResult) {
  3689. if (delegateResult === ContinueSentinel) continue;
  3690. return delegateResult;
  3691. }
  3692. }
  3693. if (context.method === "next") {
  3694. context.sent = context._sent = context.arg;
  3695. } else if (context.method === "throw") {
  3696. if (state === GenStateSuspendedStart) {
  3697. state = GenStateCompleted;
  3698. throw context.arg;
  3699. }
  3700. context.dispatchException(context.arg);
  3701. } else if (context.method === "return") {
  3702. context.abrupt("return", context.arg);
  3703. }
  3704. state = GenStateExecuting;
  3705. var record = tryCatch(innerFn, self, context);
  3706. if (record.type === "normal") {
  3707. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  3708. if (record.arg === ContinueSentinel) {
  3709. continue;
  3710. }
  3711. return {
  3712. value: record.arg,
  3713. done: context.done
  3714. };
  3715. } else if (record.type === "throw") {
  3716. state = GenStateCompleted;
  3717. context.method = "throw";
  3718. context.arg = record.arg;
  3719. }
  3720. }
  3721. };
  3722. }
  3723. function maybeInvokeDelegate(delegate, context) {
  3724. var method = delegate.iterator[context.method];
  3725. if (method === undefined) {
  3726. context.delegate = null;
  3727. if (context.method === "throw") {
  3728. if (delegate.iterator["return"]) {
  3729. context.method = "return";
  3730. context.arg = undefined;
  3731. maybeInvokeDelegate(delegate, context);
  3732. if (context.method === "throw") {
  3733. return ContinueSentinel;
  3734. }
  3735. }
  3736. context.method = "throw";
  3737. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  3738. }
  3739. return ContinueSentinel;
  3740. }
  3741. var record = tryCatch(method, delegate.iterator, context.arg);
  3742. if (record.type === "throw") {
  3743. context.method = "throw";
  3744. context.arg = record.arg;
  3745. context.delegate = null;
  3746. return ContinueSentinel;
  3747. }
  3748. var info = record.arg;
  3749. if (!info) {
  3750. context.method = "throw";
  3751. context.arg = new TypeError("iterator result is not an object");
  3752. context.delegate = null;
  3753. return ContinueSentinel;
  3754. }
  3755. if (info.done) {
  3756. context[delegate.resultName] = info.value;
  3757. context.next = delegate.nextLoc;
  3758. if (context.method !== "return") {
  3759. context.method = "next";
  3760. context.arg = undefined;
  3761. }
  3762. } else {
  3763. return info;
  3764. }
  3765. context.delegate = null;
  3766. return ContinueSentinel;
  3767. }
  3768. defineIteratorMethods(Gp);
  3769. define(Gp, toStringTagSymbol, "Generator");
  3770. Gp[iteratorSymbol] = function () {
  3771. return this;
  3772. };
  3773. Gp.toString = function () {
  3774. return "[object Generator]";
  3775. };
  3776. function pushTryEntry(locs) {
  3777. var entry = {
  3778. tryLoc: locs[0]
  3779. };
  3780. if (1 in locs) {
  3781. entry.catchLoc = locs[1];
  3782. }
  3783. if (2 in locs) {
  3784. entry.finallyLoc = locs[2];
  3785. entry.afterLoc = locs[3];
  3786. }
  3787. this.tryEntries.push(entry);
  3788. }
  3789. function resetTryEntry(entry) {
  3790. var record = entry.completion || {};
  3791. record.type = "normal";
  3792. delete record.arg;
  3793. entry.completion = record;
  3794. }
  3795. function Context(tryLocsList) {
  3796. this.tryEntries = [{
  3797. tryLoc: "root"
  3798. }];
  3799. tryLocsList.forEach(pushTryEntry, this);
  3800. this.reset(true);
  3801. }
  3802. exports.keys = function (object) {
  3803. var keys = [];
  3804. for (var key in object) {
  3805. keys.push(key);
  3806. }
  3807. keys.reverse();
  3808. return function next() {
  3809. while (keys.length) {
  3810. var key = keys.pop();
  3811. if (key in object) {
  3812. next.value = key;
  3813. next.done = false;
  3814. return next;
  3815. }
  3816. }
  3817. next.done = true;
  3818. return next;
  3819. };
  3820. };
  3821. function values(iterable) {
  3822. if (iterable) {
  3823. var iteratorMethod = iterable[iteratorSymbol];
  3824. if (iteratorMethod) {
  3825. return iteratorMethod.call(iterable);
  3826. }
  3827. if (typeof iterable.next === "function") {
  3828. return iterable;
  3829. }
  3830. if (!isNaN(iterable.length)) {
  3831. var i = -1,
  3832. next = function next() {
  3833. while (++i < iterable.length) {
  3834. if (hasOwn.call(iterable, i)) {
  3835. next.value = iterable[i];
  3836. next.done = false;
  3837. return next;
  3838. }
  3839. }
  3840. next.value = undefined;
  3841. next.done = true;
  3842. return next;
  3843. };
  3844. return next.next = next;
  3845. }
  3846. }
  3847. return {
  3848. next: doneResult
  3849. };
  3850. }
  3851. exports.values = values;
  3852. function doneResult() {
  3853. return {
  3854. value: undefined,
  3855. done: true
  3856. };
  3857. }
  3858. Context.prototype = {
  3859. constructor: Context,
  3860. reset: function reset(skipTempReset) {
  3861. this.prev = 0;
  3862. this.next = 0;
  3863. this.sent = this._sent = undefined;
  3864. this.done = false;
  3865. this.delegate = null;
  3866. this.method = "next";
  3867. this.arg = undefined;
  3868. this.tryEntries.forEach(resetTryEntry);
  3869. if (!skipTempReset) {
  3870. for (var name in this) {
  3871. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  3872. this[name] = undefined;
  3873. }
  3874. }
  3875. }
  3876. },
  3877. stop: function stop() {
  3878. this.done = true;
  3879. var rootEntry = this.tryEntries[0];
  3880. var rootRecord = rootEntry.completion;
  3881. if (rootRecord.type === "throw") {
  3882. throw rootRecord.arg;
  3883. }
  3884. return this.rval;
  3885. },
  3886. dispatchException: function dispatchException(exception) {
  3887. if (this.done) {
  3888. throw exception;
  3889. }
  3890. var context = this;
  3891. function handle(loc, caught) {
  3892. record.type = "throw";
  3893. record.arg = exception;
  3894. context.next = loc;
  3895. if (caught) {
  3896. context.method = "next";
  3897. context.arg = undefined;
  3898. }
  3899. return !!caught;
  3900. }
  3901. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3902. var entry = this.tryEntries[i];
  3903. var record = entry.completion;
  3904. if (entry.tryLoc === "root") {
  3905. return handle("end");
  3906. }
  3907. if (entry.tryLoc <= this.prev) {
  3908. var hasCatch = hasOwn.call(entry, "catchLoc");
  3909. var hasFinally = hasOwn.call(entry, "finallyLoc");
  3910. if (hasCatch && hasFinally) {
  3911. if (this.prev < entry.catchLoc) {
  3912. return handle(entry.catchLoc, true);
  3913. } else if (this.prev < entry.finallyLoc) {
  3914. return handle(entry.finallyLoc);
  3915. }
  3916. } else if (hasCatch) {
  3917. if (this.prev < entry.catchLoc) {
  3918. return handle(entry.catchLoc, true);
  3919. }
  3920. } else if (hasFinally) {
  3921. if (this.prev < entry.finallyLoc) {
  3922. return handle(entry.finallyLoc);
  3923. }
  3924. } else {
  3925. throw new Error("try statement without catch or finally");
  3926. }
  3927. }
  3928. }
  3929. },
  3930. abrupt: function abrupt(type, arg) {
  3931. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3932. var entry = this.tryEntries[i];
  3933. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  3934. var finallyEntry = entry;
  3935. break;
  3936. }
  3937. }
  3938. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  3939. finallyEntry = null;
  3940. }
  3941. var record = finallyEntry ? finallyEntry.completion : {};
  3942. record.type = type;
  3943. record.arg = arg;
  3944. if (finallyEntry) {
  3945. this.method = "next";
  3946. this.next = finallyEntry.finallyLoc;
  3947. return ContinueSentinel;
  3948. }
  3949. return this.complete(record);
  3950. },
  3951. complete: function complete(record, afterLoc) {
  3952. if (record.type === "throw") {
  3953. throw record.arg;
  3954. }
  3955. if (record.type === "break" || record.type === "continue") {
  3956. this.next = record.arg;
  3957. } else if (record.type === "return") {
  3958. this.rval = this.arg = record.arg;
  3959. this.method = "return";
  3960. this.next = "end";
  3961. } else if (record.type === "normal" && afterLoc) {
  3962. this.next = afterLoc;
  3963. }
  3964. return ContinueSentinel;
  3965. },
  3966. finish: function finish(finallyLoc) {
  3967. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3968. var entry = this.tryEntries[i];
  3969. if (entry.finallyLoc === finallyLoc) {
  3970. this.complete(entry.completion, entry.afterLoc);
  3971. resetTryEntry(entry);
  3972. return ContinueSentinel;
  3973. }
  3974. }
  3975. },
  3976. "catch": function _catch(tryLoc) {
  3977. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3978. var entry = this.tryEntries[i];
  3979. if (entry.tryLoc === tryLoc) {
  3980. var record = entry.completion;
  3981. if (record.type === "throw") {
  3982. var thrown = record.arg;
  3983. resetTryEntry(entry);
  3984. }
  3985. return thrown;
  3986. }
  3987. }
  3988. throw new Error("illegal catch attempt");
  3989. },
  3990. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  3991. this.delegate = {
  3992. iterator: values(iterable),
  3993. resultName: resultName,
  3994. nextLoc: nextLoc
  3995. };
  3996. if (this.method === "next") {
  3997. this.arg = undefined;
  3998. }
  3999. return ContinueSentinel;
  4000. }
  4001. };
  4002. return exports;
  4003. }(( false ? 0 : _typeof(module)) === "object" ? module.exports : {});
  4004. try {
  4005. regeneratorRuntime = runtime;
  4006. } catch (accidentalStrictMode) {
  4007. Function("r", "regeneratorRuntime = r")(runtime);
  4008. }
  4009. /***/ }),
  4010. /* 6 */
  4011. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4012. Object.defineProperty(exports, "__esModule", ({
  4013. value: true
  4014. }));
  4015. exports.approximateFraction = approximateFraction;
  4016. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  4017. exports.binarySearchFirstItem = binarySearchFirstItem;
  4018. exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
  4019. exports.getOutputScale = getOutputScale;
  4020. exports.getPageSizeInches = getPageSizeInches;
  4021. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  4022. exports.getVisibleElements = getVisibleElements;
  4023. exports.isPortraitOrientation = isPortraitOrientation;
  4024. exports.isValidRotation = isValidRotation;
  4025. exports.isValidScrollMode = isValidScrollMode;
  4026. exports.isValidSpreadMode = isValidSpreadMode;
  4027. exports.moveToEndOfArray = moveToEndOfArray;
  4028. exports.noContextMenuHandler = noContextMenuHandler;
  4029. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  4030. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  4031. exports.parseQueryString = parseQueryString;
  4032. exports.roundToDivide = roundToDivide;
  4033. exports.scrollIntoView = scrollIntoView;
  4034. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  4035. exports.watchScroll = watchScroll;
  4036. exports.WaitOnType = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports.TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports.SCROLLBAR_PADDING = exports.RendererType = exports.ProgressBar = exports.PresentationModeState = exports.NullL10n = exports.MIN_SCALE = exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.EventBus = exports.DEFAULT_SCALE_VALUE = exports.DEFAULT_SCALE = exports.CSS_UNITS = exports.AutoPrintRegExp = exports.animationStarted = void 0;
  4037. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  4038. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4039. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4040. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4041. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4042. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  4043. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  4044. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  4045. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  4046. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  4047. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  4048. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  4049. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  4050. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  4051. var CSS_UNITS = 96.0 / 72.0;
  4052. exports.CSS_UNITS = CSS_UNITS;
  4053. var DEFAULT_SCALE_VALUE = "auto";
  4054. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  4055. var DEFAULT_SCALE = 1.0;
  4056. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  4057. var MIN_SCALE = 0.1;
  4058. exports.MIN_SCALE = MIN_SCALE;
  4059. var MAX_SCALE = 10.0;
  4060. exports.MAX_SCALE = MAX_SCALE;
  4061. var UNKNOWN_SCALE = 0;
  4062. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  4063. var MAX_AUTO_SCALE = 1.25;
  4064. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  4065. var SCROLLBAR_PADDING = 40;
  4066. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  4067. var VERTICAL_PADDING = 5;
  4068. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  4069. var LOADINGBAR_END_OFFSET_VAR = "--loadingBar-end-offset";
  4070. var PresentationModeState = {
  4071. UNKNOWN: 0,
  4072. NORMAL: 1,
  4073. CHANGING: 2,
  4074. FULLSCREEN: 3
  4075. };
  4076. exports.PresentationModeState = PresentationModeState;
  4077. var SidebarView = {
  4078. UNKNOWN: -1,
  4079. NONE: 0,
  4080. THUMBS: 1,
  4081. OUTLINE: 2,
  4082. ATTACHMENTS: 3,
  4083. LAYERS: 4
  4084. };
  4085. exports.SidebarView = SidebarView;
  4086. var RendererType = {
  4087. CANVAS: "canvas",
  4088. SVG: "svg"
  4089. };
  4090. exports.RendererType = RendererType;
  4091. var TextLayerMode = {
  4092. DISABLE: 0,
  4093. ENABLE: 1,
  4094. ENABLE_ENHANCE: 2
  4095. };
  4096. exports.TextLayerMode = TextLayerMode;
  4097. var ScrollMode = {
  4098. UNKNOWN: -1,
  4099. VERTICAL: 0,
  4100. HORIZONTAL: 1,
  4101. WRAPPED: 2
  4102. };
  4103. exports.ScrollMode = ScrollMode;
  4104. var SpreadMode = {
  4105. UNKNOWN: -1,
  4106. NONE: 0,
  4107. ODD: 1,
  4108. EVEN: 2
  4109. };
  4110. exports.SpreadMode = SpreadMode;
  4111. var AutoPrintRegExp = /\bprint\s*\(/;
  4112. exports.AutoPrintRegExp = AutoPrintRegExp;
  4113. function formatL10nValue(text, args) {
  4114. if (!args) {
  4115. return text;
  4116. }
  4117. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  4118. return name in args ? args[name] : "{{" + name + "}}";
  4119. });
  4120. }
  4121. var NullL10n = {
  4122. getLanguage: function getLanguage() {
  4123. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  4124. return _regenerator["default"].wrap(function _callee$(_context) {
  4125. while (1) {
  4126. switch (_context.prev = _context.next) {
  4127. case 0:
  4128. return _context.abrupt("return", "en-us");
  4129. case 1:
  4130. case "end":
  4131. return _context.stop();
  4132. }
  4133. }
  4134. }, _callee);
  4135. }))();
  4136. },
  4137. getDirection: function getDirection() {
  4138. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  4139. return _regenerator["default"].wrap(function _callee2$(_context2) {
  4140. while (1) {
  4141. switch (_context2.prev = _context2.next) {
  4142. case 0:
  4143. return _context2.abrupt("return", "ltr");
  4144. case 1:
  4145. case "end":
  4146. return _context2.stop();
  4147. }
  4148. }
  4149. }, _callee2);
  4150. }))();
  4151. },
  4152. get: function get(property, args, fallback) {
  4153. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  4154. return _regenerator["default"].wrap(function _callee3$(_context3) {
  4155. while (1) {
  4156. switch (_context3.prev = _context3.next) {
  4157. case 0:
  4158. return _context3.abrupt("return", formatL10nValue(fallback, args));
  4159. case 1:
  4160. case "end":
  4161. return _context3.stop();
  4162. }
  4163. }
  4164. }, _callee3);
  4165. }))();
  4166. },
  4167. translate: function translate(element) {
  4168. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  4169. return _regenerator["default"].wrap(function _callee4$(_context4) {
  4170. while (1) {
  4171. switch (_context4.prev = _context4.next) {
  4172. case 0:
  4173. case "end":
  4174. return _context4.stop();
  4175. }
  4176. }
  4177. }, _callee4);
  4178. }))();
  4179. }
  4180. };
  4181. exports.NullL10n = NullL10n;
  4182. function getOutputScale(ctx) {
  4183. var devicePixelRatio = window.devicePixelRatio || 1;
  4184. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  4185. var pixelRatio = devicePixelRatio / backingStoreRatio;
  4186. return {
  4187. sx: pixelRatio,
  4188. sy: pixelRatio,
  4189. scaled: pixelRatio !== 1
  4190. };
  4191. }
  4192. function scrollIntoView(element, spot) {
  4193. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4194. var parent = element.offsetParent;
  4195. if (!parent) {
  4196. console.error("offsetParent is not set -- cannot scroll");
  4197. return;
  4198. }
  4199. var offsetY = element.offsetTop + element.clientTop;
  4200. var offsetX = element.offsetLeft + element.clientLeft;
  4201. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === "hidden") {
  4202. if (parent.dataset._scaleY) {
  4203. offsetY /= parent.dataset._scaleY;
  4204. offsetX /= parent.dataset._scaleX;
  4205. }
  4206. offsetY += parent.offsetTop;
  4207. offsetX += parent.offsetLeft;
  4208. parent = parent.offsetParent;
  4209. if (!parent) {
  4210. return;
  4211. }
  4212. }
  4213. if (spot) {
  4214. if (spot.top !== undefined) {
  4215. offsetY += spot.top;
  4216. }
  4217. if (spot.left !== undefined) {
  4218. offsetX += spot.left;
  4219. parent.scrollLeft = offsetX;
  4220. }
  4221. }
  4222. parent.scrollTop = offsetY;
  4223. }
  4224. function watchScroll(viewAreaElement, callback) {
  4225. var debounceScroll = function debounceScroll(evt) {
  4226. if (rAF) {
  4227. return;
  4228. }
  4229. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  4230. rAF = null;
  4231. var currentX = viewAreaElement.scrollLeft;
  4232. var lastX = state.lastX;
  4233. if (currentX !== lastX) {
  4234. state.right = currentX > lastX;
  4235. }
  4236. state.lastX = currentX;
  4237. var currentY = viewAreaElement.scrollTop;
  4238. var lastY = state.lastY;
  4239. if (currentY !== lastY) {
  4240. state.down = currentY > lastY;
  4241. }
  4242. state.lastY = currentY;
  4243. callback(state);
  4244. });
  4245. };
  4246. var state = {
  4247. right: true,
  4248. down: true,
  4249. lastX: viewAreaElement.scrollLeft,
  4250. lastY: viewAreaElement.scrollTop,
  4251. _eventHandler: debounceScroll
  4252. };
  4253. var rAF = null;
  4254. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  4255. return state;
  4256. }
  4257. function parseQueryString(query) {
  4258. var parts = query.split("&");
  4259. var params = Object.create(null);
  4260. for (var i = 0, ii = parts.length; i < ii; ++i) {
  4261. var param = parts[i].split("=");
  4262. var key = param[0].toLowerCase();
  4263. var value = param.length > 1 ? param[1] : null;
  4264. params[decodeURIComponent(key)] = decodeURIComponent(value);
  4265. }
  4266. return params;
  4267. }
  4268. function binarySearchFirstItem(items, condition) {
  4269. var minIndex = 0;
  4270. var maxIndex = items.length - 1;
  4271. if (maxIndex < 0 || !condition(items[maxIndex])) {
  4272. return items.length;
  4273. }
  4274. if (condition(items[minIndex])) {
  4275. return minIndex;
  4276. }
  4277. while (minIndex < maxIndex) {
  4278. var currentIndex = minIndex + maxIndex >> 1;
  4279. var currentItem = items[currentIndex];
  4280. if (condition(currentItem)) {
  4281. maxIndex = currentIndex;
  4282. } else {
  4283. minIndex = currentIndex + 1;
  4284. }
  4285. }
  4286. return minIndex;
  4287. }
  4288. function approximateFraction(x) {
  4289. if (Math.floor(x) === x) {
  4290. return [x, 1];
  4291. }
  4292. var xinv = 1 / x;
  4293. var limit = 8;
  4294. if (xinv > limit) {
  4295. return [1, limit];
  4296. } else if (Math.floor(xinv) === xinv) {
  4297. return [1, xinv];
  4298. }
  4299. var x_ = x > 1 ? xinv : x;
  4300. var a = 0,
  4301. b = 1,
  4302. c = 1,
  4303. d = 1;
  4304. while (true) {
  4305. var p = a + c,
  4306. q = b + d;
  4307. if (q > limit) {
  4308. break;
  4309. }
  4310. if (x_ <= p / q) {
  4311. c = p;
  4312. d = q;
  4313. } else {
  4314. a = p;
  4315. b = q;
  4316. }
  4317. }
  4318. var result;
  4319. if (x_ - a / b < c / d - x_) {
  4320. result = x_ === x ? [a, b] : [b, a];
  4321. } else {
  4322. result = x_ === x ? [c, d] : [d, c];
  4323. }
  4324. return result;
  4325. }
  4326. function roundToDivide(x, div) {
  4327. var r = x % div;
  4328. return r === 0 ? x : Math.round(x - r + div);
  4329. }
  4330. function getPageSizeInches(_ref) {
  4331. var view = _ref.view,
  4332. userUnit = _ref.userUnit,
  4333. rotate = _ref.rotate;
  4334. var _view = _slicedToArray(view, 4),
  4335. x1 = _view[0],
  4336. y1 = _view[1],
  4337. x2 = _view[2],
  4338. y2 = _view[3];
  4339. var changeOrientation = rotate % 180 !== 0;
  4340. var width = (x2 - x1) / 72 * userUnit;
  4341. var height = (y2 - y1) / 72 * userUnit;
  4342. return {
  4343. width: changeOrientation ? height : width,
  4344. height: changeOrientation ? width : height
  4345. };
  4346. }
  4347. function backtrackBeforeAllVisibleElements(index, views, top) {
  4348. if (index < 2) {
  4349. return index;
  4350. }
  4351. var elt = views[index].div;
  4352. var pageTop = elt.offsetTop + elt.clientTop;
  4353. if (pageTop >= top) {
  4354. elt = views[index - 1].div;
  4355. pageTop = elt.offsetTop + elt.clientTop;
  4356. }
  4357. for (var i = index - 2; i >= 0; --i) {
  4358. elt = views[i].div;
  4359. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  4360. break;
  4361. }
  4362. index = i;
  4363. }
  4364. return index;
  4365. }
  4366. function getVisibleElements(_ref2) {
  4367. var scrollEl = _ref2.scrollEl,
  4368. views = _ref2.views,
  4369. _ref2$sortByVisibilit = _ref2.sortByVisibility,
  4370. sortByVisibility = _ref2$sortByVisibilit === void 0 ? false : _ref2$sortByVisibilit,
  4371. _ref2$horizontal = _ref2.horizontal,
  4372. horizontal = _ref2$horizontal === void 0 ? false : _ref2$horizontal,
  4373. _ref2$rtl = _ref2.rtl,
  4374. rtl = _ref2$rtl === void 0 ? false : _ref2$rtl;
  4375. var top = scrollEl.scrollTop,
  4376. bottom = top + scrollEl.clientHeight;
  4377. var left = scrollEl.scrollLeft,
  4378. right = left + scrollEl.clientWidth;
  4379. function isElementBottomAfterViewTop(view) {
  4380. var element = view.div;
  4381. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  4382. return elementBottom > top;
  4383. }
  4384. function isElementNextAfterViewHorizontally(view) {
  4385. var element = view.div;
  4386. var elementLeft = element.offsetLeft + element.clientLeft;
  4387. var elementRight = elementLeft + element.clientWidth;
  4388. return rtl ? elementLeft < right : elementRight > left;
  4389. }
  4390. var visible = [],
  4391. numViews = views.length;
  4392. var firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  4393. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  4394. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  4395. }
  4396. var lastEdge = horizontal ? right : -1;
  4397. for (var i = firstVisibleElementInd; i < numViews; i++) {
  4398. var view = views[i],
  4399. element = view.div;
  4400. var currentWidth = element.offsetLeft + element.clientLeft;
  4401. var currentHeight = element.offsetTop + element.clientTop;
  4402. var viewWidth = element.clientWidth,
  4403. viewHeight = element.clientHeight;
  4404. var viewRight = currentWidth + viewWidth;
  4405. var viewBottom = currentHeight + viewHeight;
  4406. if (lastEdge === -1) {
  4407. if (viewBottom >= bottom) {
  4408. lastEdge = viewBottom;
  4409. }
  4410. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  4411. break;
  4412. }
  4413. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  4414. continue;
  4415. }
  4416. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  4417. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  4418. var fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  4419. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  4420. var percent = fractionHeight * fractionWidth * 100 | 0;
  4421. visible.push({
  4422. id: view.id,
  4423. x: currentWidth,
  4424. y: currentHeight,
  4425. view: view,
  4426. percent: percent,
  4427. widthPercent: fractionWidth * 100 | 0
  4428. });
  4429. }
  4430. var first = visible[0],
  4431. last = visible[visible.length - 1];
  4432. if (sortByVisibility) {
  4433. visible.sort(function (a, b) {
  4434. var pc = a.percent - b.percent;
  4435. if (Math.abs(pc) > 0.001) {
  4436. return -pc;
  4437. }
  4438. return a.id - b.id;
  4439. });
  4440. }
  4441. return {
  4442. first: first,
  4443. last: last,
  4444. views: visible
  4445. };
  4446. }
  4447. function noContextMenuHandler(evt) {
  4448. evt.preventDefault();
  4449. }
  4450. function isDataSchema(url) {
  4451. var i = 0;
  4452. var ii = url.length;
  4453. while (i < ii && url[i].trim() === "") {
  4454. i++;
  4455. }
  4456. return url.substring(i, i + 5).toLowerCase() === "data:";
  4457. }
  4458. function getPDFFileNameFromURL(url) {
  4459. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "document.pdf";
  4460. if (typeof url !== "string") {
  4461. return defaultFilename;
  4462. }
  4463. if (isDataSchema(url)) {
  4464. console.warn("getPDFFileNameFromURL: " + 'ignoring "data:" URL for performance reasons.');
  4465. return defaultFilename;
  4466. }
  4467. var reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  4468. var reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  4469. var splitURI = reURI.exec(url);
  4470. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  4471. if (suggestedFilename) {
  4472. suggestedFilename = suggestedFilename[0];
  4473. if (suggestedFilename.includes("%")) {
  4474. try {
  4475. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  4476. } catch (ex) {}
  4477. }
  4478. }
  4479. return suggestedFilename || defaultFilename;
  4480. }
  4481. function normalizeWheelEventDirection(evt) {
  4482. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  4483. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  4484. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  4485. delta = -delta;
  4486. }
  4487. return delta;
  4488. }
  4489. function normalizeWheelEventDelta(evt) {
  4490. var delta = normalizeWheelEventDirection(evt);
  4491. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  4492. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  4493. var MOUSE_PIXELS_PER_LINE = 30;
  4494. var MOUSE_LINES_PER_PAGE = 30;
  4495. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  4496. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  4497. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  4498. delta /= MOUSE_LINES_PER_PAGE;
  4499. }
  4500. return delta;
  4501. }
  4502. function isValidRotation(angle) {
  4503. return Number.isInteger(angle) && angle % 90 === 0;
  4504. }
  4505. function isValidScrollMode(mode) {
  4506. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  4507. }
  4508. function isValidSpreadMode(mode) {
  4509. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  4510. }
  4511. function isPortraitOrientation(size) {
  4512. return size.width <= size.height;
  4513. }
  4514. var WaitOnType = {
  4515. EVENT: "event",
  4516. TIMEOUT: "timeout"
  4517. };
  4518. exports.WaitOnType = WaitOnType;
  4519. function waitOnEventOrTimeout(_ref3) {
  4520. var target = _ref3.target,
  4521. name = _ref3.name,
  4522. _ref3$delay = _ref3.delay,
  4523. delay = _ref3$delay === void 0 ? 0 : _ref3$delay;
  4524. return new Promise(function (resolve, reject) {
  4525. if (_typeof(target) !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  4526. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  4527. }
  4528. function handler(type) {
  4529. if (target instanceof EventBus) {
  4530. target._off(name, eventHandler);
  4531. } else {
  4532. target.removeEventListener(name, eventHandler);
  4533. }
  4534. if (timeout) {
  4535. clearTimeout(timeout);
  4536. }
  4537. resolve(type);
  4538. }
  4539. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  4540. if (target instanceof EventBus) {
  4541. target._on(name, eventHandler);
  4542. } else {
  4543. target.addEventListener(name, eventHandler);
  4544. }
  4545. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  4546. var timeout = setTimeout(timeoutHandler, delay);
  4547. });
  4548. }
  4549. var animationStarted = new Promise(function (resolve) {
  4550. window.requestAnimationFrame(resolve);
  4551. });
  4552. exports.animationStarted = animationStarted;
  4553. function dispatchDOMEvent(eventName) {
  4554. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  4555. throw new Error("Not implemented: dispatchDOMEvent");
  4556. }
  4557. var EventBus = /*#__PURE__*/function () {
  4558. function EventBus(options) {
  4559. _classCallCheck(this, EventBus);
  4560. this._listeners = Object.create(null);
  4561. }
  4562. _createClass(EventBus, [{
  4563. key: "on",
  4564. value: function on(eventName, listener) {
  4565. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4566. this._on(eventName, listener, {
  4567. external: true,
  4568. once: options === null || options === void 0 ? void 0 : options.once
  4569. });
  4570. }
  4571. }, {
  4572. key: "off",
  4573. value: function off(eventName, listener) {
  4574. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4575. this._off(eventName, listener, {
  4576. external: true,
  4577. once: options === null || options === void 0 ? void 0 : options.once
  4578. });
  4579. }
  4580. }, {
  4581. key: "dispatch",
  4582. value: function dispatch(eventName) {
  4583. var _this = this;
  4584. var eventListeners = this._listeners[eventName];
  4585. if (!eventListeners || eventListeners.length === 0) {
  4586. return;
  4587. }
  4588. var args = Array.prototype.slice.call(arguments, 1);
  4589. var externalListeners;
  4590. eventListeners.slice(0).forEach(function (_ref4) {
  4591. var listener = _ref4.listener,
  4592. external = _ref4.external,
  4593. once = _ref4.once;
  4594. if (once) {
  4595. _this._off(eventName, listener);
  4596. }
  4597. if (external) {
  4598. (externalListeners || (externalListeners = [])).push(listener);
  4599. return;
  4600. }
  4601. listener.apply(null, args);
  4602. });
  4603. if (externalListeners) {
  4604. externalListeners.forEach(function (listener) {
  4605. listener.apply(null, args);
  4606. });
  4607. externalListeners = null;
  4608. }
  4609. }
  4610. }, {
  4611. key: "_on",
  4612. value: function _on(eventName, listener) {
  4613. var _this$_listeners;
  4614. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4615. var eventListeners = (_this$_listeners = this._listeners)[eventName] || (_this$_listeners[eventName] = []);
  4616. eventListeners.push({
  4617. listener: listener,
  4618. external: (options === null || options === void 0 ? void 0 : options.external) === true,
  4619. once: (options === null || options === void 0 ? void 0 : options.once) === true
  4620. });
  4621. }
  4622. }, {
  4623. key: "_off",
  4624. value: function _off(eventName, listener) {
  4625. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4626. var eventListeners = this._listeners[eventName];
  4627. if (!eventListeners) {
  4628. return;
  4629. }
  4630. for (var i = 0, ii = eventListeners.length; i < ii; i++) {
  4631. if (eventListeners[i].listener === listener) {
  4632. eventListeners.splice(i, 1);
  4633. return;
  4634. }
  4635. }
  4636. }
  4637. }]);
  4638. return EventBus;
  4639. }();
  4640. exports.EventBus = EventBus;
  4641. function clamp(v, min, max) {
  4642. return Math.min(Math.max(v, min), max);
  4643. }
  4644. var ProgressBar = /*#__PURE__*/function () {
  4645. function ProgressBar(id) {
  4646. var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  4647. height = _ref5.height,
  4648. width = _ref5.width,
  4649. units = _ref5.units;
  4650. _classCallCheck(this, ProgressBar);
  4651. this.visible = true;
  4652. this.div = document.querySelector(id + " .progress");
  4653. this.bar = this.div.parentNode;
  4654. this.height = height || 100;
  4655. this.width = width || 100;
  4656. this.units = units || "%";
  4657. this.div.style.height = this.height + this.units;
  4658. this.percent = 0;
  4659. }
  4660. _createClass(ProgressBar, [{
  4661. key: "_updateBar",
  4662. value: function _updateBar() {
  4663. if (this._indeterminate) {
  4664. this.div.classList.add("indeterminate");
  4665. this.div.style.width = this.width + this.units;
  4666. return;
  4667. }
  4668. this.div.classList.remove("indeterminate");
  4669. var progressSize = this.width * this._percent / 100;
  4670. this.div.style.width = progressSize + this.units;
  4671. }
  4672. }, {
  4673. key: "setWidth",
  4674. value: function setWidth(viewer) {
  4675. if (!viewer) {
  4676. return;
  4677. }
  4678. var container = viewer.parentNode;
  4679. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  4680. if (scrollbarWidth > 0) {
  4681. var doc = document.documentElement;
  4682. doc.style.setProperty(LOADINGBAR_END_OFFSET_VAR, "".concat(scrollbarWidth, "px"));
  4683. }
  4684. }
  4685. }, {
  4686. key: "hide",
  4687. value: function hide() {
  4688. if (!this.visible) {
  4689. return;
  4690. }
  4691. this.visible = false;
  4692. this.bar.classList.add("hidden");
  4693. }
  4694. }, {
  4695. key: "show",
  4696. value: function show() {
  4697. if (this.visible) {
  4698. return;
  4699. }
  4700. this.visible = true;
  4701. this.bar.classList.remove("hidden");
  4702. }
  4703. }, {
  4704. key: "percent",
  4705. get: function get() {
  4706. return this._percent;
  4707. },
  4708. set: function set(val) {
  4709. this._indeterminate = isNaN(val);
  4710. this._percent = clamp(val, 0, 100);
  4711. this._updateBar();
  4712. }
  4713. }]);
  4714. return ProgressBar;
  4715. }();
  4716. exports.ProgressBar = ProgressBar;
  4717. function moveToEndOfArray(arr, condition) {
  4718. var moved = [],
  4719. len = arr.length;
  4720. var write = 0;
  4721. for (var read = 0; read < len; ++read) {
  4722. if (condition(arr[read])) {
  4723. moved.push(arr[read]);
  4724. } else {
  4725. arr[write] = arr[read];
  4726. ++write;
  4727. }
  4728. }
  4729. for (var _read = 0; write < len; ++_read, ++write) {
  4730. arr[write] = moved[_read];
  4731. }
  4732. }
  4733. function getActiveOrFocusedElement() {
  4734. var curRoot = document;
  4735. var curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  4736. while (curActiveOrFocused && curActiveOrFocused.shadowRoot) {
  4737. curRoot = curActiveOrFocused.shadowRoot;
  4738. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  4739. }
  4740. return curActiveOrFocused;
  4741. }
  4742. /***/ }),
  4743. /* 7 */
  4744. /***/ ((module) => {
  4745. var pdfjsLib;
  4746. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  4747. pdfjsLib = window["pdfjs-dist/build/pdf"];
  4748. } else {
  4749. pdfjsLib = require("../build/pdf.js");
  4750. }
  4751. module.exports = pdfjsLib;
  4752. /***/ }),
  4753. /* 8 */
  4754. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4755. Object.defineProperty(exports, "__esModule", ({
  4756. value: true
  4757. }));
  4758. exports.PDFCursorTools = exports.CursorTool = void 0;
  4759. var _grab_to_pan = __webpack_require__(9);
  4760. var _ui_utils = __webpack_require__(6);
  4761. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4762. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4763. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4764. var CursorTool = {
  4765. SELECT: 0,
  4766. HAND: 1,
  4767. ZOOM: 2
  4768. };
  4769. exports.CursorTool = CursorTool;
  4770. var PDFCursorTools = /*#__PURE__*/function () {
  4771. function PDFCursorTools(_ref) {
  4772. var _this = this;
  4773. var container = _ref.container,
  4774. eventBus = _ref.eventBus,
  4775. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  4776. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT : _ref$cursorToolOnLoad;
  4777. _classCallCheck(this, PDFCursorTools);
  4778. this.container = container;
  4779. this.eventBus = eventBus;
  4780. this.active = CursorTool.SELECT;
  4781. this.activeBeforePresentationMode = null;
  4782. this.handTool = new _grab_to_pan.GrabToPan({
  4783. element: this.container
  4784. });
  4785. this._addEventListeners();
  4786. Promise.resolve().then(function () {
  4787. _this.switchTool(cursorToolOnLoad);
  4788. });
  4789. }
  4790. _createClass(PDFCursorTools, [{
  4791. key: "switchTool",
  4792. value: function switchTool(tool) {
  4793. var _this2 = this;
  4794. if (this.activeBeforePresentationMode !== null) {
  4795. return;
  4796. }
  4797. if (tool === this.active) {
  4798. return;
  4799. }
  4800. var disableActiveTool = function disableActiveTool() {
  4801. switch (_this2.active) {
  4802. case CursorTool.SELECT:
  4803. break;
  4804. case CursorTool.HAND:
  4805. _this2.handTool.deactivate();
  4806. break;
  4807. case CursorTool.ZOOM:
  4808. }
  4809. };
  4810. switch (tool) {
  4811. case CursorTool.SELECT:
  4812. disableActiveTool();
  4813. break;
  4814. case CursorTool.HAND:
  4815. disableActiveTool();
  4816. this.handTool.activate();
  4817. break;
  4818. case CursorTool.ZOOM:
  4819. default:
  4820. console.error("switchTool: \"".concat(tool, "\" is an unsupported value."));
  4821. return;
  4822. }
  4823. this.active = tool;
  4824. this._dispatchEvent();
  4825. }
  4826. }, {
  4827. key: "_dispatchEvent",
  4828. value: function _dispatchEvent() {
  4829. this.eventBus.dispatch("cursortoolchanged", {
  4830. source: this,
  4831. tool: this.active
  4832. });
  4833. }
  4834. }, {
  4835. key: "_addEventListeners",
  4836. value: function _addEventListeners() {
  4837. var _this3 = this;
  4838. this.eventBus._on("switchcursortool", function (evt) {
  4839. _this3.switchTool(evt.tool);
  4840. });
  4841. this.eventBus._on("presentationmodechanged", function (evt) {
  4842. switch (evt.state) {
  4843. case _ui_utils.PresentationModeState.CHANGING:
  4844. break;
  4845. case _ui_utils.PresentationModeState.FULLSCREEN:
  4846. {
  4847. var previouslyActive = _this3.active;
  4848. _this3.switchTool(CursorTool.SELECT);
  4849. _this3.activeBeforePresentationMode = previouslyActive;
  4850. break;
  4851. }
  4852. case _ui_utils.PresentationModeState.NORMAL:
  4853. {
  4854. var _previouslyActive = _this3.activeBeforePresentationMode;
  4855. _this3.activeBeforePresentationMode = null;
  4856. _this3.switchTool(_previouslyActive);
  4857. break;
  4858. }
  4859. }
  4860. });
  4861. }
  4862. }, {
  4863. key: "activeTool",
  4864. get: function get() {
  4865. return this.active;
  4866. }
  4867. }]);
  4868. return PDFCursorTools;
  4869. }();
  4870. exports.PDFCursorTools = PDFCursorTools;
  4871. /***/ }),
  4872. /* 9 */
  4873. /***/ ((__unused_webpack_module, exports) => {
  4874. Object.defineProperty(exports, "__esModule", ({
  4875. value: true
  4876. }));
  4877. exports.GrabToPan = GrabToPan;
  4878. function GrabToPan(options) {
  4879. this.element = options.element;
  4880. this.document = options.element.ownerDocument;
  4881. if (typeof options.ignoreTarget === "function") {
  4882. this.ignoreTarget = options.ignoreTarget;
  4883. }
  4884. this.onActiveChanged = options.onActiveChanged;
  4885. this.activate = this.activate.bind(this);
  4886. this.deactivate = this.deactivate.bind(this);
  4887. this.toggle = this.toggle.bind(this);
  4888. this._onmousedown = this._onmousedown.bind(this);
  4889. this._onmousemove = this._onmousemove.bind(this);
  4890. this._endPan = this._endPan.bind(this);
  4891. var overlay = this.overlay = document.createElement("div");
  4892. overlay.className = "grab-to-pan-grabbing";
  4893. }
  4894. GrabToPan.prototype = {
  4895. CSS_CLASS_GRAB: "grab-to-pan-grab",
  4896. activate: function GrabToPan_activate() {
  4897. if (!this.active) {
  4898. this.active = true;
  4899. this.element.addEventListener("mousedown", this._onmousedown, true);
  4900. this.element.classList.add(this.CSS_CLASS_GRAB);
  4901. if (this.onActiveChanged) {
  4902. this.onActiveChanged(true);
  4903. }
  4904. }
  4905. },
  4906. deactivate: function GrabToPan_deactivate() {
  4907. if (this.active) {
  4908. this.active = false;
  4909. this.element.removeEventListener("mousedown", this._onmousedown, true);
  4910. this._endPan();
  4911. this.element.classList.remove(this.CSS_CLASS_GRAB);
  4912. if (this.onActiveChanged) {
  4913. this.onActiveChanged(false);
  4914. }
  4915. }
  4916. },
  4917. toggle: function GrabToPan_toggle() {
  4918. if (this.active) {
  4919. this.deactivate();
  4920. } else {
  4921. this.activate();
  4922. }
  4923. },
  4924. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  4925. return node[matchesSelector]("a[href], a[href] *, input, textarea, button, button *, select, option");
  4926. },
  4927. _onmousedown: function GrabToPan__onmousedown(event) {
  4928. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  4929. return;
  4930. }
  4931. if (event.originalTarget) {
  4932. try {
  4933. event.originalTarget.tagName;
  4934. } catch (e) {
  4935. return;
  4936. }
  4937. }
  4938. this.scrollLeftStart = this.element.scrollLeft;
  4939. this.scrollTopStart = this.element.scrollTop;
  4940. this.clientXStart = event.clientX;
  4941. this.clientYStart = event.clientY;
  4942. this.document.addEventListener("mousemove", this._onmousemove, true);
  4943. this.document.addEventListener("mouseup", this._endPan, true);
  4944. this.element.addEventListener("scroll", this._endPan, true);
  4945. event.preventDefault();
  4946. event.stopPropagation();
  4947. var focusedElement = document.activeElement;
  4948. if (focusedElement && !focusedElement.contains(event.target)) {
  4949. focusedElement.blur();
  4950. }
  4951. },
  4952. _onmousemove: function GrabToPan__onmousemove(event) {
  4953. this.element.removeEventListener("scroll", this._endPan, true);
  4954. if (isLeftMouseReleased(event)) {
  4955. this._endPan();
  4956. return;
  4957. }
  4958. var xDiff = event.clientX - this.clientXStart;
  4959. var yDiff = event.clientY - this.clientYStart;
  4960. var scrollTop = this.scrollTopStart - yDiff;
  4961. var scrollLeft = this.scrollLeftStart - xDiff;
  4962. if (this.element.scrollTo) {
  4963. this.element.scrollTo({
  4964. top: scrollTop,
  4965. left: scrollLeft,
  4966. behavior: "instant"
  4967. });
  4968. } else {
  4969. this.element.scrollTop = scrollTop;
  4970. this.element.scrollLeft = scrollLeft;
  4971. }
  4972. if (!this.overlay.parentNode) {
  4973. document.body.appendChild(this.overlay);
  4974. }
  4975. },
  4976. _endPan: function GrabToPan__endPan() {
  4977. this.element.removeEventListener("scroll", this._endPan, true);
  4978. this.document.removeEventListener("mousemove", this._onmousemove, true);
  4979. this.document.removeEventListener("mouseup", this._endPan, true);
  4980. this.overlay.remove();
  4981. }
  4982. };
  4983. var matchesSelector;
  4984. ["webkitM", "mozM", "m"].some(function (prefix) {
  4985. var name = prefix + "atches";
  4986. if (name in document.documentElement) {
  4987. matchesSelector = name;
  4988. }
  4989. name += "Selector";
  4990. if (name in document.documentElement) {
  4991. matchesSelector = name;
  4992. }
  4993. return matchesSelector;
  4994. });
  4995. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  4996. var chrome = window.chrome;
  4997. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  4998. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  4999. function isLeftMouseReleased(event) {
  5000. if ("buttons" in event && isNotIEorIsIE10plus) {
  5001. return !(event.buttons & 1);
  5002. }
  5003. if (isChrome15OrOpera15plus || isSafari6plus) {
  5004. return event.which === 0;
  5005. }
  5006. return false;
  5007. }
  5008. /***/ }),
  5009. /* 10 */
  5010. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5011. Object.defineProperty(exports, "__esModule", ({
  5012. value: true
  5013. }));
  5014. exports.RenderingStates = exports.PDFRenderingQueue = void 0;
  5015. var _pdfjsLib = __webpack_require__(7);
  5016. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5017. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5018. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5019. var CLEANUP_TIMEOUT = 30000;
  5020. var RenderingStates = {
  5021. INITIAL: 0,
  5022. RUNNING: 1,
  5023. PAUSED: 2,
  5024. FINISHED: 3
  5025. };
  5026. exports.RenderingStates = RenderingStates;
  5027. var PDFRenderingQueue = /*#__PURE__*/function () {
  5028. function PDFRenderingQueue() {
  5029. _classCallCheck(this, PDFRenderingQueue);
  5030. this.pdfViewer = null;
  5031. this.pdfThumbnailViewer = null;
  5032. this.onIdle = null;
  5033. this.highestPriorityPage = null;
  5034. this.idleTimeout = null;
  5035. this.printing = false;
  5036. this.isThumbnailViewEnabled = false;
  5037. }
  5038. _createClass(PDFRenderingQueue, [{
  5039. key: "setViewer",
  5040. value: function setViewer(pdfViewer) {
  5041. this.pdfViewer = pdfViewer;
  5042. }
  5043. }, {
  5044. key: "setThumbnailViewer",
  5045. value: function setThumbnailViewer(pdfThumbnailViewer) {
  5046. this.pdfThumbnailViewer = pdfThumbnailViewer;
  5047. }
  5048. }, {
  5049. key: "isHighestPriority",
  5050. value: function isHighestPriority(view) {
  5051. return this.highestPriorityPage === view.renderingId;
  5052. }
  5053. }, {
  5054. key: "renderHighestPriority",
  5055. value: function renderHighestPriority(currentlyVisiblePages) {
  5056. if (this.idleTimeout) {
  5057. clearTimeout(this.idleTimeout);
  5058. this.idleTimeout = null;
  5059. }
  5060. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  5061. return;
  5062. }
  5063. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  5064. if (this.pdfThumbnailViewer.forceRendering()) {
  5065. return;
  5066. }
  5067. }
  5068. if (this.printing) {
  5069. return;
  5070. }
  5071. if (this.onIdle) {
  5072. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  5073. }
  5074. }
  5075. }, {
  5076. key: "getHighestPriority",
  5077. value: function getHighestPriority(visible, views, scrolledDown) {
  5078. var visibleViews = visible.views;
  5079. var numVisible = visibleViews.length;
  5080. if (numVisible === 0) {
  5081. return null;
  5082. }
  5083. for (var i = 0; i < numVisible; ++i) {
  5084. var view = visibleViews[i].view;
  5085. if (!this.isViewFinished(view)) {
  5086. return view;
  5087. }
  5088. }
  5089. if (scrolledDown) {
  5090. var nextPageIndex = visible.last.id;
  5091. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  5092. return views[nextPageIndex];
  5093. }
  5094. } else {
  5095. var previousPageIndex = visible.first.id - 2;
  5096. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  5097. return views[previousPageIndex];
  5098. }
  5099. }
  5100. return null;
  5101. }
  5102. }, {
  5103. key: "isViewFinished",
  5104. value: function isViewFinished(view) {
  5105. return view.renderingState === RenderingStates.FINISHED;
  5106. }
  5107. }, {
  5108. key: "renderView",
  5109. value: function renderView(view) {
  5110. var _this = this;
  5111. switch (view.renderingState) {
  5112. case RenderingStates.FINISHED:
  5113. return false;
  5114. case RenderingStates.PAUSED:
  5115. this.highestPriorityPage = view.renderingId;
  5116. view.resume();
  5117. break;
  5118. case RenderingStates.RUNNING:
  5119. this.highestPriorityPage = view.renderingId;
  5120. break;
  5121. case RenderingStates.INITIAL:
  5122. this.highestPriorityPage = view.renderingId;
  5123. view.draw()["finally"](function () {
  5124. _this.renderHighestPriority();
  5125. })["catch"](function (reason) {
  5126. if (reason instanceof _pdfjsLib.RenderingCancelledException) {
  5127. return;
  5128. }
  5129. console.error("renderView: \"".concat(reason, "\""));
  5130. });
  5131. break;
  5132. }
  5133. return true;
  5134. }
  5135. }]);
  5136. return PDFRenderingQueue;
  5137. }();
  5138. exports.PDFRenderingQueue = PDFRenderingQueue;
  5139. /***/ }),
  5140. /* 11 */
  5141. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5142. Object.defineProperty(exports, "__esModule", ({
  5143. value: true
  5144. }));
  5145. exports.OverlayManager = void 0;
  5146. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  5147. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5148. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  5149. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  5150. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5151. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5152. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5153. var OverlayManager = /*#__PURE__*/function () {
  5154. function OverlayManager() {
  5155. _classCallCheck(this, OverlayManager);
  5156. this._overlays = {};
  5157. this._active = null;
  5158. this._keyDownBound = this._keyDown.bind(this);
  5159. }
  5160. _createClass(OverlayManager, [{
  5161. key: "register",
  5162. value: function () {
  5163. var _register = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, element) {
  5164. var callerCloseMethod,
  5165. canForceClose,
  5166. container,
  5167. _args = arguments;
  5168. return _regenerator["default"].wrap(function _callee$(_context) {
  5169. while (1) {
  5170. switch (_context.prev = _context.next) {
  5171. case 0:
  5172. callerCloseMethod = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
  5173. canForceClose = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
  5174. if (!(!name || !element || !(container = element.parentNode))) {
  5175. _context.next = 6;
  5176. break;
  5177. }
  5178. throw new Error("Not enough parameters.");
  5179. case 6:
  5180. if (!this._overlays[name]) {
  5181. _context.next = 8;
  5182. break;
  5183. }
  5184. throw new Error("The overlay is already registered.");
  5185. case 8:
  5186. this._overlays[name] = {
  5187. element: element,
  5188. container: container,
  5189. callerCloseMethod: callerCloseMethod,
  5190. canForceClose: canForceClose
  5191. };
  5192. case 9:
  5193. case "end":
  5194. return _context.stop();
  5195. }
  5196. }
  5197. }, _callee, this);
  5198. }));
  5199. function register(_x, _x2) {
  5200. return _register.apply(this, arguments);
  5201. }
  5202. return register;
  5203. }()
  5204. }, {
  5205. key: "unregister",
  5206. value: function () {
  5207. var _unregister = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(name) {
  5208. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5209. while (1) {
  5210. switch (_context2.prev = _context2.next) {
  5211. case 0:
  5212. if (this._overlays[name]) {
  5213. _context2.next = 4;
  5214. break;
  5215. }
  5216. throw new Error("The overlay does not exist.");
  5217. case 4:
  5218. if (!(this._active === name)) {
  5219. _context2.next = 6;
  5220. break;
  5221. }
  5222. throw new Error("The overlay cannot be removed while it is active.");
  5223. case 6:
  5224. delete this._overlays[name];
  5225. case 7:
  5226. case "end":
  5227. return _context2.stop();
  5228. }
  5229. }
  5230. }, _callee2, this);
  5231. }));
  5232. function unregister(_x3) {
  5233. return _unregister.apply(this, arguments);
  5234. }
  5235. return unregister;
  5236. }()
  5237. }, {
  5238. key: "open",
  5239. value: function () {
  5240. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name) {
  5241. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5242. while (1) {
  5243. switch (_context3.prev = _context3.next) {
  5244. case 0:
  5245. if (this._overlays[name]) {
  5246. _context3.next = 4;
  5247. break;
  5248. }
  5249. throw new Error("The overlay does not exist.");
  5250. case 4:
  5251. if (!this._active) {
  5252. _context3.next = 14;
  5253. break;
  5254. }
  5255. if (!this._overlays[name].canForceClose) {
  5256. _context3.next = 9;
  5257. break;
  5258. }
  5259. this._closeThroughCaller();
  5260. _context3.next = 14;
  5261. break;
  5262. case 9:
  5263. if (!(this._active === name)) {
  5264. _context3.next = 13;
  5265. break;
  5266. }
  5267. throw new Error("The overlay is already active.");
  5268. case 13:
  5269. throw new Error("Another overlay is currently active.");
  5270. case 14:
  5271. this._active = name;
  5272. this._overlays[this._active].element.classList.remove("hidden");
  5273. this._overlays[this._active].container.classList.remove("hidden");
  5274. window.addEventListener("keydown", this._keyDownBound);
  5275. case 18:
  5276. case "end":
  5277. return _context3.stop();
  5278. }
  5279. }
  5280. }, _callee3, this);
  5281. }));
  5282. function open(_x4) {
  5283. return _open.apply(this, arguments);
  5284. }
  5285. return open;
  5286. }()
  5287. }, {
  5288. key: "close",
  5289. value: function () {
  5290. var _close = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name) {
  5291. return _regenerator["default"].wrap(function _callee4$(_context4) {
  5292. while (1) {
  5293. switch (_context4.prev = _context4.next) {
  5294. case 0:
  5295. if (this._overlays[name]) {
  5296. _context4.next = 4;
  5297. break;
  5298. }
  5299. throw new Error("The overlay does not exist.");
  5300. case 4:
  5301. if (this._active) {
  5302. _context4.next = 8;
  5303. break;
  5304. }
  5305. throw new Error("The overlay is currently not active.");
  5306. case 8:
  5307. if (!(this._active !== name)) {
  5308. _context4.next = 10;
  5309. break;
  5310. }
  5311. throw new Error("Another overlay is currently active.");
  5312. case 10:
  5313. this._overlays[this._active].container.classList.add("hidden");
  5314. this._overlays[this._active].element.classList.add("hidden");
  5315. this._active = null;
  5316. window.removeEventListener("keydown", this._keyDownBound);
  5317. case 14:
  5318. case "end":
  5319. return _context4.stop();
  5320. }
  5321. }
  5322. }, _callee4, this);
  5323. }));
  5324. function close(_x5) {
  5325. return _close.apply(this, arguments);
  5326. }
  5327. return close;
  5328. }()
  5329. }, {
  5330. key: "_keyDown",
  5331. value: function _keyDown(evt) {
  5332. if (this._active && evt.keyCode === 27) {
  5333. this._closeThroughCaller();
  5334. evt.preventDefault();
  5335. }
  5336. }
  5337. }, {
  5338. key: "_closeThroughCaller",
  5339. value: function _closeThroughCaller() {
  5340. if (this._overlays[this._active].callerCloseMethod) {
  5341. this._overlays[this._active].callerCloseMethod();
  5342. }
  5343. if (this._active) {
  5344. this.close(this._active);
  5345. }
  5346. }
  5347. }, {
  5348. key: "active",
  5349. get: function get() {
  5350. return this._active;
  5351. }
  5352. }]);
  5353. return OverlayManager;
  5354. }();
  5355. exports.OverlayManager = OverlayManager;
  5356. /***/ }),
  5357. /* 12 */
  5358. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5359. Object.defineProperty(exports, "__esModule", ({
  5360. value: true
  5361. }));
  5362. exports.PasswordPrompt = void 0;
  5363. var _ui_utils = __webpack_require__(6);
  5364. var _pdfjsLib = __webpack_require__(7);
  5365. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5366. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5367. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5368. var PasswordPrompt = /*#__PURE__*/function () {
  5369. function PasswordPrompt(options, overlayManager) {
  5370. var _this = this;
  5371. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5372. _classCallCheck(this, PasswordPrompt);
  5373. this.overlayName = options.overlayName;
  5374. this.container = options.container;
  5375. this.label = options.label;
  5376. this.input = options.input;
  5377. this.submitButton = options.submitButton;
  5378. this.cancelButton = options.cancelButton;
  5379. this.overlayManager = overlayManager;
  5380. this.l10n = l10n;
  5381. this.updateCallback = null;
  5382. this.reason = null;
  5383. this.submitButton.addEventListener("click", this.verify.bind(this));
  5384. this.cancelButton.addEventListener("click", this.close.bind(this));
  5385. this.input.addEventListener("keydown", function (e) {
  5386. if (e.keyCode === 13) {
  5387. _this.verify();
  5388. }
  5389. });
  5390. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  5391. }
  5392. _createClass(PasswordPrompt, [{
  5393. key: "open",
  5394. value: function open() {
  5395. var _this2 = this;
  5396. this.overlayManager.open(this.overlayName).then(function () {
  5397. _this2.input.focus();
  5398. var promptString;
  5399. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  5400. promptString = _this2.l10n.get("password_invalid", null, "Invalid password. Please try again.");
  5401. } else {
  5402. promptString = _this2.l10n.get("password_label", null, "Enter the password to open this PDF file.");
  5403. }
  5404. promptString.then(function (msg) {
  5405. _this2.label.textContent = msg;
  5406. });
  5407. });
  5408. }
  5409. }, {
  5410. key: "close",
  5411. value: function close() {
  5412. var _this3 = this;
  5413. this.overlayManager.close(this.overlayName).then(function () {
  5414. _this3.input.value = "";
  5415. });
  5416. }
  5417. }, {
  5418. key: "verify",
  5419. value: function verify() {
  5420. var password = this.input.value;
  5421. if (password && password.length > 0) {
  5422. this.close();
  5423. this.updateCallback(password);
  5424. }
  5425. }
  5426. }, {
  5427. key: "setUpdateCallback",
  5428. value: function setUpdateCallback(updateCallback, reason) {
  5429. this.updateCallback = updateCallback;
  5430. this.reason = reason;
  5431. }
  5432. }]);
  5433. return PasswordPrompt;
  5434. }();
  5435. exports.PasswordPrompt = PasswordPrompt;
  5436. /***/ }),
  5437. /* 13 */
  5438. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5439. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  5440. Object.defineProperty(exports, "__esModule", ({
  5441. value: true
  5442. }));
  5443. exports.PDFAttachmentViewer = void 0;
  5444. var _pdfjsLib = __webpack_require__(7);
  5445. var _base_tree_viewer = __webpack_require__(14);
  5446. var _viewer_compatibility = __webpack_require__(2);
  5447. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  5448. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  5449. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5450. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5451. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5452. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5453. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  5454. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  5455. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  5456. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  5457. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  5458. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  5459. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  5460. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  5461. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  5462. var PdfFileRegExp = /\.pdf$/i;
  5463. var PDFAttachmentViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  5464. _inherits(PDFAttachmentViewer, _BaseTreeViewer);
  5465. var _super = _createSuper(PDFAttachmentViewer);
  5466. function PDFAttachmentViewer(options) {
  5467. var _this;
  5468. _classCallCheck(this, PDFAttachmentViewer);
  5469. _this = _super.call(this, options);
  5470. _this.downloadManager = options.downloadManager;
  5471. _this.eventBus._on("fileattachmentannotation", _this._appendAttachment.bind(_assertThisInitialized(_this)));
  5472. return _this;
  5473. }
  5474. _createClass(PDFAttachmentViewer, [{
  5475. key: "reset",
  5476. value: function reset() {
  5477. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5478. _get(_getPrototypeOf(PDFAttachmentViewer.prototype), "reset", this).call(this);
  5479. this._attachments = null;
  5480. if (!keepRenderedCapability) {
  5481. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  5482. }
  5483. if (this._pendingDispatchEvent) {
  5484. clearTimeout(this._pendingDispatchEvent);
  5485. }
  5486. this._pendingDispatchEvent = null;
  5487. }
  5488. }, {
  5489. key: "_dispatchEvent",
  5490. value: function _dispatchEvent(attachmentsCount) {
  5491. var _this2 = this;
  5492. this._renderedCapability.resolve();
  5493. if (this._pendingDispatchEvent) {
  5494. clearTimeout(this._pendingDispatchEvent);
  5495. this._pendingDispatchEvent = null;
  5496. }
  5497. if (attachmentsCount === 0) {
  5498. this._pendingDispatchEvent = setTimeout(function () {
  5499. _this2.eventBus.dispatch("attachmentsloaded", {
  5500. source: _this2,
  5501. attachmentsCount: 0
  5502. });
  5503. _this2._pendingDispatchEvent = null;
  5504. });
  5505. return;
  5506. }
  5507. this.eventBus.dispatch("attachmentsloaded", {
  5508. source: this,
  5509. attachmentsCount: attachmentsCount
  5510. });
  5511. }
  5512. }, {
  5513. key: "_bindPdfLink",
  5514. value: function _bindPdfLink(element, _ref) {
  5515. var _this3 = this;
  5516. var content = _ref.content,
  5517. filename = _ref.filename;
  5518. var blobUrl;
  5519. element.onclick = function () {
  5520. if (!blobUrl) {
  5521. blobUrl = URL.createObjectURL(new Blob([content], {
  5522. type: "application/pdf"
  5523. }));
  5524. }
  5525. var viewerUrl;
  5526. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  5527. try {
  5528. window.open(viewerUrl);
  5529. } catch (ex) {
  5530. console.error("_bindPdfLink: ".concat(ex));
  5531. URL.revokeObjectURL(blobUrl);
  5532. blobUrl = null;
  5533. _this3.downloadManager.downloadData(content, filename, "application/pdf");
  5534. }
  5535. return false;
  5536. };
  5537. }
  5538. }, {
  5539. key: "_bindLink",
  5540. value: function _bindLink(element, _ref2) {
  5541. var _this4 = this;
  5542. var content = _ref2.content,
  5543. filename = _ref2.filename;
  5544. element.onclick = function () {
  5545. var contentType = PdfFileRegExp.test(filename) ? "application/pdf" : "";
  5546. _this4.downloadManager.downloadData(content, filename, contentType);
  5547. return false;
  5548. };
  5549. }
  5550. }, {
  5551. key: "render",
  5552. value: function render(_ref3) {
  5553. var attachments = _ref3.attachments,
  5554. _ref3$keepRenderedCap = _ref3.keepRenderedCapability,
  5555. keepRenderedCapability = _ref3$keepRenderedCap === void 0 ? false : _ref3$keepRenderedCap;
  5556. if (this._attachments) {
  5557. this.reset(keepRenderedCapability);
  5558. }
  5559. this._attachments = attachments || null;
  5560. if (!attachments) {
  5561. this._dispatchEvent(0);
  5562. return;
  5563. }
  5564. var names = Object.keys(attachments).sort(function (a, b) {
  5565. return a.toLowerCase().localeCompare(b.toLowerCase());
  5566. });
  5567. var fragment = document.createDocumentFragment();
  5568. var attachmentsCount = 0;
  5569. var _iterator = _createForOfIteratorHelper(names),
  5570. _step;
  5571. try {
  5572. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5573. var name = _step.value;
  5574. var item = attachments[name];
  5575. var filename = (0, _pdfjsLib.getFilenameFromUrl)(item.filename);
  5576. var div = document.createElement("div");
  5577. div.className = "treeItem";
  5578. var element = document.createElement("a");
  5579. if (PdfFileRegExp.test(filename) && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  5580. this._bindPdfLink(element, {
  5581. content: item.content,
  5582. filename: filename
  5583. });
  5584. } else {
  5585. this._bindLink(element, {
  5586. content: item.content,
  5587. filename: filename
  5588. });
  5589. }
  5590. element.textContent = this._normalizeTextContent(filename);
  5591. div.appendChild(element);
  5592. fragment.appendChild(div);
  5593. attachmentsCount++;
  5594. }
  5595. } catch (err) {
  5596. _iterator.e(err);
  5597. } finally {
  5598. _iterator.f();
  5599. }
  5600. this._finishRendering(fragment, attachmentsCount);
  5601. }
  5602. }, {
  5603. key: "_appendAttachment",
  5604. value: function _appendAttachment(_ref4) {
  5605. var _this5 = this;
  5606. var id = _ref4.id,
  5607. filename = _ref4.filename,
  5608. content = _ref4.content;
  5609. var renderedPromise = this._renderedCapability.promise;
  5610. renderedPromise.then(function () {
  5611. if (renderedPromise !== _this5._renderedCapability.promise) {
  5612. return;
  5613. }
  5614. var attachments = _this5._attachments;
  5615. if (!attachments) {
  5616. attachments = Object.create(null);
  5617. } else {
  5618. for (var name in attachments) {
  5619. if (id === name) {
  5620. return;
  5621. }
  5622. }
  5623. }
  5624. attachments[id] = {
  5625. filename: filename,
  5626. content: content
  5627. };
  5628. _this5.render({
  5629. attachments: attachments,
  5630. keepRenderedCapability: true
  5631. });
  5632. });
  5633. }
  5634. }]);
  5635. return PDFAttachmentViewer;
  5636. }(_base_tree_viewer.BaseTreeViewer);
  5637. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  5638. /***/ }),
  5639. /* 14 */
  5640. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5641. Object.defineProperty(exports, "__esModule", ({
  5642. value: true
  5643. }));
  5644. exports.BaseTreeViewer = void 0;
  5645. var _pdfjsLib = __webpack_require__(7);
  5646. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  5647. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  5648. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5649. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5650. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5651. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5652. var TREEITEM_OFFSET_TOP = -100;
  5653. var TREEITEM_SELECTED_CLASS = "selected";
  5654. var BaseTreeViewer = /*#__PURE__*/function () {
  5655. function BaseTreeViewer(options) {
  5656. _classCallCheck(this, BaseTreeViewer);
  5657. if (this.constructor === BaseTreeViewer) {
  5658. throw new Error("Cannot initialize BaseTreeViewer.");
  5659. }
  5660. this.container = options.container;
  5661. this.eventBus = options.eventBus;
  5662. this.reset();
  5663. }
  5664. _createClass(BaseTreeViewer, [{
  5665. key: "reset",
  5666. value: function reset() {
  5667. this._pdfDocument = null;
  5668. this._lastToggleIsShow = true;
  5669. this._currentTreeItem = null;
  5670. this.container.textContent = "";
  5671. this.container.classList.remove("treeWithDeepNesting");
  5672. }
  5673. }, {
  5674. key: "_dispatchEvent",
  5675. value: function _dispatchEvent(count) {
  5676. throw new Error("Not implemented: _dispatchEvent");
  5677. }
  5678. }, {
  5679. key: "_bindLink",
  5680. value: function _bindLink(element, params) {
  5681. throw new Error("Not implemented: _bindLink");
  5682. }
  5683. }, {
  5684. key: "_normalizeTextContent",
  5685. value: function _normalizeTextContent(str) {
  5686. return (0, _pdfjsLib.removeNullCharacters)(str) || "\u2013";
  5687. }
  5688. }, {
  5689. key: "_addToggleButton",
  5690. value: function _addToggleButton(div) {
  5691. var _this = this;
  5692. var hidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5693. var toggler = document.createElement("div");
  5694. toggler.className = "treeItemToggler";
  5695. if (hidden) {
  5696. toggler.classList.add("treeItemsHidden");
  5697. }
  5698. toggler.onclick = function (evt) {
  5699. evt.stopPropagation();
  5700. toggler.classList.toggle("treeItemsHidden");
  5701. if (evt.shiftKey) {
  5702. var shouldShowAll = !toggler.classList.contains("treeItemsHidden");
  5703. _this._toggleTreeItem(div, shouldShowAll);
  5704. }
  5705. };
  5706. div.insertBefore(toggler, div.firstChild);
  5707. }
  5708. }, {
  5709. key: "_toggleTreeItem",
  5710. value: function _toggleTreeItem(root) {
  5711. var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5712. this._lastToggleIsShow = show;
  5713. var _iterator = _createForOfIteratorHelper(root.querySelectorAll(".treeItemToggler")),
  5714. _step;
  5715. try {
  5716. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5717. var toggler = _step.value;
  5718. toggler.classList.toggle("treeItemsHidden", !show);
  5719. }
  5720. } catch (err) {
  5721. _iterator.e(err);
  5722. } finally {
  5723. _iterator.f();
  5724. }
  5725. }
  5726. }, {
  5727. key: "_toggleAllTreeItems",
  5728. value: function _toggleAllTreeItems() {
  5729. this._toggleTreeItem(this.container, !this._lastToggleIsShow);
  5730. }
  5731. }, {
  5732. key: "_finishRendering",
  5733. value: function _finishRendering(fragment, count) {
  5734. var hasAnyNesting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5735. if (hasAnyNesting) {
  5736. this.container.classList.add("treeWithDeepNesting");
  5737. this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
  5738. }
  5739. this.container.appendChild(fragment);
  5740. this._dispatchEvent(count);
  5741. }
  5742. }, {
  5743. key: "render",
  5744. value: function render(params) {
  5745. throw new Error("Not implemented: render");
  5746. }
  5747. }, {
  5748. key: "_updateCurrentTreeItem",
  5749. value: function _updateCurrentTreeItem() {
  5750. var treeItem = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  5751. if (this._currentTreeItem) {
  5752. this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS);
  5753. this._currentTreeItem = null;
  5754. }
  5755. if (treeItem) {
  5756. treeItem.classList.add(TREEITEM_SELECTED_CLASS);
  5757. this._currentTreeItem = treeItem;
  5758. }
  5759. }
  5760. }, {
  5761. key: "_scrollToCurrentTreeItem",
  5762. value: function _scrollToCurrentTreeItem(treeItem) {
  5763. if (!treeItem) {
  5764. return;
  5765. }
  5766. var currentNode = treeItem.parentNode;
  5767. while (currentNode && currentNode !== this.container) {
  5768. if (currentNode.classList.contains("treeItem")) {
  5769. var toggler = currentNode.firstElementChild;
  5770. toggler === null || toggler === void 0 ? void 0 : toggler.classList.remove("treeItemsHidden");
  5771. }
  5772. currentNode = currentNode.parentNode;
  5773. }
  5774. this._updateCurrentTreeItem(treeItem);
  5775. this.container.scrollTo(treeItem.offsetLeft, treeItem.offsetTop + TREEITEM_OFFSET_TOP);
  5776. }
  5777. }]);
  5778. return BaseTreeViewer;
  5779. }();
  5780. exports.BaseTreeViewer = BaseTreeViewer;
  5781. /***/ }),
  5782. /* 15 */
  5783. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5784. Object.defineProperty(exports, "__esModule", ({
  5785. value: true
  5786. }));
  5787. exports.PDFDocumentProperties = void 0;
  5788. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  5789. var _pdfjsLib = __webpack_require__(7);
  5790. var _ui_utils = __webpack_require__(6);
  5791. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5792. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  5793. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  5794. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  5795. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5796. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  5797. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  5798. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  5799. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  5800. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5801. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5802. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5803. var DEFAULT_FIELD_CONTENT = "-";
  5804. var NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  5805. var US_PAGE_NAMES = {
  5806. "8.5x11": "Letter",
  5807. "8.5x14": "Legal"
  5808. };
  5809. var METRIC_PAGE_NAMES = {
  5810. "297x420": "A3",
  5811. "210x297": "A4"
  5812. };
  5813. function getPageName(size, isPortrait, pageNames) {
  5814. var width = isPortrait ? size.width : size.height;
  5815. var height = isPortrait ? size.height : size.width;
  5816. return pageNames["".concat(width, "x").concat(height)];
  5817. }
  5818. var PDFDocumentProperties = /*#__PURE__*/function () {
  5819. function PDFDocumentProperties(_ref, overlayManager, eventBus) {
  5820. var _this = this;
  5821. var overlayName = _ref.overlayName,
  5822. fields = _ref.fields,
  5823. container = _ref.container,
  5824. closeButton = _ref.closeButton;
  5825. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  5826. _classCallCheck(this, PDFDocumentProperties);
  5827. this.overlayName = overlayName;
  5828. this.fields = fields;
  5829. this.container = container;
  5830. this.overlayManager = overlayManager;
  5831. this.l10n = l10n;
  5832. this._reset();
  5833. closeButton.addEventListener("click", this.close.bind(this));
  5834. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  5835. eventBus._on("pagechanging", function (evt) {
  5836. _this._currentPageNumber = evt.pageNumber;
  5837. });
  5838. eventBus._on("rotationchanging", function (evt) {
  5839. _this._pagesRotation = evt.pagesRotation;
  5840. });
  5841. this._isNonMetricLocale = true;
  5842. l10n.getLanguage().then(function (locale) {
  5843. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  5844. });
  5845. }
  5846. _createClass(PDFDocumentProperties, [{
  5847. key: "open",
  5848. value: function () {
  5849. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  5850. var _this2 = this;
  5851. var freezeFieldData, currentPageNumber, pagesRotation, _yield$this$pdfDocume, info, contentDispositionFilename, contentLength, _yield$Promise$all, _yield$Promise$all2, fileName, fileSize, creationDate, modificationDate, pageSize, isLinearized, _yield$this$pdfDocume2, length, data;
  5852. return _regenerator["default"].wrap(function _callee$(_context) {
  5853. while (1) {
  5854. switch (_context.prev = _context.next) {
  5855. case 0:
  5856. freezeFieldData = function freezeFieldData(data) {
  5857. Object.defineProperty(_this2, "fieldData", {
  5858. value: Object.freeze(data),
  5859. writable: false,
  5860. enumerable: true,
  5861. configurable: true
  5862. });
  5863. };
  5864. _context.next = 3;
  5865. return Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]);
  5866. case 3:
  5867. currentPageNumber = this._currentPageNumber;
  5868. pagesRotation = this._pagesRotation;
  5869. if (!(this.fieldData && currentPageNumber === this.fieldData._currentPageNumber && pagesRotation === this.fieldData._pagesRotation)) {
  5870. _context.next = 8;
  5871. break;
  5872. }
  5873. this._updateUI();
  5874. return _context.abrupt("return");
  5875. case 8:
  5876. _context.next = 10;
  5877. return this.pdfDocument.getMetadata();
  5878. case 10:
  5879. _yield$this$pdfDocume = _context.sent;
  5880. info = _yield$this$pdfDocume.info;
  5881. contentDispositionFilename = _yield$this$pdfDocume.contentDispositionFilename;
  5882. contentLength = _yield$this$pdfDocume.contentLength;
  5883. _context.next = 16;
  5884. return Promise.all([contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url), this._parseFileSize(contentLength), this._parseDate(info.CreationDate), this._parseDate(info.ModDate), this.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
  5885. return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  5886. }), this._parseLinearization(info.IsLinearized)]);
  5887. case 16:
  5888. _yield$Promise$all = _context.sent;
  5889. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 6);
  5890. fileName = _yield$Promise$all2[0];
  5891. fileSize = _yield$Promise$all2[1];
  5892. creationDate = _yield$Promise$all2[2];
  5893. modificationDate = _yield$Promise$all2[3];
  5894. pageSize = _yield$Promise$all2[4];
  5895. isLinearized = _yield$Promise$all2[5];
  5896. freezeFieldData({
  5897. fileName: fileName,
  5898. fileSize: fileSize,
  5899. title: info.Title,
  5900. author: info.Author,
  5901. subject: info.Subject,
  5902. keywords: info.Keywords,
  5903. creationDate: creationDate,
  5904. modificationDate: modificationDate,
  5905. creator: info.Creator,
  5906. producer: info.Producer,
  5907. version: info.PDFFormatVersion,
  5908. pageCount: this.pdfDocument.numPages,
  5909. pageSize: pageSize,
  5910. linearized: isLinearized,
  5911. _currentPageNumber: currentPageNumber,
  5912. _pagesRotation: pagesRotation
  5913. });
  5914. this._updateUI();
  5915. _context.next = 28;
  5916. return this.pdfDocument.getDownloadInfo();
  5917. case 28:
  5918. _yield$this$pdfDocume2 = _context.sent;
  5919. length = _yield$this$pdfDocume2.length;
  5920. if (!(contentLength === length)) {
  5921. _context.next = 32;
  5922. break;
  5923. }
  5924. return _context.abrupt("return");
  5925. case 32:
  5926. data = Object.assign(Object.create(null), this.fieldData);
  5927. _context.next = 35;
  5928. return this._parseFileSize(length);
  5929. case 35:
  5930. data.fileSize = _context.sent;
  5931. freezeFieldData(data);
  5932. this._updateUI();
  5933. case 38:
  5934. case "end":
  5935. return _context.stop();
  5936. }
  5937. }
  5938. }, _callee, this);
  5939. }));
  5940. function open() {
  5941. return _open.apply(this, arguments);
  5942. }
  5943. return open;
  5944. }()
  5945. }, {
  5946. key: "close",
  5947. value: function close() {
  5948. this.overlayManager.close(this.overlayName);
  5949. }
  5950. }, {
  5951. key: "setDocument",
  5952. value: function setDocument(pdfDocument) {
  5953. var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5954. if (this.pdfDocument) {
  5955. this._reset();
  5956. this._updateUI(true);
  5957. }
  5958. if (!pdfDocument) {
  5959. return;
  5960. }
  5961. this.pdfDocument = pdfDocument;
  5962. this.url = url;
  5963. this._dataAvailableCapability.resolve();
  5964. }
  5965. }, {
  5966. key: "_reset",
  5967. value: function _reset() {
  5968. this.pdfDocument = null;
  5969. this.url = null;
  5970. delete this.fieldData;
  5971. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5972. this._currentPageNumber = 1;
  5973. this._pagesRotation = 0;
  5974. }
  5975. }, {
  5976. key: "_updateUI",
  5977. value: function _updateUI() {
  5978. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5979. if (reset || !this.fieldData) {
  5980. for (var id in this.fields) {
  5981. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5982. }
  5983. return;
  5984. }
  5985. if (this.overlayManager.active !== this.overlayName) {
  5986. return;
  5987. }
  5988. for (var _id in this.fields) {
  5989. var content = this.fieldData[_id];
  5990. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5991. }
  5992. }
  5993. }, {
  5994. key: "_parseFileSize",
  5995. value: function () {
  5996. var _parseFileSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  5997. var fileSize,
  5998. kb,
  5999. _args2 = arguments;
  6000. return _regenerator["default"].wrap(function _callee2$(_context2) {
  6001. while (1) {
  6002. switch (_context2.prev = _context2.next) {
  6003. case 0:
  6004. fileSize = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : 0;
  6005. kb = fileSize / 1024;
  6006. if (kb) {
  6007. _context2.next = 6;
  6008. break;
  6009. }
  6010. return _context2.abrupt("return", undefined);
  6011. case 6:
  6012. if (!(kb < 1024)) {
  6013. _context2.next = 8;
  6014. break;
  6015. }
  6016. return _context2.abrupt("return", this.l10n.get("document_properties_kb", {
  6017. size_kb: (+kb.toPrecision(3)).toLocaleString(),
  6018. size_b: fileSize.toLocaleString()
  6019. }, "{{size_kb}} KB ({{size_b}} bytes)"));
  6020. case 8:
  6021. return _context2.abrupt("return", this.l10n.get("document_properties_mb", {
  6022. size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
  6023. size_b: fileSize.toLocaleString()
  6024. }, "{{size_mb}} MB ({{size_b}} bytes)"));
  6025. case 9:
  6026. case "end":
  6027. return _context2.stop();
  6028. }
  6029. }
  6030. }, _callee2, this);
  6031. }));
  6032. function _parseFileSize() {
  6033. return _parseFileSize2.apply(this, arguments);
  6034. }
  6035. return _parseFileSize;
  6036. }()
  6037. }, {
  6038. key: "_parsePageSize",
  6039. value: function () {
  6040. var _parsePageSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(pageSizeInches, pagesRotation) {
  6041. var _this3 = this;
  6042. var isPortrait, sizeInches, sizeMillimeters, pageName, rawName, exactMillimeters, intMillimeters;
  6043. return _regenerator["default"].wrap(function _callee3$(_context3) {
  6044. while (1) {
  6045. switch (_context3.prev = _context3.next) {
  6046. case 0:
  6047. if (pageSizeInches) {
  6048. _context3.next = 2;
  6049. break;
  6050. }
  6051. return _context3.abrupt("return", undefined);
  6052. case 2:
  6053. if (pagesRotation % 180 !== 0) {
  6054. pageSizeInches = {
  6055. width: pageSizeInches.height,
  6056. height: pageSizeInches.width
  6057. };
  6058. }
  6059. isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  6060. sizeInches = {
  6061. width: Math.round(pageSizeInches.width * 100) / 100,
  6062. height: Math.round(pageSizeInches.height * 100) / 100
  6063. };
  6064. sizeMillimeters = {
  6065. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  6066. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  6067. };
  6068. pageName = null;
  6069. rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  6070. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  6071. exactMillimeters = {
  6072. width: pageSizeInches.width * 25.4,
  6073. height: pageSizeInches.height * 25.4
  6074. };
  6075. intMillimeters = {
  6076. width: Math.round(sizeMillimeters.width),
  6077. height: Math.round(sizeMillimeters.height)
  6078. };
  6079. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  6080. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  6081. if (rawName) {
  6082. sizeInches = {
  6083. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  6084. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  6085. };
  6086. sizeMillimeters = intMillimeters;
  6087. }
  6088. }
  6089. }
  6090. if (rawName) {
  6091. pageName = this.l10n.get("document_properties_page_size_name_" + rawName.toLowerCase(), null, rawName);
  6092. }
  6093. return _context3.abrupt("return", Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get("document_properties_page_size_unit_" + (this._isNonMetricLocale ? "inches" : "millimeters"), null, this._isNonMetricLocale ? "in" : "mm"), pageName, this.l10n.get("document_properties_page_size_orientation_" + (isPortrait ? "portrait" : "landscape"), null, isPortrait ? "portrait" : "landscape")]).then(function (_ref2) {
  6094. var _ref3 = _slicedToArray(_ref2, 4),
  6095. _ref3$ = _ref3[0],
  6096. width = _ref3$.width,
  6097. height = _ref3$.height,
  6098. unit = _ref3[1],
  6099. name = _ref3[2],
  6100. orientation = _ref3[3];
  6101. return _this3.l10n.get("document_properties_page_size_dimension_" + (name ? "name_" : "") + "string", {
  6102. width: width.toLocaleString(),
  6103. height: height.toLocaleString(),
  6104. unit: unit,
  6105. name: name,
  6106. orientation: orientation
  6107. }, "{{width}} × {{height}} {{unit}} (" + (name ? "{{name}}, " : "") + "{{orientation}})");
  6108. }));
  6109. case 11:
  6110. case "end":
  6111. return _context3.stop();
  6112. }
  6113. }
  6114. }, _callee3, this);
  6115. }));
  6116. function _parsePageSize(_x, _x2) {
  6117. return _parsePageSize2.apply(this, arguments);
  6118. }
  6119. return _parsePageSize;
  6120. }()
  6121. }, {
  6122. key: "_parseDate",
  6123. value: function () {
  6124. var _parseDate2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(inputDate) {
  6125. var dateObject;
  6126. return _regenerator["default"].wrap(function _callee4$(_context4) {
  6127. while (1) {
  6128. switch (_context4.prev = _context4.next) {
  6129. case 0:
  6130. dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  6131. if (dateObject) {
  6132. _context4.next = 3;
  6133. break;
  6134. }
  6135. return _context4.abrupt("return", undefined);
  6136. case 3:
  6137. return _context4.abrupt("return", this.l10n.get("document_properties_date_string", {
  6138. date: dateObject.toLocaleDateString(),
  6139. time: dateObject.toLocaleTimeString()
  6140. }, "{{date}}, {{time}}"));
  6141. case 4:
  6142. case "end":
  6143. return _context4.stop();
  6144. }
  6145. }
  6146. }, _callee4, this);
  6147. }));
  6148. function _parseDate(_x3) {
  6149. return _parseDate2.apply(this, arguments);
  6150. }
  6151. return _parseDate;
  6152. }()
  6153. }, {
  6154. key: "_parseLinearization",
  6155. value: function _parseLinearization(isLinearized) {
  6156. return this.l10n.get("document_properties_linearized_" + (isLinearized ? "yes" : "no"), null, isLinearized ? "Yes" : "No");
  6157. }
  6158. }]);
  6159. return PDFDocumentProperties;
  6160. }();
  6161. exports.PDFDocumentProperties = PDFDocumentProperties;
  6162. /***/ }),
  6163. /* 16 */
  6164. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6165. Object.defineProperty(exports, "__esModule", ({
  6166. value: true
  6167. }));
  6168. exports.PDFFindBar = void 0;
  6169. var _pdf_find_controller = __webpack_require__(17);
  6170. var _ui_utils = __webpack_require__(6);
  6171. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6172. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6173. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6174. var MATCHES_COUNT_LIMIT = 1000;
  6175. var PDFFindBar = /*#__PURE__*/function () {
  6176. function PDFFindBar(options, eventBus) {
  6177. var _this = this;
  6178. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  6179. _classCallCheck(this, PDFFindBar);
  6180. this.opened = false;
  6181. this.bar = options.bar || null;
  6182. this.toggleButton = options.toggleButton || null;
  6183. this.findField = options.findField || null;
  6184. this.highlightAll = options.highlightAllCheckbox || null;
  6185. this.caseSensitive = options.caseSensitiveCheckbox || null;
  6186. this.entireWord = options.entireWordCheckbox || null;
  6187. this.findMsg = options.findMsg || null;
  6188. this.findResultsCount = options.findResultsCount || null;
  6189. this.findPreviousButton = options.findPreviousButton || null;
  6190. this.findNextButton = options.findNextButton || null;
  6191. this.eventBus = eventBus;
  6192. this.l10n = l10n;
  6193. this.toggleButton.addEventListener("click", function () {
  6194. _this.toggle();
  6195. });
  6196. this.findField.addEventListener("input", function () {
  6197. _this.dispatchEvent("");
  6198. });
  6199. this.bar.addEventListener("keydown", function (e) {
  6200. switch (e.keyCode) {
  6201. case 13:
  6202. if (e.target === _this.findField) {
  6203. _this.dispatchEvent("again", e.shiftKey);
  6204. }
  6205. break;
  6206. case 27:
  6207. _this.close();
  6208. break;
  6209. }
  6210. });
  6211. this.findPreviousButton.addEventListener("click", function () {
  6212. _this.dispatchEvent("again", true);
  6213. });
  6214. this.findNextButton.addEventListener("click", function () {
  6215. _this.dispatchEvent("again", false);
  6216. });
  6217. this.highlightAll.addEventListener("click", function () {
  6218. _this.dispatchEvent("highlightallchange");
  6219. });
  6220. this.caseSensitive.addEventListener("click", function () {
  6221. _this.dispatchEvent("casesensitivitychange");
  6222. });
  6223. this.entireWord.addEventListener("click", function () {
  6224. _this.dispatchEvent("entirewordchange");
  6225. });
  6226. this.eventBus._on("resize", this._adjustWidth.bind(this));
  6227. }
  6228. _createClass(PDFFindBar, [{
  6229. key: "reset",
  6230. value: function reset() {
  6231. this.updateUIState();
  6232. }
  6233. }, {
  6234. key: "dispatchEvent",
  6235. value: function dispatchEvent(type, findPrev) {
  6236. this.eventBus.dispatch("find", {
  6237. source: this,
  6238. type: type,
  6239. query: this.findField.value,
  6240. phraseSearch: true,
  6241. caseSensitive: this.caseSensitive.checked,
  6242. entireWord: this.entireWord.checked,
  6243. highlightAll: this.highlightAll.checked,
  6244. findPrevious: findPrev
  6245. });
  6246. }
  6247. }, {
  6248. key: "updateUIState",
  6249. value: function updateUIState(state, previous, matchesCount) {
  6250. var _this2 = this;
  6251. var findMsg = "";
  6252. var status = "";
  6253. switch (state) {
  6254. case _pdf_find_controller.FindState.FOUND:
  6255. break;
  6256. case _pdf_find_controller.FindState.PENDING:
  6257. status = "pending";
  6258. break;
  6259. case _pdf_find_controller.FindState.NOT_FOUND:
  6260. findMsg = this.l10n.get("find_not_found", null, "Phrase not found");
  6261. status = "notFound";
  6262. break;
  6263. case _pdf_find_controller.FindState.WRAPPED:
  6264. if (previous) {
  6265. findMsg = this.l10n.get("find_reached_top", null, "Reached top of document, continued from bottom");
  6266. } else {
  6267. findMsg = this.l10n.get("find_reached_bottom", null, "Reached end of document, continued from top");
  6268. }
  6269. break;
  6270. }
  6271. this.findField.setAttribute("data-status", status);
  6272. Promise.resolve(findMsg).then(function (msg) {
  6273. _this2.findMsg.textContent = msg;
  6274. _this2._adjustWidth();
  6275. });
  6276. this.updateResultsCount(matchesCount);
  6277. }
  6278. }, {
  6279. key: "updateResultsCount",
  6280. value: function updateResultsCount() {
  6281. var _this3 = this;
  6282. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  6283. _ref$current = _ref.current,
  6284. current = _ref$current === void 0 ? 0 : _ref$current,
  6285. _ref$total = _ref.total,
  6286. total = _ref$total === void 0 ? 0 : _ref$total;
  6287. if (!this.findResultsCount) {
  6288. return;
  6289. }
  6290. var limit = MATCHES_COUNT_LIMIT;
  6291. var matchesCountMsg = "";
  6292. if (total > 0) {
  6293. if (total > limit) {
  6294. matchesCountMsg = this.l10n.get("find_match_count_limit", {
  6295. limit: limit
  6296. }, "More than {{limit}} match" + (limit !== 1 ? "es" : ""));
  6297. } else {
  6298. matchesCountMsg = this.l10n.get("find_match_count", {
  6299. current: current,
  6300. total: total
  6301. }, "{{current}} of {{total}} match" + (total !== 1 ? "es" : ""));
  6302. }
  6303. }
  6304. Promise.resolve(matchesCountMsg).then(function (msg) {
  6305. _this3.findResultsCount.textContent = msg;
  6306. _this3.findResultsCount.classList.toggle("hidden", !total);
  6307. _this3._adjustWidth();
  6308. });
  6309. }
  6310. }, {
  6311. key: "open",
  6312. value: function open() {
  6313. if (!this.opened) {
  6314. this.opened = true;
  6315. this.toggleButton.classList.add("toggled");
  6316. this.bar.classList.remove("hidden");
  6317. }
  6318. this.findField.select();
  6319. this.findField.focus();
  6320. this._adjustWidth();
  6321. }
  6322. }, {
  6323. key: "close",
  6324. value: function close() {
  6325. if (!this.opened) {
  6326. return;
  6327. }
  6328. this.opened = false;
  6329. this.toggleButton.classList.remove("toggled");
  6330. this.bar.classList.add("hidden");
  6331. this.eventBus.dispatch("findbarclose", {
  6332. source: this
  6333. });
  6334. }
  6335. }, {
  6336. key: "toggle",
  6337. value: function toggle() {
  6338. if (this.opened) {
  6339. this.close();
  6340. } else {
  6341. this.open();
  6342. }
  6343. }
  6344. }, {
  6345. key: "_adjustWidth",
  6346. value: function _adjustWidth() {
  6347. if (!this.opened) {
  6348. return;
  6349. }
  6350. this.bar.classList.remove("wrapContainers");
  6351. var findbarHeight = this.bar.clientHeight;
  6352. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  6353. if (findbarHeight > inputContainerHeight) {
  6354. this.bar.classList.add("wrapContainers");
  6355. }
  6356. }
  6357. }]);
  6358. return PDFFindBar;
  6359. }();
  6360. exports.PDFFindBar = PDFFindBar;
  6361. /***/ }),
  6362. /* 17 */
  6363. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6364. Object.defineProperty(exports, "__esModule", ({
  6365. value: true
  6366. }));
  6367. exports.PDFFindController = exports.FindState = void 0;
  6368. var _pdfjsLib = __webpack_require__(7);
  6369. var _pdf_find_utils = __webpack_require__(18);
  6370. var _ui_utils = __webpack_require__(6);
  6371. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6372. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6373. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6374. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  6375. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  6376. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  6377. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  6378. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  6379. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  6380. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  6381. var FindState = {
  6382. FOUND: 0,
  6383. NOT_FOUND: 1,
  6384. WRAPPED: 2,
  6385. PENDING: 3
  6386. };
  6387. exports.FindState = FindState;
  6388. var FIND_TIMEOUT = 250;
  6389. var MATCH_SCROLL_OFFSET_TOP = -50;
  6390. var MATCH_SCROLL_OFFSET_LEFT = -400;
  6391. var CHARACTERS_TO_NORMALIZE = {
  6392. "\u2018": "'",
  6393. "\u2019": "'",
  6394. "\u201A": "'",
  6395. "\u201B": "'",
  6396. "\u201C": '"',
  6397. "\u201D": '"',
  6398. "\u201E": '"',
  6399. "\u201F": '"',
  6400. "\xBC": "1/4",
  6401. "\xBD": "1/2",
  6402. "\xBE": "3/4"
  6403. };
  6404. var normalizationRegex = null;
  6405. function normalize(text) {
  6406. if (!normalizationRegex) {
  6407. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  6408. normalizationRegex = new RegExp("[".concat(replace, "]"), "g");
  6409. }
  6410. var diffs = null;
  6411. var normalizedText = text.replace(normalizationRegex, function (ch, index) {
  6412. var normalizedCh = CHARACTERS_TO_NORMALIZE[ch],
  6413. diff = normalizedCh.length - ch.length;
  6414. if (diff !== 0) {
  6415. (diffs || (diffs = [])).push([index, diff]);
  6416. }
  6417. return normalizedCh;
  6418. });
  6419. return [normalizedText, diffs];
  6420. }
  6421. function getOriginalIndex(matchIndex) {
  6422. var diffs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6423. if (!diffs) {
  6424. return matchIndex;
  6425. }
  6426. var totalDiff = 0;
  6427. var _iterator = _createForOfIteratorHelper(diffs),
  6428. _step;
  6429. try {
  6430. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  6431. var _step$value = _slicedToArray(_step.value, 2),
  6432. index = _step$value[0],
  6433. diff = _step$value[1];
  6434. var currentIndex = index + totalDiff;
  6435. if (currentIndex >= matchIndex) {
  6436. break;
  6437. }
  6438. if (currentIndex + diff > matchIndex) {
  6439. totalDiff += matchIndex - currentIndex;
  6440. break;
  6441. }
  6442. totalDiff += diff;
  6443. }
  6444. } catch (err) {
  6445. _iterator.e(err);
  6446. } finally {
  6447. _iterator.f();
  6448. }
  6449. return matchIndex - totalDiff;
  6450. }
  6451. var PDFFindController = /*#__PURE__*/function () {
  6452. function PDFFindController(_ref) {
  6453. var linkService = _ref.linkService,
  6454. eventBus = _ref.eventBus;
  6455. _classCallCheck(this, PDFFindController);
  6456. this._linkService = linkService;
  6457. this._eventBus = eventBus;
  6458. this._reset();
  6459. eventBus._on("findbarclose", this._onFindBarClose.bind(this));
  6460. }
  6461. _createClass(PDFFindController, [{
  6462. key: "setDocument",
  6463. value: function setDocument(pdfDocument) {
  6464. if (this._pdfDocument) {
  6465. this._reset();
  6466. }
  6467. if (!pdfDocument) {
  6468. return;
  6469. }
  6470. this._pdfDocument = pdfDocument;
  6471. this._firstPageCapability.resolve();
  6472. }
  6473. }, {
  6474. key: "executeCommand",
  6475. value: function executeCommand(cmd, state) {
  6476. var _this = this;
  6477. if (!state) {
  6478. return;
  6479. }
  6480. var pdfDocument = this._pdfDocument;
  6481. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  6482. this._dirtyMatch = true;
  6483. }
  6484. this._state = state;
  6485. if (cmd !== "findhighlightallchange") {
  6486. this._updateUIState(FindState.PENDING);
  6487. }
  6488. this._firstPageCapability.promise.then(function () {
  6489. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  6490. return;
  6491. }
  6492. _this._extractText();
  6493. var findbarClosed = !_this._highlightMatches;
  6494. var pendingTimeout = !!_this._findTimeout;
  6495. if (_this._findTimeout) {
  6496. clearTimeout(_this._findTimeout);
  6497. _this._findTimeout = null;
  6498. }
  6499. if (cmd === "find") {
  6500. _this._findTimeout = setTimeout(function () {
  6501. _this._nextMatch();
  6502. _this._findTimeout = null;
  6503. }, FIND_TIMEOUT);
  6504. } else if (_this._dirtyMatch) {
  6505. _this._nextMatch();
  6506. } else if (cmd === "findagain") {
  6507. _this._nextMatch();
  6508. if (findbarClosed && _this._state.highlightAll) {
  6509. _this._updateAllPages();
  6510. }
  6511. } else if (cmd === "findhighlightallchange") {
  6512. if (pendingTimeout) {
  6513. _this._nextMatch();
  6514. } else {
  6515. _this._highlightMatches = true;
  6516. }
  6517. _this._updateAllPages();
  6518. } else {
  6519. _this._nextMatch();
  6520. }
  6521. });
  6522. }
  6523. }, {
  6524. key: "scrollMatchIntoView",
  6525. value: function scrollMatchIntoView(_ref2) {
  6526. var _ref2$element = _ref2.element,
  6527. element = _ref2$element === void 0 ? null : _ref2$element,
  6528. _ref2$pageIndex = _ref2.pageIndex,
  6529. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  6530. _ref2$matchIndex = _ref2.matchIndex,
  6531. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  6532. if (!this._scrollMatches || !element) {
  6533. return;
  6534. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  6535. return;
  6536. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  6537. return;
  6538. }
  6539. this._scrollMatches = false;
  6540. var spot = {
  6541. top: MATCH_SCROLL_OFFSET_TOP,
  6542. left: MATCH_SCROLL_OFFSET_LEFT
  6543. };
  6544. (0, _ui_utils.scrollIntoView)(element, spot, true);
  6545. }
  6546. }, {
  6547. key: "_reset",
  6548. value: function _reset() {
  6549. this._highlightMatches = false;
  6550. this._scrollMatches = false;
  6551. this._pdfDocument = null;
  6552. this._pageMatches = [];
  6553. this._pageMatchesLength = [];
  6554. this._state = null;
  6555. this._selected = {
  6556. pageIdx: -1,
  6557. matchIdx: -1
  6558. };
  6559. this._offset = {
  6560. pageIdx: null,
  6561. matchIdx: null,
  6562. wrapped: false
  6563. };
  6564. this._extractTextPromises = [];
  6565. this._pageContents = [];
  6566. this._pageDiffs = [];
  6567. this._matchesCountTotal = 0;
  6568. this._pagesToSearch = null;
  6569. this._pendingFindMatches = Object.create(null);
  6570. this._resumePageIdx = null;
  6571. this._dirtyMatch = false;
  6572. clearTimeout(this._findTimeout);
  6573. this._findTimeout = null;
  6574. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  6575. }
  6576. }, {
  6577. key: "_shouldDirtyMatch",
  6578. value: function _shouldDirtyMatch(cmd, state) {
  6579. if (state.query !== this._state.query) {
  6580. return true;
  6581. }
  6582. switch (cmd) {
  6583. case "findagain":
  6584. var pageNumber = this._selected.pageIdx + 1;
  6585. var linkService = this._linkService;
  6586. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  6587. return true;
  6588. }
  6589. return false;
  6590. case "findhighlightallchange":
  6591. return false;
  6592. }
  6593. return true;
  6594. }
  6595. }, {
  6596. key: "_prepareMatches",
  6597. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  6598. function isSubTerm(currentIndex) {
  6599. var currentElem = matchesWithLength[currentIndex];
  6600. var nextElem = matchesWithLength[currentIndex + 1];
  6601. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  6602. currentElem.skipped = true;
  6603. return true;
  6604. }
  6605. for (var i = currentIndex - 1; i >= 0; i--) {
  6606. var prevElem = matchesWithLength[i];
  6607. if (prevElem.skipped) {
  6608. continue;
  6609. }
  6610. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  6611. break;
  6612. }
  6613. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  6614. currentElem.skipped = true;
  6615. return true;
  6616. }
  6617. }
  6618. return false;
  6619. }
  6620. matchesWithLength.sort(function (a, b) {
  6621. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  6622. });
  6623. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  6624. if (isSubTerm(i)) {
  6625. continue;
  6626. }
  6627. matches.push(matchesWithLength[i].match);
  6628. matchesLength.push(matchesWithLength[i].matchLength);
  6629. }
  6630. }
  6631. }, {
  6632. key: "_isEntireWord",
  6633. value: function _isEntireWord(content, startIdx, length) {
  6634. if (startIdx > 0) {
  6635. var first = content.charCodeAt(startIdx);
  6636. var limit = content.charCodeAt(startIdx - 1);
  6637. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  6638. return false;
  6639. }
  6640. }
  6641. var endIdx = startIdx + length - 1;
  6642. if (endIdx < content.length - 1) {
  6643. var last = content.charCodeAt(endIdx);
  6644. var _limit = content.charCodeAt(endIdx + 1);
  6645. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  6646. return false;
  6647. }
  6648. }
  6649. return true;
  6650. }
  6651. }, {
  6652. key: "_calculatePhraseMatch",
  6653. value: function _calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord) {
  6654. var matches = [],
  6655. matchesLength = [];
  6656. var queryLen = query.length;
  6657. var matchIdx = -queryLen;
  6658. while (true) {
  6659. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  6660. if (matchIdx === -1) {
  6661. break;
  6662. }
  6663. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  6664. continue;
  6665. }
  6666. var originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs),
  6667. matchEnd = matchIdx + queryLen - 1,
  6668. originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1;
  6669. matches.push(originalMatchIdx);
  6670. matchesLength.push(originalQueryLen);
  6671. }
  6672. this._pageMatches[pageIndex] = matches;
  6673. this._pageMatchesLength[pageIndex] = matchesLength;
  6674. }
  6675. }, {
  6676. key: "_calculateWordMatch",
  6677. value: function _calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord) {
  6678. var matchesWithLength = [];
  6679. var queryArray = query.match(/\S+/g);
  6680. for (var i = 0, len = queryArray.length; i < len; i++) {
  6681. var subquery = queryArray[i];
  6682. var subqueryLen = subquery.length;
  6683. var matchIdx = -subqueryLen;
  6684. while (true) {
  6685. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  6686. if (matchIdx === -1) {
  6687. break;
  6688. }
  6689. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  6690. continue;
  6691. }
  6692. var originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs),
  6693. matchEnd = matchIdx + subqueryLen - 1,
  6694. originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1;
  6695. matchesWithLength.push({
  6696. match: originalMatchIdx,
  6697. matchLength: originalQueryLen,
  6698. skipped: false
  6699. });
  6700. }
  6701. }
  6702. this._pageMatchesLength[pageIndex] = [];
  6703. this._pageMatches[pageIndex] = [];
  6704. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  6705. }
  6706. }, {
  6707. key: "_calculateMatch",
  6708. value: function _calculateMatch(pageIndex) {
  6709. var pageContent = this._pageContents[pageIndex];
  6710. var pageDiffs = this._pageDiffs[pageIndex];
  6711. var query = this._query;
  6712. var _this$_state = this._state,
  6713. caseSensitive = _this$_state.caseSensitive,
  6714. entireWord = _this$_state.entireWord,
  6715. phraseSearch = _this$_state.phraseSearch;
  6716. if (query.length === 0) {
  6717. return;
  6718. }
  6719. if (!caseSensitive) {
  6720. pageContent = pageContent.toLowerCase();
  6721. query = query.toLowerCase();
  6722. }
  6723. if (phraseSearch) {
  6724. this._calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord);
  6725. } else {
  6726. this._calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord);
  6727. }
  6728. if (this._state.highlightAll) {
  6729. this._updatePage(pageIndex);
  6730. }
  6731. if (this._resumePageIdx === pageIndex) {
  6732. this._resumePageIdx = null;
  6733. this._nextPageMatch();
  6734. }
  6735. var pageMatchesCount = this._pageMatches[pageIndex].length;
  6736. if (pageMatchesCount > 0) {
  6737. this._matchesCountTotal += pageMatchesCount;
  6738. this._updateUIResultsCount();
  6739. }
  6740. }
  6741. }, {
  6742. key: "_extractText",
  6743. value: function _extractText() {
  6744. var _this2 = this;
  6745. if (this._extractTextPromises.length > 0) {
  6746. return;
  6747. }
  6748. var promise = Promise.resolve();
  6749. var _loop = function _loop(i, ii) {
  6750. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  6751. _this2._extractTextPromises[i] = extractTextCapability.promise;
  6752. promise = promise.then(function () {
  6753. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  6754. return pdfPage.getTextContent({
  6755. normalizeWhitespace: true
  6756. });
  6757. }).then(function (textContent) {
  6758. var textItems = textContent.items;
  6759. var strBuf = [];
  6760. for (var j = 0, jj = textItems.length; j < jj; j++) {
  6761. strBuf.push(textItems[j].str);
  6762. }
  6763. var _normalize = normalize(strBuf.join(""));
  6764. var _normalize2 = _slicedToArray(_normalize, 2);
  6765. _this2._pageContents[i] = _normalize2[0];
  6766. _this2._pageDiffs[i] = _normalize2[1];
  6767. extractTextCapability.resolve(i);
  6768. }, function (reason) {
  6769. console.error("Unable to get text content for page ".concat(i + 1), reason);
  6770. _this2._pageContents[i] = "";
  6771. _this2._pageDiffs[i] = null;
  6772. extractTextCapability.resolve(i);
  6773. });
  6774. });
  6775. };
  6776. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  6777. _loop(i, ii);
  6778. }
  6779. }
  6780. }, {
  6781. key: "_updatePage",
  6782. value: function _updatePage(index) {
  6783. if (this._scrollMatches && this._selected.pageIdx === index) {
  6784. this._linkService.page = index + 1;
  6785. }
  6786. this._eventBus.dispatch("updatetextlayermatches", {
  6787. source: this,
  6788. pageIndex: index
  6789. });
  6790. }
  6791. }, {
  6792. key: "_updateAllPages",
  6793. value: function _updateAllPages() {
  6794. this._eventBus.dispatch("updatetextlayermatches", {
  6795. source: this,
  6796. pageIndex: -1
  6797. });
  6798. }
  6799. }, {
  6800. key: "_nextMatch",
  6801. value: function _nextMatch() {
  6802. var _this3 = this;
  6803. var previous = this._state.findPrevious;
  6804. var currentPageIndex = this._linkService.page - 1;
  6805. var numPages = this._linkService.pagesCount;
  6806. this._highlightMatches = true;
  6807. if (this._dirtyMatch) {
  6808. this._dirtyMatch = false;
  6809. this._selected.pageIdx = this._selected.matchIdx = -1;
  6810. this._offset.pageIdx = currentPageIndex;
  6811. this._offset.matchIdx = null;
  6812. this._offset.wrapped = false;
  6813. this._resumePageIdx = null;
  6814. this._pageMatches.length = 0;
  6815. this._pageMatchesLength.length = 0;
  6816. this._matchesCountTotal = 0;
  6817. this._updateAllPages();
  6818. for (var i = 0; i < numPages; i++) {
  6819. if (this._pendingFindMatches[i] === true) {
  6820. continue;
  6821. }
  6822. this._pendingFindMatches[i] = true;
  6823. this._extractTextPromises[i].then(function (pageIdx) {
  6824. delete _this3._pendingFindMatches[pageIdx];
  6825. _this3._calculateMatch(pageIdx);
  6826. });
  6827. }
  6828. }
  6829. if (this._query === "") {
  6830. this._updateUIState(FindState.FOUND);
  6831. return;
  6832. }
  6833. if (this._resumePageIdx) {
  6834. return;
  6835. }
  6836. var offset = this._offset;
  6837. this._pagesToSearch = numPages;
  6838. if (offset.matchIdx !== null) {
  6839. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  6840. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  6841. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  6842. this._updateMatch(true);
  6843. return;
  6844. }
  6845. this._advanceOffsetPage(previous);
  6846. }
  6847. this._nextPageMatch();
  6848. }
  6849. }, {
  6850. key: "_matchesReady",
  6851. value: function _matchesReady(matches) {
  6852. var offset = this._offset;
  6853. var numMatches = matches.length;
  6854. var previous = this._state.findPrevious;
  6855. if (numMatches) {
  6856. offset.matchIdx = previous ? numMatches - 1 : 0;
  6857. this._updateMatch(true);
  6858. return true;
  6859. }
  6860. this._advanceOffsetPage(previous);
  6861. if (offset.wrapped) {
  6862. offset.matchIdx = null;
  6863. if (this._pagesToSearch < 0) {
  6864. this._updateMatch(false);
  6865. return true;
  6866. }
  6867. }
  6868. return false;
  6869. }
  6870. }, {
  6871. key: "_nextPageMatch",
  6872. value: function _nextPageMatch() {
  6873. if (this._resumePageIdx !== null) {
  6874. console.error("There can only be one pending page.");
  6875. }
  6876. var matches = null;
  6877. do {
  6878. var pageIdx = this._offset.pageIdx;
  6879. matches = this._pageMatches[pageIdx];
  6880. if (!matches) {
  6881. this._resumePageIdx = pageIdx;
  6882. break;
  6883. }
  6884. } while (!this._matchesReady(matches));
  6885. }
  6886. }, {
  6887. key: "_advanceOffsetPage",
  6888. value: function _advanceOffsetPage(previous) {
  6889. var offset = this._offset;
  6890. var numPages = this._linkService.pagesCount;
  6891. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  6892. offset.matchIdx = null;
  6893. this._pagesToSearch--;
  6894. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  6895. offset.pageIdx = previous ? numPages - 1 : 0;
  6896. offset.wrapped = true;
  6897. }
  6898. }
  6899. }, {
  6900. key: "_updateMatch",
  6901. value: function _updateMatch() {
  6902. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6903. var state = FindState.NOT_FOUND;
  6904. var wrapped = this._offset.wrapped;
  6905. this._offset.wrapped = false;
  6906. if (found) {
  6907. var previousPage = this._selected.pageIdx;
  6908. this._selected.pageIdx = this._offset.pageIdx;
  6909. this._selected.matchIdx = this._offset.matchIdx;
  6910. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  6911. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  6912. this._updatePage(previousPage);
  6913. }
  6914. }
  6915. this._updateUIState(state, this._state.findPrevious);
  6916. if (this._selected.pageIdx !== -1) {
  6917. this._scrollMatches = true;
  6918. this._updatePage(this._selected.pageIdx);
  6919. }
  6920. }
  6921. }, {
  6922. key: "_onFindBarClose",
  6923. value: function _onFindBarClose(evt) {
  6924. var _this4 = this;
  6925. var pdfDocument = this._pdfDocument;
  6926. this._firstPageCapability.promise.then(function () {
  6927. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  6928. return;
  6929. }
  6930. if (_this4._findTimeout) {
  6931. clearTimeout(_this4._findTimeout);
  6932. _this4._findTimeout = null;
  6933. }
  6934. if (_this4._resumePageIdx) {
  6935. _this4._resumePageIdx = null;
  6936. _this4._dirtyMatch = true;
  6937. }
  6938. _this4._updateUIState(FindState.FOUND);
  6939. _this4._highlightMatches = false;
  6940. _this4._updateAllPages();
  6941. });
  6942. }
  6943. }, {
  6944. key: "_requestMatchesCount",
  6945. value: function _requestMatchesCount() {
  6946. var _this$_selected = this._selected,
  6947. pageIdx = _this$_selected.pageIdx,
  6948. matchIdx = _this$_selected.matchIdx;
  6949. var current = 0,
  6950. total = this._matchesCountTotal;
  6951. if (matchIdx !== -1) {
  6952. for (var i = 0; i < pageIdx; i++) {
  6953. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  6954. }
  6955. current += matchIdx + 1;
  6956. }
  6957. if (current < 1 || current > total) {
  6958. current = total = 0;
  6959. }
  6960. return {
  6961. current: current,
  6962. total: total
  6963. };
  6964. }
  6965. }, {
  6966. key: "_updateUIResultsCount",
  6967. value: function _updateUIResultsCount() {
  6968. this._eventBus.dispatch("updatefindmatchescount", {
  6969. source: this,
  6970. matchesCount: this._requestMatchesCount()
  6971. });
  6972. }
  6973. }, {
  6974. key: "_updateUIState",
  6975. value: function _updateUIState(state, previous) {
  6976. this._eventBus.dispatch("updatefindcontrolstate", {
  6977. source: this,
  6978. state: state,
  6979. previous: previous,
  6980. matchesCount: this._requestMatchesCount(),
  6981. rawQuery: this._state ? this._state.query : null
  6982. });
  6983. }
  6984. }, {
  6985. key: "highlightMatches",
  6986. get: function get() {
  6987. return this._highlightMatches;
  6988. }
  6989. }, {
  6990. key: "pageMatches",
  6991. get: function get() {
  6992. return this._pageMatches;
  6993. }
  6994. }, {
  6995. key: "pageMatchesLength",
  6996. get: function get() {
  6997. return this._pageMatchesLength;
  6998. }
  6999. }, {
  7000. key: "selected",
  7001. get: function get() {
  7002. return this._selected;
  7003. }
  7004. }, {
  7005. key: "state",
  7006. get: function get() {
  7007. return this._state;
  7008. }
  7009. }, {
  7010. key: "_query",
  7011. get: function get() {
  7012. if (this._state.query !== this._rawQuery) {
  7013. this._rawQuery = this._state.query;
  7014. var _normalize3 = normalize(this._state.query);
  7015. var _normalize4 = _slicedToArray(_normalize3, 1);
  7016. this._normalizedQuery = _normalize4[0];
  7017. }
  7018. return this._normalizedQuery;
  7019. }
  7020. }]);
  7021. return PDFFindController;
  7022. }();
  7023. exports.PDFFindController = PDFFindController;
  7024. /***/ }),
  7025. /* 18 */
  7026. /***/ ((__unused_webpack_module, exports) => {
  7027. Object.defineProperty(exports, "__esModule", ({
  7028. value: true
  7029. }));
  7030. exports.getCharacterType = getCharacterType;
  7031. exports.CharacterType = void 0;
  7032. var CharacterType = {
  7033. SPACE: 0,
  7034. ALPHA_LETTER: 1,
  7035. PUNCT: 2,
  7036. HAN_LETTER: 3,
  7037. KATAKANA_LETTER: 4,
  7038. HIRAGANA_LETTER: 5,
  7039. HALFWIDTH_KATAKANA_LETTER: 6,
  7040. THAI_LETTER: 7
  7041. };
  7042. exports.CharacterType = CharacterType;
  7043. function isAlphabeticalScript(charCode) {
  7044. return charCode < 0x2e80;
  7045. }
  7046. function isAscii(charCode) {
  7047. return (charCode & 0xff80) === 0;
  7048. }
  7049. function isAsciiAlpha(charCode) {
  7050. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  7051. }
  7052. function isAsciiDigit(charCode) {
  7053. return charCode >= 0x30 && charCode <= 0x39;
  7054. }
  7055. function isAsciiSpace(charCode) {
  7056. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  7057. }
  7058. function isHan(charCode) {
  7059. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  7060. }
  7061. function isKatakana(charCode) {
  7062. return charCode >= 0x30a0 && charCode <= 0x30ff;
  7063. }
  7064. function isHiragana(charCode) {
  7065. return charCode >= 0x3040 && charCode <= 0x309f;
  7066. }
  7067. function isHalfwidthKatakana(charCode) {
  7068. return charCode >= 0xff60 && charCode <= 0xff9f;
  7069. }
  7070. function isThai(charCode) {
  7071. return (charCode & 0xff80) === 0x0e00;
  7072. }
  7073. function getCharacterType(charCode) {
  7074. if (isAlphabeticalScript(charCode)) {
  7075. if (isAscii(charCode)) {
  7076. if (isAsciiSpace(charCode)) {
  7077. return CharacterType.SPACE;
  7078. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  7079. return CharacterType.ALPHA_LETTER;
  7080. }
  7081. return CharacterType.PUNCT;
  7082. } else if (isThai(charCode)) {
  7083. return CharacterType.THAI_LETTER;
  7084. } else if (charCode === 0xa0) {
  7085. return CharacterType.SPACE;
  7086. }
  7087. return CharacterType.ALPHA_LETTER;
  7088. }
  7089. if (isHan(charCode)) {
  7090. return CharacterType.HAN_LETTER;
  7091. } else if (isKatakana(charCode)) {
  7092. return CharacterType.KATAKANA_LETTER;
  7093. } else if (isHiragana(charCode)) {
  7094. return CharacterType.HIRAGANA_LETTER;
  7095. } else if (isHalfwidthKatakana(charCode)) {
  7096. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  7097. }
  7098. return CharacterType.ALPHA_LETTER;
  7099. }
  7100. /***/ }),
  7101. /* 19 */
  7102. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7103. Object.defineProperty(exports, "__esModule", ({
  7104. value: true
  7105. }));
  7106. exports.isDestArraysEqual = isDestArraysEqual;
  7107. exports.isDestHashesEqual = isDestHashesEqual;
  7108. exports.PDFHistory = void 0;
  7109. var _ui_utils = __webpack_require__(6);
  7110. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7111. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  7112. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  7113. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  7114. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  7115. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  7116. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  7117. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7118. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7119. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7120. var HASH_CHANGE_TIMEOUT = 1000;
  7121. var POSITION_UPDATED_THRESHOLD = 50;
  7122. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  7123. function getCurrentHash() {
  7124. return document.location.hash;
  7125. }
  7126. var PDFHistory = /*#__PURE__*/function () {
  7127. function PDFHistory(_ref) {
  7128. var _this = this;
  7129. var linkService = _ref.linkService,
  7130. eventBus = _ref.eventBus;
  7131. _classCallCheck(this, PDFHistory);
  7132. this.linkService = linkService;
  7133. this.eventBus = eventBus;
  7134. this._initialized = false;
  7135. this._fingerprint = "";
  7136. this.reset();
  7137. this._boundEvents = null;
  7138. this._isViewerInPresentationMode = false;
  7139. this.eventBus._on("presentationmodechanged", function (evt) {
  7140. _this._isViewerInPresentationMode = evt.state !== _ui_utils.PresentationModeState.NORMAL;
  7141. });
  7142. this.eventBus._on("pagesinit", function () {
  7143. _this._isPagesLoaded = false;
  7144. _this.eventBus._on("pagesloaded", function (evt) {
  7145. _this._isPagesLoaded = !!evt.pagesCount;
  7146. }, {
  7147. once: true
  7148. });
  7149. });
  7150. }
  7151. _createClass(PDFHistory, [{
  7152. key: "initialize",
  7153. value: function initialize(_ref2) {
  7154. var fingerprint = _ref2.fingerprint,
  7155. _ref2$resetHistory = _ref2.resetHistory,
  7156. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  7157. _ref2$updateUrl = _ref2.updateUrl,
  7158. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  7159. if (!fingerprint || typeof fingerprint !== "string") {
  7160. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  7161. return;
  7162. }
  7163. if (this._initialized) {
  7164. this.reset();
  7165. }
  7166. var reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  7167. this._fingerprint = fingerprint;
  7168. this._updateUrl = updateUrl === true;
  7169. this._initialized = true;
  7170. this._bindEvents();
  7171. var state = window.history.state;
  7172. this._popStateInProgress = false;
  7173. this._blockHashChange = 0;
  7174. this._currentHash = getCurrentHash();
  7175. this._numPositionUpdates = 0;
  7176. this._uid = this._maxUid = 0;
  7177. this._destination = null;
  7178. this._position = null;
  7179. if (!this._isValidState(state, true) || resetHistory) {
  7180. var _this$_parseCurrentHa = this._parseCurrentHash(true),
  7181. hash = _this$_parseCurrentHa.hash,
  7182. page = _this$_parseCurrentHa.page,
  7183. rotation = _this$_parseCurrentHa.rotation;
  7184. if (!hash || reInitialized || resetHistory) {
  7185. this._pushOrReplaceState(null, true);
  7186. return;
  7187. }
  7188. this._pushOrReplaceState({
  7189. hash: hash,
  7190. page: page,
  7191. rotation: rotation
  7192. }, true);
  7193. return;
  7194. }
  7195. var destination = state.destination;
  7196. this._updateInternalState(destination, state.uid, true);
  7197. if (destination.rotation !== undefined) {
  7198. this._initialRotation = destination.rotation;
  7199. }
  7200. if (destination.dest) {
  7201. this._initialBookmark = JSON.stringify(destination.dest);
  7202. this._destination.page = null;
  7203. } else if (destination.hash) {
  7204. this._initialBookmark = destination.hash;
  7205. } else if (destination.page) {
  7206. this._initialBookmark = "page=".concat(destination.page);
  7207. }
  7208. }
  7209. }, {
  7210. key: "reset",
  7211. value: function reset() {
  7212. if (this._initialized) {
  7213. this._pageHide();
  7214. this._initialized = false;
  7215. this._unbindEvents();
  7216. }
  7217. if (this._updateViewareaTimeout) {
  7218. clearTimeout(this._updateViewareaTimeout);
  7219. this._updateViewareaTimeout = null;
  7220. }
  7221. this._initialBookmark = null;
  7222. this._initialRotation = null;
  7223. }
  7224. }, {
  7225. key: "push",
  7226. value: function push(_ref3) {
  7227. var _this2 = this;
  7228. var _ref3$namedDest = _ref3.namedDest,
  7229. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  7230. explicitDest = _ref3.explicitDest,
  7231. pageNumber = _ref3.pageNumber;
  7232. if (!this._initialized) {
  7233. return;
  7234. }
  7235. if (namedDest && typeof namedDest !== "string") {
  7236. console.error("PDFHistory.push: " + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  7237. return;
  7238. } else if (!Array.isArray(explicitDest)) {
  7239. console.error("PDFHistory.push: " + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  7240. return;
  7241. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  7242. if (pageNumber !== null || this._destination) {
  7243. console.error("PDFHistory.push: " + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  7244. return;
  7245. }
  7246. }
  7247. var hash = namedDest || JSON.stringify(explicitDest);
  7248. if (!hash) {
  7249. return;
  7250. }
  7251. var forceReplace = false;
  7252. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  7253. if (this._destination.page) {
  7254. return;
  7255. }
  7256. forceReplace = true;
  7257. }
  7258. if (this._popStateInProgress && !forceReplace) {
  7259. return;
  7260. }
  7261. this._pushOrReplaceState({
  7262. dest: explicitDest,
  7263. hash: hash,
  7264. page: pageNumber,
  7265. rotation: this.linkService.rotation
  7266. }, forceReplace);
  7267. if (!this._popStateInProgress) {
  7268. this._popStateInProgress = true;
  7269. Promise.resolve().then(function () {
  7270. _this2._popStateInProgress = false;
  7271. });
  7272. }
  7273. }
  7274. }, {
  7275. key: "pushPage",
  7276. value: function pushPage(pageNumber) {
  7277. var _this$_destination,
  7278. _this3 = this;
  7279. if (!this._initialized) {
  7280. return;
  7281. }
  7282. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  7283. console.error("PDFHistory.pushPage: \"".concat(pageNumber, "\" is not a valid page number."));
  7284. return;
  7285. }
  7286. if (((_this$_destination = this._destination) === null || _this$_destination === void 0 ? void 0 : _this$_destination.page) === pageNumber) {
  7287. return;
  7288. }
  7289. if (this._popStateInProgress) {
  7290. return;
  7291. }
  7292. this._pushOrReplaceState({
  7293. hash: "page=".concat(pageNumber),
  7294. page: pageNumber,
  7295. rotation: this.linkService.rotation
  7296. });
  7297. if (!this._popStateInProgress) {
  7298. this._popStateInProgress = true;
  7299. Promise.resolve().then(function () {
  7300. _this3._popStateInProgress = false;
  7301. });
  7302. }
  7303. }
  7304. }, {
  7305. key: "pushCurrentPosition",
  7306. value: function pushCurrentPosition() {
  7307. if (!this._initialized || this._popStateInProgress) {
  7308. return;
  7309. }
  7310. this._tryPushCurrentPosition();
  7311. }
  7312. }, {
  7313. key: "back",
  7314. value: function back() {
  7315. if (!this._initialized || this._popStateInProgress) {
  7316. return;
  7317. }
  7318. var state = window.history.state;
  7319. if (this._isValidState(state) && state.uid > 0) {
  7320. window.history.back();
  7321. }
  7322. }
  7323. }, {
  7324. key: "forward",
  7325. value: function forward() {
  7326. if (!this._initialized || this._popStateInProgress) {
  7327. return;
  7328. }
  7329. var state = window.history.state;
  7330. if (this._isValidState(state) && state.uid < this._maxUid) {
  7331. window.history.forward();
  7332. }
  7333. }
  7334. }, {
  7335. key: "_pushOrReplaceState",
  7336. value: function _pushOrReplaceState(destination) {
  7337. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7338. var shouldReplace = forceReplace || !this._destination;
  7339. var newState = {
  7340. fingerprint: this._fingerprint,
  7341. uid: shouldReplace ? this._uid : this._uid + 1,
  7342. destination: destination
  7343. };
  7344. this._updateInternalState(destination, newState.uid);
  7345. var newUrl;
  7346. if (this._updateUrl && destination !== null && destination !== void 0 && destination.hash) {
  7347. var baseUrl = document.location.href.split("#")[0];
  7348. if (!baseUrl.startsWith("file://")) {
  7349. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  7350. }
  7351. }
  7352. if (shouldReplace) {
  7353. window.history.replaceState(newState, "", newUrl);
  7354. } else {
  7355. window.history.pushState(newState, "", newUrl);
  7356. }
  7357. }
  7358. }, {
  7359. key: "_tryPushCurrentPosition",
  7360. value: function _tryPushCurrentPosition() {
  7361. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7362. if (!this._position) {
  7363. return;
  7364. }
  7365. var position = this._position;
  7366. if (temporary) {
  7367. position = Object.assign(Object.create(null), this._position);
  7368. position.temporary = true;
  7369. }
  7370. if (!this._destination) {
  7371. this._pushOrReplaceState(position);
  7372. return;
  7373. }
  7374. if (this._destination.temporary) {
  7375. this._pushOrReplaceState(position, true);
  7376. return;
  7377. }
  7378. if (this._destination.hash === position.hash) {
  7379. return;
  7380. }
  7381. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  7382. return;
  7383. }
  7384. var forceReplace = false;
  7385. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  7386. if (this._destination.dest || !this._destination.first) {
  7387. return;
  7388. }
  7389. forceReplace = true;
  7390. }
  7391. this._pushOrReplaceState(position, forceReplace);
  7392. }
  7393. }, {
  7394. key: "_isValidState",
  7395. value: function _isValidState(state) {
  7396. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7397. if (!state) {
  7398. return false;
  7399. }
  7400. if (state.fingerprint !== this._fingerprint) {
  7401. if (checkReload) {
  7402. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  7403. return false;
  7404. }
  7405. var _performance$getEntri = performance.getEntriesByType("navigation"),
  7406. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  7407. perfEntry = _performance$getEntri2[0];
  7408. if ((perfEntry === null || perfEntry === void 0 ? void 0 : perfEntry.type) !== "reload") {
  7409. return false;
  7410. }
  7411. } else {
  7412. return false;
  7413. }
  7414. }
  7415. if (!Number.isInteger(state.uid) || state.uid < 0) {
  7416. return false;
  7417. }
  7418. if (state.destination === null || _typeof(state.destination) !== "object") {
  7419. return false;
  7420. }
  7421. return true;
  7422. }
  7423. }, {
  7424. key: "_updateInternalState",
  7425. value: function _updateInternalState(destination, uid) {
  7426. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7427. if (this._updateViewareaTimeout) {
  7428. clearTimeout(this._updateViewareaTimeout);
  7429. this._updateViewareaTimeout = null;
  7430. }
  7431. if (removeTemporary && destination !== null && destination !== void 0 && destination.temporary) {
  7432. delete destination.temporary;
  7433. }
  7434. this._destination = destination;
  7435. this._uid = uid;
  7436. this._maxUid = Math.max(this._maxUid, uid);
  7437. this._numPositionUpdates = 0;
  7438. }
  7439. }, {
  7440. key: "_parseCurrentHash",
  7441. value: function _parseCurrentHash() {
  7442. var checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7443. var hash = unescape(getCurrentHash()).substring(1);
  7444. var params = (0, _ui_utils.parseQueryString)(hash);
  7445. var nameddest = params.nameddest || "";
  7446. var page = params.page | 0;
  7447. if (!(Number.isInteger(page) && page > 0 && page <= this.linkService.pagesCount) || checkNameddest && nameddest.length > 0) {
  7448. page = null;
  7449. }
  7450. return {
  7451. hash: hash,
  7452. page: page,
  7453. rotation: this.linkService.rotation
  7454. };
  7455. }
  7456. }, {
  7457. key: "_updateViewarea",
  7458. value: function _updateViewarea(_ref4) {
  7459. var _this4 = this;
  7460. var location = _ref4.location;
  7461. if (this._updateViewareaTimeout) {
  7462. clearTimeout(this._updateViewareaTimeout);
  7463. this._updateViewareaTimeout = null;
  7464. }
  7465. this._position = {
  7466. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  7467. page: this.linkService.page,
  7468. first: location.pageNumber,
  7469. rotation: location.rotation
  7470. };
  7471. if (this._popStateInProgress) {
  7472. return;
  7473. }
  7474. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  7475. this._numPositionUpdates++;
  7476. }
  7477. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  7478. this._updateViewareaTimeout = setTimeout(function () {
  7479. if (!_this4._popStateInProgress) {
  7480. _this4._tryPushCurrentPosition(true);
  7481. }
  7482. _this4._updateViewareaTimeout = null;
  7483. }, UPDATE_VIEWAREA_TIMEOUT);
  7484. }
  7485. }
  7486. }, {
  7487. key: "_popState",
  7488. value: function _popState(_ref5) {
  7489. var _this5 = this;
  7490. var state = _ref5.state;
  7491. var newHash = getCurrentHash(),
  7492. hashChanged = this._currentHash !== newHash;
  7493. this._currentHash = newHash;
  7494. if (!state) {
  7495. this._uid++;
  7496. var _this$_parseCurrentHa2 = this._parseCurrentHash(),
  7497. hash = _this$_parseCurrentHa2.hash,
  7498. page = _this$_parseCurrentHa2.page,
  7499. rotation = _this$_parseCurrentHa2.rotation;
  7500. this._pushOrReplaceState({
  7501. hash: hash,
  7502. page: page,
  7503. rotation: rotation
  7504. }, true);
  7505. return;
  7506. }
  7507. if (!this._isValidState(state)) {
  7508. return;
  7509. }
  7510. this._popStateInProgress = true;
  7511. if (hashChanged) {
  7512. this._blockHashChange++;
  7513. (0, _ui_utils.waitOnEventOrTimeout)({
  7514. target: window,
  7515. name: "hashchange",
  7516. delay: HASH_CHANGE_TIMEOUT
  7517. }).then(function () {
  7518. _this5._blockHashChange--;
  7519. });
  7520. }
  7521. var destination = state.destination;
  7522. this._updateInternalState(destination, state.uid, true);
  7523. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  7524. this.linkService.rotation = destination.rotation;
  7525. }
  7526. if (destination.dest) {
  7527. this.linkService.goToDestination(destination.dest);
  7528. } else if (destination.hash) {
  7529. this.linkService.setHash(destination.hash);
  7530. } else if (destination.page) {
  7531. this.linkService.page = destination.page;
  7532. }
  7533. Promise.resolve().then(function () {
  7534. _this5._popStateInProgress = false;
  7535. });
  7536. }
  7537. }, {
  7538. key: "_pageHide",
  7539. value: function _pageHide() {
  7540. if (!this._destination || this._destination.temporary) {
  7541. this._tryPushCurrentPosition();
  7542. }
  7543. }
  7544. }, {
  7545. key: "_bindEvents",
  7546. value: function _bindEvents() {
  7547. if (this._boundEvents) {
  7548. return;
  7549. }
  7550. this._boundEvents = {
  7551. updateViewarea: this._updateViewarea.bind(this),
  7552. popState: this._popState.bind(this),
  7553. pageHide: this._pageHide.bind(this)
  7554. };
  7555. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  7556. window.addEventListener("popstate", this._boundEvents.popState);
  7557. window.addEventListener("pagehide", this._boundEvents.pageHide);
  7558. }
  7559. }, {
  7560. key: "_unbindEvents",
  7561. value: function _unbindEvents() {
  7562. if (!this._boundEvents) {
  7563. return;
  7564. }
  7565. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  7566. window.removeEventListener("popstate", this._boundEvents.popState);
  7567. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  7568. this._boundEvents = null;
  7569. }
  7570. }, {
  7571. key: "popStateInProgress",
  7572. get: function get() {
  7573. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  7574. }
  7575. }, {
  7576. key: "initialBookmark",
  7577. get: function get() {
  7578. return this._initialized ? this._initialBookmark : null;
  7579. }
  7580. }, {
  7581. key: "initialRotation",
  7582. get: function get() {
  7583. return this._initialized ? this._initialRotation : null;
  7584. }
  7585. }]);
  7586. return PDFHistory;
  7587. }();
  7588. exports.PDFHistory = PDFHistory;
  7589. function isDestHashesEqual(destHash, pushHash) {
  7590. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  7591. return false;
  7592. }
  7593. if (destHash === pushHash) {
  7594. return true;
  7595. }
  7596. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  7597. nameddest = _parseQueryString.nameddest;
  7598. if (nameddest === pushHash) {
  7599. return true;
  7600. }
  7601. return false;
  7602. }
  7603. function isDestArraysEqual(firstDest, secondDest) {
  7604. function isEntryEqual(first, second) {
  7605. if (_typeof(first) !== _typeof(second)) {
  7606. return false;
  7607. }
  7608. if (Array.isArray(first) || Array.isArray(second)) {
  7609. return false;
  7610. }
  7611. if (first !== null && _typeof(first) === "object" && second !== null) {
  7612. if (Object.keys(first).length !== Object.keys(second).length) {
  7613. return false;
  7614. }
  7615. for (var key in first) {
  7616. if (!isEntryEqual(first[key], second[key])) {
  7617. return false;
  7618. }
  7619. }
  7620. return true;
  7621. }
  7622. return first === second || Number.isNaN(first) && Number.isNaN(second);
  7623. }
  7624. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  7625. return false;
  7626. }
  7627. if (firstDest.length !== secondDest.length) {
  7628. return false;
  7629. }
  7630. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  7631. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  7632. return false;
  7633. }
  7634. }
  7635. return true;
  7636. }
  7637. /***/ }),
  7638. /* 20 */
  7639. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7640. Object.defineProperty(exports, "__esModule", ({
  7641. value: true
  7642. }));
  7643. exports.PDFLayerViewer = void 0;
  7644. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  7645. var _base_tree_viewer = __webpack_require__(14);
  7646. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7647. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7648. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  7649. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  7650. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  7651. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  7652. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  7653. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7654. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7655. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7656. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  7657. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  7658. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  7659. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7660. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  7661. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7662. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7663. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  7664. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7665. var PDFLayerViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  7666. _inherits(PDFLayerViewer, _BaseTreeViewer);
  7667. var _super = _createSuper(PDFLayerViewer);
  7668. function PDFLayerViewer(options) {
  7669. var _this;
  7670. _classCallCheck(this, PDFLayerViewer);
  7671. _this = _super.call(this, options);
  7672. _this.l10n = options.l10n;
  7673. _this.eventBus._on("resetlayers", _this._resetLayers.bind(_assertThisInitialized(_this)));
  7674. _this.eventBus._on("togglelayerstree", _this._toggleAllTreeItems.bind(_assertThisInitialized(_this)));
  7675. return _this;
  7676. }
  7677. _createClass(PDFLayerViewer, [{
  7678. key: "reset",
  7679. value: function reset() {
  7680. _get(_getPrototypeOf(PDFLayerViewer.prototype), "reset", this).call(this);
  7681. this._optionalContentConfig = null;
  7682. }
  7683. }, {
  7684. key: "_dispatchEvent",
  7685. value: function _dispatchEvent(layersCount) {
  7686. this.eventBus.dispatch("layersloaded", {
  7687. source: this,
  7688. layersCount: layersCount
  7689. });
  7690. }
  7691. }, {
  7692. key: "_bindLink",
  7693. value: function _bindLink(element, _ref) {
  7694. var _this2 = this;
  7695. var groupId = _ref.groupId,
  7696. input = _ref.input;
  7697. var setVisibility = function setVisibility() {
  7698. _this2._optionalContentConfig.setVisibility(groupId, input.checked);
  7699. _this2.eventBus.dispatch("optionalcontentconfig", {
  7700. source: _this2,
  7701. promise: Promise.resolve(_this2._optionalContentConfig)
  7702. });
  7703. };
  7704. element.onclick = function (evt) {
  7705. if (evt.target === input) {
  7706. setVisibility();
  7707. return true;
  7708. } else if (evt.target !== element) {
  7709. return true;
  7710. }
  7711. input.checked = !input.checked;
  7712. setVisibility();
  7713. return false;
  7714. };
  7715. }
  7716. }, {
  7717. key: "_setNestedName",
  7718. value: function () {
  7719. var _setNestedName2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(element, _ref2) {
  7720. var _ref2$name, name;
  7721. return _regenerator["default"].wrap(function _callee$(_context) {
  7722. while (1) {
  7723. switch (_context.prev = _context.next) {
  7724. case 0:
  7725. _ref2$name = _ref2.name, name = _ref2$name === void 0 ? null : _ref2$name;
  7726. if (!(typeof name === "string")) {
  7727. _context.next = 4;
  7728. break;
  7729. }
  7730. element.textContent = this._normalizeTextContent(name);
  7731. return _context.abrupt("return");
  7732. case 4:
  7733. _context.next = 6;
  7734. return this.l10n.get("additional_layers", null, "Additional Layers");
  7735. case 6:
  7736. element.textContent = _context.sent;
  7737. element.style.fontStyle = "italic";
  7738. case 8:
  7739. case "end":
  7740. return _context.stop();
  7741. }
  7742. }
  7743. }, _callee, this);
  7744. }));
  7745. function _setNestedName(_x, _x2) {
  7746. return _setNestedName2.apply(this, arguments);
  7747. }
  7748. return _setNestedName;
  7749. }()
  7750. }, {
  7751. key: "_addToggleButton",
  7752. value: function _addToggleButton(div, _ref3) {
  7753. var _ref3$name = _ref3.name,
  7754. name = _ref3$name === void 0 ? null : _ref3$name;
  7755. _get(_getPrototypeOf(PDFLayerViewer.prototype), "_addToggleButton", this).call(this, div, name === null);
  7756. }
  7757. }, {
  7758. key: "_toggleAllTreeItems",
  7759. value: function _toggleAllTreeItems() {
  7760. if (!this._optionalContentConfig) {
  7761. return;
  7762. }
  7763. _get(_getPrototypeOf(PDFLayerViewer.prototype), "_toggleAllTreeItems", this).call(this);
  7764. }
  7765. }, {
  7766. key: "render",
  7767. value: function render(_ref4) {
  7768. var optionalContentConfig = _ref4.optionalContentConfig,
  7769. pdfDocument = _ref4.pdfDocument;
  7770. if (this._optionalContentConfig) {
  7771. this.reset();
  7772. }
  7773. this._optionalContentConfig = optionalContentConfig || null;
  7774. this._pdfDocument = pdfDocument || null;
  7775. var groups = optionalContentConfig && optionalContentConfig.getOrder();
  7776. if (!groups) {
  7777. this._dispatchEvent(0);
  7778. return;
  7779. }
  7780. var fragment = document.createDocumentFragment(),
  7781. queue = [{
  7782. parent: fragment,
  7783. groups: groups
  7784. }];
  7785. var layersCount = 0,
  7786. hasAnyNesting = false;
  7787. while (queue.length > 0) {
  7788. var levelData = queue.shift();
  7789. var _iterator = _createForOfIteratorHelper(levelData.groups),
  7790. _step;
  7791. try {
  7792. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7793. var groupId = _step.value;
  7794. var div = document.createElement("div");
  7795. div.className = "treeItem";
  7796. var element = document.createElement("a");
  7797. div.appendChild(element);
  7798. if (_typeof(groupId) === "object") {
  7799. hasAnyNesting = true;
  7800. this._addToggleButton(div, groupId);
  7801. this._setNestedName(element, groupId);
  7802. var itemsDiv = document.createElement("div");
  7803. itemsDiv.className = "treeItems";
  7804. div.appendChild(itemsDiv);
  7805. queue.push({
  7806. parent: itemsDiv,
  7807. groups: groupId.order
  7808. });
  7809. } else {
  7810. var group = optionalContentConfig.getGroup(groupId);
  7811. var input = document.createElement("input");
  7812. this._bindLink(element, {
  7813. groupId: groupId,
  7814. input: input
  7815. });
  7816. input.type = "checkbox";
  7817. input.id = groupId;
  7818. input.checked = group.visible;
  7819. var label = document.createElement("label");
  7820. label.setAttribute("for", groupId);
  7821. label.textContent = this._normalizeTextContent(group.name);
  7822. element.appendChild(input);
  7823. element.appendChild(label);
  7824. layersCount++;
  7825. }
  7826. levelData.parent.appendChild(div);
  7827. }
  7828. } catch (err) {
  7829. _iterator.e(err);
  7830. } finally {
  7831. _iterator.f();
  7832. }
  7833. }
  7834. this._finishRendering(fragment, layersCount, hasAnyNesting);
  7835. }
  7836. }, {
  7837. key: "_resetLayers",
  7838. value: function () {
  7839. var _resetLayers2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  7840. var optionalContentConfig;
  7841. return _regenerator["default"].wrap(function _callee2$(_context2) {
  7842. while (1) {
  7843. switch (_context2.prev = _context2.next) {
  7844. case 0:
  7845. if (this._optionalContentConfig) {
  7846. _context2.next = 2;
  7847. break;
  7848. }
  7849. return _context2.abrupt("return");
  7850. case 2:
  7851. _context2.next = 4;
  7852. return this._pdfDocument.getOptionalContentConfig();
  7853. case 4:
  7854. optionalContentConfig = _context2.sent;
  7855. this.eventBus.dispatch("optionalcontentconfig", {
  7856. source: this,
  7857. promise: Promise.resolve(optionalContentConfig)
  7858. });
  7859. this.render({
  7860. optionalContentConfig: optionalContentConfig,
  7861. pdfDocument: this._pdfDocument
  7862. });
  7863. case 7:
  7864. case "end":
  7865. return _context2.stop();
  7866. }
  7867. }
  7868. }, _callee2, this);
  7869. }));
  7870. function _resetLayers() {
  7871. return _resetLayers2.apply(this, arguments);
  7872. }
  7873. return _resetLayers;
  7874. }()
  7875. }]);
  7876. return PDFLayerViewer;
  7877. }(_base_tree_viewer.BaseTreeViewer);
  7878. exports.PDFLayerViewer = PDFLayerViewer;
  7879. /***/ }),
  7880. /* 21 */
  7881. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7882. Object.defineProperty(exports, "__esModule", ({
  7883. value: true
  7884. }));
  7885. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  7886. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  7887. var _ui_utils = __webpack_require__(6);
  7888. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7889. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7890. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  7891. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  7892. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7893. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7894. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7895. var PDFLinkService = /*#__PURE__*/function () {
  7896. function PDFLinkService() {
  7897. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  7898. eventBus = _ref.eventBus,
  7899. _ref$externalLinkTarg = _ref.externalLinkTarget,
  7900. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  7901. _ref$externalLinkRel = _ref.externalLinkRel,
  7902. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel,
  7903. _ref$externalLinkEnab = _ref.externalLinkEnabled,
  7904. externalLinkEnabled = _ref$externalLinkEnab === void 0 ? true : _ref$externalLinkEnab,
  7905. _ref$ignoreDestinatio = _ref.ignoreDestinationZoom,
  7906. ignoreDestinationZoom = _ref$ignoreDestinatio === void 0 ? false : _ref$ignoreDestinatio;
  7907. _classCallCheck(this, PDFLinkService);
  7908. this.eventBus = eventBus;
  7909. this.externalLinkTarget = externalLinkTarget;
  7910. this.externalLinkRel = externalLinkRel;
  7911. this.externalLinkEnabled = externalLinkEnabled;
  7912. this._ignoreDestinationZoom = ignoreDestinationZoom;
  7913. this.baseUrl = null;
  7914. this.pdfDocument = null;
  7915. this.pdfViewer = null;
  7916. this.pdfHistory = null;
  7917. this._pagesRefCache = null;
  7918. }
  7919. _createClass(PDFLinkService, [{
  7920. key: "setDocument",
  7921. value: function setDocument(pdfDocument) {
  7922. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  7923. this.baseUrl = baseUrl;
  7924. this.pdfDocument = pdfDocument;
  7925. this._pagesRefCache = Object.create(null);
  7926. }
  7927. }, {
  7928. key: "setViewer",
  7929. value: function setViewer(pdfViewer) {
  7930. this.pdfViewer = pdfViewer;
  7931. }
  7932. }, {
  7933. key: "setHistory",
  7934. value: function setHistory(pdfHistory) {
  7935. this.pdfHistory = pdfHistory;
  7936. }
  7937. }, {
  7938. key: "navigateTo",
  7939. value: function navigateTo(dest) {
  7940. console.error("Deprecated method: `navigateTo`, use `goToDestination` instead.");
  7941. this.goToDestination(dest);
  7942. }
  7943. }, {
  7944. key: "_goToDestinationHelper",
  7945. value: function _goToDestinationHelper(rawDest) {
  7946. var _this = this;
  7947. var namedDest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  7948. var explicitDest = arguments.length > 2 ? arguments[2] : undefined;
  7949. var destRef = explicitDest[0];
  7950. var pageNumber;
  7951. if (destRef instanceof Object) {
  7952. pageNumber = this._cachedPageNumber(destRef);
  7953. if (pageNumber === null) {
  7954. this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  7955. _this.cachePageRef(pageIndex + 1, destRef);
  7956. _this._goToDestinationHelper(rawDest, namedDest, explicitDest);
  7957. })["catch"](function () {
  7958. console.error("PDFLinkService._goToDestinationHelper: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(rawDest, "\"."));
  7959. });
  7960. return;
  7961. }
  7962. } else if (Number.isInteger(destRef)) {
  7963. pageNumber = destRef + 1;
  7964. } else {
  7965. console.error("PDFLinkService._goToDestinationHelper: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(rawDest, "\"."));
  7966. return;
  7967. }
  7968. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  7969. console.error("PDFLinkService._goToDestinationHelper: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(rawDest, "\"."));
  7970. return;
  7971. }
  7972. if (this.pdfHistory) {
  7973. this.pdfHistory.pushCurrentPosition();
  7974. this.pdfHistory.push({
  7975. namedDest: namedDest,
  7976. explicitDest: explicitDest,
  7977. pageNumber: pageNumber
  7978. });
  7979. }
  7980. this.pdfViewer.scrollPageIntoView({
  7981. pageNumber: pageNumber,
  7982. destArray: explicitDest,
  7983. ignoreDestinationZoom: this._ignoreDestinationZoom
  7984. });
  7985. }
  7986. }, {
  7987. key: "goToDestination",
  7988. value: function () {
  7989. var _goToDestination = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(dest) {
  7990. var namedDest, explicitDest;
  7991. return _regenerator["default"].wrap(function _callee$(_context) {
  7992. while (1) {
  7993. switch (_context.prev = _context.next) {
  7994. case 0:
  7995. if (this.pdfDocument) {
  7996. _context.next = 2;
  7997. break;
  7998. }
  7999. return _context.abrupt("return");
  8000. case 2:
  8001. if (!(typeof dest === "string")) {
  8002. _context.next = 9;
  8003. break;
  8004. }
  8005. namedDest = dest;
  8006. _context.next = 6;
  8007. return this.pdfDocument.getDestination(dest);
  8008. case 6:
  8009. explicitDest = _context.sent;
  8010. _context.next = 13;
  8011. break;
  8012. case 9:
  8013. namedDest = null;
  8014. _context.next = 12;
  8015. return dest;
  8016. case 12:
  8017. explicitDest = _context.sent;
  8018. case 13:
  8019. if (Array.isArray(explicitDest)) {
  8020. _context.next = 16;
  8021. break;
  8022. }
  8023. console.error("PDFLinkService.goToDestination: \"".concat(explicitDest, "\" is not ") + "a valid destination array, for dest=\"".concat(dest, "\"."));
  8024. return _context.abrupt("return");
  8025. case 16:
  8026. this._goToDestinationHelper(dest, namedDest, explicitDest);
  8027. case 17:
  8028. case "end":
  8029. return _context.stop();
  8030. }
  8031. }
  8032. }, _callee, this);
  8033. }));
  8034. function goToDestination(_x) {
  8035. return _goToDestination.apply(this, arguments);
  8036. }
  8037. return goToDestination;
  8038. }()
  8039. }, {
  8040. key: "goToPage",
  8041. value: function goToPage(val) {
  8042. if (!this.pdfDocument) {
  8043. return;
  8044. }
  8045. var pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
  8046. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  8047. console.error("PDFLinkService.goToPage: \"".concat(val, "\" is not a valid page."));
  8048. return;
  8049. }
  8050. if (this.pdfHistory) {
  8051. this.pdfHistory.pushCurrentPosition();
  8052. this.pdfHistory.pushPage(pageNumber);
  8053. }
  8054. this.pdfViewer.scrollPageIntoView({
  8055. pageNumber: pageNumber
  8056. });
  8057. }
  8058. }, {
  8059. key: "getDestinationHash",
  8060. value: function getDestinationHash(dest) {
  8061. if (typeof dest === "string") {
  8062. if (dest.length > 0) {
  8063. return this.getAnchorUrl("#" + escape(dest));
  8064. }
  8065. } else if (Array.isArray(dest)) {
  8066. var str = JSON.stringify(dest);
  8067. if (str.length > 0) {
  8068. return this.getAnchorUrl("#" + escape(str));
  8069. }
  8070. }
  8071. return this.getAnchorUrl("");
  8072. }
  8073. }, {
  8074. key: "getAnchorUrl",
  8075. value: function getAnchorUrl(anchor) {
  8076. return (this.baseUrl || "") + anchor;
  8077. }
  8078. }, {
  8079. key: "setHash",
  8080. value: function setHash(hash) {
  8081. if (!this.pdfDocument) {
  8082. return;
  8083. }
  8084. var pageNumber, dest;
  8085. if (hash.includes("=")) {
  8086. var params = (0, _ui_utils.parseQueryString)(hash);
  8087. if ("search" in params) {
  8088. this.eventBus.dispatch("findfromurlhash", {
  8089. source: this,
  8090. query: params.search.replace(/"/g, ""),
  8091. phraseSearch: params.phrase === "true"
  8092. });
  8093. }
  8094. if ("page" in params) {
  8095. pageNumber = params.page | 0 || 1;
  8096. }
  8097. if ("zoom" in params) {
  8098. var zoomArgs = params.zoom.split(",");
  8099. var zoomArg = zoomArgs[0];
  8100. var zoomArgNumber = parseFloat(zoomArg);
  8101. if (!zoomArg.includes("Fit")) {
  8102. dest = [null, {
  8103. name: "XYZ"
  8104. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  8105. } else {
  8106. if (zoomArg === "Fit" || zoomArg === "FitB") {
  8107. dest = [null, {
  8108. name: zoomArg
  8109. }];
  8110. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  8111. dest = [null, {
  8112. name: zoomArg
  8113. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  8114. } else if (zoomArg === "FitR") {
  8115. if (zoomArgs.length !== 5) {
  8116. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  8117. } else {
  8118. dest = [null, {
  8119. name: zoomArg
  8120. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  8121. }
  8122. } else {
  8123. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + "a valid zoom value.");
  8124. }
  8125. }
  8126. }
  8127. if (dest) {
  8128. this.pdfViewer.scrollPageIntoView({
  8129. pageNumber: pageNumber || this.page,
  8130. destArray: dest,
  8131. allowNegativeOffset: true
  8132. });
  8133. } else if (pageNumber) {
  8134. this.page = pageNumber;
  8135. }
  8136. if ("pagemode" in params) {
  8137. this.eventBus.dispatch("pagemode", {
  8138. source: this,
  8139. mode: params.pagemode
  8140. });
  8141. }
  8142. if ("nameddest" in params) {
  8143. this.goToDestination(params.nameddest);
  8144. }
  8145. } else {
  8146. dest = unescape(hash);
  8147. try {
  8148. dest = JSON.parse(dest);
  8149. if (!Array.isArray(dest)) {
  8150. dest = dest.toString();
  8151. }
  8152. } catch (ex) {}
  8153. if (typeof dest === "string" || isValidExplicitDestination(dest)) {
  8154. this.goToDestination(dest);
  8155. return;
  8156. }
  8157. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + "a valid destination.");
  8158. }
  8159. }
  8160. }, {
  8161. key: "executeNamedAction",
  8162. value: function executeNamedAction(action) {
  8163. switch (action) {
  8164. case "GoBack":
  8165. if (this.pdfHistory) {
  8166. this.pdfHistory.back();
  8167. }
  8168. break;
  8169. case "GoForward":
  8170. if (this.pdfHistory) {
  8171. this.pdfHistory.forward();
  8172. }
  8173. break;
  8174. case "NextPage":
  8175. this.pdfViewer.nextPage();
  8176. break;
  8177. case "PrevPage":
  8178. this.pdfViewer.previousPage();
  8179. break;
  8180. case "LastPage":
  8181. this.page = this.pagesCount;
  8182. break;
  8183. case "FirstPage":
  8184. this.page = 1;
  8185. break;
  8186. default:
  8187. break;
  8188. }
  8189. this.eventBus.dispatch("namedaction", {
  8190. source: this,
  8191. action: action
  8192. });
  8193. }
  8194. }, {
  8195. key: "cachePageRef",
  8196. value: function cachePageRef(pageNum, pageRef) {
  8197. if (!pageRef) {
  8198. return;
  8199. }
  8200. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  8201. this._pagesRefCache[refStr] = pageNum;
  8202. }
  8203. }, {
  8204. key: "_cachedPageNumber",
  8205. value: function _cachedPageNumber(pageRef) {
  8206. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  8207. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  8208. }
  8209. }, {
  8210. key: "isPageVisible",
  8211. value: function isPageVisible(pageNumber) {
  8212. return this.pdfViewer.isPageVisible(pageNumber);
  8213. }
  8214. }, {
  8215. key: "isPageCached",
  8216. value: function isPageCached(pageNumber) {
  8217. return this.pdfViewer.isPageCached(pageNumber);
  8218. }
  8219. }, {
  8220. key: "pagesCount",
  8221. get: function get() {
  8222. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  8223. }
  8224. }, {
  8225. key: "page",
  8226. get: function get() {
  8227. return this.pdfViewer.currentPageNumber;
  8228. },
  8229. set: function set(value) {
  8230. this.pdfViewer.currentPageNumber = value;
  8231. }
  8232. }, {
  8233. key: "rotation",
  8234. get: function get() {
  8235. return this.pdfViewer.pagesRotation;
  8236. },
  8237. set: function set(value) {
  8238. this.pdfViewer.pagesRotation = value;
  8239. }
  8240. }]);
  8241. return PDFLinkService;
  8242. }();
  8243. exports.PDFLinkService = PDFLinkService;
  8244. function isValidExplicitDestination(dest) {
  8245. if (!Array.isArray(dest)) {
  8246. return false;
  8247. }
  8248. var destLength = dest.length;
  8249. if (destLength < 2) {
  8250. return false;
  8251. }
  8252. var page = dest[0];
  8253. if (!(_typeof(page) === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  8254. return false;
  8255. }
  8256. var zoom = dest[1];
  8257. if (!(_typeof(zoom) === "object" && typeof zoom.name === "string")) {
  8258. return false;
  8259. }
  8260. var allowNull = true;
  8261. switch (zoom.name) {
  8262. case "XYZ":
  8263. if (destLength !== 5) {
  8264. return false;
  8265. }
  8266. break;
  8267. case "Fit":
  8268. case "FitB":
  8269. return destLength === 2;
  8270. case "FitH":
  8271. case "FitBH":
  8272. case "FitV":
  8273. case "FitBV":
  8274. if (destLength !== 3) {
  8275. return false;
  8276. }
  8277. break;
  8278. case "FitR":
  8279. if (destLength !== 6) {
  8280. return false;
  8281. }
  8282. allowNull = false;
  8283. break;
  8284. default:
  8285. return false;
  8286. }
  8287. for (var i = 2; i < destLength; i++) {
  8288. var param = dest[i];
  8289. if (!(typeof param === "number" || allowNull && param === null)) {
  8290. return false;
  8291. }
  8292. }
  8293. return true;
  8294. }
  8295. var SimpleLinkService = /*#__PURE__*/function () {
  8296. function SimpleLinkService() {
  8297. _classCallCheck(this, SimpleLinkService);
  8298. this.externalLinkTarget = null;
  8299. this.externalLinkRel = null;
  8300. this.externalLinkEnabled = true;
  8301. this._ignoreDestinationZoom = false;
  8302. }
  8303. _createClass(SimpleLinkService, [{
  8304. key: "goToDestination",
  8305. value: function () {
  8306. var _goToDestination2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(dest) {
  8307. return _regenerator["default"].wrap(function _callee2$(_context2) {
  8308. while (1) {
  8309. switch (_context2.prev = _context2.next) {
  8310. case 0:
  8311. case "end":
  8312. return _context2.stop();
  8313. }
  8314. }
  8315. }, _callee2);
  8316. }));
  8317. function goToDestination(_x2) {
  8318. return _goToDestination2.apply(this, arguments);
  8319. }
  8320. return goToDestination;
  8321. }()
  8322. }, {
  8323. key: "goToPage",
  8324. value: function goToPage(val) {}
  8325. }, {
  8326. key: "getDestinationHash",
  8327. value: function getDestinationHash(dest) {
  8328. return "#";
  8329. }
  8330. }, {
  8331. key: "getAnchorUrl",
  8332. value: function getAnchorUrl(hash) {
  8333. return "#";
  8334. }
  8335. }, {
  8336. key: "setHash",
  8337. value: function setHash(hash) {}
  8338. }, {
  8339. key: "executeNamedAction",
  8340. value: function executeNamedAction(action) {}
  8341. }, {
  8342. key: "cachePageRef",
  8343. value: function cachePageRef(pageNum, pageRef) {}
  8344. }, {
  8345. key: "isPageVisible",
  8346. value: function isPageVisible(pageNumber) {
  8347. return true;
  8348. }
  8349. }, {
  8350. key: "isPageCached",
  8351. value: function isPageCached(pageNumber) {
  8352. return true;
  8353. }
  8354. }, {
  8355. key: "pagesCount",
  8356. get: function get() {
  8357. return 0;
  8358. }
  8359. }, {
  8360. key: "page",
  8361. get: function get() {
  8362. return 0;
  8363. },
  8364. set: function set(value) {}
  8365. }, {
  8366. key: "rotation",
  8367. get: function get() {
  8368. return 0;
  8369. },
  8370. set: function set(value) {}
  8371. }]);
  8372. return SimpleLinkService;
  8373. }();
  8374. exports.SimpleLinkService = SimpleLinkService;
  8375. /***/ }),
  8376. /* 22 */
  8377. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8378. Object.defineProperty(exports, "__esModule", ({
  8379. value: true
  8380. }));
  8381. exports.PDFOutlineViewer = void 0;
  8382. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  8383. var _pdfjsLib = __webpack_require__(7);
  8384. var _base_tree_viewer = __webpack_require__(14);
  8385. var _ui_utils = __webpack_require__(6);
  8386. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8387. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8388. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  8389. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  8390. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  8391. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  8392. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  8393. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  8394. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  8395. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  8396. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  8397. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  8398. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
  8399. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  8400. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  8401. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8402. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8403. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8404. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  8405. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  8406. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8407. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8408. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8409. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8410. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8411. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  8412. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8413. var PDFOutlineViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  8414. _inherits(PDFOutlineViewer, _BaseTreeViewer);
  8415. var _super = _createSuper(PDFOutlineViewer);
  8416. function PDFOutlineViewer(options) {
  8417. var _this;
  8418. _classCallCheck(this, PDFOutlineViewer);
  8419. _this = _super.call(this, options);
  8420. _this.linkService = options.linkService;
  8421. _this.eventBus._on("toggleoutlinetree", _this._toggleAllTreeItems.bind(_assertThisInitialized(_this)));
  8422. _this.eventBus._on("currentoutlineitem", _this._currentOutlineItem.bind(_assertThisInitialized(_this)));
  8423. _this.eventBus._on("pagechanging", function (evt) {
  8424. _this._currentPageNumber = evt.pageNumber;
  8425. });
  8426. _this.eventBus._on("pagesloaded", function (evt) {
  8427. _this._isPagesLoaded = !!evt.pagesCount;
  8428. });
  8429. _this.eventBus._on("sidebarviewchanged", function (evt) {
  8430. _this._sidebarView = evt.view;
  8431. });
  8432. return _this;
  8433. }
  8434. _createClass(PDFOutlineViewer, [{
  8435. key: "reset",
  8436. value: function reset() {
  8437. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "reset", this).call(this);
  8438. this._outline = null;
  8439. this._pageNumberToDestHashCapability = null;
  8440. this._currentPageNumber = 1;
  8441. this._isPagesLoaded = false;
  8442. }
  8443. }, {
  8444. key: "_dispatchEvent",
  8445. value: function _dispatchEvent(outlineCount) {
  8446. var _this$_pdfDocument;
  8447. this.eventBus.dispatch("outlineloaded", {
  8448. source: this,
  8449. outlineCount: outlineCount,
  8450. enableCurrentOutlineItemButton: outlineCount > 0 && !((_this$_pdfDocument = this._pdfDocument) !== null && _this$_pdfDocument !== void 0 && _this$_pdfDocument.loadingParams.disableAutoFetch)
  8451. });
  8452. }
  8453. }, {
  8454. key: "_bindLink",
  8455. value: function _bindLink(element, _ref) {
  8456. var _this2 = this;
  8457. var url = _ref.url,
  8458. newWindow = _ref.newWindow,
  8459. dest = _ref.dest;
  8460. var linkService = this.linkService;
  8461. if (url) {
  8462. (0, _pdfjsLib.addLinkAttributes)(element, {
  8463. url: url,
  8464. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
  8465. rel: linkService.externalLinkRel,
  8466. enabled: linkService.externalLinkEnabled
  8467. });
  8468. return;
  8469. }
  8470. element.href = linkService.getDestinationHash(dest);
  8471. element.onclick = function (evt) {
  8472. _this2._updateCurrentTreeItem(evt.target.parentNode);
  8473. if (dest) {
  8474. linkService.goToDestination(dest);
  8475. }
  8476. return false;
  8477. };
  8478. }
  8479. }, {
  8480. key: "_setStyles",
  8481. value: function _setStyles(element, _ref2) {
  8482. var bold = _ref2.bold,
  8483. italic = _ref2.italic;
  8484. if (bold) {
  8485. element.style.fontWeight = "bold";
  8486. }
  8487. if (italic) {
  8488. element.style.fontStyle = "italic";
  8489. }
  8490. }
  8491. }, {
  8492. key: "_addToggleButton",
  8493. value: function _addToggleButton(div, _ref3) {
  8494. var count = _ref3.count,
  8495. items = _ref3.items;
  8496. var hidden = false;
  8497. if (count < 0) {
  8498. var totalCount = items.length;
  8499. if (totalCount > 0) {
  8500. var queue = _toConsumableArray(items);
  8501. while (queue.length > 0) {
  8502. var _queue$shift = queue.shift(),
  8503. nestedCount = _queue$shift.count,
  8504. nestedItems = _queue$shift.items;
  8505. if (nestedCount > 0 && nestedItems.length > 0) {
  8506. totalCount += nestedItems.length;
  8507. queue.push.apply(queue, _toConsumableArray(nestedItems));
  8508. }
  8509. }
  8510. }
  8511. if (Math.abs(count) === totalCount) {
  8512. hidden = true;
  8513. }
  8514. }
  8515. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "_addToggleButton", this).call(this, div, hidden);
  8516. }
  8517. }, {
  8518. key: "_toggleAllTreeItems",
  8519. value: function _toggleAllTreeItems() {
  8520. if (!this._outline) {
  8521. return;
  8522. }
  8523. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "_toggleAllTreeItems", this).call(this);
  8524. }
  8525. }, {
  8526. key: "render",
  8527. value: function render(_ref4) {
  8528. var outline = _ref4.outline,
  8529. pdfDocument = _ref4.pdfDocument;
  8530. if (this._outline) {
  8531. this.reset();
  8532. }
  8533. this._outline = outline || null;
  8534. this._pdfDocument = pdfDocument || null;
  8535. if (!outline) {
  8536. this._dispatchEvent(0);
  8537. return;
  8538. }
  8539. var fragment = document.createDocumentFragment();
  8540. var queue = [{
  8541. parent: fragment,
  8542. items: outline
  8543. }];
  8544. var outlineCount = 0,
  8545. hasAnyNesting = false;
  8546. while (queue.length > 0) {
  8547. var levelData = queue.shift();
  8548. var _iterator = _createForOfIteratorHelper(levelData.items),
  8549. _step;
  8550. try {
  8551. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8552. var item = _step.value;
  8553. var div = document.createElement("div");
  8554. div.className = "treeItem";
  8555. var element = document.createElement("a");
  8556. this._bindLink(element, item);
  8557. this._setStyles(element, item);
  8558. element.textContent = this._normalizeTextContent(item.title);
  8559. div.appendChild(element);
  8560. if (item.items.length > 0) {
  8561. hasAnyNesting = true;
  8562. this._addToggleButton(div, item);
  8563. var itemsDiv = document.createElement("div");
  8564. itemsDiv.className = "treeItems";
  8565. div.appendChild(itemsDiv);
  8566. queue.push({
  8567. parent: itemsDiv,
  8568. items: item.items
  8569. });
  8570. }
  8571. levelData.parent.appendChild(div);
  8572. outlineCount++;
  8573. }
  8574. } catch (err) {
  8575. _iterator.e(err);
  8576. } finally {
  8577. _iterator.f();
  8578. }
  8579. }
  8580. this._finishRendering(fragment, outlineCount, hasAnyNesting);
  8581. }
  8582. }, {
  8583. key: "_currentOutlineItem",
  8584. value: function () {
  8585. var _currentOutlineItem2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  8586. var pageNumberToDestHash, i, destHash, linkElement;
  8587. return _regenerator["default"].wrap(function _callee$(_context) {
  8588. while (1) {
  8589. switch (_context.prev = _context.next) {
  8590. case 0:
  8591. if (this._isPagesLoaded) {
  8592. _context.next = 2;
  8593. break;
  8594. }
  8595. throw new Error("_currentOutlineItem: All pages have not been loaded.");
  8596. case 2:
  8597. if (!(!this._outline || !this._pdfDocument)) {
  8598. _context.next = 4;
  8599. break;
  8600. }
  8601. return _context.abrupt("return");
  8602. case 4:
  8603. _context.next = 6;
  8604. return this._getPageNumberToDestHash(this._pdfDocument);
  8605. case 6:
  8606. pageNumberToDestHash = _context.sent;
  8607. if (pageNumberToDestHash) {
  8608. _context.next = 9;
  8609. break;
  8610. }
  8611. return _context.abrupt("return");
  8612. case 9:
  8613. this._updateCurrentTreeItem(null);
  8614. if (!(this._sidebarView !== _ui_utils.SidebarView.OUTLINE)) {
  8615. _context.next = 12;
  8616. break;
  8617. }
  8618. return _context.abrupt("return");
  8619. case 12:
  8620. i = this._currentPageNumber;
  8621. case 13:
  8622. if (!(i > 0)) {
  8623. _context.next = 25;
  8624. break;
  8625. }
  8626. destHash = pageNumberToDestHash.get(i);
  8627. if (destHash) {
  8628. _context.next = 17;
  8629. break;
  8630. }
  8631. return _context.abrupt("continue", 22);
  8632. case 17:
  8633. linkElement = this.container.querySelector("a[href=\"".concat(destHash, "\"]"));
  8634. if (linkElement) {
  8635. _context.next = 20;
  8636. break;
  8637. }
  8638. return _context.abrupt("continue", 22);
  8639. case 20:
  8640. this._scrollToCurrentTreeItem(linkElement.parentNode);
  8641. return _context.abrupt("break", 25);
  8642. case 22:
  8643. i--;
  8644. _context.next = 13;
  8645. break;
  8646. case 25:
  8647. case "end":
  8648. return _context.stop();
  8649. }
  8650. }
  8651. }, _callee, this);
  8652. }));
  8653. function _currentOutlineItem() {
  8654. return _currentOutlineItem2.apply(this, arguments);
  8655. }
  8656. return _currentOutlineItem;
  8657. }()
  8658. }, {
  8659. key: "_getPageNumberToDestHash",
  8660. value: function () {
  8661. var _getPageNumberToDestHash2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pdfDocument) {
  8662. var pageNumberToDestHash, pageNumberNesting, queue, levelData, currentNesting, _iterator2, _step2, _step2$value, dest, items, explicitDest, pageNumber, _explicitDest, _explicitDest2, destRef, destHash;
  8663. return _regenerator["default"].wrap(function _callee2$(_context2) {
  8664. while (1) {
  8665. switch (_context2.prev = _context2.next) {
  8666. case 0:
  8667. if (!this._pageNumberToDestHashCapability) {
  8668. _context2.next = 2;
  8669. break;
  8670. }
  8671. return _context2.abrupt("return", this._pageNumberToDestHashCapability.promise);
  8672. case 2:
  8673. this._pageNumberToDestHashCapability = (0, _pdfjsLib.createPromiseCapability)();
  8674. pageNumberToDestHash = new Map(), pageNumberNesting = new Map();
  8675. queue = [{
  8676. nesting: 0,
  8677. items: this._outline
  8678. }];
  8679. case 5:
  8680. if (!(queue.length > 0)) {
  8681. _context2.next = 56;
  8682. break;
  8683. }
  8684. levelData = queue.shift(), currentNesting = levelData.nesting;
  8685. _iterator2 = _createForOfIteratorHelper(levelData.items);
  8686. _context2.prev = 8;
  8687. _iterator2.s();
  8688. case 10:
  8689. if ((_step2 = _iterator2.n()).done) {
  8690. _context2.next = 46;
  8691. break;
  8692. }
  8693. _step2$value = _step2.value, dest = _step2$value.dest, items = _step2$value.items;
  8694. explicitDest = void 0, pageNumber = void 0;
  8695. if (!(typeof dest === "string")) {
  8696. _context2.next = 21;
  8697. break;
  8698. }
  8699. _context2.next = 16;
  8700. return pdfDocument.getDestination(dest);
  8701. case 16:
  8702. explicitDest = _context2.sent;
  8703. if (!(pdfDocument !== this._pdfDocument)) {
  8704. _context2.next = 19;
  8705. break;
  8706. }
  8707. return _context2.abrupt("return", null);
  8708. case 19:
  8709. _context2.next = 22;
  8710. break;
  8711. case 21:
  8712. explicitDest = dest;
  8713. case 22:
  8714. if (!Array.isArray(explicitDest)) {
  8715. _context2.next = 43;
  8716. break;
  8717. }
  8718. _explicitDest = explicitDest, _explicitDest2 = _slicedToArray(_explicitDest, 1), destRef = _explicitDest2[0];
  8719. if (!(_typeof(destRef) === "object")) {
  8720. _context2.next = 41;
  8721. break;
  8722. }
  8723. pageNumber = this.linkService._cachedPageNumber(destRef);
  8724. if (pageNumber) {
  8725. _context2.next = 39;
  8726. break;
  8727. }
  8728. _context2.prev = 27;
  8729. _context2.next = 30;
  8730. return pdfDocument.getPageIndex(destRef);
  8731. case 30:
  8732. _context2.t0 = _context2.sent;
  8733. pageNumber = _context2.t0 + 1;
  8734. if (!(pdfDocument !== this._pdfDocument)) {
  8735. _context2.next = 34;
  8736. break;
  8737. }
  8738. return _context2.abrupt("return", null);
  8739. case 34:
  8740. this.linkService.cachePageRef(pageNumber, destRef);
  8741. _context2.next = 39;
  8742. break;
  8743. case 37:
  8744. _context2.prev = 37;
  8745. _context2.t1 = _context2["catch"](27);
  8746. case 39:
  8747. _context2.next = 42;
  8748. break;
  8749. case 41:
  8750. if (Number.isInteger(destRef)) {
  8751. pageNumber = destRef + 1;
  8752. }
  8753. case 42:
  8754. if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) {
  8755. destHash = this.linkService.getDestinationHash(dest);
  8756. pageNumberToDestHash.set(pageNumber, destHash);
  8757. pageNumberNesting.set(pageNumber, currentNesting);
  8758. }
  8759. case 43:
  8760. if (items.length > 0) {
  8761. queue.push({
  8762. nesting: currentNesting + 1,
  8763. items: items
  8764. });
  8765. }
  8766. case 44:
  8767. _context2.next = 10;
  8768. break;
  8769. case 46:
  8770. _context2.next = 51;
  8771. break;
  8772. case 48:
  8773. _context2.prev = 48;
  8774. _context2.t2 = _context2["catch"](8);
  8775. _iterator2.e(_context2.t2);
  8776. case 51:
  8777. _context2.prev = 51;
  8778. _iterator2.f();
  8779. return _context2.finish(51);
  8780. case 54:
  8781. _context2.next = 5;
  8782. break;
  8783. case 56:
  8784. this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null);
  8785. return _context2.abrupt("return", this._pageNumberToDestHashCapability.promise);
  8786. case 58:
  8787. case "end":
  8788. return _context2.stop();
  8789. }
  8790. }
  8791. }, _callee2, this, [[8, 48, 51, 54], [27, 37]]);
  8792. }));
  8793. function _getPageNumberToDestHash(_x) {
  8794. return _getPageNumberToDestHash2.apply(this, arguments);
  8795. }
  8796. return _getPageNumberToDestHash;
  8797. }()
  8798. }]);
  8799. return PDFOutlineViewer;
  8800. }(_base_tree_viewer.BaseTreeViewer);
  8801. exports.PDFOutlineViewer = PDFOutlineViewer;
  8802. /***/ }),
  8803. /* 23 */
  8804. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8805. Object.defineProperty(exports, "__esModule", ({
  8806. value: true
  8807. }));
  8808. exports.PDFPresentationMode = void 0;
  8809. var _ui_utils = __webpack_require__(6);
  8810. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8811. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8812. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8813. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  8814. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  8815. var ACTIVE_SELECTOR = "pdfPresentationMode";
  8816. var CONTROLS_SELECTOR = "pdfPresentationModeControls";
  8817. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  8818. var PAGE_SWITCH_THRESHOLD = 0.1;
  8819. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  8820. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  8821. var PDFPresentationMode = /*#__PURE__*/function () {
  8822. function PDFPresentationMode(_ref) {
  8823. var _this = this;
  8824. var container = _ref.container,
  8825. pdfViewer = _ref.pdfViewer,
  8826. eventBus = _ref.eventBus,
  8827. _ref$contextMenuItems = _ref.contextMenuItems,
  8828. contextMenuItems = _ref$contextMenuItems === void 0 ? null : _ref$contextMenuItems;
  8829. _classCallCheck(this, PDFPresentationMode);
  8830. this.container = container;
  8831. this.pdfViewer = pdfViewer;
  8832. this.eventBus = eventBus;
  8833. this.active = false;
  8834. this.args = null;
  8835. this.contextMenuOpen = false;
  8836. this.mouseScrollTimeStamp = 0;
  8837. this.mouseScrollDelta = 0;
  8838. this.touchSwipeState = null;
  8839. if (contextMenuItems) {
  8840. contextMenuItems.contextFirstPage.addEventListener("click", function () {
  8841. _this.contextMenuOpen = false;
  8842. _this.eventBus.dispatch("firstpage", {
  8843. source: _this
  8844. });
  8845. });
  8846. contextMenuItems.contextLastPage.addEventListener("click", function () {
  8847. _this.contextMenuOpen = false;
  8848. _this.eventBus.dispatch("lastpage", {
  8849. source: _this
  8850. });
  8851. });
  8852. contextMenuItems.contextPageRotateCw.addEventListener("click", function () {
  8853. _this.contextMenuOpen = false;
  8854. _this.eventBus.dispatch("rotatecw", {
  8855. source: _this
  8856. });
  8857. });
  8858. contextMenuItems.contextPageRotateCcw.addEventListener("click", function () {
  8859. _this.contextMenuOpen = false;
  8860. _this.eventBus.dispatch("rotateccw", {
  8861. source: _this
  8862. });
  8863. });
  8864. }
  8865. }
  8866. _createClass(PDFPresentationMode, [{
  8867. key: "request",
  8868. value: function request() {
  8869. if (this.switchInProgress || this.active || !this.pdfViewer.pagesCount) {
  8870. return false;
  8871. }
  8872. this._addFullscreenChangeListeners();
  8873. this._setSwitchInProgress();
  8874. this._notifyStateChange();
  8875. if (this.container.requestFullscreen) {
  8876. this.container.requestFullscreen();
  8877. } else if (this.container.mozRequestFullScreen) {
  8878. this.container.mozRequestFullScreen();
  8879. } else if (this.container.webkitRequestFullscreen) {
  8880. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  8881. } else {
  8882. return false;
  8883. }
  8884. this.args = {
  8885. page: this.pdfViewer.currentPageNumber,
  8886. previousScale: this.pdfViewer.currentScaleValue
  8887. };
  8888. return true;
  8889. }
  8890. }, {
  8891. key: "_mouseWheel",
  8892. value: function _mouseWheel(evt) {
  8893. if (!this.active) {
  8894. return;
  8895. }
  8896. evt.preventDefault();
  8897. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  8898. var currentTime = new Date().getTime();
  8899. var storedTime = this.mouseScrollTimeStamp;
  8900. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  8901. return;
  8902. }
  8903. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  8904. this._resetMouseScrollState();
  8905. }
  8906. this.mouseScrollDelta += delta;
  8907. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  8908. var totalDelta = this.mouseScrollDelta;
  8909. this._resetMouseScrollState();
  8910. var success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage();
  8911. if (success) {
  8912. this.mouseScrollTimeStamp = currentTime;
  8913. }
  8914. }
  8915. }
  8916. }, {
  8917. key: "_notifyStateChange",
  8918. value: function _notifyStateChange() {
  8919. var state = _ui_utils.PresentationModeState.NORMAL;
  8920. if (this.switchInProgress) {
  8921. state = _ui_utils.PresentationModeState.CHANGING;
  8922. } else if (this.active) {
  8923. state = _ui_utils.PresentationModeState.FULLSCREEN;
  8924. }
  8925. this.eventBus.dispatch("presentationmodechanged", {
  8926. source: this,
  8927. state: state,
  8928. get active() {
  8929. throw new Error("Deprecated parameter: `active`, please use `state` instead.");
  8930. },
  8931. get switchInProgress() {
  8932. throw new Error("Deprecated parameter: `switchInProgress`, please use `state` instead.");
  8933. }
  8934. });
  8935. }
  8936. }, {
  8937. key: "_setSwitchInProgress",
  8938. value: function _setSwitchInProgress() {
  8939. var _this2 = this;
  8940. if (this.switchInProgress) {
  8941. clearTimeout(this.switchInProgress);
  8942. }
  8943. this.switchInProgress = setTimeout(function () {
  8944. _this2._removeFullscreenChangeListeners();
  8945. delete _this2.switchInProgress;
  8946. _this2._notifyStateChange();
  8947. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  8948. }
  8949. }, {
  8950. key: "_resetSwitchInProgress",
  8951. value: function _resetSwitchInProgress() {
  8952. if (this.switchInProgress) {
  8953. clearTimeout(this.switchInProgress);
  8954. delete this.switchInProgress;
  8955. }
  8956. }
  8957. }, {
  8958. key: "_enter",
  8959. value: function _enter() {
  8960. var _this3 = this;
  8961. this.active = true;
  8962. this._resetSwitchInProgress();
  8963. this._notifyStateChange();
  8964. this.container.classList.add(ACTIVE_SELECTOR);
  8965. setTimeout(function () {
  8966. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  8967. _this3.pdfViewer.currentScaleValue = "page-fit";
  8968. }, 0);
  8969. this._addWindowListeners();
  8970. this._showControls();
  8971. this.contextMenuOpen = false;
  8972. this.container.setAttribute("contextmenu", "viewerContextMenu");
  8973. window.getSelection().removeAllRanges();
  8974. }
  8975. }, {
  8976. key: "_exit",
  8977. value: function _exit() {
  8978. var _this4 = this;
  8979. var page = this.pdfViewer.currentPageNumber;
  8980. this.container.classList.remove(ACTIVE_SELECTOR);
  8981. setTimeout(function () {
  8982. _this4.active = false;
  8983. _this4._removeFullscreenChangeListeners();
  8984. _this4._notifyStateChange();
  8985. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  8986. _this4.pdfViewer.currentPageNumber = page;
  8987. _this4.args = null;
  8988. }, 0);
  8989. this._removeWindowListeners();
  8990. this._hideControls();
  8991. this._resetMouseScrollState();
  8992. this.container.removeAttribute("contextmenu");
  8993. this.contextMenuOpen = false;
  8994. }
  8995. }, {
  8996. key: "_mouseDown",
  8997. value: function _mouseDown(evt) {
  8998. if (this.contextMenuOpen) {
  8999. this.contextMenuOpen = false;
  9000. evt.preventDefault();
  9001. return;
  9002. }
  9003. if (evt.button === 0) {
  9004. var isInternalLink = evt.target.href && evt.target.classList.contains("internalLink");
  9005. if (!isInternalLink) {
  9006. evt.preventDefault();
  9007. if (evt.shiftKey) {
  9008. this.pdfViewer.previousPage();
  9009. } else {
  9010. this.pdfViewer.nextPage();
  9011. }
  9012. }
  9013. }
  9014. }
  9015. }, {
  9016. key: "_contextMenu",
  9017. value: function _contextMenu() {
  9018. this.contextMenuOpen = true;
  9019. }
  9020. }, {
  9021. key: "_showControls",
  9022. value: function _showControls() {
  9023. var _this5 = this;
  9024. if (this.controlsTimeout) {
  9025. clearTimeout(this.controlsTimeout);
  9026. } else {
  9027. this.container.classList.add(CONTROLS_SELECTOR);
  9028. }
  9029. this.controlsTimeout = setTimeout(function () {
  9030. _this5.container.classList.remove(CONTROLS_SELECTOR);
  9031. delete _this5.controlsTimeout;
  9032. }, DELAY_BEFORE_HIDING_CONTROLS);
  9033. }
  9034. }, {
  9035. key: "_hideControls",
  9036. value: function _hideControls() {
  9037. if (!this.controlsTimeout) {
  9038. return;
  9039. }
  9040. clearTimeout(this.controlsTimeout);
  9041. this.container.classList.remove(CONTROLS_SELECTOR);
  9042. delete this.controlsTimeout;
  9043. }
  9044. }, {
  9045. key: "_resetMouseScrollState",
  9046. value: function _resetMouseScrollState() {
  9047. this.mouseScrollTimeStamp = 0;
  9048. this.mouseScrollDelta = 0;
  9049. }
  9050. }, {
  9051. key: "_touchSwipe",
  9052. value: function _touchSwipe(evt) {
  9053. if (!this.active) {
  9054. return;
  9055. }
  9056. if (evt.touches.length > 1) {
  9057. this.touchSwipeState = null;
  9058. return;
  9059. }
  9060. switch (evt.type) {
  9061. case "touchstart":
  9062. this.touchSwipeState = {
  9063. startX: evt.touches[0].pageX,
  9064. startY: evt.touches[0].pageY,
  9065. endX: evt.touches[0].pageX,
  9066. endY: evt.touches[0].pageY
  9067. };
  9068. break;
  9069. case "touchmove":
  9070. if (this.touchSwipeState === null) {
  9071. return;
  9072. }
  9073. this.touchSwipeState.endX = evt.touches[0].pageX;
  9074. this.touchSwipeState.endY = evt.touches[0].pageY;
  9075. evt.preventDefault();
  9076. break;
  9077. case "touchend":
  9078. if (this.touchSwipeState === null) {
  9079. return;
  9080. }
  9081. var delta = 0;
  9082. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  9083. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  9084. var absAngle = Math.abs(Math.atan2(dy, dx));
  9085. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  9086. delta = dx;
  9087. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  9088. delta = dy;
  9089. }
  9090. if (delta > 0) {
  9091. this.pdfViewer.previousPage();
  9092. } else if (delta < 0) {
  9093. this.pdfViewer.nextPage();
  9094. }
  9095. break;
  9096. }
  9097. }
  9098. }, {
  9099. key: "_addWindowListeners",
  9100. value: function _addWindowListeners() {
  9101. this.showControlsBind = this._showControls.bind(this);
  9102. this.mouseDownBind = this._mouseDown.bind(this);
  9103. this.mouseWheelBind = this._mouseWheel.bind(this);
  9104. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  9105. this.contextMenuBind = this._contextMenu.bind(this);
  9106. this.touchSwipeBind = this._touchSwipe.bind(this);
  9107. window.addEventListener("mousemove", this.showControlsBind);
  9108. window.addEventListener("mousedown", this.mouseDownBind);
  9109. window.addEventListener("wheel", this.mouseWheelBind, {
  9110. passive: false
  9111. });
  9112. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  9113. window.addEventListener("contextmenu", this.contextMenuBind);
  9114. window.addEventListener("touchstart", this.touchSwipeBind);
  9115. window.addEventListener("touchmove", this.touchSwipeBind);
  9116. window.addEventListener("touchend", this.touchSwipeBind);
  9117. }
  9118. }, {
  9119. key: "_removeWindowListeners",
  9120. value: function _removeWindowListeners() {
  9121. window.removeEventListener("mousemove", this.showControlsBind);
  9122. window.removeEventListener("mousedown", this.mouseDownBind);
  9123. window.removeEventListener("wheel", this.mouseWheelBind, {
  9124. passive: false
  9125. });
  9126. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  9127. window.removeEventListener("contextmenu", this.contextMenuBind);
  9128. window.removeEventListener("touchstart", this.touchSwipeBind);
  9129. window.removeEventListener("touchmove", this.touchSwipeBind);
  9130. window.removeEventListener("touchend", this.touchSwipeBind);
  9131. delete this.showControlsBind;
  9132. delete this.mouseDownBind;
  9133. delete this.mouseWheelBind;
  9134. delete this.resetMouseScrollStateBind;
  9135. delete this.contextMenuBind;
  9136. delete this.touchSwipeBind;
  9137. }
  9138. }, {
  9139. key: "_fullscreenChange",
  9140. value: function _fullscreenChange() {
  9141. if (this.isFullscreen) {
  9142. this._enter();
  9143. } else {
  9144. this._exit();
  9145. }
  9146. }
  9147. }, {
  9148. key: "_addFullscreenChangeListeners",
  9149. value: function _addFullscreenChangeListeners() {
  9150. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  9151. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  9152. window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  9153. window.addEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  9154. }
  9155. }, {
  9156. key: "_removeFullscreenChangeListeners",
  9157. value: function _removeFullscreenChangeListeners() {
  9158. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  9159. window.removeEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  9160. window.removeEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  9161. delete this.fullscreenChangeBind;
  9162. }
  9163. }, {
  9164. key: "isFullscreen",
  9165. get: function get() {
  9166. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen);
  9167. }
  9168. }]);
  9169. return PDFPresentationMode;
  9170. }();
  9171. exports.PDFPresentationMode = PDFPresentationMode;
  9172. /***/ }),
  9173. /* 24 */
  9174. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9175. Object.defineProperty(exports, "__esModule", ({
  9176. value: true
  9177. }));
  9178. exports.PDFSidebar = void 0;
  9179. var _ui_utils = __webpack_require__(6);
  9180. var _pdf_rendering_queue = __webpack_require__(10);
  9181. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9182. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9183. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9184. var UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  9185. var PDFSidebar = /*#__PURE__*/function () {
  9186. function PDFSidebar(_ref) {
  9187. var elements = _ref.elements,
  9188. pdfViewer = _ref.pdfViewer,
  9189. pdfThumbnailViewer = _ref.pdfThumbnailViewer,
  9190. eventBus = _ref.eventBus,
  9191. _ref$l10n = _ref.l10n,
  9192. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9193. _classCallCheck(this, PDFSidebar);
  9194. this.isOpen = false;
  9195. this.active = _ui_utils.SidebarView.THUMBS;
  9196. this.isInitialViewSet = false;
  9197. this.onToggled = null;
  9198. this.pdfViewer = pdfViewer;
  9199. this.pdfThumbnailViewer = pdfThumbnailViewer;
  9200. this.outerContainer = elements.outerContainer;
  9201. this.viewerContainer = elements.viewerContainer;
  9202. this.toggleButton = elements.toggleButton;
  9203. this.thumbnailButton = elements.thumbnailButton;
  9204. this.outlineButton = elements.outlineButton;
  9205. this.attachmentsButton = elements.attachmentsButton;
  9206. this.layersButton = elements.layersButton;
  9207. this.thumbnailView = elements.thumbnailView;
  9208. this.outlineView = elements.outlineView;
  9209. this.attachmentsView = elements.attachmentsView;
  9210. this.layersView = elements.layersView;
  9211. this._outlineOptionsContainer = elements.outlineOptionsContainer;
  9212. this._currentOutlineItemButton = elements.currentOutlineItemButton;
  9213. this.eventBus = eventBus;
  9214. this.l10n = l10n;
  9215. this._addEventListeners();
  9216. }
  9217. _createClass(PDFSidebar, [{
  9218. key: "reset",
  9219. value: function reset() {
  9220. this.isInitialViewSet = false;
  9221. this._hideUINotification(true);
  9222. this.switchView(_ui_utils.SidebarView.THUMBS);
  9223. this.outlineButton.disabled = false;
  9224. this.attachmentsButton.disabled = false;
  9225. this.layersButton.disabled = false;
  9226. this._currentOutlineItemButton.disabled = true;
  9227. }
  9228. }, {
  9229. key: "setInitialView",
  9230. value: function setInitialView() {
  9231. var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _ui_utils.SidebarView.NONE;
  9232. if (this.isInitialViewSet) {
  9233. return;
  9234. }
  9235. this.isInitialViewSet = true;
  9236. if (view === _ui_utils.SidebarView.NONE || view === _ui_utils.SidebarView.UNKNOWN) {
  9237. this._dispatchEvent();
  9238. return;
  9239. }
  9240. if (!this._switchView(view, true)) {
  9241. this._dispatchEvent();
  9242. }
  9243. }
  9244. }, {
  9245. key: "switchView",
  9246. value: function switchView(view) {
  9247. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9248. this._switchView(view, forceOpen);
  9249. }
  9250. }, {
  9251. key: "_switchView",
  9252. value: function _switchView(view) {
  9253. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9254. var isViewChanged = view !== this.active;
  9255. var shouldForceRendering = false;
  9256. switch (view) {
  9257. case _ui_utils.SidebarView.NONE:
  9258. if (this.isOpen) {
  9259. this.close();
  9260. return true;
  9261. }
  9262. return false;
  9263. case _ui_utils.SidebarView.THUMBS:
  9264. if (this.isOpen && isViewChanged) {
  9265. shouldForceRendering = true;
  9266. }
  9267. break;
  9268. case _ui_utils.SidebarView.OUTLINE:
  9269. if (this.outlineButton.disabled) {
  9270. return false;
  9271. }
  9272. break;
  9273. case _ui_utils.SidebarView.ATTACHMENTS:
  9274. if (this.attachmentsButton.disabled) {
  9275. return false;
  9276. }
  9277. break;
  9278. case _ui_utils.SidebarView.LAYERS:
  9279. if (this.layersButton.disabled) {
  9280. return false;
  9281. }
  9282. break;
  9283. default:
  9284. console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
  9285. return false;
  9286. }
  9287. this.active = view;
  9288. this.thumbnailButton.classList.toggle("toggled", view === _ui_utils.SidebarView.THUMBS);
  9289. this.outlineButton.classList.toggle("toggled", view === _ui_utils.SidebarView.OUTLINE);
  9290. this.attachmentsButton.classList.toggle("toggled", view === _ui_utils.SidebarView.ATTACHMENTS);
  9291. this.layersButton.classList.toggle("toggled", view === _ui_utils.SidebarView.LAYERS);
  9292. this.thumbnailView.classList.toggle("hidden", view !== _ui_utils.SidebarView.THUMBS);
  9293. this.outlineView.classList.toggle("hidden", view !== _ui_utils.SidebarView.OUTLINE);
  9294. this.attachmentsView.classList.toggle("hidden", view !== _ui_utils.SidebarView.ATTACHMENTS);
  9295. this.layersView.classList.toggle("hidden", view !== _ui_utils.SidebarView.LAYERS);
  9296. this._outlineOptionsContainer.classList.toggle("hidden", view !== _ui_utils.SidebarView.OUTLINE);
  9297. if (forceOpen && !this.isOpen) {
  9298. this.open();
  9299. return true;
  9300. }
  9301. if (shouldForceRendering) {
  9302. this._updateThumbnailViewer();
  9303. this._forceRendering();
  9304. }
  9305. if (isViewChanged) {
  9306. this._dispatchEvent();
  9307. }
  9308. return isViewChanged;
  9309. }
  9310. }, {
  9311. key: "open",
  9312. value: function open() {
  9313. if (this.isOpen) {
  9314. return;
  9315. }
  9316. this.isOpen = true;
  9317. this.toggleButton.classList.add("toggled");
  9318. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  9319. if (this.active === _ui_utils.SidebarView.THUMBS) {
  9320. this._updateThumbnailViewer();
  9321. }
  9322. this._forceRendering();
  9323. this._dispatchEvent();
  9324. this._hideUINotification();
  9325. }
  9326. }, {
  9327. key: "close",
  9328. value: function close() {
  9329. if (!this.isOpen) {
  9330. return;
  9331. }
  9332. this.isOpen = false;
  9333. this.toggleButton.classList.remove("toggled");
  9334. this.outerContainer.classList.add("sidebarMoving");
  9335. this.outerContainer.classList.remove("sidebarOpen");
  9336. this._forceRendering();
  9337. this._dispatchEvent();
  9338. }
  9339. }, {
  9340. key: "toggle",
  9341. value: function toggle() {
  9342. if (this.isOpen) {
  9343. this.close();
  9344. } else {
  9345. this.open();
  9346. }
  9347. }
  9348. }, {
  9349. key: "_dispatchEvent",
  9350. value: function _dispatchEvent() {
  9351. this.eventBus.dispatch("sidebarviewchanged", {
  9352. source: this,
  9353. view: this.visibleView
  9354. });
  9355. }
  9356. }, {
  9357. key: "_forceRendering",
  9358. value: function _forceRendering() {
  9359. if (this.onToggled) {
  9360. this.onToggled();
  9361. } else {
  9362. this.pdfViewer.forceRendering();
  9363. this.pdfThumbnailViewer.forceRendering();
  9364. }
  9365. }
  9366. }, {
  9367. key: "_updateThumbnailViewer",
  9368. value: function _updateThumbnailViewer() {
  9369. var pdfViewer = this.pdfViewer,
  9370. pdfThumbnailViewer = this.pdfThumbnailViewer;
  9371. var pagesCount = pdfViewer.pagesCount;
  9372. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  9373. var pageView = pdfViewer.getPageView(pageIndex);
  9374. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  9375. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  9376. thumbnailView.setImage(pageView);
  9377. }
  9378. }
  9379. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  9380. }
  9381. }, {
  9382. key: "_showUINotification",
  9383. value: function _showUINotification() {
  9384. var _this = this;
  9385. this.l10n.get("toggle_sidebar_notification2.title", null, "Toggle Sidebar (document contains outline/attachments/layers)").then(function (msg) {
  9386. _this.toggleButton.title = msg;
  9387. });
  9388. if (!this.isOpen) {
  9389. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  9390. }
  9391. }
  9392. }, {
  9393. key: "_hideUINotification",
  9394. value: function _hideUINotification() {
  9395. var _this2 = this;
  9396. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9397. if (this.isOpen || reset) {
  9398. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  9399. }
  9400. if (reset) {
  9401. this.l10n.get("toggle_sidebar.title", null, "Toggle Sidebar").then(function (msg) {
  9402. _this2.toggleButton.title = msg;
  9403. });
  9404. }
  9405. }
  9406. }, {
  9407. key: "_addEventListeners",
  9408. value: function _addEventListeners() {
  9409. var _this3 = this;
  9410. this.viewerContainer.addEventListener("transitionend", function (evt) {
  9411. if (evt.target === _this3.viewerContainer) {
  9412. _this3.outerContainer.classList.remove("sidebarMoving");
  9413. }
  9414. });
  9415. this.toggleButton.addEventListener("click", function () {
  9416. _this3.toggle();
  9417. });
  9418. this.thumbnailButton.addEventListener("click", function () {
  9419. _this3.switchView(_ui_utils.SidebarView.THUMBS);
  9420. });
  9421. this.outlineButton.addEventListener("click", function () {
  9422. _this3.switchView(_ui_utils.SidebarView.OUTLINE);
  9423. });
  9424. this.outlineButton.addEventListener("dblclick", function () {
  9425. _this3.eventBus.dispatch("toggleoutlinetree", {
  9426. source: _this3
  9427. });
  9428. });
  9429. this.attachmentsButton.addEventListener("click", function () {
  9430. _this3.switchView(_ui_utils.SidebarView.ATTACHMENTS);
  9431. });
  9432. this.layersButton.addEventListener("click", function () {
  9433. _this3.switchView(_ui_utils.SidebarView.LAYERS);
  9434. });
  9435. this.layersButton.addEventListener("dblclick", function () {
  9436. _this3.eventBus.dispatch("resetlayers", {
  9437. source: _this3
  9438. });
  9439. });
  9440. this._currentOutlineItemButton.addEventListener("click", function () {
  9441. _this3.eventBus.dispatch("currentoutlineitem", {
  9442. source: _this3
  9443. });
  9444. });
  9445. var onTreeLoaded = function onTreeLoaded(count, button, view) {
  9446. button.disabled = !count;
  9447. if (count) {
  9448. _this3._showUINotification();
  9449. } else if (_this3.active === view) {
  9450. _this3.switchView(_ui_utils.SidebarView.THUMBS);
  9451. }
  9452. };
  9453. this.eventBus._on("outlineloaded", function (evt) {
  9454. onTreeLoaded(evt.outlineCount, _this3.outlineButton, _ui_utils.SidebarView.OUTLINE);
  9455. if (evt.enableCurrentOutlineItemButton) {
  9456. _this3.pdfViewer.pagesPromise.then(function () {
  9457. _this3._currentOutlineItemButton.disabled = !_this3.isInitialViewSet;
  9458. });
  9459. }
  9460. });
  9461. this.eventBus._on("attachmentsloaded", function (evt) {
  9462. onTreeLoaded(evt.attachmentsCount, _this3.attachmentsButton, _ui_utils.SidebarView.ATTACHMENTS);
  9463. });
  9464. this.eventBus._on("layersloaded", function (evt) {
  9465. onTreeLoaded(evt.layersCount, _this3.layersButton, _ui_utils.SidebarView.LAYERS);
  9466. });
  9467. this.eventBus._on("presentationmodechanged", function (evt) {
  9468. if (evt.state === _ui_utils.PresentationModeState.NORMAL && _this3.isThumbnailViewVisible) {
  9469. _this3._updateThumbnailViewer();
  9470. }
  9471. });
  9472. }
  9473. }, {
  9474. key: "visibleView",
  9475. get: function get() {
  9476. return this.isOpen ? this.active : _ui_utils.SidebarView.NONE;
  9477. }
  9478. }, {
  9479. key: "isThumbnailViewVisible",
  9480. get: function get() {
  9481. return this.isOpen && this.active === _ui_utils.SidebarView.THUMBS;
  9482. }
  9483. }, {
  9484. key: "isOutlineViewVisible",
  9485. get: function get() {
  9486. return this.isOpen && this.active === _ui_utils.SidebarView.OUTLINE;
  9487. }
  9488. }, {
  9489. key: "isAttachmentsViewVisible",
  9490. get: function get() {
  9491. return this.isOpen && this.active === _ui_utils.SidebarView.ATTACHMENTS;
  9492. }
  9493. }, {
  9494. key: "isLayersViewVisible",
  9495. get: function get() {
  9496. return this.isOpen && this.active === _ui_utils.SidebarView.LAYERS;
  9497. }
  9498. }]);
  9499. return PDFSidebar;
  9500. }();
  9501. exports.PDFSidebar = PDFSidebar;
  9502. /***/ }),
  9503. /* 25 */
  9504. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9505. Object.defineProperty(exports, "__esModule", ({
  9506. value: true
  9507. }));
  9508. exports.PDFSidebarResizer = void 0;
  9509. var _ui_utils = __webpack_require__(6);
  9510. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9511. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9512. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9513. var SIDEBAR_WIDTH_VAR = "--sidebar-width";
  9514. var SIDEBAR_MIN_WIDTH = 200;
  9515. var SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  9516. var PDFSidebarResizer = /*#__PURE__*/function () {
  9517. function PDFSidebarResizer(options, eventBus) {
  9518. var _this = this;
  9519. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  9520. _classCallCheck(this, PDFSidebarResizer);
  9521. this.isRTL = false;
  9522. this.sidebarOpen = false;
  9523. this.doc = document.documentElement;
  9524. this._width = null;
  9525. this._outerContainerWidth = null;
  9526. this._boundEvents = Object.create(null);
  9527. this.outerContainer = options.outerContainer;
  9528. this.resizer = options.resizer;
  9529. this.eventBus = eventBus;
  9530. l10n.getDirection().then(function (dir) {
  9531. _this.isRTL = dir === "rtl";
  9532. });
  9533. this._addEventListeners();
  9534. }
  9535. _createClass(PDFSidebarResizer, [{
  9536. key: "_updateWidth",
  9537. value: function _updateWidth() {
  9538. var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  9539. var maxWidth = Math.floor(this.outerContainerWidth / 2);
  9540. if (width > maxWidth) {
  9541. width = maxWidth;
  9542. }
  9543. if (width < SIDEBAR_MIN_WIDTH) {
  9544. width = SIDEBAR_MIN_WIDTH;
  9545. }
  9546. if (width === this._width) {
  9547. return false;
  9548. }
  9549. this._width = width;
  9550. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(width, "px"));
  9551. return true;
  9552. }
  9553. }, {
  9554. key: "_mouseMove",
  9555. value: function _mouseMove(evt) {
  9556. var width = evt.clientX;
  9557. if (this.isRTL) {
  9558. width = this.outerContainerWidth - width;
  9559. }
  9560. this._updateWidth(width);
  9561. }
  9562. }, {
  9563. key: "_mouseUp",
  9564. value: function _mouseUp(evt) {
  9565. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  9566. this.eventBus.dispatch("resize", {
  9567. source: this
  9568. });
  9569. var _boundEvents = this._boundEvents;
  9570. window.removeEventListener("mousemove", _boundEvents.mouseMove);
  9571. window.removeEventListener("mouseup", _boundEvents.mouseUp);
  9572. }
  9573. }, {
  9574. key: "_addEventListeners",
  9575. value: function _addEventListeners() {
  9576. var _this2 = this;
  9577. var _boundEvents = this._boundEvents;
  9578. _boundEvents.mouseMove = this._mouseMove.bind(this);
  9579. _boundEvents.mouseUp = this._mouseUp.bind(this);
  9580. this.resizer.addEventListener("mousedown", function (evt) {
  9581. if (evt.button !== 0) {
  9582. return;
  9583. }
  9584. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  9585. window.addEventListener("mousemove", _boundEvents.mouseMove);
  9586. window.addEventListener("mouseup", _boundEvents.mouseUp);
  9587. });
  9588. this.eventBus._on("sidebarviewchanged", function (evt) {
  9589. _this2.sidebarOpen = !!(evt && evt.view);
  9590. });
  9591. this.eventBus._on("resize", function (evt) {
  9592. if (!evt || evt.source !== window) {
  9593. return;
  9594. }
  9595. _this2._outerContainerWidth = null;
  9596. if (!_this2._width) {
  9597. return;
  9598. }
  9599. if (!_this2.sidebarOpen) {
  9600. _this2._updateWidth(_this2._width);
  9601. return;
  9602. }
  9603. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  9604. var updated = _this2._updateWidth(_this2._width);
  9605. Promise.resolve().then(function () {
  9606. _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  9607. if (updated) {
  9608. _this2.eventBus.dispatch("resize", {
  9609. source: _this2
  9610. });
  9611. }
  9612. });
  9613. });
  9614. }
  9615. }, {
  9616. key: "outerContainerWidth",
  9617. get: function get() {
  9618. if (!this._outerContainerWidth) {
  9619. this._outerContainerWidth = this.outerContainer.clientWidth;
  9620. }
  9621. return this._outerContainerWidth;
  9622. }
  9623. }]);
  9624. return PDFSidebarResizer;
  9625. }();
  9626. exports.PDFSidebarResizer = PDFSidebarResizer;
  9627. /***/ }),
  9628. /* 26 */
  9629. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9630. Object.defineProperty(exports, "__esModule", ({
  9631. value: true
  9632. }));
  9633. exports.PDFThumbnailViewer = void 0;
  9634. var _ui_utils = __webpack_require__(6);
  9635. var _pdf_thumbnail_view = __webpack_require__(27);
  9636. var _pdf_rendering_queue = __webpack_require__(10);
  9637. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9638. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9639. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9640. var THUMBNAIL_SCROLL_MARGIN = -19;
  9641. var THUMBNAIL_SELECTED_CLASS = "selected";
  9642. var PDFThumbnailViewer = /*#__PURE__*/function () {
  9643. function PDFThumbnailViewer(_ref) {
  9644. var _this = this;
  9645. var container = _ref.container,
  9646. eventBus = _ref.eventBus,
  9647. linkService = _ref.linkService,
  9648. renderingQueue = _ref.renderingQueue,
  9649. _ref$l10n = _ref.l10n,
  9650. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9651. _classCallCheck(this, PDFThumbnailViewer);
  9652. this.container = container;
  9653. this.linkService = linkService;
  9654. this.renderingQueue = renderingQueue;
  9655. this.l10n = l10n;
  9656. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  9657. this._resetView();
  9658. eventBus._on("optionalcontentconfigchanged", function () {
  9659. _this._setImageDisabled = true;
  9660. });
  9661. }
  9662. _createClass(PDFThumbnailViewer, [{
  9663. key: "_scrollUpdated",
  9664. value: function _scrollUpdated() {
  9665. this.renderingQueue.renderHighestPriority();
  9666. }
  9667. }, {
  9668. key: "getThumbnail",
  9669. value: function getThumbnail(index) {
  9670. return this._thumbnails[index];
  9671. }
  9672. }, {
  9673. key: "_getVisibleThumbs",
  9674. value: function _getVisibleThumbs() {
  9675. return (0, _ui_utils.getVisibleElements)({
  9676. scrollEl: this.container,
  9677. views: this._thumbnails
  9678. });
  9679. }
  9680. }, {
  9681. key: "scrollThumbnailIntoView",
  9682. value: function scrollThumbnailIntoView(pageNumber) {
  9683. if (!this.pdfDocument) {
  9684. return;
  9685. }
  9686. var thumbnailView = this._thumbnails[pageNumber - 1];
  9687. if (!thumbnailView) {
  9688. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  9689. return;
  9690. }
  9691. if (pageNumber !== this._currentPageNumber) {
  9692. var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  9693. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  9694. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  9695. }
  9696. var visibleThumbs = this._getVisibleThumbs();
  9697. var numVisibleThumbs = visibleThumbs.views.length;
  9698. if (numVisibleThumbs > 0) {
  9699. var first = visibleThumbs.first.id;
  9700. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  9701. var shouldScroll = false;
  9702. if (pageNumber <= first || pageNumber >= last) {
  9703. shouldScroll = true;
  9704. } else {
  9705. visibleThumbs.views.some(function (view) {
  9706. if (view.id !== pageNumber) {
  9707. return false;
  9708. }
  9709. shouldScroll = view.percent < 100;
  9710. return true;
  9711. });
  9712. }
  9713. if (shouldScroll) {
  9714. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  9715. top: THUMBNAIL_SCROLL_MARGIN
  9716. });
  9717. }
  9718. }
  9719. this._currentPageNumber = pageNumber;
  9720. }
  9721. }, {
  9722. key: "cleanup",
  9723. value: function cleanup() {
  9724. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9725. if (this._thumbnails[i] && this._thumbnails[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9726. this._thumbnails[i].reset();
  9727. }
  9728. }
  9729. _pdf_thumbnail_view.TempImageFactory.destroyCanvas();
  9730. }
  9731. }, {
  9732. key: "_resetView",
  9733. value: function _resetView() {
  9734. this._thumbnails = [];
  9735. this._currentPageNumber = 1;
  9736. this._pageLabels = null;
  9737. this._pagesRotation = 0;
  9738. this._optionalContentConfigPromise = null;
  9739. this._pagesRequests = new WeakMap();
  9740. this._setImageDisabled = false;
  9741. this.container.textContent = "";
  9742. }
  9743. }, {
  9744. key: "setDocument",
  9745. value: function setDocument(pdfDocument) {
  9746. var _this2 = this;
  9747. if (this.pdfDocument) {
  9748. this._cancelRendering();
  9749. this._resetView();
  9750. }
  9751. this.pdfDocument = pdfDocument;
  9752. if (!pdfDocument) {
  9753. return;
  9754. }
  9755. var firstPagePromise = pdfDocument.getPage(1);
  9756. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  9757. firstPagePromise.then(function (firstPdfPage) {
  9758. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  9759. var pagesCount = pdfDocument.numPages;
  9760. var viewport = firstPdfPage.getViewport({
  9761. scale: 1
  9762. });
  9763. var checkSetImageDisabled = function checkSetImageDisabled() {
  9764. return _this2._setImageDisabled;
  9765. };
  9766. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  9767. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  9768. container: _this2.container,
  9769. id: pageNum,
  9770. defaultViewport: viewport.clone(),
  9771. optionalContentConfigPromise: optionalContentConfigPromise,
  9772. linkService: _this2.linkService,
  9773. renderingQueue: _this2.renderingQueue,
  9774. checkSetImageDisabled: checkSetImageDisabled,
  9775. disableCanvasToImageConversion: false,
  9776. l10n: _this2.l10n
  9777. });
  9778. _this2._thumbnails.push(thumbnail);
  9779. }
  9780. var firstThumbnailView = _this2._thumbnails[0];
  9781. if (firstThumbnailView) {
  9782. firstThumbnailView.setPdfPage(firstPdfPage);
  9783. }
  9784. var thumbnailView = _this2._thumbnails[_this2._currentPageNumber - 1];
  9785. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  9786. })["catch"](function (reason) {
  9787. console.error("Unable to initialize thumbnail viewer", reason);
  9788. });
  9789. }
  9790. }, {
  9791. key: "_cancelRendering",
  9792. value: function _cancelRendering() {
  9793. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9794. if (this._thumbnails[i]) {
  9795. this._thumbnails[i].cancelRendering();
  9796. }
  9797. }
  9798. }
  9799. }, {
  9800. key: "setPageLabels",
  9801. value: function setPageLabels(labels) {
  9802. if (!this.pdfDocument) {
  9803. return;
  9804. }
  9805. if (!labels) {
  9806. this._pageLabels = null;
  9807. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  9808. this._pageLabels = null;
  9809. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  9810. } else {
  9811. this._pageLabels = labels;
  9812. }
  9813. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9814. var label = this._pageLabels && this._pageLabels[i];
  9815. this._thumbnails[i].setPageLabel(label);
  9816. }
  9817. }
  9818. }, {
  9819. key: "_ensurePdfPageLoaded",
  9820. value: function _ensurePdfPageLoaded(thumbView) {
  9821. var _this3 = this;
  9822. if (thumbView.pdfPage) {
  9823. return Promise.resolve(thumbView.pdfPage);
  9824. }
  9825. if (this._pagesRequests.has(thumbView)) {
  9826. return this._pagesRequests.get(thumbView);
  9827. }
  9828. var promise = this.pdfDocument.getPage(thumbView.id).then(function (pdfPage) {
  9829. if (!thumbView.pdfPage) {
  9830. thumbView.setPdfPage(pdfPage);
  9831. }
  9832. _this3._pagesRequests["delete"](thumbView);
  9833. return pdfPage;
  9834. })["catch"](function (reason) {
  9835. console.error("Unable to get page for thumb view", reason);
  9836. _this3._pagesRequests["delete"](thumbView);
  9837. });
  9838. this._pagesRequests.set(thumbView, promise);
  9839. return promise;
  9840. }
  9841. }, {
  9842. key: "forceRendering",
  9843. value: function forceRendering() {
  9844. var _this4 = this;
  9845. var visibleThumbs = this._getVisibleThumbs();
  9846. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  9847. if (thumbView) {
  9848. this._ensurePdfPageLoaded(thumbView).then(function () {
  9849. _this4.renderingQueue.renderView(thumbView);
  9850. });
  9851. return true;
  9852. }
  9853. return false;
  9854. }
  9855. }, {
  9856. key: "pagesRotation",
  9857. get: function get() {
  9858. return this._pagesRotation;
  9859. },
  9860. set: function set(rotation) {
  9861. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  9862. throw new Error("Invalid thumbnails rotation angle.");
  9863. }
  9864. if (!this.pdfDocument) {
  9865. return;
  9866. }
  9867. if (this._pagesRotation === rotation) {
  9868. return;
  9869. }
  9870. this._pagesRotation = rotation;
  9871. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9872. this._thumbnails[i].update(rotation);
  9873. }
  9874. }
  9875. }]);
  9876. return PDFThumbnailViewer;
  9877. }();
  9878. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  9879. /***/ }),
  9880. /* 27 */
  9881. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9882. Object.defineProperty(exports, "__esModule", ({
  9883. value: true
  9884. }));
  9885. exports.TempImageFactory = exports.PDFThumbnailView = void 0;
  9886. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  9887. var _ui_utils = __webpack_require__(6);
  9888. var _pdfjsLib = __webpack_require__(7);
  9889. var _pdf_rendering_queue = __webpack_require__(10);
  9890. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9891. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  9892. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  9893. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  9894. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  9895. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  9896. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  9897. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  9898. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  9899. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9900. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9901. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9902. var MAX_NUM_SCALING_STEPS = 3;
  9903. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  9904. var THUMBNAIL_WIDTH = 98;
  9905. var TempImageFactory = function TempImageFactoryClosure() {
  9906. var tempCanvasCache = null;
  9907. return {
  9908. getCanvas: function getCanvas(width, height) {
  9909. var tempCanvas = tempCanvasCache;
  9910. if (!tempCanvas) {
  9911. tempCanvas = document.createElement("canvas");
  9912. tempCanvasCache = tempCanvas;
  9913. }
  9914. tempCanvas.width = width;
  9915. tempCanvas.height = height;
  9916. tempCanvas.mozOpaque = true;
  9917. var ctx = tempCanvas.getContext("2d", {
  9918. alpha: false
  9919. });
  9920. ctx.save();
  9921. ctx.fillStyle = "rgb(255, 255, 255)";
  9922. ctx.fillRect(0, 0, width, height);
  9923. ctx.restore();
  9924. return tempCanvas;
  9925. },
  9926. destroyCanvas: function destroyCanvas() {
  9927. var tempCanvas = tempCanvasCache;
  9928. if (tempCanvas) {
  9929. tempCanvas.width = 0;
  9930. tempCanvas.height = 0;
  9931. }
  9932. tempCanvasCache = null;
  9933. }
  9934. };
  9935. }();
  9936. exports.TempImageFactory = TempImageFactory;
  9937. var PDFThumbnailView = /*#__PURE__*/function () {
  9938. function PDFThumbnailView(_ref) {
  9939. var container = _ref.container,
  9940. id = _ref.id,
  9941. defaultViewport = _ref.defaultViewport,
  9942. optionalContentConfigPromise = _ref.optionalContentConfigPromise,
  9943. linkService = _ref.linkService,
  9944. renderingQueue = _ref.renderingQueue,
  9945. checkSetImageDisabled = _ref.checkSetImageDisabled,
  9946. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  9947. disableCanvasToImageConversion = _ref$disableCanvasToI === void 0 ? false : _ref$disableCanvasToI,
  9948. _ref$l10n = _ref.l10n,
  9949. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9950. _classCallCheck(this, PDFThumbnailView);
  9951. this.id = id;
  9952. this.renderingId = "thumbnail" + id;
  9953. this.pageLabel = null;
  9954. this.pdfPage = null;
  9955. this.rotation = 0;
  9956. this.viewport = defaultViewport;
  9957. this.pdfPageRotate = defaultViewport.rotation;
  9958. this._optionalContentConfigPromise = optionalContentConfigPromise || null;
  9959. this.linkService = linkService;
  9960. this.renderingQueue = renderingQueue;
  9961. this.renderTask = null;
  9962. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9963. this.resume = null;
  9964. this._checkSetImageDisabled = checkSetImageDisabled || function () {
  9965. return false;
  9966. };
  9967. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  9968. this.pageWidth = this.viewport.width;
  9969. this.pageHeight = this.viewport.height;
  9970. this.pageRatio = this.pageWidth / this.pageHeight;
  9971. this.canvasWidth = THUMBNAIL_WIDTH;
  9972. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  9973. this.scale = this.canvasWidth / this.pageWidth;
  9974. this.l10n = l10n;
  9975. var anchor = document.createElement("a");
  9976. anchor.href = linkService.getAnchorUrl("#page=" + id);
  9977. this._thumbPageTitle.then(function (msg) {
  9978. anchor.title = msg;
  9979. });
  9980. anchor.onclick = function () {
  9981. linkService.goToPage(id);
  9982. return false;
  9983. };
  9984. this.anchor = anchor;
  9985. var div = document.createElement("div");
  9986. div.className = "thumbnail";
  9987. div.setAttribute("data-page-number", this.id);
  9988. this.div = div;
  9989. var ring = document.createElement("div");
  9990. ring.className = "thumbnailSelectionRing";
  9991. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  9992. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  9993. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  9994. this.ring = ring;
  9995. div.appendChild(ring);
  9996. anchor.appendChild(div);
  9997. container.appendChild(anchor);
  9998. }
  9999. _createClass(PDFThumbnailView, [{
  10000. key: "setPdfPage",
  10001. value: function setPdfPage(pdfPage) {
  10002. this.pdfPage = pdfPage;
  10003. this.pdfPageRotate = pdfPage.rotate;
  10004. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10005. this.viewport = pdfPage.getViewport({
  10006. scale: 1,
  10007. rotation: totalRotation
  10008. });
  10009. this.reset();
  10010. }
  10011. }, {
  10012. key: "reset",
  10013. value: function reset() {
  10014. this.cancelRendering();
  10015. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  10016. this.pageWidth = this.viewport.width;
  10017. this.pageHeight = this.viewport.height;
  10018. this.pageRatio = this.pageWidth / this.pageHeight;
  10019. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  10020. this.scale = this.canvasWidth / this.pageWidth;
  10021. this.div.removeAttribute("data-loaded");
  10022. var ring = this.ring;
  10023. var childNodes = ring.childNodes;
  10024. for (var i = childNodes.length - 1; i >= 0; i--) {
  10025. ring.removeChild(childNodes[i]);
  10026. }
  10027. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  10028. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  10029. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  10030. if (this.canvas) {
  10031. this.canvas.width = 0;
  10032. this.canvas.height = 0;
  10033. delete this.canvas;
  10034. }
  10035. if (this.image) {
  10036. this.image.removeAttribute("src");
  10037. delete this.image;
  10038. }
  10039. }
  10040. }, {
  10041. key: "update",
  10042. value: function update(rotation) {
  10043. if (typeof rotation !== "undefined") {
  10044. this.rotation = rotation;
  10045. }
  10046. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10047. this.viewport = this.viewport.clone({
  10048. scale: 1,
  10049. rotation: totalRotation
  10050. });
  10051. this.reset();
  10052. }
  10053. }, {
  10054. key: "cancelRendering",
  10055. value: function cancelRendering() {
  10056. if (this.renderTask) {
  10057. this.renderTask.cancel();
  10058. this.renderTask = null;
  10059. }
  10060. this.resume = null;
  10061. }
  10062. }, {
  10063. key: "_getPageDrawContext",
  10064. value: function _getPageDrawContext() {
  10065. var canvas = document.createElement("canvas");
  10066. this.canvas = canvas;
  10067. canvas.mozOpaque = true;
  10068. var ctx = canvas.getContext("2d", {
  10069. alpha: false
  10070. });
  10071. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  10072. canvas.width = this.canvasWidth * outputScale.sx | 0;
  10073. canvas.height = this.canvasHeight * outputScale.sy | 0;
  10074. canvas.style.width = this.canvasWidth + "px";
  10075. canvas.style.height = this.canvasHeight + "px";
  10076. var transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  10077. return [ctx, transform];
  10078. }
  10079. }, {
  10080. key: "_convertCanvasToImage",
  10081. value: function _convertCanvasToImage() {
  10082. var _this = this;
  10083. if (!this.canvas) {
  10084. return;
  10085. }
  10086. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  10087. return;
  10088. }
  10089. var className = "thumbnailImage";
  10090. if (this.disableCanvasToImageConversion) {
  10091. this.canvas.className = className;
  10092. this._thumbPageCanvas.then(function (msg) {
  10093. _this.canvas.setAttribute("aria-label", msg);
  10094. });
  10095. this.div.setAttribute("data-loaded", true);
  10096. this.ring.appendChild(this.canvas);
  10097. return;
  10098. }
  10099. var image = document.createElement("img");
  10100. image.className = className;
  10101. this._thumbPageCanvas.then(function (msg) {
  10102. image.setAttribute("aria-label", msg);
  10103. });
  10104. image.style.width = this.canvasWidth + "px";
  10105. image.style.height = this.canvasHeight + "px";
  10106. image.src = this.canvas.toDataURL();
  10107. this.image = image;
  10108. this.div.setAttribute("data-loaded", true);
  10109. this.ring.appendChild(image);
  10110. this.canvas.width = 0;
  10111. this.canvas.height = 0;
  10112. delete this.canvas;
  10113. }
  10114. }, {
  10115. key: "draw",
  10116. value: function draw() {
  10117. var _this2 = this;
  10118. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  10119. console.error("Must be in new state before drawing");
  10120. return Promise.resolve(undefined);
  10121. }
  10122. var pdfPage = this.pdfPage;
  10123. if (!pdfPage) {
  10124. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10125. return Promise.reject(new Error("pdfPage is not loaded"));
  10126. }
  10127. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10128. var finishRenderTask = /*#__PURE__*/function () {
  10129. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  10130. var error,
  10131. _args = arguments;
  10132. return _regenerator["default"].wrap(function _callee$(_context) {
  10133. while (1) {
  10134. switch (_context.prev = _context.next) {
  10135. case 0:
  10136. error = _args.length > 0 && _args[0] !== undefined ? _args[0] : null;
  10137. if (renderTask === _this2.renderTask) {
  10138. _this2.renderTask = null;
  10139. }
  10140. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  10141. _context.next = 4;
  10142. break;
  10143. }
  10144. return _context.abrupt("return");
  10145. case 4:
  10146. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10147. _this2._convertCanvasToImage();
  10148. if (!error) {
  10149. _context.next = 8;
  10150. break;
  10151. }
  10152. throw error;
  10153. case 8:
  10154. case "end":
  10155. return _context.stop();
  10156. }
  10157. }
  10158. }, _callee);
  10159. }));
  10160. return function finishRenderTask() {
  10161. return _ref2.apply(this, arguments);
  10162. };
  10163. }();
  10164. var _this$_getPageDrawCon = this._getPageDrawContext(),
  10165. _this$_getPageDrawCon2 = _slicedToArray(_this$_getPageDrawCon, 2),
  10166. ctx = _this$_getPageDrawCon2[0],
  10167. transform = _this$_getPageDrawCon2[1];
  10168. var drawViewport = this.viewport.clone({
  10169. scale: this.scale
  10170. });
  10171. var renderContinueCallback = function renderContinueCallback(cont) {
  10172. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  10173. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  10174. _this2.resume = function () {
  10175. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10176. cont();
  10177. };
  10178. return;
  10179. }
  10180. cont();
  10181. };
  10182. var renderContext = {
  10183. canvasContext: ctx,
  10184. transform: transform,
  10185. viewport: drawViewport,
  10186. optionalContentConfigPromise: this._optionalContentConfigPromise
  10187. };
  10188. var renderTask = this.renderTask = pdfPage.render(renderContext);
  10189. renderTask.onContinue = renderContinueCallback;
  10190. var resultPromise = renderTask.promise.then(function () {
  10191. finishRenderTask(null);
  10192. }, function (error) {
  10193. finishRenderTask(error);
  10194. });
  10195. resultPromise["finally"](function () {
  10196. var _this2$pdfPage;
  10197. var pageCached = _this2.linkService.isPageCached(_this2.id);
  10198. if (pageCached) {
  10199. return;
  10200. }
  10201. (_this2$pdfPage = _this2.pdfPage) === null || _this2$pdfPage === void 0 ? void 0 : _this2$pdfPage.cleanup();
  10202. });
  10203. return resultPromise;
  10204. }
  10205. }, {
  10206. key: "setImage",
  10207. value: function setImage(pageView) {
  10208. if (this._checkSetImageDisabled()) {
  10209. return;
  10210. }
  10211. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  10212. return;
  10213. }
  10214. var img = pageView.canvas;
  10215. if (!img) {
  10216. return;
  10217. }
  10218. if (!this.pdfPage) {
  10219. this.setPdfPage(pageView.pdfPage);
  10220. }
  10221. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10222. var _this$_getPageDrawCon3 = this._getPageDrawContext(),
  10223. _this$_getPageDrawCon4 = _slicedToArray(_this$_getPageDrawCon3, 1),
  10224. ctx = _this$_getPageDrawCon4[0];
  10225. var canvas = ctx.canvas;
  10226. if (img.width <= 2 * canvas.width) {
  10227. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  10228. this._convertCanvasToImage();
  10229. return;
  10230. }
  10231. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  10232. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  10233. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  10234. var reducedImageCtx = reducedImage.getContext("2d");
  10235. while (reducedWidth > img.width || reducedHeight > img.height) {
  10236. reducedWidth >>= 1;
  10237. reducedHeight >>= 1;
  10238. }
  10239. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  10240. while (reducedWidth > 2 * canvas.width) {
  10241. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  10242. reducedWidth >>= 1;
  10243. reducedHeight >>= 1;
  10244. }
  10245. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  10246. this._convertCanvasToImage();
  10247. }
  10248. }, {
  10249. key: "setPageLabel",
  10250. value: function setPageLabel(label) {
  10251. var _this3 = this;
  10252. this.pageLabel = typeof label === "string" ? label : null;
  10253. this._thumbPageTitle.then(function (msg) {
  10254. _this3.anchor.title = msg;
  10255. });
  10256. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  10257. return;
  10258. }
  10259. this._thumbPageCanvas.then(function (msg) {
  10260. if (_this3.image) {
  10261. _this3.image.setAttribute("aria-label", msg);
  10262. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  10263. _this3.canvas.setAttribute("aria-label", msg);
  10264. }
  10265. });
  10266. }
  10267. }, {
  10268. key: "_thumbPageTitle",
  10269. get: function get() {
  10270. var _this$pageLabel;
  10271. return this.l10n.get("thumb_page_title", {
  10272. page: (_this$pageLabel = this.pageLabel) !== null && _this$pageLabel !== void 0 ? _this$pageLabel : this.id
  10273. }, "Page {{page}}");
  10274. }
  10275. }, {
  10276. key: "_thumbPageCanvas",
  10277. get: function get() {
  10278. var _this$pageLabel2;
  10279. return this.l10n.get("thumb_page_canvas", {
  10280. page: (_this$pageLabel2 = this.pageLabel) !== null && _this$pageLabel2 !== void 0 ? _this$pageLabel2 : this.id
  10281. }, "Thumbnail of Page {{page}}");
  10282. }
  10283. }]);
  10284. return PDFThumbnailView;
  10285. }();
  10286. exports.PDFThumbnailView = PDFThumbnailView;
  10287. /***/ }),
  10288. /* 28 */
  10289. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10290. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  10291. Object.defineProperty(exports, "__esModule", ({
  10292. value: true
  10293. }));
  10294. exports.PDFViewer = void 0;
  10295. var _ui_utils = __webpack_require__(6);
  10296. var _base_viewer = __webpack_require__(29);
  10297. var _pdfjsLib = __webpack_require__(7);
  10298. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  10299. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  10300. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  10301. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10302. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10303. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10304. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  10305. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  10306. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  10307. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10308. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  10309. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10310. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10311. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  10312. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10313. var PDFViewer = /*#__PURE__*/function (_BaseViewer) {
  10314. _inherits(PDFViewer, _BaseViewer);
  10315. var _super = _createSuper(PDFViewer);
  10316. function PDFViewer() {
  10317. _classCallCheck(this, PDFViewer);
  10318. return _super.apply(this, arguments);
  10319. }
  10320. _createClass(PDFViewer, [{
  10321. key: "_scrollIntoView",
  10322. value: function _scrollIntoView(_ref) {
  10323. var pageDiv = _ref.pageDiv,
  10324. _ref$pageSpot = _ref.pageSpot,
  10325. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  10326. _ref$pageNumber = _ref.pageNumber,
  10327. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  10328. if (!pageSpot && !this.isInPresentationMode) {
  10329. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  10330. var right = left + pageDiv.clientWidth;
  10331. var _this$container = this.container,
  10332. scrollLeft = _this$container.scrollLeft,
  10333. clientWidth = _this$container.clientWidth;
  10334. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  10335. pageSpot = {
  10336. left: 0,
  10337. top: 0
  10338. };
  10339. }
  10340. }
  10341. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  10342. pageDiv: pageDiv,
  10343. pageSpot: pageSpot,
  10344. pageNumber: pageNumber
  10345. });
  10346. }
  10347. }, {
  10348. key: "_getVisiblePages",
  10349. value: function _getVisiblePages() {
  10350. if (this.isInPresentationMode) {
  10351. return this._getCurrentVisiblePage();
  10352. }
  10353. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  10354. }
  10355. }, {
  10356. key: "_updateHelper",
  10357. value: function _updateHelper(visiblePages) {
  10358. if (this.isInPresentationMode) {
  10359. return;
  10360. }
  10361. var currentId = this._currentPageNumber;
  10362. var stillFullyVisible = false;
  10363. var _iterator = _createForOfIteratorHelper(visiblePages),
  10364. _step;
  10365. try {
  10366. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  10367. var page = _step.value;
  10368. if (page.percent < 100) {
  10369. break;
  10370. }
  10371. if (page.id === currentId && this._scrollMode === _ui_utils.ScrollMode.VERTICAL && this._spreadMode === _ui_utils.SpreadMode.NONE) {
  10372. stillFullyVisible = true;
  10373. break;
  10374. }
  10375. }
  10376. } catch (err) {
  10377. _iterator.e(err);
  10378. } finally {
  10379. _iterator.f();
  10380. }
  10381. if (!stillFullyVisible) {
  10382. currentId = visiblePages[0].id;
  10383. }
  10384. this._setCurrentPageNumber(currentId);
  10385. }
  10386. }, {
  10387. key: "_viewerElement",
  10388. get: function get() {
  10389. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this.viewer);
  10390. }
  10391. }]);
  10392. return PDFViewer;
  10393. }(_base_viewer.BaseViewer);
  10394. exports.PDFViewer = PDFViewer;
  10395. /***/ }),
  10396. /* 29 */
  10397. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10398. Object.defineProperty(exports, "__esModule", ({
  10399. value: true
  10400. }));
  10401. exports.BaseViewer = void 0;
  10402. var _pdfjsLib = __webpack_require__(7);
  10403. var _ui_utils = __webpack_require__(6);
  10404. var _pdf_rendering_queue = __webpack_require__(10);
  10405. var _annotation_layer_builder = __webpack_require__(30);
  10406. var _pdf_page_view = __webpack_require__(31);
  10407. var _pdf_link_service = __webpack_require__(21);
  10408. var _text_layer_builder = __webpack_require__(32);
  10409. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  10410. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  10411. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  10412. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10413. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10414. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10415. var DEFAULT_CACHE_SIZE = 10;
  10416. function PDFPageViewBuffer(size) {
  10417. var data = [];
  10418. this.push = function (view) {
  10419. var i = data.indexOf(view);
  10420. if (i >= 0) {
  10421. data.splice(i, 1);
  10422. }
  10423. data.push(view);
  10424. if (data.length > size) {
  10425. data.shift().destroy();
  10426. }
  10427. };
  10428. this.resize = function (newSize, pagesToKeep) {
  10429. size = newSize;
  10430. if (pagesToKeep) {
  10431. var pageIdsToKeep = new Set();
  10432. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  10433. pageIdsToKeep.add(pagesToKeep[i].id);
  10434. }
  10435. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  10436. return pageIdsToKeep.has(page.id);
  10437. });
  10438. }
  10439. while (data.length > size) {
  10440. data.shift().destroy();
  10441. }
  10442. };
  10443. this.has = function (view) {
  10444. return data.includes(view);
  10445. };
  10446. }
  10447. function isSameScale(oldScale, newScale) {
  10448. if (newScale === oldScale) {
  10449. return true;
  10450. }
  10451. if (Math.abs(newScale - oldScale) < 1e-15) {
  10452. return true;
  10453. }
  10454. return false;
  10455. }
  10456. var BaseViewer = /*#__PURE__*/function () {
  10457. function BaseViewer(options) {
  10458. var _this$container,
  10459. _this$viewer,
  10460. _this = this;
  10461. _classCallCheck(this, BaseViewer);
  10462. if (this.constructor === BaseViewer) {
  10463. throw new Error("Cannot initialize BaseViewer.");
  10464. }
  10465. var viewerVersion = '2.7.570';
  10466. if (_pdfjsLib.version !== viewerVersion) {
  10467. throw new Error("The API version \"".concat(_pdfjsLib.version, "\" does not match the Viewer version \"").concat(viewerVersion, "\"."));
  10468. }
  10469. this._name = this.constructor.name;
  10470. this.container = options.container;
  10471. this.viewer = options.viewer || options.container.firstElementChild;
  10472. if (!(((_this$container = this.container) === null || _this$container === void 0 ? void 0 : _this$container.tagName.toUpperCase()) === "DIV" && ((_this$viewer = this.viewer) === null || _this$viewer === void 0 ? void 0 : _this$viewer.tagName.toUpperCase()) === "DIV")) {
  10473. throw new Error("Invalid `container` and/or `viewer` option.");
  10474. }
  10475. if (getComputedStyle(this.container).position !== "absolute") {
  10476. throw new Error("The `container` must be absolutely positioned.");
  10477. }
  10478. this.eventBus = options.eventBus;
  10479. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  10480. this.downloadManager = options.downloadManager || null;
  10481. this.findController = options.findController || null;
  10482. this.removePageBorders = options.removePageBorders || false;
  10483. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  10484. this.imageResourcesPath = options.imageResourcesPath || "";
  10485. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  10486. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  10487. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  10488. this.enableWebGL = options.enableWebGL || false;
  10489. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  10490. this.maxCanvasPixels = options.maxCanvasPixels;
  10491. this.l10n = options.l10n || _ui_utils.NullL10n;
  10492. this.enableScripting = options.enableScripting || false;
  10493. this._mouseState = options.mouseState || null;
  10494. this.defaultRenderingQueue = !options.renderingQueue;
  10495. if (this.defaultRenderingQueue) {
  10496. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  10497. this.renderingQueue.setViewer(this);
  10498. } else {
  10499. this.renderingQueue = options.renderingQueue;
  10500. }
  10501. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  10502. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  10503. this._onBeforeDraw = this._onAfterDraw = null;
  10504. this._resetView();
  10505. if (this.removePageBorders) {
  10506. this.viewer.classList.add("removePageBorders");
  10507. }
  10508. Promise.resolve().then(function () {
  10509. _this.eventBus.dispatch("baseviewerinit", {
  10510. source: _this
  10511. });
  10512. });
  10513. }
  10514. _createClass(BaseViewer, [{
  10515. key: "getPageView",
  10516. value: function getPageView(index) {
  10517. return this._pages[index];
  10518. }
  10519. }, {
  10520. key: "_setCurrentPageNumber",
  10521. value: function _setCurrentPageNumber(val) {
  10522. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10523. if (this._currentPageNumber === val) {
  10524. if (resetCurrentPageView) {
  10525. this._resetCurrentPageView();
  10526. }
  10527. return true;
  10528. }
  10529. if (!(0 < val && val <= this.pagesCount)) {
  10530. return false;
  10531. }
  10532. var previous = this._currentPageNumber;
  10533. this._currentPageNumber = val;
  10534. this.eventBus.dispatch("pagechanging", {
  10535. source: this,
  10536. pageNumber: val,
  10537. pageLabel: this._pageLabels && this._pageLabels[val - 1],
  10538. previous: previous
  10539. });
  10540. if (resetCurrentPageView) {
  10541. this._resetCurrentPageView();
  10542. }
  10543. return true;
  10544. }
  10545. }, {
  10546. key: "_onePageRenderedOrForceFetch",
  10547. value: function _onePageRenderedOrForceFetch() {
  10548. if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  10549. return Promise.resolve();
  10550. }
  10551. return this._onePageRenderedCapability.promise;
  10552. }
  10553. }, {
  10554. key: "setDocument",
  10555. value: function setDocument(pdfDocument) {
  10556. var _this2 = this;
  10557. if (this.pdfDocument) {
  10558. this.eventBus.dispatch("pagesdestroy", {
  10559. source: this
  10560. });
  10561. this._cancelRendering();
  10562. this._resetView();
  10563. if (this.findController) {
  10564. this.findController.setDocument(null);
  10565. }
  10566. }
  10567. this.pdfDocument = pdfDocument;
  10568. if (!pdfDocument) {
  10569. return;
  10570. }
  10571. var pagesCount = pdfDocument.numPages;
  10572. var firstPagePromise = pdfDocument.getPage(1);
  10573. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  10574. this._pagesCapability.promise.then(function () {
  10575. _this2.eventBus.dispatch("pagesloaded", {
  10576. source: _this2,
  10577. pagesCount: pagesCount
  10578. });
  10579. });
  10580. this._onBeforeDraw = function (evt) {
  10581. var pageView = _this2._pages[evt.pageNumber - 1];
  10582. if (!pageView) {
  10583. return;
  10584. }
  10585. _this2._buffer.push(pageView);
  10586. };
  10587. this.eventBus._on("pagerender", this._onBeforeDraw);
  10588. this._onAfterDraw = function (evt) {
  10589. if (evt.cssTransform || _this2._onePageRenderedCapability.settled) {
  10590. return;
  10591. }
  10592. _this2._onePageRenderedCapability.resolve();
  10593. _this2.eventBus._off("pagerendered", _this2._onAfterDraw);
  10594. _this2._onAfterDraw = null;
  10595. };
  10596. this.eventBus._on("pagerendered", this._onAfterDraw);
  10597. firstPagePromise.then(function (firstPdfPage) {
  10598. _this2._firstPageCapability.resolve(firstPdfPage);
  10599. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  10600. var scale = _this2.currentScale;
  10601. var viewport = firstPdfPage.getViewport({
  10602. scale: scale * _ui_utils.CSS_UNITS
  10603. });
  10604. var textLayerFactory = _this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? _this2 : null;
  10605. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  10606. var pageView = new _pdf_page_view.PDFPageView({
  10607. container: _this2._viewerElement,
  10608. eventBus: _this2.eventBus,
  10609. id: pageNum,
  10610. scale: scale,
  10611. defaultViewport: viewport.clone(),
  10612. optionalContentConfigPromise: optionalContentConfigPromise,
  10613. renderingQueue: _this2.renderingQueue,
  10614. textLayerFactory: textLayerFactory,
  10615. textLayerMode: _this2.textLayerMode,
  10616. annotationLayerFactory: _this2,
  10617. imageResourcesPath: _this2.imageResourcesPath,
  10618. renderInteractiveForms: _this2.renderInteractiveForms,
  10619. renderer: _this2.renderer,
  10620. enableWebGL: _this2.enableWebGL,
  10621. useOnlyCssZoom: _this2.useOnlyCssZoom,
  10622. maxCanvasPixels: _this2.maxCanvasPixels,
  10623. l10n: _this2.l10n,
  10624. enableScripting: _this2.enableScripting
  10625. });
  10626. _this2._pages.push(pageView);
  10627. }
  10628. var firstPageView = _this2._pages[0];
  10629. if (firstPageView) {
  10630. firstPageView.setPdfPage(firstPdfPage);
  10631. _this2.linkService.cachePageRef(1, firstPdfPage.ref);
  10632. }
  10633. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  10634. _this2._updateSpreadMode();
  10635. }
  10636. _this2._onePageRenderedOrForceFetch().then(function () {
  10637. if (_this2.findController) {
  10638. _this2.findController.setDocument(pdfDocument);
  10639. }
  10640. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
  10641. _this2._pagesCapability.resolve();
  10642. return;
  10643. }
  10644. var getPagesLeft = pagesCount - 1;
  10645. if (getPagesLeft <= 0) {
  10646. _this2._pagesCapability.resolve();
  10647. return;
  10648. }
  10649. var _loop = function _loop(_pageNum) {
  10650. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  10651. var pageView = _this2._pages[_pageNum - 1];
  10652. if (!pageView.pdfPage) {
  10653. pageView.setPdfPage(pdfPage);
  10654. }
  10655. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  10656. if (--getPagesLeft === 0) {
  10657. _this2._pagesCapability.resolve();
  10658. }
  10659. }, function (reason) {
  10660. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  10661. if (--getPagesLeft === 0) {
  10662. _this2._pagesCapability.resolve();
  10663. }
  10664. });
  10665. };
  10666. for (var _pageNum = 2; _pageNum <= pagesCount; ++_pageNum) {
  10667. _loop(_pageNum);
  10668. }
  10669. });
  10670. _this2.eventBus.dispatch("pagesinit", {
  10671. source: _this2
  10672. });
  10673. if (_this2.defaultRenderingQueue) {
  10674. _this2.update();
  10675. }
  10676. })["catch"](function (reason) {
  10677. console.error("Unable to initialize viewer", reason);
  10678. });
  10679. }
  10680. }, {
  10681. key: "setPageLabels",
  10682. value: function setPageLabels(labels) {
  10683. if (!this.pdfDocument) {
  10684. return;
  10685. }
  10686. if (!labels) {
  10687. this._pageLabels = null;
  10688. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  10689. this._pageLabels = null;
  10690. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  10691. } else {
  10692. this._pageLabels = labels;
  10693. }
  10694. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10695. var pageView = this._pages[i];
  10696. var label = this._pageLabels && this._pageLabels[i];
  10697. pageView.setPageLabel(label);
  10698. }
  10699. }
  10700. }, {
  10701. key: "_resetView",
  10702. value: function _resetView() {
  10703. this._pages = [];
  10704. this._currentPageNumber = 1;
  10705. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  10706. this._currentScaleValue = null;
  10707. this._pageLabels = null;
  10708. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  10709. this._location = null;
  10710. this._pagesRotation = 0;
  10711. this._optionalContentConfigPromise = null;
  10712. this._pagesRequests = new WeakMap();
  10713. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  10714. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  10715. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  10716. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  10717. this._spreadMode = _ui_utils.SpreadMode.NONE;
  10718. if (this._onBeforeDraw) {
  10719. this.eventBus._off("pagerender", this._onBeforeDraw);
  10720. this._onBeforeDraw = null;
  10721. }
  10722. if (this._onAfterDraw) {
  10723. this.eventBus._off("pagerendered", this._onAfterDraw);
  10724. this._onAfterDraw = null;
  10725. }
  10726. this._resetScriptingEvents();
  10727. this.viewer.textContent = "";
  10728. this._updateScrollMode();
  10729. }
  10730. }, {
  10731. key: "_scrollUpdate",
  10732. value: function _scrollUpdate() {
  10733. if (this.pagesCount === 0) {
  10734. return;
  10735. }
  10736. this.update();
  10737. }
  10738. }, {
  10739. key: "_scrollIntoView",
  10740. value: function _scrollIntoView(_ref) {
  10741. var pageDiv = _ref.pageDiv,
  10742. _ref$pageSpot = _ref.pageSpot,
  10743. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  10744. _ref$pageNumber = _ref.pageNumber,
  10745. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  10746. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  10747. }
  10748. }, {
  10749. key: "_setScaleUpdatePages",
  10750. value: function _setScaleUpdatePages(newScale, newValue) {
  10751. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  10752. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10753. this._currentScaleValue = newValue.toString();
  10754. if (isSameScale(this._currentScale, newScale)) {
  10755. if (preset) {
  10756. this.eventBus.dispatch("scalechanging", {
  10757. source: this,
  10758. scale: newScale,
  10759. presetValue: newValue
  10760. });
  10761. }
  10762. return;
  10763. }
  10764. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10765. this._pages[i].update(newScale);
  10766. }
  10767. this._currentScale = newScale;
  10768. if (!noScroll) {
  10769. var page = this._currentPageNumber,
  10770. dest;
  10771. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  10772. page = this._location.pageNumber;
  10773. dest = [null, {
  10774. name: "XYZ"
  10775. }, this._location.left, this._location.top, null];
  10776. }
  10777. this.scrollPageIntoView({
  10778. pageNumber: page,
  10779. destArray: dest,
  10780. allowNegativeOffset: true
  10781. });
  10782. }
  10783. this.eventBus.dispatch("scalechanging", {
  10784. source: this,
  10785. scale: newScale,
  10786. presetValue: preset ? newValue : undefined
  10787. });
  10788. if (this.defaultRenderingQueue) {
  10789. this.update();
  10790. }
  10791. }
  10792. }, {
  10793. key: "_setScale",
  10794. value: function _setScale(value) {
  10795. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10796. var scale = parseFloat(value);
  10797. if (scale > 0) {
  10798. this._setScaleUpdatePages(scale, value, noScroll, false);
  10799. } else {
  10800. var currentPage = this._pages[this._currentPageNumber - 1];
  10801. if (!currentPage) {
  10802. return;
  10803. }
  10804. var noPadding = this.isInPresentationMode || this.removePageBorders;
  10805. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  10806. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  10807. if (!noPadding && this._isScrollModeHorizontal) {
  10808. var _ref2 = [vPadding, hPadding];
  10809. hPadding = _ref2[0];
  10810. vPadding = _ref2[1];
  10811. }
  10812. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this._pageWidthScaleFactor;
  10813. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  10814. switch (value) {
  10815. case "page-actual":
  10816. scale = 1;
  10817. break;
  10818. case "page-width":
  10819. scale = pageWidthScale;
  10820. break;
  10821. case "page-height":
  10822. scale = pageHeightScale;
  10823. break;
  10824. case "page-fit":
  10825. scale = Math.min(pageWidthScale, pageHeightScale);
  10826. break;
  10827. case "auto":
  10828. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  10829. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  10830. break;
  10831. default:
  10832. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  10833. return;
  10834. }
  10835. this._setScaleUpdatePages(scale, value, noScroll, true);
  10836. }
  10837. }
  10838. }, {
  10839. key: "_resetCurrentPageView",
  10840. value: function _resetCurrentPageView() {
  10841. if (this.isInPresentationMode) {
  10842. this._setScale(this._currentScaleValue, true);
  10843. }
  10844. var pageView = this._pages[this._currentPageNumber - 1];
  10845. this._scrollIntoView({
  10846. pageDiv: pageView.div
  10847. });
  10848. }
  10849. }, {
  10850. key: "pageLabelToPageNumber",
  10851. value: function pageLabelToPageNumber(label) {
  10852. if (!this._pageLabels) {
  10853. return null;
  10854. }
  10855. var i = this._pageLabels.indexOf(label);
  10856. if (i < 0) {
  10857. return null;
  10858. }
  10859. return i + 1;
  10860. }
  10861. }, {
  10862. key: "scrollPageIntoView",
  10863. value: function scrollPageIntoView(_ref3) {
  10864. var pageNumber = _ref3.pageNumber,
  10865. _ref3$destArray = _ref3.destArray,
  10866. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  10867. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  10868. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf,
  10869. _ref3$ignoreDestinati = _ref3.ignoreDestinationZoom,
  10870. ignoreDestinationZoom = _ref3$ignoreDestinati === void 0 ? false : _ref3$ignoreDestinati;
  10871. if (!this.pdfDocument) {
  10872. return;
  10873. }
  10874. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  10875. if (!pageView) {
  10876. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  10877. return;
  10878. }
  10879. if (this.isInPresentationMode || !destArray) {
  10880. this._setCurrentPageNumber(pageNumber, true);
  10881. return;
  10882. }
  10883. var x = 0,
  10884. y = 0;
  10885. var width = 0,
  10886. height = 0,
  10887. widthScale,
  10888. heightScale;
  10889. var changeOrientation = pageView.rotation % 180 !== 0;
  10890. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  10891. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  10892. var scale = 0;
  10893. switch (destArray[1].name) {
  10894. case "XYZ":
  10895. x = destArray[2];
  10896. y = destArray[3];
  10897. scale = destArray[4];
  10898. x = x !== null ? x : 0;
  10899. y = y !== null ? y : pageHeight;
  10900. break;
  10901. case "Fit":
  10902. case "FitB":
  10903. scale = "page-fit";
  10904. break;
  10905. case "FitH":
  10906. case "FitBH":
  10907. y = destArray[2];
  10908. scale = "page-width";
  10909. if (y === null && this._location) {
  10910. x = this._location.left;
  10911. y = this._location.top;
  10912. } else if (typeof y !== "number") {
  10913. y = pageHeight;
  10914. }
  10915. break;
  10916. case "FitV":
  10917. case "FitBV":
  10918. x = destArray[2];
  10919. width = pageWidth;
  10920. height = pageHeight;
  10921. scale = "page-height";
  10922. break;
  10923. case "FitR":
  10924. x = destArray[2];
  10925. y = destArray[3];
  10926. width = destArray[4] - x;
  10927. height = destArray[5] - y;
  10928. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  10929. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  10930. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  10931. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  10932. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  10933. break;
  10934. default:
  10935. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  10936. return;
  10937. }
  10938. if (!ignoreDestinationZoom) {
  10939. if (scale && scale !== this._currentScale) {
  10940. this.currentScaleValue = scale;
  10941. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  10942. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  10943. }
  10944. }
  10945. if (scale === "page-fit" && !destArray[4]) {
  10946. this._scrollIntoView({
  10947. pageDiv: pageView.div,
  10948. pageNumber: pageNumber
  10949. });
  10950. return;
  10951. }
  10952. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  10953. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  10954. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  10955. if (!allowNegativeOffset) {
  10956. left = Math.max(left, 0);
  10957. top = Math.max(top, 0);
  10958. }
  10959. this._scrollIntoView({
  10960. pageDiv: pageView.div,
  10961. pageSpot: {
  10962. left: left,
  10963. top: top
  10964. },
  10965. pageNumber: pageNumber
  10966. });
  10967. }
  10968. }, {
  10969. key: "_updateLocation",
  10970. value: function _updateLocation(firstPage) {
  10971. var currentScale = this._currentScale;
  10972. var currentScaleValue = this._currentScaleValue;
  10973. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  10974. var pageNumber = firstPage.id;
  10975. var pdfOpenParams = "#page=" + pageNumber;
  10976. pdfOpenParams += "&zoom=" + normalizedScaleValue;
  10977. var currentPageView = this._pages[pageNumber - 1];
  10978. var container = this.container;
  10979. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  10980. var intLeft = Math.round(topLeft[0]);
  10981. var intTop = Math.round(topLeft[1]);
  10982. pdfOpenParams += "," + intLeft + "," + intTop;
  10983. this._location = {
  10984. pageNumber: pageNumber,
  10985. scale: normalizedScaleValue,
  10986. top: intTop,
  10987. left: intLeft,
  10988. rotation: this._pagesRotation,
  10989. pdfOpenParams: pdfOpenParams
  10990. };
  10991. }
  10992. }, {
  10993. key: "_updateHelper",
  10994. value: function _updateHelper(visiblePages) {
  10995. throw new Error("Not implemented: _updateHelper");
  10996. }
  10997. }, {
  10998. key: "update",
  10999. value: function update() {
  11000. var visible = this._getVisiblePages();
  11001. var visiblePages = visible.views,
  11002. numVisiblePages = visiblePages.length;
  11003. if (numVisiblePages === 0) {
  11004. return;
  11005. }
  11006. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  11007. this._buffer.resize(newCacheSize, visiblePages);
  11008. this.renderingQueue.renderHighestPriority(visible);
  11009. this._updateHelper(visiblePages);
  11010. this._updateLocation(visible.first);
  11011. this.eventBus.dispatch("updateviewarea", {
  11012. source: this,
  11013. location: this._location
  11014. });
  11015. }
  11016. }, {
  11017. key: "containsElement",
  11018. value: function containsElement(element) {
  11019. return this.container.contains(element);
  11020. }
  11021. }, {
  11022. key: "focus",
  11023. value: function focus() {
  11024. this.container.focus();
  11025. }
  11026. }, {
  11027. key: "_getCurrentVisiblePage",
  11028. value: function _getCurrentVisiblePage() {
  11029. if (!this.pagesCount) {
  11030. return {
  11031. views: []
  11032. };
  11033. }
  11034. var pageView = this._pages[this._currentPageNumber - 1];
  11035. var element = pageView.div;
  11036. var view = {
  11037. id: pageView.id,
  11038. x: element.offsetLeft + element.clientLeft,
  11039. y: element.offsetTop + element.clientTop,
  11040. view: pageView
  11041. };
  11042. return {
  11043. first: view,
  11044. last: view,
  11045. views: [view]
  11046. };
  11047. }
  11048. }, {
  11049. key: "_getVisiblePages",
  11050. value: function _getVisiblePages() {
  11051. return (0, _ui_utils.getVisibleElements)({
  11052. scrollEl: this.container,
  11053. views: this._pages,
  11054. sortByVisibility: true,
  11055. horizontal: this._isScrollModeHorizontal,
  11056. rtl: this._isScrollModeHorizontal && this._isContainerRtl
  11057. });
  11058. }
  11059. }, {
  11060. key: "isPageVisible",
  11061. value: function isPageVisible(pageNumber) {
  11062. if (!this.pdfDocument) {
  11063. return false;
  11064. }
  11065. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  11066. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is not a valid page."));
  11067. return false;
  11068. }
  11069. return this._getVisiblePages().views.some(function (view) {
  11070. return view.id === pageNumber;
  11071. });
  11072. }
  11073. }, {
  11074. key: "isPageCached",
  11075. value: function isPageCached(pageNumber) {
  11076. if (!this.pdfDocument || !this._buffer) {
  11077. return false;
  11078. }
  11079. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  11080. console.error("".concat(this._name, ".isPageCached: \"").concat(pageNumber, "\" is not a valid page."));
  11081. return false;
  11082. }
  11083. var pageView = this._pages[pageNumber - 1];
  11084. if (!pageView) {
  11085. return false;
  11086. }
  11087. return this._buffer.has(pageView);
  11088. }
  11089. }, {
  11090. key: "cleanup",
  11091. value: function cleanup() {
  11092. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  11093. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  11094. this._pages[i].reset();
  11095. }
  11096. }
  11097. }
  11098. }, {
  11099. key: "_cancelRendering",
  11100. value: function _cancelRendering() {
  11101. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  11102. if (this._pages[i]) {
  11103. this._pages[i].cancelRendering();
  11104. }
  11105. }
  11106. }
  11107. }, {
  11108. key: "_ensurePdfPageLoaded",
  11109. value: function _ensurePdfPageLoaded(pageView) {
  11110. var _this3 = this;
  11111. if (pageView.pdfPage) {
  11112. return Promise.resolve(pageView.pdfPage);
  11113. }
  11114. if (this._pagesRequests.has(pageView)) {
  11115. return this._pagesRequests.get(pageView);
  11116. }
  11117. var promise = this.pdfDocument.getPage(pageView.id).then(function (pdfPage) {
  11118. if (!pageView.pdfPage) {
  11119. pageView.setPdfPage(pdfPage);
  11120. }
  11121. _this3._pagesRequests["delete"](pageView);
  11122. return pdfPage;
  11123. })["catch"](function (reason) {
  11124. console.error("Unable to get page for page view", reason);
  11125. _this3._pagesRequests["delete"](pageView);
  11126. });
  11127. this._pagesRequests.set(pageView, promise);
  11128. return promise;
  11129. }
  11130. }, {
  11131. key: "forceRendering",
  11132. value: function forceRendering(currentlyVisiblePages) {
  11133. var _this4 = this;
  11134. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  11135. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  11136. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  11137. if (pageView) {
  11138. this._ensurePdfPageLoaded(pageView).then(function () {
  11139. _this4.renderingQueue.renderView(pageView);
  11140. });
  11141. return true;
  11142. }
  11143. return false;
  11144. }
  11145. }, {
  11146. key: "createTextLayerBuilder",
  11147. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  11148. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  11149. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  11150. return new _text_layer_builder.TextLayerBuilder({
  11151. textLayerDiv: textLayerDiv,
  11152. eventBus: eventBus,
  11153. pageIndex: pageIndex,
  11154. viewport: viewport,
  11155. findController: this.isInPresentationMode ? null : this.findController,
  11156. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  11157. });
  11158. }
  11159. }, {
  11160. key: "createAnnotationLayerBuilder",
  11161. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  11162. var _this$pdfDocument, _this$pdfDocument2;
  11163. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  11164. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  11165. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  11166. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _ui_utils.NullL10n;
  11167. var enableScripting = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
  11168. var hasJSActionsPromise = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  11169. var mouseState = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
  11170. return new _annotation_layer_builder.AnnotationLayerBuilder({
  11171. pageDiv: pageDiv,
  11172. pdfPage: pdfPage,
  11173. annotationStorage: annotationStorage || ((_this$pdfDocument = this.pdfDocument) === null || _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage),
  11174. imageResourcesPath: imageResourcesPath,
  11175. renderInteractiveForms: renderInteractiveForms,
  11176. linkService: this.linkService,
  11177. downloadManager: this.downloadManager,
  11178. l10n: l10n,
  11179. enableScripting: enableScripting,
  11180. hasJSActionsPromise: hasJSActionsPromise || ((_this$pdfDocument2 = this.pdfDocument) === null || _this$pdfDocument2 === void 0 ? void 0 : _this$pdfDocument2.hasJSActions()),
  11181. mouseState: mouseState || this._mouseState
  11182. });
  11183. }
  11184. }, {
  11185. key: "getPagesOverview",
  11186. value: function getPagesOverview() {
  11187. var pagesOverview = this._pages.map(function (pageView) {
  11188. var viewport = pageView.pdfPage.getViewport({
  11189. scale: 1
  11190. });
  11191. return {
  11192. width: viewport.width,
  11193. height: viewport.height,
  11194. rotation: viewport.rotation
  11195. };
  11196. });
  11197. if (!this.enablePrintAutoRotate) {
  11198. return pagesOverview;
  11199. }
  11200. return pagesOverview.map(function (size) {
  11201. if ((0, _ui_utils.isPortraitOrientation)(size)) {
  11202. return size;
  11203. }
  11204. return {
  11205. width: size.height,
  11206. height: size.width,
  11207. rotation: (size.rotation + 90) % 360
  11208. };
  11209. });
  11210. }
  11211. }, {
  11212. key: "_updateScrollMode",
  11213. value: function _updateScrollMode() {
  11214. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11215. var scrollMode = this._scrollMode,
  11216. viewer = this.viewer;
  11217. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  11218. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  11219. if (!this.pdfDocument || !pageNumber) {
  11220. return;
  11221. }
  11222. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  11223. this._setScale(this._currentScaleValue, true);
  11224. }
  11225. this._setCurrentPageNumber(pageNumber, true);
  11226. this.update();
  11227. }
  11228. }, {
  11229. key: "_updateSpreadMode",
  11230. value: function _updateSpreadMode() {
  11231. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11232. if (!this.pdfDocument) {
  11233. return;
  11234. }
  11235. var viewer = this.viewer,
  11236. pages = this._pages;
  11237. viewer.textContent = "";
  11238. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  11239. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  11240. viewer.appendChild(pages[i].div);
  11241. }
  11242. } else {
  11243. var parity = this._spreadMode - 1;
  11244. var spread = null;
  11245. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  11246. if (spread === null) {
  11247. spread = document.createElement("div");
  11248. spread.className = "spread";
  11249. viewer.appendChild(spread);
  11250. } else if (_i % 2 === parity) {
  11251. spread = spread.cloneNode(false);
  11252. viewer.appendChild(spread);
  11253. }
  11254. spread.appendChild(pages[_i].div);
  11255. }
  11256. }
  11257. if (!pageNumber) {
  11258. return;
  11259. }
  11260. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  11261. this._setScale(this._currentScaleValue, true);
  11262. }
  11263. this._setCurrentPageNumber(pageNumber, true);
  11264. this.update();
  11265. }
  11266. }, {
  11267. key: "_getPageAdvance",
  11268. value: function _getPageAdvance(currentPageNumber) {
  11269. var previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  11270. if (this.isInPresentationMode) {
  11271. return 1;
  11272. }
  11273. switch (this._scrollMode) {
  11274. case _ui_utils.ScrollMode.WRAPPED:
  11275. {
  11276. var _this$_getVisiblePage = this._getVisiblePages(),
  11277. views = _this$_getVisiblePage.views,
  11278. pageLayout = new Map();
  11279. var _iterator = _createForOfIteratorHelper(views),
  11280. _step;
  11281. try {
  11282. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11283. var _step$value = _step.value,
  11284. id = _step$value.id,
  11285. y = _step$value.y,
  11286. percent = _step$value.percent,
  11287. widthPercent = _step$value.widthPercent;
  11288. if (percent === 0 || widthPercent < 100) {
  11289. continue;
  11290. }
  11291. var yArray = pageLayout.get(y);
  11292. if (!yArray) {
  11293. pageLayout.set(y, yArray || (yArray = []));
  11294. }
  11295. yArray.push(id);
  11296. }
  11297. } catch (err) {
  11298. _iterator.e(err);
  11299. } finally {
  11300. _iterator.f();
  11301. }
  11302. var _iterator2 = _createForOfIteratorHelper(pageLayout.values()),
  11303. _step2;
  11304. try {
  11305. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  11306. var _yArray = _step2.value;
  11307. var currentIndex = _yArray.indexOf(currentPageNumber);
  11308. if (currentIndex === -1) {
  11309. continue;
  11310. }
  11311. var numPages = _yArray.length;
  11312. if (numPages === 1) {
  11313. break;
  11314. }
  11315. if (previous) {
  11316. for (var i = currentIndex - 1, ii = 0; i >= ii; i--) {
  11317. var currentId = _yArray[i],
  11318. expectedId = _yArray[i + 1] - 1;
  11319. if (currentId < expectedId) {
  11320. return currentPageNumber - expectedId;
  11321. }
  11322. }
  11323. } else {
  11324. for (var _i2 = currentIndex + 1, _ii = numPages; _i2 < _ii; _i2++) {
  11325. var _currentId = _yArray[_i2],
  11326. _expectedId = _yArray[_i2 - 1] + 1;
  11327. if (_currentId > _expectedId) {
  11328. return _expectedId - currentPageNumber;
  11329. }
  11330. }
  11331. }
  11332. if (previous) {
  11333. var firstId = _yArray[0];
  11334. if (firstId < currentPageNumber) {
  11335. return currentPageNumber - firstId + 1;
  11336. }
  11337. } else {
  11338. var lastId = _yArray[numPages - 1];
  11339. if (lastId > currentPageNumber) {
  11340. return lastId - currentPageNumber + 1;
  11341. }
  11342. }
  11343. break;
  11344. }
  11345. } catch (err) {
  11346. _iterator2.e(err);
  11347. } finally {
  11348. _iterator2.f();
  11349. }
  11350. break;
  11351. }
  11352. case _ui_utils.ScrollMode.HORIZONTAL:
  11353. {
  11354. break;
  11355. }
  11356. case _ui_utils.ScrollMode.VERTICAL:
  11357. {
  11358. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  11359. break;
  11360. }
  11361. var parity = this._spreadMode - 1;
  11362. if (previous && currentPageNumber % 2 !== parity) {
  11363. break;
  11364. } else if (!previous && currentPageNumber % 2 === parity) {
  11365. break;
  11366. }
  11367. var _this$_getVisiblePage2 = this._getVisiblePages(),
  11368. _views = _this$_getVisiblePage2.views,
  11369. _expectedId2 = previous ? currentPageNumber - 1 : currentPageNumber + 1;
  11370. var _iterator3 = _createForOfIteratorHelper(_views),
  11371. _step3;
  11372. try {
  11373. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  11374. var _step3$value = _step3.value,
  11375. _id = _step3$value.id,
  11376. _percent = _step3$value.percent,
  11377. _widthPercent = _step3$value.widthPercent;
  11378. if (_id !== _expectedId2) {
  11379. continue;
  11380. }
  11381. if (_percent > 0 && _widthPercent === 100) {
  11382. return 2;
  11383. }
  11384. break;
  11385. }
  11386. } catch (err) {
  11387. _iterator3.e(err);
  11388. } finally {
  11389. _iterator3.f();
  11390. }
  11391. break;
  11392. }
  11393. }
  11394. return 1;
  11395. }
  11396. }, {
  11397. key: "nextPage",
  11398. value: function nextPage() {
  11399. var currentPageNumber = this._currentPageNumber,
  11400. pagesCount = this.pagesCount;
  11401. if (currentPageNumber >= pagesCount) {
  11402. return false;
  11403. }
  11404. var advance = this._getPageAdvance(currentPageNumber, false) || 1;
  11405. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  11406. return true;
  11407. }
  11408. }, {
  11409. key: "previousPage",
  11410. value: function previousPage() {
  11411. var currentPageNumber = this._currentPageNumber;
  11412. if (currentPageNumber <= 1) {
  11413. return false;
  11414. }
  11415. var advance = this._getPageAdvance(currentPageNumber, true) || 1;
  11416. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  11417. return true;
  11418. }
  11419. }, {
  11420. key: "initializeScriptingEvents",
  11421. value: function initializeScriptingEvents() {
  11422. var _this5 = this;
  11423. if (!this.enableScripting || this._pageOpenPendingSet) {
  11424. return;
  11425. }
  11426. var eventBus = this.eventBus,
  11427. pageOpenPendingSet = this._pageOpenPendingSet = new Set(),
  11428. scriptingEvents = this._scriptingEvents || (this._scriptingEvents = Object.create(null));
  11429. var dispatchPageClose = function dispatchPageClose(pageNumber) {
  11430. if (pageOpenPendingSet.has(pageNumber)) {
  11431. return;
  11432. }
  11433. eventBus.dispatch("pageclose", {
  11434. source: _this5,
  11435. pageNumber: pageNumber
  11436. });
  11437. };
  11438. var dispatchPageOpen = function dispatchPageOpen(pageNumber) {
  11439. var pageView = _this5._pages[pageNumber - 1];
  11440. if ((pageView === null || pageView === void 0 ? void 0 : pageView.renderingState) === _pdf_rendering_queue.RenderingStates.FINISHED) {
  11441. var _pageView$pdfPage;
  11442. pageOpenPendingSet["delete"](pageNumber);
  11443. eventBus.dispatch("pageopen", {
  11444. source: _this5,
  11445. pageNumber: pageNumber,
  11446. actionsPromise: (_pageView$pdfPage = pageView.pdfPage) === null || _pageView$pdfPage === void 0 ? void 0 : _pageView$pdfPage.getJSActions()
  11447. });
  11448. } else {
  11449. pageOpenPendingSet.add(pageNumber);
  11450. }
  11451. };
  11452. scriptingEvents.onPageChanging = function (_ref4) {
  11453. var pageNumber = _ref4.pageNumber,
  11454. previous = _ref4.previous;
  11455. if (pageNumber === previous) {
  11456. return;
  11457. }
  11458. dispatchPageClose(previous);
  11459. dispatchPageOpen(pageNumber);
  11460. };
  11461. eventBus._on("pagechanging", scriptingEvents.onPageChanging);
  11462. scriptingEvents.onPageRendered = function (_ref5) {
  11463. var pageNumber = _ref5.pageNumber;
  11464. if (!pageOpenPendingSet.has(pageNumber)) {
  11465. return;
  11466. }
  11467. if (pageNumber !== _this5._currentPageNumber) {
  11468. return;
  11469. }
  11470. dispatchPageOpen(pageNumber);
  11471. };
  11472. eventBus._on("pagerendered", scriptingEvents.onPageRendered);
  11473. scriptingEvents.onPagesDestroy = function () {
  11474. dispatchPageClose(_this5._currentPageNumber);
  11475. };
  11476. eventBus._on("pagesdestroy", scriptingEvents.onPagesDestroy);
  11477. dispatchPageOpen(this._currentPageNumber);
  11478. }
  11479. }, {
  11480. key: "_resetScriptingEvents",
  11481. value: function _resetScriptingEvents() {
  11482. if (!this.enableScripting || !this._pageOpenPendingSet) {
  11483. return;
  11484. }
  11485. var eventBus = this.eventBus,
  11486. scriptingEvents = this._scriptingEvents;
  11487. eventBus._off("pagechanging", scriptingEvents.onPageChanging);
  11488. scriptingEvents.onPageChanging = null;
  11489. eventBus._off("pagerendered", scriptingEvents.onPageRendered);
  11490. scriptingEvents.onPageRendered = null;
  11491. eventBus._off("pagesdestroy", scriptingEvents.onPagesDestroy);
  11492. scriptingEvents.onPagesDestroy = null;
  11493. this._pageOpenPendingSet = null;
  11494. }
  11495. }, {
  11496. key: "pagesCount",
  11497. get: function get() {
  11498. return this._pages.length;
  11499. }
  11500. }, {
  11501. key: "pageViewsReady",
  11502. get: function get() {
  11503. if (!this._pagesCapability.settled) {
  11504. return false;
  11505. }
  11506. return this._pages.every(function (pageView) {
  11507. return pageView && pageView.pdfPage;
  11508. });
  11509. }
  11510. }, {
  11511. key: "currentPageNumber",
  11512. get: function get() {
  11513. return this._currentPageNumber;
  11514. },
  11515. set: function set(val) {
  11516. if (!Number.isInteger(val)) {
  11517. throw new Error("Invalid page number.");
  11518. }
  11519. if (!this.pdfDocument) {
  11520. return;
  11521. }
  11522. if (!this._setCurrentPageNumber(val, true)) {
  11523. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  11524. }
  11525. }
  11526. }, {
  11527. key: "currentPageLabel",
  11528. get: function get() {
  11529. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  11530. },
  11531. set: function set(val) {
  11532. if (!this.pdfDocument) {
  11533. return;
  11534. }
  11535. var page = val | 0;
  11536. if (this._pageLabels) {
  11537. var i = this._pageLabels.indexOf(val);
  11538. if (i >= 0) {
  11539. page = i + 1;
  11540. }
  11541. }
  11542. if (!this._setCurrentPageNumber(page, true)) {
  11543. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  11544. }
  11545. }
  11546. }, {
  11547. key: "currentScale",
  11548. get: function get() {
  11549. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  11550. },
  11551. set: function set(val) {
  11552. if (isNaN(val)) {
  11553. throw new Error("Invalid numeric scale.");
  11554. }
  11555. if (!this.pdfDocument) {
  11556. return;
  11557. }
  11558. this._setScale(val, false);
  11559. }
  11560. }, {
  11561. key: "currentScaleValue",
  11562. get: function get() {
  11563. return this._currentScaleValue;
  11564. },
  11565. set: function set(val) {
  11566. if (!this.pdfDocument) {
  11567. return;
  11568. }
  11569. this._setScale(val, false);
  11570. }
  11571. }, {
  11572. key: "pagesRotation",
  11573. get: function get() {
  11574. return this._pagesRotation;
  11575. },
  11576. set: function set(rotation) {
  11577. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  11578. throw new Error("Invalid pages rotation angle.");
  11579. }
  11580. if (!this.pdfDocument) {
  11581. return;
  11582. }
  11583. if (this._pagesRotation === rotation) {
  11584. return;
  11585. }
  11586. this._pagesRotation = rotation;
  11587. var pageNumber = this._currentPageNumber;
  11588. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  11589. var pageView = this._pages[i];
  11590. pageView.update(pageView.scale, rotation);
  11591. }
  11592. if (this._currentScaleValue) {
  11593. this._setScale(this._currentScaleValue, true);
  11594. }
  11595. this.eventBus.dispatch("rotationchanging", {
  11596. source: this,
  11597. pagesRotation: rotation,
  11598. pageNumber: pageNumber
  11599. });
  11600. if (this.defaultRenderingQueue) {
  11601. this.update();
  11602. }
  11603. }
  11604. }, {
  11605. key: "firstPagePromise",
  11606. get: function get() {
  11607. return this.pdfDocument ? this._firstPageCapability.promise : null;
  11608. }
  11609. }, {
  11610. key: "onePageRendered",
  11611. get: function get() {
  11612. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  11613. }
  11614. }, {
  11615. key: "pagesPromise",
  11616. get: function get() {
  11617. return this.pdfDocument ? this._pagesCapability.promise : null;
  11618. }
  11619. }, {
  11620. key: "_viewerElement",
  11621. get: function get() {
  11622. throw new Error("Not implemented: _viewerElement");
  11623. }
  11624. }, {
  11625. key: "_pageWidthScaleFactor",
  11626. get: function get() {
  11627. if (this.spreadMode !== _ui_utils.SpreadMode.NONE && this.scrollMode !== _ui_utils.ScrollMode.HORIZONTAL && !this.isInPresentationMode) {
  11628. return 2;
  11629. }
  11630. return 1;
  11631. }
  11632. }, {
  11633. key: "_isScrollModeHorizontal",
  11634. get: function get() {
  11635. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  11636. }
  11637. }, {
  11638. key: "_isContainerRtl",
  11639. get: function get() {
  11640. return getComputedStyle(this.container).direction === "rtl";
  11641. }
  11642. }, {
  11643. key: "isInPresentationMode",
  11644. get: function get() {
  11645. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  11646. }
  11647. }, {
  11648. key: "isChangingPresentationMode",
  11649. get: function get() {
  11650. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  11651. }
  11652. }, {
  11653. key: "isHorizontalScrollbarEnabled",
  11654. get: function get() {
  11655. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  11656. }
  11657. }, {
  11658. key: "isVerticalScrollbarEnabled",
  11659. get: function get() {
  11660. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  11661. }
  11662. }, {
  11663. key: "hasEqualPageSizes",
  11664. get: function get() {
  11665. var firstPageView = this._pages[0];
  11666. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  11667. var pageView = this._pages[i];
  11668. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  11669. return false;
  11670. }
  11671. }
  11672. return true;
  11673. }
  11674. }, {
  11675. key: "optionalContentConfigPromise",
  11676. get: function get() {
  11677. if (!this.pdfDocument) {
  11678. return Promise.resolve(null);
  11679. }
  11680. if (!this._optionalContentConfigPromise) {
  11681. return this.pdfDocument.getOptionalContentConfig();
  11682. }
  11683. return this._optionalContentConfigPromise;
  11684. },
  11685. set: function set(promise) {
  11686. if (!(promise instanceof Promise)) {
  11687. throw new Error("Invalid optionalContentConfigPromise: ".concat(promise));
  11688. }
  11689. if (!this.pdfDocument) {
  11690. return;
  11691. }
  11692. if (!this._optionalContentConfigPromise) {
  11693. return;
  11694. }
  11695. this._optionalContentConfigPromise = promise;
  11696. var _iterator4 = _createForOfIteratorHelper(this._pages),
  11697. _step4;
  11698. try {
  11699. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  11700. var pageView = _step4.value;
  11701. pageView.update(pageView.scale, pageView.rotation, promise);
  11702. }
  11703. } catch (err) {
  11704. _iterator4.e(err);
  11705. } finally {
  11706. _iterator4.f();
  11707. }
  11708. this.update();
  11709. this.eventBus.dispatch("optionalcontentconfigchanged", {
  11710. source: this,
  11711. promise: promise
  11712. });
  11713. }
  11714. }, {
  11715. key: "scrollMode",
  11716. get: function get() {
  11717. return this._scrollMode;
  11718. },
  11719. set: function set(mode) {
  11720. if (this._scrollMode === mode) {
  11721. return;
  11722. }
  11723. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  11724. throw new Error("Invalid scroll mode: ".concat(mode));
  11725. }
  11726. this._scrollMode = mode;
  11727. this.eventBus.dispatch("scrollmodechanged", {
  11728. source: this,
  11729. mode: mode
  11730. });
  11731. this._updateScrollMode(this._currentPageNumber);
  11732. }
  11733. }, {
  11734. key: "spreadMode",
  11735. get: function get() {
  11736. return this._spreadMode;
  11737. },
  11738. set: function set(mode) {
  11739. if (this._spreadMode === mode) {
  11740. return;
  11741. }
  11742. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  11743. throw new Error("Invalid spread mode: ".concat(mode));
  11744. }
  11745. this._spreadMode = mode;
  11746. this.eventBus.dispatch("spreadmodechanged", {
  11747. source: this,
  11748. mode: mode
  11749. });
  11750. this._updateSpreadMode(this._currentPageNumber);
  11751. }
  11752. }]);
  11753. return BaseViewer;
  11754. }();
  11755. exports.BaseViewer = BaseViewer;
  11756. /***/ }),
  11757. /* 30 */
  11758. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11759. Object.defineProperty(exports, "__esModule", ({
  11760. value: true
  11761. }));
  11762. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  11763. var _pdfjsLib = __webpack_require__(7);
  11764. var _ui_utils = __webpack_require__(6);
  11765. var _pdf_link_service = __webpack_require__(21);
  11766. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  11767. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  11768. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  11769. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  11770. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  11771. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  11772. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11773. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11774. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11775. var AnnotationLayerBuilder = /*#__PURE__*/function () {
  11776. function AnnotationLayerBuilder(_ref) {
  11777. var pageDiv = _ref.pageDiv,
  11778. pdfPage = _ref.pdfPage,
  11779. linkService = _ref.linkService,
  11780. downloadManager = _ref.downloadManager,
  11781. _ref$annotationStorag = _ref.annotationStorage,
  11782. annotationStorage = _ref$annotationStorag === void 0 ? null : _ref$annotationStorag,
  11783. _ref$imageResourcesPa = _ref.imageResourcesPath,
  11784. imageResourcesPath = _ref$imageResourcesPa === void 0 ? "" : _ref$imageResourcesPa,
  11785. _ref$renderInteractiv = _ref.renderInteractiveForms,
  11786. renderInteractiveForms = _ref$renderInteractiv === void 0 ? true : _ref$renderInteractiv,
  11787. _ref$l10n = _ref.l10n,
  11788. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n,
  11789. _ref$enableScripting = _ref.enableScripting,
  11790. enableScripting = _ref$enableScripting === void 0 ? false : _ref$enableScripting,
  11791. _ref$hasJSActionsProm = _ref.hasJSActionsPromise,
  11792. hasJSActionsPromise = _ref$hasJSActionsProm === void 0 ? null : _ref$hasJSActionsProm,
  11793. _ref$mouseState = _ref.mouseState,
  11794. mouseState = _ref$mouseState === void 0 ? null : _ref$mouseState;
  11795. _classCallCheck(this, AnnotationLayerBuilder);
  11796. this.pageDiv = pageDiv;
  11797. this.pdfPage = pdfPage;
  11798. this.linkService = linkService;
  11799. this.downloadManager = downloadManager;
  11800. this.imageResourcesPath = imageResourcesPath;
  11801. this.renderInteractiveForms = renderInteractiveForms;
  11802. this.l10n = l10n;
  11803. this.annotationStorage = annotationStorage;
  11804. this.enableScripting = enableScripting;
  11805. this._hasJSActionsPromise = hasJSActionsPromise;
  11806. this._mouseState = mouseState;
  11807. this.div = null;
  11808. this._cancelled = false;
  11809. }
  11810. _createClass(AnnotationLayerBuilder, [{
  11811. key: "render",
  11812. value: function render(viewport) {
  11813. var _this = this;
  11814. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  11815. return Promise.all([this.pdfPage.getAnnotations({
  11816. intent: intent
  11817. }), this._hasJSActionsPromise]).then(function (_ref2) {
  11818. var _ref3 = _slicedToArray(_ref2, 2),
  11819. annotations = _ref3[0],
  11820. _ref3$ = _ref3[1],
  11821. hasJSActions = _ref3$ === void 0 ? false : _ref3$;
  11822. if (_this._cancelled) {
  11823. return;
  11824. }
  11825. if (annotations.length === 0) {
  11826. return;
  11827. }
  11828. var parameters = {
  11829. viewport: viewport.clone({
  11830. dontFlip: true
  11831. }),
  11832. div: _this.div,
  11833. annotations: annotations,
  11834. page: _this.pdfPage,
  11835. imageResourcesPath: _this.imageResourcesPath,
  11836. renderInteractiveForms: _this.renderInteractiveForms,
  11837. linkService: _this.linkService,
  11838. downloadManager: _this.downloadManager,
  11839. annotationStorage: _this.annotationStorage,
  11840. enableScripting: _this.enableScripting,
  11841. hasJSActions: hasJSActions,
  11842. mouseState: _this._mouseState
  11843. };
  11844. if (_this.div) {
  11845. _pdfjsLib.AnnotationLayer.update(parameters);
  11846. } else {
  11847. _this.div = document.createElement("div");
  11848. _this.div.className = "annotationLayer";
  11849. _this.pageDiv.appendChild(_this.div);
  11850. parameters.div = _this.div;
  11851. _pdfjsLib.AnnotationLayer.render(parameters);
  11852. _this.l10n.translate(_this.div);
  11853. }
  11854. });
  11855. }
  11856. }, {
  11857. key: "cancel",
  11858. value: function cancel() {
  11859. this._cancelled = true;
  11860. }
  11861. }, {
  11862. key: "hide",
  11863. value: function hide() {
  11864. if (!this.div) {
  11865. return;
  11866. }
  11867. this.div.setAttribute("hidden", "true");
  11868. }
  11869. }]);
  11870. return AnnotationLayerBuilder;
  11871. }();
  11872. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  11873. var DefaultAnnotationLayerFactory = /*#__PURE__*/function () {
  11874. function DefaultAnnotationLayerFactory() {
  11875. _classCallCheck(this, DefaultAnnotationLayerFactory);
  11876. }
  11877. _createClass(DefaultAnnotationLayerFactory, [{
  11878. key: "createAnnotationLayerBuilder",
  11879. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  11880. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  11881. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  11882. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  11883. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _ui_utils.NullL10n;
  11884. var enableScripting = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
  11885. var hasJSActionsPromise = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  11886. var mouseState = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
  11887. return new AnnotationLayerBuilder({
  11888. pageDiv: pageDiv,
  11889. pdfPage: pdfPage,
  11890. imageResourcesPath: imageResourcesPath,
  11891. renderInteractiveForms: renderInteractiveForms,
  11892. linkService: new _pdf_link_service.SimpleLinkService(),
  11893. l10n: l10n,
  11894. annotationStorage: annotationStorage,
  11895. enableScripting: enableScripting,
  11896. hasJSActionsPromise: hasJSActionsPromise,
  11897. mouseState: mouseState
  11898. });
  11899. }
  11900. }]);
  11901. return DefaultAnnotationLayerFactory;
  11902. }();
  11903. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  11904. /***/ }),
  11905. /* 31 */
  11906. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11907. Object.defineProperty(exports, "__esModule", ({
  11908. value: true
  11909. }));
  11910. exports.PDFPageView = void 0;
  11911. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  11912. var _ui_utils = __webpack_require__(6);
  11913. var _pdfjsLib = __webpack_require__(7);
  11914. var _pdf_rendering_queue = __webpack_require__(10);
  11915. var _viewer_compatibility = __webpack_require__(2);
  11916. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11917. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  11918. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  11919. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11920. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11921. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11922. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  11923. var PDFPageView = /*#__PURE__*/function () {
  11924. function PDFPageView(options) {
  11925. _classCallCheck(this, PDFPageView);
  11926. var container = options.container;
  11927. var defaultViewport = options.defaultViewport;
  11928. this.id = options.id;
  11929. this.renderingId = "page" + this.id;
  11930. this.pdfPage = null;
  11931. this.pageLabel = null;
  11932. this.rotation = 0;
  11933. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  11934. this.viewport = defaultViewport;
  11935. this.pdfPageRotate = defaultViewport.rotation;
  11936. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  11937. this.hasRestrictedScaling = false;
  11938. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  11939. this.imageResourcesPath = options.imageResourcesPath || "";
  11940. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  11941. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  11942. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  11943. this.eventBus = options.eventBus;
  11944. this.renderingQueue = options.renderingQueue;
  11945. this.textLayerFactory = options.textLayerFactory;
  11946. this.annotationLayerFactory = options.annotationLayerFactory;
  11947. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  11948. this.enableWebGL = options.enableWebGL || false;
  11949. this.l10n = options.l10n || _ui_utils.NullL10n;
  11950. this.enableScripting = options.enableScripting || false;
  11951. this.paintTask = null;
  11952. this.paintedViewportMap = new WeakMap();
  11953. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  11954. this.resume = null;
  11955. this._renderError = null;
  11956. this.annotationLayer = null;
  11957. this.textLayer = null;
  11958. this.zoomLayer = null;
  11959. var div = document.createElement("div");
  11960. div.className = "page";
  11961. div.style.width = Math.floor(this.viewport.width) + "px";
  11962. div.style.height = Math.floor(this.viewport.height) + "px";
  11963. div.setAttribute("data-page-number", this.id);
  11964. this.div = div;
  11965. container.appendChild(div);
  11966. }
  11967. _createClass(PDFPageView, [{
  11968. key: "setPdfPage",
  11969. value: function setPdfPage(pdfPage) {
  11970. this.pdfPage = pdfPage;
  11971. this.pdfPageRotate = pdfPage.rotate;
  11972. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  11973. this.viewport = pdfPage.getViewport({
  11974. scale: this.scale * _ui_utils.CSS_UNITS,
  11975. rotation: totalRotation
  11976. });
  11977. this.reset();
  11978. }
  11979. }, {
  11980. key: "destroy",
  11981. value: function destroy() {
  11982. this.reset();
  11983. if (this.pdfPage) {
  11984. this.pdfPage.cleanup();
  11985. }
  11986. }
  11987. }, {
  11988. key: "_renderAnnotationLayer",
  11989. value: function () {
  11990. var _renderAnnotationLayer2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  11991. var error;
  11992. return _regenerator["default"].wrap(function _callee$(_context) {
  11993. while (1) {
  11994. switch (_context.prev = _context.next) {
  11995. case 0:
  11996. error = null;
  11997. _context.prev = 1;
  11998. _context.next = 4;
  11999. return this.annotationLayer.render(this.viewport, "display");
  12000. case 4:
  12001. _context.next = 9;
  12002. break;
  12003. case 6:
  12004. _context.prev = 6;
  12005. _context.t0 = _context["catch"](1);
  12006. error = _context.t0;
  12007. case 9:
  12008. _context.prev = 9;
  12009. this.eventBus.dispatch("annotationlayerrendered", {
  12010. source: this,
  12011. pageNumber: this.id,
  12012. error: error
  12013. });
  12014. return _context.finish(9);
  12015. case 12:
  12016. case "end":
  12017. return _context.stop();
  12018. }
  12019. }
  12020. }, _callee, this, [[1, 6, 9, 12]]);
  12021. }));
  12022. function _renderAnnotationLayer() {
  12023. return _renderAnnotationLayer2.apply(this, arguments);
  12024. }
  12025. return _renderAnnotationLayer;
  12026. }()
  12027. }, {
  12028. key: "_resetZoomLayer",
  12029. value: function _resetZoomLayer() {
  12030. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12031. if (!this.zoomLayer) {
  12032. return;
  12033. }
  12034. var zoomLayerCanvas = this.zoomLayer.firstChild;
  12035. this.paintedViewportMap["delete"](zoomLayerCanvas);
  12036. zoomLayerCanvas.width = 0;
  12037. zoomLayerCanvas.height = 0;
  12038. if (removeFromDOM) {
  12039. this.zoomLayer.remove();
  12040. }
  12041. this.zoomLayer = null;
  12042. }
  12043. }, {
  12044. key: "reset",
  12045. value: function reset() {
  12046. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12047. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12048. this.cancelRendering(keepAnnotations);
  12049. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  12050. var div = this.div;
  12051. div.style.width = Math.floor(this.viewport.width) + "px";
  12052. div.style.height = Math.floor(this.viewport.height) + "px";
  12053. var childNodes = div.childNodes;
  12054. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  12055. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  12056. for (var i = childNodes.length - 1; i >= 0; i--) {
  12057. var node = childNodes[i];
  12058. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  12059. continue;
  12060. }
  12061. div.removeChild(node);
  12062. }
  12063. div.removeAttribute("data-loaded");
  12064. if (currentAnnotationNode) {
  12065. this.annotationLayer.hide();
  12066. } else if (this.annotationLayer) {
  12067. this.annotationLayer.cancel();
  12068. this.annotationLayer = null;
  12069. }
  12070. if (!currentZoomLayerNode) {
  12071. if (this.canvas) {
  12072. this.paintedViewportMap["delete"](this.canvas);
  12073. this.canvas.width = 0;
  12074. this.canvas.height = 0;
  12075. delete this.canvas;
  12076. }
  12077. this._resetZoomLayer();
  12078. }
  12079. if (this.svg) {
  12080. this.paintedViewportMap["delete"](this.svg);
  12081. delete this.svg;
  12082. }
  12083. this.loadingIconDiv = document.createElement("div");
  12084. this.loadingIconDiv.className = "loadingIcon";
  12085. div.appendChild(this.loadingIconDiv);
  12086. }
  12087. }, {
  12088. key: "update",
  12089. value: function update(scale, rotation) {
  12090. var optionalContentConfigPromise = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  12091. this.scale = scale || this.scale;
  12092. if (typeof rotation !== "undefined") {
  12093. this.rotation = rotation;
  12094. }
  12095. if (optionalContentConfigPromise instanceof Promise) {
  12096. this._optionalContentConfigPromise = optionalContentConfigPromise;
  12097. }
  12098. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  12099. this.viewport = this.viewport.clone({
  12100. scale: this.scale * _ui_utils.CSS_UNITS,
  12101. rotation: totalRotation
  12102. });
  12103. if (this.svg) {
  12104. this.cssTransform(this.svg, true);
  12105. this.eventBus.dispatch("pagerendered", {
  12106. source: this,
  12107. pageNumber: this.id,
  12108. cssTransform: true,
  12109. timestamp: performance.now(),
  12110. error: this._renderError
  12111. });
  12112. return;
  12113. }
  12114. var isScalingRestricted = false;
  12115. if (this.canvas && this.maxCanvasPixels > 0) {
  12116. var outputScale = this.outputScale;
  12117. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  12118. isScalingRestricted = true;
  12119. }
  12120. }
  12121. if (this.canvas) {
  12122. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  12123. this.cssTransform(this.canvas, true);
  12124. this.eventBus.dispatch("pagerendered", {
  12125. source: this,
  12126. pageNumber: this.id,
  12127. cssTransform: true,
  12128. timestamp: performance.now(),
  12129. error: this._renderError
  12130. });
  12131. return;
  12132. }
  12133. if (!this.zoomLayer && !this.canvas.hasAttribute("hidden")) {
  12134. this.zoomLayer = this.canvas.parentNode;
  12135. this.zoomLayer.style.position = "absolute";
  12136. }
  12137. }
  12138. if (this.zoomLayer) {
  12139. this.cssTransform(this.zoomLayer.firstChild);
  12140. }
  12141. this.reset(true, true);
  12142. }
  12143. }, {
  12144. key: "cancelRendering",
  12145. value: function cancelRendering() {
  12146. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12147. if (this.paintTask) {
  12148. this.paintTask.cancel();
  12149. this.paintTask = null;
  12150. }
  12151. this.resume = null;
  12152. if (this.textLayer) {
  12153. this.textLayer.cancel();
  12154. this.textLayer = null;
  12155. }
  12156. if (!keepAnnotations && this.annotationLayer) {
  12157. this.annotationLayer.cancel();
  12158. this.annotationLayer = null;
  12159. }
  12160. }
  12161. }, {
  12162. key: "cssTransform",
  12163. value: function cssTransform(target) {
  12164. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12165. var width = this.viewport.width;
  12166. var height = this.viewport.height;
  12167. var div = this.div;
  12168. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
  12169. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
  12170. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  12171. var absRotation = Math.abs(relativeRotation);
  12172. var scaleX = 1,
  12173. scaleY = 1;
  12174. if (absRotation === 90 || absRotation === 270) {
  12175. scaleX = height / width;
  12176. scaleY = width / height;
  12177. }
  12178. target.style.transform = "rotate(".concat(relativeRotation, "deg) scale(").concat(scaleX, ", ").concat(scaleY, ")");
  12179. if (this.textLayer) {
  12180. var textLayerViewport = this.textLayer.viewport;
  12181. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  12182. var textAbsRotation = Math.abs(textRelativeRotation);
  12183. var scale = width / textLayerViewport.width;
  12184. if (textAbsRotation === 90 || textAbsRotation === 270) {
  12185. scale = width / textLayerViewport.height;
  12186. }
  12187. var textLayerDiv = this.textLayer.textLayerDiv;
  12188. var transX, transY;
  12189. switch (textAbsRotation) {
  12190. case 0:
  12191. transX = transY = 0;
  12192. break;
  12193. case 90:
  12194. transX = 0;
  12195. transY = "-" + textLayerDiv.style.height;
  12196. break;
  12197. case 180:
  12198. transX = "-" + textLayerDiv.style.width;
  12199. transY = "-" + textLayerDiv.style.height;
  12200. break;
  12201. case 270:
  12202. transX = "-" + textLayerDiv.style.width;
  12203. transY = 0;
  12204. break;
  12205. default:
  12206. console.error("Bad rotation value.");
  12207. break;
  12208. }
  12209. textLayerDiv.style.transform = "rotate(".concat(textAbsRotation, "deg) ") + "scale(".concat(scale, ") ") + "translate(".concat(transX, ", ").concat(transY, ")");
  12210. textLayerDiv.style.transformOrigin = "0% 0%";
  12211. }
  12212. if (redrawAnnotations && this.annotationLayer) {
  12213. this._renderAnnotationLayer();
  12214. }
  12215. }
  12216. }, {
  12217. key: "getPagePoint",
  12218. value: function getPagePoint(x, y) {
  12219. return this.viewport.convertToPdfPoint(x, y);
  12220. }
  12221. }, {
  12222. key: "draw",
  12223. value: function draw() {
  12224. var _this = this;
  12225. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  12226. console.error("Must be in new state before drawing");
  12227. this.reset();
  12228. }
  12229. var div = this.div,
  12230. pdfPage = this.pdfPage;
  12231. if (!pdfPage) {
  12232. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  12233. if (this.loadingIconDiv) {
  12234. div.removeChild(this.loadingIconDiv);
  12235. delete this.loadingIconDiv;
  12236. }
  12237. return Promise.reject(new Error("pdfPage is not loaded"));
  12238. }
  12239. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  12240. var canvasWrapper = document.createElement("div");
  12241. canvasWrapper.style.width = div.style.width;
  12242. canvasWrapper.style.height = div.style.height;
  12243. canvasWrapper.classList.add("canvasWrapper");
  12244. if (this.annotationLayer && this.annotationLayer.div) {
  12245. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  12246. } else {
  12247. div.appendChild(canvasWrapper);
  12248. }
  12249. var textLayer = null;
  12250. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  12251. var textLayerDiv = document.createElement("div");
  12252. textLayerDiv.className = "textLayer";
  12253. textLayerDiv.style.width = canvasWrapper.style.width;
  12254. textLayerDiv.style.height = canvasWrapper.style.height;
  12255. if (this.annotationLayer && this.annotationLayer.div) {
  12256. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  12257. } else {
  12258. div.appendChild(textLayerDiv);
  12259. }
  12260. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, this.eventBus);
  12261. }
  12262. this.textLayer = textLayer;
  12263. var renderContinueCallback = null;
  12264. if (this.renderingQueue) {
  12265. renderContinueCallback = function renderContinueCallback(cont) {
  12266. if (!_this.renderingQueue.isHighestPriority(_this)) {
  12267. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  12268. _this.resume = function () {
  12269. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  12270. cont();
  12271. };
  12272. return;
  12273. }
  12274. cont();
  12275. };
  12276. }
  12277. var finishPaintTask = /*#__PURE__*/function () {
  12278. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  12279. var error,
  12280. _args2 = arguments;
  12281. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12282. while (1) {
  12283. switch (_context2.prev = _context2.next) {
  12284. case 0:
  12285. error = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : null;
  12286. if (paintTask === _this.paintTask) {
  12287. _this.paintTask = null;
  12288. }
  12289. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  12290. _context2.next = 5;
  12291. break;
  12292. }
  12293. _this._renderError = null;
  12294. return _context2.abrupt("return");
  12295. case 5:
  12296. _this._renderError = error;
  12297. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  12298. if (_this.loadingIconDiv) {
  12299. div.removeChild(_this.loadingIconDiv);
  12300. delete _this.loadingIconDiv;
  12301. }
  12302. _this._resetZoomLayer(true);
  12303. _this.eventBus.dispatch("pagerendered", {
  12304. source: _this,
  12305. pageNumber: _this.id,
  12306. cssTransform: false,
  12307. timestamp: performance.now(),
  12308. error: _this._renderError
  12309. });
  12310. if (!error) {
  12311. _context2.next = 12;
  12312. break;
  12313. }
  12314. throw error;
  12315. case 12:
  12316. case "end":
  12317. return _context2.stop();
  12318. }
  12319. }
  12320. }, _callee2);
  12321. }));
  12322. return function finishPaintTask() {
  12323. return _ref.apply(this, arguments);
  12324. };
  12325. }();
  12326. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  12327. paintTask.onRenderContinue = renderContinueCallback;
  12328. this.paintTask = paintTask;
  12329. var resultPromise = paintTask.promise.then(function () {
  12330. return finishPaintTask(null).then(function () {
  12331. if (textLayer) {
  12332. var readableStream = pdfPage.streamTextContent({
  12333. normalizeWhitespace: true
  12334. });
  12335. textLayer.setTextContentStream(readableStream);
  12336. textLayer.render();
  12337. }
  12338. });
  12339. }, function (reason) {
  12340. return finishPaintTask(reason);
  12341. });
  12342. if (this.annotationLayerFactory) {
  12343. if (!this.annotationLayer) {
  12344. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, null, this.imageResourcesPath, this.renderInteractiveForms, this.l10n, this.enableScripting, null, null);
  12345. }
  12346. this._renderAnnotationLayer();
  12347. }
  12348. div.setAttribute("data-loaded", true);
  12349. this.eventBus.dispatch("pagerender", {
  12350. source: this,
  12351. pageNumber: this.id
  12352. });
  12353. return resultPromise;
  12354. }
  12355. }, {
  12356. key: "paintOnCanvas",
  12357. value: function paintOnCanvas(canvasWrapper) {
  12358. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  12359. var result = {
  12360. promise: renderCapability.promise,
  12361. onRenderContinue: function onRenderContinue(cont) {
  12362. cont();
  12363. },
  12364. cancel: function cancel() {
  12365. renderTask.cancel();
  12366. }
  12367. };
  12368. var viewport = this.viewport;
  12369. var canvas = document.createElement("canvas");
  12370. this.l10n.get("page_canvas", {
  12371. page: this.id
  12372. }, "Page {{page}}").then(function (msg) {
  12373. canvas.setAttribute("aria-label", msg);
  12374. });
  12375. canvas.setAttribute("hidden", "hidden");
  12376. var isCanvasHidden = true;
  12377. var showCanvas = function showCanvas() {
  12378. if (isCanvasHidden) {
  12379. canvas.removeAttribute("hidden");
  12380. isCanvasHidden = false;
  12381. }
  12382. };
  12383. canvasWrapper.appendChild(canvas);
  12384. this.canvas = canvas;
  12385. canvas.mozOpaque = true;
  12386. var ctx = canvas.getContext("2d", {
  12387. alpha: false
  12388. });
  12389. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  12390. this.outputScale = outputScale;
  12391. if (this.useOnlyCssZoom) {
  12392. var actualSizeViewport = viewport.clone({
  12393. scale: _ui_utils.CSS_UNITS
  12394. });
  12395. outputScale.sx *= actualSizeViewport.width / viewport.width;
  12396. outputScale.sy *= actualSizeViewport.height / viewport.height;
  12397. outputScale.scaled = true;
  12398. }
  12399. if (this.maxCanvasPixels > 0) {
  12400. var pixelsInViewport = viewport.width * viewport.height;
  12401. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  12402. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  12403. outputScale.sx = maxScale;
  12404. outputScale.sy = maxScale;
  12405. outputScale.scaled = true;
  12406. this.hasRestrictedScaling = true;
  12407. } else {
  12408. this.hasRestrictedScaling = false;
  12409. }
  12410. }
  12411. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  12412. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  12413. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  12414. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  12415. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
  12416. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
  12417. this.paintedViewportMap.set(canvas, viewport);
  12418. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  12419. var renderContext = {
  12420. canvasContext: ctx,
  12421. transform: transform,
  12422. viewport: this.viewport,
  12423. enableWebGL: this.enableWebGL,
  12424. renderInteractiveForms: this.renderInteractiveForms,
  12425. optionalContentConfigPromise: this._optionalContentConfigPromise
  12426. };
  12427. var renderTask = this.pdfPage.render(renderContext);
  12428. renderTask.onContinue = function (cont) {
  12429. showCanvas();
  12430. if (result.onRenderContinue) {
  12431. result.onRenderContinue(cont);
  12432. } else {
  12433. cont();
  12434. }
  12435. };
  12436. renderTask.promise.then(function () {
  12437. showCanvas();
  12438. renderCapability.resolve(undefined);
  12439. }, function (error) {
  12440. showCanvas();
  12441. renderCapability.reject(error);
  12442. });
  12443. return result;
  12444. }
  12445. }, {
  12446. key: "paintOnSvg",
  12447. value: function paintOnSvg(wrapper) {
  12448. var _this2 = this;
  12449. var cancelled = false;
  12450. var ensureNotCancelled = function ensureNotCancelled() {
  12451. if (cancelled) {
  12452. throw new _pdfjsLib.RenderingCancelledException("Rendering cancelled, page ".concat(_this2.id), "svg");
  12453. }
  12454. };
  12455. var pdfPage = this.pdfPage;
  12456. var actualSizeViewport = this.viewport.clone({
  12457. scale: _ui_utils.CSS_UNITS
  12458. });
  12459. var promise = pdfPage.getOperatorList().then(function (opList) {
  12460. ensureNotCancelled();
  12461. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  12462. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  12463. ensureNotCancelled();
  12464. _this2.svg = svg;
  12465. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  12466. svg.style.width = wrapper.style.width;
  12467. svg.style.height = wrapper.style.height;
  12468. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  12469. wrapper.appendChild(svg);
  12470. });
  12471. });
  12472. return {
  12473. promise: promise,
  12474. onRenderContinue: function onRenderContinue(cont) {
  12475. cont();
  12476. },
  12477. cancel: function cancel() {
  12478. cancelled = true;
  12479. }
  12480. };
  12481. }
  12482. }, {
  12483. key: "setPageLabel",
  12484. value: function setPageLabel(label) {
  12485. this.pageLabel = typeof label === "string" ? label : null;
  12486. if (this.pageLabel !== null) {
  12487. this.div.setAttribute("data-page-label", this.pageLabel);
  12488. } else {
  12489. this.div.removeAttribute("data-page-label");
  12490. }
  12491. }
  12492. }, {
  12493. key: "width",
  12494. get: function get() {
  12495. return this.viewport.width;
  12496. }
  12497. }, {
  12498. key: "height",
  12499. get: function get() {
  12500. return this.viewport.height;
  12501. }
  12502. }]);
  12503. return PDFPageView;
  12504. }();
  12505. exports.PDFPageView = PDFPageView;
  12506. /***/ }),
  12507. /* 32 */
  12508. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12509. Object.defineProperty(exports, "__esModule", ({
  12510. value: true
  12511. }));
  12512. exports.TextLayerBuilder = exports.DefaultTextLayerFactory = void 0;
  12513. var _pdfjsLib = __webpack_require__(7);
  12514. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12515. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12516. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12517. var EXPAND_DIVS_TIMEOUT = 300;
  12518. var TextLayerBuilder = /*#__PURE__*/function () {
  12519. function TextLayerBuilder(_ref) {
  12520. var textLayerDiv = _ref.textLayerDiv,
  12521. eventBus = _ref.eventBus,
  12522. pageIndex = _ref.pageIndex,
  12523. viewport = _ref.viewport,
  12524. _ref$findController = _ref.findController,
  12525. findController = _ref$findController === void 0 ? null : _ref$findController,
  12526. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  12527. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  12528. _classCallCheck(this, TextLayerBuilder);
  12529. this.textLayerDiv = textLayerDiv;
  12530. this.eventBus = eventBus;
  12531. this.textContent = null;
  12532. this.textContentItemsStr = [];
  12533. this.textContentStream = null;
  12534. this.renderingDone = false;
  12535. this.pageIdx = pageIndex;
  12536. this.pageNumber = this.pageIdx + 1;
  12537. this.matches = [];
  12538. this.viewport = viewport;
  12539. this.textDivs = [];
  12540. this.findController = findController;
  12541. this.textLayerRenderTask = null;
  12542. this.enhanceTextSelection = enhanceTextSelection;
  12543. this._onUpdateTextLayerMatches = null;
  12544. this._bindMouse();
  12545. }
  12546. _createClass(TextLayerBuilder, [{
  12547. key: "_finishRendering",
  12548. value: function _finishRendering() {
  12549. this.renderingDone = true;
  12550. if (!this.enhanceTextSelection) {
  12551. var endOfContent = document.createElement("div");
  12552. endOfContent.className = "endOfContent";
  12553. this.textLayerDiv.appendChild(endOfContent);
  12554. }
  12555. this.eventBus.dispatch("textlayerrendered", {
  12556. source: this,
  12557. pageNumber: this.pageNumber,
  12558. numTextDivs: this.textDivs.length
  12559. });
  12560. }
  12561. }, {
  12562. key: "render",
  12563. value: function render() {
  12564. var _this = this;
  12565. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  12566. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  12567. return;
  12568. }
  12569. this.cancel();
  12570. this.textDivs = [];
  12571. var textLayerFrag = document.createDocumentFragment();
  12572. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  12573. textContent: this.textContent,
  12574. textContentStream: this.textContentStream,
  12575. container: textLayerFrag,
  12576. viewport: this.viewport,
  12577. textDivs: this.textDivs,
  12578. textContentItemsStr: this.textContentItemsStr,
  12579. timeout: timeout,
  12580. enhanceTextSelection: this.enhanceTextSelection
  12581. });
  12582. this.textLayerRenderTask.promise.then(function () {
  12583. _this.textLayerDiv.appendChild(textLayerFrag);
  12584. _this._finishRendering();
  12585. _this._updateMatches();
  12586. }, function (reason) {});
  12587. if (!this._onUpdateTextLayerMatches) {
  12588. this._onUpdateTextLayerMatches = function (evt) {
  12589. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  12590. _this._updateMatches();
  12591. }
  12592. };
  12593. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  12594. }
  12595. }
  12596. }, {
  12597. key: "cancel",
  12598. value: function cancel() {
  12599. if (this.textLayerRenderTask) {
  12600. this.textLayerRenderTask.cancel();
  12601. this.textLayerRenderTask = null;
  12602. }
  12603. if (this._onUpdateTextLayerMatches) {
  12604. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  12605. this._onUpdateTextLayerMatches = null;
  12606. }
  12607. }
  12608. }, {
  12609. key: "setTextContentStream",
  12610. value: function setTextContentStream(readableStream) {
  12611. this.cancel();
  12612. this.textContentStream = readableStream;
  12613. }
  12614. }, {
  12615. key: "setTextContent",
  12616. value: function setTextContent(textContent) {
  12617. this.cancel();
  12618. this.textContent = textContent;
  12619. }
  12620. }, {
  12621. key: "_convertMatches",
  12622. value: function _convertMatches(matches, matchesLength) {
  12623. if (!matches) {
  12624. return [];
  12625. }
  12626. var textContentItemsStr = this.textContentItemsStr;
  12627. var i = 0,
  12628. iIndex = 0;
  12629. var end = textContentItemsStr.length - 1;
  12630. var result = [];
  12631. for (var m = 0, mm = matches.length; m < mm; m++) {
  12632. var matchIdx = matches[m];
  12633. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  12634. iIndex += textContentItemsStr[i].length;
  12635. i++;
  12636. }
  12637. if (i === textContentItemsStr.length) {
  12638. console.error("Could not find a matching mapping");
  12639. }
  12640. var match = {
  12641. begin: {
  12642. divIdx: i,
  12643. offset: matchIdx - iIndex
  12644. }
  12645. };
  12646. matchIdx += matchesLength[m];
  12647. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  12648. iIndex += textContentItemsStr[i].length;
  12649. i++;
  12650. }
  12651. match.end = {
  12652. divIdx: i,
  12653. offset: matchIdx - iIndex
  12654. };
  12655. result.push(match);
  12656. }
  12657. return result;
  12658. }
  12659. }, {
  12660. key: "_renderMatches",
  12661. value: function _renderMatches(matches) {
  12662. if (matches.length === 0) {
  12663. return;
  12664. }
  12665. var findController = this.findController,
  12666. pageIdx = this.pageIdx,
  12667. textContentItemsStr = this.textContentItemsStr,
  12668. textDivs = this.textDivs;
  12669. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  12670. var selectedMatchIdx = findController.selected.matchIdx;
  12671. var highlightAll = findController.state.highlightAll;
  12672. var prevEnd = null;
  12673. var infinity = {
  12674. divIdx: -1,
  12675. offset: undefined
  12676. };
  12677. function beginText(begin, className) {
  12678. var divIdx = begin.divIdx;
  12679. textDivs[divIdx].textContent = "";
  12680. appendTextToDiv(divIdx, 0, begin.offset, className);
  12681. }
  12682. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  12683. var div = textDivs[divIdx];
  12684. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  12685. var node = document.createTextNode(content);
  12686. if (className) {
  12687. var span = document.createElement("span");
  12688. span.className = className;
  12689. span.appendChild(node);
  12690. div.appendChild(span);
  12691. return;
  12692. }
  12693. div.appendChild(node);
  12694. }
  12695. var i0 = selectedMatchIdx,
  12696. i1 = i0 + 1;
  12697. if (highlightAll) {
  12698. i0 = 0;
  12699. i1 = matches.length;
  12700. } else if (!isSelectedPage) {
  12701. return;
  12702. }
  12703. for (var i = i0; i < i1; i++) {
  12704. var match = matches[i];
  12705. var begin = match.begin;
  12706. var end = match.end;
  12707. var isSelected = isSelectedPage && i === selectedMatchIdx;
  12708. var highlightSuffix = isSelected ? " selected" : "";
  12709. if (isSelected) {
  12710. findController.scrollMatchIntoView({
  12711. element: textDivs[begin.divIdx],
  12712. pageIndex: pageIdx,
  12713. matchIndex: selectedMatchIdx
  12714. });
  12715. }
  12716. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  12717. if (prevEnd !== null) {
  12718. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  12719. }
  12720. beginText(begin);
  12721. } else {
  12722. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  12723. }
  12724. if (begin.divIdx === end.divIdx) {
  12725. appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  12726. } else {
  12727. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  12728. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  12729. textDivs[n0].className = "highlight middle" + highlightSuffix;
  12730. }
  12731. beginText(end, "highlight end" + highlightSuffix);
  12732. }
  12733. prevEnd = end;
  12734. }
  12735. if (prevEnd) {
  12736. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  12737. }
  12738. }
  12739. }, {
  12740. key: "_updateMatches",
  12741. value: function _updateMatches() {
  12742. if (!this.renderingDone) {
  12743. return;
  12744. }
  12745. var findController = this.findController,
  12746. matches = this.matches,
  12747. pageIdx = this.pageIdx,
  12748. textContentItemsStr = this.textContentItemsStr,
  12749. textDivs = this.textDivs;
  12750. var clearedUntilDivIdx = -1;
  12751. for (var i = 0, ii = matches.length; i < ii; i++) {
  12752. var match = matches[i];
  12753. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  12754. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  12755. var div = textDivs[n];
  12756. div.textContent = textContentItemsStr[n];
  12757. div.className = "";
  12758. }
  12759. clearedUntilDivIdx = match.end.divIdx + 1;
  12760. }
  12761. if (!findController || !findController.highlightMatches) {
  12762. return;
  12763. }
  12764. var pageMatches = findController.pageMatches[pageIdx] || null;
  12765. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  12766. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  12767. this._renderMatches(this.matches);
  12768. }
  12769. }, {
  12770. key: "_bindMouse",
  12771. value: function _bindMouse() {
  12772. var _this2 = this;
  12773. var div = this.textLayerDiv;
  12774. var expandDivsTimer = null;
  12775. div.addEventListener("mousedown", function (evt) {
  12776. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  12777. _this2.textLayerRenderTask.expandTextDivs(true);
  12778. if (expandDivsTimer) {
  12779. clearTimeout(expandDivsTimer);
  12780. expandDivsTimer = null;
  12781. }
  12782. return;
  12783. }
  12784. var end = div.querySelector(".endOfContent");
  12785. if (!end) {
  12786. return;
  12787. }
  12788. var adjustTop = evt.target !== div;
  12789. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  12790. if (adjustTop) {
  12791. var divBounds = div.getBoundingClientRect();
  12792. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  12793. end.style.top = (r * 100).toFixed(2) + "%";
  12794. }
  12795. end.classList.add("active");
  12796. });
  12797. div.addEventListener("mouseup", function () {
  12798. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  12799. expandDivsTimer = setTimeout(function () {
  12800. if (_this2.textLayerRenderTask) {
  12801. _this2.textLayerRenderTask.expandTextDivs(false);
  12802. }
  12803. expandDivsTimer = null;
  12804. }, EXPAND_DIVS_TIMEOUT);
  12805. return;
  12806. }
  12807. var end = div.querySelector(".endOfContent");
  12808. if (!end) {
  12809. return;
  12810. }
  12811. end.style.top = "";
  12812. end.classList.remove("active");
  12813. });
  12814. }
  12815. }]);
  12816. return TextLayerBuilder;
  12817. }();
  12818. exports.TextLayerBuilder = TextLayerBuilder;
  12819. var DefaultTextLayerFactory = /*#__PURE__*/function () {
  12820. function DefaultTextLayerFactory() {
  12821. _classCallCheck(this, DefaultTextLayerFactory);
  12822. }
  12823. _createClass(DefaultTextLayerFactory, [{
  12824. key: "createTextLayerBuilder",
  12825. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  12826. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  12827. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  12828. return new TextLayerBuilder({
  12829. textLayerDiv: textLayerDiv,
  12830. pageIndex: pageIndex,
  12831. viewport: viewport,
  12832. enhanceTextSelection: enhanceTextSelection,
  12833. eventBus: eventBus
  12834. });
  12835. }
  12836. }]);
  12837. return DefaultTextLayerFactory;
  12838. }();
  12839. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  12840. /***/ }),
  12841. /* 33 */
  12842. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12843. Object.defineProperty(exports, "__esModule", ({
  12844. value: true
  12845. }));
  12846. exports.SecondaryToolbar = void 0;
  12847. var _ui_utils = __webpack_require__(6);
  12848. var _pdf_cursor_tools = __webpack_require__(8);
  12849. var _pdf_single_page_viewer = __webpack_require__(34);
  12850. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  12851. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  12852. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  12853. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12854. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12855. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12856. var SecondaryToolbar = /*#__PURE__*/function () {
  12857. function SecondaryToolbar(options, mainContainer, eventBus) {
  12858. var _this = this;
  12859. _classCallCheck(this, SecondaryToolbar);
  12860. this.toolbar = options.toolbar;
  12861. this.toggleButton = options.toggleButton;
  12862. this.toolbarButtonContainer = options.toolbarButtonContainer;
  12863. this.buttons = [{
  12864. element: options.presentationModeButton,
  12865. eventName: "presentationmode",
  12866. close: true
  12867. }, {
  12868. element: options.openFileButton,
  12869. eventName: "openfile",
  12870. close: true
  12871. }, {
  12872. element: options.printButton,
  12873. eventName: "print",
  12874. close: true
  12875. }, {
  12876. element: options.downloadButton,
  12877. eventName: "download",
  12878. close: true
  12879. }, {
  12880. element: options.viewBookmarkButton,
  12881. eventName: null,
  12882. close: true
  12883. }, {
  12884. element: options.firstPageButton,
  12885. eventName: "firstpage",
  12886. close: true
  12887. }, {
  12888. element: options.lastPageButton,
  12889. eventName: "lastpage",
  12890. close: true
  12891. }, {
  12892. element: options.pageRotateCwButton,
  12893. eventName: "rotatecw",
  12894. close: false
  12895. }, {
  12896. element: options.pageRotateCcwButton,
  12897. eventName: "rotateccw",
  12898. close: false
  12899. }, {
  12900. element: options.cursorSelectToolButton,
  12901. eventName: "switchcursortool",
  12902. eventDetails: {
  12903. tool: _pdf_cursor_tools.CursorTool.SELECT
  12904. },
  12905. close: true
  12906. }, {
  12907. element: options.cursorHandToolButton,
  12908. eventName: "switchcursortool",
  12909. eventDetails: {
  12910. tool: _pdf_cursor_tools.CursorTool.HAND
  12911. },
  12912. close: true
  12913. }, {
  12914. element: options.scrollVerticalButton,
  12915. eventName: "switchscrollmode",
  12916. eventDetails: {
  12917. mode: _ui_utils.ScrollMode.VERTICAL
  12918. },
  12919. close: true
  12920. }, {
  12921. element: options.scrollHorizontalButton,
  12922. eventName: "switchscrollmode",
  12923. eventDetails: {
  12924. mode: _ui_utils.ScrollMode.HORIZONTAL
  12925. },
  12926. close: true
  12927. }, {
  12928. element: options.scrollWrappedButton,
  12929. eventName: "switchscrollmode",
  12930. eventDetails: {
  12931. mode: _ui_utils.ScrollMode.WRAPPED
  12932. },
  12933. close: true
  12934. }, {
  12935. element: options.spreadNoneButton,
  12936. eventName: "switchspreadmode",
  12937. eventDetails: {
  12938. mode: _ui_utils.SpreadMode.NONE
  12939. },
  12940. close: true
  12941. }, {
  12942. element: options.spreadOddButton,
  12943. eventName: "switchspreadmode",
  12944. eventDetails: {
  12945. mode: _ui_utils.SpreadMode.ODD
  12946. },
  12947. close: true
  12948. }, {
  12949. element: options.spreadEvenButton,
  12950. eventName: "switchspreadmode",
  12951. eventDetails: {
  12952. mode: _ui_utils.SpreadMode.EVEN
  12953. },
  12954. close: true
  12955. }, {
  12956. element: options.documentPropertiesButton,
  12957. eventName: "documentproperties",
  12958. close: true
  12959. }];
  12960. this.items = {
  12961. firstPage: options.firstPageButton,
  12962. lastPage: options.lastPageButton,
  12963. pageRotateCw: options.pageRotateCwButton,
  12964. pageRotateCcw: options.pageRotateCcwButton
  12965. };
  12966. this.mainContainer = mainContainer;
  12967. this.eventBus = eventBus;
  12968. this.opened = false;
  12969. this.containerHeight = null;
  12970. this.previousContainerHeight = null;
  12971. this.reset();
  12972. this._bindClickListeners();
  12973. this._bindCursorToolsListener(options);
  12974. this._bindScrollModeListener(options);
  12975. this._bindSpreadModeListener(options);
  12976. this.eventBus._on("resize", this._setMaxHeight.bind(this));
  12977. this.eventBus._on("baseviewerinit", function (evt) {
  12978. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  12979. _this.toolbarButtonContainer.classList.add("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  12980. } else {
  12981. _this.toolbarButtonContainer.classList.remove("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  12982. }
  12983. });
  12984. }
  12985. _createClass(SecondaryToolbar, [{
  12986. key: "setPageNumber",
  12987. value: function setPageNumber(pageNumber) {
  12988. this.pageNumber = pageNumber;
  12989. this._updateUIState();
  12990. }
  12991. }, {
  12992. key: "setPagesCount",
  12993. value: function setPagesCount(pagesCount) {
  12994. this.pagesCount = pagesCount;
  12995. this._updateUIState();
  12996. }
  12997. }, {
  12998. key: "reset",
  12999. value: function reset() {
  13000. this.pageNumber = 0;
  13001. this.pagesCount = 0;
  13002. this._updateUIState();
  13003. this.eventBus.dispatch("secondarytoolbarreset", {
  13004. source: this
  13005. });
  13006. }
  13007. }, {
  13008. key: "_updateUIState",
  13009. value: function _updateUIState() {
  13010. this.items.firstPage.disabled = this.pageNumber <= 1;
  13011. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  13012. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  13013. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  13014. }
  13015. }, {
  13016. key: "_bindClickListeners",
  13017. value: function _bindClickListeners() {
  13018. var _this2 = this;
  13019. this.toggleButton.addEventListener("click", this.toggle.bind(this));
  13020. var _iterator = _createForOfIteratorHelper(this.buttons),
  13021. _step;
  13022. try {
  13023. var _loop = function _loop() {
  13024. var _step$value = _step.value,
  13025. element = _step$value.element,
  13026. eventName = _step$value.eventName,
  13027. close = _step$value.close,
  13028. eventDetails = _step$value.eventDetails;
  13029. element.addEventListener("click", function (evt) {
  13030. if (eventName !== null) {
  13031. var details = {
  13032. source: _this2
  13033. };
  13034. for (var property in eventDetails) {
  13035. details[property] = eventDetails[property];
  13036. }
  13037. _this2.eventBus.dispatch(eventName, details);
  13038. }
  13039. if (close) {
  13040. _this2.close();
  13041. }
  13042. });
  13043. };
  13044. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  13045. _loop();
  13046. }
  13047. } catch (err) {
  13048. _iterator.e(err);
  13049. } finally {
  13050. _iterator.f();
  13051. }
  13052. }
  13053. }, {
  13054. key: "_bindCursorToolsListener",
  13055. value: function _bindCursorToolsListener(buttons) {
  13056. this.eventBus._on("cursortoolchanged", function (_ref) {
  13057. var tool = _ref.tool;
  13058. buttons.cursorSelectToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.SELECT);
  13059. buttons.cursorHandToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.HAND);
  13060. });
  13061. }
  13062. }, {
  13063. key: "_bindScrollModeListener",
  13064. value: function _bindScrollModeListener(buttons) {
  13065. var _this3 = this;
  13066. function scrollModeChanged(_ref2) {
  13067. var mode = _ref2.mode;
  13068. buttons.scrollVerticalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.VERTICAL);
  13069. buttons.scrollHorizontalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.HORIZONTAL);
  13070. buttons.scrollWrappedButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.WRAPPED);
  13071. var isScrollModeHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
  13072. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  13073. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  13074. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  13075. }
  13076. this.eventBus._on("scrollmodechanged", scrollModeChanged);
  13077. this.eventBus._on("secondarytoolbarreset", function (evt) {
  13078. if (evt.source === _this3) {
  13079. scrollModeChanged({
  13080. mode: _ui_utils.ScrollMode.VERTICAL
  13081. });
  13082. }
  13083. });
  13084. }
  13085. }, {
  13086. key: "_bindSpreadModeListener",
  13087. value: function _bindSpreadModeListener(buttons) {
  13088. var _this4 = this;
  13089. function spreadModeChanged(_ref3) {
  13090. var mode = _ref3.mode;
  13091. buttons.spreadNoneButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.NONE);
  13092. buttons.spreadOddButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.ODD);
  13093. buttons.spreadEvenButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.EVEN);
  13094. }
  13095. this.eventBus._on("spreadmodechanged", spreadModeChanged);
  13096. this.eventBus._on("secondarytoolbarreset", function (evt) {
  13097. if (evt.source === _this4) {
  13098. spreadModeChanged({
  13099. mode: _ui_utils.SpreadMode.NONE
  13100. });
  13101. }
  13102. });
  13103. }
  13104. }, {
  13105. key: "open",
  13106. value: function open() {
  13107. if (this.opened) {
  13108. return;
  13109. }
  13110. this.opened = true;
  13111. this._setMaxHeight();
  13112. this.toggleButton.classList.add("toggled");
  13113. this.toolbar.classList.remove("hidden");
  13114. }
  13115. }, {
  13116. key: "close",
  13117. value: function close() {
  13118. if (!this.opened) {
  13119. return;
  13120. }
  13121. this.opened = false;
  13122. this.toolbar.classList.add("hidden");
  13123. this.toggleButton.classList.remove("toggled");
  13124. }
  13125. }, {
  13126. key: "toggle",
  13127. value: function toggle() {
  13128. if (this.opened) {
  13129. this.close();
  13130. } else {
  13131. this.open();
  13132. }
  13133. }
  13134. }, {
  13135. key: "_setMaxHeight",
  13136. value: function _setMaxHeight() {
  13137. if (!this.opened) {
  13138. return;
  13139. }
  13140. this.containerHeight = this.mainContainer.clientHeight;
  13141. if (this.containerHeight === this.previousContainerHeight) {
  13142. return;
  13143. }
  13144. this.toolbarButtonContainer.style.maxHeight = "".concat(this.containerHeight - _ui_utils.SCROLLBAR_PADDING, "px");
  13145. this.previousContainerHeight = this.containerHeight;
  13146. }
  13147. }, {
  13148. key: "isOpen",
  13149. get: function get() {
  13150. return this.opened;
  13151. }
  13152. }]);
  13153. return SecondaryToolbar;
  13154. }();
  13155. exports.SecondaryToolbar = SecondaryToolbar;
  13156. /***/ }),
  13157. /* 34 */
  13158. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13159. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13160. Object.defineProperty(exports, "__esModule", ({
  13161. value: true
  13162. }));
  13163. exports.PDFSinglePageViewer = void 0;
  13164. var _base_viewer = __webpack_require__(29);
  13165. var _pdfjsLib = __webpack_require__(7);
  13166. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13167. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13168. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13169. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  13170. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  13171. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  13172. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13173. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13174. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13175. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13176. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  13177. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13178. var PDFSinglePageViewer = /*#__PURE__*/function (_BaseViewer) {
  13179. _inherits(PDFSinglePageViewer, _BaseViewer);
  13180. var _super = _createSuper(PDFSinglePageViewer);
  13181. function PDFSinglePageViewer(options) {
  13182. var _this;
  13183. _classCallCheck(this, PDFSinglePageViewer);
  13184. _this = _super.call(this, options);
  13185. _this.eventBus._on("pagesinit", function (evt) {
  13186. _this._ensurePageViewVisible();
  13187. });
  13188. return _this;
  13189. }
  13190. _createClass(PDFSinglePageViewer, [{
  13191. key: "_resetView",
  13192. value: function _resetView() {
  13193. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  13194. this._previousPageNumber = 1;
  13195. this._shadowViewer = document.createDocumentFragment();
  13196. this._updateScrollDown = null;
  13197. }
  13198. }, {
  13199. key: "_ensurePageViewVisible",
  13200. value: function _ensurePageViewVisible() {
  13201. var pageView = this._pages[this._currentPageNumber - 1];
  13202. var previousPageView = this._pages[this._previousPageNumber - 1];
  13203. var viewerNodes = this.viewer.childNodes;
  13204. switch (viewerNodes.length) {
  13205. case 0:
  13206. this.viewer.appendChild(pageView.div);
  13207. break;
  13208. case 1:
  13209. if (viewerNodes[0] !== previousPageView.div) {
  13210. throw new Error("_ensurePageViewVisible: Unexpected previously visible page.");
  13211. }
  13212. if (pageView === previousPageView) {
  13213. break;
  13214. }
  13215. this._shadowViewer.appendChild(previousPageView.div);
  13216. this.viewer.appendChild(pageView.div);
  13217. this.container.scrollTop = 0;
  13218. break;
  13219. default:
  13220. throw new Error("_ensurePageViewVisible: Only one page should be visible at a time.");
  13221. }
  13222. this._previousPageNumber = this._currentPageNumber;
  13223. }
  13224. }, {
  13225. key: "_scrollUpdate",
  13226. value: function _scrollUpdate() {
  13227. if (this._updateScrollDown) {
  13228. this._updateScrollDown();
  13229. }
  13230. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  13231. }
  13232. }, {
  13233. key: "_scrollIntoView",
  13234. value: function _scrollIntoView(_ref) {
  13235. var _this2 = this;
  13236. var pageDiv = _ref.pageDiv,
  13237. _ref$pageSpot = _ref.pageSpot,
  13238. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  13239. _ref$pageNumber = _ref.pageNumber,
  13240. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  13241. if (pageNumber) {
  13242. this._setCurrentPageNumber(pageNumber);
  13243. }
  13244. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  13245. this._ensurePageViewVisible();
  13246. this.update();
  13247. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  13248. pageDiv: pageDiv,
  13249. pageSpot: pageSpot,
  13250. pageNumber: pageNumber
  13251. });
  13252. this._updateScrollDown = function () {
  13253. _this2.scroll.down = scrolledDown;
  13254. _this2._updateScrollDown = null;
  13255. };
  13256. }
  13257. }, {
  13258. key: "_getVisiblePages",
  13259. value: function _getVisiblePages() {
  13260. return this._getCurrentVisiblePage();
  13261. }
  13262. }, {
  13263. key: "_updateHelper",
  13264. value: function _updateHelper(visiblePages) {}
  13265. }, {
  13266. key: "_updateScrollMode",
  13267. value: function _updateScrollMode() {}
  13268. }, {
  13269. key: "_updateSpreadMode",
  13270. value: function _updateSpreadMode() {}
  13271. }, {
  13272. key: "_getPageAdvance",
  13273. value: function _getPageAdvance() {
  13274. return 1;
  13275. }
  13276. }, {
  13277. key: "_viewerElement",
  13278. get: function get() {
  13279. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this._shadowViewer);
  13280. }
  13281. }, {
  13282. key: "_pageWidthScaleFactor",
  13283. get: function get() {
  13284. return 1;
  13285. }
  13286. }, {
  13287. key: "_isScrollModeHorizontal",
  13288. get: function get() {
  13289. return (0, _pdfjsLib.shadow)(this, "_isScrollModeHorizontal", false);
  13290. }
  13291. }]);
  13292. return PDFSinglePageViewer;
  13293. }(_base_viewer.BaseViewer);
  13294. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  13295. /***/ }),
  13296. /* 35 */
  13297. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13298. Object.defineProperty(exports, "__esModule", ({
  13299. value: true
  13300. }));
  13301. exports.Toolbar = void 0;
  13302. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  13303. var _ui_utils = __webpack_require__(6);
  13304. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13305. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  13306. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  13307. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  13308. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  13309. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  13310. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13311. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13312. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13313. var PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
  13314. var SCALE_SELECT_CONTAINER_WIDTH = 140;
  13315. var SCALE_SELECT_WIDTH = 162;
  13316. var Toolbar = /*#__PURE__*/function () {
  13317. function Toolbar(options, eventBus) {
  13318. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  13319. _classCallCheck(this, Toolbar);
  13320. this.toolbar = options.container;
  13321. this.eventBus = eventBus;
  13322. this.l10n = l10n;
  13323. this.buttons = [{
  13324. element: options.previous,
  13325. eventName: "previouspage"
  13326. }, {
  13327. element: options.next,
  13328. eventName: "nextpage"
  13329. }, {
  13330. element: options.zoomIn,
  13331. eventName: "zoomin"
  13332. }, {
  13333. element: options.zoomOut,
  13334. eventName: "zoomout"
  13335. }, {
  13336. element: options.openFile,
  13337. eventName: "openfile"
  13338. }, {
  13339. element: options.print,
  13340. eventName: "print"
  13341. }, {
  13342. element: options.presentationModeButton,
  13343. eventName: "presentationmode"
  13344. }, {
  13345. element: options.download,
  13346. eventName: "download"
  13347. }, {
  13348. element: options.viewBookmark,
  13349. eventName: null
  13350. }];
  13351. this.items = {
  13352. numPages: options.numPages,
  13353. pageNumber: options.pageNumber,
  13354. scaleSelectContainer: options.scaleSelectContainer,
  13355. scaleSelect: options.scaleSelect,
  13356. customScaleOption: options.customScaleOption,
  13357. previous: options.previous,
  13358. next: options.next,
  13359. zoomIn: options.zoomIn,
  13360. zoomOut: options.zoomOut
  13361. };
  13362. this._wasLocalized = false;
  13363. this.reset();
  13364. this._bindListeners();
  13365. }
  13366. _createClass(Toolbar, [{
  13367. key: "setPageNumber",
  13368. value: function setPageNumber(pageNumber, pageLabel) {
  13369. this.pageNumber = pageNumber;
  13370. this.pageLabel = pageLabel;
  13371. this._updateUIState(false);
  13372. }
  13373. }, {
  13374. key: "setPagesCount",
  13375. value: function setPagesCount(pagesCount, hasPageLabels) {
  13376. this.pagesCount = pagesCount;
  13377. this.hasPageLabels = hasPageLabels;
  13378. this._updateUIState(true);
  13379. }
  13380. }, {
  13381. key: "setPageScale",
  13382. value: function setPageScale(pageScaleValue, pageScale) {
  13383. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  13384. this.pageScale = pageScale;
  13385. this._updateUIState(false);
  13386. }
  13387. }, {
  13388. key: "reset",
  13389. value: function reset() {
  13390. this.pageNumber = 0;
  13391. this.pageLabel = null;
  13392. this.hasPageLabels = false;
  13393. this.pagesCount = 0;
  13394. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  13395. this.pageScale = _ui_utils.DEFAULT_SCALE;
  13396. this._updateUIState(true);
  13397. this.updateLoadingIndicatorState();
  13398. }
  13399. }, {
  13400. key: "_bindListeners",
  13401. value: function _bindListeners() {
  13402. var _this = this;
  13403. var _this$items = this.items,
  13404. pageNumber = _this$items.pageNumber,
  13405. scaleSelect = _this$items.scaleSelect;
  13406. var self = this;
  13407. var _iterator = _createForOfIteratorHelper(this.buttons),
  13408. _step;
  13409. try {
  13410. var _loop = function _loop() {
  13411. var _step$value = _step.value,
  13412. element = _step$value.element,
  13413. eventName = _step$value.eventName;
  13414. element.addEventListener("click", function (evt) {
  13415. if (eventName !== null) {
  13416. _this.eventBus.dispatch(eventName, {
  13417. source: _this
  13418. });
  13419. }
  13420. });
  13421. };
  13422. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  13423. _loop();
  13424. }
  13425. } catch (err) {
  13426. _iterator.e(err);
  13427. } finally {
  13428. _iterator.f();
  13429. }
  13430. pageNumber.addEventListener("click", function () {
  13431. this.select();
  13432. });
  13433. pageNumber.addEventListener("change", function () {
  13434. self.eventBus.dispatch("pagenumberchanged", {
  13435. source: self,
  13436. value: this.value
  13437. });
  13438. });
  13439. scaleSelect.addEventListener("change", function () {
  13440. if (this.value === "custom") {
  13441. return;
  13442. }
  13443. self.eventBus.dispatch("scalechanged", {
  13444. source: self,
  13445. value: this.value
  13446. });
  13447. });
  13448. scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  13449. this.eventBus._on("localized", function () {
  13450. _this._wasLocalized = true;
  13451. _this._adjustScaleWidth();
  13452. _this._updateUIState(true);
  13453. });
  13454. }
  13455. }, {
  13456. key: "_updateUIState",
  13457. value: function _updateUIState() {
  13458. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  13459. if (!this._wasLocalized) {
  13460. return;
  13461. }
  13462. var pageNumber = this.pageNumber,
  13463. pagesCount = this.pagesCount,
  13464. pageScaleValue = this.pageScaleValue,
  13465. pageScale = this.pageScale,
  13466. items = this.items;
  13467. if (resetNumPages) {
  13468. if (this.hasPageLabels) {
  13469. items.pageNumber.type = "text";
  13470. } else {
  13471. items.pageNumber.type = "number";
  13472. this.l10n.get("of_pages", {
  13473. pagesCount: pagesCount
  13474. }, "of {{pagesCount}}").then(function (msg) {
  13475. items.numPages.textContent = msg;
  13476. });
  13477. }
  13478. items.pageNumber.max = pagesCount;
  13479. }
  13480. if (this.hasPageLabels) {
  13481. items.pageNumber.value = this.pageLabel;
  13482. this.l10n.get("page_of_pages", {
  13483. pageNumber: pageNumber,
  13484. pagesCount: pagesCount
  13485. }, "({{pageNumber}} of {{pagesCount}})").then(function (msg) {
  13486. items.numPages.textContent = msg;
  13487. });
  13488. } else {
  13489. items.pageNumber.value = pageNumber;
  13490. }
  13491. items.previous.disabled = pageNumber <= 1;
  13492. items.next.disabled = pageNumber >= pagesCount;
  13493. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  13494. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  13495. var customScale = Math.round(pageScale * 10000) / 100;
  13496. this.l10n.get("page_scale_percent", {
  13497. scale: customScale
  13498. }, "{{scale}}%").then(function (msg) {
  13499. var predefinedValueFound = false;
  13500. var _iterator2 = _createForOfIteratorHelper(items.scaleSelect.options),
  13501. _step2;
  13502. try {
  13503. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  13504. var option = _step2.value;
  13505. if (option.value !== pageScaleValue) {
  13506. option.selected = false;
  13507. continue;
  13508. }
  13509. option.selected = true;
  13510. predefinedValueFound = true;
  13511. }
  13512. } catch (err) {
  13513. _iterator2.e(err);
  13514. } finally {
  13515. _iterator2.f();
  13516. }
  13517. if (!predefinedValueFound) {
  13518. items.customScaleOption.textContent = msg;
  13519. items.customScaleOption.selected = true;
  13520. }
  13521. });
  13522. }
  13523. }, {
  13524. key: "updateLoadingIndicatorState",
  13525. value: function updateLoadingIndicatorState() {
  13526. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  13527. var pageNumberInput = this.items.pageNumber;
  13528. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  13529. }
  13530. }, {
  13531. key: "_adjustScaleWidth",
  13532. value: function () {
  13533. var _adjustScaleWidth2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  13534. var items, l10n, predefinedValuesPromise, canvas, ctx, _getComputedStyle, fontSize, fontFamily, maxWidth, _iterator3, _step3, predefinedValue, _ctx$measureText, width, overflow;
  13535. return _regenerator["default"].wrap(function _callee$(_context) {
  13536. while (1) {
  13537. switch (_context.prev = _context.next) {
  13538. case 0:
  13539. items = this.items, l10n = this.l10n;
  13540. predefinedValuesPromise = Promise.all([l10n.get("page_scale_auto", null, "Automatic Zoom"), l10n.get("page_scale_actual", null, "Actual Size"), l10n.get("page_scale_fit", null, "Page Fit"), l10n.get("page_scale_width", null, "Page Width")]);
  13541. canvas = document.createElement("canvas");
  13542. canvas.mozOpaque = true;
  13543. ctx = canvas.getContext("2d", {
  13544. alpha: false
  13545. });
  13546. _context.next = 7;
  13547. return _ui_utils.animationStarted;
  13548. case 7:
  13549. _getComputedStyle = getComputedStyle(items.scaleSelect), fontSize = _getComputedStyle.fontSize, fontFamily = _getComputedStyle.fontFamily;
  13550. ctx.font = "".concat(fontSize, " ").concat(fontFamily);
  13551. maxWidth = 0;
  13552. _context.t0 = _createForOfIteratorHelper;
  13553. _context.next = 13;
  13554. return predefinedValuesPromise;
  13555. case 13:
  13556. _context.t1 = _context.sent;
  13557. _iterator3 = (0, _context.t0)(_context.t1);
  13558. try {
  13559. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  13560. predefinedValue = _step3.value;
  13561. _ctx$measureText = ctx.measureText(predefinedValue), width = _ctx$measureText.width;
  13562. if (width > maxWidth) {
  13563. maxWidth = width;
  13564. }
  13565. }
  13566. } catch (err) {
  13567. _iterator3.e(err);
  13568. } finally {
  13569. _iterator3.f();
  13570. }
  13571. overflow = SCALE_SELECT_WIDTH - SCALE_SELECT_CONTAINER_WIDTH;
  13572. maxWidth += 2 * overflow;
  13573. if (maxWidth > SCALE_SELECT_CONTAINER_WIDTH) {
  13574. items.scaleSelect.style.width = "".concat(maxWidth + overflow, "px");
  13575. items.scaleSelectContainer.style.width = "".concat(maxWidth, "px");
  13576. }
  13577. canvas.width = 0;
  13578. canvas.height = 0;
  13579. canvas = ctx = null;
  13580. case 22:
  13581. case "end":
  13582. return _context.stop();
  13583. }
  13584. }
  13585. }, _callee, this);
  13586. }));
  13587. function _adjustScaleWidth() {
  13588. return _adjustScaleWidth2.apply(this, arguments);
  13589. }
  13590. return _adjustScaleWidth;
  13591. }()
  13592. }]);
  13593. return Toolbar;
  13594. }();
  13595. exports.Toolbar = Toolbar;
  13596. /***/ }),
  13597. /* 36 */
  13598. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13599. Object.defineProperty(exports, "__esModule", ({
  13600. value: true
  13601. }));
  13602. exports.ViewHistory = void 0;
  13603. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  13604. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13605. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  13606. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  13607. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13608. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13609. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13610. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  13611. var ViewHistory = /*#__PURE__*/function () {
  13612. function ViewHistory(fingerprint) {
  13613. var _this = this;
  13614. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  13615. _classCallCheck(this, ViewHistory);
  13616. this.fingerprint = fingerprint;
  13617. this.cacheSize = cacheSize;
  13618. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  13619. var database = JSON.parse(databaseStr || "{}");
  13620. var index = -1;
  13621. if (!Array.isArray(database.files)) {
  13622. database.files = [];
  13623. } else {
  13624. while (database.files.length >= _this.cacheSize) {
  13625. database.files.shift();
  13626. }
  13627. for (var i = 0, ii = database.files.length; i < ii; i++) {
  13628. var branch = database.files[i];
  13629. if (branch.fingerprint === _this.fingerprint) {
  13630. index = i;
  13631. break;
  13632. }
  13633. }
  13634. }
  13635. if (index === -1) {
  13636. index = database.files.push({
  13637. fingerprint: _this.fingerprint
  13638. }) - 1;
  13639. }
  13640. _this.file = database.files[index];
  13641. _this.database = database;
  13642. });
  13643. }
  13644. _createClass(ViewHistory, [{
  13645. key: "_writeToStorage",
  13646. value: function () {
  13647. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  13648. var databaseStr;
  13649. return _regenerator["default"].wrap(function _callee$(_context) {
  13650. while (1) {
  13651. switch (_context.prev = _context.next) {
  13652. case 0:
  13653. databaseStr = JSON.stringify(this.database);
  13654. localStorage.setItem("pdfjs.history", databaseStr);
  13655. case 2:
  13656. case "end":
  13657. return _context.stop();
  13658. }
  13659. }
  13660. }, _callee, this);
  13661. }));
  13662. function _writeToStorage() {
  13663. return _writeToStorage2.apply(this, arguments);
  13664. }
  13665. return _writeToStorage;
  13666. }()
  13667. }, {
  13668. key: "_readFromStorage",
  13669. value: function () {
  13670. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  13671. return _regenerator["default"].wrap(function _callee2$(_context2) {
  13672. while (1) {
  13673. switch (_context2.prev = _context2.next) {
  13674. case 0:
  13675. return _context2.abrupt("return", localStorage.getItem("pdfjs.history"));
  13676. case 1:
  13677. case "end":
  13678. return _context2.stop();
  13679. }
  13680. }
  13681. }, _callee2);
  13682. }));
  13683. function _readFromStorage() {
  13684. return _readFromStorage2.apply(this, arguments);
  13685. }
  13686. return _readFromStorage;
  13687. }()
  13688. }, {
  13689. key: "set",
  13690. value: function () {
  13691. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name, val) {
  13692. return _regenerator["default"].wrap(function _callee3$(_context3) {
  13693. while (1) {
  13694. switch (_context3.prev = _context3.next) {
  13695. case 0:
  13696. _context3.next = 2;
  13697. return this._initializedPromise;
  13698. case 2:
  13699. this.file[name] = val;
  13700. return _context3.abrupt("return", this._writeToStorage());
  13701. case 4:
  13702. case "end":
  13703. return _context3.stop();
  13704. }
  13705. }
  13706. }, _callee3, this);
  13707. }));
  13708. function set(_x, _x2) {
  13709. return _set.apply(this, arguments);
  13710. }
  13711. return set;
  13712. }()
  13713. }, {
  13714. key: "setMultiple",
  13715. value: function () {
  13716. var _setMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(properties) {
  13717. var name;
  13718. return _regenerator["default"].wrap(function _callee4$(_context4) {
  13719. while (1) {
  13720. switch (_context4.prev = _context4.next) {
  13721. case 0:
  13722. _context4.next = 2;
  13723. return this._initializedPromise;
  13724. case 2:
  13725. for (name in properties) {
  13726. this.file[name] = properties[name];
  13727. }
  13728. return _context4.abrupt("return", this._writeToStorage());
  13729. case 4:
  13730. case "end":
  13731. return _context4.stop();
  13732. }
  13733. }
  13734. }, _callee4, this);
  13735. }));
  13736. function setMultiple(_x3) {
  13737. return _setMultiple.apply(this, arguments);
  13738. }
  13739. return setMultiple;
  13740. }()
  13741. }, {
  13742. key: "get",
  13743. value: function () {
  13744. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name, defaultValue) {
  13745. var val;
  13746. return _regenerator["default"].wrap(function _callee5$(_context5) {
  13747. while (1) {
  13748. switch (_context5.prev = _context5.next) {
  13749. case 0:
  13750. _context5.next = 2;
  13751. return this._initializedPromise;
  13752. case 2:
  13753. val = this.file[name];
  13754. return _context5.abrupt("return", val !== undefined ? val : defaultValue);
  13755. case 4:
  13756. case "end":
  13757. return _context5.stop();
  13758. }
  13759. }
  13760. }, _callee5, this);
  13761. }));
  13762. function get(_x4, _x5) {
  13763. return _get.apply(this, arguments);
  13764. }
  13765. return get;
  13766. }()
  13767. }, {
  13768. key: "getMultiple",
  13769. value: function () {
  13770. var _getMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6(properties) {
  13771. var values, name, val;
  13772. return _regenerator["default"].wrap(function _callee6$(_context6) {
  13773. while (1) {
  13774. switch (_context6.prev = _context6.next) {
  13775. case 0:
  13776. _context6.next = 2;
  13777. return this._initializedPromise;
  13778. case 2:
  13779. values = Object.create(null);
  13780. for (name in properties) {
  13781. val = this.file[name];
  13782. values[name] = val !== undefined ? val : properties[name];
  13783. }
  13784. return _context6.abrupt("return", values);
  13785. case 5:
  13786. case "end":
  13787. return _context6.stop();
  13788. }
  13789. }
  13790. }, _callee6, this);
  13791. }));
  13792. function getMultiple(_x6) {
  13793. return _getMultiple.apply(this, arguments);
  13794. }
  13795. return getMultiple;
  13796. }()
  13797. }]);
  13798. return ViewHistory;
  13799. }();
  13800. exports.ViewHistory = ViewHistory;
  13801. /***/ }),
  13802. /* 37 */
  13803. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13804. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13805. Object.defineProperty(exports, "__esModule", ({
  13806. value: true
  13807. }));
  13808. exports.GenericCom = void 0;
  13809. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  13810. var _app = __webpack_require__(3);
  13811. var _preferences = __webpack_require__(38);
  13812. var _download_manager = __webpack_require__(39);
  13813. var _genericl10n = __webpack_require__(40);
  13814. var _generic_scripting = __webpack_require__(42);
  13815. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13816. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  13817. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  13818. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13819. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13820. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13821. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  13822. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13823. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13824. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13825. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13826. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  13827. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13828. ;
  13829. var GenericCom = {};
  13830. exports.GenericCom = GenericCom;
  13831. var GenericPreferences = /*#__PURE__*/function (_BasePreferences) {
  13832. _inherits(GenericPreferences, _BasePreferences);
  13833. var _super = _createSuper(GenericPreferences);
  13834. function GenericPreferences() {
  13835. _classCallCheck(this, GenericPreferences);
  13836. return _super.apply(this, arguments);
  13837. }
  13838. _createClass(GenericPreferences, [{
  13839. key: "_writeToStorage",
  13840. value: function () {
  13841. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  13842. return _regenerator["default"].wrap(function _callee$(_context) {
  13843. while (1) {
  13844. switch (_context.prev = _context.next) {
  13845. case 0:
  13846. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  13847. case 1:
  13848. case "end":
  13849. return _context.stop();
  13850. }
  13851. }
  13852. }, _callee);
  13853. }));
  13854. function _writeToStorage(_x) {
  13855. return _writeToStorage2.apply(this, arguments);
  13856. }
  13857. return _writeToStorage;
  13858. }()
  13859. }, {
  13860. key: "_readFromStorage",
  13861. value: function () {
  13862. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  13863. return _regenerator["default"].wrap(function _callee2$(_context2) {
  13864. while (1) {
  13865. switch (_context2.prev = _context2.next) {
  13866. case 0:
  13867. return _context2.abrupt("return", JSON.parse(localStorage.getItem("pdfjs.preferences")));
  13868. case 1:
  13869. case "end":
  13870. return _context2.stop();
  13871. }
  13872. }
  13873. }, _callee2);
  13874. }));
  13875. function _readFromStorage(_x2) {
  13876. return _readFromStorage2.apply(this, arguments);
  13877. }
  13878. return _readFromStorage;
  13879. }()
  13880. }]);
  13881. return GenericPreferences;
  13882. }(_preferences.BasePreferences);
  13883. var GenericExternalServices = /*#__PURE__*/function (_DefaultExternalServi) {
  13884. _inherits(GenericExternalServices, _DefaultExternalServi);
  13885. var _super2 = _createSuper(GenericExternalServices);
  13886. function GenericExternalServices() {
  13887. _classCallCheck(this, GenericExternalServices);
  13888. return _super2.apply(this, arguments);
  13889. }
  13890. _createClass(GenericExternalServices, null, [{
  13891. key: "createDownloadManager",
  13892. value: function createDownloadManager(options) {
  13893. return new _download_manager.DownloadManager();
  13894. }
  13895. }, {
  13896. key: "createPreferences",
  13897. value: function createPreferences() {
  13898. return new GenericPreferences();
  13899. }
  13900. }, {
  13901. key: "createL10n",
  13902. value: function createL10n(_ref) {
  13903. var _ref$locale = _ref.locale,
  13904. locale = _ref$locale === void 0 ? "en-US" : _ref$locale;
  13905. return new _genericl10n.GenericL10n(locale);
  13906. }
  13907. }, {
  13908. key: "createScripting",
  13909. value: function createScripting(_ref2) {
  13910. var sandboxBundleSrc = _ref2.sandboxBundleSrc;
  13911. return new _generic_scripting.GenericScripting(sandboxBundleSrc);
  13912. }
  13913. }]);
  13914. return GenericExternalServices;
  13915. }(_app.DefaultExternalServices);
  13916. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  13917. /***/ }),
  13918. /* 38 */
  13919. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13920. Object.defineProperty(exports, "__esModule", ({
  13921. value: true
  13922. }));
  13923. exports.BasePreferences = void 0;
  13924. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  13925. var _app_options = __webpack_require__(1);
  13926. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13927. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  13928. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  13929. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13930. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13931. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13932. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13933. var BasePreferences = /*#__PURE__*/function () {
  13934. function BasePreferences() {
  13935. var _this = this;
  13936. _classCallCheck(this, BasePreferences);
  13937. if (this.constructor === BasePreferences) {
  13938. throw new Error("Cannot initialize BasePreferences.");
  13939. }
  13940. Object.defineProperty(this, "defaults", {
  13941. value: Object.freeze({
  13942. "cursorToolOnLoad": 0,
  13943. "defaultZoomValue": "",
  13944. "disablePageLabels": false,
  13945. "enablePermissions": false,
  13946. "enablePrintAutoRotate": false,
  13947. "enableScripting": false,
  13948. "enableWebGL": false,
  13949. "externalLinkTarget": 0,
  13950. "historyUpdateUrl": false,
  13951. "ignoreDestinationZoom": false,
  13952. "pdfBugEnabled": false,
  13953. "renderer": "canvas",
  13954. "renderInteractiveForms": true,
  13955. "sidebarViewOnLoad": -1,
  13956. "scrollModeOnLoad": -1,
  13957. "spreadModeOnLoad": -1,
  13958. "textLayerMode": 1,
  13959. "useOnlyCssZoom": false,
  13960. "viewerCssTheme": 0,
  13961. "viewOnLoad": 0,
  13962. "disableAutoFetch": false,
  13963. "disableFontFace": false,
  13964. "disableRange": false,
  13965. "disableStream": false
  13966. }),
  13967. writable: false,
  13968. enumerable: true,
  13969. configurable: false
  13970. });
  13971. this.prefs = Object.assign(Object.create(null), this.defaults);
  13972. this._initializedPromise = this._readFromStorage(this.defaults).then(function (prefs) {
  13973. if (!prefs) {
  13974. return;
  13975. }
  13976. for (var name in prefs) {
  13977. var defaultValue = _this.defaults[name],
  13978. prefValue = prefs[name];
  13979. if (defaultValue === undefined || _typeof(prefValue) !== _typeof(defaultValue)) {
  13980. continue;
  13981. }
  13982. _this.prefs[name] = prefValue;
  13983. }
  13984. });
  13985. }
  13986. _createClass(BasePreferences, [{
  13987. key: "_writeToStorage",
  13988. value: function () {
  13989. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  13990. return _regenerator["default"].wrap(function _callee$(_context) {
  13991. while (1) {
  13992. switch (_context.prev = _context.next) {
  13993. case 0:
  13994. throw new Error("Not implemented: _writeToStorage");
  13995. case 1:
  13996. case "end":
  13997. return _context.stop();
  13998. }
  13999. }
  14000. }, _callee);
  14001. }));
  14002. function _writeToStorage(_x) {
  14003. return _writeToStorage2.apply(this, arguments);
  14004. }
  14005. return _writeToStorage;
  14006. }()
  14007. }, {
  14008. key: "_readFromStorage",
  14009. value: function () {
  14010. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  14011. return _regenerator["default"].wrap(function _callee2$(_context2) {
  14012. while (1) {
  14013. switch (_context2.prev = _context2.next) {
  14014. case 0:
  14015. throw new Error("Not implemented: _readFromStorage");
  14016. case 1:
  14017. case "end":
  14018. return _context2.stop();
  14019. }
  14020. }
  14021. }, _callee2);
  14022. }));
  14023. function _readFromStorage(_x2) {
  14024. return _readFromStorage2.apply(this, arguments);
  14025. }
  14026. return _readFromStorage;
  14027. }()
  14028. }, {
  14029. key: "reset",
  14030. value: function () {
  14031. var _reset = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  14032. return _regenerator["default"].wrap(function _callee3$(_context3) {
  14033. while (1) {
  14034. switch (_context3.prev = _context3.next) {
  14035. case 0:
  14036. _context3.next = 2;
  14037. return this._initializedPromise;
  14038. case 2:
  14039. this.prefs = Object.assign(Object.create(null), this.defaults);
  14040. return _context3.abrupt("return", this._writeToStorage(this.defaults));
  14041. case 4:
  14042. case "end":
  14043. return _context3.stop();
  14044. }
  14045. }
  14046. }, _callee3, this);
  14047. }));
  14048. function reset() {
  14049. return _reset.apply(this, arguments);
  14050. }
  14051. return reset;
  14052. }()
  14053. }, {
  14054. key: "set",
  14055. value: function () {
  14056. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name, value) {
  14057. var defaultValue, valueType, defaultType;
  14058. return _regenerator["default"].wrap(function _callee4$(_context4) {
  14059. while (1) {
  14060. switch (_context4.prev = _context4.next) {
  14061. case 0:
  14062. _context4.next = 2;
  14063. return this._initializedPromise;
  14064. case 2:
  14065. defaultValue = this.defaults[name];
  14066. if (!(defaultValue === undefined)) {
  14067. _context4.next = 7;
  14068. break;
  14069. }
  14070. throw new Error("Set preference: \"".concat(name, "\" is undefined."));
  14071. case 7:
  14072. if (!(value === undefined)) {
  14073. _context4.next = 9;
  14074. break;
  14075. }
  14076. throw new Error("Set preference: no value is specified.");
  14077. case 9:
  14078. valueType = _typeof(value);
  14079. defaultType = _typeof(defaultValue);
  14080. if (!(valueType !== defaultType)) {
  14081. _context4.next = 19;
  14082. break;
  14083. }
  14084. if (!(valueType === "number" && defaultType === "string")) {
  14085. _context4.next = 16;
  14086. break;
  14087. }
  14088. value = value.toString();
  14089. _context4.next = 17;
  14090. break;
  14091. case 16:
  14092. throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", ") + "expected a ".concat(defaultType, "."));
  14093. case 17:
  14094. _context4.next = 21;
  14095. break;
  14096. case 19:
  14097. if (!(valueType === "number" && !Number.isInteger(value))) {
  14098. _context4.next = 21;
  14099. break;
  14100. }
  14101. throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
  14102. case 21:
  14103. this.prefs[name] = value;
  14104. return _context4.abrupt("return", this._writeToStorage(this.prefs));
  14105. case 23:
  14106. case "end":
  14107. return _context4.stop();
  14108. }
  14109. }
  14110. }, _callee4, this);
  14111. }));
  14112. function set(_x3, _x4) {
  14113. return _set.apply(this, arguments);
  14114. }
  14115. return set;
  14116. }()
  14117. }, {
  14118. key: "get",
  14119. value: function () {
  14120. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name) {
  14121. var defaultValue, prefValue;
  14122. return _regenerator["default"].wrap(function _callee5$(_context5) {
  14123. while (1) {
  14124. switch (_context5.prev = _context5.next) {
  14125. case 0:
  14126. _context5.next = 2;
  14127. return this._initializedPromise;
  14128. case 2:
  14129. defaultValue = this.defaults[name];
  14130. if (!(defaultValue === undefined)) {
  14131. _context5.next = 7;
  14132. break;
  14133. }
  14134. throw new Error("Get preference: \"".concat(name, "\" is undefined."));
  14135. case 7:
  14136. prefValue = this.prefs[name];
  14137. if (!(prefValue !== undefined)) {
  14138. _context5.next = 10;
  14139. break;
  14140. }
  14141. return _context5.abrupt("return", prefValue);
  14142. case 10:
  14143. return _context5.abrupt("return", defaultValue);
  14144. case 11:
  14145. case "end":
  14146. return _context5.stop();
  14147. }
  14148. }
  14149. }, _callee5, this);
  14150. }));
  14151. function get(_x5) {
  14152. return _get.apply(this, arguments);
  14153. }
  14154. return get;
  14155. }()
  14156. }, {
  14157. key: "getAll",
  14158. value: function () {
  14159. var _getAll = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  14160. return _regenerator["default"].wrap(function _callee6$(_context6) {
  14161. while (1) {
  14162. switch (_context6.prev = _context6.next) {
  14163. case 0:
  14164. _context6.next = 2;
  14165. return this._initializedPromise;
  14166. case 2:
  14167. return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs));
  14168. case 3:
  14169. case "end":
  14170. return _context6.stop();
  14171. }
  14172. }
  14173. }, _callee6, this);
  14174. }));
  14175. function getAll() {
  14176. return _getAll.apply(this, arguments);
  14177. }
  14178. return getAll;
  14179. }()
  14180. }]);
  14181. return BasePreferences;
  14182. }();
  14183. exports.BasePreferences = BasePreferences;
  14184. /***/ }),
  14185. /* 39 */
  14186. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14187. Object.defineProperty(exports, "__esModule", ({
  14188. value: true
  14189. }));
  14190. exports.DownloadManager = void 0;
  14191. var _pdfjsLib = __webpack_require__(7);
  14192. var _viewer_compatibility = __webpack_require__(2);
  14193. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14194. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14195. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14196. ;
  14197. function _download(blobUrl, filename) {
  14198. var a = document.createElement("a");
  14199. if (!a.click) {
  14200. throw new Error('DownloadManager: "a.click()" is not supported.');
  14201. }
  14202. a.href = blobUrl;
  14203. a.target = "_parent";
  14204. if ("download" in a) {
  14205. a.download = filename;
  14206. }
  14207. (document.body || document.documentElement).appendChild(a);
  14208. a.click();
  14209. a.remove();
  14210. }
  14211. var DownloadManager = /*#__PURE__*/function () {
  14212. function DownloadManager() {
  14213. _classCallCheck(this, DownloadManager);
  14214. }
  14215. _createClass(DownloadManager, [{
  14216. key: "downloadUrl",
  14217. value: function downloadUrl(url, filename) {
  14218. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  14219. return;
  14220. }
  14221. _download(url + "#pdfjs.action=download", filename);
  14222. }
  14223. }, {
  14224. key: "downloadData",
  14225. value: function downloadData(data, filename, contentType) {
  14226. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
  14227. _download(blobUrl, filename);
  14228. }
  14229. }, {
  14230. key: "download",
  14231. value: function download(blob, url, filename) {
  14232. var sourceEventType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "download";
  14233. if (_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  14234. this.downloadUrl(url, filename);
  14235. return;
  14236. }
  14237. var blobUrl = URL.createObjectURL(blob);
  14238. _download(blobUrl, filename);
  14239. }
  14240. }]);
  14241. return DownloadManager;
  14242. }();
  14243. exports.DownloadManager = DownloadManager;
  14244. /***/ }),
  14245. /* 40 */
  14246. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14247. Object.defineProperty(exports, "__esModule", ({
  14248. value: true
  14249. }));
  14250. exports.GenericL10n = void 0;
  14251. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  14252. __webpack_require__(41);
  14253. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14254. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  14255. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  14256. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14257. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14258. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14259. var webL10n = document.webL10n;
  14260. var GenericL10n = /*#__PURE__*/function () {
  14261. function GenericL10n(lang) {
  14262. _classCallCheck(this, GenericL10n);
  14263. this._lang = lang;
  14264. this._ready = new Promise(function (resolve, reject) {
  14265. webL10n.setLanguage(lang, function () {
  14266. resolve(webL10n);
  14267. });
  14268. });
  14269. }
  14270. _createClass(GenericL10n, [{
  14271. key: "getLanguage",
  14272. value: function () {
  14273. var _getLanguage = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  14274. var l10n;
  14275. return _regenerator["default"].wrap(function _callee$(_context) {
  14276. while (1) {
  14277. switch (_context.prev = _context.next) {
  14278. case 0:
  14279. _context.next = 2;
  14280. return this._ready;
  14281. case 2:
  14282. l10n = _context.sent;
  14283. return _context.abrupt("return", l10n.getLanguage());
  14284. case 4:
  14285. case "end":
  14286. return _context.stop();
  14287. }
  14288. }
  14289. }, _callee, this);
  14290. }));
  14291. function getLanguage() {
  14292. return _getLanguage.apply(this, arguments);
  14293. }
  14294. return getLanguage;
  14295. }()
  14296. }, {
  14297. key: "getDirection",
  14298. value: function () {
  14299. var _getDirection = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  14300. var l10n;
  14301. return _regenerator["default"].wrap(function _callee2$(_context2) {
  14302. while (1) {
  14303. switch (_context2.prev = _context2.next) {
  14304. case 0:
  14305. _context2.next = 2;
  14306. return this._ready;
  14307. case 2:
  14308. l10n = _context2.sent;
  14309. return _context2.abrupt("return", l10n.getDirection());
  14310. case 4:
  14311. case "end":
  14312. return _context2.stop();
  14313. }
  14314. }
  14315. }, _callee2, this);
  14316. }));
  14317. function getDirection() {
  14318. return _getDirection.apply(this, arguments);
  14319. }
  14320. return getDirection;
  14321. }()
  14322. }, {
  14323. key: "get",
  14324. value: function () {
  14325. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(property, args, fallback) {
  14326. var l10n;
  14327. return _regenerator["default"].wrap(function _callee3$(_context3) {
  14328. while (1) {
  14329. switch (_context3.prev = _context3.next) {
  14330. case 0:
  14331. _context3.next = 2;
  14332. return this._ready;
  14333. case 2:
  14334. l10n = _context3.sent;
  14335. return _context3.abrupt("return", l10n.get(property, args, fallback));
  14336. case 4:
  14337. case "end":
  14338. return _context3.stop();
  14339. }
  14340. }
  14341. }, _callee3, this);
  14342. }));
  14343. function get(_x, _x2, _x3) {
  14344. return _get.apply(this, arguments);
  14345. }
  14346. return get;
  14347. }()
  14348. }, {
  14349. key: "translate",
  14350. value: function () {
  14351. var _translate = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(element) {
  14352. var l10n;
  14353. return _regenerator["default"].wrap(function _callee4$(_context4) {
  14354. while (1) {
  14355. switch (_context4.prev = _context4.next) {
  14356. case 0:
  14357. _context4.next = 2;
  14358. return this._ready;
  14359. case 2:
  14360. l10n = _context4.sent;
  14361. return _context4.abrupt("return", l10n.translate(element));
  14362. case 4:
  14363. case "end":
  14364. return _context4.stop();
  14365. }
  14366. }
  14367. }, _callee4, this);
  14368. }));
  14369. function translate(_x4) {
  14370. return _translate.apply(this, arguments);
  14371. }
  14372. return translate;
  14373. }()
  14374. }]);
  14375. return GenericL10n;
  14376. }();
  14377. exports.GenericL10n = GenericL10n;
  14378. /***/ }),
  14379. /* 41 */
  14380. /***/ (() => {
  14381. document.webL10n = function (window, document, undefined) {
  14382. var gL10nData = {};
  14383. var gTextData = '';
  14384. var gTextProp = 'textContent';
  14385. var gLanguage = '';
  14386. var gMacros = {};
  14387. var gReadyState = 'loading';
  14388. var gAsyncResourceLoading = true;
  14389. function getL10nResourceLinks() {
  14390. return document.querySelectorAll('link[type="application/l10n"]');
  14391. }
  14392. function getL10nDictionary() {
  14393. var script = document.querySelector('script[type="application/l10n"]');
  14394. return script ? JSON.parse(script.innerHTML) : null;
  14395. }
  14396. function getTranslatableChildren(element) {
  14397. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  14398. }
  14399. function getL10nAttributes(element) {
  14400. if (!element) return {};
  14401. var l10nId = element.getAttribute('data-l10n-id');
  14402. var l10nArgs = element.getAttribute('data-l10n-args');
  14403. var args = {};
  14404. if (l10nArgs) {
  14405. try {
  14406. args = JSON.parse(l10nArgs);
  14407. } catch (e) {
  14408. console.warn('could not parse arguments for #' + l10nId);
  14409. }
  14410. }
  14411. return {
  14412. id: l10nId,
  14413. args: args
  14414. };
  14415. }
  14416. function xhrLoadText(url, onSuccess, onFailure) {
  14417. onSuccess = onSuccess || function _onSuccess(data) {};
  14418. onFailure = onFailure || function _onFailure() {};
  14419. var xhr = new XMLHttpRequest();
  14420. xhr.open('GET', url, gAsyncResourceLoading);
  14421. if (xhr.overrideMimeType) {
  14422. xhr.overrideMimeType('text/plain; charset=utf-8');
  14423. }
  14424. xhr.onreadystatechange = function () {
  14425. if (xhr.readyState == 4) {
  14426. if (xhr.status == 200 || xhr.status === 0) {
  14427. onSuccess(xhr.responseText);
  14428. } else {
  14429. onFailure();
  14430. }
  14431. }
  14432. };
  14433. xhr.onerror = onFailure;
  14434. xhr.ontimeout = onFailure;
  14435. try {
  14436. xhr.send(null);
  14437. } catch (e) {
  14438. onFailure();
  14439. }
  14440. }
  14441. function parseResource(href, lang, successCallback, failureCallback) {
  14442. var baseURL = href.replace(/[^\/]*$/, '') || './';
  14443. function evalString(text) {
  14444. if (text.lastIndexOf('\\') < 0) return text;
  14445. return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'");
  14446. }
  14447. function parseProperties(text, parsedPropertiesCallback) {
  14448. var dictionary = {};
  14449. var reBlank = /^\s*|\s*$/;
  14450. var reComment = /^\s*#|^\s*$/;
  14451. var reSection = /^\s*\[(.*)\]\s*$/;
  14452. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  14453. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  14454. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  14455. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  14456. var currentLang = '*';
  14457. var genericLang = lang.split('-', 1)[0];
  14458. var skipLang = false;
  14459. var match = '';
  14460. function nextEntry() {
  14461. while (true) {
  14462. if (!entries.length) {
  14463. parsedRawLinesCallback();
  14464. return;
  14465. }
  14466. var line = entries.shift();
  14467. if (reComment.test(line)) continue;
  14468. if (extendedSyntax) {
  14469. match = reSection.exec(line);
  14470. if (match) {
  14471. currentLang = match[1].toLowerCase();
  14472. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  14473. continue;
  14474. } else if (skipLang) {
  14475. continue;
  14476. }
  14477. match = reImport.exec(line);
  14478. if (match) {
  14479. loadImport(baseURL + match[1], nextEntry);
  14480. return;
  14481. }
  14482. }
  14483. var tmp = line.match(reSplit);
  14484. if (tmp && tmp.length == 3) {
  14485. dictionary[tmp[1]] = evalString(tmp[2]);
  14486. }
  14487. }
  14488. }
  14489. nextEntry();
  14490. }
  14491. function loadImport(url, callback) {
  14492. xhrLoadText(url, function (content) {
  14493. parseRawLines(content, false, callback);
  14494. }, function () {
  14495. console.warn(url + ' not found.');
  14496. callback();
  14497. });
  14498. }
  14499. parseRawLines(text, true, function () {
  14500. parsedPropertiesCallback(dictionary);
  14501. });
  14502. }
  14503. xhrLoadText(href, function (response) {
  14504. gTextData += response;
  14505. parseProperties(response, function (data) {
  14506. for (var key in data) {
  14507. var id,
  14508. prop,
  14509. index = key.lastIndexOf('.');
  14510. if (index > 0) {
  14511. id = key.substring(0, index);
  14512. prop = key.substring(index + 1);
  14513. } else {
  14514. id = key;
  14515. prop = gTextProp;
  14516. }
  14517. if (!gL10nData[id]) {
  14518. gL10nData[id] = {};
  14519. }
  14520. gL10nData[id][prop] = data[key];
  14521. }
  14522. if (successCallback) {
  14523. successCallback();
  14524. }
  14525. });
  14526. }, failureCallback);
  14527. }
  14528. function loadLocale(lang, callback) {
  14529. if (lang) {
  14530. lang = lang.toLowerCase();
  14531. }
  14532. callback = callback || function _callback() {};
  14533. clear();
  14534. gLanguage = lang;
  14535. var langLinks = getL10nResourceLinks();
  14536. var langCount = langLinks.length;
  14537. if (langCount === 0) {
  14538. var dict = getL10nDictionary();
  14539. if (dict && dict.locales && dict.default_locale) {
  14540. console.log('using the embedded JSON directory, early way out');
  14541. gL10nData = dict.locales[lang];
  14542. if (!gL10nData) {
  14543. var defaultLocale = dict.default_locale.toLowerCase();
  14544. for (var anyCaseLang in dict.locales) {
  14545. anyCaseLang = anyCaseLang.toLowerCase();
  14546. if (anyCaseLang === lang) {
  14547. gL10nData = dict.locales[lang];
  14548. break;
  14549. } else if (anyCaseLang === defaultLocale) {
  14550. gL10nData = dict.locales[defaultLocale];
  14551. }
  14552. }
  14553. }
  14554. callback();
  14555. } else {
  14556. console.log('no resource to load, early way out');
  14557. }
  14558. gReadyState = 'complete';
  14559. return;
  14560. }
  14561. var onResourceLoaded = null;
  14562. var gResourceCount = 0;
  14563. onResourceLoaded = function onResourceLoaded() {
  14564. gResourceCount++;
  14565. if (gResourceCount >= langCount) {
  14566. callback();
  14567. gReadyState = 'complete';
  14568. }
  14569. };
  14570. function L10nResourceLink(link) {
  14571. var href = link.href;
  14572. this.load = function (lang, callback) {
  14573. parseResource(href, lang, callback, function () {
  14574. console.warn(href + ' not found.');
  14575. console.warn('"' + lang + '" resource not found');
  14576. gLanguage = '';
  14577. callback();
  14578. });
  14579. };
  14580. }
  14581. for (var i = 0; i < langCount; i++) {
  14582. var resource = new L10nResourceLink(langLinks[i]);
  14583. resource.load(lang, onResourceLoaded);
  14584. }
  14585. }
  14586. function clear() {
  14587. gL10nData = {};
  14588. gTextData = '';
  14589. gLanguage = '';
  14590. }
  14591. function getPluralRules(lang) {
  14592. var locales2rules = {
  14593. 'af': 3,
  14594. 'ak': 4,
  14595. 'am': 4,
  14596. 'ar': 1,
  14597. 'asa': 3,
  14598. 'az': 0,
  14599. 'be': 11,
  14600. 'bem': 3,
  14601. 'bez': 3,
  14602. 'bg': 3,
  14603. 'bh': 4,
  14604. 'bm': 0,
  14605. 'bn': 3,
  14606. 'bo': 0,
  14607. 'br': 20,
  14608. 'brx': 3,
  14609. 'bs': 11,
  14610. 'ca': 3,
  14611. 'cgg': 3,
  14612. 'chr': 3,
  14613. 'cs': 12,
  14614. 'cy': 17,
  14615. 'da': 3,
  14616. 'de': 3,
  14617. 'dv': 3,
  14618. 'dz': 0,
  14619. 'ee': 3,
  14620. 'el': 3,
  14621. 'en': 3,
  14622. 'eo': 3,
  14623. 'es': 3,
  14624. 'et': 3,
  14625. 'eu': 3,
  14626. 'fa': 0,
  14627. 'ff': 5,
  14628. 'fi': 3,
  14629. 'fil': 4,
  14630. 'fo': 3,
  14631. 'fr': 5,
  14632. 'fur': 3,
  14633. 'fy': 3,
  14634. 'ga': 8,
  14635. 'gd': 24,
  14636. 'gl': 3,
  14637. 'gsw': 3,
  14638. 'gu': 3,
  14639. 'guw': 4,
  14640. 'gv': 23,
  14641. 'ha': 3,
  14642. 'haw': 3,
  14643. 'he': 2,
  14644. 'hi': 4,
  14645. 'hr': 11,
  14646. 'hu': 0,
  14647. 'id': 0,
  14648. 'ig': 0,
  14649. 'ii': 0,
  14650. 'is': 3,
  14651. 'it': 3,
  14652. 'iu': 7,
  14653. 'ja': 0,
  14654. 'jmc': 3,
  14655. 'jv': 0,
  14656. 'ka': 0,
  14657. 'kab': 5,
  14658. 'kaj': 3,
  14659. 'kcg': 3,
  14660. 'kde': 0,
  14661. 'kea': 0,
  14662. 'kk': 3,
  14663. 'kl': 3,
  14664. 'km': 0,
  14665. 'kn': 0,
  14666. 'ko': 0,
  14667. 'ksb': 3,
  14668. 'ksh': 21,
  14669. 'ku': 3,
  14670. 'kw': 7,
  14671. 'lag': 18,
  14672. 'lb': 3,
  14673. 'lg': 3,
  14674. 'ln': 4,
  14675. 'lo': 0,
  14676. 'lt': 10,
  14677. 'lv': 6,
  14678. 'mas': 3,
  14679. 'mg': 4,
  14680. 'mk': 16,
  14681. 'ml': 3,
  14682. 'mn': 3,
  14683. 'mo': 9,
  14684. 'mr': 3,
  14685. 'ms': 0,
  14686. 'mt': 15,
  14687. 'my': 0,
  14688. 'nah': 3,
  14689. 'naq': 7,
  14690. 'nb': 3,
  14691. 'nd': 3,
  14692. 'ne': 3,
  14693. 'nl': 3,
  14694. 'nn': 3,
  14695. 'no': 3,
  14696. 'nr': 3,
  14697. 'nso': 4,
  14698. 'ny': 3,
  14699. 'nyn': 3,
  14700. 'om': 3,
  14701. 'or': 3,
  14702. 'pa': 3,
  14703. 'pap': 3,
  14704. 'pl': 13,
  14705. 'ps': 3,
  14706. 'pt': 3,
  14707. 'rm': 3,
  14708. 'ro': 9,
  14709. 'rof': 3,
  14710. 'ru': 11,
  14711. 'rwk': 3,
  14712. 'sah': 0,
  14713. 'saq': 3,
  14714. 'se': 7,
  14715. 'seh': 3,
  14716. 'ses': 0,
  14717. 'sg': 0,
  14718. 'sh': 11,
  14719. 'shi': 19,
  14720. 'sk': 12,
  14721. 'sl': 14,
  14722. 'sma': 7,
  14723. 'smi': 7,
  14724. 'smj': 7,
  14725. 'smn': 7,
  14726. 'sms': 7,
  14727. 'sn': 3,
  14728. 'so': 3,
  14729. 'sq': 3,
  14730. 'sr': 11,
  14731. 'ss': 3,
  14732. 'ssy': 3,
  14733. 'st': 3,
  14734. 'sv': 3,
  14735. 'sw': 3,
  14736. 'syr': 3,
  14737. 'ta': 3,
  14738. 'te': 3,
  14739. 'teo': 3,
  14740. 'th': 0,
  14741. 'ti': 4,
  14742. 'tig': 3,
  14743. 'tk': 3,
  14744. 'tl': 4,
  14745. 'tn': 3,
  14746. 'to': 0,
  14747. 'tr': 0,
  14748. 'ts': 3,
  14749. 'tzm': 22,
  14750. 'uk': 11,
  14751. 'ur': 3,
  14752. 've': 3,
  14753. 'vi': 0,
  14754. 'vun': 3,
  14755. 'wa': 4,
  14756. 'wae': 3,
  14757. 'wo': 0,
  14758. 'xh': 3,
  14759. 'xog': 3,
  14760. 'yo': 0,
  14761. 'zh': 0,
  14762. 'zu': 3
  14763. };
  14764. function isIn(n, list) {
  14765. return list.indexOf(n) !== -1;
  14766. }
  14767. function isBetween(n, start, end) {
  14768. return start <= n && n <= end;
  14769. }
  14770. var pluralRules = {
  14771. '0': function _(n) {
  14772. return 'other';
  14773. },
  14774. '1': function _(n) {
  14775. if (isBetween(n % 100, 3, 10)) return 'few';
  14776. if (n === 0) return 'zero';
  14777. if (isBetween(n % 100, 11, 99)) return 'many';
  14778. if (n == 2) return 'two';
  14779. if (n == 1) return 'one';
  14780. return 'other';
  14781. },
  14782. '2': function _(n) {
  14783. if (n !== 0 && n % 10 === 0) return 'many';
  14784. if (n == 2) return 'two';
  14785. if (n == 1) return 'one';
  14786. return 'other';
  14787. },
  14788. '3': function _(n) {
  14789. if (n == 1) return 'one';
  14790. return 'other';
  14791. },
  14792. '4': function _(n) {
  14793. if (isBetween(n, 0, 1)) return 'one';
  14794. return 'other';
  14795. },
  14796. '5': function _(n) {
  14797. if (isBetween(n, 0, 2) && n != 2) return 'one';
  14798. return 'other';
  14799. },
  14800. '6': function _(n) {
  14801. if (n === 0) return 'zero';
  14802. if (n % 10 == 1 && n % 100 != 11) return 'one';
  14803. return 'other';
  14804. },
  14805. '7': function _(n) {
  14806. if (n == 2) return 'two';
  14807. if (n == 1) return 'one';
  14808. return 'other';
  14809. },
  14810. '8': function _(n) {
  14811. if (isBetween(n, 3, 6)) return 'few';
  14812. if (isBetween(n, 7, 10)) return 'many';
  14813. if (n == 2) return 'two';
  14814. if (n == 1) return 'one';
  14815. return 'other';
  14816. },
  14817. '9': function _(n) {
  14818. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  14819. if (n == 1) return 'one';
  14820. return 'other';
  14821. },
  14822. '10': function _(n) {
  14823. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  14824. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  14825. return 'other';
  14826. },
  14827. '11': function _(n) {
  14828. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  14829. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  14830. if (n % 10 == 1 && n % 100 != 11) return 'one';
  14831. return 'other';
  14832. },
  14833. '12': function _(n) {
  14834. if (isBetween(n, 2, 4)) return 'few';
  14835. if (n == 1) return 'one';
  14836. return 'other';
  14837. },
  14838. '13': function _(n) {
  14839. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  14840. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  14841. if (n == 1) return 'one';
  14842. return 'other';
  14843. },
  14844. '14': function _(n) {
  14845. if (isBetween(n % 100, 3, 4)) return 'few';
  14846. if (n % 100 == 2) return 'two';
  14847. if (n % 100 == 1) return 'one';
  14848. return 'other';
  14849. },
  14850. '15': function _(n) {
  14851. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  14852. if (isBetween(n % 100, 11, 19)) return 'many';
  14853. if (n == 1) return 'one';
  14854. return 'other';
  14855. },
  14856. '16': function _(n) {
  14857. if (n % 10 == 1 && n != 11) return 'one';
  14858. return 'other';
  14859. },
  14860. '17': function _(n) {
  14861. if (n == 3) return 'few';
  14862. if (n === 0) return 'zero';
  14863. if (n == 6) return 'many';
  14864. if (n == 2) return 'two';
  14865. if (n == 1) return 'one';
  14866. return 'other';
  14867. },
  14868. '18': function _(n) {
  14869. if (n === 0) return 'zero';
  14870. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  14871. return 'other';
  14872. },
  14873. '19': function _(n) {
  14874. if (isBetween(n, 2, 10)) return 'few';
  14875. if (isBetween(n, 0, 1)) return 'one';
  14876. return 'other';
  14877. },
  14878. '20': function _(n) {
  14879. if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) return 'few';
  14880. if (n % 1000000 === 0 && n !== 0) return 'many';
  14881. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  14882. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  14883. return 'other';
  14884. },
  14885. '21': function _(n) {
  14886. if (n === 0) return 'zero';
  14887. if (n == 1) return 'one';
  14888. return 'other';
  14889. },
  14890. '22': function _(n) {
  14891. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  14892. return 'other';
  14893. },
  14894. '23': function _(n) {
  14895. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  14896. return 'other';
  14897. },
  14898. '24': function _(n) {
  14899. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  14900. if (isIn(n, [2, 12])) return 'two';
  14901. if (isIn(n, [1, 11])) return 'one';
  14902. return 'other';
  14903. }
  14904. };
  14905. var index = locales2rules[lang.replace(/-.*$/, '')];
  14906. if (!(index in pluralRules)) {
  14907. console.warn('plural form unknown for [' + lang + ']');
  14908. return function () {
  14909. return 'other';
  14910. };
  14911. }
  14912. return pluralRules[index];
  14913. }
  14914. gMacros.plural = function (str, param, key, prop) {
  14915. var n = parseFloat(param);
  14916. if (isNaN(n)) return str;
  14917. if (prop != gTextProp) return str;
  14918. if (!gMacros._pluralRules) {
  14919. gMacros._pluralRules = getPluralRules(gLanguage);
  14920. }
  14921. var index = '[' + gMacros._pluralRules(n) + ']';
  14922. if (n === 0 && key + '[zero]' in gL10nData) {
  14923. str = gL10nData[key + '[zero]'][prop];
  14924. } else if (n == 1 && key + '[one]' in gL10nData) {
  14925. str = gL10nData[key + '[one]'][prop];
  14926. } else if (n == 2 && key + '[two]' in gL10nData) {
  14927. str = gL10nData[key + '[two]'][prop];
  14928. } else if (key + index in gL10nData) {
  14929. str = gL10nData[key + index][prop];
  14930. } else if (key + '[other]' in gL10nData) {
  14931. str = gL10nData[key + '[other]'][prop];
  14932. }
  14933. return str;
  14934. };
  14935. function getL10nData(key, args, fallback) {
  14936. var data = gL10nData[key];
  14937. if (!data) {
  14938. console.warn('#' + key + ' is undefined.');
  14939. if (!fallback) {
  14940. return null;
  14941. }
  14942. data = fallback;
  14943. }
  14944. var rv = {};
  14945. for (var prop in data) {
  14946. var str = data[prop];
  14947. str = substIndexes(str, args, key, prop);
  14948. str = substArguments(str, args, key);
  14949. rv[prop] = str;
  14950. }
  14951. return rv;
  14952. }
  14953. function substIndexes(str, args, key, prop) {
  14954. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  14955. var reMatch = reIndex.exec(str);
  14956. if (!reMatch || !reMatch.length) return str;
  14957. var macroName = reMatch[1];
  14958. var paramName = reMatch[2];
  14959. var param;
  14960. if (args && paramName in args) {
  14961. param = args[paramName];
  14962. } else if (paramName in gL10nData) {
  14963. param = gL10nData[paramName];
  14964. }
  14965. if (macroName in gMacros) {
  14966. var macro = gMacros[macroName];
  14967. str = macro(str, param, key, prop);
  14968. }
  14969. return str;
  14970. }
  14971. function substArguments(str, args, key) {
  14972. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  14973. return str.replace(reArgs, function (matched_text, arg) {
  14974. if (args && arg in args) {
  14975. return args[arg];
  14976. }
  14977. if (arg in gL10nData) {
  14978. return gL10nData[arg];
  14979. }
  14980. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  14981. return matched_text;
  14982. });
  14983. }
  14984. function translateElement(element) {
  14985. var l10n = getL10nAttributes(element);
  14986. if (!l10n.id) return;
  14987. var data = getL10nData(l10n.id, l10n.args);
  14988. if (!data) {
  14989. console.warn('#' + l10n.id + ' is undefined.');
  14990. return;
  14991. }
  14992. if (data[gTextProp]) {
  14993. if (getChildElementCount(element) === 0) {
  14994. element[gTextProp] = data[gTextProp];
  14995. } else {
  14996. var children = element.childNodes;
  14997. var found = false;
  14998. for (var i = 0, l = children.length; i < l; i++) {
  14999. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  15000. if (found) {
  15001. children[i].nodeValue = '';
  15002. } else {
  15003. children[i].nodeValue = data[gTextProp];
  15004. found = true;
  15005. }
  15006. }
  15007. }
  15008. if (!found) {
  15009. var textNode = document.createTextNode(data[gTextProp]);
  15010. element.insertBefore(textNode, element.firstChild);
  15011. }
  15012. }
  15013. delete data[gTextProp];
  15014. }
  15015. for (var k in data) {
  15016. element[k] = data[k];
  15017. }
  15018. }
  15019. function getChildElementCount(element) {
  15020. if (element.children) {
  15021. return element.children.length;
  15022. }
  15023. if (typeof element.childElementCount !== 'undefined') {
  15024. return element.childElementCount;
  15025. }
  15026. var count = 0;
  15027. for (var i = 0; i < element.childNodes.length; i++) {
  15028. count += element.nodeType === 1 ? 1 : 0;
  15029. }
  15030. return count;
  15031. }
  15032. function translateFragment(element) {
  15033. element = element || document.documentElement;
  15034. var children = getTranslatableChildren(element);
  15035. var elementCount = children.length;
  15036. for (var i = 0; i < elementCount; i++) {
  15037. translateElement(children[i]);
  15038. }
  15039. translateElement(element);
  15040. }
  15041. return {
  15042. get: function get(key, args, fallbackString) {
  15043. var index = key.lastIndexOf('.');
  15044. var prop = gTextProp;
  15045. if (index > 0) {
  15046. prop = key.substring(index + 1);
  15047. key = key.substring(0, index);
  15048. }
  15049. var fallback;
  15050. if (fallbackString) {
  15051. fallback = {};
  15052. fallback[prop] = fallbackString;
  15053. }
  15054. var data = getL10nData(key, args, fallback);
  15055. if (data && prop in data) {
  15056. return data[prop];
  15057. }
  15058. return '{{' + key + '}}';
  15059. },
  15060. getData: function getData() {
  15061. return gL10nData;
  15062. },
  15063. getText: function getText() {
  15064. return gTextData;
  15065. },
  15066. getLanguage: function getLanguage() {
  15067. return gLanguage;
  15068. },
  15069. setLanguage: function setLanguage(lang, callback) {
  15070. loadLocale(lang, function () {
  15071. if (callback) callback();
  15072. });
  15073. },
  15074. getDirection: function getDirection() {
  15075. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  15076. var shortCode = gLanguage.split('-', 1)[0];
  15077. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  15078. },
  15079. translate: translateFragment,
  15080. getReadyState: function getReadyState() {
  15081. return gReadyState;
  15082. },
  15083. ready: function ready(callback) {
  15084. if (!callback) {
  15085. return;
  15086. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  15087. window.setTimeout(function () {
  15088. callback();
  15089. });
  15090. } else if (document.addEventListener) {
  15091. document.addEventListener('localized', function once() {
  15092. document.removeEventListener('localized', once);
  15093. callback();
  15094. });
  15095. }
  15096. }
  15097. };
  15098. }(window, document);
  15099. /***/ }),
  15100. /* 42 */
  15101. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15102. Object.defineProperty(exports, "__esModule", ({
  15103. value: true
  15104. }));
  15105. exports.GenericScripting = void 0;
  15106. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  15107. var _pdfjsLib = __webpack_require__(7);
  15108. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15109. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  15110. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  15111. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15112. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  15113. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15114. var GenericScripting = /*#__PURE__*/function () {
  15115. function GenericScripting(sandboxBundleSrc) {
  15116. _classCallCheck(this, GenericScripting);
  15117. this._ready = (0, _pdfjsLib.loadScript)(sandboxBundleSrc, true).then(function () {
  15118. return window.pdfjsSandbox.QuickJSSandbox();
  15119. });
  15120. }
  15121. _createClass(GenericScripting, [{
  15122. key: "createSandbox",
  15123. value: function () {
  15124. var _createSandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(data) {
  15125. var sandbox;
  15126. return _regenerator["default"].wrap(function _callee$(_context) {
  15127. while (1) {
  15128. switch (_context.prev = _context.next) {
  15129. case 0:
  15130. _context.next = 2;
  15131. return this._ready;
  15132. case 2:
  15133. sandbox = _context.sent;
  15134. sandbox.create(data);
  15135. case 4:
  15136. case "end":
  15137. return _context.stop();
  15138. }
  15139. }
  15140. }, _callee, this);
  15141. }));
  15142. function createSandbox(_x) {
  15143. return _createSandbox.apply(this, arguments);
  15144. }
  15145. return createSandbox;
  15146. }()
  15147. }, {
  15148. key: "dispatchEventInSandbox",
  15149. value: function () {
  15150. var _dispatchEventInSandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(event) {
  15151. var sandbox;
  15152. return _regenerator["default"].wrap(function _callee2$(_context2) {
  15153. while (1) {
  15154. switch (_context2.prev = _context2.next) {
  15155. case 0:
  15156. _context2.next = 2;
  15157. return this._ready;
  15158. case 2:
  15159. sandbox = _context2.sent;
  15160. sandbox.dispatchEvent(event);
  15161. case 4:
  15162. case "end":
  15163. return _context2.stop();
  15164. }
  15165. }
  15166. }, _callee2, this);
  15167. }));
  15168. function dispatchEventInSandbox(_x2) {
  15169. return _dispatchEventInSandbox.apply(this, arguments);
  15170. }
  15171. return dispatchEventInSandbox;
  15172. }()
  15173. }, {
  15174. key: "destroySandbox",
  15175. value: function () {
  15176. var _destroySandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  15177. var sandbox;
  15178. return _regenerator["default"].wrap(function _callee3$(_context3) {
  15179. while (1) {
  15180. switch (_context3.prev = _context3.next) {
  15181. case 0:
  15182. _context3.next = 2;
  15183. return this._ready;
  15184. case 2:
  15185. sandbox = _context3.sent;
  15186. sandbox.nukeSandbox();
  15187. case 4:
  15188. case "end":
  15189. return _context3.stop();
  15190. }
  15191. }
  15192. }, _callee3, this);
  15193. }));
  15194. function destroySandbox() {
  15195. return _destroySandbox.apply(this, arguments);
  15196. }
  15197. return destroySandbox;
  15198. }()
  15199. }]);
  15200. return GenericScripting;
  15201. }();
  15202. exports.GenericScripting = GenericScripting;
  15203. /***/ }),
  15204. /* 43 */
  15205. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15206. Object.defineProperty(exports, "__esModule", ({
  15207. value: true
  15208. }));
  15209. exports.PDFPrintService = PDFPrintService;
  15210. var _ui_utils = __webpack_require__(6);
  15211. var _app = __webpack_require__(3);
  15212. var _viewer_compatibility = __webpack_require__(2);
  15213. var activeService = null;
  15214. var overlayManager = null;
  15215. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise) {
  15216. var scratchCanvas = activeService.scratchCanvas;
  15217. var PRINT_UNITS = printResolution / 72.0;
  15218. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  15219. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  15220. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + "px";
  15221. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + "px";
  15222. var ctx = scratchCanvas.getContext("2d");
  15223. ctx.save();
  15224. ctx.fillStyle = "rgb(255, 255, 255)";
  15225. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  15226. ctx.restore();
  15227. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  15228. var renderContext = {
  15229. canvasContext: ctx,
  15230. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  15231. viewport: pdfPage.getViewport({
  15232. scale: 1,
  15233. rotation: size.rotation
  15234. }),
  15235. intent: "print",
  15236. annotationStorage: pdfDocument.annotationStorage,
  15237. optionalContentConfigPromise: optionalContentConfigPromise
  15238. };
  15239. return pdfPage.render(renderContext).promise;
  15240. }).then(function () {
  15241. return {
  15242. width: width,
  15243. height: height
  15244. };
  15245. });
  15246. }
  15247. function PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution) {
  15248. var optionalContentConfigPromise = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  15249. var l10n = arguments.length > 5 ? arguments[5] : undefined;
  15250. this.pdfDocument = pdfDocument;
  15251. this.pagesOverview = pagesOverview;
  15252. this.printContainer = printContainer;
  15253. this._printResolution = printResolution || 150;
  15254. this._optionalContentConfigPromise = optionalContentConfigPromise || pdfDocument.getOptionalContentConfig();
  15255. this.l10n = l10n || _ui_utils.NullL10n;
  15256. this.currentPage = -1;
  15257. this.scratchCanvas = document.createElement("canvas");
  15258. }
  15259. PDFPrintService.prototype = {
  15260. layout: function layout() {
  15261. this.throwIfInactive();
  15262. var body = document.querySelector("body");
  15263. body.setAttribute("data-pdfjsprinting", true);
  15264. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  15265. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  15266. }, this);
  15267. if (!hasEqualPageSizes) {
  15268. console.warn("Not all pages have the same size. The printed " + "result may be incorrect!");
  15269. }
  15270. this.pageStyleSheet = document.createElement("style");
  15271. var pageSize = this.pagesOverview[0];
  15272. this.pageStyleSheet.textContent = "@supports ((size:A4) and (size:1pt 1pt)) {" + "@page { size: " + pageSize.width + "pt " + pageSize.height + "pt;}" + "}";
  15273. body.appendChild(this.pageStyleSheet);
  15274. },
  15275. destroy: function destroy() {
  15276. if (activeService !== this) {
  15277. return;
  15278. }
  15279. this.printContainer.textContent = "";
  15280. var body = document.querySelector("body");
  15281. body.removeAttribute("data-pdfjsprinting");
  15282. if (this.pageStyleSheet) {
  15283. this.pageStyleSheet.remove();
  15284. this.pageStyleSheet = null;
  15285. }
  15286. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  15287. this.scratchCanvas = null;
  15288. activeService = null;
  15289. ensureOverlay().then(function () {
  15290. if (overlayManager.active !== "printServiceOverlay") {
  15291. return;
  15292. }
  15293. overlayManager.close("printServiceOverlay");
  15294. });
  15295. },
  15296. renderPages: function renderPages() {
  15297. var _this = this;
  15298. var pageCount = this.pagesOverview.length;
  15299. var renderNextPage = function renderNextPage(resolve, reject) {
  15300. _this.throwIfInactive();
  15301. if (++_this.currentPage >= pageCount) {
  15302. renderProgress(pageCount, pageCount, _this.l10n);
  15303. resolve();
  15304. return;
  15305. }
  15306. var index = _this.currentPage;
  15307. renderProgress(index, pageCount, _this.l10n);
  15308. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index], _this._printResolution, _this._optionalContentConfigPromise).then(_this.useRenderedPage.bind(_this)).then(function () {
  15309. renderNextPage(resolve, reject);
  15310. }, reject);
  15311. };
  15312. return new Promise(renderNextPage);
  15313. },
  15314. useRenderedPage: function useRenderedPage(printItem) {
  15315. this.throwIfInactive();
  15316. var img = document.createElement("img");
  15317. img.style.width = printItem.width;
  15318. img.style.height = printItem.height;
  15319. var scratchCanvas = this.scratchCanvas;
  15320. if ("toBlob" in scratchCanvas && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  15321. scratchCanvas.toBlob(function (blob) {
  15322. img.src = URL.createObjectURL(blob);
  15323. });
  15324. } else {
  15325. img.src = scratchCanvas.toDataURL();
  15326. }
  15327. var wrapper = document.createElement("div");
  15328. wrapper.appendChild(img);
  15329. this.printContainer.appendChild(wrapper);
  15330. return new Promise(function (resolve, reject) {
  15331. img.onload = resolve;
  15332. img.onerror = reject;
  15333. });
  15334. },
  15335. performPrint: function performPrint() {
  15336. var _this2 = this;
  15337. this.throwIfInactive();
  15338. return new Promise(function (resolve) {
  15339. setTimeout(function () {
  15340. if (!_this2.active) {
  15341. resolve();
  15342. return;
  15343. }
  15344. print.call(window);
  15345. setTimeout(resolve, 20);
  15346. }, 0);
  15347. });
  15348. },
  15349. get active() {
  15350. return this === activeService;
  15351. },
  15352. throwIfInactive: function throwIfInactive() {
  15353. if (!this.active) {
  15354. throw new Error("This print request was cancelled or completed.");
  15355. }
  15356. }
  15357. };
  15358. var print = window.print;
  15359. window.print = function () {
  15360. if (activeService) {
  15361. console.warn("Ignored window.print() because of a pending print job.");
  15362. return;
  15363. }
  15364. ensureOverlay().then(function () {
  15365. if (activeService) {
  15366. overlayManager.open("printServiceOverlay");
  15367. }
  15368. });
  15369. try {
  15370. dispatchEvent("beforeprint");
  15371. } finally {
  15372. if (!activeService) {
  15373. console.error("Expected print service to be initialized.");
  15374. ensureOverlay().then(function () {
  15375. if (overlayManager.active === "printServiceOverlay") {
  15376. overlayManager.close("printServiceOverlay");
  15377. }
  15378. });
  15379. return;
  15380. }
  15381. var activeServiceOnEntry = activeService;
  15382. activeService.renderPages().then(function () {
  15383. return activeServiceOnEntry.performPrint();
  15384. })["catch"](function () {}).then(function () {
  15385. if (activeServiceOnEntry.active) {
  15386. abort();
  15387. }
  15388. });
  15389. }
  15390. };
  15391. function dispatchEvent(eventType) {
  15392. var event = document.createEvent("CustomEvent");
  15393. event.initCustomEvent(eventType, false, false, "custom");
  15394. window.dispatchEvent(event);
  15395. }
  15396. function abort() {
  15397. if (activeService) {
  15398. activeService.destroy();
  15399. dispatchEvent("afterprint");
  15400. }
  15401. }
  15402. function renderProgress(index, total, l10n) {
  15403. var progressContainer = document.getElementById("printServiceOverlay");
  15404. var progress = Math.round(100 * index / total);
  15405. var progressBar = progressContainer.querySelector("progress");
  15406. var progressPerc = progressContainer.querySelector(".relative-progress");
  15407. progressBar.value = progress;
  15408. l10n.get("print_progress_percent", {
  15409. progress: progress
  15410. }, progress + "%").then(function (msg) {
  15411. progressPerc.textContent = msg;
  15412. });
  15413. }
  15414. window.addEventListener("keydown", function (event) {
  15415. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  15416. window.print();
  15417. event.preventDefault();
  15418. if (event.stopImmediatePropagation) {
  15419. event.stopImmediatePropagation();
  15420. } else {
  15421. event.stopPropagation();
  15422. }
  15423. }
  15424. }, true);
  15425. if ("onbeforeprint" in window) {
  15426. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  15427. if (event.detail !== "custom" && event.stopImmediatePropagation) {
  15428. event.stopImmediatePropagation();
  15429. }
  15430. };
  15431. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  15432. window.addEventListener("afterprint", stopPropagationIfNeeded);
  15433. }
  15434. var overlayPromise;
  15435. function ensureOverlay() {
  15436. if (!overlayPromise) {
  15437. overlayManager = _app.PDFViewerApplication.overlayManager;
  15438. if (!overlayManager) {
  15439. throw new Error("The overlay manager has not yet been initialized.");
  15440. }
  15441. overlayPromise = overlayManager.register("printServiceOverlay", document.getElementById("printServiceOverlay"), abort, true);
  15442. document.getElementById("printCancel").onclick = abort;
  15443. }
  15444. return overlayPromise;
  15445. }
  15446. _app.PDFPrintServiceFactory.instance = {
  15447. supportsPrinting: true,
  15448. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, l10n) {
  15449. if (activeService) {
  15450. throw new Error("The print service is created and active.");
  15451. }
  15452. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, l10n);
  15453. return activeService;
  15454. }
  15455. };
  15456. /***/ })
  15457. /******/ ]);
  15458. /************************************************************************/
  15459. /******/ // The module cache
  15460. /******/ var __webpack_module_cache__ = {};
  15461. /******/
  15462. /******/ // The require function
  15463. /******/ function __webpack_require__(moduleId) {
  15464. /******/ // Check if module is in cache
  15465. /******/ if(__webpack_module_cache__[moduleId]) {
  15466. /******/ return __webpack_module_cache__[moduleId].exports;
  15467. /******/ }
  15468. /******/ // Create a new module (and put it into the cache)
  15469. /******/ var module = __webpack_module_cache__[moduleId] = {
  15470. /******/ id: moduleId,
  15471. /******/ loaded: false,
  15472. /******/ exports: {}
  15473. /******/ };
  15474. /******/
  15475. /******/ // Execute the module function
  15476. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  15477. /******/
  15478. /******/ // Flag the module as loaded
  15479. /******/ module.loaded = true;
  15480. /******/
  15481. /******/ // Return the exports of the module
  15482. /******/ return module.exports;
  15483. /******/ }
  15484. /******/
  15485. /************************************************************************/
  15486. /******/ /* webpack/runtime/node module decorator */
  15487. /******/ (() => {
  15488. /******/ __webpack_require__.nmd = (module) => {
  15489. /******/ module.paths = [];
  15490. /******/ if (!module.children) module.children = [];
  15491. /******/ return module;
  15492. /******/ };
  15493. /******/ })();
  15494. /******/
  15495. /************************************************************************/
  15496. /******/ // startup
  15497. /******/ // Load entry module
  15498. /******/ __webpack_require__(0);
  15499. /******/ // This entry module used 'exports' so it can't be inlined
  15500. /******/ })()
  15501. ;
  15502. //# sourceMappingURL=viewer.js.map