viewer.js 464 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2019 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. /******/ (function(modules) { // webpackBootstrap
  23. /******/ // The module cache
  24. /******/ var installedModules = {};
  25. /******/
  26. /******/ // The require function
  27. /******/ function __webpack_require__(moduleId) {
  28. /******/
  29. /******/ // Check if module is in cache
  30. /******/ if(installedModules[moduleId]) {
  31. /******/ return installedModules[moduleId].exports;
  32. /******/ }
  33. /******/ // Create a new module (and put it into the cache)
  34. /******/ var module = installedModules[moduleId] = {
  35. /******/ i: moduleId,
  36. /******/ l: false,
  37. /******/ exports: {}
  38. /******/ };
  39. /******/
  40. /******/ // Execute the module function
  41. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  42. /******/
  43. /******/ // Flag the module as loaded
  44. /******/ module.l = true;
  45. /******/
  46. /******/ // Return the exports of the module
  47. /******/ return module.exports;
  48. /******/ }
  49. /******/
  50. /******/
  51. /******/ // expose the modules object (__webpack_modules__)
  52. /******/ __webpack_require__.m = modules;
  53. /******/
  54. /******/ // expose the module cache
  55. /******/ __webpack_require__.c = installedModules;
  56. /******/
  57. /******/ // define getter function for harmony exports
  58. /******/ __webpack_require__.d = function(exports, name, getter) {
  59. /******/ if(!__webpack_require__.o(exports, name)) {
  60. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  61. /******/ }
  62. /******/ };
  63. /******/
  64. /******/ // define __esModule on exports
  65. /******/ __webpack_require__.r = function(exports) {
  66. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  67. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  68. /******/ }
  69. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  70. /******/ };
  71. /******/
  72. /******/ // create a fake namespace object
  73. /******/ // mode & 1: value is a module id, require it
  74. /******/ // mode & 2: merge all properties of value into the ns
  75. /******/ // mode & 4: return value when already ns object
  76. /******/ // mode & 8|1: behave like require
  77. /******/ __webpack_require__.t = function(value, mode) {
  78. /******/ if(mode & 1) value = __webpack_require__(value);
  79. /******/ if(mode & 8) return value;
  80. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  81. /******/ var ns = Object.create(null);
  82. /******/ __webpack_require__.r(ns);
  83. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  84. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  85. /******/ return ns;
  86. /******/ };
  87. /******/
  88. /******/ // getDefaultExport function for compatibility with non-harmony modules
  89. /******/ __webpack_require__.n = function(module) {
  90. /******/ var getter = module && module.__esModule ?
  91. /******/ function getDefault() { return module['default']; } :
  92. /******/ function getModuleExports() { return module; };
  93. /******/ __webpack_require__.d(getter, 'a', getter);
  94. /******/ return getter;
  95. /******/ };
  96. /******/
  97. /******/ // Object.prototype.hasOwnProperty.call
  98. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  99. /******/
  100. /******/ // __webpack_public_path__
  101. /******/ __webpack_require__.p = "";
  102. /******/
  103. /******/
  104. /******/ // Load entry module and return exports
  105. /******/ return __webpack_require__(__webpack_require__.s = 0);
  106. /******/ })
  107. /************************************************************************/
  108. /******/ ([
  109. /* 0 */
  110. /***/ (function(module, exports, __webpack_require__) {
  111. "use strict";
  112. ;
  113. var pdfjsWebApp, pdfjsWebAppOptions;
  114. {
  115. pdfjsWebApp = __webpack_require__(1);
  116. pdfjsWebAppOptions = __webpack_require__(6);
  117. }
  118. ;
  119. {
  120. __webpack_require__(36);
  121. }
  122. ;
  123. {
  124. __webpack_require__(41);
  125. }
  126. function getViewerConfiguration() {
  127. return {
  128. appContainer: document.body,
  129. mainContainer: document.getElementById('viewerContainer'),
  130. viewerContainer: document.getElementById('viewer'),
  131. eventBus: null,
  132. toolbar: {
  133. container: document.getElementById('toolbarViewer'),
  134. numPages: document.getElementById('numPages'),
  135. pageNumber: document.getElementById('pageNumber'),
  136. scaleSelectContainer: document.getElementById('scaleSelectContainer'),
  137. scaleSelect: document.getElementById('scaleSelect'),
  138. customScaleOption: document.getElementById('customScaleOption'),
  139. previous: document.getElementById('previous'),
  140. next: document.getElementById('next'),
  141. zoomIn: document.getElementById('zoomIn'),
  142. zoomOut: document.getElementById('zoomOut'),
  143. viewFind: document.getElementById('viewFind'),
  144. openFile: document.getElementById('openFile'),
  145. print: document.getElementById('print'),
  146. presentationModeButton: document.getElementById('presentationMode'),
  147. download: document.getElementById('download'),
  148. viewBookmark: document.getElementById('viewBookmark')
  149. },
  150. secondaryToolbar: {
  151. toolbar: document.getElementById('secondaryToolbar'),
  152. toggleButton: document.getElementById('secondaryToolbarToggle'),
  153. toolbarButtonContainer: document.getElementById('secondaryToolbarButtonContainer'),
  154. presentationModeButton: document.getElementById('secondaryPresentationMode'),
  155. openFileButton: document.getElementById('secondaryOpenFile'),
  156. printButton: document.getElementById('secondaryPrint'),
  157. downloadButton: document.getElementById('secondaryDownload'),
  158. viewBookmarkButton: document.getElementById('secondaryViewBookmark'),
  159. firstPageButton: document.getElementById('firstPage'),
  160. lastPageButton: document.getElementById('lastPage'),
  161. pageRotateCwButton: document.getElementById('pageRotateCw'),
  162. pageRotateCcwButton: document.getElementById('pageRotateCcw'),
  163. cursorSelectToolButton: document.getElementById('cursorSelectTool'),
  164. cursorHandToolButton: document.getElementById('cursorHandTool'),
  165. scrollVerticalButton: document.getElementById('scrollVertical'),
  166. scrollHorizontalButton: document.getElementById('scrollHorizontal'),
  167. scrollWrappedButton: document.getElementById('scrollWrapped'),
  168. spreadNoneButton: document.getElementById('spreadNone'),
  169. spreadOddButton: document.getElementById('spreadOdd'),
  170. spreadEvenButton: document.getElementById('spreadEven'),
  171. documentPropertiesButton: document.getElementById('documentProperties')
  172. },
  173. fullscreen: {
  174. contextFirstPage: document.getElementById('contextFirstPage'),
  175. contextLastPage: document.getElementById('contextLastPage'),
  176. contextPageRotateCw: document.getElementById('contextPageRotateCw'),
  177. contextPageRotateCcw: document.getElementById('contextPageRotateCcw')
  178. },
  179. sidebar: {
  180. outerContainer: document.getElementById('outerContainer'),
  181. viewerContainer: document.getElementById('viewerContainer'),
  182. toggleButton: document.getElementById('sidebarToggle'),
  183. thumbnailButton: document.getElementById('viewThumbnail'),
  184. outlineButton: document.getElementById('viewOutline'),
  185. attachmentsButton: document.getElementById('viewAttachments'),
  186. thumbnailView: document.getElementById('thumbnailView'),
  187. outlineView: document.getElementById('outlineView'),
  188. attachmentsView: document.getElementById('attachmentsView')
  189. },
  190. sidebarResizer: {
  191. outerContainer: document.getElementById('outerContainer'),
  192. resizer: document.getElementById('sidebarResizer')
  193. },
  194. findBar: {
  195. bar: document.getElementById('findbar'),
  196. toggleButton: document.getElementById('viewFind'),
  197. findField: document.getElementById('findInput'),
  198. highlightAllCheckbox: document.getElementById('findHighlightAll'),
  199. caseSensitiveCheckbox: document.getElementById('findMatchCase'),
  200. entireWordCheckbox: document.getElementById('findEntireWord'),
  201. findMsg: document.getElementById('findMsg'),
  202. findResultsCount: document.getElementById('findResultsCount'),
  203. findPreviousButton: document.getElementById('findPrevious'),
  204. findNextButton: document.getElementById('findNext')
  205. },
  206. passwordOverlay: {
  207. overlayName: 'passwordOverlay',
  208. container: document.getElementById('passwordOverlay'),
  209. label: document.getElementById('passwordText'),
  210. input: document.getElementById('password'),
  211. submitButton: document.getElementById('passwordSubmit'),
  212. cancelButton: document.getElementById('passwordCancel')
  213. },
  214. documentProperties: {
  215. overlayName: 'documentPropertiesOverlay',
  216. container: document.getElementById('documentPropertiesOverlay'),
  217. closeButton: document.getElementById('documentPropertiesClose'),
  218. fields: {
  219. 'fileName': document.getElementById('fileNameField'),
  220. 'fileSize': document.getElementById('fileSizeField'),
  221. 'title': document.getElementById('titleField'),
  222. 'author': document.getElementById('authorField'),
  223. 'subject': document.getElementById('subjectField'),
  224. 'keywords': document.getElementById('keywordsField'),
  225. 'creationDate': document.getElementById('creationDateField'),
  226. 'modificationDate': document.getElementById('modificationDateField'),
  227. 'creator': document.getElementById('creatorField'),
  228. 'producer': document.getElementById('producerField'),
  229. 'version': document.getElementById('versionField'),
  230. 'pageCount': document.getElementById('pageCountField'),
  231. 'pageSize': document.getElementById('pageSizeField'),
  232. 'linearized': document.getElementById('linearizedField')
  233. }
  234. },
  235. errorWrapper: {
  236. container: document.getElementById('errorWrapper'),
  237. errorMessage: document.getElementById('errorMessage'),
  238. closeButton: document.getElementById('errorClose'),
  239. errorMoreInfo: document.getElementById('errorMoreInfo'),
  240. moreInfoButton: document.getElementById('errorShowMore'),
  241. lessInfoButton: document.getElementById('errorShowLess')
  242. },
  243. printContainer: document.getElementById('printContainer'),
  244. openFileInputName: 'fileInput',
  245. debuggerScriptPath: './debugger.js'
  246. };
  247. }
  248. function webViewerLoad() {
  249. var config = getViewerConfiguration();
  250. window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
  251. window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;
  252. var event = document.createEvent('CustomEvent');
  253. event.initCustomEvent('webviewerloaded', true, true, {});
  254. document.dispatchEvent(event);
  255. pdfjsWebApp.PDFViewerApplication.run(config);
  256. }
  257. if (document.readyState === 'interactive' || document.readyState === 'complete') {
  258. webViewerLoad();
  259. } else {
  260. document.addEventListener('DOMContentLoaded', webViewerLoad, true);
  261. }
  262. /***/ }),
  263. /* 1 */
  264. /***/ (function(module, exports, __webpack_require__) {
  265. "use strict";
  266. Object.defineProperty(exports, "__esModule", {
  267. value: true
  268. });
  269. exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = void 0;
  270. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  271. var _ui_utils = __webpack_require__(5);
  272. var _app_options = __webpack_require__(6);
  273. var _pdfjsLib = __webpack_require__(7);
  274. var _pdf_cursor_tools = __webpack_require__(9);
  275. var _pdf_rendering_queue = __webpack_require__(11);
  276. var _pdf_sidebar = __webpack_require__(12);
  277. var _overlay_manager = __webpack_require__(13);
  278. var _password_prompt = __webpack_require__(14);
  279. var _pdf_attachment_viewer = __webpack_require__(15);
  280. var _pdf_document_properties = __webpack_require__(16);
  281. var _pdf_find_bar = __webpack_require__(17);
  282. var _pdf_find_controller = __webpack_require__(18);
  283. var _pdf_history = __webpack_require__(20);
  284. var _pdf_link_service = __webpack_require__(21);
  285. var _pdf_outline_viewer = __webpack_require__(22);
  286. var _pdf_presentation_mode = __webpack_require__(23);
  287. var _pdf_sidebar_resizer = __webpack_require__(24);
  288. var _pdf_thumbnail_viewer = __webpack_require__(25);
  289. var _pdf_viewer = __webpack_require__(27);
  290. var _secondary_toolbar = __webpack_require__(32);
  291. var _toolbar = __webpack_require__(34);
  292. var _view_history = __webpack_require__(35);
  293. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  294. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  295. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  296. function _iterableToArrayLimit(arr, i) { 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; }
  297. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  298. 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); } }
  299. 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); }); }; }
  300. var DEFAULT_SCALE_DELTA = 1.1;
  301. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  302. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  303. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  304. var ViewOnLoad = {
  305. UNKNOWN: -1,
  306. PREVIOUS: 0,
  307. INITIAL: 1
  308. };
  309. var DefaultExternalServices = {
  310. updateFindControlState: function updateFindControlState(data) {},
  311. updateFindMatchesCount: function updateFindMatchesCount(data) {},
  312. initPassiveLoading: function initPassiveLoading(callbacks) {},
  313. fallback: function fallback(data, callback) {},
  314. reportTelemetry: function reportTelemetry(data) {},
  315. createDownloadManager: function createDownloadManager(options) {
  316. throw new Error('Not implemented: createDownloadManager');
  317. },
  318. createPreferences: function createPreferences() {
  319. throw new Error('Not implemented: createPreferences');
  320. },
  321. createL10n: function createL10n(options) {
  322. throw new Error('Not implemented: createL10n');
  323. },
  324. supportsIntegratedFind: false,
  325. supportsDocumentFonts: true,
  326. supportsDocumentColors: true,
  327. supportedMouseWheelZoomModifierKeys: {
  328. ctrlKey: true,
  329. metaKey: true
  330. }
  331. };
  332. exports.DefaultExternalServices = DefaultExternalServices;
  333. var PDFViewerApplication = {
  334. initialBookmark: document.location.hash.substring(1),
  335. initialized: false,
  336. fellback: false,
  337. appConfig: null,
  338. pdfDocument: null,
  339. pdfLoadingTask: null,
  340. printService: null,
  341. pdfViewer: null,
  342. pdfThumbnailViewer: null,
  343. pdfRenderingQueue: null,
  344. pdfPresentationMode: null,
  345. pdfDocumentProperties: null,
  346. pdfLinkService: null,
  347. pdfHistory: null,
  348. pdfSidebar: null,
  349. pdfSidebarResizer: null,
  350. pdfOutlineViewer: null,
  351. pdfAttachmentViewer: null,
  352. pdfCursorTools: null,
  353. store: null,
  354. downloadManager: null,
  355. overlayManager: null,
  356. preferences: null,
  357. toolbar: null,
  358. secondaryToolbar: null,
  359. eventBus: null,
  360. l10n: null,
  361. isInitialViewSet: false,
  362. downloadComplete: false,
  363. isViewerEmbedded: window.parent !== window,
  364. url: '',
  365. baseUrl: '',
  366. externalServices: DefaultExternalServices,
  367. _boundEvents: {},
  368. contentDispositionFilename: null,
  369. initialize: function () {
  370. var _initialize = _asyncToGenerator(
  371. /*#__PURE__*/
  372. _regenerator["default"].mark(function _callee(appConfig) {
  373. var _this = this;
  374. var appContainer;
  375. return _regenerator["default"].wrap(function _callee$(_context) {
  376. while (1) {
  377. switch (_context.prev = _context.next) {
  378. case 0:
  379. this.preferences = this.externalServices.createPreferences();
  380. this.appConfig = appConfig;
  381. _context.next = 4;
  382. return this._readPreferences();
  383. case 4:
  384. _context.next = 6;
  385. return this._parseHashParameters();
  386. case 6:
  387. _context.next = 8;
  388. return this._initializeL10n();
  389. case 8:
  390. if (this.isViewerEmbedded && _app_options.AppOptions.get('externalLinkTarget') === _pdfjsLib.LinkTarget.NONE) {
  391. _app_options.AppOptions.set('externalLinkTarget', _pdfjsLib.LinkTarget.TOP);
  392. }
  393. _context.next = 11;
  394. return this._initializeViewerComponents();
  395. case 11:
  396. this.bindEvents();
  397. this.bindWindowEvents();
  398. appContainer = appConfig.appContainer || document.documentElement;
  399. this.l10n.translate(appContainer).then(function () {
  400. _this.eventBus.dispatch('localized', {
  401. source: _this
  402. });
  403. });
  404. this.initialized = true;
  405. case 16:
  406. case "end":
  407. return _context.stop();
  408. }
  409. }
  410. }, _callee, this);
  411. }));
  412. function initialize(_x) {
  413. return _initialize.apply(this, arguments);
  414. }
  415. return initialize;
  416. }(),
  417. _readPreferences: function () {
  418. var _readPreferences2 = _asyncToGenerator(
  419. /*#__PURE__*/
  420. _regenerator["default"].mark(function _callee2() {
  421. var prefs, name;
  422. return _regenerator["default"].wrap(function _callee2$(_context2) {
  423. while (1) {
  424. switch (_context2.prev = _context2.next) {
  425. case 0:
  426. if (!(_app_options.AppOptions.get('disablePreferences') === true)) {
  427. _context2.next = 2;
  428. break;
  429. }
  430. return _context2.abrupt("return");
  431. case 2:
  432. _context2.prev = 2;
  433. _context2.next = 5;
  434. return this.preferences.getAll();
  435. case 5:
  436. prefs = _context2.sent;
  437. for (name in prefs) {
  438. _app_options.AppOptions.set(name, prefs[name]);
  439. }
  440. _context2.next = 12;
  441. break;
  442. case 9:
  443. _context2.prev = 9;
  444. _context2.t0 = _context2["catch"](2);
  445. console.error("_readPreferences: \"".concat(_context2.t0.message, "\"."));
  446. case 12:
  447. case "end":
  448. return _context2.stop();
  449. }
  450. }
  451. }, _callee2, this, [[2, 9]]);
  452. }));
  453. function _readPreferences() {
  454. return _readPreferences2.apply(this, arguments);
  455. }
  456. return _readPreferences;
  457. }(),
  458. _parseHashParameters: function () {
  459. var _parseHashParameters2 = _asyncToGenerator(
  460. /*#__PURE__*/
  461. _regenerator["default"].mark(function _callee3() {
  462. var waitOn, hash, hashParams, viewer, enabled;
  463. return _regenerator["default"].wrap(function _callee3$(_context3) {
  464. while (1) {
  465. switch (_context3.prev = _context3.next) {
  466. case 0:
  467. if (_app_options.AppOptions.get('pdfBugEnabled')) {
  468. _context3.next = 2;
  469. break;
  470. }
  471. return _context3.abrupt("return", undefined);
  472. case 2:
  473. waitOn = [];
  474. hash = document.location.hash.substring(1);
  475. hashParams = (0, _ui_utils.parseQueryString)(hash);
  476. if ('disableworker' in hashParams && hashParams['disableworker'] === 'true') {
  477. waitOn.push(loadFakeWorker());
  478. }
  479. if ('disablerange' in hashParams) {
  480. _app_options.AppOptions.set('disableRange', hashParams['disablerange'] === 'true');
  481. }
  482. if ('disablestream' in hashParams) {
  483. _app_options.AppOptions.set('disableStream', hashParams['disablestream'] === 'true');
  484. }
  485. if ('disableautofetch' in hashParams) {
  486. _app_options.AppOptions.set('disableAutoFetch', hashParams['disableautofetch'] === 'true');
  487. }
  488. if ('disablefontface' in hashParams) {
  489. _app_options.AppOptions.set('disableFontFace', hashParams['disablefontface'] === 'true');
  490. }
  491. if ('disablehistory' in hashParams) {
  492. _app_options.AppOptions.set('disableHistory', hashParams['disablehistory'] === 'true');
  493. }
  494. if ('webgl' in hashParams) {
  495. _app_options.AppOptions.set('enableWebGL', hashParams['webgl'] === 'true');
  496. }
  497. if ('useonlycsszoom' in hashParams) {
  498. _app_options.AppOptions.set('useOnlyCssZoom', hashParams['useonlycsszoom'] === 'true');
  499. }
  500. if ('verbosity' in hashParams) {
  501. _app_options.AppOptions.set('verbosity', hashParams['verbosity'] | 0);
  502. }
  503. if (!('textlayer' in hashParams)) {
  504. _context3.next = 23;
  505. break;
  506. }
  507. _context3.t0 = hashParams['textlayer'];
  508. _context3.next = _context3.t0 === 'off' ? 18 : _context3.t0 === 'visible' ? 20 : _context3.t0 === 'shadow' ? 20 : _context3.t0 === 'hover' ? 20 : 23;
  509. break;
  510. case 18:
  511. _app_options.AppOptions.set('textLayerMode', _ui_utils.TextLayerMode.DISABLE);
  512. return _context3.abrupt("break", 23);
  513. case 20:
  514. viewer = this.appConfig.viewerContainer;
  515. viewer.classList.add('textLayer-' + hashParams['textlayer']);
  516. return _context3.abrupt("break", 23);
  517. case 23:
  518. if ('pdfbug' in hashParams) {
  519. _app_options.AppOptions.set('pdfBug', true);
  520. enabled = hashParams['pdfbug'].split(',');
  521. waitOn.push(loadAndEnablePDFBug(enabled));
  522. }
  523. if ('locale' in hashParams) {
  524. _app_options.AppOptions.set('locale', hashParams['locale']);
  525. }
  526. return _context3.abrupt("return", Promise.all(waitOn)["catch"](function (reason) {
  527. console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
  528. }));
  529. case 26:
  530. case "end":
  531. return _context3.stop();
  532. }
  533. }
  534. }, _callee3, this);
  535. }));
  536. function _parseHashParameters() {
  537. return _parseHashParameters2.apply(this, arguments);
  538. }
  539. return _parseHashParameters;
  540. }(),
  541. _initializeL10n: function () {
  542. var _initializeL10n2 = _asyncToGenerator(
  543. /*#__PURE__*/
  544. _regenerator["default"].mark(function _callee4() {
  545. var dir;
  546. return _regenerator["default"].wrap(function _callee4$(_context4) {
  547. while (1) {
  548. switch (_context4.prev = _context4.next) {
  549. case 0:
  550. this.l10n = this.externalServices.createL10n({
  551. locale: _app_options.AppOptions.get('locale')
  552. });
  553. _context4.next = 3;
  554. return this.l10n.getDirection();
  555. case 3:
  556. dir = _context4.sent;
  557. document.getElementsByTagName('html')[0].dir = dir;
  558. case 5:
  559. case "end":
  560. return _context4.stop();
  561. }
  562. }
  563. }, _callee4, this);
  564. }));
  565. function _initializeL10n() {
  566. return _initializeL10n2.apply(this, arguments);
  567. }
  568. return _initializeL10n;
  569. }(),
  570. _initializeViewerComponents: function () {
  571. var _initializeViewerComponents2 = _asyncToGenerator(
  572. /*#__PURE__*/
  573. _regenerator["default"].mark(function _callee5() {
  574. var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer;
  575. return _regenerator["default"].wrap(function _callee5$(_context5) {
  576. while (1) {
  577. switch (_context5.prev = _context5.next) {
  578. case 0:
  579. appConfig = this.appConfig;
  580. this.overlayManager = new _overlay_manager.OverlayManager();
  581. eventBus = appConfig.eventBus || (0, _ui_utils.getGlobalEventBus)(_app_options.AppOptions.get('eventBusDispatchToDOM'));
  582. this.eventBus = eventBus;
  583. pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  584. pdfRenderingQueue.onIdle = this.cleanup.bind(this);
  585. this.pdfRenderingQueue = pdfRenderingQueue;
  586. pdfLinkService = new _pdf_link_service.PDFLinkService({
  587. eventBus: eventBus,
  588. externalLinkTarget: _app_options.AppOptions.get('externalLinkTarget'),
  589. externalLinkRel: _app_options.AppOptions.get('externalLinkRel')
  590. });
  591. this.pdfLinkService = pdfLinkService;
  592. downloadManager = this.externalServices.createDownloadManager({
  593. disableCreateObjectURL: _app_options.AppOptions.get('disableCreateObjectURL')
  594. });
  595. this.downloadManager = downloadManager;
  596. findController = new _pdf_find_controller.PDFFindController({
  597. linkService: pdfLinkService,
  598. eventBus: eventBus
  599. });
  600. this.findController = findController;
  601. container = appConfig.mainContainer;
  602. viewer = appConfig.viewerContainer;
  603. this.pdfViewer = new _pdf_viewer.PDFViewer({
  604. container: container,
  605. viewer: viewer,
  606. eventBus: eventBus,
  607. renderingQueue: pdfRenderingQueue,
  608. linkService: pdfLinkService,
  609. downloadManager: downloadManager,
  610. findController: findController,
  611. renderer: _app_options.AppOptions.get('renderer'),
  612. enableWebGL: _app_options.AppOptions.get('enableWebGL'),
  613. l10n: this.l10n,
  614. textLayerMode: _app_options.AppOptions.get('textLayerMode'),
  615. imageResourcesPath: _app_options.AppOptions.get('imageResourcesPath'),
  616. renderInteractiveForms: _app_options.AppOptions.get('renderInteractiveForms'),
  617. enablePrintAutoRotate: _app_options.AppOptions.get('enablePrintAutoRotate'),
  618. useOnlyCssZoom: _app_options.AppOptions.get('useOnlyCssZoom'),
  619. maxCanvasPixels: _app_options.AppOptions.get('maxCanvasPixels')
  620. });
  621. pdfRenderingQueue.setViewer(this.pdfViewer);
  622. pdfLinkService.setViewer(this.pdfViewer);
  623. this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  624. container: appConfig.sidebar.thumbnailView,
  625. renderingQueue: pdfRenderingQueue,
  626. linkService: pdfLinkService,
  627. l10n: this.l10n
  628. });
  629. pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
  630. this.pdfHistory = new _pdf_history.PDFHistory({
  631. linkService: pdfLinkService,
  632. eventBus: eventBus
  633. });
  634. pdfLinkService.setHistory(this.pdfHistory);
  635. this.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, this.l10n);
  636. this.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, this.l10n);
  637. this.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  638. container: container,
  639. eventBus: eventBus,
  640. cursorToolOnLoad: _app_options.AppOptions.get('cursorToolOnLoad')
  641. });
  642. this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, this.l10n);
  643. this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  644. if (this.supportsFullscreen) {
  645. this.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  646. container: container,
  647. viewer: viewer,
  648. pdfViewer: this.pdfViewer,
  649. eventBus: eventBus,
  650. contextMenuItems: appConfig.fullscreen
  651. });
  652. }
  653. this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.l10n);
  654. this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  655. container: appConfig.sidebar.outlineView,
  656. eventBus: eventBus,
  657. linkService: pdfLinkService
  658. });
  659. this.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  660. container: appConfig.sidebar.attachmentsView,
  661. eventBus: eventBus,
  662. downloadManager: downloadManager
  663. });
  664. this.pdfSidebar = new _pdf_sidebar.PDFSidebar({
  665. elements: appConfig.sidebar,
  666. pdfViewer: this.pdfViewer,
  667. pdfThumbnailViewer: this.pdfThumbnailViewer,
  668. eventBus: eventBus,
  669. l10n: this.l10n
  670. });
  671. this.pdfSidebar.onToggled = this.forceRendering.bind(this);
  672. this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n);
  673. case 34:
  674. case "end":
  675. return _context5.stop();
  676. }
  677. }
  678. }, _callee5, this);
  679. }));
  680. function _initializeViewerComponents() {
  681. return _initializeViewerComponents2.apply(this, arguments);
  682. }
  683. return _initializeViewerComponents;
  684. }(),
  685. run: function run(config) {
  686. this.initialize(config).then(webViewerInitialized);
  687. },
  688. zoomIn: function zoomIn(ticks) {
  689. var newScale = this.pdfViewer.currentScale;
  690. do {
  691. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  692. newScale = Math.ceil(newScale * 10) / 10;
  693. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  694. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  695. this.pdfViewer.currentScaleValue = newScale;
  696. },
  697. zoomOut: function zoomOut(ticks) {
  698. var newScale = this.pdfViewer.currentScale;
  699. do {
  700. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  701. newScale = Math.floor(newScale * 10) / 10;
  702. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  703. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  704. this.pdfViewer.currentScaleValue = newScale;
  705. },
  706. zoomReset: function zoomReset() {
  707. var ignoreDuplicate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  708. if (this.pdfViewer.isInPresentationMode) {
  709. return;
  710. } else if (ignoreDuplicate && this.pdfViewer.currentScaleValue === _ui_utils.DEFAULT_SCALE_VALUE) {
  711. return;
  712. }
  713. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  714. },
  715. get pagesCount() {
  716. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  717. },
  718. set page(val) {
  719. this.pdfViewer.currentPageNumber = val;
  720. },
  721. get page() {
  722. return this.pdfViewer.currentPageNumber;
  723. },
  724. get printing() {
  725. return !!this.printService;
  726. },
  727. get supportsPrinting() {
  728. return PDFPrintServiceFactory.instance.supportsPrinting;
  729. },
  730. get supportsFullscreen() {
  731. var support;
  732. var doc = document.documentElement;
  733. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
  734. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
  735. support = false;
  736. }
  737. return (0, _pdfjsLib.shadow)(this, 'supportsFullscreen', support);
  738. },
  739. get supportsIntegratedFind() {
  740. return this.externalServices.supportsIntegratedFind;
  741. },
  742. get supportsDocumentFonts() {
  743. return this.externalServices.supportsDocumentFonts;
  744. },
  745. get supportsDocumentColors() {
  746. return this.externalServices.supportsDocumentColors;
  747. },
  748. get loadingBar() {
  749. var bar = new _ui_utils.ProgressBar('#loadingBar');
  750. return (0, _pdfjsLib.shadow)(this, 'loadingBar', bar);
  751. },
  752. get supportedMouseWheelZoomModifierKeys() {
  753. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  754. },
  755. initPassiveLoading: function initPassiveLoading() {
  756. throw new Error('Not implemented: initPassiveLoading');
  757. },
  758. setTitleUsingUrl: function setTitleUsingUrl() {
  759. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  760. this.url = url;
  761. this.baseUrl = url.split('#')[0];
  762. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
  763. if (!title) {
  764. try {
  765. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  766. } catch (ex) {
  767. title = url;
  768. }
  769. }
  770. this.setTitle(title);
  771. },
  772. setTitle: function setTitle(title) {
  773. if (this.isViewerEmbedded) {
  774. return;
  775. }
  776. document.title = title;
  777. },
  778. close: function () {
  779. var _close = _asyncToGenerator(
  780. /*#__PURE__*/
  781. _regenerator["default"].mark(function _callee6() {
  782. var errorWrapper, promise;
  783. return _regenerator["default"].wrap(function _callee6$(_context6) {
  784. while (1) {
  785. switch (_context6.prev = _context6.next) {
  786. case 0:
  787. errorWrapper = this.appConfig.errorWrapper.container;
  788. errorWrapper.setAttribute('hidden', 'true');
  789. if (this.pdfLoadingTask) {
  790. _context6.next = 4;
  791. break;
  792. }
  793. return _context6.abrupt("return", undefined);
  794. case 4:
  795. promise = this.pdfLoadingTask.destroy();
  796. this.pdfLoadingTask = null;
  797. if (this.pdfDocument) {
  798. this.pdfDocument = null;
  799. this.pdfThumbnailViewer.setDocument(null);
  800. this.pdfViewer.setDocument(null);
  801. this.pdfLinkService.setDocument(null);
  802. this.pdfDocumentProperties.setDocument(null);
  803. }
  804. this.store = null;
  805. this.isInitialViewSet = false;
  806. this.downloadComplete = false;
  807. this.url = '';
  808. this.baseUrl = '';
  809. this.contentDispositionFilename = null;
  810. this.pdfSidebar.reset();
  811. this.pdfOutlineViewer.reset();
  812. this.pdfAttachmentViewer.reset();
  813. this.findBar.reset();
  814. this.toolbar.reset();
  815. this.secondaryToolbar.reset();
  816. if (typeof PDFBug !== 'undefined') {
  817. PDFBug.cleanup();
  818. }
  819. return _context6.abrupt("return", promise);
  820. case 21:
  821. case "end":
  822. return _context6.stop();
  823. }
  824. }
  825. }, _callee6, this);
  826. }));
  827. function close() {
  828. return _close.apply(this, arguments);
  829. }
  830. return close;
  831. }(),
  832. open: function () {
  833. var _open = _asyncToGenerator(
  834. /*#__PURE__*/
  835. _regenerator["default"].mark(function _callee7(file, args) {
  836. var _this2 = this;
  837. var workerParameters, key, parameters, apiParameters, _key, prop, loadingTask;
  838. return _regenerator["default"].wrap(function _callee7$(_context7) {
  839. while (1) {
  840. switch (_context7.prev = _context7.next) {
  841. case 0:
  842. if (!this.pdfLoadingTask) {
  843. _context7.next = 3;
  844. break;
  845. }
  846. _context7.next = 3;
  847. return this.close();
  848. case 3:
  849. workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
  850. for (key in workerParameters) {
  851. _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key];
  852. }
  853. parameters = Object.create(null);
  854. if (typeof file === 'string') {
  855. this.setTitleUsingUrl(file);
  856. parameters.url = file;
  857. } else if (file && 'byteLength' in file) {
  858. parameters.data = file;
  859. } else if (file.url && file.originalUrl) {
  860. this.setTitleUsingUrl(file.originalUrl);
  861. parameters.url = file.url;
  862. }
  863. apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
  864. for (_key in apiParameters) {
  865. parameters[_key] = apiParameters[_key];
  866. }
  867. if (args) {
  868. for (prop in args) {
  869. if (prop === 'length') {
  870. this.pdfDocumentProperties.setFileSize(args[prop]);
  871. }
  872. parameters[prop] = args[prop];
  873. }
  874. }
  875. loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  876. this.pdfLoadingTask = loadingTask;
  877. loadingTask.onPassword = function (updateCallback, reason) {
  878. _this2.passwordPrompt.setUpdateCallback(updateCallback, reason);
  879. _this2.passwordPrompt.open();
  880. };
  881. loadingTask.onProgress = function (_ref) {
  882. var loaded = _ref.loaded,
  883. total = _ref.total;
  884. _this2.progress(loaded / total);
  885. };
  886. loadingTask.onUnsupportedFeature = this.fallback.bind(this);
  887. return _context7.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
  888. _this2.load(pdfDocument);
  889. }, function (exception) {
  890. if (loadingTask !== _this2.pdfLoadingTask) {
  891. return undefined;
  892. }
  893. var message = exception && exception.message;
  894. var loadingErrorMessage;
  895. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  896. loadingErrorMessage = _this2.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
  897. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  898. loadingErrorMessage = _this2.l10n.get('missing_file_error', null, 'Missing PDF file.');
  899. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  900. loadingErrorMessage = _this2.l10n.get('unexpected_response_error', null, 'Unexpected server response.');
  901. } else {
  902. loadingErrorMessage = _this2.l10n.get('loading_error', null, 'An error occurred while loading the PDF.');
  903. }
  904. return loadingErrorMessage.then(function (msg) {
  905. _this2.error(msg, {
  906. message: message
  907. });
  908. throw new Error(msg);
  909. });
  910. }));
  911. case 16:
  912. case "end":
  913. return _context7.stop();
  914. }
  915. }
  916. }, _callee7, this);
  917. }));
  918. function open(_x2, _x3) {
  919. return _open.apply(this, arguments);
  920. }
  921. return open;
  922. }(),
  923. download: function download() {
  924. var _this3 = this;
  925. function downloadByUrl() {
  926. downloadManager.downloadUrl(url, filename);
  927. }
  928. var url = this.baseUrl;
  929. var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  930. var downloadManager = this.downloadManager;
  931. downloadManager.onerror = function (err) {
  932. _this3.error("PDF failed to download: ".concat(err));
  933. };
  934. if (!this.pdfDocument || !this.downloadComplete) {
  935. downloadByUrl();
  936. return;
  937. }
  938. this.pdfDocument.getData().then(function (data) {
  939. var blob = new Blob([data], {
  940. type: 'application/pdf'
  941. });
  942. downloadManager.download(blob, url, filename);
  943. })["catch"](downloadByUrl);
  944. },
  945. fallback: function fallback(featureId) {},
  946. error: function error(message, moreInfo) {
  947. var moreInfoText = [this.l10n.get('error_version_info', {
  948. version: _pdfjsLib.version || '?',
  949. build: _pdfjsLib.build || '?'
  950. }, 'PDF.js v{{version}} (build: {{build}})')];
  951. if (moreInfo) {
  952. moreInfoText.push(this.l10n.get('error_message', {
  953. message: moreInfo.message
  954. }, 'Message: {{message}}'));
  955. if (moreInfo.stack) {
  956. moreInfoText.push(this.l10n.get('error_stack', {
  957. stack: moreInfo.stack
  958. }, 'Stack: {{stack}}'));
  959. } else {
  960. if (moreInfo.filename) {
  961. moreInfoText.push(this.l10n.get('error_file', {
  962. file: moreInfo.filename
  963. }, 'File: {{file}}'));
  964. }
  965. if (moreInfo.lineNumber) {
  966. moreInfoText.push(this.l10n.get('error_line', {
  967. line: moreInfo.lineNumber
  968. }, 'Line: {{line}}'));
  969. }
  970. }
  971. }
  972. var errorWrapperConfig = this.appConfig.errorWrapper;
  973. var errorWrapper = errorWrapperConfig.container;
  974. errorWrapper.removeAttribute('hidden');
  975. var errorMessage = errorWrapperConfig.errorMessage;
  976. errorMessage.textContent = message;
  977. var closeButton = errorWrapperConfig.closeButton;
  978. closeButton.onclick = function () {
  979. errorWrapper.setAttribute('hidden', 'true');
  980. };
  981. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  982. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  983. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  984. moreInfoButton.onclick = function () {
  985. errorMoreInfo.removeAttribute('hidden');
  986. moreInfoButton.setAttribute('hidden', 'true');
  987. lessInfoButton.removeAttribute('hidden');
  988. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px';
  989. };
  990. lessInfoButton.onclick = function () {
  991. errorMoreInfo.setAttribute('hidden', 'true');
  992. moreInfoButton.removeAttribute('hidden');
  993. lessInfoButton.setAttribute('hidden', 'true');
  994. };
  995. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  996. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  997. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  998. moreInfoButton.removeAttribute('hidden');
  999. lessInfoButton.setAttribute('hidden', 'true');
  1000. Promise.all(moreInfoText).then(function (parts) {
  1001. errorMoreInfo.value = parts.join('\n');
  1002. });
  1003. },
  1004. progress: function progress(level) {
  1005. var _this4 = this;
  1006. if (this.downloadComplete) {
  1007. return;
  1008. }
  1009. var percent = Math.round(level * 100);
  1010. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1011. this.loadingBar.percent = percent;
  1012. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams['disableAutoFetch'] : _app_options.AppOptions.get('disableAutoFetch');
  1013. if (disableAutoFetch && percent) {
  1014. if (this.disableAutoFetchLoadingBarTimeout) {
  1015. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1016. this.disableAutoFetchLoadingBarTimeout = null;
  1017. }
  1018. this.loadingBar.show();
  1019. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  1020. _this4.loadingBar.hide();
  1021. _this4.disableAutoFetchLoadingBarTimeout = null;
  1022. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1023. }
  1024. }
  1025. },
  1026. load: function load(pdfDocument) {
  1027. var _this5 = this;
  1028. this.pdfDocument = pdfDocument;
  1029. pdfDocument.getDownloadInfo().then(function () {
  1030. _this5.downloadComplete = true;
  1031. _this5.loadingBar.hide();
  1032. firstPagePromise.then(function () {
  1033. _this5.eventBus.dispatch('documentloaded', {
  1034. source: _this5
  1035. });
  1036. });
  1037. });
  1038. var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function () {});
  1039. var pageModePromise = pdfDocument.getPageMode()["catch"](function () {});
  1040. var openActionDestPromise = pdfDocument.getOpenActionDestination()["catch"](function () {});
  1041. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1042. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1043. var store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
  1044. var baseDocumentUrl;
  1045. baseDocumentUrl = null;
  1046. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1047. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1048. var pdfViewer = this.pdfViewer;
  1049. pdfViewer.setDocument(pdfDocument);
  1050. var firstPagePromise = pdfViewer.firstPagePromise;
  1051. var pagesPromise = pdfViewer.pagesPromise;
  1052. var onePageRendered = pdfViewer.onePageRendered;
  1053. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1054. pdfThumbnailViewer.setDocument(pdfDocument);
  1055. firstPagePromise.then(function (pdfPage) {
  1056. _this5.loadingBar.setWidth(_this5.appConfig.viewerContainer);
  1057. var storePromise = store.getMultiple({
  1058. page: null,
  1059. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1060. scrollLeft: '0',
  1061. scrollTop: '0',
  1062. rotation: null,
  1063. sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
  1064. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  1065. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  1066. })["catch"](function () {});
  1067. Promise.all([storePromise, pageLayoutPromise, pageModePromise, openActionDestPromise]).then(
  1068. /*#__PURE__*/
  1069. function () {
  1070. var _ref3 = _asyncToGenerator(
  1071. /*#__PURE__*/
  1072. _regenerator["default"].mark(function _callee8(_ref2) {
  1073. var _ref4, _ref4$, values, pageLayout, pageMode, openActionDest, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
  1074. return _regenerator["default"].wrap(function _callee8$(_context8) {
  1075. while (1) {
  1076. switch (_context8.prev = _context8.next) {
  1077. case 0:
  1078. _ref4 = _slicedToArray(_ref2, 4), _ref4$ = _ref4[0], values = _ref4$ === void 0 ? {} : _ref4$, pageLayout = _ref4[1], pageMode = _ref4[2], openActionDest = _ref4[3];
  1079. viewOnLoad = _app_options.AppOptions.get('viewOnLoad');
  1080. _this5._initializePdfHistory({
  1081. fingerprint: pdfDocument.fingerprint,
  1082. viewOnLoad: viewOnLoad,
  1083. initialDest: openActionDest
  1084. });
  1085. initialBookmark = _this5.initialBookmark;
  1086. zoom = _app_options.AppOptions.get('defaultZoomValue');
  1087. hash = zoom ? "zoom=".concat(zoom) : null;
  1088. rotation = null;
  1089. sidebarView = _app_options.AppOptions.get('sidebarViewOnLoad');
  1090. scrollMode = _app_options.AppOptions.get('scrollModeOnLoad');
  1091. spreadMode = _app_options.AppOptions.get('spreadModeOnLoad');
  1092. if (values.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  1093. hash = "page=".concat(values.page, "&zoom=").concat(zoom || values.zoom, ",") + "".concat(values.scrollLeft, ",").concat(values.scrollTop);
  1094. rotation = parseInt(values.rotation, 10);
  1095. if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  1096. sidebarView = values.sidebarView | 0;
  1097. }
  1098. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  1099. scrollMode = values.scrollMode | 0;
  1100. }
  1101. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1102. spreadMode = values.spreadMode | 0;
  1103. }
  1104. }
  1105. if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  1106. sidebarView = apiPageModeToSidebarView(pageMode);
  1107. }
  1108. if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1109. spreadMode = apiPageLayoutToSpreadMode(pageLayout);
  1110. }
  1111. _this5.setInitialView(hash, {
  1112. rotation: rotation,
  1113. sidebarView: sidebarView,
  1114. scrollMode: scrollMode,
  1115. spreadMode: spreadMode
  1116. });
  1117. _this5.eventBus.dispatch('documentinit', {
  1118. source: _this5
  1119. });
  1120. if (!_this5.isViewerEmbedded) {
  1121. pdfViewer.focus();
  1122. }
  1123. _context8.next = 18;
  1124. return Promise.race([pagesPromise, new Promise(function (resolve) {
  1125. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  1126. })]);
  1127. case 18:
  1128. if (!(!initialBookmark && !hash)) {
  1129. _context8.next = 20;
  1130. break;
  1131. }
  1132. return _context8.abrupt("return");
  1133. case 20:
  1134. if (!pdfViewer.hasEqualPageSizes) {
  1135. _context8.next = 22;
  1136. break;
  1137. }
  1138. return _context8.abrupt("return");
  1139. case 22:
  1140. _this5.initialBookmark = initialBookmark;
  1141. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  1142. _this5.setInitialView(hash);
  1143. case 25:
  1144. case "end":
  1145. return _context8.stop();
  1146. }
  1147. }
  1148. }, _callee8);
  1149. }));
  1150. return function (_x4) {
  1151. return _ref3.apply(this, arguments);
  1152. };
  1153. }())["catch"](function () {
  1154. _this5.setInitialView();
  1155. }).then(function () {
  1156. pdfViewer.update();
  1157. });
  1158. });
  1159. pdfDocument.getPageLabels().then(function (labels) {
  1160. if (!labels || _app_options.AppOptions.get('disablePageLabels')) {
  1161. return;
  1162. }
  1163. var i = 0,
  1164. numLabels = labels.length;
  1165. if (numLabels !== _this5.pagesCount) {
  1166. console.error('The number of Page Labels does not match ' + 'the number of pages in the document.');
  1167. return;
  1168. }
  1169. while (i < numLabels && labels[i] === (i + 1).toString()) {
  1170. i++;
  1171. }
  1172. if (i === numLabels) {
  1173. return;
  1174. }
  1175. pdfViewer.setPageLabels(labels);
  1176. pdfThumbnailViewer.setPageLabels(labels);
  1177. _this5.toolbar.setPagesCount(pdfDocument.numPages, true);
  1178. _this5.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1179. });
  1180. pagesPromise.then(function () {
  1181. if (!_this5.supportsPrinting) {
  1182. return;
  1183. }
  1184. pdfDocument.getJavaScript().then(function (javaScript) {
  1185. if (!javaScript) {
  1186. return;
  1187. }
  1188. javaScript.some(function (js) {
  1189. if (!js) {
  1190. return false;
  1191. }
  1192. console.warn('Warning: JavaScript is not supported');
  1193. _this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  1194. return true;
  1195. });
  1196. var regex = /\bprint\s*\(/;
  1197. for (var i = 0, ii = javaScript.length; i < ii; i++) {
  1198. var js = javaScript[i];
  1199. if (js && regex.test(js)) {
  1200. setTimeout(function () {
  1201. window.print();
  1202. });
  1203. return;
  1204. }
  1205. }
  1206. });
  1207. });
  1208. Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function () {
  1209. pdfDocument.getOutline().then(function (outline) {
  1210. _this5.pdfOutlineViewer.render({
  1211. outline: outline
  1212. });
  1213. });
  1214. pdfDocument.getAttachments().then(function (attachments) {
  1215. _this5.pdfAttachmentViewer.render({
  1216. attachments: attachments
  1217. });
  1218. });
  1219. });
  1220. pdfDocument.getMetadata().then(function (_ref5) {
  1221. var info = _ref5.info,
  1222. metadata = _ref5.metadata,
  1223. contentDispositionFilename = _ref5.contentDispositionFilename;
  1224. _this5.documentInfo = info;
  1225. _this5.metadata = metadata;
  1226. _this5.contentDispositionFilename = contentDispositionFilename;
  1227. console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjsLib.version || '-') + (_app_options.AppOptions.get('enableWebGL') ? ' [WebGL]' : '') + ')');
  1228. var pdfTitle;
  1229. if (metadata && metadata.has('dc:title')) {
  1230. var title = metadata.get('dc:title');
  1231. if (title !== 'Untitled') {
  1232. pdfTitle = title;
  1233. }
  1234. }
  1235. if (!pdfTitle && info && info['Title']) {
  1236. pdfTitle = info['Title'];
  1237. }
  1238. if (pdfTitle) {
  1239. _this5.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
  1240. } else if (contentDispositionFilename) {
  1241. _this5.setTitle(contentDispositionFilename);
  1242. }
  1243. if (info.IsAcroFormPresent) {
  1244. console.warn('Warning: AcroForm/XFA is not supported');
  1245. _this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1246. }
  1247. });
  1248. },
  1249. _initializePdfHistory: function _initializePdfHistory(_ref6) {
  1250. var fingerprint = _ref6.fingerprint,
  1251. viewOnLoad = _ref6.viewOnLoad,
  1252. _ref6$initialDest = _ref6.initialDest,
  1253. initialDest = _ref6$initialDest === void 0 ? null : _ref6$initialDest;
  1254. if (_app_options.AppOptions.get('disableHistory') || this.isViewerEmbedded) {
  1255. return;
  1256. }
  1257. this.pdfHistory.initialize({
  1258. fingerprint: fingerprint,
  1259. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  1260. updateUrl: _app_options.AppOptions.get('historyUpdateUrl')
  1261. });
  1262. if (this.pdfHistory.initialBookmark) {
  1263. this.initialBookmark = this.pdfHistory.initialBookmark;
  1264. this.initialRotation = this.pdfHistory.initialRotation;
  1265. }
  1266. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  1267. this.initialBookmark = JSON.stringify(initialDest);
  1268. this.pdfHistory.push({
  1269. explicitDest: initialDest,
  1270. pageNumber: null
  1271. });
  1272. }
  1273. },
  1274. setInitialView: function setInitialView(storedHash) {
  1275. var _this6 = this;
  1276. var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1277. rotation = _ref7.rotation,
  1278. sidebarView = _ref7.sidebarView,
  1279. scrollMode = _ref7.scrollMode,
  1280. spreadMode = _ref7.spreadMode;
  1281. var setRotation = function setRotation(angle) {
  1282. if ((0, _ui_utils.isValidRotation)(angle)) {
  1283. _this6.pdfViewer.pagesRotation = angle;
  1284. }
  1285. };
  1286. var setViewerModes = function setViewerModes(scroll, spread) {
  1287. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  1288. _this6.pdfViewer.scrollMode = scroll;
  1289. }
  1290. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  1291. _this6.pdfViewer.spreadMode = spread;
  1292. }
  1293. };
  1294. this.isInitialViewSet = true;
  1295. this.pdfSidebar.setInitialView(sidebarView);
  1296. setViewerModes(scrollMode, spreadMode);
  1297. if (this.initialBookmark) {
  1298. setRotation(this.initialRotation);
  1299. delete this.initialRotation;
  1300. this.pdfLinkService.setHash(this.initialBookmark);
  1301. this.initialBookmark = null;
  1302. } else if (storedHash) {
  1303. setRotation(rotation);
  1304. this.pdfLinkService.setHash(storedHash);
  1305. }
  1306. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  1307. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  1308. if (!this.pdfViewer.currentScaleValue) {
  1309. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1310. }
  1311. },
  1312. cleanup: function cleanup() {
  1313. if (!this.pdfDocument) {
  1314. return;
  1315. }
  1316. this.pdfViewer.cleanup();
  1317. this.pdfThumbnailViewer.cleanup();
  1318. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  1319. this.pdfDocument.cleanup();
  1320. }
  1321. },
  1322. forceRendering: function forceRendering() {
  1323. this.pdfRenderingQueue.printing = this.printing;
  1324. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  1325. this.pdfRenderingQueue.renderHighestPriority();
  1326. },
  1327. beforePrint: function beforePrint() {
  1328. var _this7 = this;
  1329. if (this.printService) {
  1330. return;
  1331. }
  1332. if (!this.supportsPrinting) {
  1333. this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) {
  1334. _this7.error(printMessage);
  1335. });
  1336. return;
  1337. }
  1338. if (!this.pdfViewer.pageViewsReady) {
  1339. this.l10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.').then(function (notReadyMessage) {
  1340. window.alert(notReadyMessage);
  1341. });
  1342. return;
  1343. }
  1344. var pagesOverview = this.pdfViewer.getPagesOverview();
  1345. var printContainer = this.appConfig.printContainer;
  1346. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
  1347. this.printService = printService;
  1348. this.forceRendering();
  1349. printService.layout();
  1350. },
  1351. afterPrint: function pdfViewSetupAfterPrint() {
  1352. if (this.printService) {
  1353. this.printService.destroy();
  1354. this.printService = null;
  1355. }
  1356. this.forceRendering();
  1357. },
  1358. rotatePages: function rotatePages(delta) {
  1359. if (!this.pdfDocument) {
  1360. return;
  1361. }
  1362. var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
  1363. this.pdfViewer.pagesRotation = newRotation;
  1364. },
  1365. requestPresentationMode: function requestPresentationMode() {
  1366. if (!this.pdfPresentationMode) {
  1367. return;
  1368. }
  1369. this.pdfPresentationMode.request();
  1370. },
  1371. bindEvents: function bindEvents() {
  1372. var eventBus = this.eventBus,
  1373. _boundEvents = this._boundEvents;
  1374. _boundEvents.beforePrint = this.beforePrint.bind(this);
  1375. _boundEvents.afterPrint = this.afterPrint.bind(this);
  1376. eventBus.on('resize', webViewerResize);
  1377. eventBus.on('hashchange', webViewerHashchange);
  1378. eventBus.on('beforeprint', _boundEvents.beforePrint);
  1379. eventBus.on('afterprint', _boundEvents.afterPrint);
  1380. eventBus.on('pagerendered', webViewerPageRendered);
  1381. eventBus.on('textlayerrendered', webViewerTextLayerRendered);
  1382. eventBus.on('updateviewarea', webViewerUpdateViewarea);
  1383. eventBus.on('pagechanging', webViewerPageChanging);
  1384. eventBus.on('scalechanging', webViewerScaleChanging);
  1385. eventBus.on('rotationchanging', webViewerRotationChanging);
  1386. eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);
  1387. eventBus.on('pagemode', webViewerPageMode);
  1388. eventBus.on('namedaction', webViewerNamedAction);
  1389. eventBus.on('presentationmodechanged', webViewerPresentationModeChanged);
  1390. eventBus.on('presentationmode', webViewerPresentationMode);
  1391. eventBus.on('openfile', webViewerOpenFile);
  1392. eventBus.on('print', webViewerPrint);
  1393. eventBus.on('download', webViewerDownload);
  1394. eventBus.on('firstpage', webViewerFirstPage);
  1395. eventBus.on('lastpage', webViewerLastPage);
  1396. eventBus.on('nextpage', webViewerNextPage);
  1397. eventBus.on('previouspage', webViewerPreviousPage);
  1398. eventBus.on('zoomin', webViewerZoomIn);
  1399. eventBus.on('zoomout', webViewerZoomOut);
  1400. eventBus.on('zoomreset', webViewerZoomReset);
  1401. eventBus.on('pagenumberchanged', webViewerPageNumberChanged);
  1402. eventBus.on('scalechanged', webViewerScaleChanged);
  1403. eventBus.on('rotatecw', webViewerRotateCw);
  1404. eventBus.on('rotateccw', webViewerRotateCcw);
  1405. eventBus.on('switchscrollmode', webViewerSwitchScrollMode);
  1406. eventBus.on('scrollmodechanged', webViewerScrollModeChanged);
  1407. eventBus.on('switchspreadmode', webViewerSwitchSpreadMode);
  1408. eventBus.on('spreadmodechanged', webViewerSpreadModeChanged);
  1409. eventBus.on('documentproperties', webViewerDocumentProperties);
  1410. eventBus.on('find', webViewerFind);
  1411. eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
  1412. eventBus.on('updatefindmatchescount', webViewerUpdateFindMatchesCount);
  1413. eventBus.on('updatefindcontrolstate', webViewerUpdateFindControlState);
  1414. eventBus.on('fileinputchange', webViewerFileInputChange);
  1415. },
  1416. bindWindowEvents: function bindWindowEvents() {
  1417. var eventBus = this.eventBus,
  1418. _boundEvents = this._boundEvents;
  1419. _boundEvents.windowResize = function () {
  1420. eventBus.dispatch('resize', {
  1421. source: window
  1422. });
  1423. };
  1424. _boundEvents.windowHashChange = function () {
  1425. eventBus.dispatch('hashchange', {
  1426. source: window,
  1427. hash: document.location.hash.substring(1)
  1428. });
  1429. };
  1430. _boundEvents.windowBeforePrint = function () {
  1431. eventBus.dispatch('beforeprint', {
  1432. source: window
  1433. });
  1434. };
  1435. _boundEvents.windowAfterPrint = function () {
  1436. eventBus.dispatch('afterprint', {
  1437. source: window
  1438. });
  1439. };
  1440. window.addEventListener('visibilitychange', webViewerVisibilityChange);
  1441. window.addEventListener('wheel', webViewerWheel, {
  1442. passive: false
  1443. });
  1444. window.addEventListener('click', webViewerClick);
  1445. window.addEventListener('keydown', webViewerKeyDown);
  1446. window.addEventListener('resize', _boundEvents.windowResize);
  1447. window.addEventListener('hashchange', _boundEvents.windowHashChange);
  1448. window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1449. window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
  1450. },
  1451. unbindEvents: function unbindEvents() {
  1452. var eventBus = this.eventBus,
  1453. _boundEvents = this._boundEvents;
  1454. eventBus.off('resize', webViewerResize);
  1455. eventBus.off('hashchange', webViewerHashchange);
  1456. eventBus.off('beforeprint', _boundEvents.beforePrint);
  1457. eventBus.off('afterprint', _boundEvents.afterPrint);
  1458. eventBus.off('pagerendered', webViewerPageRendered);
  1459. eventBus.off('textlayerrendered', webViewerTextLayerRendered);
  1460. eventBus.off('updateviewarea', webViewerUpdateViewarea);
  1461. eventBus.off('pagechanging', webViewerPageChanging);
  1462. eventBus.off('scalechanging', webViewerScaleChanging);
  1463. eventBus.off('rotationchanging', webViewerRotationChanging);
  1464. eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);
  1465. eventBus.off('pagemode', webViewerPageMode);
  1466. eventBus.off('namedaction', webViewerNamedAction);
  1467. eventBus.off('presentationmodechanged', webViewerPresentationModeChanged);
  1468. eventBus.off('presentationmode', webViewerPresentationMode);
  1469. eventBus.off('openfile', webViewerOpenFile);
  1470. eventBus.off('print', webViewerPrint);
  1471. eventBus.off('download', webViewerDownload);
  1472. eventBus.off('firstpage', webViewerFirstPage);
  1473. eventBus.off('lastpage', webViewerLastPage);
  1474. eventBus.off('nextpage', webViewerNextPage);
  1475. eventBus.off('previouspage', webViewerPreviousPage);
  1476. eventBus.off('zoomin', webViewerZoomIn);
  1477. eventBus.off('zoomout', webViewerZoomOut);
  1478. eventBus.off('zoomreset', webViewerZoomReset);
  1479. eventBus.off('pagenumberchanged', webViewerPageNumberChanged);
  1480. eventBus.off('scalechanged', webViewerScaleChanged);
  1481. eventBus.off('rotatecw', webViewerRotateCw);
  1482. eventBus.off('rotateccw', webViewerRotateCcw);
  1483. eventBus.off('switchscrollmode', webViewerSwitchScrollMode);
  1484. eventBus.off('scrollmodechanged', webViewerScrollModeChanged);
  1485. eventBus.off('switchspreadmode', webViewerSwitchSpreadMode);
  1486. eventBus.off('spreadmodechanged', webViewerSpreadModeChanged);
  1487. eventBus.off('documentproperties', webViewerDocumentProperties);
  1488. eventBus.off('find', webViewerFind);
  1489. eventBus.off('findfromurlhash', webViewerFindFromUrlHash);
  1490. eventBus.off('updatefindmatchescount', webViewerUpdateFindMatchesCount);
  1491. eventBus.off('updatefindcontrolstate', webViewerUpdateFindControlState);
  1492. eventBus.off('fileinputchange', webViewerFileInputChange);
  1493. _boundEvents.beforePrint = null;
  1494. _boundEvents.afterPrint = null;
  1495. },
  1496. unbindWindowEvents: function unbindWindowEvents() {
  1497. var _boundEvents = this._boundEvents;
  1498. window.removeEventListener('visibilitychange', webViewerVisibilityChange);
  1499. window.removeEventListener('wheel', webViewerWheel);
  1500. window.removeEventListener('click', webViewerClick);
  1501. window.removeEventListener('keydown', webViewerKeyDown);
  1502. window.removeEventListener('resize', _boundEvents.windowResize);
  1503. window.removeEventListener('hashchange', _boundEvents.windowHashChange);
  1504. window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1505. window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);
  1506. _boundEvents.windowResize = null;
  1507. _boundEvents.windowHashChange = null;
  1508. _boundEvents.windowBeforePrint = null;
  1509. _boundEvents.windowAfterPrint = null;
  1510. }
  1511. };
  1512. exports.PDFViewerApplication = PDFViewerApplication;
  1513. var validateFileURL;
  1514. {
  1515. var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
  1516. validateFileURL = function validateFileURL(file) {
  1517. if (file === undefined) {
  1518. return;
  1519. }
  1520. try {
  1521. var viewerOrigin = new _pdfjsLib.URL(window.location.href).origin || 'null';
  1522. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  1523. return;
  1524. }
  1525. var _ref8 = new _pdfjsLib.URL(file, window.location.href),
  1526. origin = _ref8.origin,
  1527. protocol = _ref8.protocol;
  1528. if (origin !== viewerOrigin && protocol !== 'blob:') {
  1529. // throw new Error('file origin does not match viewer\'s');
  1530. }
  1531. } catch (ex) {
  1532. var message = ex && ex.message;
  1533. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (loadingErrorMessage) {
  1534. PDFViewerApplication.error(loadingErrorMessage, {
  1535. message: message
  1536. });
  1537. });
  1538. throw ex;
  1539. }
  1540. };
  1541. }
  1542. function loadFakeWorker() {
  1543. if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
  1544. _pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get('workerSrc');
  1545. }
  1546. return (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc());
  1547. }
  1548. function loadAndEnablePDFBug(enabledTabs) {
  1549. var appConfig = PDFViewerApplication.appConfig;
  1550. return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function () {
  1551. PDFBug.enable(enabledTabs);
  1552. PDFBug.init({
  1553. OPS: _pdfjsLib.OPS,
  1554. createObjectURL: _pdfjsLib.createObjectURL
  1555. }, appConfig.mainContainer);
  1556. });
  1557. }
  1558. function webViewerInitialized() {
  1559. var appConfig = PDFViewerApplication.appConfig;
  1560. var file;
  1561. var queryString = document.location.search.substring(1);
  1562. var params = (0, _ui_utils.parseQueryString)(queryString);
  1563. file = 'file' in params ? params.file : _app_options.AppOptions.get('defaultUrl');
  1564. validateFileURL(file);
  1565. var fileInput = document.createElement('input');
  1566. fileInput.id = appConfig.openFileInputName;
  1567. fileInput.className = 'fileInput';
  1568. fileInput.setAttribute('type', 'file');
  1569. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  1570. document.body.appendChild(fileInput);
  1571. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  1572. appConfig.toolbar.openFile.setAttribute('hidden', 'true');
  1573. appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
  1574. } else {
  1575. fileInput.value = null;
  1576. }
  1577. fileInput.addEventListener('change', function (evt) {
  1578. var files = evt.target.files;
  1579. if (!files || files.length === 0) {
  1580. return;
  1581. }
  1582. PDFViewerApplication.eventBus.dispatch('fileinputchange', {
  1583. source: this,
  1584. fileInput: evt.target
  1585. });
  1586. });
  1587. appConfig.mainContainer.addEventListener('dragover', function (evt) {
  1588. evt.preventDefault();
  1589. evt.dataTransfer.dropEffect = 'move';
  1590. });
  1591. appConfig.mainContainer.addEventListener('drop', function (evt) {
  1592. evt.preventDefault();
  1593. var files = evt.dataTransfer.files;
  1594. if (!files || files.length === 0) {
  1595. return;
  1596. }
  1597. PDFViewerApplication.eventBus.dispatch('fileinputchange', {
  1598. source: this,
  1599. fileInput: evt.dataTransfer
  1600. });
  1601. });
  1602. if (!PDFViewerApplication.supportsPrinting) {
  1603. appConfig.toolbar.print.classList.add('hidden');
  1604. appConfig.secondaryToolbar.printButton.classList.add('hidden');
  1605. }
  1606. if (!PDFViewerApplication.supportsFullscreen) {
  1607. appConfig.toolbar.presentationModeButton.classList.add('hidden');
  1608. appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden');
  1609. }
  1610. if (PDFViewerApplication.supportsIntegratedFind) {
  1611. appConfig.toolbar.viewFind.classList.add('hidden');
  1612. }
  1613. appConfig.mainContainer.addEventListener('transitionend', function (evt) {
  1614. if (evt.target === this) {
  1615. PDFViewerApplication.eventBus.dispatch('resize', {
  1616. source: this
  1617. });
  1618. }
  1619. }, true);
  1620. appConfig.sidebar.toggleButton.addEventListener('click', function () {
  1621. PDFViewerApplication.pdfSidebar.toggle();
  1622. });
  1623. try {
  1624. webViewerOpenFileViaURL(file);
  1625. } catch (reason) {
  1626. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (msg) {
  1627. PDFViewerApplication.error(msg, reason);
  1628. });
  1629. }
  1630. }
  1631. var webViewerOpenFileViaURL;
  1632. {
  1633. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  1634. if (file && file.lastIndexOf('file:', 0) === 0) {
  1635. PDFViewerApplication.setTitleUsingUrl(file);
  1636. var xhr = new XMLHttpRequest();
  1637. xhr.onload = function () {
  1638. PDFViewerApplication.open(new Uint8Array(xhr.response));
  1639. };
  1640. xhr.open('GET', file);
  1641. xhr.responseType = 'arraybuffer';
  1642. xhr.send();
  1643. return;
  1644. }
  1645. if (file) {
  1646. PDFViewerApplication.open(file);
  1647. }
  1648. };
  1649. }
  1650. function webViewerPageRendered(evt) {
  1651. var pageNumber = evt.pageNumber;
  1652. var pageIndex = pageNumber - 1;
  1653. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  1654. if (pageNumber === PDFViewerApplication.page) {
  1655. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  1656. }
  1657. if (!pageView) {
  1658. return;
  1659. }
  1660. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  1661. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  1662. thumbnailView.setImage(pageView);
  1663. }
  1664. if (typeof Stats !== 'undefined' && Stats.enabled && pageView.stats) {
  1665. Stats.add(pageNumber, pageView.stats);
  1666. }
  1667. if (pageView.error) {
  1668. PDFViewerApplication.l10n.get('rendering_error', null, 'An error occurred while rendering the page.').then(function (msg) {
  1669. PDFViewerApplication.error(msg, pageView.error);
  1670. });
  1671. }
  1672. }
  1673. function webViewerTextLayerRendered(evt) {}
  1674. function webViewerPageMode(evt) {
  1675. var mode = evt.mode,
  1676. view;
  1677. switch (mode) {
  1678. case 'thumbs':
  1679. view = _pdf_sidebar.SidebarView.THUMBS;
  1680. break;
  1681. case 'bookmarks':
  1682. case 'outline':
  1683. view = _pdf_sidebar.SidebarView.OUTLINE;
  1684. break;
  1685. case 'attachments':
  1686. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  1687. break;
  1688. case 'none':
  1689. view = _pdf_sidebar.SidebarView.NONE;
  1690. break;
  1691. default:
  1692. console.error('Invalid "pagemode" hash parameter: ' + mode);
  1693. return;
  1694. }
  1695. PDFViewerApplication.pdfSidebar.switchView(view, true);
  1696. }
  1697. function webViewerNamedAction(evt) {
  1698. var action = evt.action;
  1699. switch (action) {
  1700. case 'GoToPage':
  1701. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  1702. break;
  1703. case 'Find':
  1704. if (!PDFViewerApplication.supportsIntegratedFind) {
  1705. PDFViewerApplication.findBar.toggle();
  1706. }
  1707. break;
  1708. }
  1709. }
  1710. function webViewerPresentationModeChanged(evt) {
  1711. var active = evt.active,
  1712. switchInProgress = evt.switchInProgress;
  1713. PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _ui_utils.PresentationModeState.CHANGING : active ? _ui_utils.PresentationModeState.FULLSCREEN : _ui_utils.PresentationModeState.NORMAL;
  1714. }
  1715. function webViewerSidebarViewChanged(evt) {
  1716. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  1717. var store = PDFViewerApplication.store;
  1718. if (store && PDFViewerApplication.isInitialViewSet) {
  1719. store.set('sidebarView', evt.view)["catch"](function () {});
  1720. }
  1721. }
  1722. function webViewerUpdateViewarea(evt) {
  1723. var location = evt.location,
  1724. store = PDFViewerApplication.store;
  1725. if (store && PDFViewerApplication.isInitialViewSet) {
  1726. store.setMultiple({
  1727. 'page': location.pageNumber,
  1728. 'zoom': location.scale,
  1729. 'scrollLeft': location.left,
  1730. 'scrollTop': location.top,
  1731. 'rotation': location.rotation
  1732. })["catch"](function () {});
  1733. }
  1734. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  1735. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  1736. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  1737. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  1738. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  1739. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  1740. }
  1741. function webViewerScrollModeChanged(evt) {
  1742. var store = PDFViewerApplication.store;
  1743. if (store && PDFViewerApplication.isInitialViewSet) {
  1744. store.set('scrollMode', evt.mode)["catch"](function () {});
  1745. }
  1746. }
  1747. function webViewerSpreadModeChanged(evt) {
  1748. var store = PDFViewerApplication.store;
  1749. if (store && PDFViewerApplication.isInitialViewSet) {
  1750. store.set('spreadMode', evt.mode)["catch"](function () {});
  1751. }
  1752. }
  1753. function webViewerResize() {
  1754. var pdfDocument = PDFViewerApplication.pdfDocument,
  1755. pdfViewer = PDFViewerApplication.pdfViewer;
  1756. if (!pdfDocument) {
  1757. return;
  1758. }
  1759. var currentScaleValue = pdfViewer.currentScaleValue;
  1760. if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
  1761. pdfViewer.currentScaleValue = currentScaleValue;
  1762. }
  1763. pdfViewer.update();
  1764. }
  1765. function webViewerHashchange(evt) {
  1766. var hash = evt.hash;
  1767. if (!hash) {
  1768. return;
  1769. }
  1770. if (!PDFViewerApplication.isInitialViewSet) {
  1771. PDFViewerApplication.initialBookmark = hash;
  1772. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  1773. PDFViewerApplication.pdfLinkService.setHash(hash);
  1774. }
  1775. }
  1776. var webViewerFileInputChange;
  1777. {
  1778. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  1779. if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
  1780. return;
  1781. }
  1782. var file = evt.fileInput.files[0];
  1783. if (_pdfjsLib.URL.createObjectURL && !_app_options.AppOptions.get('disableCreateObjectURL')) {
  1784. var url = _pdfjsLib.URL.createObjectURL(file);
  1785. if (file.name) {
  1786. url = {
  1787. url: url,
  1788. originalUrl: file.name
  1789. };
  1790. }
  1791. PDFViewerApplication.open(url);
  1792. } else {
  1793. PDFViewerApplication.setTitleUsingUrl(file.name);
  1794. var fileReader = new FileReader();
  1795. fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
  1796. var buffer = evt.target.result;
  1797. PDFViewerApplication.open(new Uint8Array(buffer));
  1798. };
  1799. fileReader.readAsArrayBuffer(file);
  1800. }
  1801. var appConfig = PDFViewerApplication.appConfig;
  1802. appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
  1803. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
  1804. appConfig.toolbar.download.setAttribute('hidden', 'true');
  1805. appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');
  1806. };
  1807. }
  1808. function webViewerPresentationMode() {
  1809. PDFViewerApplication.requestPresentationMode();
  1810. }
  1811. function webViewerOpenFile() {
  1812. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  1813. document.getElementById(openFileInputName).click();
  1814. }
  1815. function webViewerPrint() {
  1816. window.print();
  1817. }
  1818. function webViewerDownload() {
  1819. PDFViewerApplication.download();
  1820. }
  1821. function webViewerFirstPage() {
  1822. if (PDFViewerApplication.pdfDocument) {
  1823. PDFViewerApplication.page = 1;
  1824. }
  1825. }
  1826. function webViewerLastPage() {
  1827. if (PDFViewerApplication.pdfDocument) {
  1828. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  1829. }
  1830. }
  1831. function webViewerNextPage() {
  1832. PDFViewerApplication.page++;
  1833. }
  1834. function webViewerPreviousPage() {
  1835. PDFViewerApplication.page--;
  1836. }
  1837. function webViewerZoomIn() {
  1838. PDFViewerApplication.zoomIn();
  1839. }
  1840. function webViewerZoomOut() {
  1841. PDFViewerApplication.zoomOut();
  1842. }
  1843. function webViewerZoomReset(evt) {
  1844. PDFViewerApplication.zoomReset(evt && evt.ignoreDuplicate);
  1845. }
  1846. function webViewerPageNumberChanged(evt) {
  1847. var pdfViewer = PDFViewerApplication.pdfViewer;
  1848. if (evt.value !== '') {
  1849. pdfViewer.currentPageLabel = evt.value;
  1850. }
  1851. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  1852. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1853. }
  1854. }
  1855. function webViewerScaleChanged(evt) {
  1856. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  1857. }
  1858. function webViewerRotateCw() {
  1859. PDFViewerApplication.rotatePages(90);
  1860. }
  1861. function webViewerRotateCcw() {
  1862. PDFViewerApplication.rotatePages(-90);
  1863. }
  1864. function webViewerSwitchScrollMode(evt) {
  1865. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  1866. }
  1867. function webViewerSwitchSpreadMode(evt) {
  1868. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  1869. }
  1870. function webViewerDocumentProperties() {
  1871. PDFViewerApplication.pdfDocumentProperties.open();
  1872. }
  1873. function webViewerFind(evt) {
  1874. PDFViewerApplication.findController.executeCommand('find' + evt.type, {
  1875. query: evt.query,
  1876. phraseSearch: evt.phraseSearch,
  1877. caseSensitive: evt.caseSensitive,
  1878. entireWord: evt.entireWord,
  1879. highlightAll: evt.highlightAll,
  1880. findPrevious: evt.findPrevious
  1881. });
  1882. }
  1883. function webViewerFindFromUrlHash(evt) {
  1884. PDFViewerApplication.findController.executeCommand('find', {
  1885. query: evt.query,
  1886. phraseSearch: evt.phraseSearch,
  1887. caseSensitive: false,
  1888. entireWord: false,
  1889. highlightAll: true,
  1890. findPrevious: false
  1891. });
  1892. }
  1893. function webViewerUpdateFindMatchesCount(_ref9) {
  1894. var matchesCount = _ref9.matchesCount;
  1895. if (PDFViewerApplication.supportsIntegratedFind) {
  1896. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  1897. } else {
  1898. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  1899. }
  1900. }
  1901. function webViewerUpdateFindControlState(_ref10) {
  1902. var state = _ref10.state,
  1903. previous = _ref10.previous,
  1904. matchesCount = _ref10.matchesCount;
  1905. if (PDFViewerApplication.supportsIntegratedFind) {
  1906. PDFViewerApplication.externalServices.updateFindControlState({
  1907. result: state,
  1908. findPrevious: previous,
  1909. matchesCount: matchesCount
  1910. });
  1911. } else {
  1912. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  1913. }
  1914. }
  1915. function webViewerScaleChanging(evt) {
  1916. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  1917. PDFViewerApplication.pdfViewer.update();
  1918. }
  1919. function webViewerRotationChanging(evt) {
  1920. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  1921. PDFViewerApplication.forceRendering();
  1922. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  1923. }
  1924. function webViewerPageChanging(evt) {
  1925. var page = evt.pageNumber;
  1926. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  1927. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  1928. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  1929. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
  1930. }
  1931. if (typeof Stats !== 'undefined' && Stats.enabled) {
  1932. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  1933. if (pageView && pageView.stats) {
  1934. Stats.add(page, pageView.stats);
  1935. }
  1936. }
  1937. }
  1938. function webViewerVisibilityChange(evt) {
  1939. if (document.visibilityState === 'visible') {
  1940. setZoomDisabledTimeout();
  1941. }
  1942. }
  1943. var zoomDisabledTimeout = null;
  1944. function setZoomDisabledTimeout() {
  1945. if (zoomDisabledTimeout) {
  1946. clearTimeout(zoomDisabledTimeout);
  1947. }
  1948. zoomDisabledTimeout = setTimeout(function () {
  1949. zoomDisabledTimeout = null;
  1950. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  1951. }
  1952. function webViewerWheel(evt) {
  1953. var pdfViewer = PDFViewerApplication.pdfViewer;
  1954. if (pdfViewer.isInPresentationMode) {
  1955. return;
  1956. }
  1957. if (evt.ctrlKey || evt.metaKey) {
  1958. var support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  1959. if (evt.ctrlKey && !support.ctrlKey || evt.metaKey && !support.metaKey) {
  1960. return;
  1961. }
  1962. evt.preventDefault();
  1963. if (zoomDisabledTimeout || document.visibilityState === 'hidden') {
  1964. return;
  1965. }
  1966. var previousScale = pdfViewer.currentScale;
  1967. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  1968. var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
  1969. var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
  1970. if (ticks < 0) {
  1971. PDFViewerApplication.zoomOut(-ticks);
  1972. } else {
  1973. PDFViewerApplication.zoomIn(ticks);
  1974. }
  1975. var currentScale = pdfViewer.currentScale;
  1976. if (previousScale !== currentScale) {
  1977. var scaleCorrectionFactor = currentScale / previousScale - 1;
  1978. var rect = pdfViewer.container.getBoundingClientRect();
  1979. var dx = evt.clientX - rect.left;
  1980. var dy = evt.clientY - rect.top;
  1981. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  1982. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  1983. }
  1984. } else {
  1985. setZoomDisabledTimeout();
  1986. }
  1987. }
  1988. function webViewerClick(evt) {
  1989. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  1990. return;
  1991. }
  1992. var appConfig = PDFViewerApplication.appConfig;
  1993. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  1994. PDFViewerApplication.secondaryToolbar.close();
  1995. }
  1996. }
  1997. function webViewerKeyDown(evt) {
  1998. if (PDFViewerApplication.overlayManager.active) {
  1999. return;
  2000. }
  2001. var handled = false,
  2002. ensureViewerFocused = false;
  2003. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  2004. var pdfViewer = PDFViewerApplication.pdfViewer;
  2005. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  2006. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  2007. switch (evt.keyCode) {
  2008. case 70:
  2009. if (!PDFViewerApplication.supportsIntegratedFind) {
  2010. PDFViewerApplication.findBar.open();
  2011. handled = true;
  2012. }
  2013. break;
  2014. case 71:
  2015. if (!PDFViewerApplication.supportsIntegratedFind) {
  2016. var findState = PDFViewerApplication.findController.state;
  2017. if (findState) {
  2018. PDFViewerApplication.findController.executeCommand('findagain', {
  2019. query: findState.query,
  2020. phraseSearch: findState.phraseSearch,
  2021. caseSensitive: findState.caseSensitive,
  2022. entireWord: findState.entireWord,
  2023. highlightAll: findState.highlightAll,
  2024. findPrevious: cmd === 5 || cmd === 12
  2025. });
  2026. }
  2027. handled = true;
  2028. }
  2029. break;
  2030. case 61:
  2031. case 107:
  2032. case 187:
  2033. case 171:
  2034. if (!isViewerInPresentationMode) {
  2035. PDFViewerApplication.zoomIn();
  2036. }
  2037. handled = true;
  2038. break;
  2039. case 173:
  2040. case 109:
  2041. case 189:
  2042. if (!isViewerInPresentationMode) {
  2043. PDFViewerApplication.zoomOut();
  2044. }
  2045. handled = true;
  2046. break;
  2047. case 48:
  2048. case 96:
  2049. if (!isViewerInPresentationMode) {
  2050. setTimeout(function () {
  2051. PDFViewerApplication.zoomReset();
  2052. });
  2053. handled = false;
  2054. }
  2055. break;
  2056. case 38:
  2057. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2058. PDFViewerApplication.page = 1;
  2059. handled = true;
  2060. ensureViewerFocused = true;
  2061. }
  2062. break;
  2063. case 40:
  2064. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2065. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2066. handled = true;
  2067. ensureViewerFocused = true;
  2068. }
  2069. break;
  2070. }
  2071. }
  2072. if (cmd === 1 || cmd === 8) {
  2073. switch (evt.keyCode) {
  2074. case 83:
  2075. PDFViewerApplication.download();
  2076. handled = true;
  2077. break;
  2078. }
  2079. }
  2080. if (cmd === 3 || cmd === 10) {
  2081. switch (evt.keyCode) {
  2082. case 80:
  2083. PDFViewerApplication.requestPresentationMode();
  2084. handled = true;
  2085. break;
  2086. case 71:
  2087. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2088. handled = true;
  2089. break;
  2090. }
  2091. }
  2092. if (handled) {
  2093. if (ensureViewerFocused && !isViewerInPresentationMode) {
  2094. pdfViewer.focus();
  2095. }
  2096. evt.preventDefault();
  2097. return;
  2098. }
  2099. var curElement = document.activeElement || document.querySelector(':focus');
  2100. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  2101. if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName === 'SELECT') {
  2102. if (evt.keyCode !== 27) {
  2103. return;
  2104. }
  2105. }
  2106. if (cmd === 0) {
  2107. var turnPage = 0,
  2108. turnOnlyIfPageFit = false;
  2109. switch (evt.keyCode) {
  2110. case 38:
  2111. case 33:
  2112. if (pdfViewer.isVerticalScrollbarEnabled) {
  2113. turnOnlyIfPageFit = true;
  2114. }
  2115. turnPage = -1;
  2116. break;
  2117. case 8:
  2118. if (!isViewerInPresentationMode) {
  2119. turnOnlyIfPageFit = true;
  2120. }
  2121. turnPage = -1;
  2122. break;
  2123. case 37:
  2124. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2125. turnOnlyIfPageFit = true;
  2126. }
  2127. case 75:
  2128. case 80:
  2129. turnPage = -1;
  2130. break;
  2131. case 27:
  2132. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  2133. PDFViewerApplication.secondaryToolbar.close();
  2134. handled = true;
  2135. }
  2136. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  2137. PDFViewerApplication.findBar.close();
  2138. handled = true;
  2139. }
  2140. break;
  2141. case 40:
  2142. case 34:
  2143. if (pdfViewer.isVerticalScrollbarEnabled) {
  2144. turnOnlyIfPageFit = true;
  2145. }
  2146. turnPage = 1;
  2147. break;
  2148. case 13:
  2149. case 32:
  2150. if (!isViewerInPresentationMode) {
  2151. turnOnlyIfPageFit = true;
  2152. }
  2153. turnPage = 1;
  2154. break;
  2155. case 39:
  2156. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2157. turnOnlyIfPageFit = true;
  2158. }
  2159. case 74:
  2160. case 78:
  2161. turnPage = 1;
  2162. break;
  2163. case 36:
  2164. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2165. PDFViewerApplication.page = 1;
  2166. handled = true;
  2167. ensureViewerFocused = true;
  2168. }
  2169. break;
  2170. case 35:
  2171. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2172. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2173. handled = true;
  2174. ensureViewerFocused = true;
  2175. }
  2176. break;
  2177. case 83:
  2178. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  2179. break;
  2180. case 72:
  2181. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  2182. break;
  2183. case 82:
  2184. PDFViewerApplication.rotatePages(90);
  2185. break;
  2186. case 115:
  2187. PDFViewerApplication.pdfSidebar.toggle();
  2188. break;
  2189. }
  2190. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === 'page-fit')) {
  2191. if (turnPage > 0) {
  2192. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2193. PDFViewerApplication.page++;
  2194. }
  2195. } else {
  2196. if (PDFViewerApplication.page > 1) {
  2197. PDFViewerApplication.page--;
  2198. }
  2199. }
  2200. handled = true;
  2201. }
  2202. }
  2203. if (cmd === 4) {
  2204. switch (evt.keyCode) {
  2205. case 13:
  2206. case 32:
  2207. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  2208. break;
  2209. }
  2210. if (PDFViewerApplication.page > 1) {
  2211. PDFViewerApplication.page--;
  2212. }
  2213. handled = true;
  2214. break;
  2215. case 82:
  2216. PDFViewerApplication.rotatePages(-90);
  2217. break;
  2218. }
  2219. }
  2220. if (!handled && !isViewerInPresentationMode) {
  2221. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
  2222. ensureViewerFocused = true;
  2223. }
  2224. }
  2225. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  2226. pdfViewer.focus();
  2227. }
  2228. if (handled) {
  2229. evt.preventDefault();
  2230. }
  2231. }
  2232. function apiPageLayoutToSpreadMode(layout) {
  2233. switch (layout) {
  2234. case 'SinglePage':
  2235. case 'OneColumn':
  2236. return _ui_utils.SpreadMode.NONE;
  2237. case 'TwoColumnLeft':
  2238. case 'TwoPageLeft':
  2239. return _ui_utils.SpreadMode.ODD;
  2240. case 'TwoColumnRight':
  2241. case 'TwoPageRight':
  2242. return _ui_utils.SpreadMode.EVEN;
  2243. }
  2244. return _ui_utils.SpreadMode.NONE;
  2245. }
  2246. function apiPageModeToSidebarView(mode) {
  2247. switch (mode) {
  2248. case 'UseNone':
  2249. return _pdf_sidebar.SidebarView.NONE;
  2250. case 'UseThumbs':
  2251. return _pdf_sidebar.SidebarView.THUMBS;
  2252. case 'UseOutlines':
  2253. return _pdf_sidebar.SidebarView.OUTLINE;
  2254. case 'UseAttachments':
  2255. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  2256. case 'UseOC':
  2257. }
  2258. return _pdf_sidebar.SidebarView.NONE;
  2259. }
  2260. var PDFPrintServiceFactory = {
  2261. instance: {
  2262. supportsPrinting: false,
  2263. createPrintService: function createPrintService() {
  2264. throw new Error('Not implemented: createPrintService');
  2265. }
  2266. }
  2267. };
  2268. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  2269. /***/ }),
  2270. /* 2 */
  2271. /***/ (function(module, exports, __webpack_require__) {
  2272. "use strict";
  2273. module.exports = __webpack_require__(3);
  2274. /***/ }),
  2275. /* 3 */
  2276. /***/ (function(module, exports, __webpack_require__) {
  2277. "use strict";
  2278. /* WEBPACK VAR INJECTION */(function(module) {
  2279. function _typeof(obj) { 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); }
  2280. var runtime = function (exports) {
  2281. "use strict";
  2282. var Op = Object.prototype;
  2283. var hasOwn = Op.hasOwnProperty;
  2284. var undefined;
  2285. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  2286. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  2287. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  2288. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  2289. function wrap(innerFn, outerFn, self, tryLocsList) {
  2290. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  2291. var generator = Object.create(protoGenerator.prototype);
  2292. var context = new Context(tryLocsList || []);
  2293. generator._invoke = makeInvokeMethod(innerFn, self, context);
  2294. return generator;
  2295. }
  2296. exports.wrap = wrap;
  2297. function tryCatch(fn, obj, arg) {
  2298. try {
  2299. return {
  2300. type: "normal",
  2301. arg: fn.call(obj, arg)
  2302. };
  2303. } catch (err) {
  2304. return {
  2305. type: "throw",
  2306. arg: err
  2307. };
  2308. }
  2309. }
  2310. var GenStateSuspendedStart = "suspendedStart";
  2311. var GenStateSuspendedYield = "suspendedYield";
  2312. var GenStateExecuting = "executing";
  2313. var GenStateCompleted = "completed";
  2314. var ContinueSentinel = {};
  2315. function Generator() {}
  2316. function GeneratorFunction() {}
  2317. function GeneratorFunctionPrototype() {}
  2318. var IteratorPrototype = {};
  2319. IteratorPrototype[iteratorSymbol] = function () {
  2320. return this;
  2321. };
  2322. var getProto = Object.getPrototypeOf;
  2323. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  2324. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  2325. IteratorPrototype = NativeIteratorPrototype;
  2326. }
  2327. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  2328. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  2329. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  2330. GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
  2331. function defineIteratorMethods(prototype) {
  2332. ["next", "throw", "return"].forEach(function (method) {
  2333. prototype[method] = function (arg) {
  2334. return this._invoke(method, arg);
  2335. };
  2336. });
  2337. }
  2338. exports.isGeneratorFunction = function (genFun) {
  2339. var ctor = typeof genFun === "function" && genFun.constructor;
  2340. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  2341. };
  2342. exports.mark = function (genFun) {
  2343. if (Object.setPrototypeOf) {
  2344. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  2345. } else {
  2346. genFun.__proto__ = GeneratorFunctionPrototype;
  2347. if (!(toStringTagSymbol in genFun)) {
  2348. genFun[toStringTagSymbol] = "GeneratorFunction";
  2349. }
  2350. }
  2351. genFun.prototype = Object.create(Gp);
  2352. return genFun;
  2353. };
  2354. exports.awrap = function (arg) {
  2355. return {
  2356. __await: arg
  2357. };
  2358. };
  2359. function AsyncIterator(generator) {
  2360. function invoke(method, arg, resolve, reject) {
  2361. var record = tryCatch(generator[method], generator, arg);
  2362. if (record.type === "throw") {
  2363. reject(record.arg);
  2364. } else {
  2365. var result = record.arg;
  2366. var value = result.value;
  2367. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  2368. return Promise.resolve(value.__await).then(function (value) {
  2369. invoke("next", value, resolve, reject);
  2370. }, function (err) {
  2371. invoke("throw", err, resolve, reject);
  2372. });
  2373. }
  2374. return Promise.resolve(value).then(function (unwrapped) {
  2375. result.value = unwrapped;
  2376. resolve(result);
  2377. }, function (error) {
  2378. return invoke("throw", error, resolve, reject);
  2379. });
  2380. }
  2381. }
  2382. var previousPromise;
  2383. function enqueue(method, arg) {
  2384. function callInvokeWithMethodAndArg() {
  2385. return new Promise(function (resolve, reject) {
  2386. invoke(method, arg, resolve, reject);
  2387. });
  2388. }
  2389. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  2390. }
  2391. this._invoke = enqueue;
  2392. }
  2393. defineIteratorMethods(AsyncIterator.prototype);
  2394. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  2395. return this;
  2396. };
  2397. exports.AsyncIterator = AsyncIterator;
  2398. exports.async = function (innerFn, outerFn, self, tryLocsList) {
  2399. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
  2400. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  2401. return result.done ? result.value : iter.next();
  2402. });
  2403. };
  2404. function makeInvokeMethod(innerFn, self, context) {
  2405. var state = GenStateSuspendedStart;
  2406. return function invoke(method, arg) {
  2407. if (state === GenStateExecuting) {
  2408. throw new Error("Generator is already running");
  2409. }
  2410. if (state === GenStateCompleted) {
  2411. if (method === "throw") {
  2412. throw arg;
  2413. }
  2414. return doneResult();
  2415. }
  2416. context.method = method;
  2417. context.arg = arg;
  2418. while (true) {
  2419. var delegate = context.delegate;
  2420. if (delegate) {
  2421. var delegateResult = maybeInvokeDelegate(delegate, context);
  2422. if (delegateResult) {
  2423. if (delegateResult === ContinueSentinel) continue;
  2424. return delegateResult;
  2425. }
  2426. }
  2427. if (context.method === "next") {
  2428. context.sent = context._sent = context.arg;
  2429. } else if (context.method === "throw") {
  2430. if (state === GenStateSuspendedStart) {
  2431. state = GenStateCompleted;
  2432. throw context.arg;
  2433. }
  2434. context.dispatchException(context.arg);
  2435. } else if (context.method === "return") {
  2436. context.abrupt("return", context.arg);
  2437. }
  2438. state = GenStateExecuting;
  2439. var record = tryCatch(innerFn, self, context);
  2440. if (record.type === "normal") {
  2441. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  2442. if (record.arg === ContinueSentinel) {
  2443. continue;
  2444. }
  2445. return {
  2446. value: record.arg,
  2447. done: context.done
  2448. };
  2449. } else if (record.type === "throw") {
  2450. state = GenStateCompleted;
  2451. context.method = "throw";
  2452. context.arg = record.arg;
  2453. }
  2454. }
  2455. };
  2456. }
  2457. function maybeInvokeDelegate(delegate, context) {
  2458. var method = delegate.iterator[context.method];
  2459. if (method === undefined) {
  2460. context.delegate = null;
  2461. if (context.method === "throw") {
  2462. if (delegate.iterator["return"]) {
  2463. context.method = "return";
  2464. context.arg = undefined;
  2465. maybeInvokeDelegate(delegate, context);
  2466. if (context.method === "throw") {
  2467. return ContinueSentinel;
  2468. }
  2469. }
  2470. context.method = "throw";
  2471. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  2472. }
  2473. return ContinueSentinel;
  2474. }
  2475. var record = tryCatch(method, delegate.iterator, context.arg);
  2476. if (record.type === "throw") {
  2477. context.method = "throw";
  2478. context.arg = record.arg;
  2479. context.delegate = null;
  2480. return ContinueSentinel;
  2481. }
  2482. var info = record.arg;
  2483. if (!info) {
  2484. context.method = "throw";
  2485. context.arg = new TypeError("iterator result is not an object");
  2486. context.delegate = null;
  2487. return ContinueSentinel;
  2488. }
  2489. if (info.done) {
  2490. context[delegate.resultName] = info.value;
  2491. context.next = delegate.nextLoc;
  2492. if (context.method !== "return") {
  2493. context.method = "next";
  2494. context.arg = undefined;
  2495. }
  2496. } else {
  2497. return info;
  2498. }
  2499. context.delegate = null;
  2500. return ContinueSentinel;
  2501. }
  2502. defineIteratorMethods(Gp);
  2503. Gp[toStringTagSymbol] = "Generator";
  2504. Gp[iteratorSymbol] = function () {
  2505. return this;
  2506. };
  2507. Gp.toString = function () {
  2508. return "[object Generator]";
  2509. };
  2510. function pushTryEntry(locs) {
  2511. var entry = {
  2512. tryLoc: locs[0]
  2513. };
  2514. if (1 in locs) {
  2515. entry.catchLoc = locs[1];
  2516. }
  2517. if (2 in locs) {
  2518. entry.finallyLoc = locs[2];
  2519. entry.afterLoc = locs[3];
  2520. }
  2521. this.tryEntries.push(entry);
  2522. }
  2523. function resetTryEntry(entry) {
  2524. var record = entry.completion || {};
  2525. record.type = "normal";
  2526. delete record.arg;
  2527. entry.completion = record;
  2528. }
  2529. function Context(tryLocsList) {
  2530. this.tryEntries = [{
  2531. tryLoc: "root"
  2532. }];
  2533. tryLocsList.forEach(pushTryEntry, this);
  2534. this.reset(true);
  2535. }
  2536. exports.keys = function (object) {
  2537. var keys = [];
  2538. for (var key in object) {
  2539. keys.push(key);
  2540. }
  2541. keys.reverse();
  2542. return function next() {
  2543. while (keys.length) {
  2544. var key = keys.pop();
  2545. if (key in object) {
  2546. next.value = key;
  2547. next.done = false;
  2548. return next;
  2549. }
  2550. }
  2551. next.done = true;
  2552. return next;
  2553. };
  2554. };
  2555. function values(iterable) {
  2556. if (iterable) {
  2557. var iteratorMethod = iterable[iteratorSymbol];
  2558. if (iteratorMethod) {
  2559. return iteratorMethod.call(iterable);
  2560. }
  2561. if (typeof iterable.next === "function") {
  2562. return iterable;
  2563. }
  2564. if (!isNaN(iterable.length)) {
  2565. var i = -1,
  2566. next = function next() {
  2567. while (++i < iterable.length) {
  2568. if (hasOwn.call(iterable, i)) {
  2569. next.value = iterable[i];
  2570. next.done = false;
  2571. return next;
  2572. }
  2573. }
  2574. next.value = undefined;
  2575. next.done = true;
  2576. return next;
  2577. };
  2578. return next.next = next;
  2579. }
  2580. }
  2581. return {
  2582. next: doneResult
  2583. };
  2584. }
  2585. exports.values = values;
  2586. function doneResult() {
  2587. return {
  2588. value: undefined,
  2589. done: true
  2590. };
  2591. }
  2592. Context.prototype = {
  2593. constructor: Context,
  2594. reset: function reset(skipTempReset) {
  2595. this.prev = 0;
  2596. this.next = 0;
  2597. this.sent = this._sent = undefined;
  2598. this.done = false;
  2599. this.delegate = null;
  2600. this.method = "next";
  2601. this.arg = undefined;
  2602. this.tryEntries.forEach(resetTryEntry);
  2603. if (!skipTempReset) {
  2604. for (var name in this) {
  2605. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  2606. this[name] = undefined;
  2607. }
  2608. }
  2609. }
  2610. },
  2611. stop: function stop() {
  2612. this.done = true;
  2613. var rootEntry = this.tryEntries[0];
  2614. var rootRecord = rootEntry.completion;
  2615. if (rootRecord.type === "throw") {
  2616. throw rootRecord.arg;
  2617. }
  2618. return this.rval;
  2619. },
  2620. dispatchException: function dispatchException(exception) {
  2621. if (this.done) {
  2622. throw exception;
  2623. }
  2624. var context = this;
  2625. function handle(loc, caught) {
  2626. record.type = "throw";
  2627. record.arg = exception;
  2628. context.next = loc;
  2629. if (caught) {
  2630. context.method = "next";
  2631. context.arg = undefined;
  2632. }
  2633. return !!caught;
  2634. }
  2635. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2636. var entry = this.tryEntries[i];
  2637. var record = entry.completion;
  2638. if (entry.tryLoc === "root") {
  2639. return handle("end");
  2640. }
  2641. if (entry.tryLoc <= this.prev) {
  2642. var hasCatch = hasOwn.call(entry, "catchLoc");
  2643. var hasFinally = hasOwn.call(entry, "finallyLoc");
  2644. if (hasCatch && hasFinally) {
  2645. if (this.prev < entry.catchLoc) {
  2646. return handle(entry.catchLoc, true);
  2647. } else if (this.prev < entry.finallyLoc) {
  2648. return handle(entry.finallyLoc);
  2649. }
  2650. } else if (hasCatch) {
  2651. if (this.prev < entry.catchLoc) {
  2652. return handle(entry.catchLoc, true);
  2653. }
  2654. } else if (hasFinally) {
  2655. if (this.prev < entry.finallyLoc) {
  2656. return handle(entry.finallyLoc);
  2657. }
  2658. } else {
  2659. throw new Error("try statement without catch or finally");
  2660. }
  2661. }
  2662. }
  2663. },
  2664. abrupt: function abrupt(type, arg) {
  2665. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2666. var entry = this.tryEntries[i];
  2667. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  2668. var finallyEntry = entry;
  2669. break;
  2670. }
  2671. }
  2672. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  2673. finallyEntry = null;
  2674. }
  2675. var record = finallyEntry ? finallyEntry.completion : {};
  2676. record.type = type;
  2677. record.arg = arg;
  2678. if (finallyEntry) {
  2679. this.method = "next";
  2680. this.next = finallyEntry.finallyLoc;
  2681. return ContinueSentinel;
  2682. }
  2683. return this.complete(record);
  2684. },
  2685. complete: function complete(record, afterLoc) {
  2686. if (record.type === "throw") {
  2687. throw record.arg;
  2688. }
  2689. if (record.type === "break" || record.type === "continue") {
  2690. this.next = record.arg;
  2691. } else if (record.type === "return") {
  2692. this.rval = this.arg = record.arg;
  2693. this.method = "return";
  2694. this.next = "end";
  2695. } else if (record.type === "normal" && afterLoc) {
  2696. this.next = afterLoc;
  2697. }
  2698. return ContinueSentinel;
  2699. },
  2700. finish: function finish(finallyLoc) {
  2701. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2702. var entry = this.tryEntries[i];
  2703. if (entry.finallyLoc === finallyLoc) {
  2704. this.complete(entry.completion, entry.afterLoc);
  2705. resetTryEntry(entry);
  2706. return ContinueSentinel;
  2707. }
  2708. }
  2709. },
  2710. "catch": function _catch(tryLoc) {
  2711. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2712. var entry = this.tryEntries[i];
  2713. if (entry.tryLoc === tryLoc) {
  2714. var record = entry.completion;
  2715. if (record.type === "throw") {
  2716. var thrown = record.arg;
  2717. resetTryEntry(entry);
  2718. }
  2719. return thrown;
  2720. }
  2721. }
  2722. throw new Error("illegal catch attempt");
  2723. },
  2724. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  2725. this.delegate = {
  2726. iterator: values(iterable),
  2727. resultName: resultName,
  2728. nextLoc: nextLoc
  2729. };
  2730. if (this.method === "next") {
  2731. this.arg = undefined;
  2732. }
  2733. return ContinueSentinel;
  2734. }
  2735. };
  2736. return exports;
  2737. }(( false ? undefined : _typeof(module)) === "object" ? module.exports : {});
  2738. try {
  2739. regeneratorRuntime = runtime;
  2740. } catch (accidentalStrictMode) {
  2741. Function("r", "regeneratorRuntime = r")(runtime);
  2742. }
  2743. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4)(module)))
  2744. /***/ }),
  2745. /* 4 */
  2746. /***/ (function(module, exports, __webpack_require__) {
  2747. "use strict";
  2748. module.exports = function (module) {
  2749. if (!module.webpackPolyfill) {
  2750. module.deprecate = function () {};
  2751. module.paths = [];
  2752. if (!module.children) module.children = [];
  2753. Object.defineProperty(module, "loaded", {
  2754. enumerable: true,
  2755. get: function get() {
  2756. return module.l;
  2757. }
  2758. });
  2759. Object.defineProperty(module, "id", {
  2760. enumerable: true,
  2761. get: function get() {
  2762. return module.i;
  2763. }
  2764. });
  2765. module.webpackPolyfill = 1;
  2766. }
  2767. return module;
  2768. };
  2769. /***/ }),
  2770. /* 5 */
  2771. /***/ (function(module, exports, __webpack_require__) {
  2772. "use strict";
  2773. Object.defineProperty(exports, "__esModule", {
  2774. value: true
  2775. });
  2776. exports.isValidRotation = isValidRotation;
  2777. exports.isValidScrollMode = isValidScrollMode;
  2778. exports.isValidSpreadMode = isValidSpreadMode;
  2779. exports.isPortraitOrientation = isPortraitOrientation;
  2780. exports.getGlobalEventBus = getGlobalEventBus;
  2781. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  2782. exports.noContextMenuHandler = noContextMenuHandler;
  2783. exports.parseQueryString = parseQueryString;
  2784. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  2785. exports.getVisibleElements = getVisibleElements;
  2786. exports.roundToDivide = roundToDivide;
  2787. exports.getPageSizeInches = getPageSizeInches;
  2788. exports.approximateFraction = approximateFraction;
  2789. exports.getOutputScale = getOutputScale;
  2790. exports.scrollIntoView = scrollIntoView;
  2791. exports.watchScroll = watchScroll;
  2792. exports.binarySearchFirstItem = binarySearchFirstItem;
  2793. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  2794. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  2795. exports.moveToEndOfArray = moveToEndOfArray;
  2796. exports.WaitOnType = exports.animationStarted = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.SpreadMode = exports.ScrollMode = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = void 0;
  2797. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  2798. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2799. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2800. 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); } }
  2801. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2802. function _typeof(obj) { 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); }
  2803. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  2804. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  2805. function _iterableToArrayLimit(arr, i) { 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; }
  2806. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  2807. 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); } }
  2808. 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); }); }; }
  2809. var CSS_UNITS = 96.0 / 72.0;
  2810. exports.CSS_UNITS = CSS_UNITS;
  2811. var DEFAULT_SCALE_VALUE = 'auto';
  2812. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  2813. var DEFAULT_SCALE = 1.0;
  2814. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  2815. var MIN_SCALE = 0.10;
  2816. exports.MIN_SCALE = MIN_SCALE;
  2817. var MAX_SCALE = 10.0;
  2818. exports.MAX_SCALE = MAX_SCALE;
  2819. var UNKNOWN_SCALE = 0;
  2820. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  2821. var MAX_AUTO_SCALE = 1.25;
  2822. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  2823. var SCROLLBAR_PADDING = 40;
  2824. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  2825. var VERTICAL_PADDING = 5;
  2826. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  2827. var PresentationModeState = {
  2828. UNKNOWN: 0,
  2829. NORMAL: 1,
  2830. CHANGING: 2,
  2831. FULLSCREEN: 3
  2832. };
  2833. exports.PresentationModeState = PresentationModeState;
  2834. var RendererType = {
  2835. CANVAS: 'canvas',
  2836. SVG: 'svg'
  2837. };
  2838. exports.RendererType = RendererType;
  2839. var TextLayerMode = {
  2840. DISABLE: 0,
  2841. ENABLE: 1,
  2842. ENABLE_ENHANCE: 2
  2843. };
  2844. exports.TextLayerMode = TextLayerMode;
  2845. var ScrollMode = {
  2846. UNKNOWN: -1,
  2847. VERTICAL: 0,
  2848. HORIZONTAL: 1,
  2849. WRAPPED: 2
  2850. };
  2851. exports.ScrollMode = ScrollMode;
  2852. var SpreadMode = {
  2853. UNKNOWN: -1,
  2854. NONE: 0,
  2855. ODD: 1,
  2856. EVEN: 2
  2857. };
  2858. exports.SpreadMode = SpreadMode;
  2859. function formatL10nValue(text, args) {
  2860. if (!args) {
  2861. return text;
  2862. }
  2863. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  2864. return name in args ? args[name] : '{{' + name + '}}';
  2865. });
  2866. }
  2867. var NullL10n = {
  2868. getLanguage: function () {
  2869. var _getLanguage = _asyncToGenerator(
  2870. /*#__PURE__*/
  2871. _regenerator["default"].mark(function _callee() {
  2872. return _regenerator["default"].wrap(function _callee$(_context) {
  2873. while (1) {
  2874. switch (_context.prev = _context.next) {
  2875. case 0:
  2876. return _context.abrupt("return", 'en-us');
  2877. case 1:
  2878. case "end":
  2879. return _context.stop();
  2880. }
  2881. }
  2882. }, _callee);
  2883. }));
  2884. function getLanguage() {
  2885. return _getLanguage.apply(this, arguments);
  2886. }
  2887. return getLanguage;
  2888. }(),
  2889. getDirection: function () {
  2890. var _getDirection = _asyncToGenerator(
  2891. /*#__PURE__*/
  2892. _regenerator["default"].mark(function _callee2() {
  2893. return _regenerator["default"].wrap(function _callee2$(_context2) {
  2894. while (1) {
  2895. switch (_context2.prev = _context2.next) {
  2896. case 0:
  2897. return _context2.abrupt("return", 'ltr');
  2898. case 1:
  2899. case "end":
  2900. return _context2.stop();
  2901. }
  2902. }
  2903. }, _callee2);
  2904. }));
  2905. function getDirection() {
  2906. return _getDirection.apply(this, arguments);
  2907. }
  2908. return getDirection;
  2909. }(),
  2910. get: function () {
  2911. var _get = _asyncToGenerator(
  2912. /*#__PURE__*/
  2913. _regenerator["default"].mark(function _callee3(property, args, fallback) {
  2914. return _regenerator["default"].wrap(function _callee3$(_context3) {
  2915. while (1) {
  2916. switch (_context3.prev = _context3.next) {
  2917. case 0:
  2918. return _context3.abrupt("return", formatL10nValue(fallback, args));
  2919. case 1:
  2920. case "end":
  2921. return _context3.stop();
  2922. }
  2923. }
  2924. }, _callee3);
  2925. }));
  2926. function get(_x, _x2, _x3) {
  2927. return _get.apply(this, arguments);
  2928. }
  2929. return get;
  2930. }(),
  2931. translate: function () {
  2932. var _translate = _asyncToGenerator(
  2933. /*#__PURE__*/
  2934. _regenerator["default"].mark(function _callee4(element) {
  2935. return _regenerator["default"].wrap(function _callee4$(_context4) {
  2936. while (1) {
  2937. switch (_context4.prev = _context4.next) {
  2938. case 0:
  2939. case "end":
  2940. return _context4.stop();
  2941. }
  2942. }
  2943. }, _callee4);
  2944. }));
  2945. function translate(_x4) {
  2946. return _translate.apply(this, arguments);
  2947. }
  2948. return translate;
  2949. }()
  2950. };
  2951. exports.NullL10n = NullL10n;
  2952. function getOutputScale(ctx) {
  2953. var devicePixelRatio = window.devicePixelRatio || 1;
  2954. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  2955. var pixelRatio = devicePixelRatio / backingStoreRatio;
  2956. return {
  2957. sx: pixelRatio,
  2958. sy: pixelRatio,
  2959. scaled: pixelRatio !== 1
  2960. };
  2961. }
  2962. function scrollIntoView(element, spot) {
  2963. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2964. var parent = element.offsetParent;
  2965. if (!parent) {
  2966. console.error('offsetParent is not set -- cannot scroll');
  2967. return;
  2968. }
  2969. var offsetY = element.offsetTop + element.clientTop;
  2970. var offsetX = element.offsetLeft + element.clientLeft;
  2971. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  2972. if (parent.dataset._scaleY) {
  2973. offsetY /= parent.dataset._scaleY;
  2974. offsetX /= parent.dataset._scaleX;
  2975. }
  2976. offsetY += parent.offsetTop;
  2977. offsetX += parent.offsetLeft;
  2978. parent = parent.offsetParent;
  2979. if (!parent) {
  2980. return;
  2981. }
  2982. }
  2983. if (spot) {
  2984. if (spot.top !== undefined) {
  2985. offsetY += spot.top;
  2986. }
  2987. if (spot.left !== undefined) {
  2988. offsetX += spot.left;
  2989. parent.scrollLeft = offsetX;
  2990. }
  2991. }
  2992. parent.scrollTop = offsetY;
  2993. }
  2994. function watchScroll(viewAreaElement, callback) {
  2995. var debounceScroll = function debounceScroll(evt) {
  2996. if (rAF) {
  2997. return;
  2998. }
  2999. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  3000. rAF = null;
  3001. var currentX = viewAreaElement.scrollLeft;
  3002. var lastX = state.lastX;
  3003. if (currentX !== lastX) {
  3004. state.right = currentX > lastX;
  3005. }
  3006. state.lastX = currentX;
  3007. var currentY = viewAreaElement.scrollTop;
  3008. var lastY = state.lastY;
  3009. if (currentY !== lastY) {
  3010. state.down = currentY > lastY;
  3011. }
  3012. state.lastY = currentY;
  3013. callback(state);
  3014. });
  3015. };
  3016. var state = {
  3017. right: true,
  3018. down: true,
  3019. lastX: viewAreaElement.scrollLeft,
  3020. lastY: viewAreaElement.scrollTop,
  3021. _eventHandler: debounceScroll
  3022. };
  3023. var rAF = null;
  3024. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  3025. return state;
  3026. }
  3027. function parseQueryString(query) {
  3028. var parts = query.split('&');
  3029. var params = Object.create(null);
  3030. for (var i = 0, ii = parts.length; i < ii; ++i) {
  3031. var param = parts[i].split('=');
  3032. var key = param[0].toLowerCase();
  3033. var value = param.length > 1 ? param[1] : null;
  3034. params[decodeURIComponent(key)] = decodeURIComponent(value);
  3035. }
  3036. return params;
  3037. }
  3038. function binarySearchFirstItem(items, condition) {
  3039. var minIndex = 0;
  3040. var maxIndex = items.length - 1;
  3041. if (items.length === 0 || !condition(items[maxIndex])) {
  3042. return items.length;
  3043. }
  3044. if (condition(items[minIndex])) {
  3045. return minIndex;
  3046. }
  3047. while (minIndex < maxIndex) {
  3048. var currentIndex = minIndex + maxIndex >> 1;
  3049. var currentItem = items[currentIndex];
  3050. if (condition(currentItem)) {
  3051. maxIndex = currentIndex;
  3052. } else {
  3053. minIndex = currentIndex + 1;
  3054. }
  3055. }
  3056. return minIndex;
  3057. }
  3058. function approximateFraction(x) {
  3059. if (Math.floor(x) === x) {
  3060. return [x, 1];
  3061. }
  3062. var xinv = 1 / x;
  3063. var limit = 8;
  3064. if (xinv > limit) {
  3065. return [1, limit];
  3066. } else if (Math.floor(xinv) === xinv) {
  3067. return [1, xinv];
  3068. }
  3069. var x_ = x > 1 ? xinv : x;
  3070. var a = 0,
  3071. b = 1,
  3072. c = 1,
  3073. d = 1;
  3074. while (true) {
  3075. var p = a + c,
  3076. q = b + d;
  3077. if (q > limit) {
  3078. break;
  3079. }
  3080. if (x_ <= p / q) {
  3081. c = p;
  3082. d = q;
  3083. } else {
  3084. a = p;
  3085. b = q;
  3086. }
  3087. }
  3088. var result;
  3089. if (x_ - a / b < c / d - x_) {
  3090. result = x_ === x ? [a, b] : [b, a];
  3091. } else {
  3092. result = x_ === x ? [c, d] : [d, c];
  3093. }
  3094. return result;
  3095. }
  3096. function roundToDivide(x, div) {
  3097. var r = x % div;
  3098. return r === 0 ? x : Math.round(x - r + div);
  3099. }
  3100. function getPageSizeInches(_ref) {
  3101. var view = _ref.view,
  3102. userUnit = _ref.userUnit,
  3103. rotate = _ref.rotate;
  3104. var _view = _slicedToArray(view, 4),
  3105. x1 = _view[0],
  3106. y1 = _view[1],
  3107. x2 = _view[2],
  3108. y2 = _view[3];
  3109. var changeOrientation = rotate % 180 !== 0;
  3110. var width = (x2 - x1) / 72 * userUnit;
  3111. var height = (y2 - y1) / 72 * userUnit;
  3112. return {
  3113. width: changeOrientation ? height : width,
  3114. height: changeOrientation ? width : height
  3115. };
  3116. }
  3117. function backtrackBeforeAllVisibleElements(index, views, top) {
  3118. if (index < 2) {
  3119. return index;
  3120. }
  3121. var elt = views[index].div;
  3122. var pageTop = elt.offsetTop + elt.clientTop;
  3123. if (pageTop >= top) {
  3124. elt = views[index - 1].div;
  3125. pageTop = elt.offsetTop + elt.clientTop;
  3126. }
  3127. for (var i = index - 2; i >= 0; --i) {
  3128. elt = views[i].div;
  3129. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  3130. break;
  3131. }
  3132. index = i;
  3133. }
  3134. return index;
  3135. }
  3136. function getVisibleElements(scrollEl, views) {
  3137. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3138. var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  3139. var top = scrollEl.scrollTop,
  3140. bottom = top + scrollEl.clientHeight;
  3141. var left = scrollEl.scrollLeft,
  3142. right = left + scrollEl.clientWidth;
  3143. function isElementBottomAfterViewTop(view) {
  3144. var element = view.div;
  3145. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  3146. return elementBottom > top;
  3147. }
  3148. function isElementRightAfterViewLeft(view) {
  3149. var element = view.div;
  3150. var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
  3151. return elementRight > left;
  3152. }
  3153. var visible = [],
  3154. numViews = views.length;
  3155. var firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
  3156. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  3157. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  3158. }
  3159. var lastEdge = horizontal ? right : -1;
  3160. for (var i = firstVisibleElementInd; i < numViews; i++) {
  3161. var view = views[i],
  3162. element = view.div;
  3163. var currentWidth = element.offsetLeft + element.clientLeft;
  3164. var currentHeight = element.offsetTop + element.clientTop;
  3165. var viewWidth = element.clientWidth,
  3166. viewHeight = element.clientHeight;
  3167. var viewRight = currentWidth + viewWidth;
  3168. var viewBottom = currentHeight + viewHeight;
  3169. if (lastEdge === -1) {
  3170. if (viewBottom >= bottom) {
  3171. lastEdge = viewBottom;
  3172. }
  3173. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  3174. break;
  3175. }
  3176. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  3177. continue;
  3178. }
  3179. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  3180. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  3181. var percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
  3182. visible.push({
  3183. id: view.id,
  3184. x: currentWidth,
  3185. y: currentHeight,
  3186. view: view,
  3187. percent: percent
  3188. });
  3189. }
  3190. var first = visible[0],
  3191. last = visible[visible.length - 1];
  3192. if (sortByVisibility) {
  3193. visible.sort(function (a, b) {
  3194. var pc = a.percent - b.percent;
  3195. if (Math.abs(pc) > 0.001) {
  3196. return -pc;
  3197. }
  3198. return a.id - b.id;
  3199. });
  3200. }
  3201. return {
  3202. first: first,
  3203. last: last,
  3204. views: visible
  3205. };
  3206. }
  3207. function noContextMenuHandler(evt) {
  3208. evt.preventDefault();
  3209. }
  3210. function isDataSchema(url) {
  3211. var i = 0,
  3212. ii = url.length;
  3213. while (i < ii && url[i].trim() === '') {
  3214. i++;
  3215. }
  3216. return url.substring(i, i + 5).toLowerCase() === 'data:';
  3217. }
  3218. function getPDFFileNameFromURL(url) {
  3219. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
  3220. if (typeof url !== 'string') {
  3221. return defaultFilename;
  3222. }
  3223. if (isDataSchema(url)) {
  3224. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  3225. return defaultFilename;
  3226. }
  3227. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  3228. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  3229. var splitURI = reURI.exec(url);
  3230. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  3231. if (suggestedFilename) {
  3232. suggestedFilename = suggestedFilename[0];
  3233. if (suggestedFilename.includes('%')) {
  3234. try {
  3235. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  3236. } catch (ex) {}
  3237. }
  3238. }
  3239. return suggestedFilename || defaultFilename;
  3240. }
  3241. function normalizeWheelEventDelta(evt) {
  3242. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  3243. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  3244. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  3245. delta = -delta;
  3246. }
  3247. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  3248. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  3249. var MOUSE_PIXELS_PER_LINE = 30;
  3250. var MOUSE_LINES_PER_PAGE = 30;
  3251. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  3252. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  3253. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  3254. delta /= MOUSE_LINES_PER_PAGE;
  3255. }
  3256. return delta;
  3257. }
  3258. function isValidRotation(angle) {
  3259. return Number.isInteger(angle) && angle % 90 === 0;
  3260. }
  3261. function isValidScrollMode(mode) {
  3262. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  3263. }
  3264. function isValidSpreadMode(mode) {
  3265. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  3266. }
  3267. function isPortraitOrientation(size) {
  3268. return size.width <= size.height;
  3269. }
  3270. var WaitOnType = {
  3271. EVENT: 'event',
  3272. TIMEOUT: 'timeout'
  3273. };
  3274. exports.WaitOnType = WaitOnType;
  3275. function waitOnEventOrTimeout(_ref2) {
  3276. var target = _ref2.target,
  3277. name = _ref2.name,
  3278. _ref2$delay = _ref2.delay,
  3279. delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
  3280. return new Promise(function (resolve, reject) {
  3281. if (_typeof(target) !== 'object' || !(name && typeof name === 'string') || !(Number.isInteger(delay) && delay >= 0)) {
  3282. throw new Error('waitOnEventOrTimeout - invalid parameters.');
  3283. }
  3284. function handler(type) {
  3285. if (target instanceof EventBus) {
  3286. target.off(name, eventHandler);
  3287. } else {
  3288. target.removeEventListener(name, eventHandler);
  3289. }
  3290. if (timeout) {
  3291. clearTimeout(timeout);
  3292. }
  3293. resolve(type);
  3294. }
  3295. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  3296. if (target instanceof EventBus) {
  3297. target.on(name, eventHandler);
  3298. } else {
  3299. target.addEventListener(name, eventHandler);
  3300. }
  3301. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  3302. var timeout = setTimeout(timeoutHandler, delay);
  3303. });
  3304. }
  3305. var animationStarted = new Promise(function (resolve) {
  3306. window.requestAnimationFrame(resolve);
  3307. });
  3308. exports.animationStarted = animationStarted;
  3309. var EventBus =
  3310. /*#__PURE__*/
  3311. function () {
  3312. function EventBus() {
  3313. var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  3314. _ref3$dispatchToDOM = _ref3.dispatchToDOM,
  3315. dispatchToDOM = _ref3$dispatchToDOM === void 0 ? false : _ref3$dispatchToDOM;
  3316. _classCallCheck(this, EventBus);
  3317. this._listeners = Object.create(null);
  3318. this._dispatchToDOM = dispatchToDOM === true;
  3319. }
  3320. _createClass(EventBus, [{
  3321. key: "on",
  3322. value: function on(eventName, listener) {
  3323. var eventListeners = this._listeners[eventName];
  3324. if (!eventListeners) {
  3325. eventListeners = [];
  3326. this._listeners[eventName] = eventListeners;
  3327. }
  3328. eventListeners.push(listener);
  3329. }
  3330. }, {
  3331. key: "off",
  3332. value: function off(eventName, listener) {
  3333. var eventListeners = this._listeners[eventName];
  3334. var i;
  3335. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  3336. return;
  3337. }
  3338. eventListeners.splice(i, 1);
  3339. }
  3340. }, {
  3341. key: "dispatch",
  3342. value: function dispatch(eventName) {
  3343. var eventListeners = this._listeners[eventName];
  3344. if (!eventListeners || eventListeners.length === 0) {
  3345. if (this._dispatchToDOM) {
  3346. var _args5 = Array.prototype.slice.call(arguments, 1);
  3347. this._dispatchDOMEvent(eventName, _args5);
  3348. }
  3349. return;
  3350. }
  3351. var args = Array.prototype.slice.call(arguments, 1);
  3352. eventListeners.slice(0).forEach(function (listener) {
  3353. listener.apply(null, args);
  3354. });
  3355. if (this._dispatchToDOM) {
  3356. this._dispatchDOMEvent(eventName, args);
  3357. }
  3358. }
  3359. }, {
  3360. key: "_dispatchDOMEvent",
  3361. value: function _dispatchDOMEvent(eventName) {
  3362. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3363. var details = Object.create(null);
  3364. if (args && args.length > 0) {
  3365. var obj = args[0];
  3366. for (var key in obj) {
  3367. var value = obj[key];
  3368. if (key === 'source') {
  3369. if (value === window || value === document) {
  3370. return;
  3371. }
  3372. continue;
  3373. }
  3374. details[key] = value;
  3375. }
  3376. }
  3377. var event = document.createEvent('CustomEvent');
  3378. event.initCustomEvent(eventName, true, true, details);
  3379. document.dispatchEvent(event);
  3380. }
  3381. }]);
  3382. return EventBus;
  3383. }();
  3384. exports.EventBus = EventBus;
  3385. var globalEventBus = null;
  3386. function getGlobalEventBus() {
  3387. var dispatchToDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3388. if (!globalEventBus) {
  3389. globalEventBus = new EventBus({
  3390. dispatchToDOM: dispatchToDOM
  3391. });
  3392. }
  3393. return globalEventBus;
  3394. }
  3395. function clamp(v, min, max) {
  3396. return Math.min(Math.max(v, min), max);
  3397. }
  3398. var ProgressBar =
  3399. /*#__PURE__*/
  3400. function () {
  3401. function ProgressBar(id) {
  3402. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  3403. height = _ref4.height,
  3404. width = _ref4.width,
  3405. units = _ref4.units;
  3406. _classCallCheck(this, ProgressBar);
  3407. this.visible = true;
  3408. this.div = document.querySelector(id + ' .progress');
  3409. this.bar = this.div.parentNode;
  3410. this.height = height || 100;
  3411. this.width = width || 100;
  3412. this.units = units || '%';
  3413. this.div.style.height = this.height + this.units;
  3414. this.percent = 0;
  3415. }
  3416. _createClass(ProgressBar, [{
  3417. key: "_updateBar",
  3418. value: function _updateBar() {
  3419. if (this._indeterminate) {
  3420. this.div.classList.add('indeterminate');
  3421. this.div.style.width = this.width + this.units;
  3422. return;
  3423. }
  3424. this.div.classList.remove('indeterminate');
  3425. var progressSize = this.width * this._percent / 100;
  3426. this.div.style.width = progressSize + this.units;
  3427. }
  3428. }, {
  3429. key: "setWidth",
  3430. value: function setWidth(viewer) {
  3431. if (!viewer) {
  3432. return;
  3433. }
  3434. var container = viewer.parentNode;
  3435. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  3436. if (scrollbarWidth > 0) {
  3437. this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
  3438. }
  3439. }
  3440. }, {
  3441. key: "hide",
  3442. value: function hide() {
  3443. if (!this.visible) {
  3444. return;
  3445. }
  3446. this.visible = false;
  3447. this.bar.classList.add('hidden');
  3448. document.body.classList.remove('loadingInProgress');
  3449. }
  3450. }, {
  3451. key: "show",
  3452. value: function show() {
  3453. if (this.visible) {
  3454. return;
  3455. }
  3456. this.visible = true;
  3457. document.body.classList.add('loadingInProgress');
  3458. this.bar.classList.remove('hidden');
  3459. }
  3460. }, {
  3461. key: "percent",
  3462. get: function get() {
  3463. return this._percent;
  3464. },
  3465. set: function set(val) {
  3466. this._indeterminate = isNaN(val);
  3467. this._percent = clamp(val, 0, 100);
  3468. this._updateBar();
  3469. }
  3470. }]);
  3471. return ProgressBar;
  3472. }();
  3473. exports.ProgressBar = ProgressBar;
  3474. function moveToEndOfArray(arr, condition) {
  3475. var moved = [],
  3476. len = arr.length;
  3477. var write = 0;
  3478. for (var read = 0; read < len; ++read) {
  3479. if (condition(arr[read])) {
  3480. moved.push(arr[read]);
  3481. } else {
  3482. arr[write] = arr[read];
  3483. ++write;
  3484. }
  3485. }
  3486. for (var _read = 0; write < len; ++_read, ++write) {
  3487. arr[write] = moved[_read];
  3488. }
  3489. }
  3490. /***/ }),
  3491. /* 6 */
  3492. /***/ (function(module, exports, __webpack_require__) {
  3493. "use strict";
  3494. Object.defineProperty(exports, "__esModule", {
  3495. value: true
  3496. });
  3497. exports.OptionKind = exports.AppOptions = void 0;
  3498. var _pdfjsLib = __webpack_require__(7);
  3499. var _viewer_compatibility = __webpack_require__(8);
  3500. function _typeof(obj) { 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); }
  3501. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3502. 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); } }
  3503. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3504. var OptionKind = {
  3505. VIEWER: 0x02,
  3506. API: 0x04,
  3507. WORKER: 0x08,
  3508. PREFERENCE: 0x80
  3509. };
  3510. exports.OptionKind = OptionKind;
  3511. var defaultOptions = {
  3512. cursorToolOnLoad: {
  3513. value: 0,
  3514. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3515. },
  3516. defaultUrl: {
  3517. value: 'compressed.tracemonkey-pldi-09.pdf',
  3518. kind: OptionKind.VIEWER
  3519. },
  3520. defaultZoomValue: {
  3521. value: '',
  3522. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3523. },
  3524. disableHistory: {
  3525. value: false,
  3526. kind: OptionKind.VIEWER
  3527. },
  3528. disablePageLabels: {
  3529. value: false,
  3530. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3531. },
  3532. enablePrintAutoRotate: {
  3533. value: false,
  3534. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3535. },
  3536. enableWebGL: {
  3537. value: false,
  3538. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3539. },
  3540. eventBusDispatchToDOM: {
  3541. value: false,
  3542. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3543. },
  3544. externalLinkRel: {
  3545. value: 'noopener noreferrer nofollow',
  3546. kind: OptionKind.VIEWER
  3547. },
  3548. externalLinkTarget: {
  3549. value: 0,
  3550. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3551. },
  3552. historyUpdateUrl: {
  3553. value: false,
  3554. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3555. },
  3556. imageResourcesPath: {
  3557. value: './images/',
  3558. kind: OptionKind.VIEWER
  3559. },
  3560. maxCanvasPixels: {
  3561. value: 16777216,
  3562. compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
  3563. kind: OptionKind.VIEWER
  3564. },
  3565. pdfBugEnabled: {
  3566. value: false,
  3567. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3568. },
  3569. renderer: {
  3570. value: 'canvas',
  3571. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3572. },
  3573. renderInteractiveForms: {
  3574. value: false,
  3575. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3576. },
  3577. sidebarViewOnLoad: {
  3578. value: -1,
  3579. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3580. },
  3581. scrollModeOnLoad: {
  3582. value: -1,
  3583. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3584. },
  3585. spreadModeOnLoad: {
  3586. value: -1,
  3587. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3588. },
  3589. textLayerMode: {
  3590. value: 1,
  3591. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3592. },
  3593. useOnlyCssZoom: {
  3594. value: false,
  3595. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3596. },
  3597. viewOnLoad: {
  3598. value: 0,
  3599. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3600. },
  3601. cMapPacked: {
  3602. value: true,
  3603. kind: OptionKind.API
  3604. },
  3605. cMapUrl: {
  3606. value: '../web/cmaps/',
  3607. kind: OptionKind.API
  3608. },
  3609. disableAutoFetch: {
  3610. value: false,
  3611. kind: OptionKind.API + OptionKind.PREFERENCE
  3612. },
  3613. disableCreateObjectURL: {
  3614. value: false,
  3615. compatibility: _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL,
  3616. kind: OptionKind.API
  3617. },
  3618. disableFontFace: {
  3619. value: false,
  3620. kind: OptionKind.API + OptionKind.PREFERENCE
  3621. },
  3622. disableRange: {
  3623. value: false,
  3624. kind: OptionKind.API + OptionKind.PREFERENCE
  3625. },
  3626. disableStream: {
  3627. value: false,
  3628. kind: OptionKind.API + OptionKind.PREFERENCE
  3629. },
  3630. isEvalSupported: {
  3631. value: true,
  3632. kind: OptionKind.API
  3633. },
  3634. maxImageSize: {
  3635. value: -1,
  3636. kind: OptionKind.API
  3637. },
  3638. pdfBug: {
  3639. value: false,
  3640. kind: OptionKind.API
  3641. },
  3642. postMessageTransfers: {
  3643. value: true,
  3644. kind: OptionKind.API
  3645. },
  3646. verbosity: {
  3647. value: 1,
  3648. kind: OptionKind.API
  3649. },
  3650. workerPort: {
  3651. value: null,
  3652. kind: OptionKind.WORKER
  3653. },
  3654. workerSrc: {
  3655. value: '../build/pdf.worker.js',
  3656. kind: OptionKind.WORKER
  3657. }
  3658. };
  3659. {
  3660. defaultOptions.disablePreferences = {
  3661. value: false,
  3662. kind: OptionKind.VIEWER
  3663. };
  3664. defaultOptions.locale = {
  3665. value: typeof navigator !== 'undefined' ? navigator.language : 'en-US',
  3666. kind: OptionKind.VIEWER
  3667. };
  3668. defaultOptions.printResolution = {
  3669. value: 150,
  3670. kind: OptionKind.VIEWER
  3671. };
  3672. }
  3673. var userOptions = Object.create(null);
  3674. var AppOptions =
  3675. /*#__PURE__*/
  3676. function () {
  3677. function AppOptions() {
  3678. _classCallCheck(this, AppOptions);
  3679. throw new Error('Cannot initialize AppOptions.');
  3680. }
  3681. _createClass(AppOptions, null, [{
  3682. key: "get",
  3683. value: function get(name) {
  3684. var userOption = userOptions[name];
  3685. if (userOption !== undefined) {
  3686. return userOption;
  3687. }
  3688. var defaultOption = defaultOptions[name];
  3689. if (defaultOption !== undefined) {
  3690. return defaultOption.compatibility || defaultOption.value;
  3691. }
  3692. return undefined;
  3693. }
  3694. }, {
  3695. key: "getAll",
  3696. value: function getAll() {
  3697. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  3698. var options = Object.create(null);
  3699. for (var name in defaultOptions) {
  3700. var defaultOption = defaultOptions[name];
  3701. if (kind) {
  3702. if ((kind & defaultOption.kind) === 0) {
  3703. continue;
  3704. }
  3705. if (kind === OptionKind.PREFERENCE) {
  3706. var value = defaultOption.value,
  3707. valueType = _typeof(value);
  3708. if (valueType === 'boolean' || valueType === 'string' || valueType === 'number' && Number.isInteger(value)) {
  3709. options[name] = value;
  3710. continue;
  3711. }
  3712. throw new Error("Invalid type for preference: ".concat(name));
  3713. }
  3714. }
  3715. var userOption = userOptions[name];
  3716. options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
  3717. }
  3718. return options;
  3719. }
  3720. }, {
  3721. key: "set",
  3722. value: function set(name, value) {
  3723. userOptions[name] = value;
  3724. }
  3725. }, {
  3726. key: "remove",
  3727. value: function remove(name) {
  3728. delete userOptions[name];
  3729. }
  3730. }]);
  3731. return AppOptions;
  3732. }();
  3733. exports.AppOptions = AppOptions;
  3734. /***/ }),
  3735. /* 7 */
  3736. /***/ (function(module, exports, __webpack_require__) {
  3737. "use strict";
  3738. var pdfjsLib;
  3739. if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
  3740. pdfjsLib = window['pdfjs-dist/build/pdf'];
  3741. } else {
  3742. pdfjsLib = require('../build/pdf.js');
  3743. }
  3744. module.exports = pdfjsLib;
  3745. /***/ }),
  3746. /* 8 */
  3747. /***/ (function(module, exports, __webpack_require__) {
  3748. "use strict";
  3749. var compatibilityParams = Object.create(null);
  3750. {
  3751. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  3752. var isAndroid = /Android/.test(userAgent);
  3753. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  3754. (function checkCanvasSizeLimitation() {
  3755. if (isIOS || isAndroid) {
  3756. compatibilityParams.maxCanvasPixels = 5242880;
  3757. }
  3758. })();
  3759. }
  3760. exports.viewerCompatibilityParams = Object.freeze(compatibilityParams);
  3761. /***/ }),
  3762. /* 9 */
  3763. /***/ (function(module, exports, __webpack_require__) {
  3764. "use strict";
  3765. Object.defineProperty(exports, "__esModule", {
  3766. value: true
  3767. });
  3768. exports.PDFCursorTools = exports.CursorTool = void 0;
  3769. var _grab_to_pan = __webpack_require__(10);
  3770. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3771. 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); } }
  3772. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3773. var CursorTool = {
  3774. SELECT: 0,
  3775. HAND: 1,
  3776. ZOOM: 2
  3777. };
  3778. exports.CursorTool = CursorTool;
  3779. var PDFCursorTools =
  3780. /*#__PURE__*/
  3781. function () {
  3782. function PDFCursorTools(_ref) {
  3783. var _this = this;
  3784. var container = _ref.container,
  3785. eventBus = _ref.eventBus,
  3786. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  3787. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT : _ref$cursorToolOnLoad;
  3788. _classCallCheck(this, PDFCursorTools);
  3789. this.container = container;
  3790. this.eventBus = eventBus;
  3791. this.active = CursorTool.SELECT;
  3792. this.activeBeforePresentationMode = null;
  3793. this.handTool = new _grab_to_pan.GrabToPan({
  3794. element: this.container
  3795. });
  3796. this._addEventListeners();
  3797. Promise.resolve().then(function () {
  3798. _this.switchTool(cursorToolOnLoad);
  3799. });
  3800. }
  3801. _createClass(PDFCursorTools, [{
  3802. key: "switchTool",
  3803. value: function switchTool(tool) {
  3804. var _this2 = this;
  3805. if (this.activeBeforePresentationMode !== null) {
  3806. return;
  3807. }
  3808. if (tool === this.active) {
  3809. return;
  3810. }
  3811. var disableActiveTool = function disableActiveTool() {
  3812. switch (_this2.active) {
  3813. case CursorTool.SELECT:
  3814. break;
  3815. case CursorTool.HAND:
  3816. _this2.handTool.deactivate();
  3817. break;
  3818. case CursorTool.ZOOM:
  3819. }
  3820. };
  3821. switch (tool) {
  3822. case CursorTool.SELECT:
  3823. disableActiveTool();
  3824. break;
  3825. case CursorTool.HAND:
  3826. disableActiveTool();
  3827. this.handTool.activate();
  3828. break;
  3829. case CursorTool.ZOOM:
  3830. default:
  3831. console.error("switchTool: \"".concat(tool, "\" is an unsupported value."));
  3832. return;
  3833. }
  3834. this.active = tool;
  3835. this._dispatchEvent();
  3836. }
  3837. }, {
  3838. key: "_dispatchEvent",
  3839. value: function _dispatchEvent() {
  3840. this.eventBus.dispatch('cursortoolchanged', {
  3841. source: this,
  3842. tool: this.active
  3843. });
  3844. }
  3845. }, {
  3846. key: "_addEventListeners",
  3847. value: function _addEventListeners() {
  3848. var _this3 = this;
  3849. this.eventBus.on('switchcursortool', function (evt) {
  3850. _this3.switchTool(evt.tool);
  3851. });
  3852. this.eventBus.on('presentationmodechanged', function (evt) {
  3853. if (evt.switchInProgress) {
  3854. return;
  3855. }
  3856. var previouslyActive;
  3857. if (evt.active) {
  3858. previouslyActive = _this3.active;
  3859. _this3.switchTool(CursorTool.SELECT);
  3860. _this3.activeBeforePresentationMode = previouslyActive;
  3861. } else {
  3862. previouslyActive = _this3.activeBeforePresentationMode;
  3863. _this3.activeBeforePresentationMode = null;
  3864. _this3.switchTool(previouslyActive);
  3865. }
  3866. });
  3867. }
  3868. }, {
  3869. key: "activeTool",
  3870. get: function get() {
  3871. return this.active;
  3872. }
  3873. }]);
  3874. return PDFCursorTools;
  3875. }();
  3876. exports.PDFCursorTools = PDFCursorTools;
  3877. /***/ }),
  3878. /* 10 */
  3879. /***/ (function(module, exports, __webpack_require__) {
  3880. "use strict";
  3881. Object.defineProperty(exports, "__esModule", {
  3882. value: true
  3883. });
  3884. exports.GrabToPan = GrabToPan;
  3885. function GrabToPan(options) {
  3886. this.element = options.element;
  3887. this.document = options.element.ownerDocument;
  3888. if (typeof options.ignoreTarget === 'function') {
  3889. this.ignoreTarget = options.ignoreTarget;
  3890. }
  3891. this.onActiveChanged = options.onActiveChanged;
  3892. this.activate = this.activate.bind(this);
  3893. this.deactivate = this.deactivate.bind(this);
  3894. this.toggle = this.toggle.bind(this);
  3895. this._onmousedown = this._onmousedown.bind(this);
  3896. this._onmousemove = this._onmousemove.bind(this);
  3897. this._endPan = this._endPan.bind(this);
  3898. var overlay = this.overlay = document.createElement('div');
  3899. overlay.className = 'grab-to-pan-grabbing';
  3900. }
  3901. GrabToPan.prototype = {
  3902. CSS_CLASS_GRAB: 'grab-to-pan-grab',
  3903. activate: function GrabToPan_activate() {
  3904. if (!this.active) {
  3905. this.active = true;
  3906. this.element.addEventListener('mousedown', this._onmousedown, true);
  3907. this.element.classList.add(this.CSS_CLASS_GRAB);
  3908. if (this.onActiveChanged) {
  3909. this.onActiveChanged(true);
  3910. }
  3911. }
  3912. },
  3913. deactivate: function GrabToPan_deactivate() {
  3914. if (this.active) {
  3915. this.active = false;
  3916. this.element.removeEventListener('mousedown', this._onmousedown, true);
  3917. this._endPan();
  3918. this.element.classList.remove(this.CSS_CLASS_GRAB);
  3919. if (this.onActiveChanged) {
  3920. this.onActiveChanged(false);
  3921. }
  3922. }
  3923. },
  3924. toggle: function GrabToPan_toggle() {
  3925. if (this.active) {
  3926. this.deactivate();
  3927. } else {
  3928. this.activate();
  3929. }
  3930. },
  3931. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  3932. return node[matchesSelector]('a[href], a[href] *, input, textarea, button, button *, select, option');
  3933. },
  3934. _onmousedown: function GrabToPan__onmousedown(event) {
  3935. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  3936. return;
  3937. }
  3938. if (event.originalTarget) {
  3939. try {
  3940. event.originalTarget.tagName;
  3941. } catch (e) {
  3942. return;
  3943. }
  3944. }
  3945. this.scrollLeftStart = this.element.scrollLeft;
  3946. this.scrollTopStart = this.element.scrollTop;
  3947. this.clientXStart = event.clientX;
  3948. this.clientYStart = event.clientY;
  3949. this.document.addEventListener('mousemove', this._onmousemove, true);
  3950. this.document.addEventListener('mouseup', this._endPan, true);
  3951. this.element.addEventListener('scroll', this._endPan, true);
  3952. event.preventDefault();
  3953. event.stopPropagation();
  3954. var focusedElement = document.activeElement;
  3955. if (focusedElement && !focusedElement.contains(event.target)) {
  3956. focusedElement.blur();
  3957. }
  3958. },
  3959. _onmousemove: function GrabToPan__onmousemove(event) {
  3960. this.element.removeEventListener('scroll', this._endPan, true);
  3961. if (isLeftMouseReleased(event)) {
  3962. this._endPan();
  3963. return;
  3964. }
  3965. var xDiff = event.clientX - this.clientXStart;
  3966. var yDiff = event.clientY - this.clientYStart;
  3967. var scrollTop = this.scrollTopStart - yDiff;
  3968. var scrollLeft = this.scrollLeftStart - xDiff;
  3969. if (this.element.scrollTo) {
  3970. this.element.scrollTo({
  3971. top: scrollTop,
  3972. left: scrollLeft,
  3973. behavior: 'instant'
  3974. });
  3975. } else {
  3976. this.element.scrollTop = scrollTop;
  3977. this.element.scrollLeft = scrollLeft;
  3978. }
  3979. if (!this.overlay.parentNode) {
  3980. document.body.appendChild(this.overlay);
  3981. }
  3982. },
  3983. _endPan: function GrabToPan__endPan() {
  3984. this.element.removeEventListener('scroll', this._endPan, true);
  3985. this.document.removeEventListener('mousemove', this._onmousemove, true);
  3986. this.document.removeEventListener('mouseup', this._endPan, true);
  3987. this.overlay.remove();
  3988. }
  3989. };
  3990. var matchesSelector;
  3991. ['webkitM', 'mozM', 'msM', 'oM', 'm'].some(function (prefix) {
  3992. var name = prefix + 'atches';
  3993. if (name in document.documentElement) {
  3994. matchesSelector = name;
  3995. }
  3996. name += 'Selector';
  3997. if (name in document.documentElement) {
  3998. matchesSelector = name;
  3999. }
  4000. return matchesSelector;
  4001. });
  4002. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  4003. var chrome = window.chrome;
  4004. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  4005. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  4006. function isLeftMouseReleased(event) {
  4007. if ('buttons' in event && isNotIEorIsIE10plus) {
  4008. return !(event.buttons & 1);
  4009. }
  4010. if (isChrome15OrOpera15plus || isSafari6plus) {
  4011. return event.which === 0;
  4012. }
  4013. return false;
  4014. }
  4015. /***/ }),
  4016. /* 11 */
  4017. /***/ (function(module, exports, __webpack_require__) {
  4018. "use strict";
  4019. Object.defineProperty(exports, "__esModule", {
  4020. value: true
  4021. });
  4022. exports.PDFRenderingQueue = exports.RenderingStates = void 0;
  4023. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4024. 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); } }
  4025. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4026. var CLEANUP_TIMEOUT = 30000;
  4027. var RenderingStates = {
  4028. INITIAL: 0,
  4029. RUNNING: 1,
  4030. PAUSED: 2,
  4031. FINISHED: 3
  4032. };
  4033. exports.RenderingStates = RenderingStates;
  4034. var PDFRenderingQueue =
  4035. /*#__PURE__*/
  4036. function () {
  4037. function PDFRenderingQueue() {
  4038. _classCallCheck(this, PDFRenderingQueue);
  4039. this.pdfViewer = null;
  4040. this.pdfThumbnailViewer = null;
  4041. this.onIdle = null;
  4042. this.highestPriorityPage = null;
  4043. this.idleTimeout = null;
  4044. this.printing = false;
  4045. this.isThumbnailViewEnabled = false;
  4046. }
  4047. _createClass(PDFRenderingQueue, [{
  4048. key: "setViewer",
  4049. value: function setViewer(pdfViewer) {
  4050. this.pdfViewer = pdfViewer;
  4051. }
  4052. }, {
  4053. key: "setThumbnailViewer",
  4054. value: function setThumbnailViewer(pdfThumbnailViewer) {
  4055. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4056. }
  4057. }, {
  4058. key: "isHighestPriority",
  4059. value: function isHighestPriority(view) {
  4060. return this.highestPriorityPage === view.renderingId;
  4061. }
  4062. }, {
  4063. key: "renderHighestPriority",
  4064. value: function renderHighestPriority(currentlyVisiblePages) {
  4065. if (this.idleTimeout) {
  4066. clearTimeout(this.idleTimeout);
  4067. this.idleTimeout = null;
  4068. }
  4069. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  4070. return;
  4071. }
  4072. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  4073. if (this.pdfThumbnailViewer.forceRendering()) {
  4074. return;
  4075. }
  4076. }
  4077. if (this.printing) {
  4078. return;
  4079. }
  4080. if (this.onIdle) {
  4081. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  4082. }
  4083. }
  4084. }, {
  4085. key: "getHighestPriority",
  4086. value: function getHighestPriority(visible, views, scrolledDown) {
  4087. var visibleViews = visible.views;
  4088. var numVisible = visibleViews.length;
  4089. if (numVisible === 0) {
  4090. return null;
  4091. }
  4092. for (var i = 0; i < numVisible; ++i) {
  4093. var view = visibleViews[i].view;
  4094. if (!this.isViewFinished(view)) {
  4095. return view;
  4096. }
  4097. }
  4098. if (scrolledDown) {
  4099. var nextPageIndex = visible.last.id;
  4100. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  4101. return views[nextPageIndex];
  4102. }
  4103. } else {
  4104. var previousPageIndex = visible.first.id - 2;
  4105. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  4106. return views[previousPageIndex];
  4107. }
  4108. }
  4109. return null;
  4110. }
  4111. }, {
  4112. key: "isViewFinished",
  4113. value: function isViewFinished(view) {
  4114. return view.renderingState === RenderingStates.FINISHED;
  4115. }
  4116. }, {
  4117. key: "renderView",
  4118. value: function renderView(view) {
  4119. var _this = this;
  4120. switch (view.renderingState) {
  4121. case RenderingStates.FINISHED:
  4122. return false;
  4123. case RenderingStates.PAUSED:
  4124. this.highestPriorityPage = view.renderingId;
  4125. view.resume();
  4126. break;
  4127. case RenderingStates.RUNNING:
  4128. this.highestPriorityPage = view.renderingId;
  4129. break;
  4130. case RenderingStates.INITIAL:
  4131. this.highestPriorityPage = view.renderingId;
  4132. view.draw()["finally"](function () {
  4133. _this.renderHighestPriority();
  4134. });
  4135. break;
  4136. }
  4137. return true;
  4138. }
  4139. }]);
  4140. return PDFRenderingQueue;
  4141. }();
  4142. exports.PDFRenderingQueue = PDFRenderingQueue;
  4143. /***/ }),
  4144. /* 12 */
  4145. /***/ (function(module, exports, __webpack_require__) {
  4146. "use strict";
  4147. Object.defineProperty(exports, "__esModule", {
  4148. value: true
  4149. });
  4150. exports.PDFSidebar = exports.SidebarView = void 0;
  4151. var _ui_utils = __webpack_require__(5);
  4152. var _pdf_rendering_queue = __webpack_require__(11);
  4153. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4154. 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); } }
  4155. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4156. var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
  4157. var SidebarView = {
  4158. UNKNOWN: -1,
  4159. NONE: 0,
  4160. THUMBS: 1,
  4161. OUTLINE: 2,
  4162. ATTACHMENTS: 3,
  4163. LAYERS: 4
  4164. };
  4165. exports.SidebarView = SidebarView;
  4166. var PDFSidebar =
  4167. /*#__PURE__*/
  4168. function () {
  4169. function PDFSidebar(_ref) {
  4170. var elements = _ref.elements,
  4171. pdfViewer = _ref.pdfViewer,
  4172. pdfThumbnailViewer = _ref.pdfThumbnailViewer,
  4173. eventBus = _ref.eventBus,
  4174. _ref$l10n = _ref.l10n,
  4175. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n,
  4176. _ref$disableNotificat = _ref.disableNotification,
  4177. disableNotification = _ref$disableNotificat === void 0 ? false : _ref$disableNotificat;
  4178. _classCallCheck(this, PDFSidebar);
  4179. this.isOpen = false;
  4180. this.active = SidebarView.THUMBS;
  4181. this.isInitialViewSet = false;
  4182. this.onToggled = null;
  4183. this.pdfViewer = pdfViewer;
  4184. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4185. this.outerContainer = elements.outerContainer;
  4186. this.viewerContainer = elements.viewerContainer;
  4187. this.toggleButton = elements.toggleButton;
  4188. this.thumbnailButton = elements.thumbnailButton;
  4189. this.outlineButton = elements.outlineButton;
  4190. this.attachmentsButton = elements.attachmentsButton;
  4191. this.thumbnailView = elements.thumbnailView;
  4192. this.outlineView = elements.outlineView;
  4193. this.attachmentsView = elements.attachmentsView;
  4194. this.eventBus = eventBus;
  4195. this.l10n = l10n;
  4196. this._disableNotification = disableNotification;
  4197. this._addEventListeners();
  4198. }
  4199. _createClass(PDFSidebar, [{
  4200. key: "reset",
  4201. value: function reset() {
  4202. this.isInitialViewSet = false;
  4203. this._hideUINotification(null);
  4204. this.switchView(SidebarView.THUMBS);
  4205. this.outlineButton.disabled = false;
  4206. this.attachmentsButton.disabled = false;
  4207. }
  4208. }, {
  4209. key: "setInitialView",
  4210. value: function setInitialView() {
  4211. var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE;
  4212. if (this.isInitialViewSet) {
  4213. return;
  4214. }
  4215. this.isInitialViewSet = true;
  4216. if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
  4217. this._dispatchEvent();
  4218. return;
  4219. }
  4220. if (!this._switchView(view, true)) {
  4221. this._dispatchEvent();
  4222. }
  4223. }
  4224. }, {
  4225. key: "switchView",
  4226. value: function switchView(view) {
  4227. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4228. this._switchView(view, forceOpen);
  4229. }
  4230. }, {
  4231. key: "_switchView",
  4232. value: function _switchView(view) {
  4233. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4234. var isViewChanged = view !== this.active;
  4235. var shouldForceRendering = false;
  4236. switch (view) {
  4237. case SidebarView.NONE:
  4238. if (this.isOpen) {
  4239. this.close();
  4240. return true;
  4241. }
  4242. return false;
  4243. case SidebarView.THUMBS:
  4244. if (this.isOpen && isViewChanged) {
  4245. shouldForceRendering = true;
  4246. }
  4247. break;
  4248. case SidebarView.OUTLINE:
  4249. if (this.outlineButton.disabled) {
  4250. return false;
  4251. }
  4252. break;
  4253. case SidebarView.ATTACHMENTS:
  4254. if (this.attachmentsButton.disabled) {
  4255. return false;
  4256. }
  4257. break;
  4258. default:
  4259. console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
  4260. return false;
  4261. }
  4262. this.active = view;
  4263. this.thumbnailButton.classList.toggle('toggled', view === SidebarView.THUMBS);
  4264. this.outlineButton.classList.toggle('toggled', view === SidebarView.OUTLINE);
  4265. this.attachmentsButton.classList.toggle('toggled', view === SidebarView.ATTACHMENTS);
  4266. this.thumbnailView.classList.toggle('hidden', view !== SidebarView.THUMBS);
  4267. this.outlineView.classList.toggle('hidden', view !== SidebarView.OUTLINE);
  4268. this.attachmentsView.classList.toggle('hidden', view !== SidebarView.ATTACHMENTS);
  4269. if (forceOpen && !this.isOpen) {
  4270. this.open();
  4271. return true;
  4272. }
  4273. if (shouldForceRendering) {
  4274. this._updateThumbnailViewer();
  4275. this._forceRendering();
  4276. }
  4277. if (isViewChanged) {
  4278. this._dispatchEvent();
  4279. }
  4280. this._hideUINotification(this.active);
  4281. return isViewChanged;
  4282. }
  4283. }, {
  4284. key: "open",
  4285. value: function open() {
  4286. if (this.isOpen) {
  4287. return;
  4288. }
  4289. this.isOpen = true;
  4290. this.toggleButton.classList.add('toggled');
  4291. this.outerContainer.classList.add('sidebarMoving', 'sidebarOpen');
  4292. if (this.active === SidebarView.THUMBS) {
  4293. this._updateThumbnailViewer();
  4294. }
  4295. this._forceRendering();
  4296. this._dispatchEvent();
  4297. this._hideUINotification(this.active);
  4298. }
  4299. }, {
  4300. key: "close",
  4301. value: function close() {
  4302. if (!this.isOpen) {
  4303. return;
  4304. }
  4305. this.isOpen = false;
  4306. this.toggleButton.classList.remove('toggled');
  4307. this.outerContainer.classList.add('sidebarMoving');
  4308. this.outerContainer.classList.remove('sidebarOpen');
  4309. this._forceRendering();
  4310. this._dispatchEvent();
  4311. }
  4312. }, {
  4313. key: "toggle",
  4314. value: function toggle() {
  4315. if (this.isOpen) {
  4316. this.close();
  4317. } else {
  4318. this.open();
  4319. }
  4320. }
  4321. }, {
  4322. key: "_dispatchEvent",
  4323. value: function _dispatchEvent() {
  4324. this.eventBus.dispatch('sidebarviewchanged', {
  4325. source: this,
  4326. view: this.visibleView
  4327. });
  4328. }
  4329. }, {
  4330. key: "_forceRendering",
  4331. value: function _forceRendering() {
  4332. if (this.onToggled) {
  4333. this.onToggled();
  4334. } else {
  4335. this.pdfViewer.forceRendering();
  4336. this.pdfThumbnailViewer.forceRendering();
  4337. }
  4338. }
  4339. }, {
  4340. key: "_updateThumbnailViewer",
  4341. value: function _updateThumbnailViewer() {
  4342. var pdfViewer = this.pdfViewer,
  4343. pdfThumbnailViewer = this.pdfThumbnailViewer;
  4344. var pagesCount = pdfViewer.pagesCount;
  4345. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  4346. var pageView = pdfViewer.getPageView(pageIndex);
  4347. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  4348. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  4349. thumbnailView.setImage(pageView);
  4350. }
  4351. }
  4352. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  4353. }
  4354. }, {
  4355. key: "_showUINotification",
  4356. value: function _showUINotification(view) {
  4357. var _this = this;
  4358. if (this._disableNotification) {
  4359. return;
  4360. }
  4361. this.l10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)').then(function (msg) {
  4362. _this.toggleButton.title = msg;
  4363. });
  4364. if (!this.isOpen) {
  4365. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  4366. } else if (view === this.active) {
  4367. return;
  4368. }
  4369. switch (view) {
  4370. case SidebarView.OUTLINE:
  4371. this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
  4372. break;
  4373. case SidebarView.ATTACHMENTS:
  4374. this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
  4375. break;
  4376. }
  4377. }
  4378. }, {
  4379. key: "_hideUINotification",
  4380. value: function _hideUINotification(view) {
  4381. var _this2 = this;
  4382. if (this._disableNotification) {
  4383. return;
  4384. }
  4385. var removeNotification = function removeNotification(view) {
  4386. switch (view) {
  4387. case SidebarView.OUTLINE:
  4388. _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
  4389. break;
  4390. case SidebarView.ATTACHMENTS:
  4391. _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
  4392. break;
  4393. }
  4394. };
  4395. if (!this.isOpen && view !== null) {
  4396. return;
  4397. }
  4398. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  4399. if (view !== null) {
  4400. removeNotification(view);
  4401. return;
  4402. }
  4403. for (view in SidebarView) {
  4404. removeNotification(SidebarView[view]);
  4405. }
  4406. this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(function (msg) {
  4407. _this2.toggleButton.title = msg;
  4408. });
  4409. }
  4410. }, {
  4411. key: "_addEventListeners",
  4412. value: function _addEventListeners() {
  4413. var _this3 = this;
  4414. this.viewerContainer.addEventListener('transitionend', function (evt) {
  4415. if (evt.target === _this3.viewerContainer) {
  4416. _this3.outerContainer.classList.remove('sidebarMoving');
  4417. }
  4418. });
  4419. this.thumbnailButton.addEventListener('click', function () {
  4420. _this3.switchView(SidebarView.THUMBS);
  4421. });
  4422. this.outlineButton.addEventListener('click', function () {
  4423. _this3.switchView(SidebarView.OUTLINE);
  4424. });
  4425. this.outlineButton.addEventListener('dblclick', function () {
  4426. _this3.eventBus.dispatch('toggleoutlinetree', {
  4427. source: _this3
  4428. });
  4429. });
  4430. this.attachmentsButton.addEventListener('click', function () {
  4431. _this3.switchView(SidebarView.ATTACHMENTS);
  4432. });
  4433. this.eventBus.on('outlineloaded', function (evt) {
  4434. var outlineCount = evt.outlineCount;
  4435. _this3.outlineButton.disabled = !outlineCount;
  4436. if (outlineCount) {
  4437. _this3._showUINotification(SidebarView.OUTLINE);
  4438. } else if (_this3.active === SidebarView.OUTLINE) {
  4439. _this3.switchView(SidebarView.THUMBS);
  4440. }
  4441. });
  4442. this.eventBus.on('attachmentsloaded', function (evt) {
  4443. if (evt.attachmentsCount) {
  4444. _this3.attachmentsButton.disabled = false;
  4445. _this3._showUINotification(SidebarView.ATTACHMENTS);
  4446. return;
  4447. }
  4448. Promise.resolve().then(function () {
  4449. if (_this3.attachmentsView.hasChildNodes()) {
  4450. return;
  4451. }
  4452. _this3.attachmentsButton.disabled = true;
  4453. if (_this3.active === SidebarView.ATTACHMENTS) {
  4454. _this3.switchView(SidebarView.THUMBS);
  4455. }
  4456. });
  4457. });
  4458. this.eventBus.on('presentationmodechanged', function (evt) {
  4459. if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
  4460. _this3._updateThumbnailViewer();
  4461. }
  4462. });
  4463. }
  4464. }, {
  4465. key: "visibleView",
  4466. get: function get() {
  4467. return this.isOpen ? this.active : SidebarView.NONE;
  4468. }
  4469. }, {
  4470. key: "isThumbnailViewVisible",
  4471. get: function get() {
  4472. return this.isOpen && this.active === SidebarView.THUMBS;
  4473. }
  4474. }, {
  4475. key: "isOutlineViewVisible",
  4476. get: function get() {
  4477. return this.isOpen && this.active === SidebarView.OUTLINE;
  4478. }
  4479. }, {
  4480. key: "isAttachmentsViewVisible",
  4481. get: function get() {
  4482. return this.isOpen && this.active === SidebarView.ATTACHMENTS;
  4483. }
  4484. }]);
  4485. return PDFSidebar;
  4486. }();
  4487. exports.PDFSidebar = PDFSidebar;
  4488. /***/ }),
  4489. /* 13 */
  4490. /***/ (function(module, exports, __webpack_require__) {
  4491. "use strict";
  4492. Object.defineProperty(exports, "__esModule", {
  4493. value: true
  4494. });
  4495. exports.OverlayManager = void 0;
  4496. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  4497. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4498. 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); } }
  4499. 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); }); }; }
  4500. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4501. 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); } }
  4502. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4503. var OverlayManager =
  4504. /*#__PURE__*/
  4505. function () {
  4506. function OverlayManager() {
  4507. _classCallCheck(this, OverlayManager);
  4508. this._overlays = {};
  4509. this._active = null;
  4510. this._keyDownBound = this._keyDown.bind(this);
  4511. }
  4512. _createClass(OverlayManager, [{
  4513. key: "register",
  4514. value: function () {
  4515. var _register = _asyncToGenerator(
  4516. /*#__PURE__*/
  4517. _regenerator["default"].mark(function _callee(name, element) {
  4518. var callerCloseMethod,
  4519. canForceClose,
  4520. container,
  4521. _args = arguments;
  4522. return _regenerator["default"].wrap(function _callee$(_context) {
  4523. while (1) {
  4524. switch (_context.prev = _context.next) {
  4525. case 0:
  4526. callerCloseMethod = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
  4527. canForceClose = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
  4528. if (!(!name || !element || !(container = element.parentNode))) {
  4529. _context.next = 6;
  4530. break;
  4531. }
  4532. throw new Error('Not enough parameters.');
  4533. case 6:
  4534. if (!this._overlays[name]) {
  4535. _context.next = 8;
  4536. break;
  4537. }
  4538. throw new Error('The overlay is already registered.');
  4539. case 8:
  4540. this._overlays[name] = {
  4541. element: element,
  4542. container: container,
  4543. callerCloseMethod: callerCloseMethod,
  4544. canForceClose: canForceClose
  4545. };
  4546. case 9:
  4547. case "end":
  4548. return _context.stop();
  4549. }
  4550. }
  4551. }, _callee, this);
  4552. }));
  4553. function register(_x, _x2) {
  4554. return _register.apply(this, arguments);
  4555. }
  4556. return register;
  4557. }()
  4558. }, {
  4559. key: "unregister",
  4560. value: function () {
  4561. var _unregister = _asyncToGenerator(
  4562. /*#__PURE__*/
  4563. _regenerator["default"].mark(function _callee2(name) {
  4564. return _regenerator["default"].wrap(function _callee2$(_context2) {
  4565. while (1) {
  4566. switch (_context2.prev = _context2.next) {
  4567. case 0:
  4568. if (this._overlays[name]) {
  4569. _context2.next = 4;
  4570. break;
  4571. }
  4572. throw new Error('The overlay does not exist.');
  4573. case 4:
  4574. if (!(this._active === name)) {
  4575. _context2.next = 6;
  4576. break;
  4577. }
  4578. throw new Error('The overlay cannot be removed while it is active.');
  4579. case 6:
  4580. delete this._overlays[name];
  4581. case 7:
  4582. case "end":
  4583. return _context2.stop();
  4584. }
  4585. }
  4586. }, _callee2, this);
  4587. }));
  4588. function unregister(_x3) {
  4589. return _unregister.apply(this, arguments);
  4590. }
  4591. return unregister;
  4592. }()
  4593. }, {
  4594. key: "open",
  4595. value: function () {
  4596. var _open = _asyncToGenerator(
  4597. /*#__PURE__*/
  4598. _regenerator["default"].mark(function _callee3(name) {
  4599. return _regenerator["default"].wrap(function _callee3$(_context3) {
  4600. while (1) {
  4601. switch (_context3.prev = _context3.next) {
  4602. case 0:
  4603. if (this._overlays[name]) {
  4604. _context3.next = 4;
  4605. break;
  4606. }
  4607. throw new Error('The overlay does not exist.');
  4608. case 4:
  4609. if (!this._active) {
  4610. _context3.next = 14;
  4611. break;
  4612. }
  4613. if (!this._overlays[name].canForceClose) {
  4614. _context3.next = 9;
  4615. break;
  4616. }
  4617. this._closeThroughCaller();
  4618. _context3.next = 14;
  4619. break;
  4620. case 9:
  4621. if (!(this._active === name)) {
  4622. _context3.next = 13;
  4623. break;
  4624. }
  4625. throw new Error('The overlay is already active.');
  4626. case 13:
  4627. throw new Error('Another overlay is currently active.');
  4628. case 14:
  4629. this._active = name;
  4630. this._overlays[this._active].element.classList.remove('hidden');
  4631. this._overlays[this._active].container.classList.remove('hidden');
  4632. window.addEventListener('keydown', this._keyDownBound);
  4633. case 18:
  4634. case "end":
  4635. return _context3.stop();
  4636. }
  4637. }
  4638. }, _callee3, this);
  4639. }));
  4640. function open(_x4) {
  4641. return _open.apply(this, arguments);
  4642. }
  4643. return open;
  4644. }()
  4645. }, {
  4646. key: "close",
  4647. value: function () {
  4648. var _close = _asyncToGenerator(
  4649. /*#__PURE__*/
  4650. _regenerator["default"].mark(function _callee4(name) {
  4651. return _regenerator["default"].wrap(function _callee4$(_context4) {
  4652. while (1) {
  4653. switch (_context4.prev = _context4.next) {
  4654. case 0:
  4655. if (this._overlays[name]) {
  4656. _context4.next = 4;
  4657. break;
  4658. }
  4659. throw new Error('The overlay does not exist.');
  4660. case 4:
  4661. if (this._active) {
  4662. _context4.next = 8;
  4663. break;
  4664. }
  4665. throw new Error('The overlay is currently not active.');
  4666. case 8:
  4667. if (!(this._active !== name)) {
  4668. _context4.next = 10;
  4669. break;
  4670. }
  4671. throw new Error('Another overlay is currently active.');
  4672. case 10:
  4673. this._overlays[this._active].container.classList.add('hidden');
  4674. this._overlays[this._active].element.classList.add('hidden');
  4675. this._active = null;
  4676. window.removeEventListener('keydown', this._keyDownBound);
  4677. case 14:
  4678. case "end":
  4679. return _context4.stop();
  4680. }
  4681. }
  4682. }, _callee4, this);
  4683. }));
  4684. function close(_x5) {
  4685. return _close.apply(this, arguments);
  4686. }
  4687. return close;
  4688. }()
  4689. }, {
  4690. key: "_keyDown",
  4691. value: function _keyDown(evt) {
  4692. if (this._active && evt.keyCode === 27) {
  4693. this._closeThroughCaller();
  4694. evt.preventDefault();
  4695. }
  4696. }
  4697. }, {
  4698. key: "_closeThroughCaller",
  4699. value: function _closeThroughCaller() {
  4700. if (this._overlays[this._active].callerCloseMethod) {
  4701. this._overlays[this._active].callerCloseMethod();
  4702. }
  4703. if (this._active) {
  4704. this.close(this._active);
  4705. }
  4706. }
  4707. }, {
  4708. key: "active",
  4709. get: function get() {
  4710. return this._active;
  4711. }
  4712. }]);
  4713. return OverlayManager;
  4714. }();
  4715. exports.OverlayManager = OverlayManager;
  4716. /***/ }),
  4717. /* 14 */
  4718. /***/ (function(module, exports, __webpack_require__) {
  4719. "use strict";
  4720. Object.defineProperty(exports, "__esModule", {
  4721. value: true
  4722. });
  4723. exports.PasswordPrompt = void 0;
  4724. var _ui_utils = __webpack_require__(5);
  4725. var _pdfjsLib = __webpack_require__(7);
  4726. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4727. 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); } }
  4728. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4729. var PasswordPrompt =
  4730. /*#__PURE__*/
  4731. function () {
  4732. function PasswordPrompt(options, overlayManager) {
  4733. var _this = this;
  4734. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  4735. _classCallCheck(this, PasswordPrompt);
  4736. this.overlayName = options.overlayName;
  4737. this.container = options.container;
  4738. this.label = options.label;
  4739. this.input = options.input;
  4740. this.submitButton = options.submitButton;
  4741. this.cancelButton = options.cancelButton;
  4742. this.overlayManager = overlayManager;
  4743. this.l10n = l10n;
  4744. this.updateCallback = null;
  4745. this.reason = null;
  4746. this.submitButton.addEventListener('click', this.verify.bind(this));
  4747. this.cancelButton.addEventListener('click', this.close.bind(this));
  4748. this.input.addEventListener('keydown', function (e) {
  4749. if (e.keyCode === 13) {
  4750. _this.verify();
  4751. }
  4752. });
  4753. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  4754. }
  4755. _createClass(PasswordPrompt, [{
  4756. key: "open",
  4757. value: function open() {
  4758. var _this2 = this;
  4759. this.overlayManager.open(this.overlayName).then(function () {
  4760. _this2.input.focus();
  4761. var promptString;
  4762. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  4763. promptString = _this2.l10n.get('password_invalid', null, 'Invalid password. Please try again.');
  4764. } else {
  4765. promptString = _this2.l10n.get('password_label', null, 'Enter the password to open this PDF file.');
  4766. }
  4767. promptString.then(function (msg) {
  4768. _this2.label.textContent = msg;
  4769. });
  4770. });
  4771. }
  4772. }, {
  4773. key: "close",
  4774. value: function close() {
  4775. var _this3 = this;
  4776. this.overlayManager.close(this.overlayName).then(function () {
  4777. _this3.input.value = '';
  4778. });
  4779. }
  4780. }, {
  4781. key: "verify",
  4782. value: function verify() {
  4783. var password = this.input.value;
  4784. if (password && password.length > 0) {
  4785. this.close();
  4786. this.updateCallback(password);
  4787. }
  4788. }
  4789. }, {
  4790. key: "setUpdateCallback",
  4791. value: function setUpdateCallback(updateCallback, reason) {
  4792. this.updateCallback = updateCallback;
  4793. this.reason = reason;
  4794. }
  4795. }]);
  4796. return PasswordPrompt;
  4797. }();
  4798. exports.PasswordPrompt = PasswordPrompt;
  4799. /***/ }),
  4800. /* 15 */
  4801. /***/ (function(module, exports, __webpack_require__) {
  4802. "use strict";
  4803. Object.defineProperty(exports, "__esModule", {
  4804. value: true
  4805. });
  4806. exports.PDFAttachmentViewer = void 0;
  4807. var _pdfjsLib = __webpack_require__(7);
  4808. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4809. 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); } }
  4810. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4811. var PDFAttachmentViewer =
  4812. /*#__PURE__*/
  4813. function () {
  4814. function PDFAttachmentViewer(_ref) {
  4815. var container = _ref.container,
  4816. eventBus = _ref.eventBus,
  4817. downloadManager = _ref.downloadManager;
  4818. _classCallCheck(this, PDFAttachmentViewer);
  4819. this.container = container;
  4820. this.eventBus = eventBus;
  4821. this.downloadManager = downloadManager;
  4822. this.reset();
  4823. this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this));
  4824. }
  4825. _createClass(PDFAttachmentViewer, [{
  4826. key: "reset",
  4827. value: function reset() {
  4828. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4829. this.attachments = null;
  4830. this.container.textContent = '';
  4831. if (!keepRenderedCapability) {
  4832. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  4833. }
  4834. }
  4835. }, {
  4836. key: "_dispatchEvent",
  4837. value: function _dispatchEvent(attachmentsCount) {
  4838. this._renderedCapability.resolve();
  4839. this.eventBus.dispatch('attachmentsloaded', {
  4840. source: this,
  4841. attachmentsCount: attachmentsCount
  4842. });
  4843. }
  4844. }, {
  4845. key: "_bindPdfLink",
  4846. value: function _bindPdfLink(button, content, filename) {
  4847. if (this.downloadManager.disableCreateObjectURL) {
  4848. throw new Error('bindPdfLink: Unsupported "disableCreateObjectURL" value.');
  4849. }
  4850. var blobUrl;
  4851. button.onclick = function () {
  4852. if (!blobUrl) {
  4853. blobUrl = (0, _pdfjsLib.createObjectURL)(content, 'application/pdf');
  4854. }
  4855. var viewerUrl;
  4856. viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename);
  4857. window.open(viewerUrl);
  4858. return false;
  4859. };
  4860. }
  4861. }, {
  4862. key: "_bindLink",
  4863. value: function _bindLink(button, content, filename) {
  4864. var _this = this;
  4865. button.onclick = function () {
  4866. _this.downloadManager.downloadData(content, filename, '');
  4867. return false;
  4868. };
  4869. }
  4870. }, {
  4871. key: "render",
  4872. value: function render(_ref2) {
  4873. var attachments = _ref2.attachments,
  4874. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  4875. keepRenderedCapability = _ref2$keepRenderedCap === void 0 ? false : _ref2$keepRenderedCap;
  4876. var attachmentsCount = 0;
  4877. if (this.attachments) {
  4878. this.reset(keepRenderedCapability === true);
  4879. }
  4880. this.attachments = attachments || null;
  4881. if (!attachments) {
  4882. this._dispatchEvent(attachmentsCount);
  4883. return;
  4884. }
  4885. var names = Object.keys(attachments).sort(function (a, b) {
  4886. return a.toLowerCase().localeCompare(b.toLowerCase());
  4887. });
  4888. attachmentsCount = names.length;
  4889. for (var i = 0; i < attachmentsCount; i++) {
  4890. var item = attachments[names[i]];
  4891. var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib.getFilenameFromUrl)(item.filename));
  4892. var div = document.createElement('div');
  4893. div.className = 'attachmentsItem';
  4894. var button = document.createElement('button');
  4895. button.textContent = filename;
  4896. if (/\.pdf$/i.test(filename) && !this.downloadManager.disableCreateObjectURL) {
  4897. this._bindPdfLink(button, item.content, filename);
  4898. } else {
  4899. this._bindLink(button, item.content, filename);
  4900. }
  4901. div.appendChild(button);
  4902. this.container.appendChild(div);
  4903. }
  4904. this._dispatchEvent(attachmentsCount);
  4905. }
  4906. }, {
  4907. key: "_appendAttachment",
  4908. value: function _appendAttachment(_ref3) {
  4909. var _this2 = this;
  4910. var id = _ref3.id,
  4911. filename = _ref3.filename,
  4912. content = _ref3.content;
  4913. this._renderedCapability.promise.then(function () {
  4914. var attachments = _this2.attachments;
  4915. if (!attachments) {
  4916. attachments = Object.create(null);
  4917. } else {
  4918. for (var name in attachments) {
  4919. if (id === name) {
  4920. return;
  4921. }
  4922. }
  4923. }
  4924. attachments[id] = {
  4925. filename: filename,
  4926. content: content
  4927. };
  4928. _this2.render({
  4929. attachments: attachments,
  4930. keepRenderedCapability: true
  4931. });
  4932. });
  4933. }
  4934. }]);
  4935. return PDFAttachmentViewer;
  4936. }();
  4937. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  4938. /***/ }),
  4939. /* 16 */
  4940. /***/ (function(module, exports, __webpack_require__) {
  4941. "use strict";
  4942. Object.defineProperty(exports, "__esModule", {
  4943. value: true
  4944. });
  4945. exports.PDFDocumentProperties = void 0;
  4946. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  4947. var _pdfjsLib = __webpack_require__(7);
  4948. var _ui_utils = __webpack_require__(5);
  4949. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4950. 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); } }
  4951. 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); }); }; }
  4952. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  4953. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  4954. function _iterableToArrayLimit(arr, i) { 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; }
  4955. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  4956. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4957. 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); } }
  4958. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4959. var DEFAULT_FIELD_CONTENT = '-';
  4960. var NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my'];
  4961. var US_PAGE_NAMES = {
  4962. '8.5x11': 'Letter',
  4963. '8.5x14': 'Legal'
  4964. };
  4965. var METRIC_PAGE_NAMES = {
  4966. '297x420': 'A3',
  4967. '210x297': 'A4'
  4968. };
  4969. function getPageName(size, isPortrait, pageNames) {
  4970. var width = isPortrait ? size.width : size.height;
  4971. var height = isPortrait ? size.height : size.width;
  4972. return pageNames["".concat(width, "x").concat(height)];
  4973. }
  4974. var PDFDocumentProperties =
  4975. /*#__PURE__*/
  4976. function () {
  4977. function PDFDocumentProperties(_ref, overlayManager, eventBus) {
  4978. var _this = this;
  4979. var overlayName = _ref.overlayName,
  4980. fields = _ref.fields,
  4981. container = _ref.container,
  4982. closeButton = _ref.closeButton;
  4983. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  4984. _classCallCheck(this, PDFDocumentProperties);
  4985. this.overlayName = overlayName;
  4986. this.fields = fields;
  4987. this.container = container;
  4988. this.overlayManager = overlayManager;
  4989. this.l10n = l10n;
  4990. this._reset();
  4991. if (closeButton) {
  4992. closeButton.addEventListener('click', this.close.bind(this));
  4993. }
  4994. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  4995. if (eventBus) {
  4996. eventBus.on('pagechanging', function (evt) {
  4997. _this._currentPageNumber = evt.pageNumber;
  4998. });
  4999. eventBus.on('rotationchanging', function (evt) {
  5000. _this._pagesRotation = evt.pagesRotation;
  5001. });
  5002. }
  5003. this._isNonMetricLocale = true;
  5004. l10n.getLanguage().then(function (locale) {
  5005. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  5006. });
  5007. }
  5008. _createClass(PDFDocumentProperties, [{
  5009. key: "open",
  5010. value: function open() {
  5011. var _this2 = this;
  5012. var freezeFieldData = function freezeFieldData(data) {
  5013. Object.defineProperty(_this2, 'fieldData', {
  5014. value: Object.freeze(data),
  5015. writable: false,
  5016. enumerable: true,
  5017. configurable: true
  5018. });
  5019. };
  5020. Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
  5021. var currentPageNumber = _this2._currentPageNumber;
  5022. var pagesRotation = _this2._pagesRotation;
  5023. if (_this2.fieldData && currentPageNumber === _this2.fieldData['_currentPageNumber'] && pagesRotation === _this2.fieldData['_pagesRotation']) {
  5024. _this2._updateUI();
  5025. return;
  5026. }
  5027. _this2.pdfDocument.getMetadata().then(function (_ref2) {
  5028. var info = _ref2.info,
  5029. metadata = _ref2.metadata,
  5030. contentDispositionFilename = _ref2.contentDispositionFilename;
  5031. return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(_this2.url || ''), _this2._parseFileSize(_this2.maybeFileSize), _this2._parseDate(info.CreationDate), _this2._parseDate(info.ModDate), _this2.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
  5032. return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  5033. }), _this2._parseLinearization(info.IsLinearized)]);
  5034. }).then(function (_ref3) {
  5035. var _ref4 = _slicedToArray(_ref3, 8),
  5036. info = _ref4[0],
  5037. metadata = _ref4[1],
  5038. fileName = _ref4[2],
  5039. fileSize = _ref4[3],
  5040. creationDate = _ref4[4],
  5041. modDate = _ref4[5],
  5042. pageSize = _ref4[6],
  5043. isLinearized = _ref4[7];
  5044. freezeFieldData({
  5045. 'fileName': fileName,
  5046. 'fileSize': fileSize,
  5047. 'title': info.Title,
  5048. 'author': info.Author,
  5049. 'subject': info.Subject,
  5050. 'keywords': info.Keywords,
  5051. 'creationDate': creationDate,
  5052. 'modificationDate': modDate,
  5053. 'creator': info.Creator,
  5054. 'producer': info.Producer,
  5055. 'version': info.PDFFormatVersion,
  5056. 'pageCount': _this2.pdfDocument.numPages,
  5057. 'pageSize': pageSize,
  5058. 'linearized': isLinearized,
  5059. '_currentPageNumber': currentPageNumber,
  5060. '_pagesRotation': pagesRotation
  5061. });
  5062. _this2._updateUI();
  5063. return _this2.pdfDocument.getDownloadInfo();
  5064. }).then(function (_ref5) {
  5065. var length = _ref5.length;
  5066. _this2.maybeFileSize = length;
  5067. return _this2._parseFileSize(length);
  5068. }).then(function (fileSize) {
  5069. if (fileSize === _this2.fieldData['fileSize']) {
  5070. return;
  5071. }
  5072. var data = Object.assign(Object.create(null), _this2.fieldData);
  5073. data['fileSize'] = fileSize;
  5074. freezeFieldData(data);
  5075. _this2._updateUI();
  5076. });
  5077. });
  5078. }
  5079. }, {
  5080. key: "close",
  5081. value: function close() {
  5082. this.overlayManager.close(this.overlayName);
  5083. }
  5084. }, {
  5085. key: "setDocument",
  5086. value: function setDocument(pdfDocument) {
  5087. var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5088. if (this.pdfDocument) {
  5089. this._reset();
  5090. this._updateUI(true);
  5091. }
  5092. if (!pdfDocument) {
  5093. return;
  5094. }
  5095. this.pdfDocument = pdfDocument;
  5096. this.url = url;
  5097. this._dataAvailableCapability.resolve();
  5098. }
  5099. }, {
  5100. key: "setFileSize",
  5101. value: function setFileSize(fileSize) {
  5102. if (Number.isInteger(fileSize) && fileSize > 0) {
  5103. this.maybeFileSize = fileSize;
  5104. }
  5105. }
  5106. }, {
  5107. key: "_reset",
  5108. value: function _reset() {
  5109. this.pdfDocument = null;
  5110. this.url = null;
  5111. this.maybeFileSize = 0;
  5112. delete this.fieldData;
  5113. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5114. this._currentPageNumber = 1;
  5115. this._pagesRotation = 0;
  5116. }
  5117. }, {
  5118. key: "_updateUI",
  5119. value: function _updateUI() {
  5120. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5121. if (reset || !this.fieldData) {
  5122. for (var id in this.fields) {
  5123. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5124. }
  5125. return;
  5126. }
  5127. if (this.overlayManager.active !== this.overlayName) {
  5128. return;
  5129. }
  5130. for (var _id in this.fields) {
  5131. var content = this.fieldData[_id];
  5132. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5133. }
  5134. }
  5135. }, {
  5136. key: "_parseFileSize",
  5137. value: function () {
  5138. var _parseFileSize2 = _asyncToGenerator(
  5139. /*#__PURE__*/
  5140. _regenerator["default"].mark(function _callee() {
  5141. var fileSize,
  5142. kb,
  5143. _args = arguments;
  5144. return _regenerator["default"].wrap(function _callee$(_context) {
  5145. while (1) {
  5146. switch (_context.prev = _context.next) {
  5147. case 0:
  5148. fileSize = _args.length > 0 && _args[0] !== undefined ? _args[0] : 0;
  5149. kb = fileSize / 1024;
  5150. if (kb) {
  5151. _context.next = 6;
  5152. break;
  5153. }
  5154. return _context.abrupt("return", undefined);
  5155. case 6:
  5156. if (!(kb < 1024)) {
  5157. _context.next = 8;
  5158. break;
  5159. }
  5160. return _context.abrupt("return", this.l10n.get('document_properties_kb', {
  5161. size_kb: (+kb.toPrecision(3)).toLocaleString(),
  5162. size_b: fileSize.toLocaleString()
  5163. }, '{{size_kb}} KB ({{size_b}} bytes)'));
  5164. case 8:
  5165. return _context.abrupt("return", this.l10n.get('document_properties_mb', {
  5166. size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
  5167. size_b: fileSize.toLocaleString()
  5168. }, '{{size_mb}} MB ({{size_b}} bytes)'));
  5169. case 9:
  5170. case "end":
  5171. return _context.stop();
  5172. }
  5173. }
  5174. }, _callee, this);
  5175. }));
  5176. function _parseFileSize() {
  5177. return _parseFileSize2.apply(this, arguments);
  5178. }
  5179. return _parseFileSize;
  5180. }()
  5181. }, {
  5182. key: "_parsePageSize",
  5183. value: function () {
  5184. var _parsePageSize2 = _asyncToGenerator(
  5185. /*#__PURE__*/
  5186. _regenerator["default"].mark(function _callee2(pageSizeInches, pagesRotation) {
  5187. var _this3 = this;
  5188. var isPortrait, sizeInches, sizeMillimeters, pageName, name, exactMillimeters, intMillimeters;
  5189. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5190. while (1) {
  5191. switch (_context2.prev = _context2.next) {
  5192. case 0:
  5193. if (pageSizeInches) {
  5194. _context2.next = 2;
  5195. break;
  5196. }
  5197. return _context2.abrupt("return", undefined);
  5198. case 2:
  5199. if (pagesRotation % 180 !== 0) {
  5200. pageSizeInches = {
  5201. width: pageSizeInches.height,
  5202. height: pageSizeInches.width
  5203. };
  5204. }
  5205. isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  5206. sizeInches = {
  5207. width: Math.round(pageSizeInches.width * 100) / 100,
  5208. height: Math.round(pageSizeInches.height * 100) / 100
  5209. };
  5210. sizeMillimeters = {
  5211. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  5212. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  5213. };
  5214. pageName = null;
  5215. name = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5216. if (!name && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  5217. exactMillimeters = {
  5218. width: pageSizeInches.width * 25.4,
  5219. height: pageSizeInches.height * 25.4
  5220. };
  5221. intMillimeters = {
  5222. width: Math.round(sizeMillimeters.width),
  5223. height: Math.round(sizeMillimeters.height)
  5224. };
  5225. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  5226. name = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5227. if (name) {
  5228. sizeInches = {
  5229. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  5230. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  5231. };
  5232. sizeMillimeters = intMillimeters;
  5233. }
  5234. }
  5235. }
  5236. if (name) {
  5237. pageName = this.l10n.get('document_properties_page_size_name_' + name.toLowerCase(), null, name);
  5238. }
  5239. return _context2.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 (_ref6) {
  5240. var _ref7 = _slicedToArray(_ref6, 4),
  5241. _ref7$ = _ref7[0],
  5242. width = _ref7$.width,
  5243. height = _ref7$.height,
  5244. unit = _ref7[1],
  5245. name = _ref7[2],
  5246. orientation = _ref7[3];
  5247. return _this3.l10n.get('document_properties_page_size_dimension_' + (name ? 'name_' : '') + 'string', {
  5248. width: width.toLocaleString(),
  5249. height: height.toLocaleString(),
  5250. unit: unit,
  5251. name: name,
  5252. orientation: orientation
  5253. }, '{{width}} × {{height}} {{unit}} (' + (name ? '{{name}}, ' : '') + '{{orientation}})');
  5254. }));
  5255. case 11:
  5256. case "end":
  5257. return _context2.stop();
  5258. }
  5259. }
  5260. }, _callee2, this);
  5261. }));
  5262. function _parsePageSize(_x, _x2) {
  5263. return _parsePageSize2.apply(this, arguments);
  5264. }
  5265. return _parsePageSize;
  5266. }()
  5267. }, {
  5268. key: "_parseDate",
  5269. value: function () {
  5270. var _parseDate2 = _asyncToGenerator(
  5271. /*#__PURE__*/
  5272. _regenerator["default"].mark(function _callee3(inputDate) {
  5273. var dateObject;
  5274. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5275. while (1) {
  5276. switch (_context3.prev = _context3.next) {
  5277. case 0:
  5278. dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  5279. if (dateObject) {
  5280. _context3.next = 3;
  5281. break;
  5282. }
  5283. return _context3.abrupt("return", undefined);
  5284. case 3:
  5285. return _context3.abrupt("return", this.l10n.get('document_properties_date_string', {
  5286. date: dateObject.toLocaleDateString(),
  5287. time: dateObject.toLocaleTimeString()
  5288. }, '{{date}}, {{time}}'));
  5289. case 4:
  5290. case "end":
  5291. return _context3.stop();
  5292. }
  5293. }
  5294. }, _callee3, this);
  5295. }));
  5296. function _parseDate(_x3) {
  5297. return _parseDate2.apply(this, arguments);
  5298. }
  5299. return _parseDate;
  5300. }()
  5301. }, {
  5302. key: "_parseLinearization",
  5303. value: function _parseLinearization(isLinearized) {
  5304. return this.l10n.get('document_properties_linearized_' + (isLinearized ? 'yes' : 'no'), null, isLinearized ? 'Yes' : 'No');
  5305. }
  5306. }]);
  5307. return PDFDocumentProperties;
  5308. }();
  5309. exports.PDFDocumentProperties = PDFDocumentProperties;
  5310. /***/ }),
  5311. /* 17 */
  5312. /***/ (function(module, exports, __webpack_require__) {
  5313. "use strict";
  5314. Object.defineProperty(exports, "__esModule", {
  5315. value: true
  5316. });
  5317. exports.PDFFindBar = void 0;
  5318. var _ui_utils = __webpack_require__(5);
  5319. var _pdf_find_controller = __webpack_require__(18);
  5320. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5321. 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); } }
  5322. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5323. var MATCHES_COUNT_LIMIT = 1000;
  5324. var PDFFindBar =
  5325. /*#__PURE__*/
  5326. function () {
  5327. function PDFFindBar(options) {
  5328. var _this = this;
  5329. var eventBus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (0, _ui_utils.getGlobalEventBus)();
  5330. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5331. _classCallCheck(this, PDFFindBar);
  5332. this.opened = false;
  5333. this.bar = options.bar || null;
  5334. this.toggleButton = options.toggleButton || null;
  5335. this.findField = options.findField || null;
  5336. this.highlightAll = options.highlightAllCheckbox || null;
  5337. this.caseSensitive = options.caseSensitiveCheckbox || null;
  5338. this.entireWord = options.entireWordCheckbox || null;
  5339. this.findMsg = options.findMsg || null;
  5340. this.findResultsCount = options.findResultsCount || null;
  5341. this.findPreviousButton = options.findPreviousButton || null;
  5342. this.findNextButton = options.findNextButton || null;
  5343. this.eventBus = eventBus;
  5344. this.l10n = l10n;
  5345. this.toggleButton.addEventListener('click', function () {
  5346. _this.toggle();
  5347. });
  5348. this.findField.addEventListener('input', function () {
  5349. _this.dispatchEvent('');
  5350. });
  5351. this.bar.addEventListener('keydown', function (e) {
  5352. switch (e.keyCode) {
  5353. case 13:
  5354. if (e.target === _this.findField) {
  5355. _this.dispatchEvent('again', e.shiftKey);
  5356. }
  5357. break;
  5358. case 27:
  5359. _this.close();
  5360. break;
  5361. }
  5362. });
  5363. this.findPreviousButton.addEventListener('click', function () {
  5364. _this.dispatchEvent('again', true);
  5365. });
  5366. this.findNextButton.addEventListener('click', function () {
  5367. _this.dispatchEvent('again', false);
  5368. });
  5369. this.highlightAll.addEventListener('click', function () {
  5370. _this.dispatchEvent('highlightallchange');
  5371. });
  5372. this.caseSensitive.addEventListener('click', function () {
  5373. _this.dispatchEvent('casesensitivitychange');
  5374. });
  5375. this.entireWord.addEventListener('click', function () {
  5376. _this.dispatchEvent('entirewordchange');
  5377. });
  5378. this.eventBus.on('resize', this._adjustWidth.bind(this));
  5379. }
  5380. _createClass(PDFFindBar, [{
  5381. key: "reset",
  5382. value: function reset() {
  5383. this.updateUIState();
  5384. }
  5385. }, {
  5386. key: "dispatchEvent",
  5387. value: function dispatchEvent(type, findPrev) {
  5388. this.eventBus.dispatch('find', {
  5389. source: this,
  5390. type: type,
  5391. query: this.findField.value,
  5392. phraseSearch: true,
  5393. caseSensitive: this.caseSensitive.checked,
  5394. entireWord: this.entireWord.checked,
  5395. highlightAll: this.highlightAll.checked,
  5396. findPrevious: findPrev
  5397. });
  5398. }
  5399. }, {
  5400. key: "updateUIState",
  5401. value: function updateUIState(state, previous, matchesCount) {
  5402. var _this2 = this;
  5403. var notFound = false;
  5404. var findMsg = '';
  5405. var status = '';
  5406. switch (state) {
  5407. case _pdf_find_controller.FindState.FOUND:
  5408. break;
  5409. case _pdf_find_controller.FindState.PENDING:
  5410. status = 'pending';
  5411. break;
  5412. case _pdf_find_controller.FindState.NOT_FOUND:
  5413. findMsg = this.l10n.get('find_not_found', null, 'Phrase not found');
  5414. notFound = true;
  5415. break;
  5416. case _pdf_find_controller.FindState.WRAPPED:
  5417. if (previous) {
  5418. findMsg = this.l10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
  5419. } else {
  5420. findMsg = this.l10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
  5421. }
  5422. break;
  5423. }
  5424. this.findField.classList.toggle('notFound', notFound);
  5425. this.findField.setAttribute('data-status', status);
  5426. Promise.resolve(findMsg).then(function (msg) {
  5427. _this2.findMsg.textContent = msg;
  5428. _this2._adjustWidth();
  5429. });
  5430. this.updateResultsCount(matchesCount);
  5431. }
  5432. }, {
  5433. key: "updateResultsCount",
  5434. value: function updateResultsCount() {
  5435. var _this3 = this;
  5436. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  5437. _ref$current = _ref.current,
  5438. current = _ref$current === void 0 ? 0 : _ref$current,
  5439. _ref$total = _ref.total,
  5440. total = _ref$total === void 0 ? 0 : _ref$total;
  5441. if (!this.findResultsCount) {
  5442. return;
  5443. }
  5444. var matchesCountMsg = '',
  5445. limit = MATCHES_COUNT_LIMIT;
  5446. if (total > 0) {
  5447. if (total > limit) {
  5448. matchesCountMsg = this.l10n.get('find_match_count_limit', {
  5449. limit: limit
  5450. }, 'More than {{limit}} match' + (limit !== 1 ? 'es' : ''));
  5451. } else {
  5452. matchesCountMsg = this.l10n.get('find_match_count', {
  5453. current: current,
  5454. total: total
  5455. }, '{{current}} of {{total}} match' + (total !== 1 ? 'es' : ''));
  5456. }
  5457. }
  5458. Promise.resolve(matchesCountMsg).then(function (msg) {
  5459. _this3.findResultsCount.textContent = msg;
  5460. _this3.findResultsCount.classList.toggle('hidden', !total);
  5461. _this3._adjustWidth();
  5462. });
  5463. }
  5464. }, {
  5465. key: "open",
  5466. value: function open() {
  5467. if (!this.opened) {
  5468. this.opened = true;
  5469. this.toggleButton.classList.add('toggled');
  5470. this.bar.classList.remove('hidden');
  5471. }
  5472. this.findField.select();
  5473. this.findField.focus();
  5474. this._adjustWidth();
  5475. }
  5476. }, {
  5477. key: "close",
  5478. value: function close() {
  5479. if (!this.opened) {
  5480. return;
  5481. }
  5482. this.opened = false;
  5483. this.toggleButton.classList.remove('toggled');
  5484. this.bar.classList.add('hidden');
  5485. this.eventBus.dispatch('findbarclose', {
  5486. source: this
  5487. });
  5488. }
  5489. }, {
  5490. key: "toggle",
  5491. value: function toggle() {
  5492. if (this.opened) {
  5493. this.close();
  5494. } else {
  5495. this.open();
  5496. }
  5497. }
  5498. }, {
  5499. key: "_adjustWidth",
  5500. value: function _adjustWidth() {
  5501. if (!this.opened) {
  5502. return;
  5503. }
  5504. this.bar.classList.remove('wrapContainers');
  5505. var findbarHeight = this.bar.clientHeight;
  5506. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  5507. if (findbarHeight > inputContainerHeight) {
  5508. this.bar.classList.add('wrapContainers');
  5509. }
  5510. }
  5511. }]);
  5512. return PDFFindBar;
  5513. }();
  5514. exports.PDFFindBar = PDFFindBar;
  5515. /***/ }),
  5516. /* 18 */
  5517. /***/ (function(module, exports, __webpack_require__) {
  5518. "use strict";
  5519. Object.defineProperty(exports, "__esModule", {
  5520. value: true
  5521. });
  5522. exports.PDFFindController = exports.FindState = void 0;
  5523. var _ui_utils = __webpack_require__(5);
  5524. var _pdfjsLib = __webpack_require__(7);
  5525. var _pdf_find_utils = __webpack_require__(19);
  5526. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5527. 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); } }
  5528. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5529. var FindState = {
  5530. FOUND: 0,
  5531. NOT_FOUND: 1,
  5532. WRAPPED: 2,
  5533. PENDING: 3
  5534. };
  5535. exports.FindState = FindState;
  5536. var FIND_TIMEOUT = 250;
  5537. var MATCH_SCROLL_OFFSET_TOP = -50;
  5538. var MATCH_SCROLL_OFFSET_LEFT = -400;
  5539. var CHARACTERS_TO_NORMALIZE = {
  5540. "\u2018": '\'',
  5541. "\u2019": '\'',
  5542. "\u201A": '\'',
  5543. "\u201B": '\'',
  5544. "\u201C": '"',
  5545. "\u201D": '"',
  5546. "\u201E": '"',
  5547. "\u201F": '"',
  5548. "\xBC": '1/4',
  5549. "\xBD": '1/2',
  5550. "\xBE": '3/4'
  5551. };
  5552. var normalizationRegex = null;
  5553. function normalize(text) {
  5554. if (!normalizationRegex) {
  5555. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  5556. normalizationRegex = new RegExp("[".concat(replace, "]"), 'g');
  5557. }
  5558. return text.replace(normalizationRegex, function (ch) {
  5559. return CHARACTERS_TO_NORMALIZE[ch];
  5560. });
  5561. }
  5562. var PDFFindController =
  5563. /*#__PURE__*/
  5564. function () {
  5565. function PDFFindController(_ref) {
  5566. var linkService = _ref.linkService,
  5567. _ref$eventBus = _ref.eventBus,
  5568. eventBus = _ref$eventBus === void 0 ? (0, _ui_utils.getGlobalEventBus)() : _ref$eventBus;
  5569. _classCallCheck(this, PDFFindController);
  5570. this._linkService = linkService;
  5571. this._eventBus = eventBus;
  5572. this._reset();
  5573. eventBus.on('findbarclose', this._onFindBarClose.bind(this));
  5574. }
  5575. _createClass(PDFFindController, [{
  5576. key: "setDocument",
  5577. value: function setDocument(pdfDocument) {
  5578. if (this._pdfDocument) {
  5579. this._reset();
  5580. }
  5581. if (!pdfDocument) {
  5582. return;
  5583. }
  5584. this._pdfDocument = pdfDocument;
  5585. this._firstPageCapability.resolve();
  5586. }
  5587. }, {
  5588. key: "executeCommand",
  5589. value: function executeCommand(cmd, state) {
  5590. var _this = this;
  5591. if (!state) {
  5592. return;
  5593. }
  5594. var pdfDocument = this._pdfDocument;
  5595. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  5596. this._dirtyMatch = true;
  5597. }
  5598. this._state = state;
  5599. if (cmd !== 'findhighlightallchange') {
  5600. this._updateUIState(FindState.PENDING);
  5601. }
  5602. this._firstPageCapability.promise.then(function () {
  5603. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  5604. return;
  5605. }
  5606. _this._extractText();
  5607. var findbarClosed = !_this._highlightMatches;
  5608. var pendingTimeout = !!_this._findTimeout;
  5609. if (_this._findTimeout) {
  5610. clearTimeout(_this._findTimeout);
  5611. _this._findTimeout = null;
  5612. }
  5613. if (cmd === 'find') {
  5614. _this._findTimeout = setTimeout(function () {
  5615. _this._nextMatch();
  5616. _this._findTimeout = null;
  5617. }, FIND_TIMEOUT);
  5618. } else if (_this._dirtyMatch) {
  5619. _this._nextMatch();
  5620. } else if (cmd === 'findagain') {
  5621. _this._nextMatch();
  5622. if (findbarClosed && _this._state.highlightAll) {
  5623. _this._updateAllPages();
  5624. }
  5625. } else if (cmd === 'findhighlightallchange') {
  5626. if (pendingTimeout) {
  5627. _this._nextMatch();
  5628. } else {
  5629. _this._highlightMatches = true;
  5630. }
  5631. _this._updateAllPages();
  5632. } else {
  5633. _this._nextMatch();
  5634. }
  5635. });
  5636. }
  5637. }, {
  5638. key: "scrollMatchIntoView",
  5639. value: function scrollMatchIntoView(_ref2) {
  5640. var _ref2$element = _ref2.element,
  5641. element = _ref2$element === void 0 ? null : _ref2$element,
  5642. _ref2$pageIndex = _ref2.pageIndex,
  5643. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  5644. _ref2$matchIndex = _ref2.matchIndex,
  5645. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  5646. if (!this._scrollMatches || !element) {
  5647. return;
  5648. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  5649. return;
  5650. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  5651. return;
  5652. }
  5653. this._scrollMatches = false;
  5654. var spot = {
  5655. top: MATCH_SCROLL_OFFSET_TOP,
  5656. left: MATCH_SCROLL_OFFSET_LEFT
  5657. };
  5658. (0, _ui_utils.scrollIntoView)(element, spot, true);
  5659. }
  5660. }, {
  5661. key: "_reset",
  5662. value: function _reset() {
  5663. this._highlightMatches = false;
  5664. this._scrollMatches = false;
  5665. this._pdfDocument = null;
  5666. this._pageMatches = [];
  5667. this._pageMatchesLength = [];
  5668. this._state = null;
  5669. this._selected = {
  5670. pageIdx: -1,
  5671. matchIdx: -1
  5672. };
  5673. this._offset = {
  5674. pageIdx: null,
  5675. matchIdx: null,
  5676. wrapped: false
  5677. };
  5678. this._extractTextPromises = [];
  5679. this._pageContents = [];
  5680. this._matchesCountTotal = 0;
  5681. this._pagesToSearch = null;
  5682. this._pendingFindMatches = Object.create(null);
  5683. this._resumePageIdx = null;
  5684. this._dirtyMatch = false;
  5685. clearTimeout(this._findTimeout);
  5686. this._findTimeout = null;
  5687. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  5688. }
  5689. }, {
  5690. key: "_shouldDirtyMatch",
  5691. value: function _shouldDirtyMatch(cmd, state) {
  5692. if (state.query !== this._state.query) {
  5693. return true;
  5694. }
  5695. switch (cmd) {
  5696. case 'findagain':
  5697. var pageNumber = this._selected.pageIdx + 1;
  5698. var linkService = this._linkService;
  5699. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  5700. return true;
  5701. }
  5702. return false;
  5703. case 'findhighlightallchange':
  5704. return false;
  5705. }
  5706. return true;
  5707. }
  5708. }, {
  5709. key: "_prepareMatches",
  5710. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  5711. function isSubTerm(matchesWithLength, currentIndex) {
  5712. var currentElem = matchesWithLength[currentIndex];
  5713. var nextElem = matchesWithLength[currentIndex + 1];
  5714. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  5715. currentElem.skipped = true;
  5716. return true;
  5717. }
  5718. for (var i = currentIndex - 1; i >= 0; i--) {
  5719. var prevElem = matchesWithLength[i];
  5720. if (prevElem.skipped) {
  5721. continue;
  5722. }
  5723. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  5724. break;
  5725. }
  5726. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  5727. currentElem.skipped = true;
  5728. return true;
  5729. }
  5730. }
  5731. return false;
  5732. }
  5733. matchesWithLength.sort(function (a, b) {
  5734. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  5735. });
  5736. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  5737. if (isSubTerm(matchesWithLength, i)) {
  5738. continue;
  5739. }
  5740. matches.push(matchesWithLength[i].match);
  5741. matchesLength.push(matchesWithLength[i].matchLength);
  5742. }
  5743. }
  5744. }, {
  5745. key: "_isEntireWord",
  5746. value: function _isEntireWord(content, startIdx, length) {
  5747. if (startIdx > 0) {
  5748. var first = content.charCodeAt(startIdx);
  5749. var limit = content.charCodeAt(startIdx - 1);
  5750. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  5751. return false;
  5752. }
  5753. }
  5754. var endIdx = startIdx + length - 1;
  5755. if (endIdx < content.length - 1) {
  5756. var last = content.charCodeAt(endIdx);
  5757. var _limit = content.charCodeAt(endIdx + 1);
  5758. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  5759. return false;
  5760. }
  5761. }
  5762. return true;
  5763. }
  5764. }, {
  5765. key: "_calculatePhraseMatch",
  5766. value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
  5767. var matches = [];
  5768. var queryLen = query.length;
  5769. var matchIdx = -queryLen;
  5770. while (true) {
  5771. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  5772. if (matchIdx === -1) {
  5773. break;
  5774. }
  5775. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  5776. continue;
  5777. }
  5778. matches.push(matchIdx);
  5779. }
  5780. this._pageMatches[pageIndex] = matches;
  5781. }
  5782. }, {
  5783. key: "_calculateWordMatch",
  5784. value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  5785. var matchesWithLength = [];
  5786. var queryArray = query.match(/\S+/g);
  5787. for (var i = 0, len = queryArray.length; i < len; i++) {
  5788. var subquery = queryArray[i];
  5789. var subqueryLen = subquery.length;
  5790. var matchIdx = -subqueryLen;
  5791. while (true) {
  5792. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  5793. if (matchIdx === -1) {
  5794. break;
  5795. }
  5796. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  5797. continue;
  5798. }
  5799. matchesWithLength.push({
  5800. match: matchIdx,
  5801. matchLength: subqueryLen,
  5802. skipped: false
  5803. });
  5804. }
  5805. }
  5806. this._pageMatchesLength[pageIndex] = [];
  5807. this._pageMatches[pageIndex] = [];
  5808. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  5809. }
  5810. }, {
  5811. key: "_calculateMatch",
  5812. value: function _calculateMatch(pageIndex) {
  5813. var pageContent = this._pageContents[pageIndex];
  5814. var query = this._query;
  5815. var _this$_state = this._state,
  5816. caseSensitive = _this$_state.caseSensitive,
  5817. entireWord = _this$_state.entireWord,
  5818. phraseSearch = _this$_state.phraseSearch;
  5819. if (query.length === 0) {
  5820. return;
  5821. }
  5822. if (!caseSensitive) {
  5823. pageContent = pageContent.toLowerCase();
  5824. query = query.toLowerCase();
  5825. }
  5826. if (phraseSearch) {
  5827. this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
  5828. } else {
  5829. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  5830. }
  5831. if (this._state.highlightAll) {
  5832. this._updatePage(pageIndex);
  5833. }
  5834. if (this._resumePageIdx === pageIndex) {
  5835. this._resumePageIdx = null;
  5836. this._nextPageMatch();
  5837. }
  5838. var pageMatchesCount = this._pageMatches[pageIndex].length;
  5839. if (pageMatchesCount > 0) {
  5840. this._matchesCountTotal += pageMatchesCount;
  5841. this._updateUIResultsCount();
  5842. }
  5843. }
  5844. }, {
  5845. key: "_extractText",
  5846. value: function _extractText() {
  5847. var _this2 = this;
  5848. if (this._extractTextPromises.length > 0) {
  5849. return;
  5850. }
  5851. var promise = Promise.resolve();
  5852. var _loop = function _loop(i, ii) {
  5853. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  5854. _this2._extractTextPromises[i] = extractTextCapability.promise;
  5855. promise = promise.then(function () {
  5856. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  5857. return pdfPage.getTextContent({
  5858. normalizeWhitespace: true
  5859. });
  5860. }).then(function (textContent) {
  5861. var textItems = textContent.items;
  5862. var strBuf = [];
  5863. for (var j = 0, jj = textItems.length; j < jj; j++) {
  5864. strBuf.push(textItems[j].str);
  5865. }
  5866. _this2._pageContents[i] = normalize(strBuf.join(''));
  5867. extractTextCapability.resolve(i);
  5868. }, function (reason) {
  5869. console.error("Unable to get text content for page ".concat(i + 1), reason);
  5870. _this2._pageContents[i] = '';
  5871. extractTextCapability.resolve(i);
  5872. });
  5873. });
  5874. };
  5875. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  5876. _loop(i, ii);
  5877. }
  5878. }
  5879. }, {
  5880. key: "_updatePage",
  5881. value: function _updatePage(index) {
  5882. if (this._scrollMatches && this._selected.pageIdx === index) {
  5883. this._linkService.page = index + 1;
  5884. }
  5885. this._eventBus.dispatch('updatetextlayermatches', {
  5886. source: this,
  5887. pageIndex: index
  5888. });
  5889. }
  5890. }, {
  5891. key: "_updateAllPages",
  5892. value: function _updateAllPages() {
  5893. this._eventBus.dispatch('updatetextlayermatches', {
  5894. source: this,
  5895. pageIndex: -1
  5896. });
  5897. }
  5898. }, {
  5899. key: "_nextMatch",
  5900. value: function _nextMatch() {
  5901. var _this3 = this;
  5902. var previous = this._state.findPrevious;
  5903. var currentPageIndex = this._linkService.page - 1;
  5904. var numPages = this._linkService.pagesCount;
  5905. this._highlightMatches = true;
  5906. if (this._dirtyMatch) {
  5907. this._dirtyMatch = false;
  5908. this._selected.pageIdx = this._selected.matchIdx = -1;
  5909. this._offset.pageIdx = currentPageIndex;
  5910. this._offset.matchIdx = null;
  5911. this._offset.wrapped = false;
  5912. this._resumePageIdx = null;
  5913. this._pageMatches.length = 0;
  5914. this._pageMatchesLength.length = 0;
  5915. this._matchesCountTotal = 0;
  5916. this._updateAllPages();
  5917. for (var i = 0; i < numPages; i++) {
  5918. if (this._pendingFindMatches[i] === true) {
  5919. continue;
  5920. }
  5921. this._pendingFindMatches[i] = true;
  5922. this._extractTextPromises[i].then(function (pageIdx) {
  5923. delete _this3._pendingFindMatches[pageIdx];
  5924. _this3._calculateMatch(pageIdx);
  5925. });
  5926. }
  5927. }
  5928. if (this._query === '') {
  5929. this._updateUIState(FindState.FOUND);
  5930. return;
  5931. }
  5932. if (this._resumePageIdx) {
  5933. return;
  5934. }
  5935. var offset = this._offset;
  5936. this._pagesToSearch = numPages;
  5937. if (offset.matchIdx !== null) {
  5938. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  5939. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  5940. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  5941. this._updateMatch(true);
  5942. return;
  5943. }
  5944. this._advanceOffsetPage(previous);
  5945. }
  5946. this._nextPageMatch();
  5947. }
  5948. }, {
  5949. key: "_matchesReady",
  5950. value: function _matchesReady(matches) {
  5951. var offset = this._offset;
  5952. var numMatches = matches.length;
  5953. var previous = this._state.findPrevious;
  5954. if (numMatches) {
  5955. offset.matchIdx = previous ? numMatches - 1 : 0;
  5956. this._updateMatch(true);
  5957. return true;
  5958. }
  5959. this._advanceOffsetPage(previous);
  5960. if (offset.wrapped) {
  5961. offset.matchIdx = null;
  5962. if (this._pagesToSearch < 0) {
  5963. this._updateMatch(false);
  5964. return true;
  5965. }
  5966. }
  5967. return false;
  5968. }
  5969. }, {
  5970. key: "_nextPageMatch",
  5971. value: function _nextPageMatch() {
  5972. if (this._resumePageIdx !== null) {
  5973. console.error('There can only be one pending page.');
  5974. }
  5975. var matches = null;
  5976. do {
  5977. var pageIdx = this._offset.pageIdx;
  5978. matches = this._pageMatches[pageIdx];
  5979. if (!matches) {
  5980. this._resumePageIdx = pageIdx;
  5981. break;
  5982. }
  5983. } while (!this._matchesReady(matches));
  5984. }
  5985. }, {
  5986. key: "_advanceOffsetPage",
  5987. value: function _advanceOffsetPage(previous) {
  5988. var offset = this._offset;
  5989. var numPages = this._linkService.pagesCount;
  5990. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  5991. offset.matchIdx = null;
  5992. this._pagesToSearch--;
  5993. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  5994. offset.pageIdx = previous ? numPages - 1 : 0;
  5995. offset.wrapped = true;
  5996. }
  5997. }
  5998. }, {
  5999. key: "_updateMatch",
  6000. value: function _updateMatch() {
  6001. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6002. var state = FindState.NOT_FOUND;
  6003. var wrapped = this._offset.wrapped;
  6004. this._offset.wrapped = false;
  6005. if (found) {
  6006. var previousPage = this._selected.pageIdx;
  6007. this._selected.pageIdx = this._offset.pageIdx;
  6008. this._selected.matchIdx = this._offset.matchIdx;
  6009. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  6010. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  6011. this._updatePage(previousPage);
  6012. }
  6013. }
  6014. this._updateUIState(state, this._state.findPrevious);
  6015. if (this._selected.pageIdx !== -1) {
  6016. this._scrollMatches = true;
  6017. this._updatePage(this._selected.pageIdx);
  6018. }
  6019. }
  6020. }, {
  6021. key: "_onFindBarClose",
  6022. value: function _onFindBarClose(evt) {
  6023. var _this4 = this;
  6024. var pdfDocument = this._pdfDocument;
  6025. this._firstPageCapability.promise.then(function () {
  6026. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  6027. return;
  6028. }
  6029. if (_this4._findTimeout) {
  6030. clearTimeout(_this4._findTimeout);
  6031. _this4._findTimeout = null;
  6032. }
  6033. if (_this4._resumePageIdx) {
  6034. _this4._resumePageIdx = null;
  6035. _this4._dirtyMatch = true;
  6036. }
  6037. _this4._updateUIState(FindState.FOUND);
  6038. _this4._highlightMatches = false;
  6039. _this4._updateAllPages();
  6040. });
  6041. }
  6042. }, {
  6043. key: "_requestMatchesCount",
  6044. value: function _requestMatchesCount() {
  6045. var _this$_selected = this._selected,
  6046. pageIdx = _this$_selected.pageIdx,
  6047. matchIdx = _this$_selected.matchIdx;
  6048. var current = 0,
  6049. total = this._matchesCountTotal;
  6050. if (matchIdx !== -1) {
  6051. for (var i = 0; i < pageIdx; i++) {
  6052. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  6053. }
  6054. current += matchIdx + 1;
  6055. }
  6056. if (current < 1 || current > total) {
  6057. current = total = 0;
  6058. }
  6059. return {
  6060. current: current,
  6061. total: total
  6062. };
  6063. }
  6064. }, {
  6065. key: "_updateUIResultsCount",
  6066. value: function _updateUIResultsCount() {
  6067. this._eventBus.dispatch('updatefindmatchescount', {
  6068. source: this,
  6069. matchesCount: this._requestMatchesCount()
  6070. });
  6071. }
  6072. }, {
  6073. key: "_updateUIState",
  6074. value: function _updateUIState(state, previous) {
  6075. this._eventBus.dispatch('updatefindcontrolstate', {
  6076. source: this,
  6077. state: state,
  6078. previous: previous,
  6079. matchesCount: this._requestMatchesCount()
  6080. });
  6081. }
  6082. }, {
  6083. key: "highlightMatches",
  6084. get: function get() {
  6085. return this._highlightMatches;
  6086. }
  6087. }, {
  6088. key: "pageMatches",
  6089. get: function get() {
  6090. return this._pageMatches;
  6091. }
  6092. }, {
  6093. key: "pageMatchesLength",
  6094. get: function get() {
  6095. return this._pageMatchesLength;
  6096. }
  6097. }, {
  6098. key: "selected",
  6099. get: function get() {
  6100. return this._selected;
  6101. }
  6102. }, {
  6103. key: "state",
  6104. get: function get() {
  6105. return this._state;
  6106. }
  6107. }, {
  6108. key: "_query",
  6109. get: function get() {
  6110. if (this._state.query !== this._rawQuery) {
  6111. this._rawQuery = this._state.query;
  6112. this._normalizedQuery = normalize(this._state.query);
  6113. }
  6114. return this._normalizedQuery;
  6115. }
  6116. }]);
  6117. return PDFFindController;
  6118. }();
  6119. exports.PDFFindController = PDFFindController;
  6120. /***/ }),
  6121. /* 19 */
  6122. /***/ (function(module, exports, __webpack_require__) {
  6123. "use strict";
  6124. Object.defineProperty(exports, "__esModule", {
  6125. value: true
  6126. });
  6127. exports.getCharacterType = getCharacterType;
  6128. exports.CharacterType = void 0;
  6129. var CharacterType = {
  6130. SPACE: 0,
  6131. ALPHA_LETTER: 1,
  6132. PUNCT: 2,
  6133. HAN_LETTER: 3,
  6134. KATAKANA_LETTER: 4,
  6135. HIRAGANA_LETTER: 5,
  6136. HALFWIDTH_KATAKANA_LETTER: 6,
  6137. THAI_LETTER: 7
  6138. };
  6139. exports.CharacterType = CharacterType;
  6140. function isAlphabeticalScript(charCode) {
  6141. return charCode < 0x2E80;
  6142. }
  6143. function isAscii(charCode) {
  6144. return (charCode & 0xFF80) === 0;
  6145. }
  6146. function isAsciiAlpha(charCode) {
  6147. return charCode >= 0x61 && charCode <= 0x7A || charCode >= 0x41 && charCode <= 0x5A;
  6148. }
  6149. function isAsciiDigit(charCode) {
  6150. return charCode >= 0x30 && charCode <= 0x39;
  6151. }
  6152. function isAsciiSpace(charCode) {
  6153. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0D || charCode === 0x0A;
  6154. }
  6155. function isHan(charCode) {
  6156. return charCode >= 0x3400 && charCode <= 0x9FFF || charCode >= 0xF900 && charCode <= 0xFAFF;
  6157. }
  6158. function isKatakana(charCode) {
  6159. return charCode >= 0x30A0 && charCode <= 0x30FF;
  6160. }
  6161. function isHiragana(charCode) {
  6162. return charCode >= 0x3040 && charCode <= 0x309F;
  6163. }
  6164. function isHalfwidthKatakana(charCode) {
  6165. return charCode >= 0xFF60 && charCode <= 0xFF9F;
  6166. }
  6167. function isThai(charCode) {
  6168. return (charCode & 0xFF80) === 0x0E00;
  6169. }
  6170. function getCharacterType(charCode) {
  6171. if (isAlphabeticalScript(charCode)) {
  6172. if (isAscii(charCode)) {
  6173. if (isAsciiSpace(charCode)) {
  6174. return CharacterType.SPACE;
  6175. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5F) {
  6176. return CharacterType.ALPHA_LETTER;
  6177. }
  6178. return CharacterType.PUNCT;
  6179. } else if (isThai(charCode)) {
  6180. return CharacterType.THAI_LETTER;
  6181. } else if (charCode === 0xA0) {
  6182. return CharacterType.SPACE;
  6183. }
  6184. return CharacterType.ALPHA_LETTER;
  6185. }
  6186. if (isHan(charCode)) {
  6187. return CharacterType.HAN_LETTER;
  6188. } else if (isKatakana(charCode)) {
  6189. return CharacterType.KATAKANA_LETTER;
  6190. } else if (isHiragana(charCode)) {
  6191. return CharacterType.HIRAGANA_LETTER;
  6192. } else if (isHalfwidthKatakana(charCode)) {
  6193. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  6194. }
  6195. return CharacterType.ALPHA_LETTER;
  6196. }
  6197. /***/ }),
  6198. /* 20 */
  6199. /***/ (function(module, exports, __webpack_require__) {
  6200. "use strict";
  6201. Object.defineProperty(exports, "__esModule", {
  6202. value: true
  6203. });
  6204. exports.isDestHashesEqual = isDestHashesEqual;
  6205. exports.isDestArraysEqual = isDestArraysEqual;
  6206. exports.PDFHistory = void 0;
  6207. var _ui_utils = __webpack_require__(5);
  6208. function _typeof(obj) { 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); }
  6209. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  6210. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  6211. function _iterableToArrayLimit(arr, i) { 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; }
  6212. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  6213. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6214. 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); } }
  6215. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6216. var HASH_CHANGE_TIMEOUT = 1000;
  6217. var POSITION_UPDATED_THRESHOLD = 50;
  6218. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  6219. function getCurrentHash() {
  6220. return document.location.hash;
  6221. }
  6222. function parseCurrentHash(linkService) {
  6223. var hash = unescape(getCurrentHash()).substring(1);
  6224. var params = (0, _ui_utils.parseQueryString)(hash);
  6225. var page = params.page | 0;
  6226. if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
  6227. page = null;
  6228. }
  6229. return {
  6230. hash: hash,
  6231. page: page,
  6232. rotation: linkService.rotation
  6233. };
  6234. }
  6235. var PDFHistory =
  6236. /*#__PURE__*/
  6237. function () {
  6238. function PDFHistory(_ref) {
  6239. var _this = this;
  6240. var linkService = _ref.linkService,
  6241. eventBus = _ref.eventBus;
  6242. _classCallCheck(this, PDFHistory);
  6243. this.linkService = linkService;
  6244. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  6245. this.initialized = false;
  6246. this.initialBookmark = null;
  6247. this.initialRotation = null;
  6248. this._boundEvents = Object.create(null);
  6249. this._isViewerInPresentationMode = false;
  6250. this._isPagesLoaded = false;
  6251. this.eventBus.on('presentationmodechanged', function (evt) {
  6252. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  6253. });
  6254. this.eventBus.on('pagesloaded', function (evt) {
  6255. _this._isPagesLoaded = !!evt.pagesCount;
  6256. });
  6257. }
  6258. _createClass(PDFHistory, [{
  6259. key: "initialize",
  6260. value: function initialize(_ref2) {
  6261. var fingerprint = _ref2.fingerprint,
  6262. _ref2$resetHistory = _ref2.resetHistory,
  6263. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  6264. _ref2$updateUrl = _ref2.updateUrl,
  6265. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  6266. if (!fingerprint || typeof fingerprint !== 'string') {
  6267. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  6268. return;
  6269. }
  6270. var reInitialized = this.initialized && this.fingerprint !== fingerprint;
  6271. this.fingerprint = fingerprint;
  6272. this._updateUrl = updateUrl === true;
  6273. if (!this.initialized) {
  6274. this._bindEvents();
  6275. }
  6276. var state = window.history.state;
  6277. this.initialized = true;
  6278. this.initialBookmark = null;
  6279. this.initialRotation = null;
  6280. this._popStateInProgress = false;
  6281. this._blockHashChange = 0;
  6282. this._currentHash = getCurrentHash();
  6283. this._numPositionUpdates = 0;
  6284. this._uid = this._maxUid = 0;
  6285. this._destination = null;
  6286. this._position = null;
  6287. if (!this._isValidState(state, true) || resetHistory) {
  6288. var _parseCurrentHash = parseCurrentHash(this.linkService),
  6289. hash = _parseCurrentHash.hash,
  6290. page = _parseCurrentHash.page,
  6291. rotation = _parseCurrentHash.rotation;
  6292. if (!hash || reInitialized || resetHistory) {
  6293. this._pushOrReplaceState(null, true);
  6294. return;
  6295. }
  6296. this._pushOrReplaceState({
  6297. hash: hash,
  6298. page: page,
  6299. rotation: rotation
  6300. }, true);
  6301. return;
  6302. }
  6303. var destination = state.destination;
  6304. this._updateInternalState(destination, state.uid, true);
  6305. if (this._uid > this._maxUid) {
  6306. this._maxUid = this._uid;
  6307. }
  6308. if (destination.rotation !== undefined) {
  6309. this.initialRotation = destination.rotation;
  6310. }
  6311. if (destination.dest) {
  6312. this.initialBookmark = JSON.stringify(destination.dest);
  6313. this._destination.page = null;
  6314. } else if (destination.hash) {
  6315. this.initialBookmark = destination.hash;
  6316. } else if (destination.page) {
  6317. this.initialBookmark = "page=".concat(destination.page);
  6318. }
  6319. }
  6320. }, {
  6321. key: "push",
  6322. value: function push(_ref3) {
  6323. var _this2 = this;
  6324. var _ref3$namedDest = _ref3.namedDest,
  6325. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  6326. explicitDest = _ref3.explicitDest,
  6327. pageNumber = _ref3.pageNumber;
  6328. if (!this.initialized) {
  6329. return;
  6330. }
  6331. if (namedDest && typeof namedDest !== 'string') {
  6332. console.error('PDFHistory.push: ' + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  6333. return;
  6334. } else if (!Array.isArray(explicitDest)) {
  6335. console.error('PDFHistory.push: ' + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  6336. return;
  6337. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  6338. if (pageNumber !== null || this._destination) {
  6339. console.error('PDFHistory.push: ' + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  6340. return;
  6341. }
  6342. }
  6343. var hash = namedDest || JSON.stringify(explicitDest);
  6344. if (!hash) {
  6345. return;
  6346. }
  6347. var forceReplace = false;
  6348. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  6349. if (this._destination.page) {
  6350. return;
  6351. }
  6352. forceReplace = true;
  6353. }
  6354. if (this._popStateInProgress && !forceReplace) {
  6355. return;
  6356. }
  6357. this._pushOrReplaceState({
  6358. dest: explicitDest,
  6359. hash: hash,
  6360. page: pageNumber,
  6361. rotation: this.linkService.rotation
  6362. }, forceReplace);
  6363. if (!this._popStateInProgress) {
  6364. this._popStateInProgress = true;
  6365. Promise.resolve().then(function () {
  6366. _this2._popStateInProgress = false;
  6367. });
  6368. }
  6369. }
  6370. }, {
  6371. key: "pushCurrentPosition",
  6372. value: function pushCurrentPosition() {
  6373. if (!this.initialized || this._popStateInProgress) {
  6374. return;
  6375. }
  6376. this._tryPushCurrentPosition();
  6377. }
  6378. }, {
  6379. key: "back",
  6380. value: function back() {
  6381. if (!this.initialized || this._popStateInProgress) {
  6382. return;
  6383. }
  6384. var state = window.history.state;
  6385. if (this._isValidState(state) && state.uid > 0) {
  6386. window.history.back();
  6387. }
  6388. }
  6389. }, {
  6390. key: "forward",
  6391. value: function forward() {
  6392. if (!this.initialized || this._popStateInProgress) {
  6393. return;
  6394. }
  6395. var state = window.history.state;
  6396. if (this._isValidState(state) && state.uid < this._maxUid) {
  6397. window.history.forward();
  6398. }
  6399. }
  6400. }, {
  6401. key: "_pushOrReplaceState",
  6402. value: function _pushOrReplaceState(destination) {
  6403. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6404. var shouldReplace = forceReplace || !this._destination;
  6405. var newState = {
  6406. fingerprint: this.fingerprint,
  6407. uid: shouldReplace ? this._uid : this._uid + 1,
  6408. destination: destination
  6409. };
  6410. this._updateInternalState(destination, newState.uid);
  6411. var newUrl;
  6412. if (this._updateUrl && destination && destination.hash) {
  6413. var baseUrl = document.location.href.split('#')[0];
  6414. if (!baseUrl.startsWith('file://')) {
  6415. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  6416. }
  6417. }
  6418. if (shouldReplace) {
  6419. if (newUrl) {
  6420. window.history.replaceState(newState, '', newUrl);
  6421. } else {
  6422. window.history.replaceState(newState, '');
  6423. }
  6424. } else {
  6425. this._maxUid = this._uid;
  6426. if (newUrl) {
  6427. window.history.pushState(newState, '', newUrl);
  6428. } else {
  6429. window.history.pushState(newState, '');
  6430. }
  6431. }
  6432. }
  6433. }, {
  6434. key: "_tryPushCurrentPosition",
  6435. value: function _tryPushCurrentPosition() {
  6436. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6437. if (!this._position) {
  6438. return;
  6439. }
  6440. var position = this._position;
  6441. if (temporary) {
  6442. position = Object.assign(Object.create(null), this._position);
  6443. position.temporary = true;
  6444. }
  6445. if (!this._destination) {
  6446. this._pushOrReplaceState(position);
  6447. return;
  6448. }
  6449. if (this._destination.temporary) {
  6450. this._pushOrReplaceState(position, true);
  6451. return;
  6452. }
  6453. if (this._destination.hash === position.hash) {
  6454. return;
  6455. }
  6456. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  6457. return;
  6458. }
  6459. var forceReplace = false;
  6460. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  6461. if (this._destination.dest || !this._destination.first) {
  6462. return;
  6463. }
  6464. forceReplace = true;
  6465. }
  6466. this._pushOrReplaceState(position, forceReplace);
  6467. }
  6468. }, {
  6469. key: "_isValidState",
  6470. value: function _isValidState(state) {
  6471. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6472. if (!state) {
  6473. return false;
  6474. }
  6475. if (state.fingerprint !== this.fingerprint) {
  6476. if (checkReload) {
  6477. if (typeof state.fingerprint !== 'string' || state.fingerprint.length !== this.fingerprint.length) {
  6478. return false;
  6479. }
  6480. var _performance$getEntri = performance.getEntriesByType('navigation'),
  6481. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  6482. perfEntry = _performance$getEntri2[0];
  6483. if (!perfEntry || perfEntry.type !== 'reload') {
  6484. return false;
  6485. }
  6486. } else {
  6487. return false;
  6488. }
  6489. }
  6490. if (!Number.isInteger(state.uid) || state.uid < 0) {
  6491. return false;
  6492. }
  6493. if (state.destination === null || _typeof(state.destination) !== 'object') {
  6494. return false;
  6495. }
  6496. return true;
  6497. }
  6498. }, {
  6499. key: "_updateInternalState",
  6500. value: function _updateInternalState(destination, uid) {
  6501. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6502. if (this._updateViewareaTimeout) {
  6503. clearTimeout(this._updateViewareaTimeout);
  6504. this._updateViewareaTimeout = null;
  6505. }
  6506. if (removeTemporary && destination && destination.temporary) {
  6507. delete destination.temporary;
  6508. }
  6509. this._destination = destination;
  6510. this._uid = uid;
  6511. this._numPositionUpdates = 0;
  6512. }
  6513. }, {
  6514. key: "_updateViewarea",
  6515. value: function _updateViewarea(_ref4) {
  6516. var _this3 = this;
  6517. var location = _ref4.location;
  6518. if (this._updateViewareaTimeout) {
  6519. clearTimeout(this._updateViewareaTimeout);
  6520. this._updateViewareaTimeout = null;
  6521. }
  6522. this._position = {
  6523. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  6524. page: this.linkService.page,
  6525. first: location.pageNumber,
  6526. rotation: location.rotation
  6527. };
  6528. if (this._popStateInProgress) {
  6529. return;
  6530. }
  6531. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  6532. this._numPositionUpdates++;
  6533. }
  6534. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  6535. this._updateViewareaTimeout = setTimeout(function () {
  6536. if (!_this3._popStateInProgress) {
  6537. _this3._tryPushCurrentPosition(true);
  6538. }
  6539. _this3._updateViewareaTimeout = null;
  6540. }, UPDATE_VIEWAREA_TIMEOUT);
  6541. }
  6542. }
  6543. }, {
  6544. key: "_popState",
  6545. value: function _popState(_ref5) {
  6546. var _this4 = this;
  6547. var state = _ref5.state;
  6548. var newHash = getCurrentHash(),
  6549. hashChanged = this._currentHash !== newHash;
  6550. this._currentHash = newHash;
  6551. if (!state || false) {
  6552. this._uid++;
  6553. var _parseCurrentHash2 = parseCurrentHash(this.linkService),
  6554. hash = _parseCurrentHash2.hash,
  6555. page = _parseCurrentHash2.page,
  6556. rotation = _parseCurrentHash2.rotation;
  6557. this._pushOrReplaceState({
  6558. hash: hash,
  6559. page: page,
  6560. rotation: rotation
  6561. }, true);
  6562. return;
  6563. }
  6564. if (!this._isValidState(state)) {
  6565. return;
  6566. }
  6567. this._popStateInProgress = true;
  6568. if (hashChanged) {
  6569. this._blockHashChange++;
  6570. (0, _ui_utils.waitOnEventOrTimeout)({
  6571. target: window,
  6572. name: 'hashchange',
  6573. delay: HASH_CHANGE_TIMEOUT
  6574. }).then(function () {
  6575. _this4._blockHashChange--;
  6576. });
  6577. }
  6578. var destination = state.destination;
  6579. this._updateInternalState(destination, state.uid, true);
  6580. if (this._uid > this._maxUid) {
  6581. this._maxUid = this._uid;
  6582. }
  6583. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  6584. this.linkService.rotation = destination.rotation;
  6585. }
  6586. if (destination.dest) {
  6587. this.linkService.navigateTo(destination.dest);
  6588. } else if (destination.hash) {
  6589. this.linkService.setHash(destination.hash);
  6590. } else if (destination.page) {
  6591. this.linkService.page = destination.page;
  6592. }
  6593. Promise.resolve().then(function () {
  6594. _this4._popStateInProgress = false;
  6595. });
  6596. }
  6597. }, {
  6598. key: "_bindEvents",
  6599. value: function _bindEvents() {
  6600. var _this5 = this;
  6601. var _boundEvents = this._boundEvents,
  6602. eventBus = this.eventBus;
  6603. _boundEvents.updateViewarea = this._updateViewarea.bind(this);
  6604. _boundEvents.popState = this._popState.bind(this);
  6605. _boundEvents.pageHide = function (evt) {
  6606. if (!_this5._destination || _this5._destination.temporary) {
  6607. _this5._tryPushCurrentPosition();
  6608. }
  6609. };
  6610. eventBus.on('updateviewarea', _boundEvents.updateViewarea);
  6611. window.addEventListener('popstate', _boundEvents.popState);
  6612. window.addEventListener('pagehide', _boundEvents.pageHide);
  6613. }
  6614. }, {
  6615. key: "popStateInProgress",
  6616. get: function get() {
  6617. return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);
  6618. }
  6619. }]);
  6620. return PDFHistory;
  6621. }();
  6622. exports.PDFHistory = PDFHistory;
  6623. function isDestHashesEqual(destHash, pushHash) {
  6624. if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
  6625. return false;
  6626. }
  6627. if (destHash === pushHash) {
  6628. return true;
  6629. }
  6630. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  6631. nameddest = _parseQueryString.nameddest;
  6632. if (nameddest === pushHash) {
  6633. return true;
  6634. }
  6635. return false;
  6636. }
  6637. function isDestArraysEqual(firstDest, secondDest) {
  6638. function isEntryEqual(first, second) {
  6639. if (_typeof(first) !== _typeof(second)) {
  6640. return false;
  6641. }
  6642. if (Array.isArray(first) || Array.isArray(second)) {
  6643. return false;
  6644. }
  6645. if (first !== null && _typeof(first) === 'object' && second !== null) {
  6646. if (Object.keys(first).length !== Object.keys(second).length) {
  6647. return false;
  6648. }
  6649. for (var key in first) {
  6650. if (!isEntryEqual(first[key], second[key])) {
  6651. return false;
  6652. }
  6653. }
  6654. return true;
  6655. }
  6656. return first === second || Number.isNaN(first) && Number.isNaN(second);
  6657. }
  6658. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  6659. return false;
  6660. }
  6661. if (firstDest.length !== secondDest.length) {
  6662. return false;
  6663. }
  6664. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  6665. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  6666. return false;
  6667. }
  6668. }
  6669. return true;
  6670. }
  6671. /***/ }),
  6672. /* 21 */
  6673. /***/ (function(module, exports, __webpack_require__) {
  6674. "use strict";
  6675. Object.defineProperty(exports, "__esModule", {
  6676. value: true
  6677. });
  6678. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  6679. var _ui_utils = __webpack_require__(5);
  6680. function _typeof(obj) { 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); }
  6681. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6682. 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); } }
  6683. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6684. var PDFLinkService =
  6685. /*#__PURE__*/
  6686. function () {
  6687. function PDFLinkService() {
  6688. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  6689. eventBus = _ref.eventBus,
  6690. _ref$externalLinkTarg = _ref.externalLinkTarget,
  6691. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  6692. _ref$externalLinkRel = _ref.externalLinkRel,
  6693. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel;
  6694. _classCallCheck(this, PDFLinkService);
  6695. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  6696. this.externalLinkTarget = externalLinkTarget;
  6697. this.externalLinkRel = externalLinkRel;
  6698. this.baseUrl = null;
  6699. this.pdfDocument = null;
  6700. this.pdfViewer = null;
  6701. this.pdfHistory = null;
  6702. this._pagesRefCache = null;
  6703. }
  6704. _createClass(PDFLinkService, [{
  6705. key: "setDocument",
  6706. value: function setDocument(pdfDocument) {
  6707. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6708. this.baseUrl = baseUrl;
  6709. this.pdfDocument = pdfDocument;
  6710. this._pagesRefCache = Object.create(null);
  6711. }
  6712. }, {
  6713. key: "setViewer",
  6714. value: function setViewer(pdfViewer) {
  6715. this.pdfViewer = pdfViewer;
  6716. }
  6717. }, {
  6718. key: "setHistory",
  6719. value: function setHistory(pdfHistory) {
  6720. this.pdfHistory = pdfHistory;
  6721. }
  6722. }, {
  6723. key: "navigateTo",
  6724. value: function navigateTo(dest) {
  6725. var _this = this;
  6726. var goToDestination = function goToDestination(_ref2) {
  6727. var namedDest = _ref2.namedDest,
  6728. explicitDest = _ref2.explicitDest;
  6729. var destRef = explicitDest[0],
  6730. pageNumber;
  6731. if (destRef instanceof Object) {
  6732. pageNumber = _this._cachedPageNumber(destRef);
  6733. if (pageNumber === null) {
  6734. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  6735. _this.cachePageRef(pageIndex + 1, destRef);
  6736. goToDestination({
  6737. namedDest: namedDest,
  6738. explicitDest: explicitDest
  6739. });
  6740. })["catch"](function () {
  6741. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(dest, "\"."));
  6742. });
  6743. return;
  6744. }
  6745. } else if (Number.isInteger(destRef)) {
  6746. pageNumber = destRef + 1;
  6747. } else {
  6748. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(dest, "\"."));
  6749. return;
  6750. }
  6751. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  6752. console.error("PDFLinkService.navigateTo: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(dest, "\"."));
  6753. return;
  6754. }
  6755. if (_this.pdfHistory) {
  6756. _this.pdfHistory.pushCurrentPosition();
  6757. _this.pdfHistory.push({
  6758. namedDest: namedDest,
  6759. explicitDest: explicitDest,
  6760. pageNumber: pageNumber
  6761. });
  6762. }
  6763. _this.pdfViewer.scrollPageIntoView({
  6764. pageNumber: pageNumber,
  6765. destArray: explicitDest
  6766. });
  6767. };
  6768. new Promise(function (resolve, reject) {
  6769. if (typeof dest === 'string') {
  6770. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  6771. resolve({
  6772. namedDest: dest,
  6773. explicitDest: destArray
  6774. });
  6775. });
  6776. return;
  6777. }
  6778. resolve({
  6779. namedDest: '',
  6780. explicitDest: dest
  6781. });
  6782. }).then(function (data) {
  6783. if (!Array.isArray(data.explicitDest)) {
  6784. console.error("PDFLinkService.navigateTo: \"".concat(data.explicitDest, "\" is") + " not a valid destination array, for dest=\"".concat(dest, "\"."));
  6785. return;
  6786. }
  6787. goToDestination(data);
  6788. });
  6789. }
  6790. }, {
  6791. key: "getDestinationHash",
  6792. value: function getDestinationHash(dest) {
  6793. if (typeof dest === 'string') {
  6794. return this.getAnchorUrl('#' + escape(dest));
  6795. }
  6796. if (Array.isArray(dest)) {
  6797. var str = JSON.stringify(dest);
  6798. return this.getAnchorUrl('#' + escape(str));
  6799. }
  6800. return this.getAnchorUrl('');
  6801. }
  6802. }, {
  6803. key: "getAnchorUrl",
  6804. value: function getAnchorUrl(anchor) {
  6805. return (this.baseUrl || '') + anchor;
  6806. }
  6807. }, {
  6808. key: "setHash",
  6809. value: function setHash(hash) {
  6810. var pageNumber, dest;
  6811. if (hash.includes('=')) {
  6812. var params = (0, _ui_utils.parseQueryString)(hash);
  6813. if ('search' in params) {
  6814. this.eventBus.dispatch('findfromurlhash', {
  6815. source: this,
  6816. query: params['search'].replace(/"/g, ''),
  6817. phraseSearch: params['phrase'] === 'true'
  6818. });
  6819. }
  6820. if ('nameddest' in params) {
  6821. this.navigateTo(params.nameddest);
  6822. return;
  6823. }
  6824. if ('page' in params) {
  6825. pageNumber = params.page | 0 || 1;
  6826. }
  6827. if ('zoom' in params) {
  6828. var zoomArgs = params.zoom.split(',');
  6829. var zoomArg = zoomArgs[0];
  6830. var zoomArgNumber = parseFloat(zoomArg);
  6831. if (!zoomArg.includes('Fit')) {
  6832. dest = [null, {
  6833. name: 'XYZ'
  6834. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  6835. } else {
  6836. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  6837. dest = [null, {
  6838. name: zoomArg
  6839. }];
  6840. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
  6841. dest = [null, {
  6842. name: zoomArg
  6843. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  6844. } else if (zoomArg === 'FitR') {
  6845. if (zoomArgs.length !== 5) {
  6846. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  6847. } else {
  6848. dest = [null, {
  6849. name: zoomArg
  6850. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  6851. }
  6852. } else {
  6853. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + 'a valid zoom value.');
  6854. }
  6855. }
  6856. }
  6857. if (dest) {
  6858. this.pdfViewer.scrollPageIntoView({
  6859. pageNumber: pageNumber || this.page,
  6860. destArray: dest,
  6861. allowNegativeOffset: true
  6862. });
  6863. } else if (pageNumber) {
  6864. this.page = pageNumber;
  6865. }
  6866. if ('pagemode' in params) {
  6867. this.eventBus.dispatch('pagemode', {
  6868. source: this,
  6869. mode: params.pagemode
  6870. });
  6871. }
  6872. } else {
  6873. dest = unescape(hash);
  6874. try {
  6875. dest = JSON.parse(dest);
  6876. if (!Array.isArray(dest)) {
  6877. dest = dest.toString();
  6878. }
  6879. } catch (ex) {}
  6880. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  6881. this.navigateTo(dest);
  6882. return;
  6883. }
  6884. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + 'a valid destination.');
  6885. }
  6886. }
  6887. }, {
  6888. key: "executeNamedAction",
  6889. value: function executeNamedAction(action) {
  6890. switch (action) {
  6891. case 'GoBack':
  6892. if (this.pdfHistory) {
  6893. this.pdfHistory.back();
  6894. }
  6895. break;
  6896. case 'GoForward':
  6897. if (this.pdfHistory) {
  6898. this.pdfHistory.forward();
  6899. }
  6900. break;
  6901. case 'NextPage':
  6902. if (this.page < this.pagesCount) {
  6903. this.page++;
  6904. }
  6905. break;
  6906. case 'PrevPage':
  6907. if (this.page > 1) {
  6908. this.page--;
  6909. }
  6910. break;
  6911. case 'LastPage':
  6912. this.page = this.pagesCount;
  6913. break;
  6914. case 'FirstPage':
  6915. this.page = 1;
  6916. break;
  6917. default:
  6918. break;
  6919. }
  6920. this.eventBus.dispatch('namedaction', {
  6921. source: this,
  6922. action: action
  6923. });
  6924. }
  6925. }, {
  6926. key: "cachePageRef",
  6927. value: function cachePageRef(pageNum, pageRef) {
  6928. if (!pageRef) {
  6929. return;
  6930. }
  6931. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  6932. this._pagesRefCache[refStr] = pageNum;
  6933. }
  6934. }, {
  6935. key: "_cachedPageNumber",
  6936. value: function _cachedPageNumber(pageRef) {
  6937. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  6938. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  6939. }
  6940. }, {
  6941. key: "isPageVisible",
  6942. value: function isPageVisible(pageNumber) {
  6943. return this.pdfViewer.isPageVisible(pageNumber);
  6944. }
  6945. }, {
  6946. key: "pagesCount",
  6947. get: function get() {
  6948. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  6949. }
  6950. }, {
  6951. key: "page",
  6952. get: function get() {
  6953. return this.pdfViewer.currentPageNumber;
  6954. },
  6955. set: function set(value) {
  6956. this.pdfViewer.currentPageNumber = value;
  6957. }
  6958. }, {
  6959. key: "rotation",
  6960. get: function get() {
  6961. return this.pdfViewer.pagesRotation;
  6962. },
  6963. set: function set(value) {
  6964. this.pdfViewer.pagesRotation = value;
  6965. }
  6966. }]);
  6967. return PDFLinkService;
  6968. }();
  6969. exports.PDFLinkService = PDFLinkService;
  6970. function isValidExplicitDestination(dest) {
  6971. if (!Array.isArray(dest)) {
  6972. return false;
  6973. }
  6974. var destLength = dest.length,
  6975. allowNull = true;
  6976. if (destLength < 2) {
  6977. return false;
  6978. }
  6979. var page = dest[0];
  6980. if (!(_typeof(page) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  6981. return false;
  6982. }
  6983. var zoom = dest[1];
  6984. if (!(_typeof(zoom) === 'object' && typeof zoom.name === 'string')) {
  6985. return false;
  6986. }
  6987. switch (zoom.name) {
  6988. case 'XYZ':
  6989. if (destLength !== 5) {
  6990. return false;
  6991. }
  6992. break;
  6993. case 'Fit':
  6994. case 'FitB':
  6995. return destLength === 2;
  6996. case 'FitH':
  6997. case 'FitBH':
  6998. case 'FitV':
  6999. case 'FitBV':
  7000. if (destLength !== 3) {
  7001. return false;
  7002. }
  7003. break;
  7004. case 'FitR':
  7005. if (destLength !== 6) {
  7006. return false;
  7007. }
  7008. allowNull = false;
  7009. break;
  7010. default:
  7011. return false;
  7012. }
  7013. for (var i = 2; i < destLength; i++) {
  7014. var param = dest[i];
  7015. if (!(typeof param === 'number' || allowNull && param === null)) {
  7016. return false;
  7017. }
  7018. }
  7019. return true;
  7020. }
  7021. var SimpleLinkService =
  7022. /*#__PURE__*/
  7023. function () {
  7024. function SimpleLinkService() {
  7025. _classCallCheck(this, SimpleLinkService);
  7026. this.externalLinkTarget = null;
  7027. this.externalLinkRel = null;
  7028. }
  7029. _createClass(SimpleLinkService, [{
  7030. key: "navigateTo",
  7031. value: function navigateTo(dest) {}
  7032. }, {
  7033. key: "getDestinationHash",
  7034. value: function getDestinationHash(dest) {
  7035. return '#';
  7036. }
  7037. }, {
  7038. key: "getAnchorUrl",
  7039. value: function getAnchorUrl(hash) {
  7040. return '#';
  7041. }
  7042. }, {
  7043. key: "setHash",
  7044. value: function setHash(hash) {}
  7045. }, {
  7046. key: "executeNamedAction",
  7047. value: function executeNamedAction(action) {}
  7048. }, {
  7049. key: "cachePageRef",
  7050. value: function cachePageRef(pageNum, pageRef) {}
  7051. }, {
  7052. key: "isPageVisible",
  7053. value: function isPageVisible(pageNumber) {
  7054. return true;
  7055. }
  7056. }, {
  7057. key: "pagesCount",
  7058. get: function get() {
  7059. return 0;
  7060. }
  7061. }, {
  7062. key: "page",
  7063. get: function get() {
  7064. return 0;
  7065. },
  7066. set: function set(value) {}
  7067. }, {
  7068. key: "rotation",
  7069. get: function get() {
  7070. return 0;
  7071. },
  7072. set: function set(value) {}
  7073. }]);
  7074. return SimpleLinkService;
  7075. }();
  7076. exports.SimpleLinkService = SimpleLinkService;
  7077. /***/ }),
  7078. /* 22 */
  7079. /***/ (function(module, exports, __webpack_require__) {
  7080. "use strict";
  7081. Object.defineProperty(exports, "__esModule", {
  7082. value: true
  7083. });
  7084. exports.PDFOutlineViewer = void 0;
  7085. var _pdfjsLib = __webpack_require__(7);
  7086. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7087. 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); } }
  7088. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7089. var DEFAULT_TITLE = "\u2013";
  7090. var PDFOutlineViewer =
  7091. /*#__PURE__*/
  7092. function () {
  7093. function PDFOutlineViewer(_ref) {
  7094. var container = _ref.container,
  7095. linkService = _ref.linkService,
  7096. eventBus = _ref.eventBus;
  7097. _classCallCheck(this, PDFOutlineViewer);
  7098. this.container = container;
  7099. this.linkService = linkService;
  7100. this.eventBus = eventBus;
  7101. this.reset();
  7102. eventBus.on('toggleoutlinetree', this.toggleOutlineTree.bind(this));
  7103. }
  7104. _createClass(PDFOutlineViewer, [{
  7105. key: "reset",
  7106. value: function reset() {
  7107. this.outline = null;
  7108. this.lastToggleIsShow = true;
  7109. this.container.textContent = '';
  7110. this.container.classList.remove('outlineWithDeepNesting');
  7111. }
  7112. }, {
  7113. key: "_dispatchEvent",
  7114. value: function _dispatchEvent(outlineCount) {
  7115. this.eventBus.dispatch('outlineloaded', {
  7116. source: this,
  7117. outlineCount: outlineCount
  7118. });
  7119. }
  7120. }, {
  7121. key: "_bindLink",
  7122. value: function _bindLink(element, _ref2) {
  7123. var url = _ref2.url,
  7124. newWindow = _ref2.newWindow,
  7125. dest = _ref2.dest;
  7126. var linkService = this.linkService;
  7127. if (url) {
  7128. (0, _pdfjsLib.addLinkAttributes)(element, {
  7129. url: url,
  7130. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
  7131. rel: linkService.externalLinkRel
  7132. });
  7133. return;
  7134. }
  7135. element.href = linkService.getDestinationHash(dest);
  7136. element.onclick = function () {
  7137. if (dest) {
  7138. linkService.navigateTo(dest);
  7139. }
  7140. return false;
  7141. };
  7142. }
  7143. }, {
  7144. key: "_setStyles",
  7145. value: function _setStyles(element, _ref3) {
  7146. var bold = _ref3.bold,
  7147. italic = _ref3.italic;
  7148. var styleStr = '';
  7149. if (bold) {
  7150. styleStr += 'font-weight: bold;';
  7151. }
  7152. if (italic) {
  7153. styleStr += 'font-style: italic;';
  7154. }
  7155. if (styleStr) {
  7156. element.setAttribute('style', styleStr);
  7157. }
  7158. }
  7159. }, {
  7160. key: "_addToggleButton",
  7161. value: function _addToggleButton(div, _ref4) {
  7162. var _this = this;
  7163. var count = _ref4.count,
  7164. items = _ref4.items;
  7165. var toggler = document.createElement('div');
  7166. toggler.className = 'outlineItemToggler';
  7167. if (count < 0 && Math.abs(count) === items.length) {
  7168. toggler.classList.add('outlineItemsHidden');
  7169. }
  7170. toggler.onclick = function (evt) {
  7171. evt.stopPropagation();
  7172. toggler.classList.toggle('outlineItemsHidden');
  7173. if (evt.shiftKey) {
  7174. var shouldShowAll = !toggler.classList.contains('outlineItemsHidden');
  7175. _this._toggleOutlineItem(div, shouldShowAll);
  7176. }
  7177. };
  7178. div.insertBefore(toggler, div.firstChild);
  7179. }
  7180. }, {
  7181. key: "_toggleOutlineItem",
  7182. value: function _toggleOutlineItem(root) {
  7183. var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7184. this.lastToggleIsShow = show;
  7185. var _iteratorNormalCompletion = true;
  7186. var _didIteratorError = false;
  7187. var _iteratorError = undefined;
  7188. try {
  7189. for (var _iterator = root.querySelectorAll('.outlineItemToggler')[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7190. var toggler = _step.value;
  7191. toggler.classList.toggle('outlineItemsHidden', !show);
  7192. }
  7193. } catch (err) {
  7194. _didIteratorError = true;
  7195. _iteratorError = err;
  7196. } finally {
  7197. try {
  7198. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  7199. _iterator["return"]();
  7200. }
  7201. } finally {
  7202. if (_didIteratorError) {
  7203. throw _iteratorError;
  7204. }
  7205. }
  7206. }
  7207. }
  7208. }, {
  7209. key: "toggleOutlineTree",
  7210. value: function toggleOutlineTree() {
  7211. if (!this.outline) {
  7212. return;
  7213. }
  7214. this._toggleOutlineItem(this.container, !this.lastToggleIsShow);
  7215. }
  7216. }, {
  7217. key: "render",
  7218. value: function render(_ref5) {
  7219. var outline = _ref5.outline;
  7220. var outlineCount = 0;
  7221. if (this.outline) {
  7222. this.reset();
  7223. }
  7224. this.outline = outline || null;
  7225. if (!outline) {
  7226. this._dispatchEvent(outlineCount);
  7227. return;
  7228. }
  7229. var fragment = document.createDocumentFragment();
  7230. var queue = [{
  7231. parent: fragment,
  7232. items: this.outline
  7233. }];
  7234. var hasAnyNesting = false;
  7235. while (queue.length > 0) {
  7236. var levelData = queue.shift();
  7237. var _iteratorNormalCompletion2 = true;
  7238. var _didIteratorError2 = false;
  7239. var _iteratorError2 = undefined;
  7240. try {
  7241. for (var _iterator2 = levelData.items[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  7242. var item = _step2.value;
  7243. var div = document.createElement('div');
  7244. div.className = 'outlineItem';
  7245. var element = document.createElement('a');
  7246. this._bindLink(element, item);
  7247. this._setStyles(element, item);
  7248. element.textContent = (0, _pdfjsLib.removeNullCharacters)(item.title) || DEFAULT_TITLE;
  7249. div.appendChild(element);
  7250. if (item.items.length > 0) {
  7251. hasAnyNesting = true;
  7252. this._addToggleButton(div, item);
  7253. var itemsDiv = document.createElement('div');
  7254. itemsDiv.className = 'outlineItems';
  7255. div.appendChild(itemsDiv);
  7256. queue.push({
  7257. parent: itemsDiv,
  7258. items: item.items
  7259. });
  7260. }
  7261. levelData.parent.appendChild(div);
  7262. outlineCount++;
  7263. }
  7264. } catch (err) {
  7265. _didIteratorError2 = true;
  7266. _iteratorError2 = err;
  7267. } finally {
  7268. try {
  7269. if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
  7270. _iterator2["return"]();
  7271. }
  7272. } finally {
  7273. if (_didIteratorError2) {
  7274. throw _iteratorError2;
  7275. }
  7276. }
  7277. }
  7278. }
  7279. if (hasAnyNesting) {
  7280. this.container.classList.add('outlineWithDeepNesting');
  7281. this.lastToggleIsShow = fragment.querySelectorAll('.outlineItemsHidden').length === 0;
  7282. }
  7283. this.container.appendChild(fragment);
  7284. this._dispatchEvent(outlineCount);
  7285. }
  7286. }]);
  7287. return PDFOutlineViewer;
  7288. }();
  7289. exports.PDFOutlineViewer = PDFOutlineViewer;
  7290. /***/ }),
  7291. /* 23 */
  7292. /***/ (function(module, exports, __webpack_require__) {
  7293. "use strict";
  7294. Object.defineProperty(exports, "__esModule", {
  7295. value: true
  7296. });
  7297. exports.PDFPresentationMode = void 0;
  7298. var _ui_utils = __webpack_require__(5);
  7299. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7300. 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); } }
  7301. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7302. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  7303. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  7304. var ACTIVE_SELECTOR = 'pdfPresentationMode';
  7305. var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
  7306. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  7307. var PAGE_SWITCH_THRESHOLD = 0.1;
  7308. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  7309. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  7310. var PDFPresentationMode =
  7311. /*#__PURE__*/
  7312. function () {
  7313. function PDFPresentationMode(_ref) {
  7314. var _this = this;
  7315. var container = _ref.container,
  7316. _ref$viewer = _ref.viewer,
  7317. viewer = _ref$viewer === void 0 ? null : _ref$viewer,
  7318. pdfViewer = _ref.pdfViewer,
  7319. eventBus = _ref.eventBus,
  7320. _ref$contextMenuItems = _ref.contextMenuItems,
  7321. contextMenuItems = _ref$contextMenuItems === void 0 ? null : _ref$contextMenuItems;
  7322. _classCallCheck(this, PDFPresentationMode);
  7323. this.container = container;
  7324. this.viewer = viewer || container.firstElementChild;
  7325. this.pdfViewer = pdfViewer;
  7326. this.eventBus = eventBus;
  7327. this.active = false;
  7328. this.args = null;
  7329. this.contextMenuOpen = false;
  7330. this.mouseScrollTimeStamp = 0;
  7331. this.mouseScrollDelta = 0;
  7332. this.touchSwipeState = null;
  7333. if (contextMenuItems) {
  7334. contextMenuItems.contextFirstPage.addEventListener('click', function () {
  7335. _this.contextMenuOpen = false;
  7336. _this.eventBus.dispatch('firstpage', {
  7337. source: _this
  7338. });
  7339. });
  7340. contextMenuItems.contextLastPage.addEventListener('click', function () {
  7341. _this.contextMenuOpen = false;
  7342. _this.eventBus.dispatch('lastpage', {
  7343. source: _this
  7344. });
  7345. });
  7346. contextMenuItems.contextPageRotateCw.addEventListener('click', function () {
  7347. _this.contextMenuOpen = false;
  7348. _this.eventBus.dispatch('rotatecw', {
  7349. source: _this
  7350. });
  7351. });
  7352. contextMenuItems.contextPageRotateCcw.addEventListener('click', function () {
  7353. _this.contextMenuOpen = false;
  7354. _this.eventBus.dispatch('rotateccw', {
  7355. source: _this
  7356. });
  7357. });
  7358. }
  7359. }
  7360. _createClass(PDFPresentationMode, [{
  7361. key: "request",
  7362. value: function request() {
  7363. if (this.switchInProgress || this.active || !this.viewer.hasChildNodes()) {
  7364. return false;
  7365. }
  7366. this._addFullscreenChangeListeners();
  7367. this._setSwitchInProgress();
  7368. this._notifyStateChange();
  7369. if (this.container.requestFullscreen) {
  7370. this.container.requestFullscreen();
  7371. } else if (this.container.mozRequestFullScreen) {
  7372. this.container.mozRequestFullScreen();
  7373. } else if (this.container.webkitRequestFullscreen) {
  7374. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  7375. } else if (this.container.msRequestFullscreen) {
  7376. this.container.msRequestFullscreen();
  7377. } else {
  7378. return false;
  7379. }
  7380. this.args = {
  7381. page: this.pdfViewer.currentPageNumber,
  7382. previousScale: this.pdfViewer.currentScaleValue
  7383. };
  7384. return true;
  7385. }
  7386. }, {
  7387. key: "_mouseWheel",
  7388. value: function _mouseWheel(evt) {
  7389. if (!this.active) {
  7390. return;
  7391. }
  7392. evt.preventDefault();
  7393. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  7394. var currentTime = new Date().getTime();
  7395. var storedTime = this.mouseScrollTimeStamp;
  7396. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  7397. return;
  7398. }
  7399. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  7400. this._resetMouseScrollState();
  7401. }
  7402. this.mouseScrollDelta += delta;
  7403. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  7404. var totalDelta = this.mouseScrollDelta;
  7405. this._resetMouseScrollState();
  7406. var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
  7407. if (success) {
  7408. this.mouseScrollTimeStamp = currentTime;
  7409. }
  7410. }
  7411. }
  7412. }, {
  7413. key: "_goToPreviousPage",
  7414. value: function _goToPreviousPage() {
  7415. var page = this.pdfViewer.currentPageNumber;
  7416. if (page <= 1) {
  7417. return false;
  7418. }
  7419. this.pdfViewer.currentPageNumber = page - 1;
  7420. return true;
  7421. }
  7422. }, {
  7423. key: "_goToNextPage",
  7424. value: function _goToNextPage() {
  7425. var page = this.pdfViewer.currentPageNumber;
  7426. if (page >= this.pdfViewer.pagesCount) {
  7427. return false;
  7428. }
  7429. this.pdfViewer.currentPageNumber = page + 1;
  7430. return true;
  7431. }
  7432. }, {
  7433. key: "_notifyStateChange",
  7434. value: function _notifyStateChange() {
  7435. this.eventBus.dispatch('presentationmodechanged', {
  7436. source: this,
  7437. active: this.active,
  7438. switchInProgress: !!this.switchInProgress
  7439. });
  7440. }
  7441. }, {
  7442. key: "_setSwitchInProgress",
  7443. value: function _setSwitchInProgress() {
  7444. var _this2 = this;
  7445. if (this.switchInProgress) {
  7446. clearTimeout(this.switchInProgress);
  7447. }
  7448. this.switchInProgress = setTimeout(function () {
  7449. _this2._removeFullscreenChangeListeners();
  7450. delete _this2.switchInProgress;
  7451. _this2._notifyStateChange();
  7452. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  7453. }
  7454. }, {
  7455. key: "_resetSwitchInProgress",
  7456. value: function _resetSwitchInProgress() {
  7457. if (this.switchInProgress) {
  7458. clearTimeout(this.switchInProgress);
  7459. delete this.switchInProgress;
  7460. }
  7461. }
  7462. }, {
  7463. key: "_enter",
  7464. value: function _enter() {
  7465. var _this3 = this;
  7466. this.active = true;
  7467. this._resetSwitchInProgress();
  7468. this._notifyStateChange();
  7469. this.container.classList.add(ACTIVE_SELECTOR);
  7470. setTimeout(function () {
  7471. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  7472. _this3.pdfViewer.currentScaleValue = 'page-fit';
  7473. }, 0);
  7474. this._addWindowListeners();
  7475. this._showControls();
  7476. this.contextMenuOpen = false;
  7477. this.container.setAttribute('contextmenu', 'viewerContextMenu');
  7478. window.getSelection().removeAllRanges();
  7479. }
  7480. }, {
  7481. key: "_exit",
  7482. value: function _exit() {
  7483. var _this4 = this;
  7484. var page = this.pdfViewer.currentPageNumber;
  7485. this.container.classList.remove(ACTIVE_SELECTOR);
  7486. setTimeout(function () {
  7487. _this4.active = false;
  7488. _this4._removeFullscreenChangeListeners();
  7489. _this4._notifyStateChange();
  7490. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  7491. _this4.pdfViewer.currentPageNumber = page;
  7492. _this4.args = null;
  7493. }, 0);
  7494. this._removeWindowListeners();
  7495. this._hideControls();
  7496. this._resetMouseScrollState();
  7497. this.container.removeAttribute('contextmenu');
  7498. this.contextMenuOpen = false;
  7499. }
  7500. }, {
  7501. key: "_mouseDown",
  7502. value: function _mouseDown(evt) {
  7503. if (this.contextMenuOpen) {
  7504. this.contextMenuOpen = false;
  7505. evt.preventDefault();
  7506. return;
  7507. }
  7508. if (evt.button === 0) {
  7509. var isInternalLink = evt.target.href && evt.target.classList.contains('internalLink');
  7510. if (!isInternalLink) {
  7511. evt.preventDefault();
  7512. if (evt.shiftKey) {
  7513. this._goToPreviousPage();
  7514. } else {
  7515. this._goToNextPage();
  7516. }
  7517. }
  7518. }
  7519. }
  7520. }, {
  7521. key: "_contextMenu",
  7522. value: function _contextMenu() {
  7523. this.contextMenuOpen = true;
  7524. }
  7525. }, {
  7526. key: "_showControls",
  7527. value: function _showControls() {
  7528. var _this5 = this;
  7529. if (this.controlsTimeout) {
  7530. clearTimeout(this.controlsTimeout);
  7531. } else {
  7532. this.container.classList.add(CONTROLS_SELECTOR);
  7533. }
  7534. this.controlsTimeout = setTimeout(function () {
  7535. _this5.container.classList.remove(CONTROLS_SELECTOR);
  7536. delete _this5.controlsTimeout;
  7537. }, DELAY_BEFORE_HIDING_CONTROLS);
  7538. }
  7539. }, {
  7540. key: "_hideControls",
  7541. value: function _hideControls() {
  7542. if (!this.controlsTimeout) {
  7543. return;
  7544. }
  7545. clearTimeout(this.controlsTimeout);
  7546. this.container.classList.remove(CONTROLS_SELECTOR);
  7547. delete this.controlsTimeout;
  7548. }
  7549. }, {
  7550. key: "_resetMouseScrollState",
  7551. value: function _resetMouseScrollState() {
  7552. this.mouseScrollTimeStamp = 0;
  7553. this.mouseScrollDelta = 0;
  7554. }
  7555. }, {
  7556. key: "_touchSwipe",
  7557. value: function _touchSwipe(evt) {
  7558. if (!this.active) {
  7559. return;
  7560. }
  7561. if (evt.touches.length > 1) {
  7562. this.touchSwipeState = null;
  7563. return;
  7564. }
  7565. switch (evt.type) {
  7566. case 'touchstart':
  7567. this.touchSwipeState = {
  7568. startX: evt.touches[0].pageX,
  7569. startY: evt.touches[0].pageY,
  7570. endX: evt.touches[0].pageX,
  7571. endY: evt.touches[0].pageY
  7572. };
  7573. break;
  7574. case 'touchmove':
  7575. if (this.touchSwipeState === null) {
  7576. return;
  7577. }
  7578. this.touchSwipeState.endX = evt.touches[0].pageX;
  7579. this.touchSwipeState.endY = evt.touches[0].pageY;
  7580. evt.preventDefault();
  7581. break;
  7582. case 'touchend':
  7583. if (this.touchSwipeState === null) {
  7584. return;
  7585. }
  7586. var delta = 0;
  7587. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  7588. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  7589. var absAngle = Math.abs(Math.atan2(dy, dx));
  7590. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  7591. delta = dx;
  7592. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  7593. delta = dy;
  7594. }
  7595. if (delta > 0) {
  7596. this._goToPreviousPage();
  7597. } else if (delta < 0) {
  7598. this._goToNextPage();
  7599. }
  7600. break;
  7601. }
  7602. }
  7603. }, {
  7604. key: "_addWindowListeners",
  7605. value: function _addWindowListeners() {
  7606. this.showControlsBind = this._showControls.bind(this);
  7607. this.mouseDownBind = this._mouseDown.bind(this);
  7608. this.mouseWheelBind = this._mouseWheel.bind(this);
  7609. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  7610. this.contextMenuBind = this._contextMenu.bind(this);
  7611. this.touchSwipeBind = this._touchSwipe.bind(this);
  7612. window.addEventListener('mousemove', this.showControlsBind);
  7613. window.addEventListener('mousedown', this.mouseDownBind);
  7614. window.addEventListener('wheel', this.mouseWheelBind);
  7615. window.addEventListener('keydown', this.resetMouseScrollStateBind);
  7616. window.addEventListener('contextmenu', this.contextMenuBind);
  7617. window.addEventListener('touchstart', this.touchSwipeBind);
  7618. window.addEventListener('touchmove', this.touchSwipeBind);
  7619. window.addEventListener('touchend', this.touchSwipeBind);
  7620. }
  7621. }, {
  7622. key: "_removeWindowListeners",
  7623. value: function _removeWindowListeners() {
  7624. window.removeEventListener('mousemove', this.showControlsBind);
  7625. window.removeEventListener('mousedown', this.mouseDownBind);
  7626. window.removeEventListener('wheel', this.mouseWheelBind);
  7627. window.removeEventListener('keydown', this.resetMouseScrollStateBind);
  7628. window.removeEventListener('contextmenu', this.contextMenuBind);
  7629. window.removeEventListener('touchstart', this.touchSwipeBind);
  7630. window.removeEventListener('touchmove', this.touchSwipeBind);
  7631. window.removeEventListener('touchend', this.touchSwipeBind);
  7632. delete this.showControlsBind;
  7633. delete this.mouseDownBind;
  7634. delete this.mouseWheelBind;
  7635. delete this.resetMouseScrollStateBind;
  7636. delete this.contextMenuBind;
  7637. delete this.touchSwipeBind;
  7638. }
  7639. }, {
  7640. key: "_fullscreenChange",
  7641. value: function _fullscreenChange() {
  7642. if (this.isFullscreen) {
  7643. this._enter();
  7644. } else {
  7645. this._exit();
  7646. }
  7647. }
  7648. }, {
  7649. key: "_addFullscreenChangeListeners",
  7650. value: function _addFullscreenChangeListeners() {
  7651. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  7652. window.addEventListener('fullscreenchange', this.fullscreenChangeBind);
  7653. window.addEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  7654. window.addEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  7655. window.addEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  7656. }
  7657. }, {
  7658. key: "_removeFullscreenChangeListeners",
  7659. value: function _removeFullscreenChangeListeners() {
  7660. window.removeEventListener('fullscreenchange', this.fullscreenChangeBind);
  7661. window.removeEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  7662. window.removeEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  7663. window.removeEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  7664. delete this.fullscreenChangeBind;
  7665. }
  7666. }, {
  7667. key: "isFullscreen",
  7668. get: function get() {
  7669. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
  7670. }
  7671. }]);
  7672. return PDFPresentationMode;
  7673. }();
  7674. exports.PDFPresentationMode = PDFPresentationMode;
  7675. /***/ }),
  7676. /* 24 */
  7677. /***/ (function(module, exports, __webpack_require__) {
  7678. "use strict";
  7679. Object.defineProperty(exports, "__esModule", {
  7680. value: true
  7681. });
  7682. exports.PDFSidebarResizer = void 0;
  7683. var _ui_utils = __webpack_require__(5);
  7684. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7685. 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); } }
  7686. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7687. var SIDEBAR_WIDTH_VAR = '--sidebar-width';
  7688. var SIDEBAR_MIN_WIDTH = 200;
  7689. var SIDEBAR_RESIZING_CLASS = 'sidebarResizing';
  7690. var PDFSidebarResizer =
  7691. /*#__PURE__*/
  7692. function () {
  7693. function PDFSidebarResizer(options, eventBus) {
  7694. var _this = this;
  7695. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  7696. _classCallCheck(this, PDFSidebarResizer);
  7697. this.enabled = false;
  7698. this.isRTL = false;
  7699. this.sidebarOpen = false;
  7700. this.doc = document.documentElement;
  7701. this._width = null;
  7702. this._outerContainerWidth = null;
  7703. this._boundEvents = Object.create(null);
  7704. this.outerContainer = options.outerContainer;
  7705. this.resizer = options.resizer;
  7706. this.eventBus = eventBus;
  7707. this.l10n = l10n;
  7708. if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function' || !CSS.supports(SIDEBAR_WIDTH_VAR, "calc(-1 * ".concat(SIDEBAR_MIN_WIDTH, "px)"))) {
  7709. console.warn('PDFSidebarResizer: ' + 'The browser does not support resizing of the sidebar.');
  7710. return;
  7711. }
  7712. this.enabled = true;
  7713. this.resizer.classList.remove('hidden');
  7714. this.l10n.getDirection().then(function (dir) {
  7715. _this.isRTL = dir === 'rtl';
  7716. });
  7717. this._addEventListeners();
  7718. }
  7719. _createClass(PDFSidebarResizer, [{
  7720. key: "_updateWidth",
  7721. value: function _updateWidth() {
  7722. var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  7723. if (!this.enabled) {
  7724. return false;
  7725. }
  7726. var maxWidth = Math.floor(this.outerContainerWidth / 2);
  7727. if (width > maxWidth) {
  7728. width = maxWidth;
  7729. }
  7730. if (width < SIDEBAR_MIN_WIDTH) {
  7731. width = SIDEBAR_MIN_WIDTH;
  7732. }
  7733. if (width === this._width) {
  7734. return false;
  7735. }
  7736. this._width = width;
  7737. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(width, "px"));
  7738. return true;
  7739. }
  7740. }, {
  7741. key: "_mouseMove",
  7742. value: function _mouseMove(evt) {
  7743. var width = evt.clientX;
  7744. if (this.isRTL) {
  7745. width = this.outerContainerWidth - width;
  7746. }
  7747. this._updateWidth(width);
  7748. }
  7749. }, {
  7750. key: "_mouseUp",
  7751. value: function _mouseUp(evt) {
  7752. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  7753. this.eventBus.dispatch('resize', {
  7754. source: this
  7755. });
  7756. var _boundEvents = this._boundEvents;
  7757. window.removeEventListener('mousemove', _boundEvents.mouseMove);
  7758. window.removeEventListener('mouseup', _boundEvents.mouseUp);
  7759. }
  7760. }, {
  7761. key: "_addEventListeners",
  7762. value: function _addEventListeners() {
  7763. var _this2 = this;
  7764. if (!this.enabled) {
  7765. return;
  7766. }
  7767. var _boundEvents = this._boundEvents;
  7768. _boundEvents.mouseMove = this._mouseMove.bind(this);
  7769. _boundEvents.mouseUp = this._mouseUp.bind(this);
  7770. this.resizer.addEventListener('mousedown', function (evt) {
  7771. if (evt.button !== 0) {
  7772. return;
  7773. }
  7774. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  7775. window.addEventListener('mousemove', _boundEvents.mouseMove);
  7776. window.addEventListener('mouseup', _boundEvents.mouseUp);
  7777. });
  7778. this.eventBus.on('sidebarviewchanged', function (evt) {
  7779. _this2.sidebarOpen = !!(evt && evt.view);
  7780. });
  7781. this.eventBus.on('resize', function (evt) {
  7782. if (evt && evt.source === window) {
  7783. _this2._outerContainerWidth = null;
  7784. if (_this2._width) {
  7785. if (_this2.sidebarOpen) {
  7786. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  7787. var updated = _this2._updateWidth(_this2._width);
  7788. Promise.resolve().then(function () {
  7789. _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  7790. if (updated) {
  7791. _this2.eventBus.dispatch('resize', {
  7792. source: _this2
  7793. });
  7794. }
  7795. });
  7796. } else {
  7797. _this2._updateWidth(_this2._width);
  7798. }
  7799. }
  7800. }
  7801. });
  7802. }
  7803. }, {
  7804. key: "outerContainerWidth",
  7805. get: function get() {
  7806. if (!this._outerContainerWidth) {
  7807. this._outerContainerWidth = this.outerContainer.clientWidth;
  7808. }
  7809. return this._outerContainerWidth;
  7810. }
  7811. }]);
  7812. return PDFSidebarResizer;
  7813. }();
  7814. exports.PDFSidebarResizer = PDFSidebarResizer;
  7815. /***/ }),
  7816. /* 25 */
  7817. /***/ (function(module, exports, __webpack_require__) {
  7818. "use strict";
  7819. Object.defineProperty(exports, "__esModule", {
  7820. value: true
  7821. });
  7822. exports.PDFThumbnailViewer = void 0;
  7823. var _ui_utils = __webpack_require__(5);
  7824. var _pdf_thumbnail_view = __webpack_require__(26);
  7825. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7826. 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); } }
  7827. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7828. var THUMBNAIL_SCROLL_MARGIN = -19;
  7829. var THUMBNAIL_SELECTED_CLASS = 'selected';
  7830. var PDFThumbnailViewer =
  7831. /*#__PURE__*/
  7832. function () {
  7833. function PDFThumbnailViewer(_ref) {
  7834. var container = _ref.container,
  7835. linkService = _ref.linkService,
  7836. renderingQueue = _ref.renderingQueue,
  7837. _ref$l10n = _ref.l10n,
  7838. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  7839. _classCallCheck(this, PDFThumbnailViewer);
  7840. this.container = container;
  7841. this.linkService = linkService;
  7842. this.renderingQueue = renderingQueue;
  7843. this.l10n = l10n;
  7844. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  7845. this._resetView();
  7846. }
  7847. _createClass(PDFThumbnailViewer, [{
  7848. key: "_scrollUpdated",
  7849. value: function _scrollUpdated() {
  7850. this.renderingQueue.renderHighestPriority();
  7851. }
  7852. }, {
  7853. key: "getThumbnail",
  7854. value: function getThumbnail(index) {
  7855. return this._thumbnails[index];
  7856. }
  7857. }, {
  7858. key: "_getVisibleThumbs",
  7859. value: function _getVisibleThumbs() {
  7860. return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
  7861. }
  7862. }, {
  7863. key: "scrollThumbnailIntoView",
  7864. value: function scrollThumbnailIntoView(pageNumber) {
  7865. if (!this.pdfDocument) {
  7866. return;
  7867. }
  7868. var thumbnailView = this._thumbnails[pageNumber - 1];
  7869. if (!thumbnailView) {
  7870. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  7871. return;
  7872. }
  7873. if (pageNumber !== this._currentPageNumber) {
  7874. var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  7875. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  7876. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  7877. }
  7878. var visibleThumbs = this._getVisibleThumbs();
  7879. var numVisibleThumbs = visibleThumbs.views.length;
  7880. if (numVisibleThumbs > 0) {
  7881. var first = visibleThumbs.first.id;
  7882. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  7883. var shouldScroll = false;
  7884. if (pageNumber <= first || pageNumber >= last) {
  7885. shouldScroll = true;
  7886. } else {
  7887. visibleThumbs.views.some(function (view) {
  7888. if (view.id !== pageNumber) {
  7889. return false;
  7890. }
  7891. shouldScroll = view.percent < 100;
  7892. return true;
  7893. });
  7894. }
  7895. if (shouldScroll) {
  7896. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  7897. top: THUMBNAIL_SCROLL_MARGIN
  7898. });
  7899. }
  7900. }
  7901. this._currentPageNumber = pageNumber;
  7902. }
  7903. }, {
  7904. key: "cleanup",
  7905. value: function cleanup() {
  7906. _pdf_thumbnail_view.PDFThumbnailView.cleanup();
  7907. }
  7908. }, {
  7909. key: "_resetView",
  7910. value: function _resetView() {
  7911. this._thumbnails = [];
  7912. this._currentPageNumber = 1;
  7913. this._pageLabels = null;
  7914. this._pagesRotation = 0;
  7915. this._pagesRequests = [];
  7916. this.container.textContent = '';
  7917. }
  7918. }, {
  7919. key: "setDocument",
  7920. value: function setDocument(pdfDocument) {
  7921. var _this = this;
  7922. if (this.pdfDocument) {
  7923. this._cancelRendering();
  7924. this._resetView();
  7925. }
  7926. this.pdfDocument = pdfDocument;
  7927. if (!pdfDocument) {
  7928. return;
  7929. }
  7930. pdfDocument.getPage(1).then(function (firstPage) {
  7931. var pagesCount = pdfDocument.numPages;
  7932. var viewport = firstPage.getViewport({
  7933. scale: 1
  7934. });
  7935. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  7936. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  7937. container: _this.container,
  7938. id: pageNum,
  7939. defaultViewport: viewport.clone(),
  7940. linkService: _this.linkService,
  7941. renderingQueue: _this.renderingQueue,
  7942. disableCanvasToImageConversion: false,
  7943. l10n: _this.l10n
  7944. });
  7945. _this._thumbnails.push(thumbnail);
  7946. }
  7947. var thumbnailView = _this._thumbnails[_this._currentPageNumber - 1];
  7948. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  7949. })["catch"](function (reason) {
  7950. console.error('Unable to initialize thumbnail viewer', reason);
  7951. });
  7952. }
  7953. }, {
  7954. key: "_cancelRendering",
  7955. value: function _cancelRendering() {
  7956. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7957. if (this._thumbnails[i]) {
  7958. this._thumbnails[i].cancelRendering();
  7959. }
  7960. }
  7961. }
  7962. }, {
  7963. key: "setPageLabels",
  7964. value: function setPageLabels(labels) {
  7965. if (!this.pdfDocument) {
  7966. return;
  7967. }
  7968. if (!labels) {
  7969. this._pageLabels = null;
  7970. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  7971. this._pageLabels = null;
  7972. console.error('PDFThumbnailViewer_setPageLabels: Invalid page labels.');
  7973. } else {
  7974. this._pageLabels = labels;
  7975. }
  7976. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7977. var label = this._pageLabels && this._pageLabels[i];
  7978. this._thumbnails[i].setPageLabel(label);
  7979. }
  7980. }
  7981. }, {
  7982. key: "_ensurePdfPageLoaded",
  7983. value: function _ensurePdfPageLoaded(thumbView) {
  7984. var _this2 = this;
  7985. if (thumbView.pdfPage) {
  7986. return Promise.resolve(thumbView.pdfPage);
  7987. }
  7988. var pageNumber = thumbView.id;
  7989. if (this._pagesRequests[pageNumber]) {
  7990. return this._pagesRequests[pageNumber];
  7991. }
  7992. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  7993. thumbView.setPdfPage(pdfPage);
  7994. _this2._pagesRequests[pageNumber] = null;
  7995. return pdfPage;
  7996. })["catch"](function (reason) {
  7997. console.error('Unable to get page for thumb view', reason);
  7998. _this2._pagesRequests[pageNumber] = null;
  7999. });
  8000. this._pagesRequests[pageNumber] = promise;
  8001. return promise;
  8002. }
  8003. }, {
  8004. key: "forceRendering",
  8005. value: function forceRendering() {
  8006. var _this3 = this;
  8007. var visibleThumbs = this._getVisibleThumbs();
  8008. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  8009. if (thumbView) {
  8010. this._ensurePdfPageLoaded(thumbView).then(function () {
  8011. _this3.renderingQueue.renderView(thumbView);
  8012. });
  8013. return true;
  8014. }
  8015. return false;
  8016. }
  8017. }, {
  8018. key: "pagesRotation",
  8019. get: function get() {
  8020. return this._pagesRotation;
  8021. },
  8022. set: function set(rotation) {
  8023. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  8024. throw new Error('Invalid thumbnails rotation angle.');
  8025. }
  8026. if (!this.pdfDocument) {
  8027. return;
  8028. }
  8029. if (this._pagesRotation === rotation) {
  8030. return;
  8031. }
  8032. this._pagesRotation = rotation;
  8033. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8034. this._thumbnails[i].update(rotation);
  8035. }
  8036. }
  8037. }]);
  8038. return PDFThumbnailViewer;
  8039. }();
  8040. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  8041. /***/ }),
  8042. /* 26 */
  8043. /***/ (function(module, exports, __webpack_require__) {
  8044. "use strict";
  8045. Object.defineProperty(exports, "__esModule", {
  8046. value: true
  8047. });
  8048. exports.PDFThumbnailView = void 0;
  8049. var _pdfjsLib = __webpack_require__(7);
  8050. var _ui_utils = __webpack_require__(5);
  8051. var _pdf_rendering_queue = __webpack_require__(11);
  8052. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8053. 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); } }
  8054. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8055. var MAX_NUM_SCALING_STEPS = 3;
  8056. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  8057. var THUMBNAIL_WIDTH = 98;
  8058. var TempImageFactory = function TempImageFactoryClosure() {
  8059. var tempCanvasCache = null;
  8060. return {
  8061. getCanvas: function getCanvas(width, height) {
  8062. var tempCanvas = tempCanvasCache;
  8063. if (!tempCanvas) {
  8064. tempCanvas = document.createElement('canvas');
  8065. tempCanvasCache = tempCanvas;
  8066. }
  8067. tempCanvas.width = width;
  8068. tempCanvas.height = height;
  8069. tempCanvas.mozOpaque = true;
  8070. var ctx = tempCanvas.getContext('2d', {
  8071. alpha: false
  8072. });
  8073. ctx.save();
  8074. ctx.fillStyle = 'rgb(255, 255, 255)';
  8075. ctx.fillRect(0, 0, width, height);
  8076. ctx.restore();
  8077. return tempCanvas;
  8078. },
  8079. destroyCanvas: function destroyCanvas() {
  8080. var tempCanvas = tempCanvasCache;
  8081. if (tempCanvas) {
  8082. tempCanvas.width = 0;
  8083. tempCanvas.height = 0;
  8084. }
  8085. tempCanvasCache = null;
  8086. }
  8087. };
  8088. }();
  8089. var PDFThumbnailView =
  8090. /*#__PURE__*/
  8091. function () {
  8092. function PDFThumbnailView(_ref) {
  8093. var container = _ref.container,
  8094. id = _ref.id,
  8095. defaultViewport = _ref.defaultViewport,
  8096. linkService = _ref.linkService,
  8097. renderingQueue = _ref.renderingQueue,
  8098. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  8099. disableCanvasToImageConversion = _ref$disableCanvasToI === void 0 ? false : _ref$disableCanvasToI,
  8100. _ref$l10n = _ref.l10n,
  8101. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  8102. _classCallCheck(this, PDFThumbnailView);
  8103. this.id = id;
  8104. this.renderingId = 'thumbnail' + id;
  8105. this.pageLabel = null;
  8106. this.pdfPage = null;
  8107. this.rotation = 0;
  8108. this.viewport = defaultViewport;
  8109. this.pdfPageRotate = defaultViewport.rotation;
  8110. this.linkService = linkService;
  8111. this.renderingQueue = renderingQueue;
  8112. this.renderTask = null;
  8113. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8114. this.resume = null;
  8115. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  8116. this.pageWidth = this.viewport.width;
  8117. this.pageHeight = this.viewport.height;
  8118. this.pageRatio = this.pageWidth / this.pageHeight;
  8119. this.canvasWidth = THUMBNAIL_WIDTH;
  8120. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  8121. this.scale = this.canvasWidth / this.pageWidth;
  8122. this.l10n = l10n;
  8123. var anchor = document.createElement('a');
  8124. anchor.href = linkService.getAnchorUrl('#page=' + id);
  8125. this.l10n.get('thumb_page_title', {
  8126. page: id
  8127. }, 'Page {{page}}').then(function (msg) {
  8128. anchor.title = msg;
  8129. });
  8130. anchor.onclick = function () {
  8131. linkService.page = id;
  8132. return false;
  8133. };
  8134. this.anchor = anchor;
  8135. var div = document.createElement('div');
  8136. div.className = 'thumbnail';
  8137. div.setAttribute('data-page-number', this.id);
  8138. this.div = div;
  8139. var ring = document.createElement('div');
  8140. ring.className = 'thumbnailSelectionRing';
  8141. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8142. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  8143. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  8144. this.ring = ring;
  8145. div.appendChild(ring);
  8146. anchor.appendChild(div);
  8147. container.appendChild(anchor);
  8148. }
  8149. _createClass(PDFThumbnailView, [{
  8150. key: "setPdfPage",
  8151. value: function setPdfPage(pdfPage) {
  8152. this.pdfPage = pdfPage;
  8153. this.pdfPageRotate = pdfPage.rotate;
  8154. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8155. this.viewport = pdfPage.getViewport({
  8156. scale: 1,
  8157. rotation: totalRotation
  8158. });
  8159. this.reset();
  8160. }
  8161. }, {
  8162. key: "reset",
  8163. value: function reset() {
  8164. this.cancelRendering();
  8165. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8166. this.pageWidth = this.viewport.width;
  8167. this.pageHeight = this.viewport.height;
  8168. this.pageRatio = this.pageWidth / this.pageHeight;
  8169. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  8170. this.scale = this.canvasWidth / this.pageWidth;
  8171. this.div.removeAttribute('data-loaded');
  8172. var ring = this.ring;
  8173. var childNodes = ring.childNodes;
  8174. for (var i = childNodes.length - 1; i >= 0; i--) {
  8175. ring.removeChild(childNodes[i]);
  8176. }
  8177. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8178. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  8179. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  8180. if (this.canvas) {
  8181. this.canvas.width = 0;
  8182. this.canvas.height = 0;
  8183. delete this.canvas;
  8184. }
  8185. if (this.image) {
  8186. this.image.removeAttribute('src');
  8187. delete this.image;
  8188. }
  8189. }
  8190. }, {
  8191. key: "update",
  8192. value: function update(rotation) {
  8193. if (typeof rotation !== 'undefined') {
  8194. this.rotation = rotation;
  8195. }
  8196. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8197. this.viewport = this.viewport.clone({
  8198. scale: 1,
  8199. rotation: totalRotation
  8200. });
  8201. this.reset();
  8202. }
  8203. }, {
  8204. key: "cancelRendering",
  8205. value: function cancelRendering() {
  8206. if (this.renderTask) {
  8207. this.renderTask.cancel();
  8208. this.renderTask = null;
  8209. }
  8210. this.resume = null;
  8211. }
  8212. }, {
  8213. key: "_getPageDrawContext",
  8214. value: function _getPageDrawContext() {
  8215. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8216. var canvas = document.createElement('canvas');
  8217. this.canvas = canvas;
  8218. canvas.mozOpaque = true;
  8219. var ctx = canvas.getContext('2d', {
  8220. alpha: false
  8221. });
  8222. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  8223. canvas.width = this.canvasWidth * outputScale.sx | 0;
  8224. canvas.height = this.canvasHeight * outputScale.sy | 0;
  8225. canvas.style.width = this.canvasWidth + 'px';
  8226. canvas.style.height = this.canvasHeight + 'px';
  8227. if (!noCtxScale && outputScale.scaled) {
  8228. ctx.scale(outputScale.sx, outputScale.sy);
  8229. }
  8230. return ctx;
  8231. }
  8232. }, {
  8233. key: "_convertCanvasToImage",
  8234. value: function _convertCanvasToImage() {
  8235. var _this = this;
  8236. if (!this.canvas) {
  8237. return;
  8238. }
  8239. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8240. return;
  8241. }
  8242. var id = this.renderingId;
  8243. var className = 'thumbnailImage';
  8244. if (this.disableCanvasToImageConversion) {
  8245. this.canvas.id = id;
  8246. this.canvas.className = className;
  8247. this.l10n.get('thumb_page_canvas', {
  8248. page: this.pageId
  8249. }, 'Thumbnail of Page {{page}}').then(function (msg) {
  8250. _this.canvas.setAttribute('aria-label', msg);
  8251. });
  8252. this.div.setAttribute('data-loaded', true);
  8253. this.ring.appendChild(this.canvas);
  8254. return;
  8255. }
  8256. var image = document.createElement('img');
  8257. image.id = id;
  8258. image.className = className;
  8259. this.l10n.get('thumb_page_canvas', {
  8260. page: this.pageId
  8261. }, 'Thumbnail of Page {{page}}').then(function (msg) {
  8262. image.setAttribute('aria-label', msg);
  8263. });
  8264. image.style.width = this.canvasWidth + 'px';
  8265. image.style.height = this.canvasHeight + 'px';
  8266. image.src = this.canvas.toDataURL();
  8267. this.image = image;
  8268. this.div.setAttribute('data-loaded', true);
  8269. this.ring.appendChild(image);
  8270. this.canvas.width = 0;
  8271. this.canvas.height = 0;
  8272. delete this.canvas;
  8273. }
  8274. }, {
  8275. key: "draw",
  8276. value: function draw() {
  8277. var _this2 = this;
  8278. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8279. console.error('Must be in new state before drawing');
  8280. return Promise.resolve(undefined);
  8281. }
  8282. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8283. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  8284. var finishRenderTask = function finishRenderTask(error) {
  8285. if (renderTask === _this2.renderTask) {
  8286. _this2.renderTask = null;
  8287. }
  8288. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  8289. renderCapability.resolve(undefined);
  8290. return;
  8291. }
  8292. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8293. _this2._convertCanvasToImage();
  8294. if (!error) {
  8295. renderCapability.resolve(undefined);
  8296. } else {
  8297. renderCapability.reject(error);
  8298. }
  8299. };
  8300. var ctx = this._getPageDrawContext();
  8301. var drawViewport = this.viewport.clone({
  8302. scale: this.scale
  8303. });
  8304. var renderContinueCallback = function renderContinueCallback(cont) {
  8305. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  8306. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  8307. _this2.resume = function () {
  8308. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8309. cont();
  8310. };
  8311. return;
  8312. }
  8313. cont();
  8314. };
  8315. var renderContext = {
  8316. canvasContext: ctx,
  8317. viewport: drawViewport
  8318. };
  8319. var renderTask = this.renderTask = this.pdfPage.render(renderContext);
  8320. renderTask.onContinue = renderContinueCallback;
  8321. renderTask.promise.then(function () {
  8322. finishRenderTask(null);
  8323. }, function (error) {
  8324. finishRenderTask(error);
  8325. });
  8326. return renderCapability.promise;
  8327. }
  8328. }, {
  8329. key: "setImage",
  8330. value: function setImage(pageView) {
  8331. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8332. return;
  8333. }
  8334. var img = pageView.canvas;
  8335. if (!img) {
  8336. return;
  8337. }
  8338. if (!this.pdfPage) {
  8339. this.setPdfPage(pageView.pdfPage);
  8340. }
  8341. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8342. var ctx = this._getPageDrawContext(true);
  8343. var canvas = ctx.canvas;
  8344. if (img.width <= 2 * canvas.width) {
  8345. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  8346. this._convertCanvasToImage();
  8347. return;
  8348. }
  8349. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  8350. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  8351. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  8352. var reducedImageCtx = reducedImage.getContext('2d');
  8353. while (reducedWidth > img.width || reducedHeight > img.height) {
  8354. reducedWidth >>= 1;
  8355. reducedHeight >>= 1;
  8356. }
  8357. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  8358. while (reducedWidth > 2 * canvas.width) {
  8359. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  8360. reducedWidth >>= 1;
  8361. reducedHeight >>= 1;
  8362. }
  8363. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  8364. this._convertCanvasToImage();
  8365. }
  8366. }, {
  8367. key: "setPageLabel",
  8368. value: function setPageLabel(label) {
  8369. var _this3 = this;
  8370. this.pageLabel = typeof label === 'string' ? label : null;
  8371. this.l10n.get('thumb_page_title', {
  8372. page: this.pageId
  8373. }, 'Page {{page}}').then(function (msg) {
  8374. _this3.anchor.title = msg;
  8375. });
  8376. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8377. return;
  8378. }
  8379. this.l10n.get('thumb_page_canvas', {
  8380. page: this.pageId
  8381. }, 'Thumbnail of Page {{page}}').then(function (ariaLabel) {
  8382. if (_this3.image) {
  8383. _this3.image.setAttribute('aria-label', ariaLabel);
  8384. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  8385. _this3.canvas.setAttribute('aria-label', ariaLabel);
  8386. }
  8387. });
  8388. }
  8389. }, {
  8390. key: "pageId",
  8391. get: function get() {
  8392. return this.pageLabel !== null ? this.pageLabel : this.id;
  8393. }
  8394. }], [{
  8395. key: "cleanup",
  8396. value: function cleanup() {
  8397. TempImageFactory.destroyCanvas();
  8398. }
  8399. }]);
  8400. return PDFThumbnailView;
  8401. }();
  8402. exports.PDFThumbnailView = PDFThumbnailView;
  8403. /***/ }),
  8404. /* 27 */
  8405. /***/ (function(module, exports, __webpack_require__) {
  8406. "use strict";
  8407. Object.defineProperty(exports, "__esModule", {
  8408. value: true
  8409. });
  8410. exports.PDFViewer = void 0;
  8411. var _base_viewer = __webpack_require__(28);
  8412. var _pdfjsLib = __webpack_require__(7);
  8413. function _typeof(obj) { 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); }
  8414. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8415. 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); } }
  8416. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8417. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8418. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8419. 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); }
  8420. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  8421. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8422. 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); }
  8423. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8424. var PDFViewer =
  8425. /*#__PURE__*/
  8426. function (_BaseViewer) {
  8427. _inherits(PDFViewer, _BaseViewer);
  8428. function PDFViewer() {
  8429. _classCallCheck(this, PDFViewer);
  8430. return _possibleConstructorReturn(this, _getPrototypeOf(PDFViewer).apply(this, arguments));
  8431. }
  8432. _createClass(PDFViewer, [{
  8433. key: "_scrollIntoView",
  8434. value: function _scrollIntoView(_ref) {
  8435. var pageDiv = _ref.pageDiv,
  8436. _ref$pageSpot = _ref.pageSpot,
  8437. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  8438. _ref$pageNumber = _ref.pageNumber,
  8439. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  8440. if (!pageSpot && !this.isInPresentationMode) {
  8441. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  8442. var right = left + pageDiv.clientWidth;
  8443. var _this$container = this.container,
  8444. scrollLeft = _this$container.scrollLeft,
  8445. clientWidth = _this$container.clientWidth;
  8446. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  8447. pageSpot = {
  8448. left: 0,
  8449. top: 0
  8450. };
  8451. }
  8452. }
  8453. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  8454. pageDiv: pageDiv,
  8455. pageSpot: pageSpot,
  8456. pageNumber: pageNumber
  8457. });
  8458. }
  8459. }, {
  8460. key: "_getVisiblePages",
  8461. value: function _getVisiblePages() {
  8462. if (this.isInPresentationMode) {
  8463. return this._getCurrentVisiblePage();
  8464. }
  8465. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  8466. }
  8467. }, {
  8468. key: "_updateHelper",
  8469. value: function _updateHelper(visiblePages) {
  8470. if (this.isInPresentationMode) {
  8471. return;
  8472. }
  8473. var currentId = this._currentPageNumber;
  8474. var stillFullyVisible = false;
  8475. var _iteratorNormalCompletion = true;
  8476. var _didIteratorError = false;
  8477. var _iteratorError = undefined;
  8478. try {
  8479. for (var _iterator = visiblePages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  8480. var page = _step.value;
  8481. if (page.percent < 100) {
  8482. break;
  8483. }
  8484. if (page.id === currentId) {
  8485. stillFullyVisible = true;
  8486. break;
  8487. }
  8488. }
  8489. } catch (err) {
  8490. _didIteratorError = true;
  8491. _iteratorError = err;
  8492. } finally {
  8493. try {
  8494. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  8495. _iterator["return"]();
  8496. }
  8497. } finally {
  8498. if (_didIteratorError) {
  8499. throw _iteratorError;
  8500. }
  8501. }
  8502. }
  8503. if (!stillFullyVisible) {
  8504. currentId = visiblePages[0].id;
  8505. }
  8506. this._setCurrentPageNumber(currentId);
  8507. }
  8508. }, {
  8509. key: "_setDocumentViewerElement",
  8510. get: function get() {
  8511. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer);
  8512. }
  8513. }]);
  8514. return PDFViewer;
  8515. }(_base_viewer.BaseViewer);
  8516. exports.PDFViewer = PDFViewer;
  8517. /***/ }),
  8518. /* 28 */
  8519. /***/ (function(module, exports, __webpack_require__) {
  8520. "use strict";
  8521. Object.defineProperty(exports, "__esModule", {
  8522. value: true
  8523. });
  8524. exports.BaseViewer = void 0;
  8525. var _ui_utils = __webpack_require__(5);
  8526. var _pdf_rendering_queue = __webpack_require__(11);
  8527. var _annotation_layer_builder = __webpack_require__(29);
  8528. var _pdfjsLib = __webpack_require__(7);
  8529. var _pdf_page_view = __webpack_require__(30);
  8530. var _pdf_link_service = __webpack_require__(21);
  8531. var _text_layer_builder = __webpack_require__(31);
  8532. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8533. 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); } }
  8534. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8535. var DEFAULT_CACHE_SIZE = 10;
  8536. function PDFPageViewBuffer(size) {
  8537. var data = [];
  8538. this.push = function (view) {
  8539. var i = data.indexOf(view);
  8540. if (i >= 0) {
  8541. data.splice(i, 1);
  8542. }
  8543. data.push(view);
  8544. if (data.length > size) {
  8545. data.shift().destroy();
  8546. }
  8547. };
  8548. this.resize = function (newSize, pagesToKeep) {
  8549. size = newSize;
  8550. if (pagesToKeep) {
  8551. var pageIdsToKeep = new Set();
  8552. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  8553. pageIdsToKeep.add(pagesToKeep[i].id);
  8554. }
  8555. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  8556. return pageIdsToKeep.has(page.id);
  8557. });
  8558. }
  8559. while (data.length > size) {
  8560. data.shift().destroy();
  8561. }
  8562. };
  8563. }
  8564. function isSameScale(oldScale, newScale) {
  8565. if (newScale === oldScale) {
  8566. return true;
  8567. }
  8568. if (Math.abs(newScale - oldScale) < 1e-15) {
  8569. return true;
  8570. }
  8571. return false;
  8572. }
  8573. var BaseViewer =
  8574. /*#__PURE__*/
  8575. function () {
  8576. function BaseViewer(options) {
  8577. var _this = this;
  8578. _classCallCheck(this, BaseViewer);
  8579. if (this.constructor === BaseViewer) {
  8580. throw new Error('Cannot initialize BaseViewer.');
  8581. }
  8582. this._name = this.constructor.name;
  8583. this.container = options.container;
  8584. this.viewer = options.viewer || options.container.firstElementChild;
  8585. this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
  8586. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  8587. this.downloadManager = options.downloadManager || null;
  8588. this.findController = options.findController || null;
  8589. this.removePageBorders = options.removePageBorders || false;
  8590. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  8591. this.imageResourcesPath = options.imageResourcesPath || '';
  8592. this.renderInteractiveForms = options.renderInteractiveForms || false;
  8593. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  8594. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  8595. this.enableWebGL = options.enableWebGL || false;
  8596. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  8597. this.maxCanvasPixels = options.maxCanvasPixels;
  8598. this.l10n = options.l10n || _ui_utils.NullL10n;
  8599. this.defaultRenderingQueue = !options.renderingQueue;
  8600. if (this.defaultRenderingQueue) {
  8601. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  8602. this.renderingQueue.setViewer(this);
  8603. } else {
  8604. this.renderingQueue = options.renderingQueue;
  8605. }
  8606. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  8607. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  8608. this._resetView();
  8609. if (this.removePageBorders) {
  8610. this.viewer.classList.add('removePageBorders');
  8611. }
  8612. Promise.resolve().then(function () {
  8613. _this.eventBus.dispatch('baseviewerinit', {
  8614. source: _this
  8615. });
  8616. });
  8617. }
  8618. _createClass(BaseViewer, [{
  8619. key: "getPageView",
  8620. value: function getPageView(index) {
  8621. return this._pages[index];
  8622. }
  8623. }, {
  8624. key: "_setCurrentPageNumber",
  8625. value: function _setCurrentPageNumber(val) {
  8626. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8627. if (this._currentPageNumber === val) {
  8628. if (resetCurrentPageView) {
  8629. this._resetCurrentPageView();
  8630. }
  8631. return true;
  8632. }
  8633. if (!(0 < val && val <= this.pagesCount)) {
  8634. return false;
  8635. }
  8636. this._currentPageNumber = val;
  8637. this.eventBus.dispatch('pagechanging', {
  8638. source: this,
  8639. pageNumber: val,
  8640. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  8641. });
  8642. if (resetCurrentPageView) {
  8643. this._resetCurrentPageView();
  8644. }
  8645. return true;
  8646. }
  8647. }, {
  8648. key: "setDocument",
  8649. value: function setDocument(pdfDocument) {
  8650. var _this2 = this;
  8651. if (this.pdfDocument) {
  8652. this._cancelRendering();
  8653. this._resetView();
  8654. if (this.findController) {
  8655. this.findController.setDocument(null);
  8656. }
  8657. }
  8658. this.pdfDocument = pdfDocument;
  8659. if (!pdfDocument) {
  8660. return;
  8661. }
  8662. var pagesCount = pdfDocument.numPages;
  8663. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  8664. this.pagesPromise = pagesCapability.promise;
  8665. pagesCapability.promise.then(function () {
  8666. _this2._pageViewsReady = true;
  8667. _this2.eventBus.dispatch('pagesloaded', {
  8668. source: _this2,
  8669. pagesCount: pagesCount
  8670. });
  8671. });
  8672. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  8673. this.onePageRendered = onePageRenderedCapability.promise;
  8674. var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
  8675. pageView.onBeforeDraw = function () {
  8676. _this2._buffer.push(pageView);
  8677. };
  8678. pageView.onAfterDraw = function () {
  8679. if (!onePageRenderedCapability.settled) {
  8680. onePageRenderedCapability.resolve();
  8681. }
  8682. };
  8683. };
  8684. var firstPagePromise = pdfDocument.getPage(1);
  8685. this.firstPagePromise = firstPagePromise;
  8686. firstPagePromise.then(function (pdfPage) {
  8687. var scale = _this2.currentScale;
  8688. var viewport = pdfPage.getViewport({
  8689. scale: scale * _ui_utils.CSS_UNITS
  8690. });
  8691. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8692. var textLayerFactory = null;
  8693. if (_this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE) {
  8694. textLayerFactory = _this2;
  8695. }
  8696. var pageView = new _pdf_page_view.PDFPageView({
  8697. container: _this2._setDocumentViewerElement,
  8698. eventBus: _this2.eventBus,
  8699. id: pageNum,
  8700. scale: scale,
  8701. defaultViewport: viewport.clone(),
  8702. renderingQueue: _this2.renderingQueue,
  8703. textLayerFactory: textLayerFactory,
  8704. textLayerMode: _this2.textLayerMode,
  8705. annotationLayerFactory: _this2,
  8706. imageResourcesPath: _this2.imageResourcesPath,
  8707. renderInteractiveForms: _this2.renderInteractiveForms,
  8708. renderer: _this2.renderer,
  8709. enableWebGL: _this2.enableWebGL,
  8710. useOnlyCssZoom: _this2.useOnlyCssZoom,
  8711. maxCanvasPixels: _this2.maxCanvasPixels,
  8712. l10n: _this2.l10n
  8713. });
  8714. bindOnAfterAndBeforeDraw(pageView);
  8715. _this2._pages.push(pageView);
  8716. }
  8717. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  8718. _this2._updateSpreadMode();
  8719. }
  8720. onePageRenderedCapability.promise.then(function () {
  8721. if (_this2.findController) {
  8722. _this2.findController.setDocument(pdfDocument);
  8723. }
  8724. if (pdfDocument.loadingParams['disableAutoFetch']) {
  8725. pagesCapability.resolve();
  8726. return;
  8727. }
  8728. var getPagesLeft = pagesCount;
  8729. var _loop = function _loop(_pageNum) {
  8730. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  8731. var pageView = _this2._pages[_pageNum - 1];
  8732. if (!pageView.pdfPage) {
  8733. pageView.setPdfPage(pdfPage);
  8734. }
  8735. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  8736. if (--getPagesLeft === 0) {
  8737. pagesCapability.resolve();
  8738. }
  8739. }, function (reason) {
  8740. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  8741. if (--getPagesLeft === 0) {
  8742. pagesCapability.resolve();
  8743. }
  8744. });
  8745. };
  8746. for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
  8747. _loop(_pageNum);
  8748. }
  8749. });
  8750. _this2.eventBus.dispatch('pagesinit', {
  8751. source: _this2
  8752. });
  8753. if (_this2.defaultRenderingQueue) {
  8754. _this2.update();
  8755. }
  8756. })["catch"](function (reason) {
  8757. console.error('Unable to initialize viewer', reason);
  8758. });
  8759. }
  8760. }, {
  8761. key: "setPageLabels",
  8762. value: function setPageLabels(labels) {
  8763. if (!this.pdfDocument) {
  8764. return;
  8765. }
  8766. if (!labels) {
  8767. this._pageLabels = null;
  8768. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  8769. this._pageLabels = null;
  8770. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  8771. } else {
  8772. this._pageLabels = labels;
  8773. }
  8774. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8775. var pageView = this._pages[i];
  8776. var label = this._pageLabels && this._pageLabels[i];
  8777. pageView.setPageLabel(label);
  8778. }
  8779. }
  8780. }, {
  8781. key: "_resetView",
  8782. value: function _resetView() {
  8783. this._pages = [];
  8784. this._currentPageNumber = 1;
  8785. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  8786. this._currentScaleValue = null;
  8787. this._pageLabels = null;
  8788. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  8789. this._location = null;
  8790. this._pagesRotation = 0;
  8791. this._pagesRequests = [];
  8792. this._pageViewsReady = false;
  8793. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  8794. this._spreadMode = _ui_utils.SpreadMode.NONE;
  8795. this.viewer.textContent = '';
  8796. this._updateScrollMode();
  8797. }
  8798. }, {
  8799. key: "_scrollUpdate",
  8800. value: function _scrollUpdate() {
  8801. if (this.pagesCount === 0) {
  8802. return;
  8803. }
  8804. this.update();
  8805. }
  8806. }, {
  8807. key: "_scrollIntoView",
  8808. value: function _scrollIntoView(_ref) {
  8809. var pageDiv = _ref.pageDiv,
  8810. _ref$pageSpot = _ref.pageSpot,
  8811. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  8812. _ref$pageNumber = _ref.pageNumber,
  8813. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  8814. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  8815. }
  8816. }, {
  8817. key: "_setScaleUpdatePages",
  8818. value: function _setScaleUpdatePages(newScale, newValue) {
  8819. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8820. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  8821. this._currentScaleValue = newValue.toString();
  8822. if (isSameScale(this._currentScale, newScale)) {
  8823. if (preset) {
  8824. this.eventBus.dispatch('scalechanging', {
  8825. source: this,
  8826. scale: newScale,
  8827. presetValue: newValue
  8828. });
  8829. }
  8830. return;
  8831. }
  8832. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8833. this._pages[i].update(newScale);
  8834. }
  8835. this._currentScale = newScale;
  8836. if (!noScroll) {
  8837. var page = this._currentPageNumber,
  8838. dest;
  8839. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  8840. page = this._location.pageNumber;
  8841. dest = [null, {
  8842. name: 'XYZ'
  8843. }, this._location.left, this._location.top, null];
  8844. }
  8845. this.scrollPageIntoView({
  8846. pageNumber: page,
  8847. destArray: dest,
  8848. allowNegativeOffset: true
  8849. });
  8850. }
  8851. this.eventBus.dispatch('scalechanging', {
  8852. source: this,
  8853. scale: newScale,
  8854. presetValue: preset ? newValue : undefined
  8855. });
  8856. if (this.defaultRenderingQueue) {
  8857. this.update();
  8858. }
  8859. }
  8860. }, {
  8861. key: "_setScale",
  8862. value: function _setScale(value) {
  8863. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8864. var scale = parseFloat(value);
  8865. if (scale > 0) {
  8866. this._setScaleUpdatePages(scale, value, noScroll, false);
  8867. } else {
  8868. var currentPage = this._pages[this._currentPageNumber - 1];
  8869. if (!currentPage) {
  8870. return;
  8871. }
  8872. var noPadding = this.isInPresentationMode || this.removePageBorders;
  8873. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  8874. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  8875. if (!noPadding && this._isScrollModeHorizontal) {
  8876. var _ref2 = [vPadding, hPadding];
  8877. hPadding = _ref2[0];
  8878. vPadding = _ref2[1];
  8879. }
  8880. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  8881. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  8882. switch (value) {
  8883. case 'page-actual':
  8884. scale = 1;
  8885. break;
  8886. case 'page-width':
  8887. scale = pageWidthScale;
  8888. break;
  8889. case 'page-height':
  8890. scale = pageHeightScale;
  8891. break;
  8892. case 'page-fit':
  8893. scale = Math.min(pageWidthScale, pageHeightScale);
  8894. break;
  8895. case 'auto':
  8896. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  8897. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  8898. break;
  8899. default:
  8900. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  8901. return;
  8902. }
  8903. this._setScaleUpdatePages(scale, value, noScroll, true);
  8904. }
  8905. }
  8906. }, {
  8907. key: "_resetCurrentPageView",
  8908. value: function _resetCurrentPageView() {
  8909. if (this.isInPresentationMode) {
  8910. this._setScale(this._currentScaleValue, true);
  8911. }
  8912. var pageView = this._pages[this._currentPageNumber - 1];
  8913. this._scrollIntoView({
  8914. pageDiv: pageView.div
  8915. });
  8916. }
  8917. }, {
  8918. key: "scrollPageIntoView",
  8919. value: function scrollPageIntoView(_ref3) {
  8920. var pageNumber = _ref3.pageNumber,
  8921. _ref3$destArray = _ref3.destArray,
  8922. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  8923. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  8924. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf;
  8925. if (!this.pdfDocument) {
  8926. return;
  8927. }
  8928. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  8929. if (!pageView) {
  8930. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  8931. return;
  8932. }
  8933. if (this.isInPresentationMode || !destArray) {
  8934. this._setCurrentPageNumber(pageNumber, true);
  8935. return;
  8936. }
  8937. var x = 0,
  8938. y = 0;
  8939. var width = 0,
  8940. height = 0,
  8941. widthScale,
  8942. heightScale;
  8943. var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
  8944. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  8945. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  8946. var scale = 0;
  8947. switch (destArray[1].name) {
  8948. case 'XYZ':
  8949. x = destArray[2];
  8950. y = destArray[3];
  8951. scale = destArray[4];
  8952. x = x !== null ? x : 0;
  8953. y = y !== null ? y : pageHeight;
  8954. break;
  8955. case 'Fit':
  8956. case 'FitB':
  8957. scale = 'page-fit';
  8958. break;
  8959. case 'FitH':
  8960. case 'FitBH':
  8961. y = destArray[2];
  8962. scale = 'page-width';
  8963. if (y === null && this._location) {
  8964. x = this._location.left;
  8965. y = this._location.top;
  8966. }
  8967. break;
  8968. case 'FitV':
  8969. case 'FitBV':
  8970. x = destArray[2];
  8971. width = pageWidth;
  8972. height = pageHeight;
  8973. scale = 'page-height';
  8974. break;
  8975. case 'FitR':
  8976. x = destArray[2];
  8977. y = destArray[3];
  8978. width = destArray[4] - x;
  8979. height = destArray[5] - y;
  8980. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  8981. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  8982. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  8983. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  8984. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  8985. break;
  8986. default:
  8987. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  8988. return;
  8989. }
  8990. if (scale && scale !== this._currentScale) {
  8991. this.currentScaleValue = scale;
  8992. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  8993. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  8994. }
  8995. if (scale === 'page-fit' && !destArray[4]) {
  8996. this._scrollIntoView({
  8997. pageDiv: pageView.div,
  8998. pageNumber: pageNumber
  8999. });
  9000. return;
  9001. }
  9002. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  9003. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  9004. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  9005. if (!allowNegativeOffset) {
  9006. left = Math.max(left, 0);
  9007. top = Math.max(top, 0);
  9008. }
  9009. this._scrollIntoView({
  9010. pageDiv: pageView.div,
  9011. pageSpot: {
  9012. left: left,
  9013. top: top
  9014. },
  9015. pageNumber: pageNumber
  9016. });
  9017. }
  9018. }, {
  9019. key: "_updateLocation",
  9020. value: function _updateLocation(firstPage) {
  9021. var currentScale = this._currentScale;
  9022. var currentScaleValue = this._currentScaleValue;
  9023. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  9024. var pageNumber = firstPage.id;
  9025. var pdfOpenParams = '#page=' + pageNumber;
  9026. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  9027. var currentPageView = this._pages[pageNumber - 1];
  9028. var container = this.container;
  9029. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  9030. var intLeft = Math.round(topLeft[0]);
  9031. var intTop = Math.round(topLeft[1]);
  9032. pdfOpenParams += ',' + intLeft + ',' + intTop;
  9033. this._location = {
  9034. pageNumber: pageNumber,
  9035. scale: normalizedScaleValue,
  9036. top: intTop,
  9037. left: intLeft,
  9038. rotation: this._pagesRotation,
  9039. pdfOpenParams: pdfOpenParams
  9040. };
  9041. }
  9042. }, {
  9043. key: "_updateHelper",
  9044. value: function _updateHelper(visiblePages) {
  9045. throw new Error('Not implemented: _updateHelper');
  9046. }
  9047. }, {
  9048. key: "update",
  9049. value: function update() {
  9050. var visible = this._getVisiblePages();
  9051. var visiblePages = visible.views,
  9052. numVisiblePages = visiblePages.length;
  9053. if (numVisiblePages === 0) {
  9054. return;
  9055. }
  9056. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  9057. this._buffer.resize(newCacheSize, visiblePages);
  9058. this.renderingQueue.renderHighestPriority(visible);
  9059. this._updateHelper(visiblePages);
  9060. this._updateLocation(visible.first);
  9061. this.eventBus.dispatch('updateviewarea', {
  9062. source: this,
  9063. location: this._location
  9064. });
  9065. }
  9066. }, {
  9067. key: "containsElement",
  9068. value: function containsElement(element) {
  9069. return this.container.contains(element);
  9070. }
  9071. }, {
  9072. key: "focus",
  9073. value: function focus() {
  9074. this.container.focus();
  9075. }
  9076. }, {
  9077. key: "_getCurrentVisiblePage",
  9078. value: function _getCurrentVisiblePage() {
  9079. if (!this.pagesCount) {
  9080. return {
  9081. views: []
  9082. };
  9083. }
  9084. var pageView = this._pages[this._currentPageNumber - 1];
  9085. var element = pageView.div;
  9086. var view = {
  9087. id: pageView.id,
  9088. x: element.offsetLeft + element.clientLeft,
  9089. y: element.offsetTop + element.clientTop,
  9090. view: pageView
  9091. };
  9092. return {
  9093. first: view,
  9094. last: view,
  9095. views: [view]
  9096. };
  9097. }
  9098. }, {
  9099. key: "_getVisiblePages",
  9100. value: function _getVisiblePages() {
  9101. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._isScrollModeHorizontal);
  9102. }
  9103. }, {
  9104. key: "isPageVisible",
  9105. value: function isPageVisible(pageNumber) {
  9106. if (!this.pdfDocument) {
  9107. return false;
  9108. }
  9109. if (this.pageNumber < 1 || pageNumber > this.pagesCount) {
  9110. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is out of bounds."));
  9111. return false;
  9112. }
  9113. return this._getVisiblePages().views.some(function (view) {
  9114. return view.id === pageNumber;
  9115. });
  9116. }
  9117. }, {
  9118. key: "cleanup",
  9119. value: function cleanup() {
  9120. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9121. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9122. this._pages[i].reset();
  9123. }
  9124. }
  9125. }
  9126. }, {
  9127. key: "_cancelRendering",
  9128. value: function _cancelRendering() {
  9129. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9130. if (this._pages[i]) {
  9131. this._pages[i].cancelRendering();
  9132. }
  9133. }
  9134. }
  9135. }, {
  9136. key: "_ensurePdfPageLoaded",
  9137. value: function _ensurePdfPageLoaded(pageView) {
  9138. var _this3 = this;
  9139. if (pageView.pdfPage) {
  9140. return Promise.resolve(pageView.pdfPage);
  9141. }
  9142. var pageNumber = pageView.id;
  9143. if (this._pagesRequests[pageNumber]) {
  9144. return this._pagesRequests[pageNumber];
  9145. }
  9146. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  9147. if (!pageView.pdfPage) {
  9148. pageView.setPdfPage(pdfPage);
  9149. }
  9150. _this3._pagesRequests[pageNumber] = null;
  9151. return pdfPage;
  9152. })["catch"](function (reason) {
  9153. console.error('Unable to get page for page view', reason);
  9154. _this3._pagesRequests[pageNumber] = null;
  9155. });
  9156. this._pagesRequests[pageNumber] = promise;
  9157. return promise;
  9158. }
  9159. }, {
  9160. key: "forceRendering",
  9161. value: function forceRendering(currentlyVisiblePages) {
  9162. var _this4 = this;
  9163. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  9164. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  9165. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  9166. if (pageView) {
  9167. this._ensurePdfPageLoaded(pageView).then(function () {
  9168. _this4.renderingQueue.renderView(pageView);
  9169. });
  9170. return true;
  9171. }
  9172. return false;
  9173. }
  9174. }, {
  9175. key: "createTextLayerBuilder",
  9176. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  9177. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9178. return new _text_layer_builder.TextLayerBuilder({
  9179. textLayerDiv: textLayerDiv,
  9180. eventBus: this.eventBus,
  9181. pageIndex: pageIndex,
  9182. viewport: viewport,
  9183. findController: this.isInPresentationMode ? null : this.findController,
  9184. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  9185. });
  9186. }
  9187. }, {
  9188. key: "createAnnotationLayerBuilder",
  9189. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9190. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  9191. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9192. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  9193. return new _annotation_layer_builder.AnnotationLayerBuilder({
  9194. pageDiv: pageDiv,
  9195. pdfPage: pdfPage,
  9196. imageResourcesPath: imageResourcesPath,
  9197. renderInteractiveForms: renderInteractiveForms,
  9198. linkService: this.linkService,
  9199. downloadManager: this.downloadManager,
  9200. l10n: l10n
  9201. });
  9202. }
  9203. }, {
  9204. key: "getPagesOverview",
  9205. value: function getPagesOverview() {
  9206. var pagesOverview = this._pages.map(function (pageView) {
  9207. var viewport = pageView.pdfPage.getViewport({
  9208. scale: 1
  9209. });
  9210. return {
  9211. width: viewport.width,
  9212. height: viewport.height,
  9213. rotation: viewport.rotation
  9214. };
  9215. });
  9216. if (!this.enablePrintAutoRotate) {
  9217. return pagesOverview;
  9218. }
  9219. var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]);
  9220. return pagesOverview.map(function (size) {
  9221. if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) {
  9222. return size;
  9223. }
  9224. return {
  9225. width: size.height,
  9226. height: size.width,
  9227. rotation: (size.rotation + 90) % 360
  9228. };
  9229. });
  9230. }
  9231. }, {
  9232. key: "_updateScrollMode",
  9233. value: function _updateScrollMode() {
  9234. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9235. var scrollMode = this._scrollMode,
  9236. viewer = this.viewer;
  9237. viewer.classList.toggle('scrollHorizontal', scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  9238. viewer.classList.toggle('scrollWrapped', scrollMode === _ui_utils.ScrollMode.WRAPPED);
  9239. if (!this.pdfDocument || !pageNumber) {
  9240. return;
  9241. }
  9242. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  9243. this._setScale(this._currentScaleValue, true);
  9244. }
  9245. this._setCurrentPageNumber(pageNumber, true);
  9246. this.update();
  9247. }
  9248. }, {
  9249. key: "_updateSpreadMode",
  9250. value: function _updateSpreadMode() {
  9251. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9252. if (!this.pdfDocument) {
  9253. return;
  9254. }
  9255. var viewer = this.viewer,
  9256. pages = this._pages;
  9257. viewer.textContent = '';
  9258. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  9259. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  9260. viewer.appendChild(pages[i].div);
  9261. }
  9262. } else {
  9263. var parity = this._spreadMode - 1;
  9264. var spread = null;
  9265. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  9266. if (spread === null) {
  9267. spread = document.createElement('div');
  9268. spread.className = 'spread';
  9269. viewer.appendChild(spread);
  9270. } else if (_i % 2 === parity) {
  9271. spread = spread.cloneNode(false);
  9272. viewer.appendChild(spread);
  9273. }
  9274. spread.appendChild(pages[_i].div);
  9275. }
  9276. }
  9277. if (!pageNumber) {
  9278. return;
  9279. }
  9280. this._setCurrentPageNumber(pageNumber, true);
  9281. this.update();
  9282. }
  9283. }, {
  9284. key: "pagesCount",
  9285. get: function get() {
  9286. return this._pages.length;
  9287. }
  9288. }, {
  9289. key: "pageViewsReady",
  9290. get: function get() {
  9291. return this._pageViewsReady;
  9292. }
  9293. }, {
  9294. key: "currentPageNumber",
  9295. get: function get() {
  9296. return this._currentPageNumber;
  9297. },
  9298. set: function set(val) {
  9299. if (!Number.isInteger(val)) {
  9300. throw new Error('Invalid page number.');
  9301. }
  9302. if (!this.pdfDocument) {
  9303. return;
  9304. }
  9305. if (!this._setCurrentPageNumber(val, true)) {
  9306. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  9307. }
  9308. }
  9309. }, {
  9310. key: "currentPageLabel",
  9311. get: function get() {
  9312. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  9313. },
  9314. set: function set(val) {
  9315. if (!this.pdfDocument) {
  9316. return;
  9317. }
  9318. var page = val | 0;
  9319. if (this._pageLabels) {
  9320. var i = this._pageLabels.indexOf(val);
  9321. if (i >= 0) {
  9322. page = i + 1;
  9323. }
  9324. }
  9325. if (!this._setCurrentPageNumber(page, true)) {
  9326. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  9327. }
  9328. }
  9329. }, {
  9330. key: "currentScale",
  9331. get: function get() {
  9332. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  9333. },
  9334. set: function set(val) {
  9335. if (isNaN(val)) {
  9336. throw new Error('Invalid numeric scale.');
  9337. }
  9338. if (!this.pdfDocument) {
  9339. return;
  9340. }
  9341. this._setScale(val, false);
  9342. }
  9343. }, {
  9344. key: "currentScaleValue",
  9345. get: function get() {
  9346. return this._currentScaleValue;
  9347. },
  9348. set: function set(val) {
  9349. if (!this.pdfDocument) {
  9350. return;
  9351. }
  9352. this._setScale(val, false);
  9353. }
  9354. }, {
  9355. key: "pagesRotation",
  9356. get: function get() {
  9357. return this._pagesRotation;
  9358. },
  9359. set: function set(rotation) {
  9360. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  9361. throw new Error('Invalid pages rotation angle.');
  9362. }
  9363. if (!this.pdfDocument) {
  9364. return;
  9365. }
  9366. if (this._pagesRotation === rotation) {
  9367. return;
  9368. }
  9369. this._pagesRotation = rotation;
  9370. var pageNumber = this._currentPageNumber;
  9371. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9372. var pageView = this._pages[i];
  9373. pageView.update(pageView.scale, rotation);
  9374. }
  9375. if (this._currentScaleValue) {
  9376. this._setScale(this._currentScaleValue, true);
  9377. }
  9378. this.eventBus.dispatch('rotationchanging', {
  9379. source: this,
  9380. pagesRotation: rotation,
  9381. pageNumber: pageNumber
  9382. });
  9383. if (this.defaultRenderingQueue) {
  9384. this.update();
  9385. }
  9386. }
  9387. }, {
  9388. key: "_setDocumentViewerElement",
  9389. get: function get() {
  9390. throw new Error('Not implemented: _setDocumentViewerElement');
  9391. }
  9392. }, {
  9393. key: "_isScrollModeHorizontal",
  9394. get: function get() {
  9395. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  9396. }
  9397. }, {
  9398. key: "isInPresentationMode",
  9399. get: function get() {
  9400. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  9401. }
  9402. }, {
  9403. key: "isChangingPresentationMode",
  9404. get: function get() {
  9405. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  9406. }
  9407. }, {
  9408. key: "isHorizontalScrollbarEnabled",
  9409. get: function get() {
  9410. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  9411. }
  9412. }, {
  9413. key: "isVerticalScrollbarEnabled",
  9414. get: function get() {
  9415. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  9416. }
  9417. }, {
  9418. key: "hasEqualPageSizes",
  9419. get: function get() {
  9420. var firstPageView = this._pages[0];
  9421. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  9422. var pageView = this._pages[i];
  9423. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  9424. return false;
  9425. }
  9426. }
  9427. return true;
  9428. }
  9429. }, {
  9430. key: "scrollMode",
  9431. get: function get() {
  9432. return this._scrollMode;
  9433. },
  9434. set: function set(mode) {
  9435. if (this._scrollMode === mode) {
  9436. return;
  9437. }
  9438. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  9439. throw new Error("Invalid scroll mode: ".concat(mode));
  9440. }
  9441. this._scrollMode = mode;
  9442. this.eventBus.dispatch('scrollmodechanged', {
  9443. source: this,
  9444. mode: mode
  9445. });
  9446. this._updateScrollMode(this._currentPageNumber);
  9447. }
  9448. }, {
  9449. key: "spreadMode",
  9450. get: function get() {
  9451. return this._spreadMode;
  9452. },
  9453. set: function set(mode) {
  9454. if (this._spreadMode === mode) {
  9455. return;
  9456. }
  9457. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  9458. throw new Error("Invalid spread mode: ".concat(mode));
  9459. }
  9460. this._spreadMode = mode;
  9461. this.eventBus.dispatch('spreadmodechanged', {
  9462. source: this,
  9463. mode: mode
  9464. });
  9465. this._updateSpreadMode(this._currentPageNumber);
  9466. }
  9467. }]);
  9468. return BaseViewer;
  9469. }();
  9470. exports.BaseViewer = BaseViewer;
  9471. /***/ }),
  9472. /* 29 */
  9473. /***/ (function(module, exports, __webpack_require__) {
  9474. "use strict";
  9475. Object.defineProperty(exports, "__esModule", {
  9476. value: true
  9477. });
  9478. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  9479. var _pdfjsLib = __webpack_require__(7);
  9480. var _ui_utils = __webpack_require__(5);
  9481. var _pdf_link_service = __webpack_require__(21);
  9482. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9483. 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); } }
  9484. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9485. var AnnotationLayerBuilder =
  9486. /*#__PURE__*/
  9487. function () {
  9488. function AnnotationLayerBuilder(_ref) {
  9489. var pageDiv = _ref.pageDiv,
  9490. pdfPage = _ref.pdfPage,
  9491. linkService = _ref.linkService,
  9492. downloadManager = _ref.downloadManager,
  9493. _ref$imageResourcesPa = _ref.imageResourcesPath,
  9494. imageResourcesPath = _ref$imageResourcesPa === void 0 ? '' : _ref$imageResourcesPa,
  9495. _ref$renderInteractiv = _ref.renderInteractiveForms,
  9496. renderInteractiveForms = _ref$renderInteractiv === void 0 ? false : _ref$renderInteractiv,
  9497. _ref$l10n = _ref.l10n,
  9498. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9499. _classCallCheck(this, AnnotationLayerBuilder);
  9500. this.pageDiv = pageDiv;
  9501. this.pdfPage = pdfPage;
  9502. this.linkService = linkService;
  9503. this.downloadManager = downloadManager;
  9504. this.imageResourcesPath = imageResourcesPath;
  9505. this.renderInteractiveForms = renderInteractiveForms;
  9506. this.l10n = l10n;
  9507. this.div = null;
  9508. this._cancelled = false;
  9509. }
  9510. _createClass(AnnotationLayerBuilder, [{
  9511. key: "render",
  9512. value: function render(viewport) {
  9513. var _this = this;
  9514. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
  9515. this.pdfPage.getAnnotations({
  9516. intent: intent
  9517. }).then(function (annotations) {
  9518. if (_this._cancelled) {
  9519. return;
  9520. }
  9521. var parameters = {
  9522. viewport: viewport.clone({
  9523. dontFlip: true
  9524. }),
  9525. div: _this.div,
  9526. annotations: annotations,
  9527. page: _this.pdfPage,
  9528. imageResourcesPath: _this.imageResourcesPath,
  9529. renderInteractiveForms: _this.renderInteractiveForms,
  9530. linkService: _this.linkService,
  9531. downloadManager: _this.downloadManager
  9532. };
  9533. if (_this.div) {
  9534. _pdfjsLib.AnnotationLayer.update(parameters);
  9535. } else {
  9536. if (annotations.length === 0) {
  9537. return;
  9538. }
  9539. _this.div = document.createElement('div');
  9540. _this.div.className = 'annotationLayer';
  9541. _this.pageDiv.appendChild(_this.div);
  9542. parameters.div = _this.div;
  9543. _pdfjsLib.AnnotationLayer.render(parameters);
  9544. _this.l10n.translate(_this.div);
  9545. }
  9546. });
  9547. }
  9548. }, {
  9549. key: "cancel",
  9550. value: function cancel() {
  9551. this._cancelled = true;
  9552. }
  9553. }, {
  9554. key: "hide",
  9555. value: function hide() {
  9556. if (!this.div) {
  9557. return;
  9558. }
  9559. this.div.setAttribute('hidden', 'true');
  9560. }
  9561. }]);
  9562. return AnnotationLayerBuilder;
  9563. }();
  9564. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  9565. var DefaultAnnotationLayerFactory =
  9566. /*#__PURE__*/
  9567. function () {
  9568. function DefaultAnnotationLayerFactory() {
  9569. _classCallCheck(this, DefaultAnnotationLayerFactory);
  9570. }
  9571. _createClass(DefaultAnnotationLayerFactory, [{
  9572. key: "createAnnotationLayerBuilder",
  9573. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9574. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  9575. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9576. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  9577. return new AnnotationLayerBuilder({
  9578. pageDiv: pageDiv,
  9579. pdfPage: pdfPage,
  9580. imageResourcesPath: imageResourcesPath,
  9581. renderInteractiveForms: renderInteractiveForms,
  9582. linkService: new _pdf_link_service.SimpleLinkService(),
  9583. l10n: l10n
  9584. });
  9585. }
  9586. }]);
  9587. return DefaultAnnotationLayerFactory;
  9588. }();
  9589. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  9590. /***/ }),
  9591. /* 30 */
  9592. /***/ (function(module, exports, __webpack_require__) {
  9593. "use strict";
  9594. Object.defineProperty(exports, "__esModule", {
  9595. value: true
  9596. });
  9597. exports.PDFPageView = void 0;
  9598. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  9599. var _ui_utils = __webpack_require__(5);
  9600. var _pdfjsLib = __webpack_require__(7);
  9601. var _pdf_rendering_queue = __webpack_require__(11);
  9602. var _viewer_compatibility = __webpack_require__(8);
  9603. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9604. 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); } }
  9605. 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); }); }; }
  9606. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9607. 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); } }
  9608. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9609. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  9610. var PDFPageView =
  9611. /*#__PURE__*/
  9612. function () {
  9613. function PDFPageView(options) {
  9614. _classCallCheck(this, PDFPageView);
  9615. var container = options.container;
  9616. var defaultViewport = options.defaultViewport;
  9617. this.id = options.id;
  9618. this.renderingId = 'page' + this.id;
  9619. this.pdfPage = null;
  9620. this.pageLabel = null;
  9621. this.rotation = 0;
  9622. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  9623. this.viewport = defaultViewport;
  9624. this.pdfPageRotate = defaultViewport.rotation;
  9625. this.hasRestrictedScaling = false;
  9626. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  9627. this.imageResourcesPath = options.imageResourcesPath || '';
  9628. this.renderInteractiveForms = options.renderInteractiveForms || false;
  9629. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  9630. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  9631. this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
  9632. this.renderingQueue = options.renderingQueue;
  9633. this.textLayerFactory = options.textLayerFactory;
  9634. this.annotationLayerFactory = options.annotationLayerFactory;
  9635. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  9636. this.enableWebGL = options.enableWebGL || false;
  9637. this.l10n = options.l10n || _ui_utils.NullL10n;
  9638. this.paintTask = null;
  9639. this.paintedViewportMap = new WeakMap();
  9640. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9641. this.resume = null;
  9642. this.error = null;
  9643. this.onBeforeDraw = null;
  9644. this.onAfterDraw = null;
  9645. this.annotationLayer = null;
  9646. this.textLayer = null;
  9647. this.zoomLayer = null;
  9648. var div = document.createElement('div');
  9649. div.className = 'page';
  9650. div.style.width = Math.floor(this.viewport.width) + 'px';
  9651. div.style.height = Math.floor(this.viewport.height) + 'px';
  9652. div.setAttribute('data-page-number', this.id);
  9653. this.div = div;
  9654. container.appendChild(div);
  9655. }
  9656. _createClass(PDFPageView, [{
  9657. key: "setPdfPage",
  9658. value: function setPdfPage(pdfPage) {
  9659. this.pdfPage = pdfPage;
  9660. this.pdfPageRotate = pdfPage.rotate;
  9661. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9662. this.viewport = pdfPage.getViewport({
  9663. scale: this.scale * _ui_utils.CSS_UNITS,
  9664. rotation: totalRotation
  9665. });
  9666. this.stats = pdfPage.stats;
  9667. this.reset();
  9668. }
  9669. }, {
  9670. key: "destroy",
  9671. value: function destroy() {
  9672. this.reset();
  9673. if (this.pdfPage) {
  9674. this.pdfPage.cleanup();
  9675. }
  9676. }
  9677. }, {
  9678. key: "_resetZoomLayer",
  9679. value: function _resetZoomLayer() {
  9680. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9681. if (!this.zoomLayer) {
  9682. return;
  9683. }
  9684. var zoomLayerCanvas = this.zoomLayer.firstChild;
  9685. this.paintedViewportMap["delete"](zoomLayerCanvas);
  9686. zoomLayerCanvas.width = 0;
  9687. zoomLayerCanvas.height = 0;
  9688. if (removeFromDOM) {
  9689. this.zoomLayer.remove();
  9690. }
  9691. this.zoomLayer = null;
  9692. }
  9693. }, {
  9694. key: "reset",
  9695. value: function reset() {
  9696. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9697. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9698. this.cancelRendering(keepAnnotations);
  9699. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9700. var div = this.div;
  9701. div.style.width = Math.floor(this.viewport.width) + 'px';
  9702. div.style.height = Math.floor(this.viewport.height) + 'px';
  9703. var childNodes = div.childNodes;
  9704. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  9705. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  9706. for (var i = childNodes.length - 1; i >= 0; i--) {
  9707. var node = childNodes[i];
  9708. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  9709. continue;
  9710. }
  9711. div.removeChild(node);
  9712. }
  9713. div.removeAttribute('data-loaded');
  9714. if (currentAnnotationNode) {
  9715. this.annotationLayer.hide();
  9716. } else if (this.annotationLayer) {
  9717. this.annotationLayer.cancel();
  9718. this.annotationLayer = null;
  9719. }
  9720. if (!currentZoomLayerNode) {
  9721. if (this.canvas) {
  9722. this.paintedViewportMap["delete"](this.canvas);
  9723. this.canvas.width = 0;
  9724. this.canvas.height = 0;
  9725. delete this.canvas;
  9726. }
  9727. this._resetZoomLayer();
  9728. }
  9729. if (this.svg) {
  9730. this.paintedViewportMap["delete"](this.svg);
  9731. delete this.svg;
  9732. }
  9733. this.loadingIconDiv = document.createElement('div');
  9734. this.loadingIconDiv.className = 'loadingIcon';
  9735. div.appendChild(this.loadingIconDiv);
  9736. }
  9737. }, {
  9738. key: "update",
  9739. value: function update(scale, rotation) {
  9740. this.scale = scale || this.scale;
  9741. if (typeof rotation !== 'undefined') {
  9742. this.rotation = rotation;
  9743. }
  9744. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9745. this.viewport = this.viewport.clone({
  9746. scale: this.scale * _ui_utils.CSS_UNITS,
  9747. rotation: totalRotation
  9748. });
  9749. if (this.svg) {
  9750. this.cssTransform(this.svg, true);
  9751. this.eventBus.dispatch('pagerendered', {
  9752. source: this,
  9753. pageNumber: this.id,
  9754. cssTransform: true
  9755. });
  9756. return;
  9757. }
  9758. var isScalingRestricted = false;
  9759. if (this.canvas && this.maxCanvasPixels > 0) {
  9760. var outputScale = this.outputScale;
  9761. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  9762. isScalingRestricted = true;
  9763. }
  9764. }
  9765. if (this.canvas) {
  9766. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  9767. this.cssTransform(this.canvas, true);
  9768. this.eventBus.dispatch('pagerendered', {
  9769. source: this,
  9770. pageNumber: this.id,
  9771. cssTransform: true
  9772. });
  9773. return;
  9774. }
  9775. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  9776. this.zoomLayer = this.canvas.parentNode;
  9777. this.zoomLayer.style.position = 'absolute';
  9778. }
  9779. }
  9780. if (this.zoomLayer) {
  9781. this.cssTransform(this.zoomLayer.firstChild);
  9782. }
  9783. this.reset(true, true);
  9784. }
  9785. }, {
  9786. key: "cancelRendering",
  9787. value: function cancelRendering() {
  9788. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9789. if (this.paintTask) {
  9790. this.paintTask.cancel();
  9791. this.paintTask = null;
  9792. }
  9793. this.resume = null;
  9794. if (this.textLayer) {
  9795. this.textLayer.cancel();
  9796. this.textLayer = null;
  9797. }
  9798. if (!keepAnnotations && this.annotationLayer) {
  9799. this.annotationLayer.cancel();
  9800. this.annotationLayer = null;
  9801. }
  9802. }
  9803. }, {
  9804. key: "cssTransform",
  9805. value: function cssTransform(target) {
  9806. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9807. var width = this.viewport.width;
  9808. var height = this.viewport.height;
  9809. var div = this.div;
  9810. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
  9811. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
  9812. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  9813. var absRotation = Math.abs(relativeRotation);
  9814. var scaleX = 1,
  9815. scaleY = 1;
  9816. if (absRotation === 90 || absRotation === 270) {
  9817. scaleX = height / width;
  9818. scaleY = width / height;
  9819. }
  9820. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
  9821. target.style.transform = cssTransform;
  9822. if (this.textLayer) {
  9823. var textLayerViewport = this.textLayer.viewport;
  9824. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  9825. var textAbsRotation = Math.abs(textRelativeRotation);
  9826. var scale = width / textLayerViewport.width;
  9827. if (textAbsRotation === 90 || textAbsRotation === 270) {
  9828. scale = width / textLayerViewport.height;
  9829. }
  9830. var textLayerDiv = this.textLayer.textLayerDiv;
  9831. var transX, transY;
  9832. switch (textAbsRotation) {
  9833. case 0:
  9834. transX = transY = 0;
  9835. break;
  9836. case 90:
  9837. transX = 0;
  9838. transY = '-' + textLayerDiv.style.height;
  9839. break;
  9840. case 180:
  9841. transX = '-' + textLayerDiv.style.width;
  9842. transY = '-' + textLayerDiv.style.height;
  9843. break;
  9844. case 270:
  9845. transX = '-' + textLayerDiv.style.width;
  9846. transY = 0;
  9847. break;
  9848. default:
  9849. console.error('Bad rotation value.');
  9850. break;
  9851. }
  9852. textLayerDiv.style.transform = 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')';
  9853. textLayerDiv.style.transformOrigin = '0% 0%';
  9854. }
  9855. if (redrawAnnotations && this.annotationLayer) {
  9856. this.annotationLayer.render(this.viewport, 'display');
  9857. }
  9858. }
  9859. }, {
  9860. key: "getPagePoint",
  9861. value: function getPagePoint(x, y) {
  9862. return this.viewport.convertToPdfPoint(x, y);
  9863. }
  9864. }, {
  9865. key: "draw",
  9866. value: function draw() {
  9867. var _this = this;
  9868. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  9869. console.error('Must be in new state before drawing');
  9870. this.reset();
  9871. }
  9872. if (!this.pdfPage) {
  9873. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9874. return Promise.reject(new Error('Page is not loaded'));
  9875. }
  9876. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9877. var pdfPage = this.pdfPage;
  9878. var div = this.div;
  9879. var canvasWrapper = document.createElement('div');
  9880. canvasWrapper.style.width = div.style.width;
  9881. canvasWrapper.style.height = div.style.height;
  9882. canvasWrapper.classList.add('canvasWrapper');
  9883. if (this.annotationLayer && this.annotationLayer.div) {
  9884. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  9885. } else {
  9886. div.appendChild(canvasWrapper);
  9887. }
  9888. var textLayer = null;
  9889. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  9890. var textLayerDiv = document.createElement('div');
  9891. textLayerDiv.className = 'textLayer';
  9892. textLayerDiv.style.width = canvasWrapper.style.width;
  9893. textLayerDiv.style.height = canvasWrapper.style.height;
  9894. if (this.annotationLayer && this.annotationLayer.div) {
  9895. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  9896. } else {
  9897. div.appendChild(textLayerDiv);
  9898. }
  9899. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE);
  9900. }
  9901. this.textLayer = textLayer;
  9902. var renderContinueCallback = null;
  9903. if (this.renderingQueue) {
  9904. renderContinueCallback = function renderContinueCallback(cont) {
  9905. if (!_this.renderingQueue.isHighestPriority(_this)) {
  9906. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  9907. _this.resume = function () {
  9908. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9909. cont();
  9910. };
  9911. return;
  9912. }
  9913. cont();
  9914. };
  9915. }
  9916. var finishPaintTask =
  9917. /*#__PURE__*/
  9918. function () {
  9919. var _ref = _asyncToGenerator(
  9920. /*#__PURE__*/
  9921. _regenerator["default"].mark(function _callee(error) {
  9922. return _regenerator["default"].wrap(function _callee$(_context) {
  9923. while (1) {
  9924. switch (_context.prev = _context.next) {
  9925. case 0:
  9926. if (paintTask === _this.paintTask) {
  9927. _this.paintTask = null;
  9928. }
  9929. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  9930. _context.next = 4;
  9931. break;
  9932. }
  9933. _this.error = null;
  9934. return _context.abrupt("return");
  9935. case 4:
  9936. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9937. if (_this.loadingIconDiv) {
  9938. div.removeChild(_this.loadingIconDiv);
  9939. delete _this.loadingIconDiv;
  9940. }
  9941. _this._resetZoomLayer(true);
  9942. _this.error = error;
  9943. _this.stats = pdfPage.stats;
  9944. if (_this.onAfterDraw) {
  9945. _this.onAfterDraw();
  9946. }
  9947. _this.eventBus.dispatch('pagerendered', {
  9948. source: _this,
  9949. pageNumber: _this.id,
  9950. cssTransform: false
  9951. });
  9952. if (!error) {
  9953. _context.next = 13;
  9954. break;
  9955. }
  9956. throw error;
  9957. case 13:
  9958. case "end":
  9959. return _context.stop();
  9960. }
  9961. }
  9962. }, _callee);
  9963. }));
  9964. return function finishPaintTask(_x) {
  9965. return _ref.apply(this, arguments);
  9966. };
  9967. }();
  9968. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  9969. paintTask.onRenderContinue = renderContinueCallback;
  9970. this.paintTask = paintTask;
  9971. var resultPromise = paintTask.promise.then(function () {
  9972. return finishPaintTask(null).then(function () {
  9973. if (textLayer) {
  9974. var readableStream = pdfPage.streamTextContent({
  9975. normalizeWhitespace: true
  9976. });
  9977. textLayer.setTextContentStream(readableStream);
  9978. textLayer.render();
  9979. }
  9980. });
  9981. }, function (reason) {
  9982. return finishPaintTask(reason);
  9983. });
  9984. if (this.annotationLayerFactory) {
  9985. if (!this.annotationLayer) {
  9986. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  9987. }
  9988. this.annotationLayer.render(this.viewport, 'display');
  9989. }
  9990. div.setAttribute('data-loaded', true);
  9991. if (this.onBeforeDraw) {
  9992. this.onBeforeDraw();
  9993. }
  9994. return resultPromise;
  9995. }
  9996. }, {
  9997. key: "paintOnCanvas",
  9998. value: function paintOnCanvas(canvasWrapper) {
  9999. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  10000. var result = {
  10001. promise: renderCapability.promise,
  10002. onRenderContinue: function onRenderContinue(cont) {
  10003. cont();
  10004. },
  10005. cancel: function cancel() {
  10006. renderTask.cancel();
  10007. }
  10008. };
  10009. var viewport = this.viewport;
  10010. var canvas = document.createElement('canvas');
  10011. canvas.id = this.renderingId;
  10012. canvas.setAttribute('hidden', 'hidden');
  10013. var isCanvasHidden = true;
  10014. var showCanvas = function showCanvas() {
  10015. if (isCanvasHidden) {
  10016. canvas.removeAttribute('hidden');
  10017. isCanvasHidden = false;
  10018. }
  10019. };
  10020. canvasWrapper.appendChild(canvas);
  10021. this.canvas = canvas;
  10022. canvas.mozOpaque = true;
  10023. var ctx = canvas.getContext('2d', {
  10024. alpha: false
  10025. });
  10026. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  10027. this.outputScale = outputScale;
  10028. if (this.useOnlyCssZoom) {
  10029. var actualSizeViewport = viewport.clone({
  10030. scale: _ui_utils.CSS_UNITS
  10031. });
  10032. outputScale.sx *= actualSizeViewport.width / viewport.width;
  10033. outputScale.sy *= actualSizeViewport.height / viewport.height;
  10034. outputScale.scaled = true;
  10035. }
  10036. if (this.maxCanvasPixels > 0) {
  10037. var pixelsInViewport = viewport.width * viewport.height;
  10038. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  10039. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  10040. outputScale.sx = maxScale;
  10041. outputScale.sy = maxScale;
  10042. outputScale.scaled = true;
  10043. this.hasRestrictedScaling = true;
  10044. } else {
  10045. this.hasRestrictedScaling = false;
  10046. }
  10047. }
  10048. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  10049. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  10050. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  10051. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  10052. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
  10053. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
  10054. this.paintedViewportMap.set(canvas, viewport);
  10055. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  10056. var renderContext = {
  10057. canvasContext: ctx,
  10058. transform: transform,
  10059. viewport: this.viewport,
  10060. enableWebGL: this.enableWebGL,
  10061. renderInteractiveForms: this.renderInteractiveForms
  10062. };
  10063. var renderTask = this.pdfPage.render(renderContext);
  10064. renderTask.onContinue = function (cont) {
  10065. showCanvas();
  10066. if (result.onRenderContinue) {
  10067. result.onRenderContinue(cont);
  10068. } else {
  10069. cont();
  10070. }
  10071. };
  10072. renderTask.promise.then(function () {
  10073. showCanvas();
  10074. renderCapability.resolve(undefined);
  10075. }, function (error) {
  10076. showCanvas();
  10077. renderCapability.reject(error);
  10078. });
  10079. return result;
  10080. }
  10081. }, {
  10082. key: "paintOnSvg",
  10083. value: function paintOnSvg(wrapper) {
  10084. var _this2 = this;
  10085. var cancelled = false;
  10086. var ensureNotCancelled = function ensureNotCancelled() {
  10087. if (cancelled) {
  10088. throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
  10089. }
  10090. };
  10091. var pdfPage = this.pdfPage;
  10092. var actualSizeViewport = this.viewport.clone({
  10093. scale: _ui_utils.CSS_UNITS
  10094. });
  10095. var promise = pdfPage.getOperatorList().then(function (opList) {
  10096. ensureNotCancelled();
  10097. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  10098. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  10099. ensureNotCancelled();
  10100. _this2.svg = svg;
  10101. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  10102. svg.style.width = wrapper.style.width;
  10103. svg.style.height = wrapper.style.height;
  10104. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10105. wrapper.appendChild(svg);
  10106. });
  10107. });
  10108. return {
  10109. promise: promise,
  10110. onRenderContinue: function onRenderContinue(cont) {
  10111. cont();
  10112. },
  10113. cancel: function cancel() {
  10114. cancelled = true;
  10115. }
  10116. };
  10117. }
  10118. }, {
  10119. key: "setPageLabel",
  10120. value: function setPageLabel(label) {
  10121. this.pageLabel = typeof label === 'string' ? label : null;
  10122. if (this.pageLabel !== null) {
  10123. this.div.setAttribute('data-page-label', this.pageLabel);
  10124. } else {
  10125. this.div.removeAttribute('data-page-label');
  10126. }
  10127. }
  10128. }, {
  10129. key: "width",
  10130. get: function get() {
  10131. return this.viewport.width;
  10132. }
  10133. }, {
  10134. key: "height",
  10135. get: function get() {
  10136. return this.viewport.height;
  10137. }
  10138. }]);
  10139. return PDFPageView;
  10140. }();
  10141. exports.PDFPageView = PDFPageView;
  10142. /***/ }),
  10143. /* 31 */
  10144. /***/ (function(module, exports, __webpack_require__) {
  10145. "use strict";
  10146. Object.defineProperty(exports, "__esModule", {
  10147. value: true
  10148. });
  10149. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
  10150. var _ui_utils = __webpack_require__(5);
  10151. var _pdfjsLib = __webpack_require__(7);
  10152. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10153. 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); } }
  10154. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10155. var EXPAND_DIVS_TIMEOUT = 300;
  10156. var TextLayerBuilder =
  10157. /*#__PURE__*/
  10158. function () {
  10159. function TextLayerBuilder(_ref) {
  10160. var textLayerDiv = _ref.textLayerDiv,
  10161. eventBus = _ref.eventBus,
  10162. pageIndex = _ref.pageIndex,
  10163. viewport = _ref.viewport,
  10164. _ref$findController = _ref.findController,
  10165. findController = _ref$findController === void 0 ? null : _ref$findController,
  10166. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  10167. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  10168. _classCallCheck(this, TextLayerBuilder);
  10169. this.textLayerDiv = textLayerDiv;
  10170. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  10171. this.textContent = null;
  10172. this.textContentItemsStr = [];
  10173. this.textContentStream = null;
  10174. this.renderingDone = false;
  10175. this.pageIdx = pageIndex;
  10176. this.pageNumber = this.pageIdx + 1;
  10177. this.matches = [];
  10178. this.viewport = viewport;
  10179. this.textDivs = [];
  10180. this.findController = findController;
  10181. this.textLayerRenderTask = null;
  10182. this.enhanceTextSelection = enhanceTextSelection;
  10183. this._onUpdateTextLayerMatches = null;
  10184. this._bindMouse();
  10185. }
  10186. _createClass(TextLayerBuilder, [{
  10187. key: "_finishRendering",
  10188. value: function _finishRendering() {
  10189. this.renderingDone = true;
  10190. if (!this.enhanceTextSelection) {
  10191. var endOfContent = document.createElement('div');
  10192. endOfContent.className = 'endOfContent';
  10193. this.textLayerDiv.appendChild(endOfContent);
  10194. }
  10195. this.eventBus.dispatch('textlayerrendered', {
  10196. source: this,
  10197. pageNumber: this.pageNumber,
  10198. numTextDivs: this.textDivs.length
  10199. });
  10200. }
  10201. }, {
  10202. key: "render",
  10203. value: function render() {
  10204. var _this = this;
  10205. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10206. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  10207. return;
  10208. }
  10209. this.cancel();
  10210. this.textDivs = [];
  10211. var textLayerFrag = document.createDocumentFragment();
  10212. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  10213. textContent: this.textContent,
  10214. textContentStream: this.textContentStream,
  10215. container: textLayerFrag,
  10216. viewport: this.viewport,
  10217. textDivs: this.textDivs,
  10218. textContentItemsStr: this.textContentItemsStr,
  10219. timeout: timeout,
  10220. enhanceTextSelection: this.enhanceTextSelection
  10221. });
  10222. this.textLayerRenderTask.promise.then(function () {
  10223. _this.textLayerDiv.appendChild(textLayerFrag);
  10224. _this._finishRendering();
  10225. _this._updateMatches();
  10226. }, function (reason) {});
  10227. if (!this._onUpdateTextLayerMatches) {
  10228. this._onUpdateTextLayerMatches = function (evt) {
  10229. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  10230. _this._updateMatches();
  10231. }
  10232. };
  10233. this.eventBus.on('updatetextlayermatches', this._onUpdateTextLayerMatches);
  10234. }
  10235. }
  10236. }, {
  10237. key: "cancel",
  10238. value: function cancel() {
  10239. if (this.textLayerRenderTask) {
  10240. this.textLayerRenderTask.cancel();
  10241. this.textLayerRenderTask = null;
  10242. }
  10243. if (this._onUpdateTextLayerMatches) {
  10244. this.eventBus.off('updatetextlayermatches', this._onUpdateTextLayerMatches);
  10245. this._onUpdateTextLayerMatches = null;
  10246. }
  10247. }
  10248. }, {
  10249. key: "setTextContentStream",
  10250. value: function setTextContentStream(readableStream) {
  10251. this.cancel();
  10252. this.textContentStream = readableStream;
  10253. }
  10254. }, {
  10255. key: "setTextContent",
  10256. value: function setTextContent(textContent) {
  10257. this.cancel();
  10258. this.textContent = textContent;
  10259. }
  10260. }, {
  10261. key: "_convertMatches",
  10262. value: function _convertMatches(matches, matchesLength) {
  10263. if (!matches) {
  10264. return [];
  10265. }
  10266. var findController = this.findController,
  10267. textContentItemsStr = this.textContentItemsStr;
  10268. var i = 0,
  10269. iIndex = 0;
  10270. var end = textContentItemsStr.length - 1;
  10271. var queryLen = findController.state.query.length;
  10272. var result = [];
  10273. for (var m = 0, mm = matches.length; m < mm; m++) {
  10274. var matchIdx = matches[m];
  10275. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  10276. iIndex += textContentItemsStr[i].length;
  10277. i++;
  10278. }
  10279. if (i === textContentItemsStr.length) {
  10280. console.error('Could not find a matching mapping');
  10281. }
  10282. var match = {
  10283. begin: {
  10284. divIdx: i,
  10285. offset: matchIdx - iIndex
  10286. }
  10287. };
  10288. if (matchesLength) {
  10289. matchIdx += matchesLength[m];
  10290. } else {
  10291. matchIdx += queryLen;
  10292. }
  10293. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  10294. iIndex += textContentItemsStr[i].length;
  10295. i++;
  10296. }
  10297. match.end = {
  10298. divIdx: i,
  10299. offset: matchIdx - iIndex
  10300. };
  10301. result.push(match);
  10302. }
  10303. return result;
  10304. }
  10305. }, {
  10306. key: "_renderMatches",
  10307. value: function _renderMatches(matches) {
  10308. if (matches.length === 0) {
  10309. return;
  10310. }
  10311. var findController = this.findController,
  10312. pageIdx = this.pageIdx,
  10313. textContentItemsStr = this.textContentItemsStr,
  10314. textDivs = this.textDivs;
  10315. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  10316. var selectedMatchIdx = findController.selected.matchIdx;
  10317. var highlightAll = findController.state.highlightAll;
  10318. var prevEnd = null;
  10319. var infinity = {
  10320. divIdx: -1,
  10321. offset: undefined
  10322. };
  10323. function beginText(begin, className) {
  10324. var divIdx = begin.divIdx;
  10325. textDivs[divIdx].textContent = '';
  10326. appendTextToDiv(divIdx, 0, begin.offset, className);
  10327. }
  10328. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  10329. var div = textDivs[divIdx];
  10330. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  10331. var node = document.createTextNode(content);
  10332. if (className) {
  10333. var span = document.createElement('span');
  10334. span.className = className;
  10335. span.appendChild(node);
  10336. div.appendChild(span);
  10337. return;
  10338. }
  10339. div.appendChild(node);
  10340. }
  10341. var i0 = selectedMatchIdx,
  10342. i1 = i0 + 1;
  10343. if (highlightAll) {
  10344. i0 = 0;
  10345. i1 = matches.length;
  10346. } else if (!isSelectedPage) {
  10347. return;
  10348. }
  10349. for (var i = i0; i < i1; i++) {
  10350. var match = matches[i];
  10351. var begin = match.begin;
  10352. var end = match.end;
  10353. var isSelected = isSelectedPage && i === selectedMatchIdx;
  10354. var highlightSuffix = isSelected ? ' selected' : '';
  10355. if (isSelected) {
  10356. findController.scrollMatchIntoView({
  10357. element: textDivs[begin.divIdx],
  10358. pageIndex: pageIdx,
  10359. matchIndex: selectedMatchIdx
  10360. });
  10361. }
  10362. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  10363. if (prevEnd !== null) {
  10364. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  10365. }
  10366. beginText(begin);
  10367. } else {
  10368. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  10369. }
  10370. if (begin.divIdx === end.divIdx) {
  10371. appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
  10372. } else {
  10373. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
  10374. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  10375. textDivs[n0].className = 'highlight middle' + highlightSuffix;
  10376. }
  10377. beginText(end, 'highlight end' + highlightSuffix);
  10378. }
  10379. prevEnd = end;
  10380. }
  10381. if (prevEnd) {
  10382. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  10383. }
  10384. }
  10385. }, {
  10386. key: "_updateMatches",
  10387. value: function _updateMatches() {
  10388. if (!this.renderingDone) {
  10389. return;
  10390. }
  10391. var findController = this.findController,
  10392. matches = this.matches,
  10393. pageIdx = this.pageIdx,
  10394. textContentItemsStr = this.textContentItemsStr,
  10395. textDivs = this.textDivs;
  10396. var clearedUntilDivIdx = -1;
  10397. for (var i = 0, ii = matches.length; i < ii; i++) {
  10398. var match = matches[i];
  10399. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  10400. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  10401. var div = textDivs[n];
  10402. div.textContent = textContentItemsStr[n];
  10403. div.className = '';
  10404. }
  10405. clearedUntilDivIdx = match.end.divIdx + 1;
  10406. }
  10407. if (!findController || !findController.highlightMatches) {
  10408. return;
  10409. }
  10410. var pageMatches = findController.pageMatches[pageIdx] || null;
  10411. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  10412. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  10413. this._renderMatches(this.matches);
  10414. }
  10415. }, {
  10416. key: "_bindMouse",
  10417. value: function _bindMouse() {
  10418. var _this2 = this;
  10419. var div = this.textLayerDiv;
  10420. var expandDivsTimer = null;
  10421. div.addEventListener('mousedown', function (evt) {
  10422. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  10423. _this2.textLayerRenderTask.expandTextDivs(true);
  10424. if (expandDivsTimer) {
  10425. clearTimeout(expandDivsTimer);
  10426. expandDivsTimer = null;
  10427. }
  10428. return;
  10429. }
  10430. var end = div.querySelector('.endOfContent');
  10431. if (!end) {
  10432. return;
  10433. }
  10434. var adjustTop = evt.target !== div;
  10435. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
  10436. if (adjustTop) {
  10437. var divBounds = div.getBoundingClientRect();
  10438. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  10439. end.style.top = (r * 100).toFixed(2) + '%';
  10440. }
  10441. end.classList.add('active');
  10442. });
  10443. div.addEventListener('mouseup', function () {
  10444. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  10445. expandDivsTimer = setTimeout(function () {
  10446. if (_this2.textLayerRenderTask) {
  10447. _this2.textLayerRenderTask.expandTextDivs(false);
  10448. }
  10449. expandDivsTimer = null;
  10450. }, EXPAND_DIVS_TIMEOUT);
  10451. return;
  10452. }
  10453. var end = div.querySelector('.endOfContent');
  10454. if (!end) {
  10455. return;
  10456. }
  10457. end.style.top = '';
  10458. end.classList.remove('active');
  10459. });
  10460. }
  10461. }]);
  10462. return TextLayerBuilder;
  10463. }();
  10464. exports.TextLayerBuilder = TextLayerBuilder;
  10465. var DefaultTextLayerFactory =
  10466. /*#__PURE__*/
  10467. function () {
  10468. function DefaultTextLayerFactory() {
  10469. _classCallCheck(this, DefaultTextLayerFactory);
  10470. }
  10471. _createClass(DefaultTextLayerFactory, [{
  10472. key: "createTextLayerBuilder",
  10473. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  10474. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10475. return new TextLayerBuilder({
  10476. textLayerDiv: textLayerDiv,
  10477. pageIndex: pageIndex,
  10478. viewport: viewport,
  10479. enhanceTextSelection: enhanceTextSelection
  10480. });
  10481. }
  10482. }]);
  10483. return DefaultTextLayerFactory;
  10484. }();
  10485. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  10486. /***/ }),
  10487. /* 32 */
  10488. /***/ (function(module, exports, __webpack_require__) {
  10489. "use strict";
  10490. Object.defineProperty(exports, "__esModule", {
  10491. value: true
  10492. });
  10493. exports.SecondaryToolbar = void 0;
  10494. var _ui_utils = __webpack_require__(5);
  10495. var _pdf_cursor_tools = __webpack_require__(9);
  10496. var _pdf_single_page_viewer = __webpack_require__(33);
  10497. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10498. 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); } }
  10499. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10500. var SecondaryToolbar =
  10501. /*#__PURE__*/
  10502. function () {
  10503. function SecondaryToolbar(options, mainContainer, eventBus) {
  10504. var _this = this;
  10505. _classCallCheck(this, SecondaryToolbar);
  10506. this.toolbar = options.toolbar;
  10507. this.toggleButton = options.toggleButton;
  10508. this.toolbarButtonContainer = options.toolbarButtonContainer;
  10509. this.buttons = [{
  10510. element: options.presentationModeButton,
  10511. eventName: 'presentationmode',
  10512. close: true
  10513. }, {
  10514. element: options.openFileButton,
  10515. eventName: 'openfile',
  10516. close: true
  10517. }, {
  10518. element: options.printButton,
  10519. eventName: 'print',
  10520. close: true
  10521. }, {
  10522. element: options.downloadButton,
  10523. eventName: 'download',
  10524. close: true
  10525. }, {
  10526. element: options.viewBookmarkButton,
  10527. eventName: null,
  10528. close: true
  10529. }, {
  10530. element: options.firstPageButton,
  10531. eventName: 'firstpage',
  10532. close: true
  10533. }, {
  10534. element: options.lastPageButton,
  10535. eventName: 'lastpage',
  10536. close: true
  10537. }, {
  10538. element: options.pageRotateCwButton,
  10539. eventName: 'rotatecw',
  10540. close: false
  10541. }, {
  10542. element: options.pageRotateCcwButton,
  10543. eventName: 'rotateccw',
  10544. close: false
  10545. }, {
  10546. element: options.cursorSelectToolButton,
  10547. eventName: 'switchcursortool',
  10548. eventDetails: {
  10549. tool: _pdf_cursor_tools.CursorTool.SELECT
  10550. },
  10551. close: true
  10552. }, {
  10553. element: options.cursorHandToolButton,
  10554. eventName: 'switchcursortool',
  10555. eventDetails: {
  10556. tool: _pdf_cursor_tools.CursorTool.HAND
  10557. },
  10558. close: true
  10559. }, {
  10560. element: options.scrollVerticalButton,
  10561. eventName: 'switchscrollmode',
  10562. eventDetails: {
  10563. mode: _ui_utils.ScrollMode.VERTICAL
  10564. },
  10565. close: true
  10566. }, {
  10567. element: options.scrollHorizontalButton,
  10568. eventName: 'switchscrollmode',
  10569. eventDetails: {
  10570. mode: _ui_utils.ScrollMode.HORIZONTAL
  10571. },
  10572. close: true
  10573. }, {
  10574. element: options.scrollWrappedButton,
  10575. eventName: 'switchscrollmode',
  10576. eventDetails: {
  10577. mode: _ui_utils.ScrollMode.WRAPPED
  10578. },
  10579. close: true
  10580. }, {
  10581. element: options.spreadNoneButton,
  10582. eventName: 'switchspreadmode',
  10583. eventDetails: {
  10584. mode: _ui_utils.SpreadMode.NONE
  10585. },
  10586. close: true
  10587. }, {
  10588. element: options.spreadOddButton,
  10589. eventName: 'switchspreadmode',
  10590. eventDetails: {
  10591. mode: _ui_utils.SpreadMode.ODD
  10592. },
  10593. close: true
  10594. }, {
  10595. element: options.spreadEvenButton,
  10596. eventName: 'switchspreadmode',
  10597. eventDetails: {
  10598. mode: _ui_utils.SpreadMode.EVEN
  10599. },
  10600. close: true
  10601. }, {
  10602. element: options.documentPropertiesButton,
  10603. eventName: 'documentproperties',
  10604. close: true
  10605. }];
  10606. this.items = {
  10607. firstPage: options.firstPageButton,
  10608. lastPage: options.lastPageButton,
  10609. pageRotateCw: options.pageRotateCwButton,
  10610. pageRotateCcw: options.pageRotateCcwButton
  10611. };
  10612. this.mainContainer = mainContainer;
  10613. this.eventBus = eventBus;
  10614. this.opened = false;
  10615. this.containerHeight = null;
  10616. this.previousContainerHeight = null;
  10617. this.reset();
  10618. this._bindClickListeners();
  10619. this._bindCursorToolsListener(options);
  10620. this._bindScrollModeListener(options);
  10621. this._bindSpreadModeListener(options);
  10622. this.eventBus.on('resize', this._setMaxHeight.bind(this));
  10623. this.eventBus.on('baseviewerinit', function (evt) {
  10624. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  10625. _this.toolbarButtonContainer.classList.add('hiddenScrollModeButtons', 'hiddenSpreadModeButtons');
  10626. } else {
  10627. _this.toolbarButtonContainer.classList.remove('hiddenScrollModeButtons', 'hiddenSpreadModeButtons');
  10628. }
  10629. });
  10630. }
  10631. _createClass(SecondaryToolbar, [{
  10632. key: "setPageNumber",
  10633. value: function setPageNumber(pageNumber) {
  10634. this.pageNumber = pageNumber;
  10635. this._updateUIState();
  10636. }
  10637. }, {
  10638. key: "setPagesCount",
  10639. value: function setPagesCount(pagesCount) {
  10640. this.pagesCount = pagesCount;
  10641. this._updateUIState();
  10642. }
  10643. }, {
  10644. key: "reset",
  10645. value: function reset() {
  10646. this.pageNumber = 0;
  10647. this.pagesCount = 0;
  10648. this._updateUIState();
  10649. this.eventBus.dispatch('secondarytoolbarreset', {
  10650. source: this
  10651. });
  10652. }
  10653. }, {
  10654. key: "_updateUIState",
  10655. value: function _updateUIState() {
  10656. this.items.firstPage.disabled = this.pageNumber <= 1;
  10657. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  10658. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  10659. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  10660. }
  10661. }, {
  10662. key: "_bindClickListeners",
  10663. value: function _bindClickListeners() {
  10664. var _this2 = this;
  10665. this.toggleButton.addEventListener('click', this.toggle.bind(this));
  10666. var _loop = function _loop(button) {
  10667. var _this2$buttons$button = _this2.buttons[button],
  10668. element = _this2$buttons$button.element,
  10669. eventName = _this2$buttons$button.eventName,
  10670. close = _this2$buttons$button.close,
  10671. eventDetails = _this2$buttons$button.eventDetails;
  10672. element.addEventListener('click', function (evt) {
  10673. if (eventName !== null) {
  10674. var details = {
  10675. source: _this2
  10676. };
  10677. for (var property in eventDetails) {
  10678. details[property] = eventDetails[property];
  10679. }
  10680. _this2.eventBus.dispatch(eventName, details);
  10681. }
  10682. if (close) {
  10683. _this2.close();
  10684. }
  10685. });
  10686. };
  10687. for (var button in this.buttons) {
  10688. _loop(button);
  10689. }
  10690. }
  10691. }, {
  10692. key: "_bindCursorToolsListener",
  10693. value: function _bindCursorToolsListener(buttons) {
  10694. this.eventBus.on('cursortoolchanged', function (_ref) {
  10695. var tool = _ref.tool;
  10696. buttons.cursorSelectToolButton.classList.toggle('toggled', tool === _pdf_cursor_tools.CursorTool.SELECT);
  10697. buttons.cursorHandToolButton.classList.toggle('toggled', tool === _pdf_cursor_tools.CursorTool.HAND);
  10698. });
  10699. }
  10700. }, {
  10701. key: "_bindScrollModeListener",
  10702. value: function _bindScrollModeListener(buttons) {
  10703. var _this3 = this;
  10704. function scrollModeChanged(_ref2) {
  10705. var mode = _ref2.mode;
  10706. buttons.scrollVerticalButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.VERTICAL);
  10707. buttons.scrollHorizontalButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.HORIZONTAL);
  10708. buttons.scrollWrappedButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.WRAPPED);
  10709. var isScrollModeHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
  10710. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  10711. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  10712. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  10713. }
  10714. this.eventBus.on('scrollmodechanged', scrollModeChanged);
  10715. this.eventBus.on('secondarytoolbarreset', function (evt) {
  10716. if (evt.source === _this3) {
  10717. scrollModeChanged({
  10718. mode: _ui_utils.ScrollMode.VERTICAL
  10719. });
  10720. }
  10721. });
  10722. }
  10723. }, {
  10724. key: "_bindSpreadModeListener",
  10725. value: function _bindSpreadModeListener(buttons) {
  10726. var _this4 = this;
  10727. function spreadModeChanged(_ref3) {
  10728. var mode = _ref3.mode;
  10729. buttons.spreadNoneButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.NONE);
  10730. buttons.spreadOddButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.ODD);
  10731. buttons.spreadEvenButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.EVEN);
  10732. }
  10733. this.eventBus.on('spreadmodechanged', spreadModeChanged);
  10734. this.eventBus.on('secondarytoolbarreset', function (evt) {
  10735. if (evt.source === _this4) {
  10736. spreadModeChanged({
  10737. mode: _ui_utils.SpreadMode.NONE
  10738. });
  10739. }
  10740. });
  10741. }
  10742. }, {
  10743. key: "open",
  10744. value: function open() {
  10745. if (this.opened) {
  10746. return;
  10747. }
  10748. this.opened = true;
  10749. this._setMaxHeight();
  10750. this.toggleButton.classList.add('toggled');
  10751. this.toolbar.classList.remove('hidden');
  10752. }
  10753. }, {
  10754. key: "close",
  10755. value: function close() {
  10756. if (!this.opened) {
  10757. return;
  10758. }
  10759. this.opened = false;
  10760. this.toolbar.classList.add('hidden');
  10761. this.toggleButton.classList.remove('toggled');
  10762. }
  10763. }, {
  10764. key: "toggle",
  10765. value: function toggle() {
  10766. if (this.opened) {
  10767. this.close();
  10768. } else {
  10769. this.open();
  10770. }
  10771. }
  10772. }, {
  10773. key: "_setMaxHeight",
  10774. value: function _setMaxHeight() {
  10775. if (!this.opened) {
  10776. return;
  10777. }
  10778. this.containerHeight = this.mainContainer.clientHeight;
  10779. if (this.containerHeight === this.previousContainerHeight) {
  10780. return;
  10781. }
  10782. this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
  10783. this.previousContainerHeight = this.containerHeight;
  10784. }
  10785. }, {
  10786. key: "isOpen",
  10787. get: function get() {
  10788. return this.opened;
  10789. }
  10790. }]);
  10791. return SecondaryToolbar;
  10792. }();
  10793. exports.SecondaryToolbar = SecondaryToolbar;
  10794. /***/ }),
  10795. /* 33 */
  10796. /***/ (function(module, exports, __webpack_require__) {
  10797. "use strict";
  10798. Object.defineProperty(exports, "__esModule", {
  10799. value: true
  10800. });
  10801. exports.PDFSinglePageViewer = void 0;
  10802. var _base_viewer = __webpack_require__(28);
  10803. var _pdfjsLib = __webpack_require__(7);
  10804. function _typeof(obj) { 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); }
  10805. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10806. 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); } }
  10807. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10808. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10809. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10810. 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); }
  10811. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  10812. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10813. 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); }
  10814. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10815. var PDFSinglePageViewer =
  10816. /*#__PURE__*/
  10817. function (_BaseViewer) {
  10818. _inherits(PDFSinglePageViewer, _BaseViewer);
  10819. function PDFSinglePageViewer(options) {
  10820. var _this;
  10821. _classCallCheck(this, PDFSinglePageViewer);
  10822. _this = _possibleConstructorReturn(this, _getPrototypeOf(PDFSinglePageViewer).call(this, options));
  10823. _this.eventBus.on('pagesinit', function (evt) {
  10824. _this._ensurePageViewVisible();
  10825. });
  10826. return _this;
  10827. }
  10828. _createClass(PDFSinglePageViewer, [{
  10829. key: "_resetView",
  10830. value: function _resetView() {
  10831. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  10832. this._previousPageNumber = 1;
  10833. this._shadowViewer = document.createDocumentFragment();
  10834. this._updateScrollDown = null;
  10835. }
  10836. }, {
  10837. key: "_ensurePageViewVisible",
  10838. value: function _ensurePageViewVisible() {
  10839. var pageView = this._pages[this._currentPageNumber - 1];
  10840. var previousPageView = this._pages[this._previousPageNumber - 1];
  10841. var viewerNodes = this.viewer.childNodes;
  10842. switch (viewerNodes.length) {
  10843. case 0:
  10844. this.viewer.appendChild(pageView.div);
  10845. break;
  10846. case 1:
  10847. if (viewerNodes[0] !== previousPageView.div) {
  10848. throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');
  10849. }
  10850. if (pageView === previousPageView) {
  10851. break;
  10852. }
  10853. this._shadowViewer.appendChild(previousPageView.div);
  10854. this.viewer.appendChild(pageView.div);
  10855. this.container.scrollTop = 0;
  10856. break;
  10857. default:
  10858. throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');
  10859. }
  10860. this._previousPageNumber = this._currentPageNumber;
  10861. }
  10862. }, {
  10863. key: "_scrollUpdate",
  10864. value: function _scrollUpdate() {
  10865. if (this._updateScrollDown) {
  10866. this._updateScrollDown();
  10867. }
  10868. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  10869. }
  10870. }, {
  10871. key: "_scrollIntoView",
  10872. value: function _scrollIntoView(_ref) {
  10873. var _this2 = this;
  10874. var pageDiv = _ref.pageDiv,
  10875. _ref$pageSpot = _ref.pageSpot,
  10876. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  10877. _ref$pageNumber = _ref.pageNumber,
  10878. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  10879. if (pageNumber) {
  10880. this._setCurrentPageNumber(pageNumber);
  10881. }
  10882. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  10883. this._ensurePageViewVisible();
  10884. this.update();
  10885. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  10886. pageDiv: pageDiv,
  10887. pageSpot: pageSpot,
  10888. pageNumber: pageNumber
  10889. });
  10890. this._updateScrollDown = function () {
  10891. _this2.scroll.down = scrolledDown;
  10892. _this2._updateScrollDown = null;
  10893. };
  10894. }
  10895. }, {
  10896. key: "_getVisiblePages",
  10897. value: function _getVisiblePages() {
  10898. return this._getCurrentVisiblePage();
  10899. }
  10900. }, {
  10901. key: "_updateHelper",
  10902. value: function _updateHelper(visiblePages) {}
  10903. }, {
  10904. key: "_updateScrollMode",
  10905. value: function _updateScrollMode() {}
  10906. }, {
  10907. key: "_updateSpreadMode",
  10908. value: function _updateSpreadMode() {}
  10909. }, {
  10910. key: "_setDocumentViewerElement",
  10911. get: function get() {
  10912. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);
  10913. }
  10914. }, {
  10915. key: "_isScrollModeHorizontal",
  10916. get: function get() {
  10917. return (0, _pdfjsLib.shadow)(this, '_isScrollModeHorizontal', false);
  10918. }
  10919. }]);
  10920. return PDFSinglePageViewer;
  10921. }(_base_viewer.BaseViewer);
  10922. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  10923. /***/ }),
  10924. /* 34 */
  10925. /***/ (function(module, exports, __webpack_require__) {
  10926. "use strict";
  10927. Object.defineProperty(exports, "__esModule", {
  10928. value: true
  10929. });
  10930. exports.Toolbar = void 0;
  10931. var _ui_utils = __webpack_require__(5);
  10932. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10933. 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); } }
  10934. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10935. var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
  10936. var SCALE_SELECT_CONTAINER_PADDING = 8;
  10937. var SCALE_SELECT_PADDING = 22;
  10938. var Toolbar =
  10939. /*#__PURE__*/
  10940. function () {
  10941. function Toolbar(options, eventBus) {
  10942. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  10943. _classCallCheck(this, Toolbar);
  10944. this.toolbar = options.container;
  10945. this.eventBus = eventBus;
  10946. this.l10n = l10n;
  10947. this.items = options;
  10948. this._wasLocalized = false;
  10949. this.reset();
  10950. this._bindListeners();
  10951. }
  10952. _createClass(Toolbar, [{
  10953. key: "setPageNumber",
  10954. value: function setPageNumber(pageNumber, pageLabel) {
  10955. this.pageNumber = pageNumber;
  10956. this.pageLabel = pageLabel;
  10957. this._updateUIState(false);
  10958. }
  10959. }, {
  10960. key: "setPagesCount",
  10961. value: function setPagesCount(pagesCount, hasPageLabels) {
  10962. this.pagesCount = pagesCount;
  10963. this.hasPageLabels = hasPageLabels;
  10964. this._updateUIState(true);
  10965. }
  10966. }, {
  10967. key: "setPageScale",
  10968. value: function setPageScale(pageScaleValue, pageScale) {
  10969. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  10970. this.pageScale = pageScale;
  10971. this._updateUIState(false);
  10972. }
  10973. }, {
  10974. key: "reset",
  10975. value: function reset() {
  10976. this.pageNumber = 0;
  10977. this.pageLabel = null;
  10978. this.hasPageLabels = false;
  10979. this.pagesCount = 0;
  10980. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  10981. this.pageScale = _ui_utils.DEFAULT_SCALE;
  10982. this._updateUIState(true);
  10983. }
  10984. }, {
  10985. key: "_bindListeners",
  10986. value: function _bindListeners() {
  10987. var _this = this;
  10988. var eventBus = this.eventBus,
  10989. items = this.items;
  10990. var self = this;
  10991. items.previous.addEventListener('click', function () {
  10992. eventBus.dispatch('previouspage', {
  10993. source: self
  10994. });
  10995. });
  10996. items.next.addEventListener('click', function () {
  10997. eventBus.dispatch('nextpage', {
  10998. source: self
  10999. });
  11000. });
  11001. items.zoomIn.addEventListener('click', function () {
  11002. eventBus.dispatch('zoomin', {
  11003. source: self
  11004. });
  11005. });
  11006. items.zoomOut.addEventListener('click', function () {
  11007. eventBus.dispatch('zoomout', {
  11008. source: self
  11009. });
  11010. });
  11011. items.pageNumber.addEventListener('click', function () {
  11012. this.select();
  11013. });
  11014. items.pageNumber.addEventListener('change', function () {
  11015. eventBus.dispatch('pagenumberchanged', {
  11016. source: self,
  11017. value: this.value
  11018. });
  11019. });
  11020. items.scaleSelect.addEventListener('change', function () {
  11021. if (this.value === 'custom') {
  11022. return;
  11023. }
  11024. eventBus.dispatch('scalechanged', {
  11025. source: self,
  11026. value: this.value
  11027. });
  11028. });
  11029. items.presentationModeButton.addEventListener('click', function () {
  11030. eventBus.dispatch('presentationmode', {
  11031. source: self
  11032. });
  11033. });
  11034. items.openFile.addEventListener('click', function () {
  11035. eventBus.dispatch('openfile', {
  11036. source: self
  11037. });
  11038. });
  11039. items.print.addEventListener('click', function () {
  11040. eventBus.dispatch('print', {
  11041. source: self
  11042. });
  11043. });
  11044. items.download.addEventListener('click', function () {
  11045. eventBus.dispatch('download', {
  11046. source: self
  11047. });
  11048. });
  11049. items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  11050. eventBus.on('localized', function () {
  11051. _this._localized();
  11052. });
  11053. }
  11054. }, {
  11055. key: "_localized",
  11056. value: function _localized() {
  11057. this._wasLocalized = true;
  11058. this._adjustScaleWidth();
  11059. this._updateUIState(true);
  11060. }
  11061. }, {
  11062. key: "_updateUIState",
  11063. value: function _updateUIState() {
  11064. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11065. if (!this._wasLocalized) {
  11066. return;
  11067. }
  11068. var pageNumber = this.pageNumber,
  11069. pagesCount = this.pagesCount,
  11070. pageScaleValue = this.pageScaleValue,
  11071. pageScale = this.pageScale,
  11072. items = this.items;
  11073. if (resetNumPages) {
  11074. if (this.hasPageLabels) {
  11075. items.pageNumber.type = 'text';
  11076. } else {
  11077. items.pageNumber.type = 'number';
  11078. this.l10n.get('of_pages', {
  11079. pagesCount: pagesCount
  11080. }, 'of {{pagesCount}}').then(function (msg) {
  11081. items.numPages.textContent = msg;
  11082. });
  11083. }
  11084. items.pageNumber.max = pagesCount;
  11085. }
  11086. if (this.hasPageLabels) {
  11087. items.pageNumber.value = this.pageLabel;
  11088. this.l10n.get('page_of_pages', {
  11089. pageNumber: pageNumber,
  11090. pagesCount: pagesCount
  11091. }, '({{pageNumber}} of {{pagesCount}})').then(function (msg) {
  11092. items.numPages.textContent = msg;
  11093. });
  11094. } else {
  11095. items.pageNumber.value = pageNumber;
  11096. }
  11097. items.previous.disabled = pageNumber <= 1;
  11098. items.next.disabled = pageNumber >= pagesCount;
  11099. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  11100. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  11101. var customScale = Math.round(pageScale * 10000) / 100;
  11102. this.l10n.get('page_scale_percent', {
  11103. scale: customScale
  11104. }, '{{scale}}%').then(function (msg) {
  11105. var options = items.scaleSelect.options;
  11106. var predefinedValueFound = false;
  11107. for (var i = 0, ii = options.length; i < ii; i++) {
  11108. var option = options[i];
  11109. if (option.value !== pageScaleValue) {
  11110. option.selected = false;
  11111. continue;
  11112. }
  11113. option.selected = true;
  11114. predefinedValueFound = true;
  11115. }
  11116. if (!predefinedValueFound) {
  11117. items.customScaleOption.textContent = msg;
  11118. items.customScaleOption.selected = true;
  11119. }
  11120. });
  11121. }
  11122. }, {
  11123. key: "updateLoadingIndicatorState",
  11124. value: function updateLoadingIndicatorState() {
  11125. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11126. var pageNumberInput = this.items.pageNumber;
  11127. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  11128. }
  11129. }, {
  11130. key: "_adjustScaleWidth",
  11131. value: function _adjustScaleWidth() {
  11132. var container = this.items.scaleSelectContainer;
  11133. var select = this.items.scaleSelect;
  11134. _ui_utils.animationStarted.then(function () {
  11135. if (container.clientWidth === 0) {
  11136. container.setAttribute('style', 'display: inherit;');
  11137. }
  11138. if (container.clientWidth > 0) {
  11139. select.setAttribute('style', 'min-width: inherit;');
  11140. var width = select.clientWidth + SCALE_SELECT_CONTAINER_PADDING;
  11141. select.setAttribute('style', 'min-width: ' + (width + SCALE_SELECT_PADDING) + 'px;');
  11142. container.setAttribute('style', 'min-width: ' + width + 'px; ' + 'max-width: ' + width + 'px;');
  11143. }
  11144. });
  11145. }
  11146. }]);
  11147. return Toolbar;
  11148. }();
  11149. exports.Toolbar = Toolbar;
  11150. /***/ }),
  11151. /* 35 */
  11152. /***/ (function(module, exports, __webpack_require__) {
  11153. "use strict";
  11154. Object.defineProperty(exports, "__esModule", {
  11155. value: true
  11156. });
  11157. exports.ViewHistory = void 0;
  11158. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11159. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11160. 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); } }
  11161. 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); }); }; }
  11162. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11163. 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); } }
  11164. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11165. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  11166. var ViewHistory =
  11167. /*#__PURE__*/
  11168. function () {
  11169. function ViewHistory(fingerprint) {
  11170. var _this = this;
  11171. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  11172. _classCallCheck(this, ViewHistory);
  11173. this.fingerprint = fingerprint;
  11174. this.cacheSize = cacheSize;
  11175. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  11176. var database = JSON.parse(databaseStr || '{}');
  11177. if (!('files' in database)) {
  11178. database.files = [];
  11179. } else {
  11180. while (database.files.length >= _this.cacheSize) {
  11181. database.files.shift();
  11182. }
  11183. }
  11184. var index = -1;
  11185. for (var i = 0, length = database.files.length; i < length; i++) {
  11186. var branch = database.files[i];
  11187. if (branch.fingerprint === _this.fingerprint) {
  11188. index = i;
  11189. break;
  11190. }
  11191. }
  11192. if (index === -1) {
  11193. index = database.files.push({
  11194. fingerprint: _this.fingerprint
  11195. }) - 1;
  11196. }
  11197. _this.file = database.files[index];
  11198. _this.database = database;
  11199. });
  11200. }
  11201. _createClass(ViewHistory, [{
  11202. key: "_writeToStorage",
  11203. value: function () {
  11204. var _writeToStorage2 = _asyncToGenerator(
  11205. /*#__PURE__*/
  11206. _regenerator["default"].mark(function _callee() {
  11207. var databaseStr;
  11208. return _regenerator["default"].wrap(function _callee$(_context) {
  11209. while (1) {
  11210. switch (_context.prev = _context.next) {
  11211. case 0:
  11212. databaseStr = JSON.stringify(this.database);
  11213. localStorage.setItem('pdfjs.history', databaseStr);
  11214. case 2:
  11215. case "end":
  11216. return _context.stop();
  11217. }
  11218. }
  11219. }, _callee, this);
  11220. }));
  11221. function _writeToStorage() {
  11222. return _writeToStorage2.apply(this, arguments);
  11223. }
  11224. return _writeToStorage;
  11225. }()
  11226. }, {
  11227. key: "_readFromStorage",
  11228. value: function () {
  11229. var _readFromStorage2 = _asyncToGenerator(
  11230. /*#__PURE__*/
  11231. _regenerator["default"].mark(function _callee2() {
  11232. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11233. while (1) {
  11234. switch (_context2.prev = _context2.next) {
  11235. case 0:
  11236. return _context2.abrupt("return", localStorage.getItem('pdfjs.history'));
  11237. case 1:
  11238. case "end":
  11239. return _context2.stop();
  11240. }
  11241. }
  11242. }, _callee2);
  11243. }));
  11244. function _readFromStorage() {
  11245. return _readFromStorage2.apply(this, arguments);
  11246. }
  11247. return _readFromStorage;
  11248. }()
  11249. }, {
  11250. key: "set",
  11251. value: function () {
  11252. var _set = _asyncToGenerator(
  11253. /*#__PURE__*/
  11254. _regenerator["default"].mark(function _callee3(name, val) {
  11255. return _regenerator["default"].wrap(function _callee3$(_context3) {
  11256. while (1) {
  11257. switch (_context3.prev = _context3.next) {
  11258. case 0:
  11259. _context3.next = 2;
  11260. return this._initializedPromise;
  11261. case 2:
  11262. this.file[name] = val;
  11263. return _context3.abrupt("return", this._writeToStorage());
  11264. case 4:
  11265. case "end":
  11266. return _context3.stop();
  11267. }
  11268. }
  11269. }, _callee3, this);
  11270. }));
  11271. function set(_x, _x2) {
  11272. return _set.apply(this, arguments);
  11273. }
  11274. return set;
  11275. }()
  11276. }, {
  11277. key: "setMultiple",
  11278. value: function () {
  11279. var _setMultiple = _asyncToGenerator(
  11280. /*#__PURE__*/
  11281. _regenerator["default"].mark(function _callee4(properties) {
  11282. var name;
  11283. return _regenerator["default"].wrap(function _callee4$(_context4) {
  11284. while (1) {
  11285. switch (_context4.prev = _context4.next) {
  11286. case 0:
  11287. _context4.next = 2;
  11288. return this._initializedPromise;
  11289. case 2:
  11290. for (name in properties) {
  11291. this.file[name] = properties[name];
  11292. }
  11293. return _context4.abrupt("return", this._writeToStorage());
  11294. case 4:
  11295. case "end":
  11296. return _context4.stop();
  11297. }
  11298. }
  11299. }, _callee4, this);
  11300. }));
  11301. function setMultiple(_x3) {
  11302. return _setMultiple.apply(this, arguments);
  11303. }
  11304. return setMultiple;
  11305. }()
  11306. }, {
  11307. key: "get",
  11308. value: function () {
  11309. var _get = _asyncToGenerator(
  11310. /*#__PURE__*/
  11311. _regenerator["default"].mark(function _callee5(name, defaultValue) {
  11312. var val;
  11313. return _regenerator["default"].wrap(function _callee5$(_context5) {
  11314. while (1) {
  11315. switch (_context5.prev = _context5.next) {
  11316. case 0:
  11317. _context5.next = 2;
  11318. return this._initializedPromise;
  11319. case 2:
  11320. val = this.file[name];
  11321. return _context5.abrupt("return", val !== undefined ? val : defaultValue);
  11322. case 4:
  11323. case "end":
  11324. return _context5.stop();
  11325. }
  11326. }
  11327. }, _callee5, this);
  11328. }));
  11329. function get(_x4, _x5) {
  11330. return _get.apply(this, arguments);
  11331. }
  11332. return get;
  11333. }()
  11334. }, {
  11335. key: "getMultiple",
  11336. value: function () {
  11337. var _getMultiple = _asyncToGenerator(
  11338. /*#__PURE__*/
  11339. _regenerator["default"].mark(function _callee6(properties) {
  11340. var values, name, val;
  11341. return _regenerator["default"].wrap(function _callee6$(_context6) {
  11342. while (1) {
  11343. switch (_context6.prev = _context6.next) {
  11344. case 0:
  11345. _context6.next = 2;
  11346. return this._initializedPromise;
  11347. case 2:
  11348. values = Object.create(null);
  11349. for (name in properties) {
  11350. val = this.file[name];
  11351. values[name] = val !== undefined ? val : properties[name];
  11352. }
  11353. return _context6.abrupt("return", values);
  11354. case 5:
  11355. case "end":
  11356. return _context6.stop();
  11357. }
  11358. }
  11359. }, _callee6, this);
  11360. }));
  11361. function getMultiple(_x6) {
  11362. return _getMultiple.apply(this, arguments);
  11363. }
  11364. return getMultiple;
  11365. }()
  11366. }]);
  11367. return ViewHistory;
  11368. }();
  11369. exports.ViewHistory = ViewHistory;
  11370. /***/ }),
  11371. /* 36 */
  11372. /***/ (function(module, exports, __webpack_require__) {
  11373. "use strict";
  11374. Object.defineProperty(exports, "__esModule", {
  11375. value: true
  11376. });
  11377. exports.GenericCom = void 0;
  11378. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11379. var _app = __webpack_require__(1);
  11380. var _preferences = __webpack_require__(37);
  11381. var _download_manager = __webpack_require__(38);
  11382. var _genericl10n = __webpack_require__(39);
  11383. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11384. function _typeof(obj) { 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); }
  11385. 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); } }
  11386. 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); }); }; }
  11387. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11388. 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); } }
  11389. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11390. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11391. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11392. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11393. 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); }
  11394. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11395. ;
  11396. var GenericCom = {};
  11397. exports.GenericCom = GenericCom;
  11398. var GenericPreferences =
  11399. /*#__PURE__*/
  11400. function (_BasePreferences) {
  11401. _inherits(GenericPreferences, _BasePreferences);
  11402. function GenericPreferences() {
  11403. _classCallCheck(this, GenericPreferences);
  11404. return _possibleConstructorReturn(this, _getPrototypeOf(GenericPreferences).apply(this, arguments));
  11405. }
  11406. _createClass(GenericPreferences, [{
  11407. key: "_writeToStorage",
  11408. value: function () {
  11409. var _writeToStorage2 = _asyncToGenerator(
  11410. /*#__PURE__*/
  11411. _regenerator["default"].mark(function _callee(prefObj) {
  11412. return _regenerator["default"].wrap(function _callee$(_context) {
  11413. while (1) {
  11414. switch (_context.prev = _context.next) {
  11415. case 0:
  11416. localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
  11417. case 1:
  11418. case "end":
  11419. return _context.stop();
  11420. }
  11421. }
  11422. }, _callee);
  11423. }));
  11424. function _writeToStorage(_x) {
  11425. return _writeToStorage2.apply(this, arguments);
  11426. }
  11427. return _writeToStorage;
  11428. }()
  11429. }, {
  11430. key: "_readFromStorage",
  11431. value: function () {
  11432. var _readFromStorage2 = _asyncToGenerator(
  11433. /*#__PURE__*/
  11434. _regenerator["default"].mark(function _callee2(prefObj) {
  11435. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11436. while (1) {
  11437. switch (_context2.prev = _context2.next) {
  11438. case 0:
  11439. return _context2.abrupt("return", JSON.parse(localStorage.getItem('pdfjs.preferences')));
  11440. case 1:
  11441. case "end":
  11442. return _context2.stop();
  11443. }
  11444. }
  11445. }, _callee2);
  11446. }));
  11447. function _readFromStorage(_x2) {
  11448. return _readFromStorage2.apply(this, arguments);
  11449. }
  11450. return _readFromStorage;
  11451. }()
  11452. }]);
  11453. return GenericPreferences;
  11454. }(_preferences.BasePreferences);
  11455. var GenericExternalServices = Object.create(_app.DefaultExternalServices);
  11456. GenericExternalServices.createDownloadManager = function (options) {
  11457. return new _download_manager.DownloadManager(options);
  11458. };
  11459. GenericExternalServices.createPreferences = function () {
  11460. return new GenericPreferences();
  11461. };
  11462. GenericExternalServices.createL10n = function (_ref) {
  11463. var _ref$locale = _ref.locale,
  11464. locale = _ref$locale === void 0 ? 'en-US' : _ref$locale;
  11465. return new _genericl10n.GenericL10n(locale);
  11466. };
  11467. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  11468. /***/ }),
  11469. /* 37 */
  11470. /***/ (function(module, exports, __webpack_require__) {
  11471. "use strict";
  11472. Object.defineProperty(exports, "__esModule", {
  11473. value: true
  11474. });
  11475. exports.BasePreferences = void 0;
  11476. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11477. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11478. 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); } }
  11479. 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); }); }; }
  11480. function _typeof(obj) { 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); }
  11481. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11482. 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); } }
  11483. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11484. var defaultPreferences = null;
  11485. function getDefaultPreferences() {
  11486. if (!defaultPreferences) {
  11487. defaultPreferences = Promise.resolve({
  11488. "cursorToolOnLoad": 0,
  11489. "defaultZoomValue": "",
  11490. "disablePageLabels": false,
  11491. "enablePrintAutoRotate": false,
  11492. "enableWebGL": false,
  11493. "eventBusDispatchToDOM": false,
  11494. "externalLinkTarget": 0,
  11495. "historyUpdateUrl": false,
  11496. "pdfBugEnabled": false,
  11497. "renderer": "canvas",
  11498. "renderInteractiveForms": false,
  11499. "sidebarViewOnLoad": -1,
  11500. "scrollModeOnLoad": -1,
  11501. "spreadModeOnLoad": -1,
  11502. "textLayerMode": 1,
  11503. "useOnlyCssZoom": false,
  11504. "viewOnLoad": 0,
  11505. "disableAutoFetch": false,
  11506. "disableFontFace": false,
  11507. "disableRange": false,
  11508. "disableStream": false
  11509. });
  11510. }
  11511. return defaultPreferences;
  11512. }
  11513. var BasePreferences =
  11514. /*#__PURE__*/
  11515. function () {
  11516. function BasePreferences() {
  11517. var _this = this;
  11518. _classCallCheck(this, BasePreferences);
  11519. if (this.constructor === BasePreferences) {
  11520. throw new Error('Cannot initialize BasePreferences.');
  11521. }
  11522. this.prefs = null;
  11523. this._initializedPromise = getDefaultPreferences().then(function (defaults) {
  11524. Object.defineProperty(_this, 'defaults', {
  11525. value: Object.freeze(defaults),
  11526. writable: false,
  11527. enumerable: true,
  11528. configurable: false
  11529. });
  11530. _this.prefs = Object.assign(Object.create(null), defaults);
  11531. return _this._readFromStorage(defaults);
  11532. }).then(function (prefs) {
  11533. if (!prefs) {
  11534. return;
  11535. }
  11536. for (var name in prefs) {
  11537. var defaultValue = _this.defaults[name],
  11538. prefValue = prefs[name];
  11539. if (defaultValue === undefined || _typeof(prefValue) !== _typeof(defaultValue)) {
  11540. continue;
  11541. }
  11542. _this.prefs[name] = prefValue;
  11543. }
  11544. });
  11545. }
  11546. _createClass(BasePreferences, [{
  11547. key: "_writeToStorage",
  11548. value: function () {
  11549. var _writeToStorage2 = _asyncToGenerator(
  11550. /*#__PURE__*/
  11551. _regenerator["default"].mark(function _callee(prefObj) {
  11552. return _regenerator["default"].wrap(function _callee$(_context) {
  11553. while (1) {
  11554. switch (_context.prev = _context.next) {
  11555. case 0:
  11556. throw new Error('Not implemented: _writeToStorage');
  11557. case 1:
  11558. case "end":
  11559. return _context.stop();
  11560. }
  11561. }
  11562. }, _callee);
  11563. }));
  11564. function _writeToStorage(_x) {
  11565. return _writeToStorage2.apply(this, arguments);
  11566. }
  11567. return _writeToStorage;
  11568. }()
  11569. }, {
  11570. key: "_readFromStorage",
  11571. value: function () {
  11572. var _readFromStorage2 = _asyncToGenerator(
  11573. /*#__PURE__*/
  11574. _regenerator["default"].mark(function _callee2(prefObj) {
  11575. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11576. while (1) {
  11577. switch (_context2.prev = _context2.next) {
  11578. case 0:
  11579. throw new Error('Not implemented: _readFromStorage');
  11580. case 1:
  11581. case "end":
  11582. return _context2.stop();
  11583. }
  11584. }
  11585. }, _callee2);
  11586. }));
  11587. function _readFromStorage(_x2) {
  11588. return _readFromStorage2.apply(this, arguments);
  11589. }
  11590. return _readFromStorage;
  11591. }()
  11592. }, {
  11593. key: "reset",
  11594. value: function () {
  11595. var _reset = _asyncToGenerator(
  11596. /*#__PURE__*/
  11597. _regenerator["default"].mark(function _callee3() {
  11598. return _regenerator["default"].wrap(function _callee3$(_context3) {
  11599. while (1) {
  11600. switch (_context3.prev = _context3.next) {
  11601. case 0:
  11602. _context3.next = 2;
  11603. return this._initializedPromise;
  11604. case 2:
  11605. this.prefs = Object.assign(Object.create(null), this.defaults);
  11606. return _context3.abrupt("return", this._writeToStorage(this.defaults));
  11607. case 4:
  11608. case "end":
  11609. return _context3.stop();
  11610. }
  11611. }
  11612. }, _callee3, this);
  11613. }));
  11614. function reset() {
  11615. return _reset.apply(this, arguments);
  11616. }
  11617. return reset;
  11618. }()
  11619. }, {
  11620. key: "set",
  11621. value: function () {
  11622. var _set = _asyncToGenerator(
  11623. /*#__PURE__*/
  11624. _regenerator["default"].mark(function _callee4(name, value) {
  11625. var defaultValue, valueType, defaultType;
  11626. return _regenerator["default"].wrap(function _callee4$(_context4) {
  11627. while (1) {
  11628. switch (_context4.prev = _context4.next) {
  11629. case 0:
  11630. _context4.next = 2;
  11631. return this._initializedPromise;
  11632. case 2:
  11633. defaultValue = this.defaults[name];
  11634. if (!(defaultValue === undefined)) {
  11635. _context4.next = 7;
  11636. break;
  11637. }
  11638. throw new Error("Set preference: \"".concat(name, "\" is undefined."));
  11639. case 7:
  11640. if (!(value === undefined)) {
  11641. _context4.next = 9;
  11642. break;
  11643. }
  11644. throw new Error('Set preference: no value is specified.');
  11645. case 9:
  11646. valueType = _typeof(value);
  11647. defaultType = _typeof(defaultValue);
  11648. if (!(valueType !== defaultType)) {
  11649. _context4.next = 19;
  11650. break;
  11651. }
  11652. if (!(valueType === 'number' && defaultType === 'string')) {
  11653. _context4.next = 16;
  11654. break;
  11655. }
  11656. value = value.toString();
  11657. _context4.next = 17;
  11658. break;
  11659. case 16:
  11660. throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", ") + "expected a ".concat(defaultType, "."));
  11661. case 17:
  11662. _context4.next = 21;
  11663. break;
  11664. case 19:
  11665. if (!(valueType === 'number' && !Number.isInteger(value))) {
  11666. _context4.next = 21;
  11667. break;
  11668. }
  11669. throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
  11670. case 21:
  11671. this.prefs[name] = value;
  11672. return _context4.abrupt("return", this._writeToStorage(this.prefs));
  11673. case 23:
  11674. case "end":
  11675. return _context4.stop();
  11676. }
  11677. }
  11678. }, _callee4, this);
  11679. }));
  11680. function set(_x3, _x4) {
  11681. return _set.apply(this, arguments);
  11682. }
  11683. return set;
  11684. }()
  11685. }, {
  11686. key: "get",
  11687. value: function () {
  11688. var _get = _asyncToGenerator(
  11689. /*#__PURE__*/
  11690. _regenerator["default"].mark(function _callee5(name) {
  11691. var defaultValue, prefValue;
  11692. return _regenerator["default"].wrap(function _callee5$(_context5) {
  11693. while (1) {
  11694. switch (_context5.prev = _context5.next) {
  11695. case 0:
  11696. _context5.next = 2;
  11697. return this._initializedPromise;
  11698. case 2:
  11699. defaultValue = this.defaults[name];
  11700. if (!(defaultValue === undefined)) {
  11701. _context5.next = 7;
  11702. break;
  11703. }
  11704. throw new Error("Get preference: \"".concat(name, "\" is undefined."));
  11705. case 7:
  11706. prefValue = this.prefs[name];
  11707. if (!(prefValue !== undefined)) {
  11708. _context5.next = 10;
  11709. break;
  11710. }
  11711. return _context5.abrupt("return", prefValue);
  11712. case 10:
  11713. return _context5.abrupt("return", defaultValue);
  11714. case 11:
  11715. case "end":
  11716. return _context5.stop();
  11717. }
  11718. }
  11719. }, _callee5, this);
  11720. }));
  11721. function get(_x5) {
  11722. return _get.apply(this, arguments);
  11723. }
  11724. return get;
  11725. }()
  11726. }, {
  11727. key: "getAll",
  11728. value: function () {
  11729. var _getAll = _asyncToGenerator(
  11730. /*#__PURE__*/
  11731. _regenerator["default"].mark(function _callee6() {
  11732. return _regenerator["default"].wrap(function _callee6$(_context6) {
  11733. while (1) {
  11734. switch (_context6.prev = _context6.next) {
  11735. case 0:
  11736. _context6.next = 2;
  11737. return this._initializedPromise;
  11738. case 2:
  11739. return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs));
  11740. case 3:
  11741. case "end":
  11742. return _context6.stop();
  11743. }
  11744. }
  11745. }, _callee6, this);
  11746. }));
  11747. function getAll() {
  11748. return _getAll.apply(this, arguments);
  11749. }
  11750. return getAll;
  11751. }()
  11752. }]);
  11753. return BasePreferences;
  11754. }();
  11755. exports.BasePreferences = BasePreferences;
  11756. /***/ }),
  11757. /* 38 */
  11758. /***/ (function(module, exports, __webpack_require__) {
  11759. "use strict";
  11760. Object.defineProperty(exports, "__esModule", {
  11761. value: true
  11762. });
  11763. exports.DownloadManager = void 0;
  11764. var _pdfjsLib = __webpack_require__(7);
  11765. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11766. 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); } }
  11767. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11768. ;
  11769. var DISABLE_CREATE_OBJECT_URL = _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false;
  11770. function _download(blobUrl, filename) {
  11771. var a = document.createElement('a');
  11772. if (!a.click) {
  11773. throw new Error('DownloadManager: "a.click()" is not supported.');
  11774. }
  11775. a.href = blobUrl;
  11776. a.target = '_parent';
  11777. if ('download' in a) {
  11778. a.download = filename;
  11779. }
  11780. (document.body || document.documentElement).appendChild(a);
  11781. a.click();
  11782. a.remove();
  11783. }
  11784. var DownloadManager =
  11785. /*#__PURE__*/
  11786. function () {
  11787. function DownloadManager(_ref) {
  11788. var _ref$disableCreateObj = _ref.disableCreateObjectURL,
  11789. disableCreateObjectURL = _ref$disableCreateObj === void 0 ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj;
  11790. _classCallCheck(this, DownloadManager);
  11791. this.disableCreateObjectURL = disableCreateObjectURL;
  11792. }
  11793. _createClass(DownloadManager, [{
  11794. key: "downloadUrl",
  11795. value: function downloadUrl(url, filename) {
  11796. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  11797. return;
  11798. }
  11799. _download(url + '#pdfjs.action=download', filename);
  11800. }
  11801. }, {
  11802. key: "downloadData",
  11803. value: function downloadData(data, filename, contentType) {
  11804. if (navigator.msSaveBlob) {
  11805. navigator.msSaveBlob(new Blob([data], {
  11806. type: contentType
  11807. }), filename);
  11808. return;
  11809. }
  11810. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL);
  11811. _download(blobUrl, filename);
  11812. }
  11813. }, {
  11814. key: "download",
  11815. value: function download(blob, url, filename) {
  11816. if (navigator.msSaveBlob) {
  11817. if (!navigator.msSaveBlob(blob, filename)) {
  11818. this.downloadUrl(url, filename);
  11819. }
  11820. return;
  11821. }
  11822. if (this.disableCreateObjectURL) {
  11823. this.downloadUrl(url, filename);
  11824. return;
  11825. }
  11826. var blobUrl = _pdfjsLib.URL.createObjectURL(blob);
  11827. _download(blobUrl, filename);
  11828. }
  11829. }]);
  11830. return DownloadManager;
  11831. }();
  11832. exports.DownloadManager = DownloadManager;
  11833. /***/ }),
  11834. /* 39 */
  11835. /***/ (function(module, exports, __webpack_require__) {
  11836. "use strict";
  11837. Object.defineProperty(exports, "__esModule", {
  11838. value: true
  11839. });
  11840. exports.GenericL10n = void 0;
  11841. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11842. __webpack_require__(40);
  11843. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11844. 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); } }
  11845. 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); }); }; }
  11846. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11847. 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); } }
  11848. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11849. var webL10n = document.webL10n;
  11850. var GenericL10n =
  11851. /*#__PURE__*/
  11852. function () {
  11853. function GenericL10n(lang) {
  11854. _classCallCheck(this, GenericL10n);
  11855. this._lang = lang;
  11856. this._ready = new Promise(function (resolve, reject) {
  11857. webL10n.setLanguage(lang, function () {
  11858. resolve(webL10n);
  11859. });
  11860. });
  11861. }
  11862. _createClass(GenericL10n, [{
  11863. key: "getLanguage",
  11864. value: function () {
  11865. var _getLanguage = _asyncToGenerator(
  11866. /*#__PURE__*/
  11867. _regenerator["default"].mark(function _callee() {
  11868. var l10n;
  11869. return _regenerator["default"].wrap(function _callee$(_context) {
  11870. while (1) {
  11871. switch (_context.prev = _context.next) {
  11872. case 0:
  11873. _context.next = 2;
  11874. return this._ready;
  11875. case 2:
  11876. l10n = _context.sent;
  11877. return _context.abrupt("return", l10n.getLanguage());
  11878. case 4:
  11879. case "end":
  11880. return _context.stop();
  11881. }
  11882. }
  11883. }, _callee, this);
  11884. }));
  11885. function getLanguage() {
  11886. return _getLanguage.apply(this, arguments);
  11887. }
  11888. return getLanguage;
  11889. }()
  11890. }, {
  11891. key: "getDirection",
  11892. value: function () {
  11893. var _getDirection = _asyncToGenerator(
  11894. /*#__PURE__*/
  11895. _regenerator["default"].mark(function _callee2() {
  11896. var l10n;
  11897. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11898. while (1) {
  11899. switch (_context2.prev = _context2.next) {
  11900. case 0:
  11901. _context2.next = 2;
  11902. return this._ready;
  11903. case 2:
  11904. l10n = _context2.sent;
  11905. return _context2.abrupt("return", l10n.getDirection());
  11906. case 4:
  11907. case "end":
  11908. return _context2.stop();
  11909. }
  11910. }
  11911. }, _callee2, this);
  11912. }));
  11913. function getDirection() {
  11914. return _getDirection.apply(this, arguments);
  11915. }
  11916. return getDirection;
  11917. }()
  11918. }, {
  11919. key: "get",
  11920. value: function () {
  11921. var _get = _asyncToGenerator(
  11922. /*#__PURE__*/
  11923. _regenerator["default"].mark(function _callee3(property, args, fallback) {
  11924. var l10n;
  11925. return _regenerator["default"].wrap(function _callee3$(_context3) {
  11926. while (1) {
  11927. switch (_context3.prev = _context3.next) {
  11928. case 0:
  11929. _context3.next = 2;
  11930. return this._ready;
  11931. case 2:
  11932. l10n = _context3.sent;
  11933. return _context3.abrupt("return", l10n.get(property, args, fallback));
  11934. case 4:
  11935. case "end":
  11936. return _context3.stop();
  11937. }
  11938. }
  11939. }, _callee3, this);
  11940. }));
  11941. function get(_x, _x2, _x3) {
  11942. return _get.apply(this, arguments);
  11943. }
  11944. return get;
  11945. }()
  11946. }, {
  11947. key: "translate",
  11948. value: function () {
  11949. var _translate = _asyncToGenerator(
  11950. /*#__PURE__*/
  11951. _regenerator["default"].mark(function _callee4(element) {
  11952. var l10n;
  11953. return _regenerator["default"].wrap(function _callee4$(_context4) {
  11954. while (1) {
  11955. switch (_context4.prev = _context4.next) {
  11956. case 0:
  11957. _context4.next = 2;
  11958. return this._ready;
  11959. case 2:
  11960. l10n = _context4.sent;
  11961. return _context4.abrupt("return", l10n.translate(element));
  11962. case 4:
  11963. case "end":
  11964. return _context4.stop();
  11965. }
  11966. }
  11967. }, _callee4, this);
  11968. }));
  11969. function translate(_x4) {
  11970. return _translate.apply(this, arguments);
  11971. }
  11972. return translate;
  11973. }()
  11974. }]);
  11975. return GenericL10n;
  11976. }();
  11977. exports.GenericL10n = GenericL10n;
  11978. /***/ }),
  11979. /* 40 */
  11980. /***/ (function(module, exports, __webpack_require__) {
  11981. "use strict";
  11982. document.webL10n = function (window, document, undefined) {
  11983. var gL10nData = {};
  11984. var gTextData = '';
  11985. var gTextProp = 'textContent';
  11986. var gLanguage = '';
  11987. var gMacros = {};
  11988. var gReadyState = 'loading';
  11989. var gAsyncResourceLoading = true;
  11990. function getL10nResourceLinks() {
  11991. return document.querySelectorAll('link[type="application/l10n"]');
  11992. }
  11993. function getL10nDictionary() {
  11994. var script = document.querySelector('script[type="application/l10n"]');
  11995. return script ? JSON.parse(script.innerHTML) : null;
  11996. }
  11997. function getTranslatableChildren(element) {
  11998. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  11999. }
  12000. function getL10nAttributes(element) {
  12001. if (!element) return {};
  12002. var l10nId = element.getAttribute('data-l10n-id');
  12003. var l10nArgs = element.getAttribute('data-l10n-args');
  12004. var args = {};
  12005. if (l10nArgs) {
  12006. try {
  12007. args = JSON.parse(l10nArgs);
  12008. } catch (e) {
  12009. console.warn('could not parse arguments for #' + l10nId);
  12010. }
  12011. }
  12012. return {
  12013. id: l10nId,
  12014. args: args
  12015. };
  12016. }
  12017. function fireL10nReadyEvent(lang) {
  12018. var evtObject = document.createEvent('Event');
  12019. evtObject.initEvent('localized', true, false);
  12020. evtObject.language = lang;
  12021. document.dispatchEvent(evtObject);
  12022. }
  12023. function xhrLoadText(url, onSuccess, onFailure) {
  12024. onSuccess = onSuccess || function _onSuccess(data) {};
  12025. onFailure = onFailure || function _onFailure() {};
  12026. var xhr = new XMLHttpRequest();
  12027. xhr.open('GET', url, gAsyncResourceLoading);
  12028. if (xhr.overrideMimeType) {
  12029. xhr.overrideMimeType('text/plain; charset=utf-8');
  12030. }
  12031. xhr.onreadystatechange = function () {
  12032. if (xhr.readyState == 4) {
  12033. if (xhr.status == 200 || xhr.status === 0) {
  12034. onSuccess(xhr.responseText);
  12035. } else {
  12036. onFailure();
  12037. }
  12038. }
  12039. };
  12040. xhr.onerror = onFailure;
  12041. xhr.ontimeout = onFailure;
  12042. try {
  12043. xhr.send(null);
  12044. } catch (e) {
  12045. onFailure();
  12046. }
  12047. }
  12048. function parseResource(href, lang, successCallback, failureCallback) {
  12049. var baseURL = href.replace(/[^\/]*$/, '') || './';
  12050. function evalString(text) {
  12051. if (text.lastIndexOf('\\') < 0) return text;
  12052. 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, "'");
  12053. }
  12054. function parseProperties(text, parsedPropertiesCallback) {
  12055. var dictionary = {};
  12056. var reBlank = /^\s*|\s*$/;
  12057. var reComment = /^\s*#|^\s*$/;
  12058. var reSection = /^\s*\[(.*)\]\s*$/;
  12059. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  12060. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  12061. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  12062. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  12063. var currentLang = '*';
  12064. var genericLang = lang.split('-', 1)[0];
  12065. var skipLang = false;
  12066. var match = '';
  12067. function nextEntry() {
  12068. while (true) {
  12069. if (!entries.length) {
  12070. parsedRawLinesCallback();
  12071. return;
  12072. }
  12073. var line = entries.shift();
  12074. if (reComment.test(line)) continue;
  12075. if (extendedSyntax) {
  12076. match = reSection.exec(line);
  12077. if (match) {
  12078. currentLang = match[1].toLowerCase();
  12079. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  12080. continue;
  12081. } else if (skipLang) {
  12082. continue;
  12083. }
  12084. match = reImport.exec(line);
  12085. if (match) {
  12086. loadImport(baseURL + match[1], nextEntry);
  12087. return;
  12088. }
  12089. }
  12090. var tmp = line.match(reSplit);
  12091. if (tmp && tmp.length == 3) {
  12092. dictionary[tmp[1]] = evalString(tmp[2]);
  12093. }
  12094. }
  12095. }
  12096. nextEntry();
  12097. }
  12098. function loadImport(url, callback) {
  12099. xhrLoadText(url, function (content) {
  12100. parseRawLines(content, false, callback);
  12101. }, function () {
  12102. console.warn(url + ' not found.');
  12103. callback();
  12104. });
  12105. }
  12106. parseRawLines(text, true, function () {
  12107. parsedPropertiesCallback(dictionary);
  12108. });
  12109. }
  12110. xhrLoadText(href, function (response) {
  12111. gTextData += response;
  12112. parseProperties(response, function (data) {
  12113. for (var key in data) {
  12114. var id,
  12115. prop,
  12116. index = key.lastIndexOf('.');
  12117. if (index > 0) {
  12118. id = key.substring(0, index);
  12119. prop = key.substring(index + 1);
  12120. } else {
  12121. id = key;
  12122. prop = gTextProp;
  12123. }
  12124. if (!gL10nData[id]) {
  12125. gL10nData[id] = {};
  12126. }
  12127. gL10nData[id][prop] = data[key];
  12128. }
  12129. if (successCallback) {
  12130. successCallback();
  12131. }
  12132. });
  12133. }, failureCallback);
  12134. }
  12135. function loadLocale(lang, callback) {
  12136. if (lang) {
  12137. lang = lang.toLowerCase();
  12138. }
  12139. callback = callback || function _callback() {};
  12140. clear();
  12141. gLanguage = lang;
  12142. var langLinks = getL10nResourceLinks();
  12143. var langCount = langLinks.length;
  12144. if (langCount === 0) {
  12145. var dict = getL10nDictionary();
  12146. if (dict && dict.locales && dict.default_locale) {
  12147. console.log('using the embedded JSON directory, early way out');
  12148. gL10nData = dict.locales[lang];
  12149. if (!gL10nData) {
  12150. var defaultLocale = dict.default_locale.toLowerCase();
  12151. for (var anyCaseLang in dict.locales) {
  12152. anyCaseLang = anyCaseLang.toLowerCase();
  12153. if (anyCaseLang === lang) {
  12154. gL10nData = dict.locales[lang];
  12155. break;
  12156. } else if (anyCaseLang === defaultLocale) {
  12157. gL10nData = dict.locales[defaultLocale];
  12158. }
  12159. }
  12160. }
  12161. callback();
  12162. } else {
  12163. console.log('no resource to load, early way out');
  12164. }
  12165. fireL10nReadyEvent(lang);
  12166. gReadyState = 'complete';
  12167. return;
  12168. }
  12169. var onResourceLoaded = null;
  12170. var gResourceCount = 0;
  12171. onResourceLoaded = function onResourceLoaded() {
  12172. gResourceCount++;
  12173. if (gResourceCount >= langCount) {
  12174. callback();
  12175. fireL10nReadyEvent(lang);
  12176. gReadyState = 'complete';
  12177. }
  12178. };
  12179. function L10nResourceLink(link) {
  12180. var href = link.href;
  12181. this.load = function (lang, callback) {
  12182. parseResource(href, lang, callback, function () {
  12183. console.warn(href + ' not found.');
  12184. console.warn('"' + lang + '" resource not found');
  12185. gLanguage = '';
  12186. callback();
  12187. });
  12188. };
  12189. }
  12190. for (var i = 0; i < langCount; i++) {
  12191. var resource = new L10nResourceLink(langLinks[i]);
  12192. resource.load(lang, onResourceLoaded);
  12193. }
  12194. }
  12195. function clear() {
  12196. gL10nData = {};
  12197. gTextData = '';
  12198. gLanguage = '';
  12199. }
  12200. function getPluralRules(lang) {
  12201. var locales2rules = {
  12202. 'af': 3,
  12203. 'ak': 4,
  12204. 'am': 4,
  12205. 'ar': 1,
  12206. 'asa': 3,
  12207. 'az': 0,
  12208. 'be': 11,
  12209. 'bem': 3,
  12210. 'bez': 3,
  12211. 'bg': 3,
  12212. 'bh': 4,
  12213. 'bm': 0,
  12214. 'bn': 3,
  12215. 'bo': 0,
  12216. 'br': 20,
  12217. 'brx': 3,
  12218. 'bs': 11,
  12219. 'ca': 3,
  12220. 'cgg': 3,
  12221. 'chr': 3,
  12222. 'cs': 12,
  12223. 'cy': 17,
  12224. 'da': 3,
  12225. 'de': 3,
  12226. 'dv': 3,
  12227. 'dz': 0,
  12228. 'ee': 3,
  12229. 'el': 3,
  12230. 'en': 3,
  12231. 'eo': 3,
  12232. 'es': 3,
  12233. 'et': 3,
  12234. 'eu': 3,
  12235. 'fa': 0,
  12236. 'ff': 5,
  12237. 'fi': 3,
  12238. 'fil': 4,
  12239. 'fo': 3,
  12240. 'fr': 5,
  12241. 'fur': 3,
  12242. 'fy': 3,
  12243. 'ga': 8,
  12244. 'gd': 24,
  12245. 'gl': 3,
  12246. 'gsw': 3,
  12247. 'gu': 3,
  12248. 'guw': 4,
  12249. 'gv': 23,
  12250. 'ha': 3,
  12251. 'haw': 3,
  12252. 'he': 2,
  12253. 'hi': 4,
  12254. 'hr': 11,
  12255. 'hu': 0,
  12256. 'id': 0,
  12257. 'ig': 0,
  12258. 'ii': 0,
  12259. 'is': 3,
  12260. 'it': 3,
  12261. 'iu': 7,
  12262. 'ja': 0,
  12263. 'jmc': 3,
  12264. 'jv': 0,
  12265. 'ka': 0,
  12266. 'kab': 5,
  12267. 'kaj': 3,
  12268. 'kcg': 3,
  12269. 'kde': 0,
  12270. 'kea': 0,
  12271. 'kk': 3,
  12272. 'kl': 3,
  12273. 'km': 0,
  12274. 'kn': 0,
  12275. 'ko': 0,
  12276. 'ksb': 3,
  12277. 'ksh': 21,
  12278. 'ku': 3,
  12279. 'kw': 7,
  12280. 'lag': 18,
  12281. 'lb': 3,
  12282. 'lg': 3,
  12283. 'ln': 4,
  12284. 'lo': 0,
  12285. 'lt': 10,
  12286. 'lv': 6,
  12287. 'mas': 3,
  12288. 'mg': 4,
  12289. 'mk': 16,
  12290. 'ml': 3,
  12291. 'mn': 3,
  12292. 'mo': 9,
  12293. 'mr': 3,
  12294. 'ms': 0,
  12295. 'mt': 15,
  12296. 'my': 0,
  12297. 'nah': 3,
  12298. 'naq': 7,
  12299. 'nb': 3,
  12300. 'nd': 3,
  12301. 'ne': 3,
  12302. 'nl': 3,
  12303. 'nn': 3,
  12304. 'no': 3,
  12305. 'nr': 3,
  12306. 'nso': 4,
  12307. 'ny': 3,
  12308. 'nyn': 3,
  12309. 'om': 3,
  12310. 'or': 3,
  12311. 'pa': 3,
  12312. 'pap': 3,
  12313. 'pl': 13,
  12314. 'ps': 3,
  12315. 'pt': 3,
  12316. 'rm': 3,
  12317. 'ro': 9,
  12318. 'rof': 3,
  12319. 'ru': 11,
  12320. 'rwk': 3,
  12321. 'sah': 0,
  12322. 'saq': 3,
  12323. 'se': 7,
  12324. 'seh': 3,
  12325. 'ses': 0,
  12326. 'sg': 0,
  12327. 'sh': 11,
  12328. 'shi': 19,
  12329. 'sk': 12,
  12330. 'sl': 14,
  12331. 'sma': 7,
  12332. 'smi': 7,
  12333. 'smj': 7,
  12334. 'smn': 7,
  12335. 'sms': 7,
  12336. 'sn': 3,
  12337. 'so': 3,
  12338. 'sq': 3,
  12339. 'sr': 11,
  12340. 'ss': 3,
  12341. 'ssy': 3,
  12342. 'st': 3,
  12343. 'sv': 3,
  12344. 'sw': 3,
  12345. 'syr': 3,
  12346. 'ta': 3,
  12347. 'te': 3,
  12348. 'teo': 3,
  12349. 'th': 0,
  12350. 'ti': 4,
  12351. 'tig': 3,
  12352. 'tk': 3,
  12353. 'tl': 4,
  12354. 'tn': 3,
  12355. 'to': 0,
  12356. 'tr': 0,
  12357. 'ts': 3,
  12358. 'tzm': 22,
  12359. 'uk': 11,
  12360. 'ur': 3,
  12361. 've': 3,
  12362. 'vi': 0,
  12363. 'vun': 3,
  12364. 'wa': 4,
  12365. 'wae': 3,
  12366. 'wo': 0,
  12367. 'xh': 3,
  12368. 'xog': 3,
  12369. 'yo': 0,
  12370. 'zh': 0,
  12371. 'zu': 3
  12372. };
  12373. function isIn(n, list) {
  12374. return list.indexOf(n) !== -1;
  12375. }
  12376. function isBetween(n, start, end) {
  12377. return start <= n && n <= end;
  12378. }
  12379. var pluralRules = {
  12380. '0': function _(n) {
  12381. return 'other';
  12382. },
  12383. '1': function _(n) {
  12384. if (isBetween(n % 100, 3, 10)) return 'few';
  12385. if (n === 0) return 'zero';
  12386. if (isBetween(n % 100, 11, 99)) return 'many';
  12387. if (n == 2) return 'two';
  12388. if (n == 1) return 'one';
  12389. return 'other';
  12390. },
  12391. '2': function _(n) {
  12392. if (n !== 0 && n % 10 === 0) return 'many';
  12393. if (n == 2) return 'two';
  12394. if (n == 1) return 'one';
  12395. return 'other';
  12396. },
  12397. '3': function _(n) {
  12398. if (n == 1) return 'one';
  12399. return 'other';
  12400. },
  12401. '4': function _(n) {
  12402. if (isBetween(n, 0, 1)) return 'one';
  12403. return 'other';
  12404. },
  12405. '5': function _(n) {
  12406. if (isBetween(n, 0, 2) && n != 2) return 'one';
  12407. return 'other';
  12408. },
  12409. '6': function _(n) {
  12410. if (n === 0) return 'zero';
  12411. if (n % 10 == 1 && n % 100 != 11) return 'one';
  12412. return 'other';
  12413. },
  12414. '7': function _(n) {
  12415. if (n == 2) return 'two';
  12416. if (n == 1) return 'one';
  12417. return 'other';
  12418. },
  12419. '8': function _(n) {
  12420. if (isBetween(n, 3, 6)) return 'few';
  12421. if (isBetween(n, 7, 10)) return 'many';
  12422. if (n == 2) return 'two';
  12423. if (n == 1) return 'one';
  12424. return 'other';
  12425. },
  12426. '9': function _(n) {
  12427. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  12428. if (n == 1) return 'one';
  12429. return 'other';
  12430. },
  12431. '10': function _(n) {
  12432. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  12433. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  12434. return 'other';
  12435. },
  12436. '11': function _(n) {
  12437. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  12438. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  12439. if (n % 10 == 1 && n % 100 != 11) return 'one';
  12440. return 'other';
  12441. },
  12442. '12': function _(n) {
  12443. if (isBetween(n, 2, 4)) return 'few';
  12444. if (n == 1) return 'one';
  12445. return 'other';
  12446. },
  12447. '13': function _(n) {
  12448. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  12449. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  12450. if (n == 1) return 'one';
  12451. return 'other';
  12452. },
  12453. '14': function _(n) {
  12454. if (isBetween(n % 100, 3, 4)) return 'few';
  12455. if (n % 100 == 2) return 'two';
  12456. if (n % 100 == 1) return 'one';
  12457. return 'other';
  12458. },
  12459. '15': function _(n) {
  12460. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  12461. if (isBetween(n % 100, 11, 19)) return 'many';
  12462. if (n == 1) return 'one';
  12463. return 'other';
  12464. },
  12465. '16': function _(n) {
  12466. if (n % 10 == 1 && n != 11) return 'one';
  12467. return 'other';
  12468. },
  12469. '17': function _(n) {
  12470. if (n == 3) return 'few';
  12471. if (n === 0) return 'zero';
  12472. if (n == 6) return 'many';
  12473. if (n == 2) return 'two';
  12474. if (n == 1) return 'one';
  12475. return 'other';
  12476. },
  12477. '18': function _(n) {
  12478. if (n === 0) return 'zero';
  12479. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  12480. return 'other';
  12481. },
  12482. '19': function _(n) {
  12483. if (isBetween(n, 2, 10)) return 'few';
  12484. if (isBetween(n, 0, 1)) return 'one';
  12485. return 'other';
  12486. },
  12487. '20': function _(n) {
  12488. 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';
  12489. if (n % 1000000 === 0 && n !== 0) return 'many';
  12490. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  12491. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  12492. return 'other';
  12493. },
  12494. '21': function _(n) {
  12495. if (n === 0) return 'zero';
  12496. if (n == 1) return 'one';
  12497. return 'other';
  12498. },
  12499. '22': function _(n) {
  12500. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  12501. return 'other';
  12502. },
  12503. '23': function _(n) {
  12504. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  12505. return 'other';
  12506. },
  12507. '24': function _(n) {
  12508. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  12509. if (isIn(n, [2, 12])) return 'two';
  12510. if (isIn(n, [1, 11])) return 'one';
  12511. return 'other';
  12512. }
  12513. };
  12514. var index = locales2rules[lang.replace(/-.*$/, '')];
  12515. if (!(index in pluralRules)) {
  12516. console.warn('plural form unknown for [' + lang + ']');
  12517. return function () {
  12518. return 'other';
  12519. };
  12520. }
  12521. return pluralRules[index];
  12522. }
  12523. gMacros.plural = function (str, param, key, prop) {
  12524. var n = parseFloat(param);
  12525. if (isNaN(n)) return str;
  12526. if (prop != gTextProp) return str;
  12527. if (!gMacros._pluralRules) {
  12528. gMacros._pluralRules = getPluralRules(gLanguage);
  12529. }
  12530. var index = '[' + gMacros._pluralRules(n) + ']';
  12531. if (n === 0 && key + '[zero]' in gL10nData) {
  12532. str = gL10nData[key + '[zero]'][prop];
  12533. } else if (n == 1 && key + '[one]' in gL10nData) {
  12534. str = gL10nData[key + '[one]'][prop];
  12535. } else if (n == 2 && key + '[two]' in gL10nData) {
  12536. str = gL10nData[key + '[two]'][prop];
  12537. } else if (key + index in gL10nData) {
  12538. str = gL10nData[key + index][prop];
  12539. } else if (key + '[other]' in gL10nData) {
  12540. str = gL10nData[key + '[other]'][prop];
  12541. }
  12542. return str;
  12543. };
  12544. function getL10nData(key, args, fallback) {
  12545. var data = gL10nData[key];
  12546. if (!data) {
  12547. console.warn('#' + key + ' is undefined.');
  12548. if (!fallback) {
  12549. return null;
  12550. }
  12551. data = fallback;
  12552. }
  12553. var rv = {};
  12554. for (var prop in data) {
  12555. var str = data[prop];
  12556. str = substIndexes(str, args, key, prop);
  12557. str = substArguments(str, args, key);
  12558. rv[prop] = str;
  12559. }
  12560. return rv;
  12561. }
  12562. function substIndexes(str, args, key, prop) {
  12563. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  12564. var reMatch = reIndex.exec(str);
  12565. if (!reMatch || !reMatch.length) return str;
  12566. var macroName = reMatch[1];
  12567. var paramName = reMatch[2];
  12568. var param;
  12569. if (args && paramName in args) {
  12570. param = args[paramName];
  12571. } else if (paramName in gL10nData) {
  12572. param = gL10nData[paramName];
  12573. }
  12574. if (macroName in gMacros) {
  12575. var macro = gMacros[macroName];
  12576. str = macro(str, param, key, prop);
  12577. }
  12578. return str;
  12579. }
  12580. function substArguments(str, args, key) {
  12581. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  12582. return str.replace(reArgs, function (matched_text, arg) {
  12583. if (args && arg in args) {
  12584. return args[arg];
  12585. }
  12586. if (arg in gL10nData) {
  12587. return gL10nData[arg];
  12588. }
  12589. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  12590. return matched_text;
  12591. });
  12592. }
  12593. function translateElement(element) {
  12594. var l10n = getL10nAttributes(element);
  12595. if (!l10n.id) return;
  12596. var data = getL10nData(l10n.id, l10n.args);
  12597. if (!data) {
  12598. console.warn('#' + l10n.id + ' is undefined.');
  12599. return;
  12600. }
  12601. if (data[gTextProp]) {
  12602. if (getChildElementCount(element) === 0) {
  12603. element[gTextProp] = data[gTextProp];
  12604. } else {
  12605. var children = element.childNodes;
  12606. var found = false;
  12607. for (var i = 0, l = children.length; i < l; i++) {
  12608. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  12609. if (found) {
  12610. children[i].nodeValue = '';
  12611. } else {
  12612. children[i].nodeValue = data[gTextProp];
  12613. found = true;
  12614. }
  12615. }
  12616. }
  12617. if (!found) {
  12618. var textNode = document.createTextNode(data[gTextProp]);
  12619. element.insertBefore(textNode, element.firstChild);
  12620. }
  12621. }
  12622. delete data[gTextProp];
  12623. }
  12624. for (var k in data) {
  12625. element[k] = data[k];
  12626. }
  12627. }
  12628. function getChildElementCount(element) {
  12629. if (element.children) {
  12630. return element.children.length;
  12631. }
  12632. if (typeof element.childElementCount !== 'undefined') {
  12633. return element.childElementCount;
  12634. }
  12635. var count = 0;
  12636. for (var i = 0; i < element.childNodes.length; i++) {
  12637. count += element.nodeType === 1 ? 1 : 0;
  12638. }
  12639. return count;
  12640. }
  12641. function translateFragment(element) {
  12642. element = element || document.documentElement;
  12643. var children = getTranslatableChildren(element);
  12644. var elementCount = children.length;
  12645. for (var i = 0; i < elementCount; i++) {
  12646. translateElement(children[i]);
  12647. }
  12648. translateElement(element);
  12649. }
  12650. return {
  12651. get: function get(key, args, fallbackString) {
  12652. var index = key.lastIndexOf('.');
  12653. var prop = gTextProp;
  12654. if (index > 0) {
  12655. prop = key.substring(index + 1);
  12656. key = key.substring(0, index);
  12657. }
  12658. var fallback;
  12659. if (fallbackString) {
  12660. fallback = {};
  12661. fallback[prop] = fallbackString;
  12662. }
  12663. var data = getL10nData(key, args, fallback);
  12664. if (data && prop in data) {
  12665. return data[prop];
  12666. }
  12667. return '{{' + key + '}}';
  12668. },
  12669. getData: function getData() {
  12670. return gL10nData;
  12671. },
  12672. getText: function getText() {
  12673. return gTextData;
  12674. },
  12675. getLanguage: function getLanguage() {
  12676. return gLanguage;
  12677. },
  12678. setLanguage: function setLanguage(lang, callback) {
  12679. loadLocale(lang, function () {
  12680. if (callback) callback();
  12681. });
  12682. },
  12683. getDirection: function getDirection() {
  12684. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  12685. var shortCode = gLanguage.split('-', 1)[0];
  12686. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  12687. },
  12688. translate: translateFragment,
  12689. getReadyState: function getReadyState() {
  12690. return gReadyState;
  12691. },
  12692. ready: function ready(callback) {
  12693. if (!callback) {
  12694. return;
  12695. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  12696. window.setTimeout(function () {
  12697. callback();
  12698. });
  12699. } else if (document.addEventListener) {
  12700. document.addEventListener('localized', function once() {
  12701. document.removeEventListener('localized', once);
  12702. callback();
  12703. });
  12704. }
  12705. }
  12706. };
  12707. }(window, document);
  12708. /***/ }),
  12709. /* 41 */
  12710. /***/ (function(module, exports, __webpack_require__) {
  12711. "use strict";
  12712. Object.defineProperty(exports, "__esModule", {
  12713. value: true
  12714. });
  12715. exports.PDFPrintService = PDFPrintService;
  12716. var _ui_utils = __webpack_require__(5);
  12717. var _app = __webpack_require__(1);
  12718. var _app_options = __webpack_require__(6);
  12719. var _pdfjsLib = __webpack_require__(7);
  12720. var activeService = null;
  12721. var overlayManager = null;
  12722. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
  12723. var scratchCanvas = activeService.scratchCanvas;
  12724. var PRINT_RESOLUTION = _app_options.AppOptions.get('printResolution') || 150;
  12725. var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
  12726. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  12727. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  12728. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + 'px';
  12729. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + 'px';
  12730. var ctx = scratchCanvas.getContext('2d');
  12731. ctx.save();
  12732. ctx.fillStyle = 'rgb(255, 255, 255)';
  12733. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  12734. ctx.restore();
  12735. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  12736. var renderContext = {
  12737. canvasContext: ctx,
  12738. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  12739. viewport: pdfPage.getViewport({
  12740. scale: 1,
  12741. rotation: size.rotation
  12742. }),
  12743. intent: 'print'
  12744. };
  12745. return pdfPage.render(renderContext).promise;
  12746. }).then(function () {
  12747. return {
  12748. width: width,
  12749. height: height
  12750. };
  12751. });
  12752. }
  12753. function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  12754. this.pdfDocument = pdfDocument;
  12755. this.pagesOverview = pagesOverview;
  12756. this.printContainer = printContainer;
  12757. this.l10n = l10n || _ui_utils.NullL10n;
  12758. this.disableCreateObjectURL = pdfDocument.loadingParams['disableCreateObjectURL'];
  12759. this.currentPage = -1;
  12760. this.scratchCanvas = document.createElement('canvas');
  12761. }
  12762. PDFPrintService.prototype = {
  12763. layout: function layout() {
  12764. this.throwIfInactive();
  12765. var body = document.querySelector('body');
  12766. body.setAttribute('data-pdfjsprinting', true);
  12767. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  12768. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  12769. }, this);
  12770. if (!hasEqualPageSizes) {
  12771. console.warn('Not all pages have the same size. The printed ' + 'result may be incorrect!');
  12772. }
  12773. this.pageStyleSheet = document.createElement('style');
  12774. var pageSize = this.pagesOverview[0];
  12775. this.pageStyleSheet.textContent = '@supports ((size:A4) and (size:1pt 1pt)) {' + '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' + '}';
  12776. body.appendChild(this.pageStyleSheet);
  12777. },
  12778. destroy: function destroy() {
  12779. if (activeService !== this) {
  12780. return;
  12781. }
  12782. this.printContainer.textContent = '';
  12783. if (this.pageStyleSheet) {
  12784. this.pageStyleSheet.remove();
  12785. this.pageStyleSheet = null;
  12786. }
  12787. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  12788. this.scratchCanvas = null;
  12789. activeService = null;
  12790. ensureOverlay().then(function () {
  12791. if (overlayManager.active !== 'printServiceOverlay') {
  12792. return;
  12793. }
  12794. overlayManager.close('printServiceOverlay');
  12795. });
  12796. },
  12797. renderPages: function renderPages() {
  12798. var _this = this;
  12799. var pageCount = this.pagesOverview.length;
  12800. var renderNextPage = function renderNextPage(resolve, reject) {
  12801. _this.throwIfInactive();
  12802. if (++_this.currentPage >= pageCount) {
  12803. renderProgress(pageCount, pageCount, _this.l10n);
  12804. resolve();
  12805. return;
  12806. }
  12807. var index = _this.currentPage;
  12808. renderProgress(index, pageCount, _this.l10n);
  12809. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () {
  12810. renderNextPage(resolve, reject);
  12811. }, reject);
  12812. };
  12813. return new Promise(renderNextPage);
  12814. },
  12815. useRenderedPage: function useRenderedPage(printItem) {
  12816. this.throwIfInactive();
  12817. var img = document.createElement('img');
  12818. img.style.width = printItem.width;
  12819. img.style.height = printItem.height;
  12820. var scratchCanvas = this.scratchCanvas;
  12821. if ('toBlob' in scratchCanvas && !this.disableCreateObjectURL) {
  12822. scratchCanvas.toBlob(function (blob) {
  12823. img.src = _pdfjsLib.URL.createObjectURL(blob);
  12824. });
  12825. } else {
  12826. img.src = scratchCanvas.toDataURL();
  12827. }
  12828. var wrapper = document.createElement('div');
  12829. wrapper.appendChild(img);
  12830. this.printContainer.appendChild(wrapper);
  12831. return new Promise(function (resolve, reject) {
  12832. img.onload = resolve;
  12833. img.onerror = reject;
  12834. });
  12835. },
  12836. performPrint: function performPrint() {
  12837. var _this2 = this;
  12838. this.throwIfInactive();
  12839. return new Promise(function (resolve) {
  12840. setTimeout(function () {
  12841. if (!_this2.active) {
  12842. resolve();
  12843. return;
  12844. }
  12845. print.call(window);
  12846. setTimeout(resolve, 20);
  12847. }, 0);
  12848. });
  12849. },
  12850. get active() {
  12851. return this === activeService;
  12852. },
  12853. throwIfInactive: function throwIfInactive() {
  12854. if (!this.active) {
  12855. throw new Error('This print request was cancelled or completed.');
  12856. }
  12857. }
  12858. };
  12859. var print = window.print;
  12860. window.print = function print() {
  12861. if (activeService) {
  12862. console.warn('Ignored window.print() because of a pending print job.');
  12863. return;
  12864. }
  12865. ensureOverlay().then(function () {
  12866. if (activeService) {
  12867. overlayManager.open('printServiceOverlay');
  12868. }
  12869. });
  12870. try {
  12871. dispatchEvent('beforeprint');
  12872. } finally {
  12873. if (!activeService) {
  12874. console.error('Expected print service to be initialized.');
  12875. ensureOverlay().then(function () {
  12876. if (overlayManager.active === 'printServiceOverlay') {
  12877. overlayManager.close('printServiceOverlay');
  12878. }
  12879. });
  12880. return;
  12881. }
  12882. var activeServiceOnEntry = activeService;
  12883. activeService.renderPages().then(function () {
  12884. return activeServiceOnEntry.performPrint();
  12885. })["catch"](function () {}).then(function () {
  12886. if (activeServiceOnEntry.active) {
  12887. abort();
  12888. }
  12889. });
  12890. }
  12891. };
  12892. function dispatchEvent(eventType) {
  12893. var event = document.createEvent('CustomEvent');
  12894. event.initCustomEvent(eventType, false, false, 'custom');
  12895. window.dispatchEvent(event);
  12896. }
  12897. function abort() {
  12898. if (activeService) {
  12899. activeService.destroy();
  12900. dispatchEvent('afterprint');
  12901. }
  12902. }
  12903. function renderProgress(index, total, l10n) {
  12904. var progressContainer = document.getElementById('printServiceOverlay');
  12905. var progress = Math.round(100 * index / total);
  12906. var progressBar = progressContainer.querySelector('progress');
  12907. var progressPerc = progressContainer.querySelector('.relative-progress');
  12908. progressBar.value = progress;
  12909. l10n.get('print_progress_percent', {
  12910. progress: progress
  12911. }, progress + '%').then(function (msg) {
  12912. progressPerc.textContent = msg;
  12913. });
  12914. }
  12915. var hasAttachEvent = !!document.attachEvent;
  12916. window.addEventListener('keydown', function (event) {
  12917. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  12918. window.print();
  12919. if (hasAttachEvent) {
  12920. return;
  12921. }
  12922. event.preventDefault();
  12923. if (event.stopImmediatePropagation) {
  12924. event.stopImmediatePropagation();
  12925. } else {
  12926. event.stopPropagation();
  12927. }
  12928. return;
  12929. }
  12930. }, true);
  12931. if (hasAttachEvent) {
  12932. document.attachEvent('onkeydown', function (event) {
  12933. event = event || window.event;
  12934. if (event.keyCode === 80 && event.ctrlKey) {
  12935. event.keyCode = 0;
  12936. return false;
  12937. }
  12938. });
  12939. }
  12940. if ('onbeforeprint' in window) {
  12941. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  12942. if (event.detail !== 'custom' && event.stopImmediatePropagation) {
  12943. event.stopImmediatePropagation();
  12944. }
  12945. };
  12946. window.addEventListener('beforeprint', stopPropagationIfNeeded);
  12947. window.addEventListener('afterprint', stopPropagationIfNeeded);
  12948. }
  12949. var overlayPromise;
  12950. function ensureOverlay() {
  12951. if (!overlayPromise) {
  12952. overlayManager = _app.PDFViewerApplication.overlayManager;
  12953. if (!overlayManager) {
  12954. throw new Error('The overlay manager has not yet been initialized.');
  12955. }
  12956. overlayPromise = overlayManager.register('printServiceOverlay', document.getElementById('printServiceOverlay'), abort, true);
  12957. document.getElementById('printCancel').onclick = abort;
  12958. }
  12959. return overlayPromise;
  12960. }
  12961. _app.PDFPrintServiceFactory.instance = {
  12962. supportsPrinting: true,
  12963. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  12964. if (activeService) {
  12965. throw new Error('The print service is created and active.');
  12966. }
  12967. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
  12968. return activeService;
  12969. }
  12970. };
  12971. /***/ })
  12972. /******/ ]);
  12973. //# sourceMappingURL=viewer.js.map