viewer.js 495 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2020 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. /******/ (function(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. source: window
  255. });
  256. try {
  257. parent.document.dispatchEvent(event);
  258. } catch (ex) {
  259. console.error("webviewerloaded: ".concat(ex));
  260. document.dispatchEvent(event);
  261. }
  262. pdfjsWebApp.PDFViewerApplication.run(config);
  263. }
  264. if (document.readyState === "interactive" || document.readyState === "complete") {
  265. webViewerLoad();
  266. } else {
  267. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  268. }
  269. /***/ }),
  270. /* 1 */
  271. /***/ (function(module, exports, __webpack_require__) {
  272. "use strict";
  273. Object.defineProperty(exports, "__esModule", {
  274. value: true
  275. });
  276. exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = void 0;
  277. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  278. var _ui_utils = __webpack_require__(5);
  279. var _app_options = __webpack_require__(6);
  280. var _pdfjsLib = __webpack_require__(8);
  281. var _pdf_cursor_tools = __webpack_require__(9);
  282. var _pdf_rendering_queue = __webpack_require__(11);
  283. var _pdf_sidebar = __webpack_require__(12);
  284. var _overlay_manager = __webpack_require__(13);
  285. var _password_prompt = __webpack_require__(14);
  286. var _pdf_attachment_viewer = __webpack_require__(15);
  287. var _pdf_document_properties = __webpack_require__(16);
  288. var _pdf_find_bar = __webpack_require__(17);
  289. var _pdf_find_controller = __webpack_require__(18);
  290. var _pdf_history = __webpack_require__(20);
  291. var _pdf_link_service = __webpack_require__(21);
  292. var _pdf_outline_viewer = __webpack_require__(22);
  293. var _pdf_presentation_mode = __webpack_require__(23);
  294. var _pdf_sidebar_resizer = __webpack_require__(24);
  295. var _pdf_thumbnail_viewer = __webpack_require__(25);
  296. var _pdf_viewer = __webpack_require__(27);
  297. var _secondary_toolbar = __webpack_require__(32);
  298. var _toolbar = __webpack_require__(34);
  299. var _view_history = __webpack_require__(35);
  300. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  301. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  302. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  303. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  304. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  305. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  306. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  307. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  308. 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); } }
  309. 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); }); }; }
  310. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  311. 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); } }
  312. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  313. var DEFAULT_SCALE_DELTA = 1.1;
  314. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  315. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  316. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  317. var ENABLE_PERMISSIONS_CLASS = "enablePermissions";
  318. var ViewOnLoad = {
  319. UNKNOWN: -1,
  320. PREVIOUS: 0,
  321. INITIAL: 1
  322. };
  323. var DefaultExternalServices = /*#__PURE__*/function () {
  324. function DefaultExternalServices() {
  325. _classCallCheck(this, DefaultExternalServices);
  326. throw new Error("Cannot initialize DefaultExternalServices.");
  327. }
  328. _createClass(DefaultExternalServices, null, [{
  329. key: "updateFindControlState",
  330. value: function updateFindControlState(data) {}
  331. }, {
  332. key: "updateFindMatchesCount",
  333. value: function updateFindMatchesCount(data) {}
  334. }, {
  335. key: "initPassiveLoading",
  336. value: function initPassiveLoading(callbacks) {}
  337. }, {
  338. key: "fallback",
  339. value: function fallback(data, callback) {}
  340. }, {
  341. key: "reportTelemetry",
  342. value: function reportTelemetry(data) {}
  343. }, {
  344. key: "createDownloadManager",
  345. value: function createDownloadManager(options) {
  346. throw new Error("Not implemented: createDownloadManager");
  347. }
  348. }, {
  349. key: "createPreferences",
  350. value: function createPreferences() {
  351. throw new Error("Not implemented: createPreferences");
  352. }
  353. }, {
  354. key: "createL10n",
  355. value: function createL10n(options) {
  356. throw new Error("Not implemented: createL10n");
  357. }
  358. }, {
  359. key: "supportsIntegratedFind",
  360. get: function get() {
  361. return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false);
  362. }
  363. }, {
  364. key: "supportsDocumentFonts",
  365. get: function get() {
  366. return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts", true);
  367. }
  368. }, {
  369. key: "supportedMouseWheelZoomModifierKeys",
  370. get: function get() {
  371. return (0, _pdfjsLib.shadow)(this, "supportedMouseWheelZoomModifierKeys", {
  372. ctrlKey: true,
  373. metaKey: true
  374. });
  375. }
  376. }, {
  377. key: "isInAutomation",
  378. get: function get() {
  379. return (0, _pdfjsLib.shadow)(this, "isInAutomation", false);
  380. }
  381. }]);
  382. return DefaultExternalServices;
  383. }();
  384. exports.DefaultExternalServices = DefaultExternalServices;
  385. var PDFViewerApplication = {
  386. initialBookmark: document.location.hash.substring(1),
  387. _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(),
  388. fellback: false,
  389. appConfig: null,
  390. pdfDocument: null,
  391. pdfLoadingTask: null,
  392. printService: null,
  393. pdfViewer: null,
  394. pdfThumbnailViewer: null,
  395. pdfRenderingQueue: null,
  396. pdfPresentationMode: null,
  397. pdfDocumentProperties: null,
  398. pdfLinkService: null,
  399. pdfHistory: null,
  400. pdfSidebar: null,
  401. pdfSidebarResizer: null,
  402. pdfOutlineViewer: null,
  403. pdfAttachmentViewer: null,
  404. pdfCursorTools: null,
  405. store: null,
  406. downloadManager: null,
  407. overlayManager: null,
  408. preferences: null,
  409. toolbar: null,
  410. secondaryToolbar: null,
  411. eventBus: null,
  412. l10n: null,
  413. isInitialViewSet: false,
  414. downloadComplete: false,
  415. isViewerEmbedded: window.parent !== window,
  416. url: "",
  417. baseUrl: "",
  418. externalServices: DefaultExternalServices,
  419. _boundEvents: {},
  420. contentDispositionFilename: null,
  421. initialize: function initialize(appConfig) {
  422. var _this = this;
  423. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  424. var appContainer;
  425. return _regenerator["default"].wrap(function _callee$(_context) {
  426. while (1) {
  427. switch (_context.prev = _context.next) {
  428. case 0:
  429. _this.preferences = _this.externalServices.createPreferences();
  430. _this.appConfig = appConfig;
  431. _context.next = 4;
  432. return _this._readPreferences();
  433. case 4:
  434. _context.next = 6;
  435. return _this._parseHashParameters();
  436. case 6:
  437. _context.next = 8;
  438. return _this._initializeL10n();
  439. case 8:
  440. if (_this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdfjsLib.LinkTarget.NONE) {
  441. _app_options.AppOptions.set("externalLinkTarget", _pdfjsLib.LinkTarget.TOP);
  442. }
  443. _context.next = 11;
  444. return _this._initializeViewerComponents();
  445. case 11:
  446. _this.bindEvents();
  447. _this.bindWindowEvents();
  448. appContainer = appConfig.appContainer || document.documentElement;
  449. _this.l10n.translate(appContainer).then(function () {
  450. _this.eventBus.dispatch("localized", {
  451. source: _this
  452. });
  453. });
  454. _this._initializedCapability.resolve();
  455. case 16:
  456. case "end":
  457. return _context.stop();
  458. }
  459. }
  460. }, _callee);
  461. }))();
  462. },
  463. _readPreferences: function _readPreferences() {
  464. var _this2 = this;
  465. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  466. var prefs, name;
  467. return _regenerator["default"].wrap(function _callee2$(_context2) {
  468. while (1) {
  469. switch (_context2.prev = _context2.next) {
  470. case 0:
  471. if (!_app_options.AppOptions.get("disablePreferences")) {
  472. _context2.next = 2;
  473. break;
  474. }
  475. return _context2.abrupt("return");
  476. case 2:
  477. _context2.prev = 2;
  478. _context2.next = 5;
  479. return _this2.preferences.getAll();
  480. case 5:
  481. prefs = _context2.sent;
  482. for (name in prefs) {
  483. _app_options.AppOptions.set(name, prefs[name]);
  484. }
  485. _context2.next = 12;
  486. break;
  487. case 9:
  488. _context2.prev = 9;
  489. _context2.t0 = _context2["catch"](2);
  490. console.error("_readPreferences: \"".concat(_context2.t0.message, "\"."));
  491. case 12:
  492. case "end":
  493. return _context2.stop();
  494. }
  495. }
  496. }, _callee2, null, [[2, 9]]);
  497. }))();
  498. },
  499. _parseHashParameters: function _parseHashParameters() {
  500. var _this3 = this;
  501. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  502. var hash, hashParams, waitOn, viewer, enabled;
  503. return _regenerator["default"].wrap(function _callee3$(_context3) {
  504. while (1) {
  505. switch (_context3.prev = _context3.next) {
  506. case 0:
  507. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  508. _context3.next = 2;
  509. break;
  510. }
  511. return _context3.abrupt("return", undefined);
  512. case 2:
  513. hash = document.location.hash.substring(1);
  514. if (hash) {
  515. _context3.next = 5;
  516. break;
  517. }
  518. return _context3.abrupt("return", undefined);
  519. case 5:
  520. hashParams = (0, _ui_utils.parseQueryString)(hash), waitOn = [];
  521. if ("disableworker" in hashParams && hashParams.disableworker === "true") {
  522. waitOn.push(loadFakeWorker());
  523. }
  524. if ("disablerange" in hashParams) {
  525. _app_options.AppOptions.set("disableRange", hashParams.disablerange === "true");
  526. }
  527. if ("disablestream" in hashParams) {
  528. _app_options.AppOptions.set("disableStream", hashParams.disablestream === "true");
  529. }
  530. if ("disableautofetch" in hashParams) {
  531. _app_options.AppOptions.set("disableAutoFetch", hashParams.disableautofetch === "true");
  532. }
  533. if ("disablefontface" in hashParams) {
  534. _app_options.AppOptions.set("disableFontFace", hashParams.disablefontface === "true");
  535. }
  536. if ("disablehistory" in hashParams) {
  537. _app_options.AppOptions.set("disableHistory", hashParams.disablehistory === "true");
  538. }
  539. if ("webgl" in hashParams) {
  540. _app_options.AppOptions.set("enableWebGL", hashParams.webgl === "true");
  541. }
  542. if ("verbosity" in hashParams) {
  543. _app_options.AppOptions.set("verbosity", hashParams.verbosity | 0);
  544. }
  545. if (!("textlayer" in hashParams)) {
  546. _context3.next = 23;
  547. break;
  548. }
  549. _context3.t0 = hashParams.textlayer;
  550. _context3.next = _context3.t0 === "off" ? 18 : _context3.t0 === "visible" ? 20 : _context3.t0 === "shadow" ? 20 : _context3.t0 === "hover" ? 20 : 23;
  551. break;
  552. case 18:
  553. _app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
  554. return _context3.abrupt("break", 23);
  555. case 20:
  556. viewer = _this3.appConfig.viewerContainer;
  557. viewer.classList.add("textLayer-" + hashParams.textlayer);
  558. return _context3.abrupt("break", 23);
  559. case 23:
  560. if ("pdfbug" in hashParams) {
  561. _app_options.AppOptions.set("pdfBug", true);
  562. _app_options.AppOptions.set("fontExtraProperties", true);
  563. enabled = hashParams.pdfbug.split(",");
  564. waitOn.push(loadAndEnablePDFBug(enabled));
  565. }
  566. if ("locale" in hashParams) {
  567. _app_options.AppOptions.set("locale", hashParams.locale);
  568. }
  569. return _context3.abrupt("return", Promise.all(waitOn)["catch"](function (reason) {
  570. console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
  571. }));
  572. case 26:
  573. case "end":
  574. return _context3.stop();
  575. }
  576. }
  577. }, _callee3);
  578. }))();
  579. },
  580. _initializeL10n: function _initializeL10n() {
  581. var _this4 = this;
  582. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  583. var dir;
  584. return _regenerator["default"].wrap(function _callee4$(_context4) {
  585. while (1) {
  586. switch (_context4.prev = _context4.next) {
  587. case 0:
  588. _this4.l10n = _this4.externalServices.createL10n({
  589. locale: _app_options.AppOptions.get("locale")
  590. });
  591. _context4.next = 3;
  592. return _this4.l10n.getDirection();
  593. case 3:
  594. dir = _context4.sent;
  595. document.getElementsByTagName("html")[0].dir = dir;
  596. case 5:
  597. case "end":
  598. return _context4.stop();
  599. }
  600. }
  601. }, _callee4);
  602. }))();
  603. },
  604. _initializeViewerComponents: function _initializeViewerComponents() {
  605. var _this5 = this;
  606. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
  607. var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer;
  608. return _regenerator["default"].wrap(function _callee5$(_context5) {
  609. while (1) {
  610. switch (_context5.prev = _context5.next) {
  611. case 0:
  612. appConfig = _this5.appConfig;
  613. eventBus = appConfig.eventBus || new _ui_utils.EventBus({
  614. isInAutomation: _this5.externalServices.isInAutomation
  615. });
  616. _this5.eventBus = eventBus;
  617. _this5.overlayManager = new _overlay_manager.OverlayManager();
  618. pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  619. pdfRenderingQueue.onIdle = _this5.cleanup.bind(_this5);
  620. _this5.pdfRenderingQueue = pdfRenderingQueue;
  621. pdfLinkService = new _pdf_link_service.PDFLinkService({
  622. eventBus: eventBus,
  623. externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"),
  624. externalLinkRel: _app_options.AppOptions.get("externalLinkRel"),
  625. ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom")
  626. });
  627. _this5.pdfLinkService = pdfLinkService;
  628. downloadManager = _this5.externalServices.createDownloadManager({
  629. disableCreateObjectURL: _app_options.AppOptions.get("disableCreateObjectURL")
  630. });
  631. _this5.downloadManager = downloadManager;
  632. findController = new _pdf_find_controller.PDFFindController({
  633. linkService: pdfLinkService,
  634. eventBus: eventBus
  635. });
  636. _this5.findController = findController;
  637. container = appConfig.mainContainer;
  638. viewer = appConfig.viewerContainer;
  639. _this5.pdfViewer = new _pdf_viewer.PDFViewer({
  640. container: container,
  641. viewer: viewer,
  642. eventBus: eventBus,
  643. renderingQueue: pdfRenderingQueue,
  644. linkService: pdfLinkService,
  645. downloadManager: downloadManager,
  646. findController: findController,
  647. renderer: _app_options.AppOptions.get("renderer"),
  648. enableWebGL: _app_options.AppOptions.get("enableWebGL"),
  649. l10n: _this5.l10n,
  650. textLayerMode: _app_options.AppOptions.get("textLayerMode"),
  651. imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"),
  652. renderInteractiveForms: _app_options.AppOptions.get("renderInteractiveForms"),
  653. enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"),
  654. useOnlyCssZoom: _app_options.AppOptions.get("useOnlyCssZoom"),
  655. maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels")
  656. });
  657. pdfRenderingQueue.setViewer(_this5.pdfViewer);
  658. pdfLinkService.setViewer(_this5.pdfViewer);
  659. _this5.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  660. container: appConfig.sidebar.thumbnailView,
  661. renderingQueue: pdfRenderingQueue,
  662. linkService: pdfLinkService,
  663. l10n: _this5.l10n
  664. });
  665. pdfRenderingQueue.setThumbnailViewer(_this5.pdfThumbnailViewer);
  666. _this5.pdfHistory = new _pdf_history.PDFHistory({
  667. linkService: pdfLinkService,
  668. eventBus: eventBus
  669. });
  670. pdfLinkService.setHistory(_this5.pdfHistory);
  671. if (!_this5.supportsIntegratedFind) {
  672. _this5.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, _this5.l10n);
  673. }
  674. _this5.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this5.overlayManager, eventBus, _this5.l10n);
  675. _this5.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  676. container: container,
  677. eventBus: eventBus,
  678. cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad")
  679. });
  680. _this5.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, _this5.l10n);
  681. _this5.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  682. if (_this5.supportsFullscreen) {
  683. _this5.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  684. container: container,
  685. pdfViewer: _this5.pdfViewer,
  686. eventBus: eventBus,
  687. contextMenuItems: appConfig.fullscreen
  688. });
  689. }
  690. _this5.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this5.overlayManager, _this5.l10n);
  691. _this5.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  692. container: appConfig.sidebar.outlineView,
  693. eventBus: eventBus,
  694. linkService: pdfLinkService
  695. });
  696. _this5.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  697. container: appConfig.sidebar.attachmentsView,
  698. eventBus: eventBus,
  699. downloadManager: downloadManager
  700. });
  701. _this5.pdfSidebar = new _pdf_sidebar.PDFSidebar({
  702. elements: appConfig.sidebar,
  703. pdfViewer: _this5.pdfViewer,
  704. pdfThumbnailViewer: _this5.pdfThumbnailViewer,
  705. eventBus: eventBus,
  706. l10n: _this5.l10n
  707. });
  708. _this5.pdfSidebar.onToggled = _this5.forceRendering.bind(_this5);
  709. _this5.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, _this5.l10n);
  710. case 34:
  711. case "end":
  712. return _context5.stop();
  713. }
  714. }
  715. }, _callee5);
  716. }))();
  717. },
  718. run: function run(config) {
  719. this.initialize(config).then(webViewerInitialized);
  720. },
  721. get initialized() {
  722. return this._initializedCapability.settled;
  723. },
  724. get initializedPromise() {
  725. return this._initializedCapability.promise;
  726. },
  727. zoomIn: function zoomIn(ticks) {
  728. if (this.pdfViewer.isInPresentationMode) {
  729. return;
  730. }
  731. var newScale = this.pdfViewer.currentScale;
  732. do {
  733. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  734. newScale = Math.ceil(newScale * 10) / 10;
  735. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  736. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  737. this.pdfViewer.currentScaleValue = newScale;
  738. },
  739. zoomOut: function zoomOut(ticks) {
  740. if (this.pdfViewer.isInPresentationMode) {
  741. return;
  742. }
  743. var newScale = this.pdfViewer.currentScale;
  744. do {
  745. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  746. newScale = Math.floor(newScale * 10) / 10;
  747. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  748. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  749. this.pdfViewer.currentScaleValue = newScale;
  750. },
  751. zoomReset: function zoomReset() {
  752. if (this.pdfViewer.isInPresentationMode) {
  753. return;
  754. }
  755. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  756. },
  757. get pagesCount() {
  758. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  759. },
  760. get page() {
  761. return this.pdfViewer.currentPageNumber;
  762. },
  763. set page(val) {
  764. this.pdfViewer.currentPageNumber = val;
  765. },
  766. get printing() {
  767. return !!this.printService;
  768. },
  769. get supportsPrinting() {
  770. return PDFPrintServiceFactory.instance.supportsPrinting;
  771. },
  772. get supportsFullscreen() {
  773. var support;
  774. var doc = document.documentElement;
  775. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
  776. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
  777. support = false;
  778. }
  779. return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", support);
  780. },
  781. get supportsIntegratedFind() {
  782. return this.externalServices.supportsIntegratedFind;
  783. },
  784. get supportsDocumentFonts() {
  785. return this.externalServices.supportsDocumentFonts;
  786. },
  787. get loadingBar() {
  788. var bar = new _ui_utils.ProgressBar("#loadingBar");
  789. return (0, _pdfjsLib.shadow)(this, "loadingBar", bar);
  790. },
  791. get supportedMouseWheelZoomModifierKeys() {
  792. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  793. },
  794. initPassiveLoading: function initPassiveLoading() {
  795. throw new Error("Not implemented: initPassiveLoading");
  796. },
  797. setTitleUsingUrl: function setTitleUsingUrl() {
  798. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  799. this.url = url;
  800. this.baseUrl = url.split("#")[0];
  801. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, "");
  802. if (!title) {
  803. try {
  804. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  805. } catch (ex) {
  806. title = url;
  807. }
  808. }
  809. this.setTitle(title);
  810. },
  811. setTitle: function setTitle(title) {
  812. if (this.isViewerEmbedded) {
  813. return;
  814. }
  815. document.title = title;
  816. },
  817. close: function close() {
  818. var _this6 = this;
  819. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  820. var errorWrapper, promise;
  821. return _regenerator["default"].wrap(function _callee6$(_context6) {
  822. while (1) {
  823. switch (_context6.prev = _context6.next) {
  824. case 0:
  825. errorWrapper = _this6.appConfig.errorWrapper.container;
  826. errorWrapper.setAttribute("hidden", "true");
  827. if (_this6.pdfLoadingTask) {
  828. _context6.next = 4;
  829. break;
  830. }
  831. return _context6.abrupt("return", undefined);
  832. case 4:
  833. promise = _this6.pdfLoadingTask.destroy();
  834. _this6.pdfLoadingTask = null;
  835. if (_this6.pdfDocument) {
  836. _this6.pdfDocument = null;
  837. _this6.pdfThumbnailViewer.setDocument(null);
  838. _this6.pdfViewer.setDocument(null);
  839. _this6.pdfLinkService.setDocument(null);
  840. _this6.pdfDocumentProperties.setDocument(null);
  841. }
  842. webViewerResetPermissions();
  843. _this6.store = null;
  844. _this6.isInitialViewSet = false;
  845. _this6.downloadComplete = false;
  846. _this6.url = "";
  847. _this6.baseUrl = "";
  848. _this6.contentDispositionFilename = null;
  849. _this6.pdfSidebar.reset();
  850. _this6.pdfOutlineViewer.reset();
  851. _this6.pdfAttachmentViewer.reset();
  852. if (_this6.pdfHistory) {
  853. _this6.pdfHistory.reset();
  854. }
  855. if (_this6.findBar) {
  856. _this6.findBar.reset();
  857. }
  858. _this6.toolbar.reset();
  859. _this6.secondaryToolbar.reset();
  860. if (typeof PDFBug !== "undefined") {
  861. PDFBug.cleanup();
  862. }
  863. return _context6.abrupt("return", promise);
  864. case 23:
  865. case "end":
  866. return _context6.stop();
  867. }
  868. }
  869. }, _callee6);
  870. }))();
  871. },
  872. open: function open(file, args) {
  873. var _this7 = this;
  874. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
  875. var workerParameters, key, parameters, apiParameters, _key, value, _key2, _value, loadingTask;
  876. return _regenerator["default"].wrap(function _callee7$(_context7) {
  877. while (1) {
  878. switch (_context7.prev = _context7.next) {
  879. case 0:
  880. if (!_this7.pdfLoadingTask) {
  881. _context7.next = 3;
  882. break;
  883. }
  884. _context7.next = 3;
  885. return _this7.close();
  886. case 3:
  887. workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
  888. for (key in workerParameters) {
  889. _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key];
  890. }
  891. parameters = Object.create(null);
  892. if (typeof file === "string") {
  893. _this7.setTitleUsingUrl(file);
  894. parameters.url = file;
  895. } else if (file && "byteLength" in file) {
  896. parameters.data = file;
  897. } else if (file.url && file.originalUrl) {
  898. _this7.setTitleUsingUrl(file.originalUrl);
  899. parameters.url = file.url;
  900. }
  901. apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
  902. for (_key in apiParameters) {
  903. value = apiParameters[_key];
  904. if (_key === "docBaseUrl" && !value) {}
  905. parameters[_key] = value;
  906. }
  907. if (args) {
  908. for (_key2 in args) {
  909. _value = args[_key2];
  910. if (_key2 === "length") {
  911. _this7.pdfDocumentProperties.setFileSize(_value);
  912. }
  913. parameters[_key2] = _value;
  914. }
  915. }
  916. loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  917. _this7.pdfLoadingTask = loadingTask;
  918. loadingTask.onPassword = function (updateCallback, reason) {
  919. _this7.pdfLinkService.externalLinkEnabled = false;
  920. _this7.passwordPrompt.setUpdateCallback(updateCallback, reason);
  921. _this7.passwordPrompt.open();
  922. };
  923. loadingTask.onProgress = function (_ref) {
  924. var loaded = _ref.loaded,
  925. total = _ref.total;
  926. _this7.progress(loaded / total);
  927. };
  928. loadingTask.onUnsupportedFeature = _this7.fallback.bind(_this7);
  929. return _context7.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
  930. _this7.load(pdfDocument);
  931. }, function (exception) {
  932. if (loadingTask !== _this7.pdfLoadingTask) {
  933. return undefined;
  934. }
  935. var message = exception && exception.message;
  936. var loadingErrorMessage;
  937. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  938. loadingErrorMessage = _this7.l10n.get("invalid_file_error", null, "Invalid or corrupted PDF file.");
  939. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  940. loadingErrorMessage = _this7.l10n.get("missing_file_error", null, "Missing PDF file.");
  941. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  942. loadingErrorMessage = _this7.l10n.get("unexpected_response_error", null, "Unexpected server response.");
  943. } else {
  944. loadingErrorMessage = _this7.l10n.get("loading_error", null, "An error occurred while loading the PDF.");
  945. }
  946. return loadingErrorMessage.then(function (msg) {
  947. _this7.error(msg, {
  948. message: message
  949. });
  950. throw exception;
  951. });
  952. }));
  953. case 16:
  954. case "end":
  955. return _context7.stop();
  956. }
  957. }
  958. }, _callee7);
  959. }))();
  960. },
  961. download: function download() {
  962. var _this8 = this;
  963. function downloadByUrl() {
  964. downloadManager.downloadUrl(url, filename);
  965. }
  966. var url = this.baseUrl;
  967. var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  968. var downloadManager = this.downloadManager;
  969. downloadManager.onerror = function (err) {
  970. _this8.error("PDF failed to download: ".concat(err));
  971. };
  972. if (!this.pdfDocument || !this.downloadComplete) {
  973. downloadByUrl();
  974. return;
  975. }
  976. this.pdfDocument.getData().then(function (data) {
  977. var blob = new Blob([data], {
  978. type: "application/pdf"
  979. });
  980. downloadManager.download(blob, url, filename);
  981. })["catch"](downloadByUrl);
  982. },
  983. fallback: function fallback(featureId) {
  984. if (this.fellback) {
  985. return;
  986. }
  987. this.fellback = true;
  988. this.externalServices.fallback({
  989. featureId: featureId,
  990. url: this.baseUrl
  991. }, function response(download) {
  992. if (!download) {
  993. return;
  994. }
  995. PDFViewerApplication.download();
  996. });
  997. },
  998. error: function error(message, moreInfo) {
  999. var moreInfoText = [this.l10n.get("error_version_info", {
  1000. version: _pdfjsLib.version || "?",
  1001. build: _pdfjsLib.build || "?"
  1002. }, "PDF.js v{{version}} (build: {{build}})")];
  1003. if (moreInfo) {
  1004. moreInfoText.push(this.l10n.get("error_message", {
  1005. message: moreInfo.message
  1006. }, "Message: {{message}}"));
  1007. if (moreInfo.stack) {
  1008. moreInfoText.push(this.l10n.get("error_stack", {
  1009. stack: moreInfo.stack
  1010. }, "Stack: {{stack}}"));
  1011. } else {
  1012. if (moreInfo.filename) {
  1013. moreInfoText.push(this.l10n.get("error_file", {
  1014. file: moreInfo.filename
  1015. }, "File: {{file}}"));
  1016. }
  1017. if (moreInfo.lineNumber) {
  1018. moreInfoText.push(this.l10n.get("error_line", {
  1019. line: moreInfo.lineNumber
  1020. }, "Line: {{line}}"));
  1021. }
  1022. }
  1023. }
  1024. var errorWrapperConfig = this.appConfig.errorWrapper;
  1025. var errorWrapper = errorWrapperConfig.container;
  1026. errorWrapper.removeAttribute("hidden");
  1027. var errorMessage = errorWrapperConfig.errorMessage;
  1028. errorMessage.textContent = message;
  1029. var closeButton = errorWrapperConfig.closeButton;
  1030. closeButton.onclick = function () {
  1031. errorWrapper.setAttribute("hidden", "true");
  1032. };
  1033. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  1034. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  1035. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  1036. moreInfoButton.onclick = function () {
  1037. errorMoreInfo.removeAttribute("hidden");
  1038. moreInfoButton.setAttribute("hidden", "true");
  1039. lessInfoButton.removeAttribute("hidden");
  1040. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + "px";
  1041. };
  1042. lessInfoButton.onclick = function () {
  1043. errorMoreInfo.setAttribute("hidden", "true");
  1044. moreInfoButton.removeAttribute("hidden");
  1045. lessInfoButton.setAttribute("hidden", "true");
  1046. };
  1047. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1048. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1049. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1050. moreInfoButton.removeAttribute("hidden");
  1051. lessInfoButton.setAttribute("hidden", "true");
  1052. Promise.all(moreInfoText).then(function (parts) {
  1053. errorMoreInfo.value = parts.join("\n");
  1054. });
  1055. },
  1056. progress: function progress(level) {
  1057. var _this9 = this;
  1058. if (this.downloadComplete) {
  1059. return;
  1060. }
  1061. var percent = Math.round(level * 100);
  1062. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1063. this.loadingBar.percent = percent;
  1064. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams.disableAutoFetch : _app_options.AppOptions.get("disableAutoFetch");
  1065. if (disableAutoFetch && percent) {
  1066. if (this.disableAutoFetchLoadingBarTimeout) {
  1067. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1068. this.disableAutoFetchLoadingBarTimeout = null;
  1069. }
  1070. this.loadingBar.show();
  1071. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  1072. _this9.loadingBar.hide();
  1073. _this9.disableAutoFetchLoadingBarTimeout = null;
  1074. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1075. }
  1076. }
  1077. },
  1078. load: function load(pdfDocument) {
  1079. var _this10 = this;
  1080. this.pdfDocument = pdfDocument;
  1081. pdfDocument.getDownloadInfo().then(function () {
  1082. _this10.downloadComplete = true;
  1083. _this10.loadingBar.hide();
  1084. firstPagePromise.then(function () {
  1085. _this10.eventBus.dispatch("documentloaded", {
  1086. source: _this10
  1087. });
  1088. });
  1089. });
  1090. var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function () {});
  1091. var pageModePromise = pdfDocument.getPageMode()["catch"](function () {});
  1092. var openActionPromise = pdfDocument.getOpenAction()["catch"](function () {});
  1093. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1094. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1095. var baseDocumentUrl;
  1096. baseDocumentUrl = null;
  1097. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1098. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1099. var pdfViewer = this.pdfViewer;
  1100. pdfViewer.setDocument(pdfDocument);
  1101. var firstPagePromise = pdfViewer.firstPagePromise,
  1102. onePageRendered = pdfViewer.onePageRendered,
  1103. pagesPromise = pdfViewer.pagesPromise;
  1104. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1105. pdfThumbnailViewer.setDocument(pdfDocument);
  1106. var storedPromise = (this.store = new _view_history.ViewHistory(pdfDocument.fingerprint)).getMultiple({
  1107. page: null,
  1108. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1109. scrollLeft: "0",
  1110. scrollTop: "0",
  1111. rotation: null,
  1112. sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
  1113. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  1114. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  1115. })["catch"](function () {
  1116. return Object.create(null);
  1117. });
  1118. firstPagePromise.then(function (pdfPage) {
  1119. _this10.loadingBar.setWidth(_this10.appConfig.viewerContainer);
  1120. Promise.all([_ui_utils.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then( /*#__PURE__*/function () {
  1121. var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee8(_ref2) {
  1122. var _ref4, timeStamp, stored, pageLayout, pageMode, openAction, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
  1123. return _regenerator["default"].wrap(function _callee8$(_context8) {
  1124. while (1) {
  1125. switch (_context8.prev = _context8.next) {
  1126. case 0:
  1127. _ref4 = _slicedToArray(_ref2, 5), timeStamp = _ref4[0], stored = _ref4[1], pageLayout = _ref4[2], pageMode = _ref4[3], openAction = _ref4[4];
  1128. viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
  1129. _this10._initializePdfHistory({
  1130. fingerprint: pdfDocument.fingerprint,
  1131. viewOnLoad: viewOnLoad,
  1132. initialDest: openAction && openAction.dest
  1133. });
  1134. initialBookmark = _this10.initialBookmark;
  1135. zoom = _app_options.AppOptions.get("defaultZoomValue");
  1136. hash = zoom ? "zoom=".concat(zoom) : null;
  1137. rotation = null;
  1138. sidebarView = _app_options.AppOptions.get("sidebarViewOnLoad");
  1139. scrollMode = _app_options.AppOptions.get("scrollModeOnLoad");
  1140. spreadMode = _app_options.AppOptions.get("spreadModeOnLoad");
  1141. if (stored.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  1142. hash = "page=".concat(stored.page, "&zoom=").concat(zoom || stored.zoom, ",") + "".concat(stored.scrollLeft, ",").concat(stored.scrollTop);
  1143. rotation = parseInt(stored.rotation, 10);
  1144. if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  1145. sidebarView = stored.sidebarView | 0;
  1146. }
  1147. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  1148. scrollMode = stored.scrollMode | 0;
  1149. }
  1150. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1151. spreadMode = stored.spreadMode | 0;
  1152. }
  1153. }
  1154. if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  1155. sidebarView = apiPageModeToSidebarView(pageMode);
  1156. }
  1157. if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1158. spreadMode = apiPageLayoutToSpreadMode(pageLayout);
  1159. }
  1160. _this10.setInitialView(hash, {
  1161. rotation: rotation,
  1162. sidebarView: sidebarView,
  1163. scrollMode: scrollMode,
  1164. spreadMode: spreadMode
  1165. });
  1166. _this10.eventBus.dispatch("documentinit", {
  1167. source: _this10
  1168. });
  1169. if (!_this10.isViewerEmbedded) {
  1170. pdfViewer.focus();
  1171. }
  1172. _this10._initializePermissions(pdfDocument);
  1173. _context8.next = 19;
  1174. return Promise.race([pagesPromise, new Promise(function (resolve) {
  1175. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  1176. })]);
  1177. case 19:
  1178. if (!(!initialBookmark && !hash)) {
  1179. _context8.next = 21;
  1180. break;
  1181. }
  1182. return _context8.abrupt("return");
  1183. case 21:
  1184. if (!pdfViewer.hasEqualPageSizes) {
  1185. _context8.next = 23;
  1186. break;
  1187. }
  1188. return _context8.abrupt("return");
  1189. case 23:
  1190. _this10.initialBookmark = initialBookmark;
  1191. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  1192. _this10.setInitialView(hash);
  1193. case 26:
  1194. case "end":
  1195. return _context8.stop();
  1196. }
  1197. }
  1198. }, _callee8);
  1199. }));
  1200. return function (_x) {
  1201. return _ref3.apply(this, arguments);
  1202. };
  1203. }())["catch"](function () {
  1204. _this10.setInitialView();
  1205. }).then(function () {
  1206. pdfViewer.update();
  1207. });
  1208. });
  1209. pagesPromise.then(function () {
  1210. _this10._initializeAutoPrint(pdfDocument, openActionPromise);
  1211. });
  1212. onePageRendered.then(function () {
  1213. pdfDocument.getOutline().then(function (outline) {
  1214. _this10.pdfOutlineViewer.render({
  1215. outline: outline
  1216. });
  1217. });
  1218. pdfDocument.getAttachments().then(function (attachments) {
  1219. _this10.pdfAttachmentViewer.render({
  1220. attachments: attachments
  1221. });
  1222. });
  1223. });
  1224. this._initializePageLabels(pdfDocument);
  1225. this._initializeMetadata(pdfDocument);
  1226. },
  1227. _initializeAutoPrint: function _initializeAutoPrint(pdfDocument, openActionPromise) {
  1228. var _this11 = this;
  1229. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
  1230. var _yield$Promise$all, _yield$Promise$all2, openAction, javaScript, triggerAutoPrint, _iterator, _step, js;
  1231. return _regenerator["default"].wrap(function _callee9$(_context9) {
  1232. while (1) {
  1233. switch (_context9.prev = _context9.next) {
  1234. case 0:
  1235. _context9.next = 2;
  1236. return Promise.all([openActionPromise, pdfDocument.getJavaScript()]);
  1237. case 2:
  1238. _yield$Promise$all = _context9.sent;
  1239. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
  1240. openAction = _yield$Promise$all2[0];
  1241. javaScript = _yield$Promise$all2[1];
  1242. if (!(pdfDocument !== _this11.pdfDocument)) {
  1243. _context9.next = 8;
  1244. break;
  1245. }
  1246. return _context9.abrupt("return");
  1247. case 8:
  1248. triggerAutoPrint = false;
  1249. if (openAction && openAction.action === "Print") {
  1250. triggerAutoPrint = true;
  1251. }
  1252. if (!javaScript) {
  1253. _context9.next = 31;
  1254. break;
  1255. }
  1256. javaScript.some(function (js) {
  1257. if (!js) {
  1258. return false;
  1259. }
  1260. console.warn("Warning: JavaScript is not supported");
  1261. _this11.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  1262. return true;
  1263. });
  1264. if (triggerAutoPrint) {
  1265. _context9.next = 31;
  1266. break;
  1267. }
  1268. _iterator = _createForOfIteratorHelper(javaScript);
  1269. _context9.prev = 14;
  1270. _iterator.s();
  1271. case 16:
  1272. if ((_step = _iterator.n()).done) {
  1273. _context9.next = 23;
  1274. break;
  1275. }
  1276. js = _step.value;
  1277. if (!(js && _ui_utils.AutoPrintRegExp.test(js))) {
  1278. _context9.next = 21;
  1279. break;
  1280. }
  1281. triggerAutoPrint = true;
  1282. return _context9.abrupt("break", 23);
  1283. case 21:
  1284. _context9.next = 16;
  1285. break;
  1286. case 23:
  1287. _context9.next = 28;
  1288. break;
  1289. case 25:
  1290. _context9.prev = 25;
  1291. _context9.t0 = _context9["catch"](14);
  1292. _iterator.e(_context9.t0);
  1293. case 28:
  1294. _context9.prev = 28;
  1295. _iterator.f();
  1296. return _context9.finish(28);
  1297. case 31:
  1298. if (_this11.supportsPrinting) {
  1299. _context9.next = 33;
  1300. break;
  1301. }
  1302. return _context9.abrupt("return");
  1303. case 33:
  1304. if (triggerAutoPrint) {
  1305. setTimeout(function () {
  1306. window.print();
  1307. });
  1308. }
  1309. case 34:
  1310. case "end":
  1311. return _context9.stop();
  1312. }
  1313. }
  1314. }, _callee9, null, [[14, 25, 28, 31]]);
  1315. }))();
  1316. },
  1317. _initializeMetadata: function _initializeMetadata(pdfDocument) {
  1318. var _this12 = this;
  1319. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee10() {
  1320. var _yield$pdfDocument$ge, info, metadata, contentDispositionFilename, pdfTitle, infoTitle, metadataTitle, versionId, KNOWN_VERSIONS, generatorId, KNOWN_GENERATORS, producer, formType;
  1321. return _regenerator["default"].wrap(function _callee10$(_context10) {
  1322. while (1) {
  1323. switch (_context10.prev = _context10.next) {
  1324. case 0:
  1325. _context10.next = 2;
  1326. return pdfDocument.getMetadata();
  1327. case 2:
  1328. _yield$pdfDocument$ge = _context10.sent;
  1329. info = _yield$pdfDocument$ge.info;
  1330. metadata = _yield$pdfDocument$ge.metadata;
  1331. contentDispositionFilename = _yield$pdfDocument$ge.contentDispositionFilename;
  1332. if (!(pdfDocument !== _this12.pdfDocument)) {
  1333. _context10.next = 8;
  1334. break;
  1335. }
  1336. return _context10.abrupt("return");
  1337. case 8:
  1338. _this12.documentInfo = info;
  1339. _this12.metadata = metadata;
  1340. _this12.contentDispositionFilename = contentDispositionFilename;
  1341. console.log("PDF ".concat(pdfDocument.fingerprint, " [").concat(info.PDFFormatVersion, " ") + "".concat((info.Producer || "-").trim(), " / ").concat((info.Creator || "-").trim(), "] ") + "(PDF.js: ".concat(_pdfjsLib.version || "-") + "".concat(_this12.pdfViewer.enableWebGL ? " [WebGL]" : "", ")"));
  1342. infoTitle = info && info.Title;
  1343. if (infoTitle) {
  1344. pdfTitle = infoTitle;
  1345. }
  1346. metadataTitle = metadata && metadata.get("dc:title");
  1347. if (metadataTitle) {
  1348. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
  1349. pdfTitle = metadataTitle;
  1350. }
  1351. }
  1352. if (pdfTitle) {
  1353. _this12.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
  1354. } else if (contentDispositionFilename) {
  1355. _this12.setTitle(contentDispositionFilename);
  1356. }
  1357. if (info.IsAcroFormPresent) {
  1358. console.warn("Warning: AcroForm/XFA is not supported");
  1359. _this12.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1360. }
  1361. versionId = "other";
  1362. KNOWN_VERSIONS = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2.0", "2.1", "2.2", "2.3"];
  1363. if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
  1364. versionId = "v".concat(info.PDFFormatVersion.replace(".", "_"));
  1365. }
  1366. generatorId = "other";
  1367. KNOWN_GENERATORS = ["acrobat distiller", "acrobat pdfwriter", "adobe livecycle", "adobe pdf library", "adobe photoshop", "ghostscript", "tcpdf", "cairo", "dvipdfm", "dvips", "pdftex", "pdfkit", "itext", "prince", "quarkxpress", "mac os x", "microsoft", "openoffice", "oracle", "luradocument", "pdf-xchange", "antenna house", "aspose.cells", "fpdf"];
  1368. if (info.Producer) {
  1369. producer = info.Producer.toLowerCase();
  1370. KNOWN_GENERATORS.some(function (generator) {
  1371. if (!producer.includes(generator)) {
  1372. return false;
  1373. }
  1374. generatorId = generator.replace(/[ .\-]/g, "_");
  1375. return true;
  1376. });
  1377. }
  1378. formType = null;
  1379. if (info.IsAcroFormPresent) {
  1380. formType = info.IsXFAPresent ? "xfa" : "acroform";
  1381. }
  1382. _this12.externalServices.reportTelemetry({
  1383. type: "documentInfo",
  1384. version: versionId,
  1385. generator: generatorId,
  1386. formType: formType
  1387. });
  1388. case 27:
  1389. case "end":
  1390. return _context10.stop();
  1391. }
  1392. }
  1393. }, _callee10);
  1394. }))();
  1395. },
  1396. _initializePageLabels: function _initializePageLabels(pdfDocument) {
  1397. var _this13 = this;
  1398. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
  1399. var labels, numLabels, i, pdfViewer, pdfThumbnailViewer, toolbar;
  1400. return _regenerator["default"].wrap(function _callee11$(_context11) {
  1401. while (1) {
  1402. switch (_context11.prev = _context11.next) {
  1403. case 0:
  1404. _context11.next = 2;
  1405. return pdfDocument.getPageLabels();
  1406. case 2:
  1407. labels = _context11.sent;
  1408. if (!(pdfDocument !== _this13.pdfDocument)) {
  1409. _context11.next = 5;
  1410. break;
  1411. }
  1412. return _context11.abrupt("return");
  1413. case 5:
  1414. if (!(!labels || _app_options.AppOptions.get("disablePageLabels"))) {
  1415. _context11.next = 7;
  1416. break;
  1417. }
  1418. return _context11.abrupt("return");
  1419. case 7:
  1420. numLabels = labels.length;
  1421. if (!(numLabels !== _this13.pagesCount)) {
  1422. _context11.next = 11;
  1423. break;
  1424. }
  1425. console.error("The number of Page Labels does not match the number of pages in the document.");
  1426. return _context11.abrupt("return");
  1427. case 11:
  1428. i = 0;
  1429. while (i < numLabels && labels[i] === (i + 1).toString()) {
  1430. i++;
  1431. }
  1432. if (!(i === numLabels)) {
  1433. _context11.next = 15;
  1434. break;
  1435. }
  1436. return _context11.abrupt("return");
  1437. case 15:
  1438. pdfViewer = _this13.pdfViewer, pdfThumbnailViewer = _this13.pdfThumbnailViewer, toolbar = _this13.toolbar;
  1439. pdfViewer.setPageLabels(labels);
  1440. pdfThumbnailViewer.setPageLabels(labels);
  1441. toolbar.setPagesCount(numLabels, true);
  1442. toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1443. case 20:
  1444. case "end":
  1445. return _context11.stop();
  1446. }
  1447. }
  1448. }, _callee11);
  1449. }))();
  1450. },
  1451. _initializePdfHistory: function _initializePdfHistory(_ref5) {
  1452. var fingerprint = _ref5.fingerprint,
  1453. viewOnLoad = _ref5.viewOnLoad,
  1454. _ref5$initialDest = _ref5.initialDest,
  1455. initialDest = _ref5$initialDest === void 0 ? null : _ref5$initialDest;
  1456. if (this.isViewerEmbedded || _app_options.AppOptions.get("disableHistory")) {
  1457. return;
  1458. }
  1459. this.pdfHistory.initialize({
  1460. fingerprint: fingerprint,
  1461. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  1462. updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
  1463. });
  1464. if (this.pdfHistory.initialBookmark) {
  1465. this.initialBookmark = this.pdfHistory.initialBookmark;
  1466. this.initialRotation = this.pdfHistory.initialRotation;
  1467. }
  1468. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  1469. this.initialBookmark = JSON.stringify(initialDest);
  1470. this.pdfHistory.push({
  1471. explicitDest: initialDest,
  1472. pageNumber: null
  1473. });
  1474. }
  1475. },
  1476. _initializePermissions: function _initializePermissions(pdfDocument) {
  1477. var _this14 = this;
  1478. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
  1479. var permissions;
  1480. return _regenerator["default"].wrap(function _callee12$(_context12) {
  1481. while (1) {
  1482. switch (_context12.prev = _context12.next) {
  1483. case 0:
  1484. _context12.next = 2;
  1485. return pdfDocument.getPermissions();
  1486. case 2:
  1487. permissions = _context12.sent;
  1488. if (!(pdfDocument !== _this14.pdfDocument)) {
  1489. _context12.next = 5;
  1490. break;
  1491. }
  1492. return _context12.abrupt("return");
  1493. case 5:
  1494. if (!(!permissions || !_app_options.AppOptions.get("enablePermissions"))) {
  1495. _context12.next = 7;
  1496. break;
  1497. }
  1498. return _context12.abrupt("return");
  1499. case 7:
  1500. if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY)) {
  1501. _this14.appConfig.viewerContainer.classList.add(ENABLE_PERMISSIONS_CLASS);
  1502. }
  1503. case 8:
  1504. case "end":
  1505. return _context12.stop();
  1506. }
  1507. }
  1508. }, _callee12);
  1509. }))();
  1510. },
  1511. setInitialView: function setInitialView(storedHash) {
  1512. var _this15 = this;
  1513. var _ref6 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1514. rotation = _ref6.rotation,
  1515. sidebarView = _ref6.sidebarView,
  1516. scrollMode = _ref6.scrollMode,
  1517. spreadMode = _ref6.spreadMode;
  1518. var setRotation = function setRotation(angle) {
  1519. if ((0, _ui_utils.isValidRotation)(angle)) {
  1520. _this15.pdfViewer.pagesRotation = angle;
  1521. }
  1522. };
  1523. var setViewerModes = function setViewerModes(scroll, spread) {
  1524. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  1525. _this15.pdfViewer.scrollMode = scroll;
  1526. }
  1527. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  1528. _this15.pdfViewer.spreadMode = spread;
  1529. }
  1530. };
  1531. this.isInitialViewSet = true;
  1532. this.pdfSidebar.setInitialView(sidebarView);
  1533. setViewerModes(scrollMode, spreadMode);
  1534. if (this.initialBookmark) {
  1535. setRotation(this.initialRotation);
  1536. delete this.initialRotation;
  1537. this.pdfLinkService.setHash(this.initialBookmark);
  1538. this.initialBookmark = null;
  1539. } else if (storedHash) {
  1540. setRotation(rotation);
  1541. this.pdfLinkService.setHash(storedHash);
  1542. }
  1543. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  1544. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  1545. if (!this.pdfViewer.currentScaleValue) {
  1546. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1547. }
  1548. },
  1549. cleanup: function cleanup() {
  1550. if (!this.pdfDocument) {
  1551. return;
  1552. }
  1553. this.pdfViewer.cleanup();
  1554. this.pdfThumbnailViewer.cleanup();
  1555. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  1556. this.pdfDocument.cleanup();
  1557. }
  1558. },
  1559. forceRendering: function forceRendering() {
  1560. this.pdfRenderingQueue.printing = this.printing;
  1561. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  1562. this.pdfRenderingQueue.renderHighestPriority();
  1563. },
  1564. beforePrint: function beforePrint() {
  1565. var _this16 = this;
  1566. if (this.printService) {
  1567. return;
  1568. }
  1569. if (!this.supportsPrinting) {
  1570. this.l10n.get("printing_not_supported", null, "Warning: Printing is not fully supported by this browser.").then(function (printMessage) {
  1571. _this16.error(printMessage);
  1572. });
  1573. return;
  1574. }
  1575. if (!this.pdfViewer.pageViewsReady) {
  1576. this.l10n.get("printing_not_ready", null, "Warning: The PDF is not fully loaded for printing.").then(function (notReadyMessage) {
  1577. window.alert(notReadyMessage);
  1578. });
  1579. return;
  1580. }
  1581. var pagesOverview = this.pdfViewer.getPagesOverview();
  1582. var printContainer = this.appConfig.printContainer;
  1583. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
  1584. this.printService = printService;
  1585. this.forceRendering();
  1586. printService.layout();
  1587. this.externalServices.reportTelemetry({
  1588. type: "print"
  1589. });
  1590. },
  1591. afterPrint: function afterPrint() {
  1592. if (this.printService) {
  1593. this.printService.destroy();
  1594. this.printService = null;
  1595. }
  1596. this.forceRendering();
  1597. },
  1598. rotatePages: function rotatePages(delta) {
  1599. if (!this.pdfDocument) {
  1600. return;
  1601. }
  1602. var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
  1603. this.pdfViewer.pagesRotation = newRotation;
  1604. },
  1605. requestPresentationMode: function requestPresentationMode() {
  1606. if (!this.pdfPresentationMode) {
  1607. return;
  1608. }
  1609. this.pdfPresentationMode.request();
  1610. },
  1611. bindEvents: function bindEvents() {
  1612. var eventBus = this.eventBus,
  1613. _boundEvents = this._boundEvents;
  1614. _boundEvents.beforePrint = this.beforePrint.bind(this);
  1615. _boundEvents.afterPrint = this.afterPrint.bind(this);
  1616. eventBus._on("resize", webViewerResize);
  1617. eventBus._on("hashchange", webViewerHashchange);
  1618. eventBus._on("beforeprint", _boundEvents.beforePrint);
  1619. eventBus._on("afterprint", _boundEvents.afterPrint);
  1620. eventBus._on("pagerendered", webViewerPageRendered);
  1621. eventBus._on("updateviewarea", webViewerUpdateViewarea);
  1622. eventBus._on("pagechanging", webViewerPageChanging);
  1623. eventBus._on("scalechanging", webViewerScaleChanging);
  1624. eventBus._on("rotationchanging", webViewerRotationChanging);
  1625. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
  1626. eventBus._on("pagemode", webViewerPageMode);
  1627. eventBus._on("namedaction", webViewerNamedAction);
  1628. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
  1629. eventBus._on("presentationmode", webViewerPresentationMode);
  1630. eventBus._on("print", webViewerPrint);
  1631. eventBus._on("download", webViewerDownload);
  1632. eventBus._on("firstpage", webViewerFirstPage);
  1633. eventBus._on("lastpage", webViewerLastPage);
  1634. eventBus._on("nextpage", webViewerNextPage);
  1635. eventBus._on("previouspage", webViewerPreviousPage);
  1636. eventBus._on("zoomin", webViewerZoomIn);
  1637. eventBus._on("zoomout", webViewerZoomOut);
  1638. eventBus._on("zoomreset", webViewerZoomReset);
  1639. eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
  1640. eventBus._on("scalechanged", webViewerScaleChanged);
  1641. eventBus._on("rotatecw", webViewerRotateCw);
  1642. eventBus._on("rotateccw", webViewerRotateCcw);
  1643. eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
  1644. eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
  1645. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
  1646. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
  1647. eventBus._on("documentproperties", webViewerDocumentProperties);
  1648. eventBus._on("find", webViewerFind);
  1649. eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
  1650. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  1651. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
  1652. eventBus._on("fileinputchange", webViewerFileInputChange);
  1653. eventBus._on("openfile", webViewerOpenFile);
  1654. },
  1655. bindWindowEvents: function bindWindowEvents() {
  1656. var eventBus = this.eventBus,
  1657. _boundEvents = this._boundEvents;
  1658. _boundEvents.windowResize = function () {
  1659. eventBus.dispatch("resize", {
  1660. source: window
  1661. });
  1662. };
  1663. _boundEvents.windowHashChange = function () {
  1664. eventBus.dispatch("hashchange", {
  1665. source: window,
  1666. hash: document.location.hash.substring(1)
  1667. });
  1668. };
  1669. _boundEvents.windowBeforePrint = function () {
  1670. eventBus.dispatch("beforeprint", {
  1671. source: window
  1672. });
  1673. };
  1674. _boundEvents.windowAfterPrint = function () {
  1675. eventBus.dispatch("afterprint", {
  1676. source: window
  1677. });
  1678. };
  1679. window.addEventListener("visibilitychange", webViewerVisibilityChange);
  1680. window.addEventListener("wheel", webViewerWheel, {
  1681. passive: false
  1682. });
  1683. window.addEventListener("click", webViewerClick);
  1684. window.addEventListener("keydown", webViewerKeyDown);
  1685. window.addEventListener("resize", _boundEvents.windowResize);
  1686. window.addEventListener("hashchange", _boundEvents.windowHashChange);
  1687. window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
  1688. window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
  1689. },
  1690. unbindEvents: function unbindEvents() {
  1691. var eventBus = this.eventBus,
  1692. _boundEvents = this._boundEvents;
  1693. eventBus._off("resize", webViewerResize);
  1694. eventBus._off("hashchange", webViewerHashchange);
  1695. eventBus._off("beforeprint", _boundEvents.beforePrint);
  1696. eventBus._off("afterprint", _boundEvents.afterPrint);
  1697. eventBus._off("pagerendered", webViewerPageRendered);
  1698. eventBus._off("updateviewarea", webViewerUpdateViewarea);
  1699. eventBus._off("pagechanging", webViewerPageChanging);
  1700. eventBus._off("scalechanging", webViewerScaleChanging);
  1701. eventBus._off("rotationchanging", webViewerRotationChanging);
  1702. eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
  1703. eventBus._off("pagemode", webViewerPageMode);
  1704. eventBus._off("namedaction", webViewerNamedAction);
  1705. eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
  1706. eventBus._off("presentationmode", webViewerPresentationMode);
  1707. eventBus._off("print", webViewerPrint);
  1708. eventBus._off("download", webViewerDownload);
  1709. eventBus._off("firstpage", webViewerFirstPage);
  1710. eventBus._off("lastpage", webViewerLastPage);
  1711. eventBus._off("nextpage", webViewerNextPage);
  1712. eventBus._off("previouspage", webViewerPreviousPage);
  1713. eventBus._off("zoomin", webViewerZoomIn);
  1714. eventBus._off("zoomout", webViewerZoomOut);
  1715. eventBus._off("zoomreset", webViewerZoomReset);
  1716. eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
  1717. eventBus._off("scalechanged", webViewerScaleChanged);
  1718. eventBus._off("rotatecw", webViewerRotateCw);
  1719. eventBus._off("rotateccw", webViewerRotateCcw);
  1720. eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
  1721. eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
  1722. eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
  1723. eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
  1724. eventBus._off("documentproperties", webViewerDocumentProperties);
  1725. eventBus._off("find", webViewerFind);
  1726. eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
  1727. eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  1728. eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
  1729. eventBus._off("fileinputchange", webViewerFileInputChange);
  1730. eventBus._off("openfile", webViewerOpenFile);
  1731. _boundEvents.beforePrint = null;
  1732. _boundEvents.afterPrint = null;
  1733. },
  1734. unbindWindowEvents: function unbindWindowEvents() {
  1735. var _boundEvents = this._boundEvents;
  1736. window.removeEventListener("visibilitychange", webViewerVisibilityChange);
  1737. window.removeEventListener("wheel", webViewerWheel, {
  1738. passive: false
  1739. });
  1740. window.removeEventListener("click", webViewerClick);
  1741. window.removeEventListener("keydown", webViewerKeyDown);
  1742. window.removeEventListener("resize", _boundEvents.windowResize);
  1743. window.removeEventListener("hashchange", _boundEvents.windowHashChange);
  1744. window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
  1745. window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
  1746. _boundEvents.windowResize = null;
  1747. _boundEvents.windowHashChange = null;
  1748. _boundEvents.windowBeforePrint = null;
  1749. _boundEvents.windowAfterPrint = null;
  1750. }
  1751. };
  1752. exports.PDFViewerApplication = PDFViewerApplication;
  1753. var validateFileURL;
  1754. {
  1755. var HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
  1756. validateFileURL = function validateFileURL(file) {
  1757. if (file === undefined) {
  1758. return;
  1759. }
  1760. try {
  1761. var viewerOrigin = new URL(window.location.href).origin || "null";
  1762. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  1763. return;
  1764. }
  1765. var _URL = new URL(file, window.location.href),
  1766. origin = _URL.origin,
  1767. protocol = _URL.protocol;
  1768. if (origin !== viewerOrigin && protocol !== "blob:") {
  1769. throw new Error("file origin does not match viewer's");
  1770. }
  1771. } catch (ex) {
  1772. var message = ex && ex.message;
  1773. PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(function (loadingErrorMessage) {
  1774. PDFViewerApplication.error(loadingErrorMessage, {
  1775. message: message
  1776. });
  1777. });
  1778. throw ex;
  1779. }
  1780. };
  1781. }
  1782. function loadFakeWorker() {
  1783. return _loadFakeWorker.apply(this, arguments);
  1784. }
  1785. function _loadFakeWorker() {
  1786. _loadFakeWorker = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
  1787. return _regenerator["default"].wrap(function _callee13$(_context13) {
  1788. while (1) {
  1789. switch (_context13.prev = _context13.next) {
  1790. case 0:
  1791. if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
  1792. _pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get("workerSrc");
  1793. }
  1794. return _context13.abrupt("return", (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc()));
  1795. case 2:
  1796. case "end":
  1797. return _context13.stop();
  1798. }
  1799. }
  1800. }, _callee13);
  1801. }));
  1802. return _loadFakeWorker.apply(this, arguments);
  1803. }
  1804. function loadAndEnablePDFBug(enabledTabs) {
  1805. var appConfig = PDFViewerApplication.appConfig;
  1806. return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function () {
  1807. PDFBug.enable(enabledTabs);
  1808. PDFBug.init({
  1809. OPS: _pdfjsLib.OPS
  1810. }, appConfig.mainContainer);
  1811. });
  1812. }
  1813. function webViewerInitialized() {
  1814. var appConfig = PDFViewerApplication.appConfig;
  1815. var file;
  1816. var queryString = document.location.search.substring(1);
  1817. var params = (0, _ui_utils.parseQueryString)(queryString);
  1818. file = "file" in params ? params.file : _app_options.AppOptions.get("defaultUrl");
  1819. validateFileURL(file);
  1820. var fileInput = document.createElement("input");
  1821. fileInput.id = appConfig.openFileInputName;
  1822. fileInput.className = "fileInput";
  1823. fileInput.setAttribute("type", "file");
  1824. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  1825. document.body.appendChild(fileInput);
  1826. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  1827. appConfig.toolbar.openFile.setAttribute("hidden", "true");
  1828. appConfig.secondaryToolbar.openFileButton.setAttribute("hidden", "true");
  1829. } else {
  1830. fileInput.value = null;
  1831. }
  1832. fileInput.addEventListener("change", function (evt) {
  1833. var files = evt.target.files;
  1834. if (!files || files.length === 0) {
  1835. return;
  1836. }
  1837. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  1838. source: this,
  1839. fileInput: evt.target
  1840. });
  1841. });
  1842. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  1843. evt.preventDefault();
  1844. evt.dataTransfer.dropEffect = "move";
  1845. });
  1846. appConfig.mainContainer.addEventListener("drop", function (evt) {
  1847. evt.preventDefault();
  1848. var files = evt.dataTransfer.files;
  1849. if (!files || files.length === 0) {
  1850. return;
  1851. }
  1852. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  1853. source: this,
  1854. fileInput: evt.dataTransfer
  1855. });
  1856. });
  1857. if (!PDFViewerApplication.supportsDocumentFonts) {
  1858. _app_options.AppOptions.set("disableFontFace", true);
  1859. PDFViewerApplication.l10n.get("web_fonts_disabled", null, "Web fonts are disabled: unable to use embedded PDF fonts.").then(function (msg) {
  1860. console.warn(msg);
  1861. });
  1862. }
  1863. if (!PDFViewerApplication.supportsPrinting) {
  1864. appConfig.toolbar.print.classList.add("hidden");
  1865. appConfig.secondaryToolbar.printButton.classList.add("hidden");
  1866. }
  1867. if (!PDFViewerApplication.supportsFullscreen) {
  1868. appConfig.toolbar.presentationModeButton.classList.add("hidden");
  1869. appConfig.secondaryToolbar.presentationModeButton.classList.add("hidden");
  1870. }
  1871. if (PDFViewerApplication.supportsIntegratedFind) {
  1872. appConfig.toolbar.viewFind.classList.add("hidden");
  1873. }
  1874. appConfig.mainContainer.addEventListener("transitionend", function (evt) {
  1875. if (evt.target === this) {
  1876. PDFViewerApplication.eventBus.dispatch("resize", {
  1877. source: this
  1878. });
  1879. }
  1880. }, true);
  1881. try {
  1882. webViewerOpenFileViaURL(file);
  1883. } catch (reason) {
  1884. PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(function (msg) {
  1885. PDFViewerApplication.error(msg, reason);
  1886. });
  1887. }
  1888. }
  1889. var webViewerOpenFileViaURL;
  1890. {
  1891. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  1892. if (file && file.lastIndexOf("file:", 0) === 0) {
  1893. PDFViewerApplication.setTitleUsingUrl(file);
  1894. var xhr = new XMLHttpRequest();
  1895. xhr.onload = function () {
  1896. PDFViewerApplication.open(new Uint8Array(xhr.response));
  1897. };
  1898. xhr.open("GET", file);
  1899. xhr.responseType = "arraybuffer";
  1900. xhr.send();
  1901. return;
  1902. }
  1903. if (file) {
  1904. PDFViewerApplication.open(file);
  1905. }
  1906. };
  1907. }
  1908. function webViewerResetPermissions() {
  1909. var appConfig = PDFViewerApplication.appConfig;
  1910. if (!appConfig) {
  1911. return;
  1912. }
  1913. appConfig.viewerContainer.classList.remove(ENABLE_PERMISSIONS_CLASS);
  1914. }
  1915. function webViewerPageRendered(evt) {
  1916. var pageNumber = evt.pageNumber;
  1917. var pageIndex = pageNumber - 1;
  1918. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  1919. if (pageNumber === PDFViewerApplication.page) {
  1920. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  1921. }
  1922. if (!pageView) {
  1923. return;
  1924. }
  1925. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  1926. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  1927. thumbnailView.setImage(pageView);
  1928. }
  1929. if (typeof Stats !== "undefined" && Stats.enabled && pageView.stats) {
  1930. Stats.add(pageNumber, pageView.stats);
  1931. }
  1932. if (pageView.error) {
  1933. PDFViewerApplication.l10n.get("rendering_error", null, "An error occurred while rendering the page.").then(function (msg) {
  1934. PDFViewerApplication.error(msg, pageView.error);
  1935. });
  1936. }
  1937. PDFViewerApplication.externalServices.reportTelemetry({
  1938. type: "pageInfo",
  1939. timestamp: evt.timestamp
  1940. });
  1941. PDFViewerApplication.pdfDocument.getStats().then(function (stats) {
  1942. PDFViewerApplication.externalServices.reportTelemetry({
  1943. type: "documentStats",
  1944. stats: stats
  1945. });
  1946. });
  1947. }
  1948. function webViewerPageMode(_ref7) {
  1949. var mode = _ref7.mode;
  1950. var view;
  1951. switch (mode) {
  1952. case "thumbs":
  1953. view = _pdf_sidebar.SidebarView.THUMBS;
  1954. break;
  1955. case "bookmarks":
  1956. case "outline":
  1957. view = _pdf_sidebar.SidebarView.OUTLINE;
  1958. break;
  1959. case "attachments":
  1960. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  1961. break;
  1962. case "none":
  1963. view = _pdf_sidebar.SidebarView.NONE;
  1964. break;
  1965. default:
  1966. console.error('Invalid "pagemode" hash parameter: ' + mode);
  1967. return;
  1968. }
  1969. PDFViewerApplication.pdfSidebar.switchView(view, true);
  1970. }
  1971. function webViewerNamedAction(evt) {
  1972. var action = evt.action;
  1973. switch (action) {
  1974. case "GoToPage":
  1975. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  1976. break;
  1977. case "Find":
  1978. if (!PDFViewerApplication.supportsIntegratedFind) {
  1979. PDFViewerApplication.findBar.toggle();
  1980. }
  1981. break;
  1982. }
  1983. }
  1984. function webViewerPresentationModeChanged(_ref8) {
  1985. var active = _ref8.active,
  1986. switchInProgress = _ref8.switchInProgress;
  1987. var state = _ui_utils.PresentationModeState.NORMAL;
  1988. if (switchInProgress) {
  1989. state = _ui_utils.PresentationModeState.CHANGING;
  1990. } else if (active) {
  1991. state = _ui_utils.PresentationModeState.FULLSCREEN;
  1992. }
  1993. PDFViewerApplication.pdfViewer.presentationModeState = state;
  1994. }
  1995. function webViewerSidebarViewChanged(evt) {
  1996. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  1997. var store = PDFViewerApplication.store;
  1998. if (store && PDFViewerApplication.isInitialViewSet) {
  1999. store.set("sidebarView", evt.view)["catch"](function () {});
  2000. }
  2001. }
  2002. function webViewerUpdateViewarea(evt) {
  2003. var location = evt.location,
  2004. store = PDFViewerApplication.store;
  2005. if (store && PDFViewerApplication.isInitialViewSet) {
  2006. store.setMultiple({
  2007. page: location.pageNumber,
  2008. zoom: location.scale,
  2009. scrollLeft: location.left,
  2010. scrollTop: location.top,
  2011. rotation: location.rotation
  2012. })["catch"](function () {});
  2013. }
  2014. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  2015. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  2016. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  2017. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  2018. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  2019. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  2020. }
  2021. function webViewerScrollModeChanged(evt) {
  2022. var store = PDFViewerApplication.store;
  2023. if (store && PDFViewerApplication.isInitialViewSet) {
  2024. store.set("scrollMode", evt.mode)["catch"](function () {});
  2025. }
  2026. }
  2027. function webViewerSpreadModeChanged(evt) {
  2028. var store = PDFViewerApplication.store;
  2029. if (store && PDFViewerApplication.isInitialViewSet) {
  2030. store.set("spreadMode", evt.mode)["catch"](function () {});
  2031. }
  2032. }
  2033. function webViewerResize() {
  2034. var pdfDocument = PDFViewerApplication.pdfDocument,
  2035. pdfViewer = PDFViewerApplication.pdfViewer;
  2036. if (!pdfDocument) {
  2037. return;
  2038. }
  2039. var currentScaleValue = pdfViewer.currentScaleValue;
  2040. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  2041. pdfViewer.currentScaleValue = currentScaleValue;
  2042. }
  2043. pdfViewer.update();
  2044. }
  2045. function webViewerHashchange(evt) {
  2046. var hash = evt.hash;
  2047. if (!hash) {
  2048. return;
  2049. }
  2050. if (!PDFViewerApplication.isInitialViewSet) {
  2051. PDFViewerApplication.initialBookmark = hash;
  2052. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  2053. PDFViewerApplication.pdfLinkService.setHash(hash);
  2054. }
  2055. }
  2056. var webViewerFileInputChange, webViewerOpenFile;
  2057. {
  2058. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  2059. if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
  2060. return;
  2061. }
  2062. var file = evt.fileInput.files[0];
  2063. if (!_app_options.AppOptions.get("disableCreateObjectURL")) {
  2064. var url = URL.createObjectURL(file);
  2065. if (file.name) {
  2066. url = {
  2067. url: url,
  2068. originalUrl: file.name
  2069. };
  2070. }
  2071. PDFViewerApplication.open(url);
  2072. } else {
  2073. PDFViewerApplication.setTitleUsingUrl(file.name);
  2074. var fileReader = new FileReader();
  2075. fileReader.onload = function webViewerChangeFileReaderOnload(event) {
  2076. var buffer = event.target.result;
  2077. PDFViewerApplication.open(new Uint8Array(buffer));
  2078. };
  2079. fileReader.readAsArrayBuffer(file);
  2080. }
  2081. var appConfig = PDFViewerApplication.appConfig;
  2082. appConfig.toolbar.viewBookmark.setAttribute("hidden", "true");
  2083. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute("hidden", "true");
  2084. appConfig.toolbar.download.setAttribute("hidden", "true");
  2085. appConfig.secondaryToolbar.downloadButton.setAttribute("hidden", "true");
  2086. };
  2087. webViewerOpenFile = function webViewerOpenFile(evt) {
  2088. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  2089. document.getElementById(openFileInputName).click();
  2090. };
  2091. }
  2092. function webViewerPresentationMode() {
  2093. PDFViewerApplication.requestPresentationMode();
  2094. }
  2095. function webViewerPrint() {
  2096. window.print();
  2097. }
  2098. function webViewerDownload() {
  2099. PDFViewerApplication.download();
  2100. }
  2101. function webViewerFirstPage() {
  2102. if (PDFViewerApplication.pdfDocument) {
  2103. PDFViewerApplication.page = 1;
  2104. }
  2105. }
  2106. function webViewerLastPage() {
  2107. if (PDFViewerApplication.pdfDocument) {
  2108. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2109. }
  2110. }
  2111. function webViewerNextPage() {
  2112. PDFViewerApplication.page++;
  2113. }
  2114. function webViewerPreviousPage() {
  2115. PDFViewerApplication.page--;
  2116. }
  2117. function webViewerZoomIn() {
  2118. PDFViewerApplication.zoomIn();
  2119. }
  2120. function webViewerZoomOut() {
  2121. PDFViewerApplication.zoomOut();
  2122. }
  2123. function webViewerZoomReset() {
  2124. PDFViewerApplication.zoomReset();
  2125. }
  2126. function webViewerPageNumberChanged(evt) {
  2127. var pdfViewer = PDFViewerApplication.pdfViewer;
  2128. if (evt.value !== "") {
  2129. pdfViewer.currentPageLabel = evt.value;
  2130. }
  2131. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  2132. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  2133. }
  2134. }
  2135. function webViewerScaleChanged(evt) {
  2136. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  2137. }
  2138. function webViewerRotateCw() {
  2139. PDFViewerApplication.rotatePages(90);
  2140. }
  2141. function webViewerRotateCcw() {
  2142. PDFViewerApplication.rotatePages(-90);
  2143. }
  2144. function webViewerSwitchScrollMode(evt) {
  2145. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  2146. }
  2147. function webViewerSwitchSpreadMode(evt) {
  2148. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  2149. }
  2150. function webViewerDocumentProperties() {
  2151. PDFViewerApplication.pdfDocumentProperties.open();
  2152. }
  2153. function webViewerFind(evt) {
  2154. PDFViewerApplication.findController.executeCommand("find" + evt.type, {
  2155. query: evt.query,
  2156. phraseSearch: evt.phraseSearch,
  2157. caseSensitive: evt.caseSensitive,
  2158. entireWord: evt.entireWord,
  2159. highlightAll: evt.highlightAll,
  2160. findPrevious: evt.findPrevious
  2161. });
  2162. }
  2163. function webViewerFindFromUrlHash(evt) {
  2164. PDFViewerApplication.findController.executeCommand("find", {
  2165. query: evt.query,
  2166. phraseSearch: evt.phraseSearch,
  2167. caseSensitive: false,
  2168. entireWord: false,
  2169. highlightAll: true,
  2170. findPrevious: false
  2171. });
  2172. }
  2173. function webViewerUpdateFindMatchesCount(_ref9) {
  2174. var matchesCount = _ref9.matchesCount;
  2175. if (PDFViewerApplication.supportsIntegratedFind) {
  2176. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  2177. } else {
  2178. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  2179. }
  2180. }
  2181. function webViewerUpdateFindControlState(_ref10) {
  2182. var state = _ref10.state,
  2183. previous = _ref10.previous,
  2184. matchesCount = _ref10.matchesCount;
  2185. if (PDFViewerApplication.supportsIntegratedFind) {
  2186. PDFViewerApplication.externalServices.updateFindControlState({
  2187. result: state,
  2188. findPrevious: previous,
  2189. matchesCount: matchesCount
  2190. });
  2191. } else {
  2192. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  2193. }
  2194. }
  2195. function webViewerScaleChanging(evt) {
  2196. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  2197. PDFViewerApplication.pdfViewer.update();
  2198. }
  2199. function webViewerRotationChanging(evt) {
  2200. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  2201. PDFViewerApplication.forceRendering();
  2202. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  2203. }
  2204. function webViewerPageChanging(evt) {
  2205. var page = evt.pageNumber;
  2206. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  2207. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  2208. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2209. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
  2210. }
  2211. if (typeof Stats !== "undefined" && Stats.enabled) {
  2212. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  2213. if (pageView && pageView.stats) {
  2214. Stats.add(page, pageView.stats);
  2215. }
  2216. }
  2217. }
  2218. function webViewerVisibilityChange(evt) {
  2219. if (document.visibilityState === "visible") {
  2220. setZoomDisabledTimeout();
  2221. }
  2222. }
  2223. var zoomDisabledTimeout = null;
  2224. function setZoomDisabledTimeout() {
  2225. if (zoomDisabledTimeout) {
  2226. clearTimeout(zoomDisabledTimeout);
  2227. }
  2228. zoomDisabledTimeout = setTimeout(function () {
  2229. zoomDisabledTimeout = null;
  2230. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  2231. }
  2232. function webViewerWheel(evt) {
  2233. var pdfViewer = PDFViewerApplication.pdfViewer,
  2234. supportedMouseWheelZoomModifierKeys = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  2235. if (pdfViewer.isInPresentationMode) {
  2236. return;
  2237. }
  2238. if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
  2239. evt.preventDefault();
  2240. if (zoomDisabledTimeout || document.visibilityState === "hidden") {
  2241. return;
  2242. }
  2243. var previousScale = pdfViewer.currentScale;
  2244. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  2245. var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
  2246. var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
  2247. if (ticks < 0) {
  2248. PDFViewerApplication.zoomOut(-ticks);
  2249. } else {
  2250. PDFViewerApplication.zoomIn(ticks);
  2251. }
  2252. var currentScale = pdfViewer.currentScale;
  2253. if (previousScale !== currentScale) {
  2254. var scaleCorrectionFactor = currentScale / previousScale - 1;
  2255. var rect = pdfViewer.container.getBoundingClientRect();
  2256. var dx = evt.clientX - rect.left;
  2257. var dy = evt.clientY - rect.top;
  2258. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  2259. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  2260. }
  2261. } else {
  2262. setZoomDisabledTimeout();
  2263. }
  2264. }
  2265. function webViewerClick(evt) {
  2266. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  2267. return;
  2268. }
  2269. var appConfig = PDFViewerApplication.appConfig;
  2270. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  2271. PDFViewerApplication.secondaryToolbar.close();
  2272. }
  2273. }
  2274. function webViewerKeyDown(evt) {
  2275. if (PDFViewerApplication.overlayManager.active) {
  2276. return;
  2277. }
  2278. var handled = false,
  2279. ensureViewerFocused = false;
  2280. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  2281. var pdfViewer = PDFViewerApplication.pdfViewer;
  2282. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  2283. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  2284. switch (evt.keyCode) {
  2285. case 70:
  2286. if (!PDFViewerApplication.supportsIntegratedFind) {
  2287. PDFViewerApplication.findBar.open();
  2288. handled = true;
  2289. }
  2290. break;
  2291. case 71:
  2292. if (!PDFViewerApplication.supportsIntegratedFind) {
  2293. var findState = PDFViewerApplication.findController.state;
  2294. if (findState) {
  2295. PDFViewerApplication.findController.executeCommand("findagain", {
  2296. query: findState.query,
  2297. phraseSearch: findState.phraseSearch,
  2298. caseSensitive: findState.caseSensitive,
  2299. entireWord: findState.entireWord,
  2300. highlightAll: findState.highlightAll,
  2301. findPrevious: cmd === 5 || cmd === 12
  2302. });
  2303. }
  2304. handled = true;
  2305. }
  2306. break;
  2307. case 61:
  2308. case 107:
  2309. case 187:
  2310. case 171:
  2311. if (!isViewerInPresentationMode) {
  2312. PDFViewerApplication.zoomIn();
  2313. }
  2314. handled = true;
  2315. break;
  2316. case 173:
  2317. case 109:
  2318. case 189:
  2319. if (!isViewerInPresentationMode) {
  2320. PDFViewerApplication.zoomOut();
  2321. }
  2322. handled = true;
  2323. break;
  2324. case 48:
  2325. case 96:
  2326. if (!isViewerInPresentationMode) {
  2327. setTimeout(function () {
  2328. PDFViewerApplication.zoomReset();
  2329. });
  2330. handled = false;
  2331. }
  2332. break;
  2333. case 38:
  2334. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2335. PDFViewerApplication.page = 1;
  2336. handled = true;
  2337. ensureViewerFocused = true;
  2338. }
  2339. break;
  2340. case 40:
  2341. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2342. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2343. handled = true;
  2344. ensureViewerFocused = true;
  2345. }
  2346. break;
  2347. }
  2348. }
  2349. var eventBus = PDFViewerApplication.eventBus;
  2350. if (cmd === 1 || cmd === 8) {
  2351. switch (evt.keyCode) {
  2352. case 83:
  2353. eventBus.dispatch("download", {
  2354. source: window
  2355. });
  2356. handled = true;
  2357. break;
  2358. case 79:
  2359. {
  2360. eventBus.dispatch("openfile", {
  2361. source: window
  2362. });
  2363. handled = true;
  2364. }
  2365. break;
  2366. }
  2367. }
  2368. if (cmd === 3 || cmd === 10) {
  2369. switch (evt.keyCode) {
  2370. case 80:
  2371. PDFViewerApplication.requestPresentationMode();
  2372. handled = true;
  2373. break;
  2374. case 71:
  2375. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2376. handled = true;
  2377. break;
  2378. }
  2379. }
  2380. if (handled) {
  2381. if (ensureViewerFocused && !isViewerInPresentationMode) {
  2382. pdfViewer.focus();
  2383. }
  2384. evt.preventDefault();
  2385. return;
  2386. }
  2387. var curElement = document.activeElement || document.querySelector(":focus");
  2388. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  2389. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement && curElement.isContentEditable) {
  2390. if (evt.keyCode !== 27) {
  2391. return;
  2392. }
  2393. }
  2394. if (cmd === 0) {
  2395. var turnPage = 0,
  2396. turnOnlyIfPageFit = false;
  2397. switch (evt.keyCode) {
  2398. case 38:
  2399. case 33:
  2400. if (pdfViewer.isVerticalScrollbarEnabled) {
  2401. turnOnlyIfPageFit = true;
  2402. }
  2403. turnPage = -1;
  2404. break;
  2405. case 8:
  2406. if (!isViewerInPresentationMode) {
  2407. turnOnlyIfPageFit = true;
  2408. }
  2409. turnPage = -1;
  2410. break;
  2411. case 37:
  2412. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2413. turnOnlyIfPageFit = true;
  2414. }
  2415. case 75:
  2416. case 80:
  2417. turnPage = -1;
  2418. break;
  2419. case 27:
  2420. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  2421. PDFViewerApplication.secondaryToolbar.close();
  2422. handled = true;
  2423. }
  2424. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  2425. PDFViewerApplication.findBar.close();
  2426. handled = true;
  2427. }
  2428. break;
  2429. case 40:
  2430. case 34:
  2431. if (pdfViewer.isVerticalScrollbarEnabled) {
  2432. turnOnlyIfPageFit = true;
  2433. }
  2434. turnPage = 1;
  2435. break;
  2436. case 13:
  2437. case 32:
  2438. if (!isViewerInPresentationMode) {
  2439. turnOnlyIfPageFit = true;
  2440. }
  2441. turnPage = 1;
  2442. break;
  2443. case 39:
  2444. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2445. turnOnlyIfPageFit = true;
  2446. }
  2447. case 74:
  2448. case 78:
  2449. turnPage = 1;
  2450. break;
  2451. case 36:
  2452. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2453. PDFViewerApplication.page = 1;
  2454. handled = true;
  2455. ensureViewerFocused = true;
  2456. }
  2457. break;
  2458. case 35:
  2459. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2460. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2461. handled = true;
  2462. ensureViewerFocused = true;
  2463. }
  2464. break;
  2465. case 83:
  2466. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  2467. break;
  2468. case 72:
  2469. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  2470. break;
  2471. case 82:
  2472. PDFViewerApplication.rotatePages(90);
  2473. break;
  2474. case 115:
  2475. PDFViewerApplication.pdfSidebar.toggle();
  2476. break;
  2477. }
  2478. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  2479. if (turnPage > 0) {
  2480. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2481. PDFViewerApplication.page++;
  2482. }
  2483. } else {
  2484. if (PDFViewerApplication.page > 1) {
  2485. PDFViewerApplication.page--;
  2486. }
  2487. }
  2488. handled = true;
  2489. }
  2490. }
  2491. if (cmd === 4) {
  2492. switch (evt.keyCode) {
  2493. case 13:
  2494. case 32:
  2495. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  2496. break;
  2497. }
  2498. if (PDFViewerApplication.page > 1) {
  2499. PDFViewerApplication.page--;
  2500. }
  2501. handled = true;
  2502. break;
  2503. case 82:
  2504. PDFViewerApplication.rotatePages(-90);
  2505. break;
  2506. }
  2507. }
  2508. if (!handled && !isViewerInPresentationMode) {
  2509. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  2510. ensureViewerFocused = true;
  2511. }
  2512. }
  2513. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  2514. pdfViewer.focus();
  2515. }
  2516. if (handled) {
  2517. evt.preventDefault();
  2518. }
  2519. }
  2520. function apiPageLayoutToSpreadMode(layout) {
  2521. switch (layout) {
  2522. case "SinglePage":
  2523. case "OneColumn":
  2524. return _ui_utils.SpreadMode.NONE;
  2525. case "TwoColumnLeft":
  2526. case "TwoPageLeft":
  2527. return _ui_utils.SpreadMode.ODD;
  2528. case "TwoColumnRight":
  2529. case "TwoPageRight":
  2530. return _ui_utils.SpreadMode.EVEN;
  2531. }
  2532. return _ui_utils.SpreadMode.NONE;
  2533. }
  2534. function apiPageModeToSidebarView(mode) {
  2535. switch (mode) {
  2536. case "UseNone":
  2537. return _pdf_sidebar.SidebarView.NONE;
  2538. case "UseThumbs":
  2539. return _pdf_sidebar.SidebarView.THUMBS;
  2540. case "UseOutlines":
  2541. return _pdf_sidebar.SidebarView.OUTLINE;
  2542. case "UseAttachments":
  2543. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  2544. case "UseOC":
  2545. }
  2546. return _pdf_sidebar.SidebarView.NONE;
  2547. }
  2548. var PDFPrintServiceFactory = {
  2549. instance: {
  2550. supportsPrinting: false,
  2551. createPrintService: function createPrintService() {
  2552. throw new Error("Not implemented: createPrintService");
  2553. }
  2554. }
  2555. };
  2556. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  2557. /***/ }),
  2558. /* 2 */
  2559. /***/ (function(module, exports, __webpack_require__) {
  2560. "use strict";
  2561. module.exports = __webpack_require__(3);
  2562. /***/ }),
  2563. /* 3 */
  2564. /***/ (function(module, exports, __webpack_require__) {
  2565. "use strict";
  2566. /* WEBPACK VAR INJECTION */(function(module) {
  2567. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2568. var runtime = function (exports) {
  2569. "use strict";
  2570. var Op = Object.prototype;
  2571. var hasOwn = Op.hasOwnProperty;
  2572. var undefined;
  2573. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  2574. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  2575. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  2576. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  2577. function wrap(innerFn, outerFn, self, tryLocsList) {
  2578. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  2579. var generator = Object.create(protoGenerator.prototype);
  2580. var context = new Context(tryLocsList || []);
  2581. generator._invoke = makeInvokeMethod(innerFn, self, context);
  2582. return generator;
  2583. }
  2584. exports.wrap = wrap;
  2585. function tryCatch(fn, obj, arg) {
  2586. try {
  2587. return {
  2588. type: "normal",
  2589. arg: fn.call(obj, arg)
  2590. };
  2591. } catch (err) {
  2592. return {
  2593. type: "throw",
  2594. arg: err
  2595. };
  2596. }
  2597. }
  2598. var GenStateSuspendedStart = "suspendedStart";
  2599. var GenStateSuspendedYield = "suspendedYield";
  2600. var GenStateExecuting = "executing";
  2601. var GenStateCompleted = "completed";
  2602. var ContinueSentinel = {};
  2603. function Generator() {}
  2604. function GeneratorFunction() {}
  2605. function GeneratorFunctionPrototype() {}
  2606. var IteratorPrototype = {};
  2607. IteratorPrototype[iteratorSymbol] = function () {
  2608. return this;
  2609. };
  2610. var getProto = Object.getPrototypeOf;
  2611. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  2612. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  2613. IteratorPrototype = NativeIteratorPrototype;
  2614. }
  2615. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  2616. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  2617. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  2618. GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
  2619. function defineIteratorMethods(prototype) {
  2620. ["next", "throw", "return"].forEach(function (method) {
  2621. prototype[method] = function (arg) {
  2622. return this._invoke(method, arg);
  2623. };
  2624. });
  2625. }
  2626. exports.isGeneratorFunction = function (genFun) {
  2627. var ctor = typeof genFun === "function" && genFun.constructor;
  2628. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  2629. };
  2630. exports.mark = function (genFun) {
  2631. if (Object.setPrototypeOf) {
  2632. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  2633. } else {
  2634. genFun.__proto__ = GeneratorFunctionPrototype;
  2635. if (!(toStringTagSymbol in genFun)) {
  2636. genFun[toStringTagSymbol] = "GeneratorFunction";
  2637. }
  2638. }
  2639. genFun.prototype = Object.create(Gp);
  2640. return genFun;
  2641. };
  2642. exports.awrap = function (arg) {
  2643. return {
  2644. __await: arg
  2645. };
  2646. };
  2647. function AsyncIterator(generator, PromiseImpl) {
  2648. function invoke(method, arg, resolve, reject) {
  2649. var record = tryCatch(generator[method], generator, arg);
  2650. if (record.type === "throw") {
  2651. reject(record.arg);
  2652. } else {
  2653. var result = record.arg;
  2654. var value = result.value;
  2655. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  2656. return PromiseImpl.resolve(value.__await).then(function (value) {
  2657. invoke("next", value, resolve, reject);
  2658. }, function (err) {
  2659. invoke("throw", err, resolve, reject);
  2660. });
  2661. }
  2662. return PromiseImpl.resolve(value).then(function (unwrapped) {
  2663. result.value = unwrapped;
  2664. resolve(result);
  2665. }, function (error) {
  2666. return invoke("throw", error, resolve, reject);
  2667. });
  2668. }
  2669. }
  2670. var previousPromise;
  2671. function enqueue(method, arg) {
  2672. function callInvokeWithMethodAndArg() {
  2673. return new PromiseImpl(function (resolve, reject) {
  2674. invoke(method, arg, resolve, reject);
  2675. });
  2676. }
  2677. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  2678. }
  2679. this._invoke = enqueue;
  2680. }
  2681. defineIteratorMethods(AsyncIterator.prototype);
  2682. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  2683. return this;
  2684. };
  2685. exports.AsyncIterator = AsyncIterator;
  2686. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  2687. if (PromiseImpl === void 0) PromiseImpl = Promise;
  2688. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  2689. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  2690. return result.done ? result.value : iter.next();
  2691. });
  2692. };
  2693. function makeInvokeMethod(innerFn, self, context) {
  2694. var state = GenStateSuspendedStart;
  2695. return function invoke(method, arg) {
  2696. if (state === GenStateExecuting) {
  2697. throw new Error("Generator is already running");
  2698. }
  2699. if (state === GenStateCompleted) {
  2700. if (method === "throw") {
  2701. throw arg;
  2702. }
  2703. return doneResult();
  2704. }
  2705. context.method = method;
  2706. context.arg = arg;
  2707. while (true) {
  2708. var delegate = context.delegate;
  2709. if (delegate) {
  2710. var delegateResult = maybeInvokeDelegate(delegate, context);
  2711. if (delegateResult) {
  2712. if (delegateResult === ContinueSentinel) continue;
  2713. return delegateResult;
  2714. }
  2715. }
  2716. if (context.method === "next") {
  2717. context.sent = context._sent = context.arg;
  2718. } else if (context.method === "throw") {
  2719. if (state === GenStateSuspendedStart) {
  2720. state = GenStateCompleted;
  2721. throw context.arg;
  2722. }
  2723. context.dispatchException(context.arg);
  2724. } else if (context.method === "return") {
  2725. context.abrupt("return", context.arg);
  2726. }
  2727. state = GenStateExecuting;
  2728. var record = tryCatch(innerFn, self, context);
  2729. if (record.type === "normal") {
  2730. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  2731. if (record.arg === ContinueSentinel) {
  2732. continue;
  2733. }
  2734. return {
  2735. value: record.arg,
  2736. done: context.done
  2737. };
  2738. } else if (record.type === "throw") {
  2739. state = GenStateCompleted;
  2740. context.method = "throw";
  2741. context.arg = record.arg;
  2742. }
  2743. }
  2744. };
  2745. }
  2746. function maybeInvokeDelegate(delegate, context) {
  2747. var method = delegate.iterator[context.method];
  2748. if (method === undefined) {
  2749. context.delegate = null;
  2750. if (context.method === "throw") {
  2751. if (delegate.iterator["return"]) {
  2752. context.method = "return";
  2753. context.arg = undefined;
  2754. maybeInvokeDelegate(delegate, context);
  2755. if (context.method === "throw") {
  2756. return ContinueSentinel;
  2757. }
  2758. }
  2759. context.method = "throw";
  2760. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  2761. }
  2762. return ContinueSentinel;
  2763. }
  2764. var record = tryCatch(method, delegate.iterator, context.arg);
  2765. if (record.type === "throw") {
  2766. context.method = "throw";
  2767. context.arg = record.arg;
  2768. context.delegate = null;
  2769. return ContinueSentinel;
  2770. }
  2771. var info = record.arg;
  2772. if (!info) {
  2773. context.method = "throw";
  2774. context.arg = new TypeError("iterator result is not an object");
  2775. context.delegate = null;
  2776. return ContinueSentinel;
  2777. }
  2778. if (info.done) {
  2779. context[delegate.resultName] = info.value;
  2780. context.next = delegate.nextLoc;
  2781. if (context.method !== "return") {
  2782. context.method = "next";
  2783. context.arg = undefined;
  2784. }
  2785. } else {
  2786. return info;
  2787. }
  2788. context.delegate = null;
  2789. return ContinueSentinel;
  2790. }
  2791. defineIteratorMethods(Gp);
  2792. Gp[toStringTagSymbol] = "Generator";
  2793. Gp[iteratorSymbol] = function () {
  2794. return this;
  2795. };
  2796. Gp.toString = function () {
  2797. return "[object Generator]";
  2798. };
  2799. function pushTryEntry(locs) {
  2800. var entry = {
  2801. tryLoc: locs[0]
  2802. };
  2803. if (1 in locs) {
  2804. entry.catchLoc = locs[1];
  2805. }
  2806. if (2 in locs) {
  2807. entry.finallyLoc = locs[2];
  2808. entry.afterLoc = locs[3];
  2809. }
  2810. this.tryEntries.push(entry);
  2811. }
  2812. function resetTryEntry(entry) {
  2813. var record = entry.completion || {};
  2814. record.type = "normal";
  2815. delete record.arg;
  2816. entry.completion = record;
  2817. }
  2818. function Context(tryLocsList) {
  2819. this.tryEntries = [{
  2820. tryLoc: "root"
  2821. }];
  2822. tryLocsList.forEach(pushTryEntry, this);
  2823. this.reset(true);
  2824. }
  2825. exports.keys = function (object) {
  2826. var keys = [];
  2827. for (var key in object) {
  2828. keys.push(key);
  2829. }
  2830. keys.reverse();
  2831. return function next() {
  2832. while (keys.length) {
  2833. var key = keys.pop();
  2834. if (key in object) {
  2835. next.value = key;
  2836. next.done = false;
  2837. return next;
  2838. }
  2839. }
  2840. next.done = true;
  2841. return next;
  2842. };
  2843. };
  2844. function values(iterable) {
  2845. if (iterable) {
  2846. var iteratorMethod = iterable[iteratorSymbol];
  2847. if (iteratorMethod) {
  2848. return iteratorMethod.call(iterable);
  2849. }
  2850. if (typeof iterable.next === "function") {
  2851. return iterable;
  2852. }
  2853. if (!isNaN(iterable.length)) {
  2854. var i = -1,
  2855. next = function next() {
  2856. while (++i < iterable.length) {
  2857. if (hasOwn.call(iterable, i)) {
  2858. next.value = iterable[i];
  2859. next.done = false;
  2860. return next;
  2861. }
  2862. }
  2863. next.value = undefined;
  2864. next.done = true;
  2865. return next;
  2866. };
  2867. return next.next = next;
  2868. }
  2869. }
  2870. return {
  2871. next: doneResult
  2872. };
  2873. }
  2874. exports.values = values;
  2875. function doneResult() {
  2876. return {
  2877. value: undefined,
  2878. done: true
  2879. };
  2880. }
  2881. Context.prototype = {
  2882. constructor: Context,
  2883. reset: function reset(skipTempReset) {
  2884. this.prev = 0;
  2885. this.next = 0;
  2886. this.sent = this._sent = undefined;
  2887. this.done = false;
  2888. this.delegate = null;
  2889. this.method = "next";
  2890. this.arg = undefined;
  2891. this.tryEntries.forEach(resetTryEntry);
  2892. if (!skipTempReset) {
  2893. for (var name in this) {
  2894. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  2895. this[name] = undefined;
  2896. }
  2897. }
  2898. }
  2899. },
  2900. stop: function stop() {
  2901. this.done = true;
  2902. var rootEntry = this.tryEntries[0];
  2903. var rootRecord = rootEntry.completion;
  2904. if (rootRecord.type === "throw") {
  2905. throw rootRecord.arg;
  2906. }
  2907. return this.rval;
  2908. },
  2909. dispatchException: function dispatchException(exception) {
  2910. if (this.done) {
  2911. throw exception;
  2912. }
  2913. var context = this;
  2914. function handle(loc, caught) {
  2915. record.type = "throw";
  2916. record.arg = exception;
  2917. context.next = loc;
  2918. if (caught) {
  2919. context.method = "next";
  2920. context.arg = undefined;
  2921. }
  2922. return !!caught;
  2923. }
  2924. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2925. var entry = this.tryEntries[i];
  2926. var record = entry.completion;
  2927. if (entry.tryLoc === "root") {
  2928. return handle("end");
  2929. }
  2930. if (entry.tryLoc <= this.prev) {
  2931. var hasCatch = hasOwn.call(entry, "catchLoc");
  2932. var hasFinally = hasOwn.call(entry, "finallyLoc");
  2933. if (hasCatch && hasFinally) {
  2934. if (this.prev < entry.catchLoc) {
  2935. return handle(entry.catchLoc, true);
  2936. } else if (this.prev < entry.finallyLoc) {
  2937. return handle(entry.finallyLoc);
  2938. }
  2939. } else if (hasCatch) {
  2940. if (this.prev < entry.catchLoc) {
  2941. return handle(entry.catchLoc, true);
  2942. }
  2943. } else if (hasFinally) {
  2944. if (this.prev < entry.finallyLoc) {
  2945. return handle(entry.finallyLoc);
  2946. }
  2947. } else {
  2948. throw new Error("try statement without catch or finally");
  2949. }
  2950. }
  2951. }
  2952. },
  2953. abrupt: function abrupt(type, arg) {
  2954. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2955. var entry = this.tryEntries[i];
  2956. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  2957. var finallyEntry = entry;
  2958. break;
  2959. }
  2960. }
  2961. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  2962. finallyEntry = null;
  2963. }
  2964. var record = finallyEntry ? finallyEntry.completion : {};
  2965. record.type = type;
  2966. record.arg = arg;
  2967. if (finallyEntry) {
  2968. this.method = "next";
  2969. this.next = finallyEntry.finallyLoc;
  2970. return ContinueSentinel;
  2971. }
  2972. return this.complete(record);
  2973. },
  2974. complete: function complete(record, afterLoc) {
  2975. if (record.type === "throw") {
  2976. throw record.arg;
  2977. }
  2978. if (record.type === "break" || record.type === "continue") {
  2979. this.next = record.arg;
  2980. } else if (record.type === "return") {
  2981. this.rval = this.arg = record.arg;
  2982. this.method = "return";
  2983. this.next = "end";
  2984. } else if (record.type === "normal" && afterLoc) {
  2985. this.next = afterLoc;
  2986. }
  2987. return ContinueSentinel;
  2988. },
  2989. finish: function finish(finallyLoc) {
  2990. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2991. var entry = this.tryEntries[i];
  2992. if (entry.finallyLoc === finallyLoc) {
  2993. this.complete(entry.completion, entry.afterLoc);
  2994. resetTryEntry(entry);
  2995. return ContinueSentinel;
  2996. }
  2997. }
  2998. },
  2999. "catch": function _catch(tryLoc) {
  3000. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3001. var entry = this.tryEntries[i];
  3002. if (entry.tryLoc === tryLoc) {
  3003. var record = entry.completion;
  3004. if (record.type === "throw") {
  3005. var thrown = record.arg;
  3006. resetTryEntry(entry);
  3007. }
  3008. return thrown;
  3009. }
  3010. }
  3011. throw new Error("illegal catch attempt");
  3012. },
  3013. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  3014. this.delegate = {
  3015. iterator: values(iterable),
  3016. resultName: resultName,
  3017. nextLoc: nextLoc
  3018. };
  3019. if (this.method === "next") {
  3020. this.arg = undefined;
  3021. }
  3022. return ContinueSentinel;
  3023. }
  3024. };
  3025. return exports;
  3026. }(( false ? undefined : _typeof(module)) === "object" ? module.exports : {});
  3027. try {
  3028. regeneratorRuntime = runtime;
  3029. } catch (accidentalStrictMode) {
  3030. Function("r", "regeneratorRuntime = r")(runtime);
  3031. }
  3032. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4)(module)))
  3033. /***/ }),
  3034. /* 4 */
  3035. /***/ (function(module, exports, __webpack_require__) {
  3036. "use strict";
  3037. module.exports = function (module) {
  3038. if (!module.webpackPolyfill) {
  3039. module.deprecate = function () {};
  3040. module.paths = [];
  3041. if (!module.children) module.children = [];
  3042. Object.defineProperty(module, "loaded", {
  3043. enumerable: true,
  3044. get: function get() {
  3045. return module.l;
  3046. }
  3047. });
  3048. Object.defineProperty(module, "id", {
  3049. enumerable: true,
  3050. get: function get() {
  3051. return module.i;
  3052. }
  3053. });
  3054. module.webpackPolyfill = 1;
  3055. }
  3056. return module;
  3057. };
  3058. /***/ }),
  3059. /* 5 */
  3060. /***/ (function(module, exports, __webpack_require__) {
  3061. "use strict";
  3062. Object.defineProperty(exports, "__esModule", {
  3063. value: true
  3064. });
  3065. exports.isValidRotation = isValidRotation;
  3066. exports.isValidScrollMode = isValidScrollMode;
  3067. exports.isValidSpreadMode = isValidSpreadMode;
  3068. exports.isPortraitOrientation = isPortraitOrientation;
  3069. exports.clamp = clamp;
  3070. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  3071. exports.noContextMenuHandler = noContextMenuHandler;
  3072. exports.parseQueryString = parseQueryString;
  3073. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  3074. exports.getVisibleElements = getVisibleElements;
  3075. exports.roundToDivide = roundToDivide;
  3076. exports.getPageSizeInches = getPageSizeInches;
  3077. exports.approximateFraction = approximateFraction;
  3078. exports.getOutputScale = getOutputScale;
  3079. exports.scrollIntoView = scrollIntoView;
  3080. exports.watchScroll = watchScroll;
  3081. exports.binarySearchFirstItem = binarySearchFirstItem;
  3082. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  3083. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  3084. exports.moveToEndOfArray = moveToEndOfArray;
  3085. 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 = exports.AutoPrintRegExp = void 0;
  3086. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  3087. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3088. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3089. 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); } }
  3090. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3091. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3092. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  3093. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  3094. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  3095. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  3096. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  3097. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  3098. 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); } }
  3099. 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); }); }; }
  3100. var CSS_UNITS = 96.0 / 72.0;
  3101. exports.CSS_UNITS = CSS_UNITS;
  3102. var DEFAULT_SCALE_VALUE = "auto";
  3103. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  3104. var DEFAULT_SCALE = 1.0;
  3105. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  3106. var MIN_SCALE = 0.1;
  3107. exports.MIN_SCALE = MIN_SCALE;
  3108. var MAX_SCALE = 10.0;
  3109. exports.MAX_SCALE = MAX_SCALE;
  3110. var UNKNOWN_SCALE = 0;
  3111. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  3112. var MAX_AUTO_SCALE = 1.25;
  3113. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  3114. var SCROLLBAR_PADDING = 40;
  3115. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  3116. var VERTICAL_PADDING = 5;
  3117. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  3118. var PresentationModeState = {
  3119. UNKNOWN: 0,
  3120. NORMAL: 1,
  3121. CHANGING: 2,
  3122. FULLSCREEN: 3
  3123. };
  3124. exports.PresentationModeState = PresentationModeState;
  3125. var RendererType = {
  3126. CANVAS: "canvas",
  3127. SVG: "svg"
  3128. };
  3129. exports.RendererType = RendererType;
  3130. var TextLayerMode = {
  3131. DISABLE: 0,
  3132. ENABLE: 1,
  3133. ENABLE_ENHANCE: 2
  3134. };
  3135. exports.TextLayerMode = TextLayerMode;
  3136. var ScrollMode = {
  3137. UNKNOWN: -1,
  3138. VERTICAL: 0,
  3139. HORIZONTAL: 1,
  3140. WRAPPED: 2
  3141. };
  3142. exports.ScrollMode = ScrollMode;
  3143. var SpreadMode = {
  3144. UNKNOWN: -1,
  3145. NONE: 0,
  3146. ODD: 1,
  3147. EVEN: 2
  3148. };
  3149. exports.SpreadMode = SpreadMode;
  3150. var AutoPrintRegExp = /\bprint\s*\(/;
  3151. exports.AutoPrintRegExp = AutoPrintRegExp;
  3152. function formatL10nValue(text, args) {
  3153. if (!args) {
  3154. return text;
  3155. }
  3156. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  3157. return name in args ? args[name] : "{{" + name + "}}";
  3158. });
  3159. }
  3160. var NullL10n = {
  3161. getLanguage: function getLanguage() {
  3162. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  3163. return _regenerator["default"].wrap(function _callee$(_context) {
  3164. while (1) {
  3165. switch (_context.prev = _context.next) {
  3166. case 0:
  3167. return _context.abrupt("return", "en-us");
  3168. case 1:
  3169. case "end":
  3170. return _context.stop();
  3171. }
  3172. }
  3173. }, _callee);
  3174. }))();
  3175. },
  3176. getDirection: function getDirection() {
  3177. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  3178. return _regenerator["default"].wrap(function _callee2$(_context2) {
  3179. while (1) {
  3180. switch (_context2.prev = _context2.next) {
  3181. case 0:
  3182. return _context2.abrupt("return", "ltr");
  3183. case 1:
  3184. case "end":
  3185. return _context2.stop();
  3186. }
  3187. }
  3188. }, _callee2);
  3189. }))();
  3190. },
  3191. get: function get(property, args, fallback) {
  3192. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  3193. return _regenerator["default"].wrap(function _callee3$(_context3) {
  3194. while (1) {
  3195. switch (_context3.prev = _context3.next) {
  3196. case 0:
  3197. return _context3.abrupt("return", formatL10nValue(fallback, args));
  3198. case 1:
  3199. case "end":
  3200. return _context3.stop();
  3201. }
  3202. }
  3203. }, _callee3);
  3204. }))();
  3205. },
  3206. translate: function translate(element) {
  3207. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  3208. return _regenerator["default"].wrap(function _callee4$(_context4) {
  3209. while (1) {
  3210. switch (_context4.prev = _context4.next) {
  3211. case 0:
  3212. case "end":
  3213. return _context4.stop();
  3214. }
  3215. }
  3216. }, _callee4);
  3217. }))();
  3218. }
  3219. };
  3220. exports.NullL10n = NullL10n;
  3221. function getOutputScale(ctx) {
  3222. var devicePixelRatio = window.devicePixelRatio || 1;
  3223. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  3224. var pixelRatio = devicePixelRatio / backingStoreRatio;
  3225. return {
  3226. sx: pixelRatio,
  3227. sy: pixelRatio,
  3228. scaled: pixelRatio !== 1
  3229. };
  3230. }
  3231. function scrollIntoView(element, spot) {
  3232. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3233. var parent = element.offsetParent;
  3234. if (!parent) {
  3235. console.error("offsetParent is not set -- cannot scroll");
  3236. return;
  3237. }
  3238. var offsetY = element.offsetTop + element.clientTop;
  3239. var offsetX = element.offsetLeft + element.clientLeft;
  3240. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === "hidden") {
  3241. if (parent.dataset._scaleY) {
  3242. offsetY /= parent.dataset._scaleY;
  3243. offsetX /= parent.dataset._scaleX;
  3244. }
  3245. offsetY += parent.offsetTop;
  3246. offsetX += parent.offsetLeft;
  3247. parent = parent.offsetParent;
  3248. if (!parent) {
  3249. return;
  3250. }
  3251. }
  3252. if (spot) {
  3253. if (spot.top !== undefined) {
  3254. offsetY += spot.top;
  3255. }
  3256. if (spot.left !== undefined) {
  3257. offsetX += spot.left;
  3258. parent.scrollLeft = offsetX;
  3259. }
  3260. }
  3261. parent.scrollTop = offsetY;
  3262. }
  3263. function watchScroll(viewAreaElement, callback) {
  3264. var debounceScroll = function debounceScroll(evt) {
  3265. if (rAF) {
  3266. return;
  3267. }
  3268. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  3269. rAF = null;
  3270. var currentX = viewAreaElement.scrollLeft;
  3271. var lastX = state.lastX;
  3272. if (currentX !== lastX) {
  3273. state.right = currentX > lastX;
  3274. }
  3275. state.lastX = currentX;
  3276. var currentY = viewAreaElement.scrollTop;
  3277. var lastY = state.lastY;
  3278. if (currentY !== lastY) {
  3279. state.down = currentY > lastY;
  3280. }
  3281. state.lastY = currentY;
  3282. callback(state);
  3283. });
  3284. };
  3285. var state = {
  3286. right: true,
  3287. down: true,
  3288. lastX: viewAreaElement.scrollLeft,
  3289. lastY: viewAreaElement.scrollTop,
  3290. _eventHandler: debounceScroll
  3291. };
  3292. var rAF = null;
  3293. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  3294. return state;
  3295. }
  3296. function parseQueryString(query) {
  3297. var parts = query.split("&");
  3298. var params = Object.create(null);
  3299. for (var i = 0, ii = parts.length; i < ii; ++i) {
  3300. var param = parts[i].split("=");
  3301. var key = param[0].toLowerCase();
  3302. var value = param.length > 1 ? param[1] : null;
  3303. params[decodeURIComponent(key)] = decodeURIComponent(value);
  3304. }
  3305. return params;
  3306. }
  3307. function binarySearchFirstItem(items, condition) {
  3308. var minIndex = 0;
  3309. var maxIndex = items.length - 1;
  3310. if (maxIndex < 0 || !condition(items[maxIndex])) {
  3311. return items.length;
  3312. }
  3313. if (condition(items[minIndex])) {
  3314. return minIndex;
  3315. }
  3316. while (minIndex < maxIndex) {
  3317. var currentIndex = minIndex + maxIndex >> 1;
  3318. var currentItem = items[currentIndex];
  3319. if (condition(currentItem)) {
  3320. maxIndex = currentIndex;
  3321. } else {
  3322. minIndex = currentIndex + 1;
  3323. }
  3324. }
  3325. return minIndex;
  3326. }
  3327. function approximateFraction(x) {
  3328. if (Math.floor(x) === x) {
  3329. return [x, 1];
  3330. }
  3331. var xinv = 1 / x;
  3332. var limit = 8;
  3333. if (xinv > limit) {
  3334. return [1, limit];
  3335. } else if (Math.floor(xinv) === xinv) {
  3336. return [1, xinv];
  3337. }
  3338. var x_ = x > 1 ? xinv : x;
  3339. var a = 0,
  3340. b = 1,
  3341. c = 1,
  3342. d = 1;
  3343. while (true) {
  3344. var p = a + c,
  3345. q = b + d;
  3346. if (q > limit) {
  3347. break;
  3348. }
  3349. if (x_ <= p / q) {
  3350. c = p;
  3351. d = q;
  3352. } else {
  3353. a = p;
  3354. b = q;
  3355. }
  3356. }
  3357. var result;
  3358. if (x_ - a / b < c / d - x_) {
  3359. result = x_ === x ? [a, b] : [b, a];
  3360. } else {
  3361. result = x_ === x ? [c, d] : [d, c];
  3362. }
  3363. return result;
  3364. }
  3365. function roundToDivide(x, div) {
  3366. var r = x % div;
  3367. return r === 0 ? x : Math.round(x - r + div);
  3368. }
  3369. function getPageSizeInches(_ref) {
  3370. var view = _ref.view,
  3371. userUnit = _ref.userUnit,
  3372. rotate = _ref.rotate;
  3373. var _view = _slicedToArray(view, 4),
  3374. x1 = _view[0],
  3375. y1 = _view[1],
  3376. x2 = _view[2],
  3377. y2 = _view[3];
  3378. var changeOrientation = rotate % 180 !== 0;
  3379. var width = (x2 - x1) / 72 * userUnit;
  3380. var height = (y2 - y1) / 72 * userUnit;
  3381. return {
  3382. width: changeOrientation ? height : width,
  3383. height: changeOrientation ? width : height
  3384. };
  3385. }
  3386. function backtrackBeforeAllVisibleElements(index, views, top) {
  3387. if (index < 2) {
  3388. return index;
  3389. }
  3390. var elt = views[index].div;
  3391. var pageTop = elt.offsetTop + elt.clientTop;
  3392. if (pageTop >= top) {
  3393. elt = views[index - 1].div;
  3394. pageTop = elt.offsetTop + elt.clientTop;
  3395. }
  3396. for (var i = index - 2; i >= 0; --i) {
  3397. elt = views[i].div;
  3398. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  3399. break;
  3400. }
  3401. index = i;
  3402. }
  3403. return index;
  3404. }
  3405. function getVisibleElements(scrollEl, views) {
  3406. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3407. var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  3408. var top = scrollEl.scrollTop,
  3409. bottom = top + scrollEl.clientHeight;
  3410. var left = scrollEl.scrollLeft,
  3411. right = left + scrollEl.clientWidth;
  3412. function isElementBottomAfterViewTop(view) {
  3413. var element = view.div;
  3414. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  3415. return elementBottom > top;
  3416. }
  3417. function isElementRightAfterViewLeft(view) {
  3418. var element = view.div;
  3419. var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
  3420. return elementRight > left;
  3421. }
  3422. var visible = [],
  3423. numViews = views.length;
  3424. var firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
  3425. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  3426. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  3427. }
  3428. var lastEdge = horizontal ? right : -1;
  3429. for (var i = firstVisibleElementInd; i < numViews; i++) {
  3430. var view = views[i],
  3431. element = view.div;
  3432. var currentWidth = element.offsetLeft + element.clientLeft;
  3433. var currentHeight = element.offsetTop + element.clientTop;
  3434. var viewWidth = element.clientWidth,
  3435. viewHeight = element.clientHeight;
  3436. var viewRight = currentWidth + viewWidth;
  3437. var viewBottom = currentHeight + viewHeight;
  3438. if (lastEdge === -1) {
  3439. if (viewBottom >= bottom) {
  3440. lastEdge = viewBottom;
  3441. }
  3442. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  3443. break;
  3444. }
  3445. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  3446. continue;
  3447. }
  3448. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  3449. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  3450. var percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
  3451. visible.push({
  3452. id: view.id,
  3453. x: currentWidth,
  3454. y: currentHeight,
  3455. view: view,
  3456. percent: percent
  3457. });
  3458. }
  3459. var first = visible[0],
  3460. last = visible[visible.length - 1];
  3461. if (sortByVisibility) {
  3462. visible.sort(function (a, b) {
  3463. var pc = a.percent - b.percent;
  3464. if (Math.abs(pc) > 0.001) {
  3465. return -pc;
  3466. }
  3467. return a.id - b.id;
  3468. });
  3469. }
  3470. return {
  3471. first: first,
  3472. last: last,
  3473. views: visible
  3474. };
  3475. }
  3476. function noContextMenuHandler(evt) {
  3477. evt.preventDefault();
  3478. }
  3479. function isDataSchema(url) {
  3480. var i = 0;
  3481. var ii = url.length;
  3482. while (i < ii && url[i].trim() === "") {
  3483. i++;
  3484. }
  3485. return url.substring(i, i + 5).toLowerCase() === "data:";
  3486. }
  3487. function getPDFFileNameFromURL(url) {
  3488. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "document.pdf";
  3489. if (typeof url !== "string") {
  3490. return defaultFilename;
  3491. }
  3492. if (isDataSchema(url)) {
  3493. console.warn("getPDFFileNameFromURL: " + 'ignoring "data:" URL for performance reasons.');
  3494. return defaultFilename;
  3495. }
  3496. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  3497. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  3498. var splitURI = reURI.exec(url);
  3499. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  3500. if (suggestedFilename) {
  3501. suggestedFilename = suggestedFilename[0];
  3502. if (suggestedFilename.includes("%")) {
  3503. try {
  3504. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  3505. } catch (ex) {}
  3506. }
  3507. }
  3508. return suggestedFilename || defaultFilename;
  3509. }
  3510. function normalizeWheelEventDelta(evt) {
  3511. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  3512. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  3513. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  3514. delta = -delta;
  3515. }
  3516. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  3517. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  3518. var MOUSE_PIXELS_PER_LINE = 30;
  3519. var MOUSE_LINES_PER_PAGE = 30;
  3520. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  3521. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  3522. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  3523. delta /= MOUSE_LINES_PER_PAGE;
  3524. }
  3525. return delta;
  3526. }
  3527. function isValidRotation(angle) {
  3528. return Number.isInteger(angle) && angle % 90 === 0;
  3529. }
  3530. function isValidScrollMode(mode) {
  3531. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  3532. }
  3533. function isValidSpreadMode(mode) {
  3534. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  3535. }
  3536. function isPortraitOrientation(size) {
  3537. return size.width <= size.height;
  3538. }
  3539. var WaitOnType = {
  3540. EVENT: "event",
  3541. TIMEOUT: "timeout"
  3542. };
  3543. exports.WaitOnType = WaitOnType;
  3544. function waitOnEventOrTimeout(_ref2) {
  3545. var target = _ref2.target,
  3546. name = _ref2.name,
  3547. _ref2$delay = _ref2.delay,
  3548. delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
  3549. return new Promise(function (resolve, reject) {
  3550. if (_typeof(target) !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  3551. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  3552. }
  3553. function handler(type) {
  3554. if (target instanceof EventBus) {
  3555. target._off(name, eventHandler);
  3556. } else {
  3557. target.removeEventListener(name, eventHandler);
  3558. }
  3559. if (timeout) {
  3560. clearTimeout(timeout);
  3561. }
  3562. resolve(type);
  3563. }
  3564. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  3565. if (target instanceof EventBus) {
  3566. target._on(name, eventHandler);
  3567. } else {
  3568. target.addEventListener(name, eventHandler);
  3569. }
  3570. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  3571. var timeout = setTimeout(timeoutHandler, delay);
  3572. });
  3573. }
  3574. var animationStarted = new Promise(function (resolve) {
  3575. window.requestAnimationFrame(resolve);
  3576. });
  3577. exports.animationStarted = animationStarted;
  3578. function dispatchDOMEvent(eventName) {
  3579. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3580. throw new Error("Not implemented: dispatchDOMEvent");
  3581. }
  3582. var EventBus = /*#__PURE__*/function () {
  3583. function EventBus(options) {
  3584. _classCallCheck(this, EventBus);
  3585. this._listeners = Object.create(null);
  3586. }
  3587. _createClass(EventBus, [{
  3588. key: "on",
  3589. value: function on(eventName, listener) {
  3590. this._on(eventName, listener, {
  3591. external: true
  3592. });
  3593. }
  3594. }, {
  3595. key: "off",
  3596. value: function off(eventName, listener) {
  3597. this._off(eventName, listener, {
  3598. external: true
  3599. });
  3600. }
  3601. }, {
  3602. key: "dispatch",
  3603. value: function dispatch(eventName) {
  3604. var eventListeners = this._listeners[eventName];
  3605. if (!eventListeners || eventListeners.length === 0) {
  3606. return;
  3607. }
  3608. var args = Array.prototype.slice.call(arguments, 1);
  3609. var externalListeners;
  3610. eventListeners.slice(0).forEach(function (_ref3) {
  3611. var listener = _ref3.listener,
  3612. external = _ref3.external;
  3613. if (external) {
  3614. if (!externalListeners) {
  3615. externalListeners = [];
  3616. }
  3617. externalListeners.push(listener);
  3618. return;
  3619. }
  3620. listener.apply(null, args);
  3621. });
  3622. if (externalListeners) {
  3623. externalListeners.forEach(function (listener) {
  3624. listener.apply(null, args);
  3625. });
  3626. externalListeners = null;
  3627. }
  3628. }
  3629. }, {
  3630. key: "_on",
  3631. value: function _on(eventName, listener) {
  3632. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3633. var eventListeners = this._listeners[eventName];
  3634. if (!eventListeners) {
  3635. this._listeners[eventName] = eventListeners = [];
  3636. }
  3637. eventListeners.push({
  3638. listener: listener,
  3639. external: (options && options.external) === true
  3640. });
  3641. }
  3642. }, {
  3643. key: "_off",
  3644. value: function _off(eventName, listener) {
  3645. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3646. var eventListeners = this._listeners[eventName];
  3647. if (!eventListeners) {
  3648. return;
  3649. }
  3650. for (var i = 0, ii = eventListeners.length; i < ii; i++) {
  3651. if (eventListeners[i].listener === listener) {
  3652. eventListeners.splice(i, 1);
  3653. return;
  3654. }
  3655. }
  3656. }
  3657. }]);
  3658. return EventBus;
  3659. }();
  3660. exports.EventBus = EventBus;
  3661. function clamp(v, min, max) {
  3662. return Math.min(Math.max(v, min), max);
  3663. }
  3664. var ProgressBar = /*#__PURE__*/function () {
  3665. function ProgressBar(id) {
  3666. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  3667. height = _ref4.height,
  3668. width = _ref4.width,
  3669. units = _ref4.units;
  3670. _classCallCheck(this, ProgressBar);
  3671. this.visible = true;
  3672. this.div = document.querySelector(id + " .progress");
  3673. this.bar = this.div.parentNode;
  3674. this.height = height || 100;
  3675. this.width = width || 100;
  3676. this.units = units || "%";
  3677. this.div.style.height = this.height + this.units;
  3678. this.percent = 0;
  3679. }
  3680. _createClass(ProgressBar, [{
  3681. key: "_updateBar",
  3682. value: function _updateBar() {
  3683. if (this._indeterminate) {
  3684. this.div.classList.add("indeterminate");
  3685. this.div.style.width = this.width + this.units;
  3686. return;
  3687. }
  3688. this.div.classList.remove("indeterminate");
  3689. var progressSize = this.width * this._percent / 100;
  3690. this.div.style.width = progressSize + this.units;
  3691. }
  3692. }, {
  3693. key: "setWidth",
  3694. value: function setWidth(viewer) {
  3695. if (!viewer) {
  3696. return;
  3697. }
  3698. var container = viewer.parentNode;
  3699. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  3700. if (scrollbarWidth > 0) {
  3701. this.bar.style.width = "calc(100% - ".concat(scrollbarWidth, "px)");
  3702. }
  3703. }
  3704. }, {
  3705. key: "hide",
  3706. value: function hide() {
  3707. if (!this.visible) {
  3708. return;
  3709. }
  3710. this.visible = false;
  3711. this.bar.classList.add("hidden");
  3712. document.body.classList.remove("loadingInProgress");
  3713. }
  3714. }, {
  3715. key: "show",
  3716. value: function show() {
  3717. if (this.visible) {
  3718. return;
  3719. }
  3720. this.visible = true;
  3721. document.body.classList.add("loadingInProgress");
  3722. this.bar.classList.remove("hidden");
  3723. }
  3724. }, {
  3725. key: "percent",
  3726. get: function get() {
  3727. return this._percent;
  3728. },
  3729. set: function set(val) {
  3730. this._indeterminate = isNaN(val);
  3731. this._percent = clamp(val, 0, 100);
  3732. this._updateBar();
  3733. }
  3734. }]);
  3735. return ProgressBar;
  3736. }();
  3737. exports.ProgressBar = ProgressBar;
  3738. function moveToEndOfArray(arr, condition) {
  3739. var moved = [],
  3740. len = arr.length;
  3741. var write = 0;
  3742. for (var read = 0; read < len; ++read) {
  3743. if (condition(arr[read])) {
  3744. moved.push(arr[read]);
  3745. } else {
  3746. arr[write] = arr[read];
  3747. ++write;
  3748. }
  3749. }
  3750. for (var _read = 0; write < len; ++_read, ++write) {
  3751. arr[write] = moved[_read];
  3752. }
  3753. }
  3754. /***/ }),
  3755. /* 6 */
  3756. /***/ (function(module, exports, __webpack_require__) {
  3757. "use strict";
  3758. Object.defineProperty(exports, "__esModule", {
  3759. value: true
  3760. });
  3761. exports.OptionKind = exports.AppOptions = void 0;
  3762. var _viewer_compatibility = __webpack_require__(7);
  3763. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3764. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3765. 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); } }
  3766. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3767. var OptionKind = {
  3768. VIEWER: 0x02,
  3769. API: 0x04,
  3770. WORKER: 0x08,
  3771. PREFERENCE: 0x80
  3772. };
  3773. exports.OptionKind = OptionKind;
  3774. var defaultOptions = {
  3775. cursorToolOnLoad: {
  3776. value: 0,
  3777. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3778. },
  3779. defaultUrl: {
  3780. value: "compressed.tracemonkey-pldi-09.pdf",
  3781. kind: OptionKind.VIEWER
  3782. },
  3783. defaultZoomValue: {
  3784. value: "",
  3785. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3786. },
  3787. disableCreateObjectURL: {
  3788. value: false,
  3789. compatibility: _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL,
  3790. kind: OptionKind.VIEWER
  3791. },
  3792. disableHistory: {
  3793. value: false,
  3794. kind: OptionKind.VIEWER
  3795. },
  3796. disablePageLabels: {
  3797. value: false,
  3798. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3799. },
  3800. enablePermissions: {
  3801. value: false,
  3802. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3803. },
  3804. enablePrintAutoRotate: {
  3805. value: false,
  3806. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3807. },
  3808. enableWebGL: {
  3809. value: false,
  3810. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3811. },
  3812. externalLinkRel: {
  3813. value: "noopener noreferrer nofollow",
  3814. kind: OptionKind.VIEWER
  3815. },
  3816. externalLinkTarget: {
  3817. value: 0,
  3818. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3819. },
  3820. historyUpdateUrl: {
  3821. value: false,
  3822. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3823. },
  3824. ignoreDestinationZoom: {
  3825. value: false,
  3826. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3827. },
  3828. imageResourcesPath: {
  3829. value: "./images/",
  3830. kind: OptionKind.VIEWER
  3831. },
  3832. maxCanvasPixels: {
  3833. value: 16777216,
  3834. compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
  3835. kind: OptionKind.VIEWER
  3836. },
  3837. pdfBugEnabled: {
  3838. value: false,
  3839. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3840. },
  3841. printResolution: {
  3842. value: 150,
  3843. kind: OptionKind.VIEWER
  3844. },
  3845. renderer: {
  3846. value: "canvas",
  3847. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3848. },
  3849. renderInteractiveForms: {
  3850. value: false,
  3851. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3852. },
  3853. sidebarViewOnLoad: {
  3854. value: -1,
  3855. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3856. },
  3857. scrollModeOnLoad: {
  3858. value: -1,
  3859. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3860. },
  3861. spreadModeOnLoad: {
  3862. value: -1,
  3863. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3864. },
  3865. textLayerMode: {
  3866. value: 1,
  3867. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3868. },
  3869. useOnlyCssZoom: {
  3870. value: false,
  3871. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3872. },
  3873. viewOnLoad: {
  3874. value: 0,
  3875. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3876. },
  3877. cMapPacked: {
  3878. value: true,
  3879. kind: OptionKind.API
  3880. },
  3881. cMapUrl: {
  3882. value: "../web/cmaps/",
  3883. kind: OptionKind.API
  3884. },
  3885. disableAutoFetch: {
  3886. value: false,
  3887. kind: OptionKind.API + OptionKind.PREFERENCE
  3888. },
  3889. disableFontFace: {
  3890. value: false,
  3891. kind: OptionKind.API + OptionKind.PREFERENCE
  3892. },
  3893. disableRange: {
  3894. value: false,
  3895. kind: OptionKind.API + OptionKind.PREFERENCE
  3896. },
  3897. disableStream: {
  3898. value: false,
  3899. kind: OptionKind.API + OptionKind.PREFERENCE
  3900. },
  3901. docBaseUrl: {
  3902. value: "",
  3903. kind: OptionKind.API
  3904. },
  3905. fontExtraProperties: {
  3906. value: false,
  3907. kind: OptionKind.API
  3908. },
  3909. isEvalSupported: {
  3910. value: true,
  3911. kind: OptionKind.API
  3912. },
  3913. maxImageSize: {
  3914. value: -1,
  3915. kind: OptionKind.API
  3916. },
  3917. pdfBug: {
  3918. value: false,
  3919. kind: OptionKind.API
  3920. },
  3921. verbosity: {
  3922. value: 1,
  3923. kind: OptionKind.API
  3924. },
  3925. workerPort: {
  3926. value: null,
  3927. kind: OptionKind.WORKER
  3928. },
  3929. workerSrc: {
  3930. value: "../build/pdf.worker.js",
  3931. kind: OptionKind.WORKER
  3932. }
  3933. };
  3934. {
  3935. defaultOptions.disablePreferences = {
  3936. value: false,
  3937. kind: OptionKind.VIEWER
  3938. };
  3939. defaultOptions.locale = {
  3940. value: typeof navigator !== "undefined" ? navigator.language : "en-US",
  3941. kind: OptionKind.VIEWER
  3942. };
  3943. }
  3944. var userOptions = Object.create(null);
  3945. var AppOptions = /*#__PURE__*/function () {
  3946. function AppOptions() {
  3947. _classCallCheck(this, AppOptions);
  3948. throw new Error("Cannot initialize AppOptions.");
  3949. }
  3950. _createClass(AppOptions, null, [{
  3951. key: "get",
  3952. value: function get(name) {
  3953. var userOption = userOptions[name];
  3954. if (userOption !== undefined) {
  3955. return userOption;
  3956. }
  3957. var defaultOption = defaultOptions[name];
  3958. if (defaultOption !== undefined) {
  3959. return defaultOption.compatibility || defaultOption.value;
  3960. }
  3961. return undefined;
  3962. }
  3963. }, {
  3964. key: "getAll",
  3965. value: function getAll() {
  3966. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  3967. var options = Object.create(null);
  3968. for (var name in defaultOptions) {
  3969. var defaultOption = defaultOptions[name];
  3970. if (kind) {
  3971. if ((kind & defaultOption.kind) === 0) {
  3972. continue;
  3973. }
  3974. if (kind === OptionKind.PREFERENCE) {
  3975. var value = defaultOption.value,
  3976. valueType = _typeof(value);
  3977. if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
  3978. options[name] = value;
  3979. continue;
  3980. }
  3981. throw new Error("Invalid type for preference: ".concat(name));
  3982. }
  3983. }
  3984. var userOption = userOptions[name];
  3985. options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
  3986. }
  3987. return options;
  3988. }
  3989. }, {
  3990. key: "set",
  3991. value: function set(name, value) {
  3992. userOptions[name] = value;
  3993. }
  3994. }, {
  3995. key: "remove",
  3996. value: function remove(name) {
  3997. delete userOptions[name];
  3998. }
  3999. }]);
  4000. return AppOptions;
  4001. }();
  4002. exports.AppOptions = AppOptions;
  4003. /***/ }),
  4004. /* 7 */
  4005. /***/ (function(module, exports, __webpack_require__) {
  4006. "use strict";
  4007. Object.defineProperty(exports, "__esModule", {
  4008. value: true
  4009. });
  4010. exports.viewerCompatibilityParams = void 0;
  4011. var compatibilityParams = Object.create(null);
  4012. {
  4013. var userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
  4014. var platform = typeof navigator !== "undefined" && navigator.platform || "";
  4015. var maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
  4016. var isAndroid = /Android/.test(userAgent);
  4017. var isIE = /Trident/.test(userAgent);
  4018. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  4019. var isIOSChrome = /CriOS/.test(userAgent);
  4020. (function checkOnBlobSupport() {
  4021. if (isIE || isIOSChrome) {
  4022. compatibilityParams.disableCreateObjectURL = true;
  4023. }
  4024. })();
  4025. (function checkCanvasSizeLimitation() {
  4026. if (isIOS || isAndroid) {
  4027. compatibilityParams.maxCanvasPixels = 5242880;
  4028. }
  4029. })();
  4030. }
  4031. var viewerCompatibilityParams = Object.freeze(compatibilityParams);
  4032. exports.viewerCompatibilityParams = viewerCompatibilityParams;
  4033. /***/ }),
  4034. /* 8 */
  4035. /***/ (function(module, exports, __webpack_require__) {
  4036. "use strict";
  4037. var pdfjsLib;
  4038. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  4039. pdfjsLib = window["pdfjs-dist/build/pdf"];
  4040. } else {
  4041. pdfjsLib = require("../build/pdf.js");
  4042. }
  4043. module.exports = pdfjsLib;
  4044. /***/ }),
  4045. /* 9 */
  4046. /***/ (function(module, exports, __webpack_require__) {
  4047. "use strict";
  4048. Object.defineProperty(exports, "__esModule", {
  4049. value: true
  4050. });
  4051. exports.PDFCursorTools = exports.CursorTool = void 0;
  4052. var _grab_to_pan = __webpack_require__(10);
  4053. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4054. 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); } }
  4055. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4056. var CursorTool = {
  4057. SELECT: 0,
  4058. HAND: 1,
  4059. ZOOM: 2
  4060. };
  4061. exports.CursorTool = CursorTool;
  4062. var PDFCursorTools = /*#__PURE__*/function () {
  4063. function PDFCursorTools(_ref) {
  4064. var _this = this;
  4065. var container = _ref.container,
  4066. eventBus = _ref.eventBus,
  4067. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  4068. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT : _ref$cursorToolOnLoad;
  4069. _classCallCheck(this, PDFCursorTools);
  4070. this.container = container;
  4071. this.eventBus = eventBus;
  4072. this.active = CursorTool.SELECT;
  4073. this.activeBeforePresentationMode = null;
  4074. this.handTool = new _grab_to_pan.GrabToPan({
  4075. element: this.container
  4076. });
  4077. this._addEventListeners();
  4078. Promise.resolve().then(function () {
  4079. _this.switchTool(cursorToolOnLoad);
  4080. });
  4081. }
  4082. _createClass(PDFCursorTools, [{
  4083. key: "switchTool",
  4084. value: function switchTool(tool) {
  4085. var _this2 = this;
  4086. if (this.activeBeforePresentationMode !== null) {
  4087. return;
  4088. }
  4089. if (tool === this.active) {
  4090. return;
  4091. }
  4092. var disableActiveTool = function disableActiveTool() {
  4093. switch (_this2.active) {
  4094. case CursorTool.SELECT:
  4095. break;
  4096. case CursorTool.HAND:
  4097. _this2.handTool.deactivate();
  4098. break;
  4099. case CursorTool.ZOOM:
  4100. }
  4101. };
  4102. switch (tool) {
  4103. case CursorTool.SELECT:
  4104. disableActiveTool();
  4105. break;
  4106. case CursorTool.HAND:
  4107. disableActiveTool();
  4108. this.handTool.activate();
  4109. break;
  4110. case CursorTool.ZOOM:
  4111. default:
  4112. console.error("switchTool: \"".concat(tool, "\" is an unsupported value."));
  4113. return;
  4114. }
  4115. this.active = tool;
  4116. this._dispatchEvent();
  4117. }
  4118. }, {
  4119. key: "_dispatchEvent",
  4120. value: function _dispatchEvent() {
  4121. this.eventBus.dispatch("cursortoolchanged", {
  4122. source: this,
  4123. tool: this.active
  4124. });
  4125. }
  4126. }, {
  4127. key: "_addEventListeners",
  4128. value: function _addEventListeners() {
  4129. var _this3 = this;
  4130. this.eventBus._on("switchcursortool", function (evt) {
  4131. _this3.switchTool(evt.tool);
  4132. });
  4133. this.eventBus._on("presentationmodechanged", function (evt) {
  4134. if (evt.switchInProgress) {
  4135. return;
  4136. }
  4137. var previouslyActive;
  4138. if (evt.active) {
  4139. previouslyActive = _this3.active;
  4140. _this3.switchTool(CursorTool.SELECT);
  4141. _this3.activeBeforePresentationMode = previouslyActive;
  4142. } else {
  4143. previouslyActive = _this3.activeBeforePresentationMode;
  4144. _this3.activeBeforePresentationMode = null;
  4145. _this3.switchTool(previouslyActive);
  4146. }
  4147. });
  4148. }
  4149. }, {
  4150. key: "activeTool",
  4151. get: function get() {
  4152. return this.active;
  4153. }
  4154. }]);
  4155. return PDFCursorTools;
  4156. }();
  4157. exports.PDFCursorTools = PDFCursorTools;
  4158. /***/ }),
  4159. /* 10 */
  4160. /***/ (function(module, exports, __webpack_require__) {
  4161. "use strict";
  4162. Object.defineProperty(exports, "__esModule", {
  4163. value: true
  4164. });
  4165. exports.GrabToPan = GrabToPan;
  4166. function GrabToPan(options) {
  4167. this.element = options.element;
  4168. this.document = options.element.ownerDocument;
  4169. if (typeof options.ignoreTarget === "function") {
  4170. this.ignoreTarget = options.ignoreTarget;
  4171. }
  4172. this.onActiveChanged = options.onActiveChanged;
  4173. this.activate = this.activate.bind(this);
  4174. this.deactivate = this.deactivate.bind(this);
  4175. this.toggle = this.toggle.bind(this);
  4176. this._onmousedown = this._onmousedown.bind(this);
  4177. this._onmousemove = this._onmousemove.bind(this);
  4178. this._endPan = this._endPan.bind(this);
  4179. var overlay = this.overlay = document.createElement("div");
  4180. overlay.className = "grab-to-pan-grabbing";
  4181. }
  4182. GrabToPan.prototype = {
  4183. CSS_CLASS_GRAB: "grab-to-pan-grab",
  4184. activate: function GrabToPan_activate() {
  4185. if (!this.active) {
  4186. this.active = true;
  4187. this.element.addEventListener("mousedown", this._onmousedown, true);
  4188. this.element.classList.add(this.CSS_CLASS_GRAB);
  4189. if (this.onActiveChanged) {
  4190. this.onActiveChanged(true);
  4191. }
  4192. }
  4193. },
  4194. deactivate: function GrabToPan_deactivate() {
  4195. if (this.active) {
  4196. this.active = false;
  4197. this.element.removeEventListener("mousedown", this._onmousedown, true);
  4198. this._endPan();
  4199. this.element.classList.remove(this.CSS_CLASS_GRAB);
  4200. if (this.onActiveChanged) {
  4201. this.onActiveChanged(false);
  4202. }
  4203. }
  4204. },
  4205. toggle: function GrabToPan_toggle() {
  4206. if (this.active) {
  4207. this.deactivate();
  4208. } else {
  4209. this.activate();
  4210. }
  4211. },
  4212. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  4213. return node[matchesSelector]("a[href], a[href] *, input, textarea, button, button *, select, option");
  4214. },
  4215. _onmousedown: function GrabToPan__onmousedown(event) {
  4216. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  4217. return;
  4218. }
  4219. if (event.originalTarget) {
  4220. try {
  4221. event.originalTarget.tagName;
  4222. } catch (e) {
  4223. return;
  4224. }
  4225. }
  4226. this.scrollLeftStart = this.element.scrollLeft;
  4227. this.scrollTopStart = this.element.scrollTop;
  4228. this.clientXStart = event.clientX;
  4229. this.clientYStart = event.clientY;
  4230. this.document.addEventListener("mousemove", this._onmousemove, true);
  4231. this.document.addEventListener("mouseup", this._endPan, true);
  4232. this.element.addEventListener("scroll", this._endPan, true);
  4233. event.preventDefault();
  4234. event.stopPropagation();
  4235. var focusedElement = document.activeElement;
  4236. if (focusedElement && !focusedElement.contains(event.target)) {
  4237. focusedElement.blur();
  4238. }
  4239. },
  4240. _onmousemove: function GrabToPan__onmousemove(event) {
  4241. this.element.removeEventListener("scroll", this._endPan, true);
  4242. if (isLeftMouseReleased(event)) {
  4243. this._endPan();
  4244. return;
  4245. }
  4246. var xDiff = event.clientX - this.clientXStart;
  4247. var yDiff = event.clientY - this.clientYStart;
  4248. var scrollTop = this.scrollTopStart - yDiff;
  4249. var scrollLeft = this.scrollLeftStart - xDiff;
  4250. if (this.element.scrollTo) {
  4251. this.element.scrollTo({
  4252. top: scrollTop,
  4253. left: scrollLeft,
  4254. behavior: "instant"
  4255. });
  4256. } else {
  4257. this.element.scrollTop = scrollTop;
  4258. this.element.scrollLeft = scrollLeft;
  4259. }
  4260. if (!this.overlay.parentNode) {
  4261. document.body.appendChild(this.overlay);
  4262. }
  4263. },
  4264. _endPan: function GrabToPan__endPan() {
  4265. this.element.removeEventListener("scroll", this._endPan, true);
  4266. this.document.removeEventListener("mousemove", this._onmousemove, true);
  4267. this.document.removeEventListener("mouseup", this._endPan, true);
  4268. this.overlay.remove();
  4269. }
  4270. };
  4271. var matchesSelector;
  4272. ["webkitM", "mozM", "msM", "oM", "m"].some(function (prefix) {
  4273. var name = prefix + "atches";
  4274. if (name in document.documentElement) {
  4275. matchesSelector = name;
  4276. }
  4277. name += "Selector";
  4278. if (name in document.documentElement) {
  4279. matchesSelector = name;
  4280. }
  4281. return matchesSelector;
  4282. });
  4283. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  4284. var chrome = window.chrome;
  4285. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  4286. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  4287. function isLeftMouseReleased(event) {
  4288. if ("buttons" in event && isNotIEorIsIE10plus) {
  4289. return !(event.buttons & 1);
  4290. }
  4291. if (isChrome15OrOpera15plus || isSafari6plus) {
  4292. return event.which === 0;
  4293. }
  4294. return false;
  4295. }
  4296. /***/ }),
  4297. /* 11 */
  4298. /***/ (function(module, exports, __webpack_require__) {
  4299. "use strict";
  4300. Object.defineProperty(exports, "__esModule", {
  4301. value: true
  4302. });
  4303. exports.PDFRenderingQueue = exports.RenderingStates = void 0;
  4304. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4305. 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); } }
  4306. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4307. var CLEANUP_TIMEOUT = 30000;
  4308. var RenderingStates = {
  4309. INITIAL: 0,
  4310. RUNNING: 1,
  4311. PAUSED: 2,
  4312. FINISHED: 3
  4313. };
  4314. exports.RenderingStates = RenderingStates;
  4315. var PDFRenderingQueue = /*#__PURE__*/function () {
  4316. function PDFRenderingQueue() {
  4317. _classCallCheck(this, PDFRenderingQueue);
  4318. this.pdfViewer = null;
  4319. this.pdfThumbnailViewer = null;
  4320. this.onIdle = null;
  4321. this.highestPriorityPage = null;
  4322. this.idleTimeout = null;
  4323. this.printing = false;
  4324. this.isThumbnailViewEnabled = false;
  4325. }
  4326. _createClass(PDFRenderingQueue, [{
  4327. key: "setViewer",
  4328. value: function setViewer(pdfViewer) {
  4329. this.pdfViewer = pdfViewer;
  4330. }
  4331. }, {
  4332. key: "setThumbnailViewer",
  4333. value: function setThumbnailViewer(pdfThumbnailViewer) {
  4334. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4335. }
  4336. }, {
  4337. key: "isHighestPriority",
  4338. value: function isHighestPriority(view) {
  4339. return this.highestPriorityPage === view.renderingId;
  4340. }
  4341. }, {
  4342. key: "renderHighestPriority",
  4343. value: function renderHighestPriority(currentlyVisiblePages) {
  4344. if (this.idleTimeout) {
  4345. clearTimeout(this.idleTimeout);
  4346. this.idleTimeout = null;
  4347. }
  4348. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  4349. return;
  4350. }
  4351. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  4352. if (this.pdfThumbnailViewer.forceRendering()) {
  4353. return;
  4354. }
  4355. }
  4356. if (this.printing) {
  4357. return;
  4358. }
  4359. if (this.onIdle) {
  4360. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  4361. }
  4362. }
  4363. }, {
  4364. key: "getHighestPriority",
  4365. value: function getHighestPriority(visible, views, scrolledDown) {
  4366. var visibleViews = visible.views;
  4367. var numVisible = visibleViews.length;
  4368. if (numVisible === 0) {
  4369. return null;
  4370. }
  4371. for (var i = 0; i < numVisible; ++i) {
  4372. var view = visibleViews[i].view;
  4373. if (!this.isViewFinished(view)) {
  4374. return view;
  4375. }
  4376. }
  4377. if (scrolledDown) {
  4378. var nextPageIndex = visible.last.id;
  4379. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  4380. return views[nextPageIndex];
  4381. }
  4382. } else {
  4383. var previousPageIndex = visible.first.id - 2;
  4384. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  4385. return views[previousPageIndex];
  4386. }
  4387. }
  4388. return null;
  4389. }
  4390. }, {
  4391. key: "isViewFinished",
  4392. value: function isViewFinished(view) {
  4393. return view.renderingState === RenderingStates.FINISHED;
  4394. }
  4395. }, {
  4396. key: "renderView",
  4397. value: function renderView(view) {
  4398. var _this = this;
  4399. switch (view.renderingState) {
  4400. case RenderingStates.FINISHED:
  4401. return false;
  4402. case RenderingStates.PAUSED:
  4403. this.highestPriorityPage = view.renderingId;
  4404. view.resume();
  4405. break;
  4406. case RenderingStates.RUNNING:
  4407. this.highestPriorityPage = view.renderingId;
  4408. break;
  4409. case RenderingStates.INITIAL:
  4410. this.highestPriorityPage = view.renderingId;
  4411. view.draw()["finally"](function () {
  4412. _this.renderHighestPriority();
  4413. })["catch"](function (reason) {
  4414. console.error("renderView: \"".concat(reason, "\""));
  4415. });
  4416. break;
  4417. }
  4418. return true;
  4419. }
  4420. }]);
  4421. return PDFRenderingQueue;
  4422. }();
  4423. exports.PDFRenderingQueue = PDFRenderingQueue;
  4424. /***/ }),
  4425. /* 12 */
  4426. /***/ (function(module, exports, __webpack_require__) {
  4427. "use strict";
  4428. Object.defineProperty(exports, "__esModule", {
  4429. value: true
  4430. });
  4431. exports.PDFSidebar = exports.SidebarView = void 0;
  4432. var _ui_utils = __webpack_require__(5);
  4433. var _pdf_rendering_queue = __webpack_require__(11);
  4434. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4435. 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); } }
  4436. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4437. var UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  4438. var SidebarView = {
  4439. UNKNOWN: -1,
  4440. NONE: 0,
  4441. THUMBS: 1,
  4442. OUTLINE: 2,
  4443. ATTACHMENTS: 3,
  4444. LAYERS: 4
  4445. };
  4446. exports.SidebarView = SidebarView;
  4447. var PDFSidebar = /*#__PURE__*/function () {
  4448. function PDFSidebar(_ref) {
  4449. var elements = _ref.elements,
  4450. pdfViewer = _ref.pdfViewer,
  4451. pdfThumbnailViewer = _ref.pdfThumbnailViewer,
  4452. eventBus = _ref.eventBus,
  4453. _ref$l10n = _ref.l10n,
  4454. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n,
  4455. _ref$disableNotificat = _ref.disableNotification,
  4456. disableNotification = _ref$disableNotificat === void 0 ? false : _ref$disableNotificat;
  4457. _classCallCheck(this, PDFSidebar);
  4458. this.isOpen = false;
  4459. this.active = SidebarView.THUMBS;
  4460. this.isInitialViewSet = false;
  4461. this.onToggled = null;
  4462. this.pdfViewer = pdfViewer;
  4463. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4464. this.outerContainer = elements.outerContainer;
  4465. this.viewerContainer = elements.viewerContainer;
  4466. this.toggleButton = elements.toggleButton;
  4467. this.thumbnailButton = elements.thumbnailButton;
  4468. this.outlineButton = elements.outlineButton;
  4469. this.attachmentsButton = elements.attachmentsButton;
  4470. this.thumbnailView = elements.thumbnailView;
  4471. this.outlineView = elements.outlineView;
  4472. this.attachmentsView = elements.attachmentsView;
  4473. this.eventBus = eventBus;
  4474. this.l10n = l10n;
  4475. this._disableNotification = disableNotification;
  4476. this._addEventListeners();
  4477. }
  4478. _createClass(PDFSidebar, [{
  4479. key: "reset",
  4480. value: function reset() {
  4481. this.isInitialViewSet = false;
  4482. this._hideUINotification(null);
  4483. this.switchView(SidebarView.THUMBS);
  4484. this.outlineButton.disabled = false;
  4485. this.attachmentsButton.disabled = false;
  4486. }
  4487. }, {
  4488. key: "setInitialView",
  4489. value: function setInitialView() {
  4490. var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE;
  4491. if (this.isInitialViewSet) {
  4492. return;
  4493. }
  4494. this.isInitialViewSet = true;
  4495. if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
  4496. this._dispatchEvent();
  4497. return;
  4498. }
  4499. if (!this._switchView(view, true)) {
  4500. this._dispatchEvent();
  4501. }
  4502. }
  4503. }, {
  4504. key: "switchView",
  4505. value: function switchView(view) {
  4506. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4507. this._switchView(view, forceOpen);
  4508. }
  4509. }, {
  4510. key: "_switchView",
  4511. value: function _switchView(view) {
  4512. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4513. var isViewChanged = view !== this.active;
  4514. var shouldForceRendering = false;
  4515. switch (view) {
  4516. case SidebarView.NONE:
  4517. if (this.isOpen) {
  4518. this.close();
  4519. return true;
  4520. }
  4521. return false;
  4522. case SidebarView.THUMBS:
  4523. if (this.isOpen && isViewChanged) {
  4524. shouldForceRendering = true;
  4525. }
  4526. break;
  4527. case SidebarView.OUTLINE:
  4528. if (this.outlineButton.disabled) {
  4529. return false;
  4530. }
  4531. break;
  4532. case SidebarView.ATTACHMENTS:
  4533. if (this.attachmentsButton.disabled) {
  4534. return false;
  4535. }
  4536. break;
  4537. default:
  4538. console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
  4539. return false;
  4540. }
  4541. this.active = view;
  4542. this.thumbnailButton.classList.toggle("toggled", view === SidebarView.THUMBS);
  4543. this.outlineButton.classList.toggle("toggled", view === SidebarView.OUTLINE);
  4544. this.attachmentsButton.classList.toggle("toggled", view === SidebarView.ATTACHMENTS);
  4545. this.thumbnailView.classList.toggle("hidden", view !== SidebarView.THUMBS);
  4546. this.outlineView.classList.toggle("hidden", view !== SidebarView.OUTLINE);
  4547. this.attachmentsView.classList.toggle("hidden", view !== SidebarView.ATTACHMENTS);
  4548. if (forceOpen && !this.isOpen) {
  4549. this.open();
  4550. return true;
  4551. }
  4552. if (shouldForceRendering) {
  4553. this._updateThumbnailViewer();
  4554. this._forceRendering();
  4555. }
  4556. if (isViewChanged) {
  4557. this._dispatchEvent();
  4558. }
  4559. this._hideUINotification(this.active);
  4560. return isViewChanged;
  4561. }
  4562. }, {
  4563. key: "open",
  4564. value: function open() {
  4565. if (this.isOpen) {
  4566. return;
  4567. }
  4568. this.isOpen = true;
  4569. this.toggleButton.classList.add("toggled");
  4570. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  4571. if (this.active === SidebarView.THUMBS) {
  4572. this._updateThumbnailViewer();
  4573. }
  4574. this._forceRendering();
  4575. this._dispatchEvent();
  4576. this._hideUINotification(this.active);
  4577. }
  4578. }, {
  4579. key: "close",
  4580. value: function close() {
  4581. if (!this.isOpen) {
  4582. return;
  4583. }
  4584. this.isOpen = false;
  4585. this.toggleButton.classList.remove("toggled");
  4586. this.outerContainer.classList.add("sidebarMoving");
  4587. this.outerContainer.classList.remove("sidebarOpen");
  4588. this._forceRendering();
  4589. this._dispatchEvent();
  4590. }
  4591. }, {
  4592. key: "toggle",
  4593. value: function toggle() {
  4594. if (this.isOpen) {
  4595. this.close();
  4596. } else {
  4597. this.open();
  4598. }
  4599. }
  4600. }, {
  4601. key: "_dispatchEvent",
  4602. value: function _dispatchEvent() {
  4603. this.eventBus.dispatch("sidebarviewchanged", {
  4604. source: this,
  4605. view: this.visibleView
  4606. });
  4607. }
  4608. }, {
  4609. key: "_forceRendering",
  4610. value: function _forceRendering() {
  4611. if (this.onToggled) {
  4612. this.onToggled();
  4613. } else {
  4614. this.pdfViewer.forceRendering();
  4615. this.pdfThumbnailViewer.forceRendering();
  4616. }
  4617. }
  4618. }, {
  4619. key: "_updateThumbnailViewer",
  4620. value: function _updateThumbnailViewer() {
  4621. var pdfViewer = this.pdfViewer,
  4622. pdfThumbnailViewer = this.pdfThumbnailViewer;
  4623. var pagesCount = pdfViewer.pagesCount;
  4624. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  4625. var pageView = pdfViewer.getPageView(pageIndex);
  4626. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  4627. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  4628. thumbnailView.setImage(pageView);
  4629. }
  4630. }
  4631. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  4632. }
  4633. }, {
  4634. key: "_showUINotification",
  4635. value: function _showUINotification(view) {
  4636. var _this = this;
  4637. if (this._disableNotification) {
  4638. return;
  4639. }
  4640. this.l10n.get("toggle_sidebar_notification.title", null, "Toggle Sidebar (document contains outline/attachments)").then(function (msg) {
  4641. _this.toggleButton.title = msg;
  4642. });
  4643. if (!this.isOpen) {
  4644. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  4645. } else if (view === this.active) {
  4646. return;
  4647. }
  4648. switch (view) {
  4649. case SidebarView.OUTLINE:
  4650. this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
  4651. break;
  4652. case SidebarView.ATTACHMENTS:
  4653. this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
  4654. break;
  4655. }
  4656. }
  4657. }, {
  4658. key: "_hideUINotification",
  4659. value: function _hideUINotification(view) {
  4660. var _this2 = this;
  4661. if (this._disableNotification) {
  4662. return;
  4663. }
  4664. var removeNotification = function removeNotification(sidebarView) {
  4665. switch (sidebarView) {
  4666. case SidebarView.OUTLINE:
  4667. _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
  4668. break;
  4669. case SidebarView.ATTACHMENTS:
  4670. _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
  4671. break;
  4672. }
  4673. };
  4674. if (!this.isOpen && view !== null) {
  4675. return;
  4676. }
  4677. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  4678. if (view !== null) {
  4679. removeNotification(view);
  4680. return;
  4681. }
  4682. for (view in SidebarView) {
  4683. removeNotification(SidebarView[view]);
  4684. }
  4685. this.l10n.get("toggle_sidebar.title", null, "Toggle Sidebar").then(function (msg) {
  4686. _this2.toggleButton.title = msg;
  4687. });
  4688. }
  4689. }, {
  4690. key: "_addEventListeners",
  4691. value: function _addEventListeners() {
  4692. var _this3 = this;
  4693. this.viewerContainer.addEventListener("transitionend", function (evt) {
  4694. if (evt.target === _this3.viewerContainer) {
  4695. _this3.outerContainer.classList.remove("sidebarMoving");
  4696. }
  4697. });
  4698. this.toggleButton.addEventListener("click", function () {
  4699. _this3.toggle();
  4700. });
  4701. this.thumbnailButton.addEventListener("click", function () {
  4702. _this3.switchView(SidebarView.THUMBS);
  4703. });
  4704. this.outlineButton.addEventListener("click", function () {
  4705. _this3.switchView(SidebarView.OUTLINE);
  4706. });
  4707. this.outlineButton.addEventListener("dblclick", function () {
  4708. _this3.eventBus.dispatch("toggleoutlinetree", {
  4709. source: _this3
  4710. });
  4711. });
  4712. this.attachmentsButton.addEventListener("click", function () {
  4713. _this3.switchView(SidebarView.ATTACHMENTS);
  4714. });
  4715. this.eventBus._on("outlineloaded", function (evt) {
  4716. var outlineCount = evt.outlineCount;
  4717. _this3.outlineButton.disabled = !outlineCount;
  4718. if (outlineCount) {
  4719. _this3._showUINotification(SidebarView.OUTLINE);
  4720. } else if (_this3.active === SidebarView.OUTLINE) {
  4721. _this3.switchView(SidebarView.THUMBS);
  4722. }
  4723. });
  4724. this.eventBus._on("attachmentsloaded", function (evt) {
  4725. if (evt.attachmentsCount) {
  4726. _this3.attachmentsButton.disabled = false;
  4727. _this3._showUINotification(SidebarView.ATTACHMENTS);
  4728. return;
  4729. }
  4730. Promise.resolve().then(function () {
  4731. if (_this3.attachmentsView.hasChildNodes()) {
  4732. return;
  4733. }
  4734. _this3.attachmentsButton.disabled = true;
  4735. if (_this3.active === SidebarView.ATTACHMENTS) {
  4736. _this3.switchView(SidebarView.THUMBS);
  4737. }
  4738. });
  4739. });
  4740. this.eventBus._on("presentationmodechanged", function (evt) {
  4741. if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
  4742. _this3._updateThumbnailViewer();
  4743. }
  4744. });
  4745. }
  4746. }, {
  4747. key: "visibleView",
  4748. get: function get() {
  4749. return this.isOpen ? this.active : SidebarView.NONE;
  4750. }
  4751. }, {
  4752. key: "isThumbnailViewVisible",
  4753. get: function get() {
  4754. return this.isOpen && this.active === SidebarView.THUMBS;
  4755. }
  4756. }, {
  4757. key: "isOutlineViewVisible",
  4758. get: function get() {
  4759. return this.isOpen && this.active === SidebarView.OUTLINE;
  4760. }
  4761. }, {
  4762. key: "isAttachmentsViewVisible",
  4763. get: function get() {
  4764. return this.isOpen && this.active === SidebarView.ATTACHMENTS;
  4765. }
  4766. }]);
  4767. return PDFSidebar;
  4768. }();
  4769. exports.PDFSidebar = PDFSidebar;
  4770. /***/ }),
  4771. /* 13 */
  4772. /***/ (function(module, exports, __webpack_require__) {
  4773. "use strict";
  4774. Object.defineProperty(exports, "__esModule", {
  4775. value: true
  4776. });
  4777. exports.OverlayManager = void 0;
  4778. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  4779. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4780. 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); } }
  4781. 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); }); }; }
  4782. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4783. 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); } }
  4784. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4785. var OverlayManager = /*#__PURE__*/function () {
  4786. function OverlayManager() {
  4787. _classCallCheck(this, OverlayManager);
  4788. this._overlays = {};
  4789. this._active = null;
  4790. this._keyDownBound = this._keyDown.bind(this);
  4791. }
  4792. _createClass(OverlayManager, [{
  4793. key: "register",
  4794. value: function () {
  4795. var _register = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, element) {
  4796. var callerCloseMethod,
  4797. canForceClose,
  4798. container,
  4799. _args = arguments;
  4800. return _regenerator["default"].wrap(function _callee$(_context) {
  4801. while (1) {
  4802. switch (_context.prev = _context.next) {
  4803. case 0:
  4804. callerCloseMethod = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
  4805. canForceClose = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
  4806. if (!(!name || !element || !(container = element.parentNode))) {
  4807. _context.next = 6;
  4808. break;
  4809. }
  4810. throw new Error("Not enough parameters.");
  4811. case 6:
  4812. if (!this._overlays[name]) {
  4813. _context.next = 8;
  4814. break;
  4815. }
  4816. throw new Error("The overlay is already registered.");
  4817. case 8:
  4818. this._overlays[name] = {
  4819. element: element,
  4820. container: container,
  4821. callerCloseMethod: callerCloseMethod,
  4822. canForceClose: canForceClose
  4823. };
  4824. case 9:
  4825. case "end":
  4826. return _context.stop();
  4827. }
  4828. }
  4829. }, _callee, this);
  4830. }));
  4831. function register(_x, _x2) {
  4832. return _register.apply(this, arguments);
  4833. }
  4834. return register;
  4835. }()
  4836. }, {
  4837. key: "unregister",
  4838. value: function () {
  4839. var _unregister = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(name) {
  4840. return _regenerator["default"].wrap(function _callee2$(_context2) {
  4841. while (1) {
  4842. switch (_context2.prev = _context2.next) {
  4843. case 0:
  4844. if (this._overlays[name]) {
  4845. _context2.next = 4;
  4846. break;
  4847. }
  4848. throw new Error("The overlay does not exist.");
  4849. case 4:
  4850. if (!(this._active === name)) {
  4851. _context2.next = 6;
  4852. break;
  4853. }
  4854. throw new Error("The overlay cannot be removed while it is active.");
  4855. case 6:
  4856. delete this._overlays[name];
  4857. case 7:
  4858. case "end":
  4859. return _context2.stop();
  4860. }
  4861. }
  4862. }, _callee2, this);
  4863. }));
  4864. function unregister(_x3) {
  4865. return _unregister.apply(this, arguments);
  4866. }
  4867. return unregister;
  4868. }()
  4869. }, {
  4870. key: "open",
  4871. value: function () {
  4872. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name) {
  4873. return _regenerator["default"].wrap(function _callee3$(_context3) {
  4874. while (1) {
  4875. switch (_context3.prev = _context3.next) {
  4876. case 0:
  4877. if (this._overlays[name]) {
  4878. _context3.next = 4;
  4879. break;
  4880. }
  4881. throw new Error("The overlay does not exist.");
  4882. case 4:
  4883. if (!this._active) {
  4884. _context3.next = 14;
  4885. break;
  4886. }
  4887. if (!this._overlays[name].canForceClose) {
  4888. _context3.next = 9;
  4889. break;
  4890. }
  4891. this._closeThroughCaller();
  4892. _context3.next = 14;
  4893. break;
  4894. case 9:
  4895. if (!(this._active === name)) {
  4896. _context3.next = 13;
  4897. break;
  4898. }
  4899. throw new Error("The overlay is already active.");
  4900. case 13:
  4901. throw new Error("Another overlay is currently active.");
  4902. case 14:
  4903. this._active = name;
  4904. this._overlays[this._active].element.classList.remove("hidden");
  4905. this._overlays[this._active].container.classList.remove("hidden");
  4906. window.addEventListener("keydown", this._keyDownBound);
  4907. case 18:
  4908. case "end":
  4909. return _context3.stop();
  4910. }
  4911. }
  4912. }, _callee3, this);
  4913. }));
  4914. function open(_x4) {
  4915. return _open.apply(this, arguments);
  4916. }
  4917. return open;
  4918. }()
  4919. }, {
  4920. key: "close",
  4921. value: function () {
  4922. var _close = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name) {
  4923. return _regenerator["default"].wrap(function _callee4$(_context4) {
  4924. while (1) {
  4925. switch (_context4.prev = _context4.next) {
  4926. case 0:
  4927. if (this._overlays[name]) {
  4928. _context4.next = 4;
  4929. break;
  4930. }
  4931. throw new Error("The overlay does not exist.");
  4932. case 4:
  4933. if (this._active) {
  4934. _context4.next = 8;
  4935. break;
  4936. }
  4937. throw new Error("The overlay is currently not active.");
  4938. case 8:
  4939. if (!(this._active !== name)) {
  4940. _context4.next = 10;
  4941. break;
  4942. }
  4943. throw new Error("Another overlay is currently active.");
  4944. case 10:
  4945. this._overlays[this._active].container.classList.add("hidden");
  4946. this._overlays[this._active].element.classList.add("hidden");
  4947. this._active = null;
  4948. window.removeEventListener("keydown", this._keyDownBound);
  4949. case 14:
  4950. case "end":
  4951. return _context4.stop();
  4952. }
  4953. }
  4954. }, _callee4, this);
  4955. }));
  4956. function close(_x5) {
  4957. return _close.apply(this, arguments);
  4958. }
  4959. return close;
  4960. }()
  4961. }, {
  4962. key: "_keyDown",
  4963. value: function _keyDown(evt) {
  4964. if (this._active && evt.keyCode === 27) {
  4965. this._closeThroughCaller();
  4966. evt.preventDefault();
  4967. }
  4968. }
  4969. }, {
  4970. key: "_closeThroughCaller",
  4971. value: function _closeThroughCaller() {
  4972. if (this._overlays[this._active].callerCloseMethod) {
  4973. this._overlays[this._active].callerCloseMethod();
  4974. }
  4975. if (this._active) {
  4976. this.close(this._active);
  4977. }
  4978. }
  4979. }, {
  4980. key: "active",
  4981. get: function get() {
  4982. return this._active;
  4983. }
  4984. }]);
  4985. return OverlayManager;
  4986. }();
  4987. exports.OverlayManager = OverlayManager;
  4988. /***/ }),
  4989. /* 14 */
  4990. /***/ (function(module, exports, __webpack_require__) {
  4991. "use strict";
  4992. Object.defineProperty(exports, "__esModule", {
  4993. value: true
  4994. });
  4995. exports.PasswordPrompt = void 0;
  4996. var _ui_utils = __webpack_require__(5);
  4997. var _pdfjsLib = __webpack_require__(8);
  4998. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4999. 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); } }
  5000. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5001. var PasswordPrompt = /*#__PURE__*/function () {
  5002. function PasswordPrompt(options, overlayManager) {
  5003. var _this = this;
  5004. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5005. _classCallCheck(this, PasswordPrompt);
  5006. this.overlayName = options.overlayName;
  5007. this.container = options.container;
  5008. this.label = options.label;
  5009. this.input = options.input;
  5010. this.submitButton = options.submitButton;
  5011. this.cancelButton = options.cancelButton;
  5012. this.overlayManager = overlayManager;
  5013. this.l10n = l10n;
  5014. this.updateCallback = null;
  5015. this.reason = null;
  5016. this.submitButton.addEventListener("click", this.verify.bind(this));
  5017. this.cancelButton.addEventListener("click", this.close.bind(this));
  5018. this.input.addEventListener("keydown", function (e) {
  5019. if (e.keyCode === 13) {
  5020. _this.verify();
  5021. }
  5022. });
  5023. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  5024. }
  5025. _createClass(PasswordPrompt, [{
  5026. key: "open",
  5027. value: function open() {
  5028. var _this2 = this;
  5029. this.overlayManager.open(this.overlayName).then(function () {
  5030. _this2.input.focus();
  5031. var promptString;
  5032. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  5033. promptString = _this2.l10n.get("password_invalid", null, "Invalid password. Please try again.");
  5034. } else {
  5035. promptString = _this2.l10n.get("password_label", null, "Enter the password to open this PDF file.");
  5036. }
  5037. promptString.then(function (msg) {
  5038. _this2.label.textContent = msg;
  5039. });
  5040. });
  5041. }
  5042. }, {
  5043. key: "close",
  5044. value: function close() {
  5045. var _this3 = this;
  5046. this.overlayManager.close(this.overlayName).then(function () {
  5047. _this3.input.value = "";
  5048. });
  5049. }
  5050. }, {
  5051. key: "verify",
  5052. value: function verify() {
  5053. var password = this.input.value;
  5054. if (password && password.length > 0) {
  5055. this.close();
  5056. this.updateCallback(password);
  5057. }
  5058. }
  5059. }, {
  5060. key: "setUpdateCallback",
  5061. value: function setUpdateCallback(updateCallback, reason) {
  5062. this.updateCallback = updateCallback;
  5063. this.reason = reason;
  5064. }
  5065. }]);
  5066. return PasswordPrompt;
  5067. }();
  5068. exports.PasswordPrompt = PasswordPrompt;
  5069. /***/ }),
  5070. /* 15 */
  5071. /***/ (function(module, exports, __webpack_require__) {
  5072. "use strict";
  5073. Object.defineProperty(exports, "__esModule", {
  5074. value: true
  5075. });
  5076. exports.PDFAttachmentViewer = void 0;
  5077. var _pdfjsLib = __webpack_require__(8);
  5078. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5079. 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); } }
  5080. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5081. var PDFAttachmentViewer = /*#__PURE__*/function () {
  5082. function PDFAttachmentViewer(_ref) {
  5083. var container = _ref.container,
  5084. eventBus = _ref.eventBus,
  5085. downloadManager = _ref.downloadManager;
  5086. _classCallCheck(this, PDFAttachmentViewer);
  5087. this.container = container;
  5088. this.eventBus = eventBus;
  5089. this.downloadManager = downloadManager;
  5090. this.reset();
  5091. this.eventBus._on("fileattachmentannotation", this._appendAttachment.bind(this));
  5092. }
  5093. _createClass(PDFAttachmentViewer, [{
  5094. key: "reset",
  5095. value: function reset() {
  5096. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5097. this.attachments = null;
  5098. this.container.textContent = "";
  5099. if (!keepRenderedCapability) {
  5100. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  5101. }
  5102. }
  5103. }, {
  5104. key: "_dispatchEvent",
  5105. value: function _dispatchEvent(attachmentsCount) {
  5106. this._renderedCapability.resolve();
  5107. this.eventBus.dispatch("attachmentsloaded", {
  5108. source: this,
  5109. attachmentsCount: attachmentsCount
  5110. });
  5111. }
  5112. }, {
  5113. key: "_bindPdfLink",
  5114. value: function _bindPdfLink(button, content, filename) {
  5115. var _this = this;
  5116. var blobUrl;
  5117. button.onclick = function () {
  5118. if (!blobUrl) {
  5119. blobUrl = URL.createObjectURL(new Blob([content], {
  5120. type: "application/pdf"
  5121. }));
  5122. }
  5123. var viewerUrl;
  5124. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  5125. try {
  5126. window.open(viewerUrl);
  5127. } catch (ex) {
  5128. console.error("_bindPdfLink: ".concat(ex));
  5129. URL.revokeObjectURL(blobUrl);
  5130. blobUrl = null;
  5131. _this.downloadManager.downloadData(content, filename, "application/pdf");
  5132. }
  5133. return false;
  5134. };
  5135. }
  5136. }, {
  5137. key: "_bindLink",
  5138. value: function _bindLink(button, content, filename) {
  5139. var _this2 = this;
  5140. button.onclick = function () {
  5141. _this2.downloadManager.downloadData(content, filename, "");
  5142. return false;
  5143. };
  5144. }
  5145. }, {
  5146. key: "render",
  5147. value: function render(_ref2) {
  5148. var attachments = _ref2.attachments,
  5149. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  5150. keepRenderedCapability = _ref2$keepRenderedCap === void 0 ? false : _ref2$keepRenderedCap;
  5151. var attachmentsCount = 0;
  5152. if (this.attachments) {
  5153. this.reset(keepRenderedCapability === true);
  5154. }
  5155. this.attachments = attachments || null;
  5156. if (!attachments) {
  5157. this._dispatchEvent(attachmentsCount);
  5158. return;
  5159. }
  5160. var names = Object.keys(attachments).sort(function (a, b) {
  5161. return a.toLowerCase().localeCompare(b.toLowerCase());
  5162. });
  5163. attachmentsCount = names.length;
  5164. for (var i = 0; i < attachmentsCount; i++) {
  5165. var item = attachments[names[i]];
  5166. var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib.getFilenameFromUrl)(item.filename));
  5167. var div = document.createElement("div");
  5168. div.className = "attachmentsItem";
  5169. var button = document.createElement("button");
  5170. button.textContent = filename;
  5171. if (/\.pdf$/i.test(filename) && !this.downloadManager.disableCreateObjectURL) {
  5172. this._bindPdfLink(button, item.content, filename);
  5173. } else {
  5174. this._bindLink(button, item.content, filename);
  5175. }
  5176. div.appendChild(button);
  5177. this.container.appendChild(div);
  5178. }
  5179. this._dispatchEvent(attachmentsCount);
  5180. }
  5181. }, {
  5182. key: "_appendAttachment",
  5183. value: function _appendAttachment(_ref3) {
  5184. var _this3 = this;
  5185. var id = _ref3.id,
  5186. filename = _ref3.filename,
  5187. content = _ref3.content;
  5188. this._renderedCapability.promise.then(function () {
  5189. var attachments = _this3.attachments;
  5190. if (!attachments) {
  5191. attachments = Object.create(null);
  5192. } else {
  5193. for (var name in attachments) {
  5194. if (id === name) {
  5195. return;
  5196. }
  5197. }
  5198. }
  5199. attachments[id] = {
  5200. filename: filename,
  5201. content: content
  5202. };
  5203. _this3.render({
  5204. attachments: attachments,
  5205. keepRenderedCapability: true
  5206. });
  5207. });
  5208. }
  5209. }]);
  5210. return PDFAttachmentViewer;
  5211. }();
  5212. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  5213. /***/ }),
  5214. /* 16 */
  5215. /***/ (function(module, exports, __webpack_require__) {
  5216. "use strict";
  5217. Object.defineProperty(exports, "__esModule", {
  5218. value: true
  5219. });
  5220. exports.PDFDocumentProperties = void 0;
  5221. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  5222. var _pdfjsLib = __webpack_require__(8);
  5223. var _ui_utils = __webpack_require__(5);
  5224. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5225. 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); } }
  5226. 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); }); }; }
  5227. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  5228. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  5229. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  5230. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5231. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  5232. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  5233. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5234. 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); } }
  5235. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5236. var DEFAULT_FIELD_CONTENT = "-";
  5237. var NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  5238. var US_PAGE_NAMES = {
  5239. "8.5x11": "Letter",
  5240. "8.5x14": "Legal"
  5241. };
  5242. var METRIC_PAGE_NAMES = {
  5243. "297x420": "A3",
  5244. "210x297": "A4"
  5245. };
  5246. function getPageName(size, isPortrait, pageNames) {
  5247. var width = isPortrait ? size.width : size.height;
  5248. var height = isPortrait ? size.height : size.width;
  5249. return pageNames["".concat(width, "x").concat(height)];
  5250. }
  5251. var PDFDocumentProperties = /*#__PURE__*/function () {
  5252. function PDFDocumentProperties(_ref, overlayManager, eventBus) {
  5253. var _this = this;
  5254. var overlayName = _ref.overlayName,
  5255. fields = _ref.fields,
  5256. container = _ref.container,
  5257. closeButton = _ref.closeButton;
  5258. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  5259. _classCallCheck(this, PDFDocumentProperties);
  5260. this.overlayName = overlayName;
  5261. this.fields = fields;
  5262. this.container = container;
  5263. this.overlayManager = overlayManager;
  5264. this.l10n = l10n;
  5265. this._reset();
  5266. closeButton.addEventListener("click", this.close.bind(this));
  5267. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  5268. eventBus._on("pagechanging", function (evt) {
  5269. _this._currentPageNumber = evt.pageNumber;
  5270. });
  5271. eventBus._on("rotationchanging", function (evt) {
  5272. _this._pagesRotation = evt.pagesRotation;
  5273. });
  5274. this._isNonMetricLocale = true;
  5275. l10n.getLanguage().then(function (locale) {
  5276. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  5277. });
  5278. }
  5279. _createClass(PDFDocumentProperties, [{
  5280. key: "open",
  5281. value: function open() {
  5282. var _this2 = this;
  5283. var freezeFieldData = function freezeFieldData(data) {
  5284. Object.defineProperty(_this2, "fieldData", {
  5285. value: Object.freeze(data),
  5286. writable: false,
  5287. enumerable: true,
  5288. configurable: true
  5289. });
  5290. };
  5291. Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
  5292. var currentPageNumber = _this2._currentPageNumber;
  5293. var pagesRotation = _this2._pagesRotation;
  5294. if (_this2.fieldData && currentPageNumber === _this2.fieldData._currentPageNumber && pagesRotation === _this2.fieldData._pagesRotation) {
  5295. _this2._updateUI();
  5296. return;
  5297. }
  5298. _this2.pdfDocument.getMetadata().then(function (_ref2) {
  5299. var info = _ref2.info,
  5300. metadata = _ref2.metadata,
  5301. contentDispositionFilename = _ref2.contentDispositionFilename;
  5302. 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) {
  5303. return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  5304. }), _this2._parseLinearization(info.IsLinearized)]);
  5305. }).then(function (_ref3) {
  5306. var _ref4 = _slicedToArray(_ref3, 8),
  5307. info = _ref4[0],
  5308. metadata = _ref4[1],
  5309. fileName = _ref4[2],
  5310. fileSize = _ref4[3],
  5311. creationDate = _ref4[4],
  5312. modDate = _ref4[5],
  5313. pageSize = _ref4[6],
  5314. isLinearized = _ref4[7];
  5315. freezeFieldData({
  5316. fileName: fileName,
  5317. fileSize: fileSize,
  5318. title: info.Title,
  5319. author: info.Author,
  5320. subject: info.Subject,
  5321. keywords: info.Keywords,
  5322. creationDate: creationDate,
  5323. modificationDate: modDate,
  5324. creator: info.Creator,
  5325. producer: info.Producer,
  5326. version: info.PDFFormatVersion,
  5327. pageCount: _this2.pdfDocument.numPages,
  5328. pageSize: pageSize,
  5329. linearized: isLinearized,
  5330. _currentPageNumber: currentPageNumber,
  5331. _pagesRotation: pagesRotation
  5332. });
  5333. _this2._updateUI();
  5334. return _this2.pdfDocument.getDownloadInfo();
  5335. }).then(function (_ref5) {
  5336. var length = _ref5.length;
  5337. _this2.maybeFileSize = length;
  5338. return _this2._parseFileSize(length);
  5339. }).then(function (fileSize) {
  5340. if (fileSize === _this2.fieldData.fileSize) {
  5341. return;
  5342. }
  5343. var data = Object.assign(Object.create(null), _this2.fieldData);
  5344. data.fileSize = fileSize;
  5345. freezeFieldData(data);
  5346. _this2._updateUI();
  5347. });
  5348. });
  5349. }
  5350. }, {
  5351. key: "close",
  5352. value: function close() {
  5353. this.overlayManager.close(this.overlayName);
  5354. }
  5355. }, {
  5356. key: "setDocument",
  5357. value: function setDocument(pdfDocument) {
  5358. var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5359. if (this.pdfDocument) {
  5360. this._reset();
  5361. this._updateUI(true);
  5362. }
  5363. if (!pdfDocument) {
  5364. return;
  5365. }
  5366. this.pdfDocument = pdfDocument;
  5367. this.url = url;
  5368. this._dataAvailableCapability.resolve();
  5369. }
  5370. }, {
  5371. key: "setFileSize",
  5372. value: function setFileSize(fileSize) {
  5373. if (Number.isInteger(fileSize) && fileSize > 0) {
  5374. this.maybeFileSize = fileSize;
  5375. }
  5376. }
  5377. }, {
  5378. key: "_reset",
  5379. value: function _reset() {
  5380. this.pdfDocument = null;
  5381. this.url = null;
  5382. this.maybeFileSize = 0;
  5383. delete this.fieldData;
  5384. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5385. this._currentPageNumber = 1;
  5386. this._pagesRotation = 0;
  5387. }
  5388. }, {
  5389. key: "_updateUI",
  5390. value: function _updateUI() {
  5391. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5392. if (reset || !this.fieldData) {
  5393. for (var id in this.fields) {
  5394. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5395. }
  5396. return;
  5397. }
  5398. if (this.overlayManager.active !== this.overlayName) {
  5399. return;
  5400. }
  5401. for (var _id in this.fields) {
  5402. var content = this.fieldData[_id];
  5403. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5404. }
  5405. }
  5406. }, {
  5407. key: "_parseFileSize",
  5408. value: function () {
  5409. var _parseFileSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  5410. var fileSize,
  5411. kb,
  5412. _args = arguments;
  5413. return _regenerator["default"].wrap(function _callee$(_context) {
  5414. while (1) {
  5415. switch (_context.prev = _context.next) {
  5416. case 0:
  5417. fileSize = _args.length > 0 && _args[0] !== undefined ? _args[0] : 0;
  5418. kb = fileSize / 1024;
  5419. if (kb) {
  5420. _context.next = 6;
  5421. break;
  5422. }
  5423. return _context.abrupt("return", undefined);
  5424. case 6:
  5425. if (!(kb < 1024)) {
  5426. _context.next = 8;
  5427. break;
  5428. }
  5429. return _context.abrupt("return", this.l10n.get("document_properties_kb", {
  5430. size_kb: (+kb.toPrecision(3)).toLocaleString(),
  5431. size_b: fileSize.toLocaleString()
  5432. }, "{{size_kb}} KB ({{size_b}} bytes)"));
  5433. case 8:
  5434. return _context.abrupt("return", this.l10n.get("document_properties_mb", {
  5435. size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
  5436. size_b: fileSize.toLocaleString()
  5437. }, "{{size_mb}} MB ({{size_b}} bytes)"));
  5438. case 9:
  5439. case "end":
  5440. return _context.stop();
  5441. }
  5442. }
  5443. }, _callee, this);
  5444. }));
  5445. function _parseFileSize() {
  5446. return _parseFileSize2.apply(this, arguments);
  5447. }
  5448. return _parseFileSize;
  5449. }()
  5450. }, {
  5451. key: "_parsePageSize",
  5452. value: function () {
  5453. var _parsePageSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pageSizeInches, pagesRotation) {
  5454. var _this3 = this;
  5455. var isPortrait, sizeInches, sizeMillimeters, pageName, rawName, exactMillimeters, intMillimeters;
  5456. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5457. while (1) {
  5458. switch (_context2.prev = _context2.next) {
  5459. case 0:
  5460. if (pageSizeInches) {
  5461. _context2.next = 2;
  5462. break;
  5463. }
  5464. return _context2.abrupt("return", undefined);
  5465. case 2:
  5466. if (pagesRotation % 180 !== 0) {
  5467. pageSizeInches = {
  5468. width: pageSizeInches.height,
  5469. height: pageSizeInches.width
  5470. };
  5471. }
  5472. isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  5473. sizeInches = {
  5474. width: Math.round(pageSizeInches.width * 100) / 100,
  5475. height: Math.round(pageSizeInches.height * 100) / 100
  5476. };
  5477. sizeMillimeters = {
  5478. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  5479. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  5480. };
  5481. pageName = null;
  5482. rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5483. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  5484. exactMillimeters = {
  5485. width: pageSizeInches.width * 25.4,
  5486. height: pageSizeInches.height * 25.4
  5487. };
  5488. intMillimeters = {
  5489. width: Math.round(sizeMillimeters.width),
  5490. height: Math.round(sizeMillimeters.height)
  5491. };
  5492. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  5493. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5494. if (rawName) {
  5495. sizeInches = {
  5496. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  5497. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  5498. };
  5499. sizeMillimeters = intMillimeters;
  5500. }
  5501. }
  5502. }
  5503. if (rawName) {
  5504. pageName = this.l10n.get("document_properties_page_size_name_" + rawName.toLowerCase(), null, rawName);
  5505. }
  5506. 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) {
  5507. var _ref7 = _slicedToArray(_ref6, 4),
  5508. _ref7$ = _ref7[0],
  5509. width = _ref7$.width,
  5510. height = _ref7$.height,
  5511. unit = _ref7[1],
  5512. name = _ref7[2],
  5513. orientation = _ref7[3];
  5514. return _this3.l10n.get("document_properties_page_size_dimension_" + (name ? "name_" : "") + "string", {
  5515. width: width.toLocaleString(),
  5516. height: height.toLocaleString(),
  5517. unit: unit,
  5518. name: name,
  5519. orientation: orientation
  5520. }, "{{width}} × {{height}} {{unit}} (" + (name ? "{{name}}, " : "") + "{{orientation}})");
  5521. }));
  5522. case 11:
  5523. case "end":
  5524. return _context2.stop();
  5525. }
  5526. }
  5527. }, _callee2, this);
  5528. }));
  5529. function _parsePageSize(_x, _x2) {
  5530. return _parsePageSize2.apply(this, arguments);
  5531. }
  5532. return _parsePageSize;
  5533. }()
  5534. }, {
  5535. key: "_parseDate",
  5536. value: function () {
  5537. var _parseDate2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(inputDate) {
  5538. var dateObject;
  5539. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5540. while (1) {
  5541. switch (_context3.prev = _context3.next) {
  5542. case 0:
  5543. dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  5544. if (dateObject) {
  5545. _context3.next = 3;
  5546. break;
  5547. }
  5548. return _context3.abrupt("return", undefined);
  5549. case 3:
  5550. return _context3.abrupt("return", this.l10n.get("document_properties_date_string", {
  5551. date: dateObject.toLocaleDateString(),
  5552. time: dateObject.toLocaleTimeString()
  5553. }, "{{date}}, {{time}}"));
  5554. case 4:
  5555. case "end":
  5556. return _context3.stop();
  5557. }
  5558. }
  5559. }, _callee3, this);
  5560. }));
  5561. function _parseDate(_x3) {
  5562. return _parseDate2.apply(this, arguments);
  5563. }
  5564. return _parseDate;
  5565. }()
  5566. }, {
  5567. key: "_parseLinearization",
  5568. value: function _parseLinearization(isLinearized) {
  5569. return this.l10n.get("document_properties_linearized_" + (isLinearized ? "yes" : "no"), null, isLinearized ? "Yes" : "No");
  5570. }
  5571. }]);
  5572. return PDFDocumentProperties;
  5573. }();
  5574. exports.PDFDocumentProperties = PDFDocumentProperties;
  5575. /***/ }),
  5576. /* 17 */
  5577. /***/ (function(module, exports, __webpack_require__) {
  5578. "use strict";
  5579. Object.defineProperty(exports, "__esModule", {
  5580. value: true
  5581. });
  5582. exports.PDFFindBar = void 0;
  5583. var _pdf_find_controller = __webpack_require__(18);
  5584. var _ui_utils = __webpack_require__(5);
  5585. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5586. 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); } }
  5587. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5588. var MATCHES_COUNT_LIMIT = 1000;
  5589. var PDFFindBar = /*#__PURE__*/function () {
  5590. function PDFFindBar(options, eventBus) {
  5591. var _this = this;
  5592. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5593. _classCallCheck(this, PDFFindBar);
  5594. this.opened = false;
  5595. this.bar = options.bar || null;
  5596. this.toggleButton = options.toggleButton || null;
  5597. this.findField = options.findField || null;
  5598. this.highlightAll = options.highlightAllCheckbox || null;
  5599. this.caseSensitive = options.caseSensitiveCheckbox || null;
  5600. this.entireWord = options.entireWordCheckbox || null;
  5601. this.findMsg = options.findMsg || null;
  5602. this.findResultsCount = options.findResultsCount || null;
  5603. this.findPreviousButton = options.findPreviousButton || null;
  5604. this.findNextButton = options.findNextButton || null;
  5605. this.eventBus = eventBus;
  5606. this.l10n = l10n;
  5607. this.toggleButton.addEventListener("click", function () {
  5608. _this.toggle();
  5609. });
  5610. this.findField.addEventListener("input", function () {
  5611. _this.dispatchEvent("");
  5612. });
  5613. this.bar.addEventListener("keydown", function (e) {
  5614. switch (e.keyCode) {
  5615. case 13:
  5616. if (e.target === _this.findField) {
  5617. _this.dispatchEvent("again", e.shiftKey);
  5618. }
  5619. break;
  5620. case 27:
  5621. _this.close();
  5622. break;
  5623. }
  5624. });
  5625. this.findPreviousButton.addEventListener("click", function () {
  5626. _this.dispatchEvent("again", true);
  5627. });
  5628. this.findNextButton.addEventListener("click", function () {
  5629. _this.dispatchEvent("again", false);
  5630. });
  5631. this.highlightAll.addEventListener("click", function () {
  5632. _this.dispatchEvent("highlightallchange");
  5633. });
  5634. this.caseSensitive.addEventListener("click", function () {
  5635. _this.dispatchEvent("casesensitivitychange");
  5636. });
  5637. this.entireWord.addEventListener("click", function () {
  5638. _this.dispatchEvent("entirewordchange");
  5639. });
  5640. this.eventBus._on("resize", this._adjustWidth.bind(this));
  5641. }
  5642. _createClass(PDFFindBar, [{
  5643. key: "reset",
  5644. value: function reset() {
  5645. this.updateUIState();
  5646. }
  5647. }, {
  5648. key: "dispatchEvent",
  5649. value: function dispatchEvent(type, findPrev) {
  5650. this.eventBus.dispatch("find", {
  5651. source: this,
  5652. type: type,
  5653. query: this.findField.value,
  5654. phraseSearch: true,
  5655. caseSensitive: this.caseSensitive.checked,
  5656. entireWord: this.entireWord.checked,
  5657. highlightAll: this.highlightAll.checked,
  5658. findPrevious: findPrev
  5659. });
  5660. }
  5661. }, {
  5662. key: "updateUIState",
  5663. value: function updateUIState(state, previous, matchesCount) {
  5664. var _this2 = this;
  5665. var notFound = false;
  5666. var findMsg = "";
  5667. var status = "";
  5668. switch (state) {
  5669. case _pdf_find_controller.FindState.FOUND:
  5670. break;
  5671. case _pdf_find_controller.FindState.PENDING:
  5672. status = "pending";
  5673. break;
  5674. case _pdf_find_controller.FindState.NOT_FOUND:
  5675. findMsg = this.l10n.get("find_not_found", null, "Phrase not found");
  5676. notFound = true;
  5677. break;
  5678. case _pdf_find_controller.FindState.WRAPPED:
  5679. if (previous) {
  5680. findMsg = this.l10n.get("find_reached_top", null, "Reached top of document, continued from bottom");
  5681. } else {
  5682. findMsg = this.l10n.get("find_reached_bottom", null, "Reached end of document, continued from top");
  5683. }
  5684. break;
  5685. }
  5686. this.findField.classList.toggle("notFound", notFound);
  5687. this.findField.setAttribute("data-status", status);
  5688. Promise.resolve(findMsg).then(function (msg) {
  5689. _this2.findMsg.textContent = msg;
  5690. _this2._adjustWidth();
  5691. });
  5692. this.updateResultsCount(matchesCount);
  5693. }
  5694. }, {
  5695. key: "updateResultsCount",
  5696. value: function updateResultsCount() {
  5697. var _this3 = this;
  5698. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  5699. _ref$current = _ref.current,
  5700. current = _ref$current === void 0 ? 0 : _ref$current,
  5701. _ref$total = _ref.total,
  5702. total = _ref$total === void 0 ? 0 : _ref$total;
  5703. if (!this.findResultsCount) {
  5704. return;
  5705. }
  5706. var limit = MATCHES_COUNT_LIMIT;
  5707. var matchesCountMsg = "";
  5708. if (total > 0) {
  5709. if (total > limit) {
  5710. matchesCountMsg = this.l10n.get("find_match_count_limit", {
  5711. limit: limit
  5712. }, "More than {{limit}} match" + (limit !== 1 ? "es" : ""));
  5713. } else {
  5714. matchesCountMsg = this.l10n.get("find_match_count", {
  5715. current: current,
  5716. total: total
  5717. }, "{{current}} of {{total}} match" + (total !== 1 ? "es" : ""));
  5718. }
  5719. }
  5720. Promise.resolve(matchesCountMsg).then(function (msg) {
  5721. _this3.findResultsCount.textContent = msg;
  5722. _this3.findResultsCount.classList.toggle("hidden", !total);
  5723. _this3._adjustWidth();
  5724. });
  5725. }
  5726. }, {
  5727. key: "open",
  5728. value: function open() {
  5729. if (!this.opened) {
  5730. this.opened = true;
  5731. this.toggleButton.classList.add("toggled");
  5732. this.bar.classList.remove("hidden");
  5733. }
  5734. this.findField.select();
  5735. this.findField.focus();
  5736. this._adjustWidth();
  5737. }
  5738. }, {
  5739. key: "close",
  5740. value: function close() {
  5741. if (!this.opened) {
  5742. return;
  5743. }
  5744. this.opened = false;
  5745. this.toggleButton.classList.remove("toggled");
  5746. this.bar.classList.add("hidden");
  5747. this.eventBus.dispatch("findbarclose", {
  5748. source: this
  5749. });
  5750. }
  5751. }, {
  5752. key: "toggle",
  5753. value: function toggle() {
  5754. if (this.opened) {
  5755. this.close();
  5756. } else {
  5757. this.open();
  5758. }
  5759. }
  5760. }, {
  5761. key: "_adjustWidth",
  5762. value: function _adjustWidth() {
  5763. if (!this.opened) {
  5764. return;
  5765. }
  5766. this.bar.classList.remove("wrapContainers");
  5767. var findbarHeight = this.bar.clientHeight;
  5768. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  5769. if (findbarHeight > inputContainerHeight) {
  5770. this.bar.classList.add("wrapContainers");
  5771. }
  5772. }
  5773. }]);
  5774. return PDFFindBar;
  5775. }();
  5776. exports.PDFFindBar = PDFFindBar;
  5777. /***/ }),
  5778. /* 18 */
  5779. /***/ (function(module, exports, __webpack_require__) {
  5780. "use strict";
  5781. Object.defineProperty(exports, "__esModule", {
  5782. value: true
  5783. });
  5784. exports.PDFFindController = exports.FindState = void 0;
  5785. var _pdfjsLib = __webpack_require__(8);
  5786. var _pdf_find_utils = __webpack_require__(19);
  5787. var _ui_utils = __webpack_require__(5);
  5788. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5789. 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); } }
  5790. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5791. var FindState = {
  5792. FOUND: 0,
  5793. NOT_FOUND: 1,
  5794. WRAPPED: 2,
  5795. PENDING: 3
  5796. };
  5797. exports.FindState = FindState;
  5798. var FIND_TIMEOUT = 250;
  5799. var MATCH_SCROLL_OFFSET_TOP = -50;
  5800. var MATCH_SCROLL_OFFSET_LEFT = -400;
  5801. var CHARACTERS_TO_NORMALIZE = {
  5802. "\u2018": "'",
  5803. "\u2019": "'",
  5804. "\u201A": "'",
  5805. "\u201B": "'",
  5806. "\u201C": '"',
  5807. "\u201D": '"',
  5808. "\u201E": '"',
  5809. "\u201F": '"',
  5810. "\xBC": "1/4",
  5811. "\xBD": "1/2",
  5812. "\xBE": "3/4"
  5813. };
  5814. var normalizationRegex = null;
  5815. function normalize(text) {
  5816. if (!normalizationRegex) {
  5817. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  5818. normalizationRegex = new RegExp("[".concat(replace, "]"), "g");
  5819. }
  5820. return text.replace(normalizationRegex, function (ch) {
  5821. return CHARACTERS_TO_NORMALIZE[ch];
  5822. });
  5823. }
  5824. var PDFFindController = /*#__PURE__*/function () {
  5825. function PDFFindController(_ref) {
  5826. var linkService = _ref.linkService,
  5827. eventBus = _ref.eventBus;
  5828. _classCallCheck(this, PDFFindController);
  5829. this._linkService = linkService;
  5830. this._eventBus = eventBus;
  5831. this._reset();
  5832. eventBus._on("findbarclose", this._onFindBarClose.bind(this));
  5833. }
  5834. _createClass(PDFFindController, [{
  5835. key: "setDocument",
  5836. value: function setDocument(pdfDocument) {
  5837. if (this._pdfDocument) {
  5838. this._reset();
  5839. }
  5840. if (!pdfDocument) {
  5841. return;
  5842. }
  5843. this._pdfDocument = pdfDocument;
  5844. this._firstPageCapability.resolve();
  5845. }
  5846. }, {
  5847. key: "executeCommand",
  5848. value: function executeCommand(cmd, state) {
  5849. var _this = this;
  5850. if (!state) {
  5851. return;
  5852. }
  5853. var pdfDocument = this._pdfDocument;
  5854. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  5855. this._dirtyMatch = true;
  5856. }
  5857. this._state = state;
  5858. if (cmd !== "findhighlightallchange") {
  5859. this._updateUIState(FindState.PENDING);
  5860. }
  5861. this._firstPageCapability.promise.then(function () {
  5862. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  5863. return;
  5864. }
  5865. _this._extractText();
  5866. var findbarClosed = !_this._highlightMatches;
  5867. var pendingTimeout = !!_this._findTimeout;
  5868. if (_this._findTimeout) {
  5869. clearTimeout(_this._findTimeout);
  5870. _this._findTimeout = null;
  5871. }
  5872. if (cmd === "find") {
  5873. _this._findTimeout = setTimeout(function () {
  5874. _this._nextMatch();
  5875. _this._findTimeout = null;
  5876. }, FIND_TIMEOUT);
  5877. } else if (_this._dirtyMatch) {
  5878. _this._nextMatch();
  5879. } else if (cmd === "findagain") {
  5880. _this._nextMatch();
  5881. if (findbarClosed && _this._state.highlightAll) {
  5882. _this._updateAllPages();
  5883. }
  5884. } else if (cmd === "findhighlightallchange") {
  5885. if (pendingTimeout) {
  5886. _this._nextMatch();
  5887. } else {
  5888. _this._highlightMatches = true;
  5889. }
  5890. _this._updateAllPages();
  5891. } else {
  5892. _this._nextMatch();
  5893. }
  5894. });
  5895. }
  5896. }, {
  5897. key: "scrollMatchIntoView",
  5898. value: function scrollMatchIntoView(_ref2) {
  5899. var _ref2$element = _ref2.element,
  5900. element = _ref2$element === void 0 ? null : _ref2$element,
  5901. _ref2$pageIndex = _ref2.pageIndex,
  5902. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  5903. _ref2$matchIndex = _ref2.matchIndex,
  5904. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  5905. if (!this._scrollMatches || !element) {
  5906. return;
  5907. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  5908. return;
  5909. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  5910. return;
  5911. }
  5912. this._scrollMatches = false;
  5913. var spot = {
  5914. top: MATCH_SCROLL_OFFSET_TOP,
  5915. left: MATCH_SCROLL_OFFSET_LEFT
  5916. };
  5917. (0, _ui_utils.scrollIntoView)(element, spot, true);
  5918. }
  5919. }, {
  5920. key: "_reset",
  5921. value: function _reset() {
  5922. this._highlightMatches = false;
  5923. this._scrollMatches = false;
  5924. this._pdfDocument = null;
  5925. this._pageMatches = [];
  5926. this._pageMatchesLength = [];
  5927. this._state = null;
  5928. this._selected = {
  5929. pageIdx: -1,
  5930. matchIdx: -1
  5931. };
  5932. this._offset = {
  5933. pageIdx: null,
  5934. matchIdx: null,
  5935. wrapped: false
  5936. };
  5937. this._extractTextPromises = [];
  5938. this._pageContents = [];
  5939. this._matchesCountTotal = 0;
  5940. this._pagesToSearch = null;
  5941. this._pendingFindMatches = Object.create(null);
  5942. this._resumePageIdx = null;
  5943. this._dirtyMatch = false;
  5944. clearTimeout(this._findTimeout);
  5945. this._findTimeout = null;
  5946. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  5947. }
  5948. }, {
  5949. key: "_shouldDirtyMatch",
  5950. value: function _shouldDirtyMatch(cmd, state) {
  5951. if (state.query !== this._state.query) {
  5952. return true;
  5953. }
  5954. switch (cmd) {
  5955. case "findagain":
  5956. var pageNumber = this._selected.pageIdx + 1;
  5957. var linkService = this._linkService;
  5958. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  5959. return true;
  5960. }
  5961. return false;
  5962. case "findhighlightallchange":
  5963. return false;
  5964. }
  5965. return true;
  5966. }
  5967. }, {
  5968. key: "_prepareMatches",
  5969. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  5970. function isSubTerm(currentIndex) {
  5971. var currentElem = matchesWithLength[currentIndex];
  5972. var nextElem = matchesWithLength[currentIndex + 1];
  5973. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  5974. currentElem.skipped = true;
  5975. return true;
  5976. }
  5977. for (var i = currentIndex - 1; i >= 0; i--) {
  5978. var prevElem = matchesWithLength[i];
  5979. if (prevElem.skipped) {
  5980. continue;
  5981. }
  5982. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  5983. break;
  5984. }
  5985. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  5986. currentElem.skipped = true;
  5987. return true;
  5988. }
  5989. }
  5990. return false;
  5991. }
  5992. matchesWithLength.sort(function (a, b) {
  5993. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  5994. });
  5995. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  5996. if (isSubTerm(i)) {
  5997. continue;
  5998. }
  5999. matches.push(matchesWithLength[i].match);
  6000. matchesLength.push(matchesWithLength[i].matchLength);
  6001. }
  6002. }
  6003. }, {
  6004. key: "_isEntireWord",
  6005. value: function _isEntireWord(content, startIdx, length) {
  6006. if (startIdx > 0) {
  6007. var first = content.charCodeAt(startIdx);
  6008. var limit = content.charCodeAt(startIdx - 1);
  6009. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  6010. return false;
  6011. }
  6012. }
  6013. var endIdx = startIdx + length - 1;
  6014. if (endIdx < content.length - 1) {
  6015. var last = content.charCodeAt(endIdx);
  6016. var _limit = content.charCodeAt(endIdx + 1);
  6017. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  6018. return false;
  6019. }
  6020. }
  6021. return true;
  6022. }
  6023. }, {
  6024. key: "_calculatePhraseMatch",
  6025. value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
  6026. var matches = [];
  6027. var queryLen = query.length;
  6028. var matchIdx = -queryLen;
  6029. while (true) {
  6030. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  6031. if (matchIdx === -1) {
  6032. break;
  6033. }
  6034. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  6035. continue;
  6036. }
  6037. matches.push(matchIdx);
  6038. }
  6039. this._pageMatches[pageIndex] = matches;
  6040. }
  6041. }, {
  6042. key: "_calculateWordMatch",
  6043. value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  6044. var matchesWithLength = [];
  6045. var queryArray = query.match(/\S+/g);
  6046. for (var i = 0, len = queryArray.length; i < len; i++) {
  6047. var subquery = queryArray[i];
  6048. var subqueryLen = subquery.length;
  6049. var matchIdx = -subqueryLen;
  6050. while (true) {
  6051. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  6052. if (matchIdx === -1) {
  6053. break;
  6054. }
  6055. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  6056. continue;
  6057. }
  6058. matchesWithLength.push({
  6059. match: matchIdx,
  6060. matchLength: subqueryLen,
  6061. skipped: false
  6062. });
  6063. }
  6064. }
  6065. this._pageMatchesLength[pageIndex] = [];
  6066. this._pageMatches[pageIndex] = [];
  6067. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  6068. }
  6069. }, {
  6070. key: "_calculateMatch",
  6071. value: function _calculateMatch(pageIndex) {
  6072. var pageContent = this._pageContents[pageIndex];
  6073. var query = this._query;
  6074. var _this$_state = this._state,
  6075. caseSensitive = _this$_state.caseSensitive,
  6076. entireWord = _this$_state.entireWord,
  6077. phraseSearch = _this$_state.phraseSearch;
  6078. if (query.length === 0) {
  6079. return;
  6080. }
  6081. if (!caseSensitive) {
  6082. pageContent = pageContent.toLowerCase();
  6083. query = query.toLowerCase();
  6084. }
  6085. if (phraseSearch) {
  6086. this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
  6087. } else {
  6088. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  6089. }
  6090. if (this._state.highlightAll) {
  6091. this._updatePage(pageIndex);
  6092. }
  6093. if (this._resumePageIdx === pageIndex) {
  6094. this._resumePageIdx = null;
  6095. this._nextPageMatch();
  6096. }
  6097. var pageMatchesCount = this._pageMatches[pageIndex].length;
  6098. if (pageMatchesCount > 0) {
  6099. this._matchesCountTotal += pageMatchesCount;
  6100. this._updateUIResultsCount();
  6101. }
  6102. }
  6103. }, {
  6104. key: "_extractText",
  6105. value: function _extractText() {
  6106. var _this2 = this;
  6107. if (this._extractTextPromises.length > 0) {
  6108. return;
  6109. }
  6110. var promise = Promise.resolve();
  6111. var _loop = function _loop(i, ii) {
  6112. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  6113. _this2._extractTextPromises[i] = extractTextCapability.promise;
  6114. promise = promise.then(function () {
  6115. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  6116. return pdfPage.getTextContent({
  6117. normalizeWhitespace: true
  6118. });
  6119. }).then(function (textContent) {
  6120. var textItems = textContent.items;
  6121. var strBuf = [];
  6122. for (var j = 0, jj = textItems.length; j < jj; j++) {
  6123. strBuf.push(textItems[j].str);
  6124. }
  6125. _this2._pageContents[i] = normalize(strBuf.join(""));
  6126. extractTextCapability.resolve(i);
  6127. }, function (reason) {
  6128. console.error("Unable to get text content for page ".concat(i + 1), reason);
  6129. _this2._pageContents[i] = "";
  6130. extractTextCapability.resolve(i);
  6131. });
  6132. });
  6133. };
  6134. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  6135. _loop(i, ii);
  6136. }
  6137. }
  6138. }, {
  6139. key: "_updatePage",
  6140. value: function _updatePage(index) {
  6141. if (this._scrollMatches && this._selected.pageIdx === index) {
  6142. this._linkService.page = index + 1;
  6143. }
  6144. this._eventBus.dispatch("updatetextlayermatches", {
  6145. source: this,
  6146. pageIndex: index
  6147. });
  6148. }
  6149. }, {
  6150. key: "_updateAllPages",
  6151. value: function _updateAllPages() {
  6152. this._eventBus.dispatch("updatetextlayermatches", {
  6153. source: this,
  6154. pageIndex: -1
  6155. });
  6156. }
  6157. }, {
  6158. key: "_nextMatch",
  6159. value: function _nextMatch() {
  6160. var _this3 = this;
  6161. var previous = this._state.findPrevious;
  6162. var currentPageIndex = this._linkService.page - 1;
  6163. var numPages = this._linkService.pagesCount;
  6164. this._highlightMatches = true;
  6165. if (this._dirtyMatch) {
  6166. this._dirtyMatch = false;
  6167. this._selected.pageIdx = this._selected.matchIdx = -1;
  6168. this._offset.pageIdx = currentPageIndex;
  6169. this._offset.matchIdx = null;
  6170. this._offset.wrapped = false;
  6171. this._resumePageIdx = null;
  6172. this._pageMatches.length = 0;
  6173. this._pageMatchesLength.length = 0;
  6174. this._matchesCountTotal = 0;
  6175. this._updateAllPages();
  6176. for (var i = 0; i < numPages; i++) {
  6177. if (this._pendingFindMatches[i] === true) {
  6178. continue;
  6179. }
  6180. this._pendingFindMatches[i] = true;
  6181. this._extractTextPromises[i].then(function (pageIdx) {
  6182. delete _this3._pendingFindMatches[pageIdx];
  6183. _this3._calculateMatch(pageIdx);
  6184. });
  6185. }
  6186. }
  6187. if (this._query === "") {
  6188. this._updateUIState(FindState.FOUND);
  6189. return;
  6190. }
  6191. if (this._resumePageIdx) {
  6192. return;
  6193. }
  6194. var offset = this._offset;
  6195. this._pagesToSearch = numPages;
  6196. if (offset.matchIdx !== null) {
  6197. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  6198. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  6199. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  6200. this._updateMatch(true);
  6201. return;
  6202. }
  6203. this._advanceOffsetPage(previous);
  6204. }
  6205. this._nextPageMatch();
  6206. }
  6207. }, {
  6208. key: "_matchesReady",
  6209. value: function _matchesReady(matches) {
  6210. var offset = this._offset;
  6211. var numMatches = matches.length;
  6212. var previous = this._state.findPrevious;
  6213. if (numMatches) {
  6214. offset.matchIdx = previous ? numMatches - 1 : 0;
  6215. this._updateMatch(true);
  6216. return true;
  6217. }
  6218. this._advanceOffsetPage(previous);
  6219. if (offset.wrapped) {
  6220. offset.matchIdx = null;
  6221. if (this._pagesToSearch < 0) {
  6222. this._updateMatch(false);
  6223. return true;
  6224. }
  6225. }
  6226. return false;
  6227. }
  6228. }, {
  6229. key: "_nextPageMatch",
  6230. value: function _nextPageMatch() {
  6231. if (this._resumePageIdx !== null) {
  6232. console.error("There can only be one pending page.");
  6233. }
  6234. var matches = null;
  6235. do {
  6236. var pageIdx = this._offset.pageIdx;
  6237. matches = this._pageMatches[pageIdx];
  6238. if (!matches) {
  6239. this._resumePageIdx = pageIdx;
  6240. break;
  6241. }
  6242. } while (!this._matchesReady(matches));
  6243. }
  6244. }, {
  6245. key: "_advanceOffsetPage",
  6246. value: function _advanceOffsetPage(previous) {
  6247. var offset = this._offset;
  6248. var numPages = this._linkService.pagesCount;
  6249. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  6250. offset.matchIdx = null;
  6251. this._pagesToSearch--;
  6252. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  6253. offset.pageIdx = previous ? numPages - 1 : 0;
  6254. offset.wrapped = true;
  6255. }
  6256. }
  6257. }, {
  6258. key: "_updateMatch",
  6259. value: function _updateMatch() {
  6260. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6261. var state = FindState.NOT_FOUND;
  6262. var wrapped = this._offset.wrapped;
  6263. this._offset.wrapped = false;
  6264. if (found) {
  6265. var previousPage = this._selected.pageIdx;
  6266. this._selected.pageIdx = this._offset.pageIdx;
  6267. this._selected.matchIdx = this._offset.matchIdx;
  6268. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  6269. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  6270. this._updatePage(previousPage);
  6271. }
  6272. }
  6273. this._updateUIState(state, this._state.findPrevious);
  6274. if (this._selected.pageIdx !== -1) {
  6275. this._scrollMatches = true;
  6276. this._updatePage(this._selected.pageIdx);
  6277. }
  6278. }
  6279. }, {
  6280. key: "_onFindBarClose",
  6281. value: function _onFindBarClose(evt) {
  6282. var _this4 = this;
  6283. var pdfDocument = this._pdfDocument;
  6284. this._firstPageCapability.promise.then(function () {
  6285. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  6286. return;
  6287. }
  6288. if (_this4._findTimeout) {
  6289. clearTimeout(_this4._findTimeout);
  6290. _this4._findTimeout = null;
  6291. }
  6292. if (_this4._resumePageIdx) {
  6293. _this4._resumePageIdx = null;
  6294. _this4._dirtyMatch = true;
  6295. }
  6296. _this4._updateUIState(FindState.FOUND);
  6297. _this4._highlightMatches = false;
  6298. _this4._updateAllPages();
  6299. });
  6300. }
  6301. }, {
  6302. key: "_requestMatchesCount",
  6303. value: function _requestMatchesCount() {
  6304. var _this$_selected = this._selected,
  6305. pageIdx = _this$_selected.pageIdx,
  6306. matchIdx = _this$_selected.matchIdx;
  6307. var current = 0,
  6308. total = this._matchesCountTotal;
  6309. if (matchIdx !== -1) {
  6310. for (var i = 0; i < pageIdx; i++) {
  6311. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  6312. }
  6313. current += matchIdx + 1;
  6314. }
  6315. if (current < 1 || current > total) {
  6316. current = total = 0;
  6317. }
  6318. return {
  6319. current: current,
  6320. total: total
  6321. };
  6322. }
  6323. }, {
  6324. key: "_updateUIResultsCount",
  6325. value: function _updateUIResultsCount() {
  6326. this._eventBus.dispatch("updatefindmatchescount", {
  6327. source: this,
  6328. matchesCount: this._requestMatchesCount()
  6329. });
  6330. }
  6331. }, {
  6332. key: "_updateUIState",
  6333. value: function _updateUIState(state, previous) {
  6334. this._eventBus.dispatch("updatefindcontrolstate", {
  6335. source: this,
  6336. state: state,
  6337. previous: previous,
  6338. matchesCount: this._requestMatchesCount()
  6339. });
  6340. }
  6341. }, {
  6342. key: "highlightMatches",
  6343. get: function get() {
  6344. return this._highlightMatches;
  6345. }
  6346. }, {
  6347. key: "pageMatches",
  6348. get: function get() {
  6349. return this._pageMatches;
  6350. }
  6351. }, {
  6352. key: "pageMatchesLength",
  6353. get: function get() {
  6354. return this._pageMatchesLength;
  6355. }
  6356. }, {
  6357. key: "selected",
  6358. get: function get() {
  6359. return this._selected;
  6360. }
  6361. }, {
  6362. key: "state",
  6363. get: function get() {
  6364. return this._state;
  6365. }
  6366. }, {
  6367. key: "_query",
  6368. get: function get() {
  6369. if (this._state.query !== this._rawQuery) {
  6370. this._rawQuery = this._state.query;
  6371. this._normalizedQuery = normalize(this._state.query);
  6372. }
  6373. return this._normalizedQuery;
  6374. }
  6375. }]);
  6376. return PDFFindController;
  6377. }();
  6378. exports.PDFFindController = PDFFindController;
  6379. /***/ }),
  6380. /* 19 */
  6381. /***/ (function(module, exports, __webpack_require__) {
  6382. "use strict";
  6383. Object.defineProperty(exports, "__esModule", {
  6384. value: true
  6385. });
  6386. exports.getCharacterType = getCharacterType;
  6387. exports.CharacterType = void 0;
  6388. var CharacterType = {
  6389. SPACE: 0,
  6390. ALPHA_LETTER: 1,
  6391. PUNCT: 2,
  6392. HAN_LETTER: 3,
  6393. KATAKANA_LETTER: 4,
  6394. HIRAGANA_LETTER: 5,
  6395. HALFWIDTH_KATAKANA_LETTER: 6,
  6396. THAI_LETTER: 7
  6397. };
  6398. exports.CharacterType = CharacterType;
  6399. function isAlphabeticalScript(charCode) {
  6400. return charCode < 0x2e80;
  6401. }
  6402. function isAscii(charCode) {
  6403. return (charCode & 0xff80) === 0;
  6404. }
  6405. function isAsciiAlpha(charCode) {
  6406. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  6407. }
  6408. function isAsciiDigit(charCode) {
  6409. return charCode >= 0x30 && charCode <= 0x39;
  6410. }
  6411. function isAsciiSpace(charCode) {
  6412. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  6413. }
  6414. function isHan(charCode) {
  6415. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  6416. }
  6417. function isKatakana(charCode) {
  6418. return charCode >= 0x30a0 && charCode <= 0x30ff;
  6419. }
  6420. function isHiragana(charCode) {
  6421. return charCode >= 0x3040 && charCode <= 0x309f;
  6422. }
  6423. function isHalfwidthKatakana(charCode) {
  6424. return charCode >= 0xff60 && charCode <= 0xff9f;
  6425. }
  6426. function isThai(charCode) {
  6427. return (charCode & 0xff80) === 0x0e00;
  6428. }
  6429. function getCharacterType(charCode) {
  6430. if (isAlphabeticalScript(charCode)) {
  6431. if (isAscii(charCode)) {
  6432. if (isAsciiSpace(charCode)) {
  6433. return CharacterType.SPACE;
  6434. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  6435. return CharacterType.ALPHA_LETTER;
  6436. }
  6437. return CharacterType.PUNCT;
  6438. } else if (isThai(charCode)) {
  6439. return CharacterType.THAI_LETTER;
  6440. } else if (charCode === 0xa0) {
  6441. return CharacterType.SPACE;
  6442. }
  6443. return CharacterType.ALPHA_LETTER;
  6444. }
  6445. if (isHan(charCode)) {
  6446. return CharacterType.HAN_LETTER;
  6447. } else if (isKatakana(charCode)) {
  6448. return CharacterType.KATAKANA_LETTER;
  6449. } else if (isHiragana(charCode)) {
  6450. return CharacterType.HIRAGANA_LETTER;
  6451. } else if (isHalfwidthKatakana(charCode)) {
  6452. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  6453. }
  6454. return CharacterType.ALPHA_LETTER;
  6455. }
  6456. /***/ }),
  6457. /* 20 */
  6458. /***/ (function(module, exports, __webpack_require__) {
  6459. "use strict";
  6460. Object.defineProperty(exports, "__esModule", {
  6461. value: true
  6462. });
  6463. exports.isDestHashesEqual = isDestHashesEqual;
  6464. exports.isDestArraysEqual = isDestArraysEqual;
  6465. exports.PDFHistory = void 0;
  6466. var _ui_utils = __webpack_require__(5);
  6467. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  6468. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  6469. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  6470. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  6471. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  6472. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  6473. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  6474. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6475. 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); } }
  6476. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6477. var HASH_CHANGE_TIMEOUT = 1000;
  6478. var POSITION_UPDATED_THRESHOLD = 50;
  6479. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  6480. function getCurrentHash() {
  6481. return document.location.hash;
  6482. }
  6483. var PDFHistory = /*#__PURE__*/function () {
  6484. function PDFHistory(_ref) {
  6485. var _this = this;
  6486. var linkService = _ref.linkService,
  6487. eventBus = _ref.eventBus;
  6488. _classCallCheck(this, PDFHistory);
  6489. this.linkService = linkService;
  6490. this.eventBus = eventBus;
  6491. this._initialized = false;
  6492. this._fingerprint = "";
  6493. this.reset();
  6494. this._boundEvents = null;
  6495. this._isViewerInPresentationMode = false;
  6496. this.eventBus._on("presentationmodechanged", function (evt) {
  6497. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  6498. });
  6499. this.eventBus._on("pagesinit", function () {
  6500. _this._isPagesLoaded = false;
  6501. var onPagesLoaded = function onPagesLoaded(evt) {
  6502. _this.eventBus._off("pagesloaded", onPagesLoaded);
  6503. _this._isPagesLoaded = !!evt.pagesCount;
  6504. };
  6505. _this.eventBus._on("pagesloaded", onPagesLoaded);
  6506. });
  6507. }
  6508. _createClass(PDFHistory, [{
  6509. key: "initialize",
  6510. value: function initialize(_ref2) {
  6511. var fingerprint = _ref2.fingerprint,
  6512. _ref2$resetHistory = _ref2.resetHistory,
  6513. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  6514. _ref2$updateUrl = _ref2.updateUrl,
  6515. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  6516. if (!fingerprint || typeof fingerprint !== "string") {
  6517. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  6518. return;
  6519. }
  6520. if (this._initialized) {
  6521. this.reset();
  6522. }
  6523. var reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  6524. this._fingerprint = fingerprint;
  6525. this._updateUrl = updateUrl === true;
  6526. this._initialized = true;
  6527. this._bindEvents();
  6528. var state = window.history.state;
  6529. this._popStateInProgress = false;
  6530. this._blockHashChange = 0;
  6531. this._currentHash = getCurrentHash();
  6532. this._numPositionUpdates = 0;
  6533. this._uid = this._maxUid = 0;
  6534. this._destination = null;
  6535. this._position = null;
  6536. if (!this._isValidState(state, true) || resetHistory) {
  6537. var _this$_parseCurrentHa = this._parseCurrentHash(true),
  6538. hash = _this$_parseCurrentHa.hash,
  6539. page = _this$_parseCurrentHa.page,
  6540. rotation = _this$_parseCurrentHa.rotation;
  6541. if (!hash || reInitialized || resetHistory) {
  6542. this._pushOrReplaceState(null, true);
  6543. return;
  6544. }
  6545. this._pushOrReplaceState({
  6546. hash: hash,
  6547. page: page,
  6548. rotation: rotation
  6549. }, true);
  6550. return;
  6551. }
  6552. var destination = state.destination;
  6553. this._updateInternalState(destination, state.uid, true);
  6554. if (this._uid > this._maxUid) {
  6555. this._maxUid = this._uid;
  6556. }
  6557. if (destination.rotation !== undefined) {
  6558. this._initialRotation = destination.rotation;
  6559. }
  6560. if (destination.dest) {
  6561. this._initialBookmark = JSON.stringify(destination.dest);
  6562. this._destination.page = null;
  6563. } else if (destination.hash) {
  6564. this._initialBookmark = destination.hash;
  6565. } else if (destination.page) {
  6566. this._initialBookmark = "page=".concat(destination.page);
  6567. }
  6568. }
  6569. }, {
  6570. key: "reset",
  6571. value: function reset() {
  6572. if (this._initialized) {
  6573. this._pageHide();
  6574. this._initialized = false;
  6575. this._unbindEvents();
  6576. }
  6577. if (this._updateViewareaTimeout) {
  6578. clearTimeout(this._updateViewareaTimeout);
  6579. this._updateViewareaTimeout = null;
  6580. }
  6581. this._initialBookmark = null;
  6582. this._initialRotation = null;
  6583. }
  6584. }, {
  6585. key: "push",
  6586. value: function push(_ref3) {
  6587. var _this2 = this;
  6588. var _ref3$namedDest = _ref3.namedDest,
  6589. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  6590. explicitDest = _ref3.explicitDest,
  6591. pageNumber = _ref3.pageNumber;
  6592. if (!this._initialized) {
  6593. return;
  6594. }
  6595. if (namedDest && typeof namedDest !== "string") {
  6596. console.error("PDFHistory.push: " + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  6597. return;
  6598. } else if (!Array.isArray(explicitDest)) {
  6599. console.error("PDFHistory.push: " + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  6600. return;
  6601. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  6602. if (pageNumber !== null || this._destination) {
  6603. console.error("PDFHistory.push: " + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  6604. return;
  6605. }
  6606. }
  6607. var hash = namedDest || JSON.stringify(explicitDest);
  6608. if (!hash) {
  6609. return;
  6610. }
  6611. var forceReplace = false;
  6612. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  6613. if (this._destination.page) {
  6614. return;
  6615. }
  6616. forceReplace = true;
  6617. }
  6618. if (this._popStateInProgress && !forceReplace) {
  6619. return;
  6620. }
  6621. this._pushOrReplaceState({
  6622. dest: explicitDest,
  6623. hash: hash,
  6624. page: pageNumber,
  6625. rotation: this.linkService.rotation
  6626. }, forceReplace);
  6627. if (!this._popStateInProgress) {
  6628. this._popStateInProgress = true;
  6629. Promise.resolve().then(function () {
  6630. _this2._popStateInProgress = false;
  6631. });
  6632. }
  6633. }
  6634. }, {
  6635. key: "pushCurrentPosition",
  6636. value: function pushCurrentPosition() {
  6637. if (!this._initialized || this._popStateInProgress) {
  6638. return;
  6639. }
  6640. this._tryPushCurrentPosition();
  6641. }
  6642. }, {
  6643. key: "back",
  6644. value: function back() {
  6645. if (!this._initialized || this._popStateInProgress) {
  6646. return;
  6647. }
  6648. var state = window.history.state;
  6649. if (this._isValidState(state) && state.uid > 0) {
  6650. window.history.back();
  6651. }
  6652. }
  6653. }, {
  6654. key: "forward",
  6655. value: function forward() {
  6656. if (!this._initialized || this._popStateInProgress) {
  6657. return;
  6658. }
  6659. var state = window.history.state;
  6660. if (this._isValidState(state) && state.uid < this._maxUid) {
  6661. window.history.forward();
  6662. }
  6663. }
  6664. }, {
  6665. key: "_pushOrReplaceState",
  6666. value: function _pushOrReplaceState(destination) {
  6667. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6668. var shouldReplace = forceReplace || !this._destination;
  6669. var newState = {
  6670. fingerprint: this._fingerprint,
  6671. uid: shouldReplace ? this._uid : this._uid + 1,
  6672. destination: destination
  6673. };
  6674. this._updateInternalState(destination, newState.uid);
  6675. var newUrl;
  6676. if (this._updateUrl && destination && destination.hash) {
  6677. var baseUrl = document.location.href.split("#")[0];
  6678. if (!baseUrl.startsWith("file://")) {
  6679. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  6680. }
  6681. }
  6682. if (shouldReplace) {
  6683. window.history.replaceState(newState, "", newUrl);
  6684. } else {
  6685. this._maxUid = this._uid;
  6686. window.history.pushState(newState, "", newUrl);
  6687. }
  6688. }
  6689. }, {
  6690. key: "_tryPushCurrentPosition",
  6691. value: function _tryPushCurrentPosition() {
  6692. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6693. if (!this._position) {
  6694. return;
  6695. }
  6696. var position = this._position;
  6697. if (temporary) {
  6698. position = Object.assign(Object.create(null), this._position);
  6699. position.temporary = true;
  6700. }
  6701. if (!this._destination) {
  6702. this._pushOrReplaceState(position);
  6703. return;
  6704. }
  6705. if (this._destination.temporary) {
  6706. this._pushOrReplaceState(position, true);
  6707. return;
  6708. }
  6709. if (this._destination.hash === position.hash) {
  6710. return;
  6711. }
  6712. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  6713. return;
  6714. }
  6715. var forceReplace = false;
  6716. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  6717. if (this._destination.dest || !this._destination.first) {
  6718. return;
  6719. }
  6720. forceReplace = true;
  6721. }
  6722. this._pushOrReplaceState(position, forceReplace);
  6723. }
  6724. }, {
  6725. key: "_isValidState",
  6726. value: function _isValidState(state) {
  6727. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6728. if (!state) {
  6729. return false;
  6730. }
  6731. if (state.fingerprint !== this._fingerprint) {
  6732. if (checkReload) {
  6733. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  6734. return false;
  6735. }
  6736. var _performance$getEntri = performance.getEntriesByType("navigation"),
  6737. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  6738. perfEntry = _performance$getEntri2[0];
  6739. if (!perfEntry || perfEntry.type !== "reload") {
  6740. return false;
  6741. }
  6742. } else {
  6743. return false;
  6744. }
  6745. }
  6746. if (!Number.isInteger(state.uid) || state.uid < 0) {
  6747. return false;
  6748. }
  6749. if (state.destination === null || _typeof(state.destination) !== "object") {
  6750. return false;
  6751. }
  6752. return true;
  6753. }
  6754. }, {
  6755. key: "_updateInternalState",
  6756. value: function _updateInternalState(destination, uid) {
  6757. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6758. if (this._updateViewareaTimeout) {
  6759. clearTimeout(this._updateViewareaTimeout);
  6760. this._updateViewareaTimeout = null;
  6761. }
  6762. if (removeTemporary && destination && destination.temporary) {
  6763. delete destination.temporary;
  6764. }
  6765. this._destination = destination;
  6766. this._uid = uid;
  6767. this._numPositionUpdates = 0;
  6768. }
  6769. }, {
  6770. key: "_parseCurrentHash",
  6771. value: function _parseCurrentHash() {
  6772. var checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6773. var hash = unescape(getCurrentHash()).substring(1);
  6774. var params = (0, _ui_utils.parseQueryString)(hash);
  6775. var nameddest = params.nameddest || "";
  6776. var page = params.page | 0;
  6777. if (!(Number.isInteger(page) && page > 0 && page <= this.linkService.pagesCount) || checkNameddest && nameddest.length > 0) {
  6778. page = null;
  6779. }
  6780. return {
  6781. hash: hash,
  6782. page: page,
  6783. rotation: this.linkService.rotation
  6784. };
  6785. }
  6786. }, {
  6787. key: "_updateViewarea",
  6788. value: function _updateViewarea(_ref4) {
  6789. var _this3 = this;
  6790. var location = _ref4.location;
  6791. if (this._updateViewareaTimeout) {
  6792. clearTimeout(this._updateViewareaTimeout);
  6793. this._updateViewareaTimeout = null;
  6794. }
  6795. this._position = {
  6796. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  6797. page: this.linkService.page,
  6798. first: location.pageNumber,
  6799. rotation: location.rotation
  6800. };
  6801. if (this._popStateInProgress) {
  6802. return;
  6803. }
  6804. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  6805. this._numPositionUpdates++;
  6806. }
  6807. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  6808. this._updateViewareaTimeout = setTimeout(function () {
  6809. if (!_this3._popStateInProgress) {
  6810. _this3._tryPushCurrentPosition(true);
  6811. }
  6812. _this3._updateViewareaTimeout = null;
  6813. }, UPDATE_VIEWAREA_TIMEOUT);
  6814. }
  6815. }
  6816. }, {
  6817. key: "_popState",
  6818. value: function _popState(_ref5) {
  6819. var _this4 = this;
  6820. var state = _ref5.state;
  6821. var newHash = getCurrentHash(),
  6822. hashChanged = this._currentHash !== newHash;
  6823. this._currentHash = newHash;
  6824. if (!state) {
  6825. this._uid++;
  6826. var _this$_parseCurrentHa2 = this._parseCurrentHash(),
  6827. hash = _this$_parseCurrentHa2.hash,
  6828. page = _this$_parseCurrentHa2.page,
  6829. rotation = _this$_parseCurrentHa2.rotation;
  6830. this._pushOrReplaceState({
  6831. hash: hash,
  6832. page: page,
  6833. rotation: rotation
  6834. }, true);
  6835. return;
  6836. }
  6837. if (!this._isValidState(state)) {
  6838. return;
  6839. }
  6840. this._popStateInProgress = true;
  6841. if (hashChanged) {
  6842. this._blockHashChange++;
  6843. (0, _ui_utils.waitOnEventOrTimeout)({
  6844. target: window,
  6845. name: "hashchange",
  6846. delay: HASH_CHANGE_TIMEOUT
  6847. }).then(function () {
  6848. _this4._blockHashChange--;
  6849. });
  6850. }
  6851. var destination = state.destination;
  6852. this._updateInternalState(destination, state.uid, true);
  6853. if (this._uid > this._maxUid) {
  6854. this._maxUid = this._uid;
  6855. }
  6856. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  6857. this.linkService.rotation = destination.rotation;
  6858. }
  6859. if (destination.dest) {
  6860. this.linkService.navigateTo(destination.dest);
  6861. } else if (destination.hash) {
  6862. this.linkService.setHash(destination.hash);
  6863. } else if (destination.page) {
  6864. this.linkService.page = destination.page;
  6865. }
  6866. Promise.resolve().then(function () {
  6867. _this4._popStateInProgress = false;
  6868. });
  6869. }
  6870. }, {
  6871. key: "_pageHide",
  6872. value: function _pageHide() {
  6873. if (!this._destination || this._destination.temporary) {
  6874. this._tryPushCurrentPosition();
  6875. }
  6876. }
  6877. }, {
  6878. key: "_bindEvents",
  6879. value: function _bindEvents() {
  6880. if (this._boundEvents) {
  6881. return;
  6882. }
  6883. this._boundEvents = {
  6884. updateViewarea: this._updateViewarea.bind(this),
  6885. popState: this._popState.bind(this),
  6886. pageHide: this._pageHide.bind(this)
  6887. };
  6888. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  6889. window.addEventListener("popstate", this._boundEvents.popState);
  6890. window.addEventListener("pagehide", this._boundEvents.pageHide);
  6891. }
  6892. }, {
  6893. key: "_unbindEvents",
  6894. value: function _unbindEvents() {
  6895. if (!this._boundEvents) {
  6896. return;
  6897. }
  6898. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  6899. window.removeEventListener("popstate", this._boundEvents.popState);
  6900. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  6901. this._boundEvents = null;
  6902. }
  6903. }, {
  6904. key: "popStateInProgress",
  6905. get: function get() {
  6906. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  6907. }
  6908. }, {
  6909. key: "initialBookmark",
  6910. get: function get() {
  6911. return this._initialized ? this._initialBookmark : null;
  6912. }
  6913. }, {
  6914. key: "initialRotation",
  6915. get: function get() {
  6916. return this._initialized ? this._initialRotation : null;
  6917. }
  6918. }]);
  6919. return PDFHistory;
  6920. }();
  6921. exports.PDFHistory = PDFHistory;
  6922. function isDestHashesEqual(destHash, pushHash) {
  6923. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  6924. return false;
  6925. }
  6926. if (destHash === pushHash) {
  6927. return true;
  6928. }
  6929. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  6930. nameddest = _parseQueryString.nameddest;
  6931. if (nameddest === pushHash) {
  6932. return true;
  6933. }
  6934. return false;
  6935. }
  6936. function isDestArraysEqual(firstDest, secondDest) {
  6937. function isEntryEqual(first, second) {
  6938. if (_typeof(first) !== _typeof(second)) {
  6939. return false;
  6940. }
  6941. if (Array.isArray(first) || Array.isArray(second)) {
  6942. return false;
  6943. }
  6944. if (first !== null && _typeof(first) === "object" && second !== null) {
  6945. if (Object.keys(first).length !== Object.keys(second).length) {
  6946. return false;
  6947. }
  6948. for (var key in first) {
  6949. if (!isEntryEqual(first[key], second[key])) {
  6950. return false;
  6951. }
  6952. }
  6953. return true;
  6954. }
  6955. return first === second || Number.isNaN(first) && Number.isNaN(second);
  6956. }
  6957. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  6958. return false;
  6959. }
  6960. if (firstDest.length !== secondDest.length) {
  6961. return false;
  6962. }
  6963. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  6964. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  6965. return false;
  6966. }
  6967. }
  6968. return true;
  6969. }
  6970. /***/ }),
  6971. /* 21 */
  6972. /***/ (function(module, exports, __webpack_require__) {
  6973. "use strict";
  6974. Object.defineProperty(exports, "__esModule", {
  6975. value: true
  6976. });
  6977. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  6978. var _ui_utils = __webpack_require__(5);
  6979. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  6980. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6981. 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); } }
  6982. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6983. var PDFLinkService = /*#__PURE__*/function () {
  6984. function PDFLinkService() {
  6985. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  6986. eventBus = _ref.eventBus,
  6987. _ref$externalLinkTarg = _ref.externalLinkTarget,
  6988. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  6989. _ref$externalLinkRel = _ref.externalLinkRel,
  6990. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel,
  6991. _ref$externalLinkEnab = _ref.externalLinkEnabled,
  6992. externalLinkEnabled = _ref$externalLinkEnab === void 0 ? true : _ref$externalLinkEnab,
  6993. _ref$ignoreDestinatio = _ref.ignoreDestinationZoom,
  6994. ignoreDestinationZoom = _ref$ignoreDestinatio === void 0 ? false : _ref$ignoreDestinatio;
  6995. _classCallCheck(this, PDFLinkService);
  6996. this.eventBus = eventBus;
  6997. this.externalLinkTarget = externalLinkTarget;
  6998. this.externalLinkRel = externalLinkRel;
  6999. this.externalLinkEnabled = externalLinkEnabled;
  7000. this._ignoreDestinationZoom = ignoreDestinationZoom;
  7001. this.baseUrl = null;
  7002. this.pdfDocument = null;
  7003. this.pdfViewer = null;
  7004. this.pdfHistory = null;
  7005. this._pagesRefCache = null;
  7006. }
  7007. _createClass(PDFLinkService, [{
  7008. key: "setDocument",
  7009. value: function setDocument(pdfDocument) {
  7010. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  7011. this.baseUrl = baseUrl;
  7012. this.pdfDocument = pdfDocument;
  7013. this._pagesRefCache = Object.create(null);
  7014. }
  7015. }, {
  7016. key: "setViewer",
  7017. value: function setViewer(pdfViewer) {
  7018. this.pdfViewer = pdfViewer;
  7019. }
  7020. }, {
  7021. key: "setHistory",
  7022. value: function setHistory(pdfHistory) {
  7023. this.pdfHistory = pdfHistory;
  7024. }
  7025. }, {
  7026. key: "navigateTo",
  7027. value: function navigateTo(dest) {
  7028. var _this = this;
  7029. var goToDestination = function goToDestination(_ref2) {
  7030. var namedDest = _ref2.namedDest,
  7031. explicitDest = _ref2.explicitDest;
  7032. var destRef = explicitDest[0];
  7033. var pageNumber;
  7034. if (destRef instanceof Object) {
  7035. pageNumber = _this._cachedPageNumber(destRef);
  7036. if (pageNumber === null) {
  7037. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  7038. _this.cachePageRef(pageIndex + 1, destRef);
  7039. goToDestination({
  7040. namedDest: namedDest,
  7041. explicitDest: explicitDest
  7042. });
  7043. })["catch"](function () {
  7044. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(dest, "\"."));
  7045. });
  7046. return;
  7047. }
  7048. } else if (Number.isInteger(destRef)) {
  7049. pageNumber = destRef + 1;
  7050. } else {
  7051. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(dest, "\"."));
  7052. return;
  7053. }
  7054. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  7055. console.error("PDFLinkService.navigateTo: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(dest, "\"."));
  7056. return;
  7057. }
  7058. if (_this.pdfHistory) {
  7059. _this.pdfHistory.pushCurrentPosition();
  7060. _this.pdfHistory.push({
  7061. namedDest: namedDest,
  7062. explicitDest: explicitDest,
  7063. pageNumber: pageNumber
  7064. });
  7065. }
  7066. _this.pdfViewer.scrollPageIntoView({
  7067. pageNumber: pageNumber,
  7068. destArray: explicitDest,
  7069. ignoreDestinationZoom: _this._ignoreDestinationZoom
  7070. });
  7071. };
  7072. new Promise(function (resolve, reject) {
  7073. if (typeof dest === "string") {
  7074. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  7075. resolve({
  7076. namedDest: dest,
  7077. explicitDest: destArray
  7078. });
  7079. });
  7080. return;
  7081. }
  7082. resolve({
  7083. namedDest: "",
  7084. explicitDest: dest
  7085. });
  7086. }).then(function (data) {
  7087. if (!Array.isArray(data.explicitDest)) {
  7088. console.error("PDFLinkService.navigateTo: \"".concat(data.explicitDest, "\" is") + " not a valid destination array, for dest=\"".concat(dest, "\"."));
  7089. return;
  7090. }
  7091. goToDestination(data);
  7092. });
  7093. }
  7094. }, {
  7095. key: "getDestinationHash",
  7096. value: function getDestinationHash(dest) {
  7097. if (typeof dest === "string") {
  7098. return this.getAnchorUrl("#" + escape(dest));
  7099. }
  7100. if (Array.isArray(dest)) {
  7101. var str = JSON.stringify(dest);
  7102. return this.getAnchorUrl("#" + escape(str));
  7103. }
  7104. return this.getAnchorUrl("");
  7105. }
  7106. }, {
  7107. key: "getAnchorUrl",
  7108. value: function getAnchorUrl(anchor) {
  7109. return (this.baseUrl || "") + anchor;
  7110. }
  7111. }, {
  7112. key: "setHash",
  7113. value: function setHash(hash) {
  7114. var pageNumber, dest;
  7115. if (hash.includes("=")) {
  7116. var params = (0, _ui_utils.parseQueryString)(hash);
  7117. if ("search" in params) {
  7118. this.eventBus.dispatch("findfromurlhash", {
  7119. source: this,
  7120. query: params.search.replace(/"/g, ""),
  7121. phraseSearch: params.phrase === "true"
  7122. });
  7123. }
  7124. if ("page" in params) {
  7125. pageNumber = params.page | 0 || 1;
  7126. }
  7127. if ("zoom" in params) {
  7128. var zoomArgs = params.zoom.split(",");
  7129. var zoomArg = zoomArgs[0];
  7130. var zoomArgNumber = parseFloat(zoomArg);
  7131. if (!zoomArg.includes("Fit")) {
  7132. dest = [null, {
  7133. name: "XYZ"
  7134. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  7135. } else {
  7136. if (zoomArg === "Fit" || zoomArg === "FitB") {
  7137. dest = [null, {
  7138. name: zoomArg
  7139. }];
  7140. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  7141. dest = [null, {
  7142. name: zoomArg
  7143. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  7144. } else if (zoomArg === "FitR") {
  7145. if (zoomArgs.length !== 5) {
  7146. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  7147. } else {
  7148. dest = [null, {
  7149. name: zoomArg
  7150. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  7151. }
  7152. } else {
  7153. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + "a valid zoom value.");
  7154. }
  7155. }
  7156. }
  7157. if (dest) {
  7158. this.pdfViewer.scrollPageIntoView({
  7159. pageNumber: pageNumber || this.page,
  7160. destArray: dest,
  7161. allowNegativeOffset: true
  7162. });
  7163. } else if (pageNumber) {
  7164. this.page = pageNumber;
  7165. }
  7166. if ("pagemode" in params) {
  7167. this.eventBus.dispatch("pagemode", {
  7168. source: this,
  7169. mode: params.pagemode
  7170. });
  7171. }
  7172. if ("nameddest" in params) {
  7173. this.navigateTo(params.nameddest);
  7174. }
  7175. } else {
  7176. dest = unescape(hash);
  7177. try {
  7178. dest = JSON.parse(dest);
  7179. if (!Array.isArray(dest)) {
  7180. dest = dest.toString();
  7181. }
  7182. } catch (ex) {}
  7183. if (typeof dest === "string" || isValidExplicitDestination(dest)) {
  7184. this.navigateTo(dest);
  7185. return;
  7186. }
  7187. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + "a valid destination.");
  7188. }
  7189. }
  7190. }, {
  7191. key: "executeNamedAction",
  7192. value: function executeNamedAction(action) {
  7193. switch (action) {
  7194. case "GoBack":
  7195. if (this.pdfHistory) {
  7196. this.pdfHistory.back();
  7197. }
  7198. break;
  7199. case "GoForward":
  7200. if (this.pdfHistory) {
  7201. this.pdfHistory.forward();
  7202. }
  7203. break;
  7204. case "NextPage":
  7205. if (this.page < this.pagesCount) {
  7206. this.page++;
  7207. }
  7208. break;
  7209. case "PrevPage":
  7210. if (this.page > 1) {
  7211. this.page--;
  7212. }
  7213. break;
  7214. case "LastPage":
  7215. this.page = this.pagesCount;
  7216. break;
  7217. case "FirstPage":
  7218. this.page = 1;
  7219. break;
  7220. default:
  7221. break;
  7222. }
  7223. this.eventBus.dispatch("namedaction", {
  7224. source: this,
  7225. action: action
  7226. });
  7227. }
  7228. }, {
  7229. key: "cachePageRef",
  7230. value: function cachePageRef(pageNum, pageRef) {
  7231. if (!pageRef) {
  7232. return;
  7233. }
  7234. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  7235. this._pagesRefCache[refStr] = pageNum;
  7236. }
  7237. }, {
  7238. key: "_cachedPageNumber",
  7239. value: function _cachedPageNumber(pageRef) {
  7240. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  7241. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  7242. }
  7243. }, {
  7244. key: "isPageVisible",
  7245. value: function isPageVisible(pageNumber) {
  7246. return this.pdfViewer.isPageVisible(pageNumber);
  7247. }
  7248. }, {
  7249. key: "pagesCount",
  7250. get: function get() {
  7251. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  7252. }
  7253. }, {
  7254. key: "page",
  7255. get: function get() {
  7256. return this.pdfViewer.currentPageNumber;
  7257. },
  7258. set: function set(value) {
  7259. this.pdfViewer.currentPageNumber = value;
  7260. }
  7261. }, {
  7262. key: "rotation",
  7263. get: function get() {
  7264. return this.pdfViewer.pagesRotation;
  7265. },
  7266. set: function set(value) {
  7267. this.pdfViewer.pagesRotation = value;
  7268. }
  7269. }]);
  7270. return PDFLinkService;
  7271. }();
  7272. exports.PDFLinkService = PDFLinkService;
  7273. function isValidExplicitDestination(dest) {
  7274. if (!Array.isArray(dest)) {
  7275. return false;
  7276. }
  7277. var destLength = dest.length;
  7278. if (destLength < 2) {
  7279. return false;
  7280. }
  7281. var page = dest[0];
  7282. if (!(_typeof(page) === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  7283. return false;
  7284. }
  7285. var zoom = dest[1];
  7286. if (!(_typeof(zoom) === "object" && typeof zoom.name === "string")) {
  7287. return false;
  7288. }
  7289. var allowNull = true;
  7290. switch (zoom.name) {
  7291. case "XYZ":
  7292. if (destLength !== 5) {
  7293. return false;
  7294. }
  7295. break;
  7296. case "Fit":
  7297. case "FitB":
  7298. return destLength === 2;
  7299. case "FitH":
  7300. case "FitBH":
  7301. case "FitV":
  7302. case "FitBV":
  7303. if (destLength !== 3) {
  7304. return false;
  7305. }
  7306. break;
  7307. case "FitR":
  7308. if (destLength !== 6) {
  7309. return false;
  7310. }
  7311. allowNull = false;
  7312. break;
  7313. default:
  7314. return false;
  7315. }
  7316. for (var i = 2; i < destLength; i++) {
  7317. var param = dest[i];
  7318. if (!(typeof param === "number" || allowNull && param === null)) {
  7319. return false;
  7320. }
  7321. }
  7322. return true;
  7323. }
  7324. var SimpleLinkService = /*#__PURE__*/function () {
  7325. function SimpleLinkService() {
  7326. _classCallCheck(this, SimpleLinkService);
  7327. this.externalLinkTarget = null;
  7328. this.externalLinkRel = null;
  7329. this.externalLinkEnabled = true;
  7330. this._ignoreDestinationZoom = false;
  7331. }
  7332. _createClass(SimpleLinkService, [{
  7333. key: "navigateTo",
  7334. value: function navigateTo(dest) {}
  7335. }, {
  7336. key: "getDestinationHash",
  7337. value: function getDestinationHash(dest) {
  7338. return "#";
  7339. }
  7340. }, {
  7341. key: "getAnchorUrl",
  7342. value: function getAnchorUrl(hash) {
  7343. return "#";
  7344. }
  7345. }, {
  7346. key: "setHash",
  7347. value: function setHash(hash) {}
  7348. }, {
  7349. key: "executeNamedAction",
  7350. value: function executeNamedAction(action) {}
  7351. }, {
  7352. key: "cachePageRef",
  7353. value: function cachePageRef(pageNum, pageRef) {}
  7354. }, {
  7355. key: "isPageVisible",
  7356. value: function isPageVisible(pageNumber) {
  7357. return true;
  7358. }
  7359. }, {
  7360. key: "pagesCount",
  7361. get: function get() {
  7362. return 0;
  7363. }
  7364. }, {
  7365. key: "page",
  7366. get: function get() {
  7367. return 0;
  7368. },
  7369. set: function set(value) {}
  7370. }, {
  7371. key: "rotation",
  7372. get: function get() {
  7373. return 0;
  7374. },
  7375. set: function set(value) {}
  7376. }]);
  7377. return SimpleLinkService;
  7378. }();
  7379. exports.SimpleLinkService = SimpleLinkService;
  7380. /***/ }),
  7381. /* 22 */
  7382. /***/ (function(module, exports, __webpack_require__) {
  7383. "use strict";
  7384. Object.defineProperty(exports, "__esModule", {
  7385. value: true
  7386. });
  7387. exports.PDFOutlineViewer = void 0;
  7388. var _pdfjsLib = __webpack_require__(8);
  7389. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  7390. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  7391. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  7392. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7393. 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); } }
  7394. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7395. var DEFAULT_TITLE = "\u2013";
  7396. var PDFOutlineViewer = /*#__PURE__*/function () {
  7397. function PDFOutlineViewer(_ref) {
  7398. var container = _ref.container,
  7399. linkService = _ref.linkService,
  7400. eventBus = _ref.eventBus;
  7401. _classCallCheck(this, PDFOutlineViewer);
  7402. this.container = container;
  7403. this.linkService = linkService;
  7404. this.eventBus = eventBus;
  7405. this.reset();
  7406. eventBus._on("toggleoutlinetree", this.toggleOutlineTree.bind(this));
  7407. }
  7408. _createClass(PDFOutlineViewer, [{
  7409. key: "reset",
  7410. value: function reset() {
  7411. this.outline = null;
  7412. this.lastToggleIsShow = true;
  7413. this.container.textContent = "";
  7414. this.container.classList.remove("outlineWithDeepNesting");
  7415. }
  7416. }, {
  7417. key: "_dispatchEvent",
  7418. value: function _dispatchEvent(outlineCount) {
  7419. this.eventBus.dispatch("outlineloaded", {
  7420. source: this,
  7421. outlineCount: outlineCount
  7422. });
  7423. }
  7424. }, {
  7425. key: "_bindLink",
  7426. value: function _bindLink(element, _ref2) {
  7427. var url = _ref2.url,
  7428. newWindow = _ref2.newWindow,
  7429. dest = _ref2.dest;
  7430. var linkService = this.linkService;
  7431. if (url) {
  7432. (0, _pdfjsLib.addLinkAttributes)(element, {
  7433. url: url,
  7434. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
  7435. rel: linkService.externalLinkRel,
  7436. enabled: linkService.externalLinkEnabled
  7437. });
  7438. return;
  7439. }
  7440. element.href = linkService.getDestinationHash(dest);
  7441. element.onclick = function () {
  7442. if (dest) {
  7443. linkService.navigateTo(dest);
  7444. }
  7445. return false;
  7446. };
  7447. }
  7448. }, {
  7449. key: "_setStyles",
  7450. value: function _setStyles(element, _ref3) {
  7451. var bold = _ref3.bold,
  7452. italic = _ref3.italic;
  7453. if (bold) {
  7454. element.style.fontWeight = "bold";
  7455. }
  7456. if (italic) {
  7457. element.style.fontStyle = "italic";
  7458. }
  7459. }
  7460. }, {
  7461. key: "_addToggleButton",
  7462. value: function _addToggleButton(div, _ref4) {
  7463. var _this = this;
  7464. var count = _ref4.count,
  7465. items = _ref4.items;
  7466. var toggler = document.createElement("div");
  7467. toggler.className = "outlineItemToggler";
  7468. if (count < 0 && Math.abs(count) === items.length) {
  7469. toggler.classList.add("outlineItemsHidden");
  7470. }
  7471. toggler.onclick = function (evt) {
  7472. evt.stopPropagation();
  7473. toggler.classList.toggle("outlineItemsHidden");
  7474. if (evt.shiftKey) {
  7475. var shouldShowAll = !toggler.classList.contains("outlineItemsHidden");
  7476. _this._toggleOutlineItem(div, shouldShowAll);
  7477. }
  7478. };
  7479. div.insertBefore(toggler, div.firstChild);
  7480. }
  7481. }, {
  7482. key: "_toggleOutlineItem",
  7483. value: function _toggleOutlineItem(root) {
  7484. var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7485. this.lastToggleIsShow = show;
  7486. var _iterator = _createForOfIteratorHelper(root.querySelectorAll(".outlineItemToggler")),
  7487. _step;
  7488. try {
  7489. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7490. var toggler = _step.value;
  7491. toggler.classList.toggle("outlineItemsHidden", !show);
  7492. }
  7493. } catch (err) {
  7494. _iterator.e(err);
  7495. } finally {
  7496. _iterator.f();
  7497. }
  7498. }
  7499. }, {
  7500. key: "toggleOutlineTree",
  7501. value: function toggleOutlineTree() {
  7502. if (!this.outline) {
  7503. return;
  7504. }
  7505. this._toggleOutlineItem(this.container, !this.lastToggleIsShow);
  7506. }
  7507. }, {
  7508. key: "render",
  7509. value: function render(_ref5) {
  7510. var outline = _ref5.outline;
  7511. var outlineCount = 0;
  7512. if (this.outline) {
  7513. this.reset();
  7514. }
  7515. this.outline = outline || null;
  7516. if (!outline) {
  7517. this._dispatchEvent(outlineCount);
  7518. return;
  7519. }
  7520. var fragment = document.createDocumentFragment();
  7521. var queue = [{
  7522. parent: fragment,
  7523. items: this.outline
  7524. }];
  7525. var hasAnyNesting = false;
  7526. while (queue.length > 0) {
  7527. var levelData = queue.shift();
  7528. var _iterator2 = _createForOfIteratorHelper(levelData.items),
  7529. _step2;
  7530. try {
  7531. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  7532. var item = _step2.value;
  7533. var div = document.createElement("div");
  7534. div.className = "outlineItem";
  7535. var element = document.createElement("a");
  7536. this._bindLink(element, item);
  7537. this._setStyles(element, item);
  7538. element.textContent = (0, _pdfjsLib.removeNullCharacters)(item.title) || DEFAULT_TITLE;
  7539. div.appendChild(element);
  7540. if (item.items.length > 0) {
  7541. hasAnyNesting = true;
  7542. this._addToggleButton(div, item);
  7543. var itemsDiv = document.createElement("div");
  7544. itemsDiv.className = "outlineItems";
  7545. div.appendChild(itemsDiv);
  7546. queue.push({
  7547. parent: itemsDiv,
  7548. items: item.items
  7549. });
  7550. }
  7551. levelData.parent.appendChild(div);
  7552. outlineCount++;
  7553. }
  7554. } catch (err) {
  7555. _iterator2.e(err);
  7556. } finally {
  7557. _iterator2.f();
  7558. }
  7559. }
  7560. if (hasAnyNesting) {
  7561. this.container.classList.add("outlineWithDeepNesting");
  7562. this.lastToggleIsShow = fragment.querySelectorAll(".outlineItemsHidden").length === 0;
  7563. }
  7564. this.container.appendChild(fragment);
  7565. this._dispatchEvent(outlineCount);
  7566. }
  7567. }]);
  7568. return PDFOutlineViewer;
  7569. }();
  7570. exports.PDFOutlineViewer = PDFOutlineViewer;
  7571. /***/ }),
  7572. /* 23 */
  7573. /***/ (function(module, exports, __webpack_require__) {
  7574. "use strict";
  7575. Object.defineProperty(exports, "__esModule", {
  7576. value: true
  7577. });
  7578. exports.PDFPresentationMode = void 0;
  7579. var _ui_utils = __webpack_require__(5);
  7580. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7581. 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); } }
  7582. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7583. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  7584. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  7585. var ACTIVE_SELECTOR = "pdfPresentationMode";
  7586. var CONTROLS_SELECTOR = "pdfPresentationModeControls";
  7587. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  7588. var PAGE_SWITCH_THRESHOLD = 0.1;
  7589. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  7590. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  7591. var PDFPresentationMode = /*#__PURE__*/function () {
  7592. function PDFPresentationMode(_ref) {
  7593. var _this = this;
  7594. var container = _ref.container,
  7595. pdfViewer = _ref.pdfViewer,
  7596. eventBus = _ref.eventBus,
  7597. _ref$contextMenuItems = _ref.contextMenuItems,
  7598. contextMenuItems = _ref$contextMenuItems === void 0 ? null : _ref$contextMenuItems;
  7599. _classCallCheck(this, PDFPresentationMode);
  7600. this.container = container;
  7601. this.pdfViewer = pdfViewer;
  7602. this.eventBus = eventBus;
  7603. this.active = false;
  7604. this.args = null;
  7605. this.contextMenuOpen = false;
  7606. this.mouseScrollTimeStamp = 0;
  7607. this.mouseScrollDelta = 0;
  7608. this.touchSwipeState = null;
  7609. if (contextMenuItems) {
  7610. contextMenuItems.contextFirstPage.addEventListener("click", function () {
  7611. _this.contextMenuOpen = false;
  7612. _this.eventBus.dispatch("firstpage", {
  7613. source: _this
  7614. });
  7615. });
  7616. contextMenuItems.contextLastPage.addEventListener("click", function () {
  7617. _this.contextMenuOpen = false;
  7618. _this.eventBus.dispatch("lastpage", {
  7619. source: _this
  7620. });
  7621. });
  7622. contextMenuItems.contextPageRotateCw.addEventListener("click", function () {
  7623. _this.contextMenuOpen = false;
  7624. _this.eventBus.dispatch("rotatecw", {
  7625. source: _this
  7626. });
  7627. });
  7628. contextMenuItems.contextPageRotateCcw.addEventListener("click", function () {
  7629. _this.contextMenuOpen = false;
  7630. _this.eventBus.dispatch("rotateccw", {
  7631. source: _this
  7632. });
  7633. });
  7634. }
  7635. }
  7636. _createClass(PDFPresentationMode, [{
  7637. key: "request",
  7638. value: function request() {
  7639. if (this.switchInProgress || this.active || !this.pdfViewer.pagesCount) {
  7640. return false;
  7641. }
  7642. this._addFullscreenChangeListeners();
  7643. this._setSwitchInProgress();
  7644. this._notifyStateChange();
  7645. if (this.container.requestFullscreen) {
  7646. this.container.requestFullscreen();
  7647. } else if (this.container.mozRequestFullScreen) {
  7648. this.container.mozRequestFullScreen();
  7649. } else if (this.container.webkitRequestFullscreen) {
  7650. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  7651. } else if (this.container.msRequestFullscreen) {
  7652. this.container.msRequestFullscreen();
  7653. } else {
  7654. return false;
  7655. }
  7656. this.args = {
  7657. page: this.pdfViewer.currentPageNumber,
  7658. previousScale: this.pdfViewer.currentScaleValue
  7659. };
  7660. return true;
  7661. }
  7662. }, {
  7663. key: "_mouseWheel",
  7664. value: function _mouseWheel(evt) {
  7665. if (!this.active) {
  7666. return;
  7667. }
  7668. evt.preventDefault();
  7669. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  7670. var currentTime = new Date().getTime();
  7671. var storedTime = this.mouseScrollTimeStamp;
  7672. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  7673. return;
  7674. }
  7675. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  7676. this._resetMouseScrollState();
  7677. }
  7678. this.mouseScrollDelta += delta;
  7679. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  7680. var totalDelta = this.mouseScrollDelta;
  7681. this._resetMouseScrollState();
  7682. var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
  7683. if (success) {
  7684. this.mouseScrollTimeStamp = currentTime;
  7685. }
  7686. }
  7687. }
  7688. }, {
  7689. key: "_goToPreviousPage",
  7690. value: function _goToPreviousPage() {
  7691. var page = this.pdfViewer.currentPageNumber;
  7692. if (page <= 1) {
  7693. return false;
  7694. }
  7695. this.pdfViewer.currentPageNumber = page - 1;
  7696. return true;
  7697. }
  7698. }, {
  7699. key: "_goToNextPage",
  7700. value: function _goToNextPage() {
  7701. var page = this.pdfViewer.currentPageNumber;
  7702. if (page >= this.pdfViewer.pagesCount) {
  7703. return false;
  7704. }
  7705. this.pdfViewer.currentPageNumber = page + 1;
  7706. return true;
  7707. }
  7708. }, {
  7709. key: "_notifyStateChange",
  7710. value: function _notifyStateChange() {
  7711. this.eventBus.dispatch("presentationmodechanged", {
  7712. source: this,
  7713. active: this.active,
  7714. switchInProgress: !!this.switchInProgress
  7715. });
  7716. }
  7717. }, {
  7718. key: "_setSwitchInProgress",
  7719. value: function _setSwitchInProgress() {
  7720. var _this2 = this;
  7721. if (this.switchInProgress) {
  7722. clearTimeout(this.switchInProgress);
  7723. }
  7724. this.switchInProgress = setTimeout(function () {
  7725. _this2._removeFullscreenChangeListeners();
  7726. delete _this2.switchInProgress;
  7727. _this2._notifyStateChange();
  7728. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  7729. }
  7730. }, {
  7731. key: "_resetSwitchInProgress",
  7732. value: function _resetSwitchInProgress() {
  7733. if (this.switchInProgress) {
  7734. clearTimeout(this.switchInProgress);
  7735. delete this.switchInProgress;
  7736. }
  7737. }
  7738. }, {
  7739. key: "_enter",
  7740. value: function _enter() {
  7741. var _this3 = this;
  7742. this.active = true;
  7743. this._resetSwitchInProgress();
  7744. this._notifyStateChange();
  7745. this.container.classList.add(ACTIVE_SELECTOR);
  7746. setTimeout(function () {
  7747. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  7748. _this3.pdfViewer.currentScaleValue = "page-fit";
  7749. }, 0);
  7750. this._addWindowListeners();
  7751. this._showControls();
  7752. this.contextMenuOpen = false;
  7753. this.container.setAttribute("contextmenu", "viewerContextMenu");
  7754. window.getSelection().removeAllRanges();
  7755. }
  7756. }, {
  7757. key: "_exit",
  7758. value: function _exit() {
  7759. var _this4 = this;
  7760. var page = this.pdfViewer.currentPageNumber;
  7761. this.container.classList.remove(ACTIVE_SELECTOR);
  7762. setTimeout(function () {
  7763. _this4.active = false;
  7764. _this4._removeFullscreenChangeListeners();
  7765. _this4._notifyStateChange();
  7766. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  7767. _this4.pdfViewer.currentPageNumber = page;
  7768. _this4.args = null;
  7769. }, 0);
  7770. this._removeWindowListeners();
  7771. this._hideControls();
  7772. this._resetMouseScrollState();
  7773. this.container.removeAttribute("contextmenu");
  7774. this.contextMenuOpen = false;
  7775. }
  7776. }, {
  7777. key: "_mouseDown",
  7778. value: function _mouseDown(evt) {
  7779. if (this.contextMenuOpen) {
  7780. this.contextMenuOpen = false;
  7781. evt.preventDefault();
  7782. return;
  7783. }
  7784. if (evt.button === 0) {
  7785. var isInternalLink = evt.target.href && evt.target.classList.contains("internalLink");
  7786. if (!isInternalLink) {
  7787. evt.preventDefault();
  7788. if (evt.shiftKey) {
  7789. this._goToPreviousPage();
  7790. } else {
  7791. this._goToNextPage();
  7792. }
  7793. }
  7794. }
  7795. }
  7796. }, {
  7797. key: "_contextMenu",
  7798. value: function _contextMenu() {
  7799. this.contextMenuOpen = true;
  7800. }
  7801. }, {
  7802. key: "_showControls",
  7803. value: function _showControls() {
  7804. var _this5 = this;
  7805. if (this.controlsTimeout) {
  7806. clearTimeout(this.controlsTimeout);
  7807. } else {
  7808. this.container.classList.add(CONTROLS_SELECTOR);
  7809. }
  7810. this.controlsTimeout = setTimeout(function () {
  7811. _this5.container.classList.remove(CONTROLS_SELECTOR);
  7812. delete _this5.controlsTimeout;
  7813. }, DELAY_BEFORE_HIDING_CONTROLS);
  7814. }
  7815. }, {
  7816. key: "_hideControls",
  7817. value: function _hideControls() {
  7818. if (!this.controlsTimeout) {
  7819. return;
  7820. }
  7821. clearTimeout(this.controlsTimeout);
  7822. this.container.classList.remove(CONTROLS_SELECTOR);
  7823. delete this.controlsTimeout;
  7824. }
  7825. }, {
  7826. key: "_resetMouseScrollState",
  7827. value: function _resetMouseScrollState() {
  7828. this.mouseScrollTimeStamp = 0;
  7829. this.mouseScrollDelta = 0;
  7830. }
  7831. }, {
  7832. key: "_touchSwipe",
  7833. value: function _touchSwipe(evt) {
  7834. if (!this.active) {
  7835. return;
  7836. }
  7837. if (evt.touches.length > 1) {
  7838. this.touchSwipeState = null;
  7839. return;
  7840. }
  7841. switch (evt.type) {
  7842. case "touchstart":
  7843. this.touchSwipeState = {
  7844. startX: evt.touches[0].pageX,
  7845. startY: evt.touches[0].pageY,
  7846. endX: evt.touches[0].pageX,
  7847. endY: evt.touches[0].pageY
  7848. };
  7849. break;
  7850. case "touchmove":
  7851. if (this.touchSwipeState === null) {
  7852. return;
  7853. }
  7854. this.touchSwipeState.endX = evt.touches[0].pageX;
  7855. this.touchSwipeState.endY = evt.touches[0].pageY;
  7856. evt.preventDefault();
  7857. break;
  7858. case "touchend":
  7859. if (this.touchSwipeState === null) {
  7860. return;
  7861. }
  7862. var delta = 0;
  7863. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  7864. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  7865. var absAngle = Math.abs(Math.atan2(dy, dx));
  7866. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  7867. delta = dx;
  7868. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  7869. delta = dy;
  7870. }
  7871. if (delta > 0) {
  7872. this._goToPreviousPage();
  7873. } else if (delta < 0) {
  7874. this._goToNextPage();
  7875. }
  7876. break;
  7877. }
  7878. }
  7879. }, {
  7880. key: "_addWindowListeners",
  7881. value: function _addWindowListeners() {
  7882. this.showControlsBind = this._showControls.bind(this);
  7883. this.mouseDownBind = this._mouseDown.bind(this);
  7884. this.mouseWheelBind = this._mouseWheel.bind(this);
  7885. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  7886. this.contextMenuBind = this._contextMenu.bind(this);
  7887. this.touchSwipeBind = this._touchSwipe.bind(this);
  7888. window.addEventListener("mousemove", this.showControlsBind);
  7889. window.addEventListener("mousedown", this.mouseDownBind);
  7890. window.addEventListener("wheel", this.mouseWheelBind, {
  7891. passive: false
  7892. });
  7893. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  7894. window.addEventListener("contextmenu", this.contextMenuBind);
  7895. window.addEventListener("touchstart", this.touchSwipeBind);
  7896. window.addEventListener("touchmove", this.touchSwipeBind);
  7897. window.addEventListener("touchend", this.touchSwipeBind);
  7898. }
  7899. }, {
  7900. key: "_removeWindowListeners",
  7901. value: function _removeWindowListeners() {
  7902. window.removeEventListener("mousemove", this.showControlsBind);
  7903. window.removeEventListener("mousedown", this.mouseDownBind);
  7904. window.removeEventListener("wheel", this.mouseWheelBind, {
  7905. passive: false
  7906. });
  7907. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  7908. window.removeEventListener("contextmenu", this.contextMenuBind);
  7909. window.removeEventListener("touchstart", this.touchSwipeBind);
  7910. window.removeEventListener("touchmove", this.touchSwipeBind);
  7911. window.removeEventListener("touchend", this.touchSwipeBind);
  7912. delete this.showControlsBind;
  7913. delete this.mouseDownBind;
  7914. delete this.mouseWheelBind;
  7915. delete this.resetMouseScrollStateBind;
  7916. delete this.contextMenuBind;
  7917. delete this.touchSwipeBind;
  7918. }
  7919. }, {
  7920. key: "_fullscreenChange",
  7921. value: function _fullscreenChange() {
  7922. if (this.isFullscreen) {
  7923. this._enter();
  7924. } else {
  7925. this._exit();
  7926. }
  7927. }
  7928. }, {
  7929. key: "_addFullscreenChangeListeners",
  7930. value: function _addFullscreenChangeListeners() {
  7931. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  7932. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  7933. window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  7934. window.addEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  7935. window.addEventListener("MSFullscreenChange", this.fullscreenChangeBind);
  7936. }
  7937. }, {
  7938. key: "_removeFullscreenChangeListeners",
  7939. value: function _removeFullscreenChangeListeners() {
  7940. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  7941. window.removeEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  7942. window.removeEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  7943. window.removeEventListener("MSFullscreenChange", this.fullscreenChangeBind);
  7944. delete this.fullscreenChangeBind;
  7945. }
  7946. }, {
  7947. key: "isFullscreen",
  7948. get: function get() {
  7949. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
  7950. }
  7951. }]);
  7952. return PDFPresentationMode;
  7953. }();
  7954. exports.PDFPresentationMode = PDFPresentationMode;
  7955. /***/ }),
  7956. /* 24 */
  7957. /***/ (function(module, exports, __webpack_require__) {
  7958. "use strict";
  7959. Object.defineProperty(exports, "__esModule", {
  7960. value: true
  7961. });
  7962. exports.PDFSidebarResizer = void 0;
  7963. var _ui_utils = __webpack_require__(5);
  7964. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7965. 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); } }
  7966. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7967. var SIDEBAR_WIDTH_VAR = "--sidebar-width";
  7968. var SIDEBAR_MIN_WIDTH = 200;
  7969. var SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  7970. var PDFSidebarResizer = /*#__PURE__*/function () {
  7971. function PDFSidebarResizer(options, eventBus) {
  7972. var _this = this;
  7973. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  7974. _classCallCheck(this, PDFSidebarResizer);
  7975. this.enabled = false;
  7976. this.isRTL = false;
  7977. this.sidebarOpen = false;
  7978. this.doc = document.documentElement;
  7979. this._width = null;
  7980. this._outerContainerWidth = null;
  7981. this._boundEvents = Object.create(null);
  7982. this.outerContainer = options.outerContainer;
  7983. this.resizer = options.resizer;
  7984. this.eventBus = eventBus;
  7985. this.l10n = l10n;
  7986. if (typeof CSS === "undefined" || typeof CSS.supports !== "function" || !CSS.supports(SIDEBAR_WIDTH_VAR, "calc(-1 * ".concat(SIDEBAR_MIN_WIDTH, "px)"))) {
  7987. console.warn("PDFSidebarResizer: " + "The browser does not support resizing of the sidebar.");
  7988. return;
  7989. }
  7990. this.enabled = true;
  7991. this.resizer.classList.remove("hidden");
  7992. this.l10n.getDirection().then(function (dir) {
  7993. _this.isRTL = dir === "rtl";
  7994. });
  7995. this._addEventListeners();
  7996. }
  7997. _createClass(PDFSidebarResizer, [{
  7998. key: "_updateWidth",
  7999. value: function _updateWidth() {
  8000. var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  8001. if (!this.enabled) {
  8002. return false;
  8003. }
  8004. var newWidth = (0, _ui_utils.clamp)(width, SIDEBAR_MIN_WIDTH, Math.floor(this.outerContainerWidth / 2));
  8005. if (newWidth === this._width) {
  8006. return false;
  8007. }
  8008. this._width = newWidth;
  8009. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(newWidth, "px"));
  8010. return true;
  8011. }
  8012. }, {
  8013. key: "_mouseMove",
  8014. value: function _mouseMove(evt) {
  8015. var width = evt.clientX;
  8016. if (this.isRTL) {
  8017. width = this.outerContainerWidth - width;
  8018. }
  8019. this._updateWidth(width);
  8020. }
  8021. }, {
  8022. key: "_mouseUp",
  8023. value: function _mouseUp(evt) {
  8024. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  8025. this.eventBus.dispatch("resize", {
  8026. source: this
  8027. });
  8028. var _boundEvents = this._boundEvents;
  8029. window.removeEventListener("mousemove", _boundEvents.mouseMove);
  8030. window.removeEventListener("mouseup", _boundEvents.mouseUp);
  8031. }
  8032. }, {
  8033. key: "_addEventListeners",
  8034. value: function _addEventListeners() {
  8035. var _this2 = this;
  8036. if (!this.enabled) {
  8037. return;
  8038. }
  8039. var _boundEvents = this._boundEvents;
  8040. _boundEvents.mouseMove = this._mouseMove.bind(this);
  8041. _boundEvents.mouseUp = this._mouseUp.bind(this);
  8042. this.resizer.addEventListener("mousedown", function (evt) {
  8043. if (evt.button !== 0) {
  8044. return;
  8045. }
  8046. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  8047. window.addEventListener("mousemove", _boundEvents.mouseMove);
  8048. window.addEventListener("mouseup", _boundEvents.mouseUp);
  8049. });
  8050. this.eventBus._on("sidebarviewchanged", function (evt) {
  8051. _this2.sidebarOpen = !!(evt && evt.view);
  8052. });
  8053. this.eventBus._on("resize", function (evt) {
  8054. if (!evt || evt.source !== window) {
  8055. return;
  8056. }
  8057. _this2._outerContainerWidth = null;
  8058. if (!_this2._width) {
  8059. return;
  8060. }
  8061. if (!_this2.sidebarOpen) {
  8062. _this2._updateWidth(_this2._width);
  8063. return;
  8064. }
  8065. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  8066. var updated = _this2._updateWidth(_this2._width);
  8067. Promise.resolve().then(function () {
  8068. _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  8069. if (updated) {
  8070. _this2.eventBus.dispatch("resize", {
  8071. source: _this2
  8072. });
  8073. }
  8074. });
  8075. });
  8076. }
  8077. }, {
  8078. key: "outerContainerWidth",
  8079. get: function get() {
  8080. if (!this._outerContainerWidth) {
  8081. this._outerContainerWidth = this.outerContainer.clientWidth;
  8082. }
  8083. return this._outerContainerWidth;
  8084. }
  8085. }]);
  8086. return PDFSidebarResizer;
  8087. }();
  8088. exports.PDFSidebarResizer = PDFSidebarResizer;
  8089. /***/ }),
  8090. /* 25 */
  8091. /***/ (function(module, exports, __webpack_require__) {
  8092. "use strict";
  8093. Object.defineProperty(exports, "__esModule", {
  8094. value: true
  8095. });
  8096. exports.PDFThumbnailViewer = void 0;
  8097. var _ui_utils = __webpack_require__(5);
  8098. var _pdf_thumbnail_view = __webpack_require__(26);
  8099. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8100. 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); } }
  8101. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8102. var THUMBNAIL_SCROLL_MARGIN = -19;
  8103. var THUMBNAIL_SELECTED_CLASS = "selected";
  8104. var PDFThumbnailViewer = /*#__PURE__*/function () {
  8105. function PDFThumbnailViewer(_ref) {
  8106. var container = _ref.container,
  8107. linkService = _ref.linkService,
  8108. renderingQueue = _ref.renderingQueue,
  8109. _ref$l10n = _ref.l10n,
  8110. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  8111. _classCallCheck(this, PDFThumbnailViewer);
  8112. this.container = container;
  8113. this.linkService = linkService;
  8114. this.renderingQueue = renderingQueue;
  8115. this.l10n = l10n;
  8116. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  8117. this._resetView();
  8118. }
  8119. _createClass(PDFThumbnailViewer, [{
  8120. key: "_scrollUpdated",
  8121. value: function _scrollUpdated() {
  8122. this.renderingQueue.renderHighestPriority();
  8123. }
  8124. }, {
  8125. key: "getThumbnail",
  8126. value: function getThumbnail(index) {
  8127. return this._thumbnails[index];
  8128. }
  8129. }, {
  8130. key: "_getVisibleThumbs",
  8131. value: function _getVisibleThumbs() {
  8132. return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
  8133. }
  8134. }, {
  8135. key: "scrollThumbnailIntoView",
  8136. value: function scrollThumbnailIntoView(pageNumber) {
  8137. if (!this.pdfDocument) {
  8138. return;
  8139. }
  8140. var thumbnailView = this._thumbnails[pageNumber - 1];
  8141. if (!thumbnailView) {
  8142. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  8143. return;
  8144. }
  8145. if (pageNumber !== this._currentPageNumber) {
  8146. var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  8147. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  8148. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  8149. }
  8150. var visibleThumbs = this._getVisibleThumbs();
  8151. var numVisibleThumbs = visibleThumbs.views.length;
  8152. if (numVisibleThumbs > 0) {
  8153. var first = visibleThumbs.first.id;
  8154. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  8155. var shouldScroll = false;
  8156. if (pageNumber <= first || pageNumber >= last) {
  8157. shouldScroll = true;
  8158. } else {
  8159. visibleThumbs.views.some(function (view) {
  8160. if (view.id !== pageNumber) {
  8161. return false;
  8162. }
  8163. shouldScroll = view.percent < 100;
  8164. return true;
  8165. });
  8166. }
  8167. if (shouldScroll) {
  8168. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  8169. top: THUMBNAIL_SCROLL_MARGIN
  8170. });
  8171. }
  8172. }
  8173. this._currentPageNumber = pageNumber;
  8174. }
  8175. }, {
  8176. key: "cleanup",
  8177. value: function cleanup() {
  8178. _pdf_thumbnail_view.PDFThumbnailView.cleanup();
  8179. }
  8180. }, {
  8181. key: "_resetView",
  8182. value: function _resetView() {
  8183. this._thumbnails = [];
  8184. this._currentPageNumber = 1;
  8185. this._pageLabels = null;
  8186. this._pagesRotation = 0;
  8187. this._pagesRequests = new WeakMap();
  8188. this.container.textContent = "";
  8189. }
  8190. }, {
  8191. key: "setDocument",
  8192. value: function setDocument(pdfDocument) {
  8193. var _this = this;
  8194. if (this.pdfDocument) {
  8195. this._cancelRendering();
  8196. this._resetView();
  8197. }
  8198. this.pdfDocument = pdfDocument;
  8199. if (!pdfDocument) {
  8200. return;
  8201. }
  8202. pdfDocument.getPage(1).then(function (firstPdfPage) {
  8203. var pagesCount = pdfDocument.numPages;
  8204. var viewport = firstPdfPage.getViewport({
  8205. scale: 1
  8206. });
  8207. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8208. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  8209. container: _this.container,
  8210. id: pageNum,
  8211. defaultViewport: viewport.clone(),
  8212. linkService: _this.linkService,
  8213. renderingQueue: _this.renderingQueue,
  8214. disableCanvasToImageConversion: false,
  8215. l10n: _this.l10n
  8216. });
  8217. _this._thumbnails.push(thumbnail);
  8218. }
  8219. var firstThumbnailView = _this._thumbnails[0];
  8220. if (firstThumbnailView) {
  8221. firstThumbnailView.setPdfPage(firstPdfPage);
  8222. }
  8223. var thumbnailView = _this._thumbnails[_this._currentPageNumber - 1];
  8224. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  8225. })["catch"](function (reason) {
  8226. console.error("Unable to initialize thumbnail viewer", reason);
  8227. });
  8228. }
  8229. }, {
  8230. key: "_cancelRendering",
  8231. value: function _cancelRendering() {
  8232. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8233. if (this._thumbnails[i]) {
  8234. this._thumbnails[i].cancelRendering();
  8235. }
  8236. }
  8237. }
  8238. }, {
  8239. key: "setPageLabels",
  8240. value: function setPageLabels(labels) {
  8241. if (!this.pdfDocument) {
  8242. return;
  8243. }
  8244. if (!labels) {
  8245. this._pageLabels = null;
  8246. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  8247. this._pageLabels = null;
  8248. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  8249. } else {
  8250. this._pageLabels = labels;
  8251. }
  8252. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8253. var label = this._pageLabels && this._pageLabels[i];
  8254. this._thumbnails[i].setPageLabel(label);
  8255. }
  8256. }
  8257. }, {
  8258. key: "_ensurePdfPageLoaded",
  8259. value: function _ensurePdfPageLoaded(thumbView) {
  8260. var _this2 = this;
  8261. if (thumbView.pdfPage) {
  8262. return Promise.resolve(thumbView.pdfPage);
  8263. }
  8264. if (this._pagesRequests.has(thumbView)) {
  8265. return this._pagesRequests.get(thumbView);
  8266. }
  8267. var promise = this.pdfDocument.getPage(thumbView.id).then(function (pdfPage) {
  8268. if (!thumbView.pdfPage) {
  8269. thumbView.setPdfPage(pdfPage);
  8270. }
  8271. _this2._pagesRequests["delete"](thumbView);
  8272. return pdfPage;
  8273. })["catch"](function (reason) {
  8274. console.error("Unable to get page for thumb view", reason);
  8275. _this2._pagesRequests["delete"](thumbView);
  8276. });
  8277. this._pagesRequests.set(thumbView, promise);
  8278. return promise;
  8279. }
  8280. }, {
  8281. key: "forceRendering",
  8282. value: function forceRendering() {
  8283. var _this3 = this;
  8284. var visibleThumbs = this._getVisibleThumbs();
  8285. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  8286. if (thumbView) {
  8287. this._ensurePdfPageLoaded(thumbView).then(function () {
  8288. _this3.renderingQueue.renderView(thumbView);
  8289. });
  8290. return true;
  8291. }
  8292. return false;
  8293. }
  8294. }, {
  8295. key: "pagesRotation",
  8296. get: function get() {
  8297. return this._pagesRotation;
  8298. },
  8299. set: function set(rotation) {
  8300. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  8301. throw new Error("Invalid thumbnails rotation angle.");
  8302. }
  8303. if (!this.pdfDocument) {
  8304. return;
  8305. }
  8306. if (this._pagesRotation === rotation) {
  8307. return;
  8308. }
  8309. this._pagesRotation = rotation;
  8310. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8311. this._thumbnails[i].update(rotation);
  8312. }
  8313. }
  8314. }]);
  8315. return PDFThumbnailViewer;
  8316. }();
  8317. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  8318. /***/ }),
  8319. /* 26 */
  8320. /***/ (function(module, exports, __webpack_require__) {
  8321. "use strict";
  8322. Object.defineProperty(exports, "__esModule", {
  8323. value: true
  8324. });
  8325. exports.PDFThumbnailView = void 0;
  8326. var _pdfjsLib = __webpack_require__(8);
  8327. var _ui_utils = __webpack_require__(5);
  8328. var _pdf_rendering_queue = __webpack_require__(11);
  8329. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8330. 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); } }
  8331. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8332. var MAX_NUM_SCALING_STEPS = 3;
  8333. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  8334. var THUMBNAIL_WIDTH = 98;
  8335. var TempImageFactory = function TempImageFactoryClosure() {
  8336. var tempCanvasCache = null;
  8337. return {
  8338. getCanvas: function getCanvas(width, height) {
  8339. var tempCanvas = tempCanvasCache;
  8340. if (!tempCanvas) {
  8341. tempCanvas = document.createElement("canvas");
  8342. tempCanvasCache = tempCanvas;
  8343. }
  8344. tempCanvas.width = width;
  8345. tempCanvas.height = height;
  8346. tempCanvas.mozOpaque = true;
  8347. var ctx = tempCanvas.getContext("2d", {
  8348. alpha: false
  8349. });
  8350. ctx.save();
  8351. ctx.fillStyle = "rgb(255, 255, 255)";
  8352. ctx.fillRect(0, 0, width, height);
  8353. ctx.restore();
  8354. return tempCanvas;
  8355. },
  8356. destroyCanvas: function destroyCanvas() {
  8357. var tempCanvas = tempCanvasCache;
  8358. if (tempCanvas) {
  8359. tempCanvas.width = 0;
  8360. tempCanvas.height = 0;
  8361. }
  8362. tempCanvasCache = null;
  8363. }
  8364. };
  8365. }();
  8366. var PDFThumbnailView = /*#__PURE__*/function () {
  8367. function PDFThumbnailView(_ref) {
  8368. var container = _ref.container,
  8369. id = _ref.id,
  8370. defaultViewport = _ref.defaultViewport,
  8371. linkService = _ref.linkService,
  8372. renderingQueue = _ref.renderingQueue,
  8373. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  8374. disableCanvasToImageConversion = _ref$disableCanvasToI === void 0 ? false : _ref$disableCanvasToI,
  8375. _ref$l10n = _ref.l10n,
  8376. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  8377. _classCallCheck(this, PDFThumbnailView);
  8378. this.id = id;
  8379. this.renderingId = "thumbnail" + id;
  8380. this.pageLabel = null;
  8381. this.pdfPage = null;
  8382. this.rotation = 0;
  8383. this.viewport = defaultViewport;
  8384. this.pdfPageRotate = defaultViewport.rotation;
  8385. this.linkService = linkService;
  8386. this.renderingQueue = renderingQueue;
  8387. this.renderTask = null;
  8388. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8389. this.resume = null;
  8390. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  8391. this.pageWidth = this.viewport.width;
  8392. this.pageHeight = this.viewport.height;
  8393. this.pageRatio = this.pageWidth / this.pageHeight;
  8394. this.canvasWidth = THUMBNAIL_WIDTH;
  8395. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  8396. this.scale = this.canvasWidth / this.pageWidth;
  8397. this.l10n = l10n;
  8398. var anchor = document.createElement("a");
  8399. anchor.href = linkService.getAnchorUrl("#page=" + id);
  8400. this._thumbPageTitle.then(function (msg) {
  8401. anchor.title = msg;
  8402. });
  8403. anchor.onclick = function () {
  8404. linkService.page = id;
  8405. return false;
  8406. };
  8407. this.anchor = anchor;
  8408. var div = document.createElement("div");
  8409. div.className = "thumbnail";
  8410. div.setAttribute("data-page-number", this.id);
  8411. this.div = div;
  8412. var ring = document.createElement("div");
  8413. ring.className = "thumbnailSelectionRing";
  8414. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8415. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  8416. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  8417. this.ring = ring;
  8418. div.appendChild(ring);
  8419. anchor.appendChild(div);
  8420. container.appendChild(anchor);
  8421. }
  8422. _createClass(PDFThumbnailView, [{
  8423. key: "setPdfPage",
  8424. value: function setPdfPage(pdfPage) {
  8425. this.pdfPage = pdfPage;
  8426. this.pdfPageRotate = pdfPage.rotate;
  8427. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8428. this.viewport = pdfPage.getViewport({
  8429. scale: 1,
  8430. rotation: totalRotation
  8431. });
  8432. this.reset();
  8433. }
  8434. }, {
  8435. key: "reset",
  8436. value: function reset() {
  8437. this.cancelRendering();
  8438. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8439. this.pageWidth = this.viewport.width;
  8440. this.pageHeight = this.viewport.height;
  8441. this.pageRatio = this.pageWidth / this.pageHeight;
  8442. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  8443. this.scale = this.canvasWidth / this.pageWidth;
  8444. this.div.removeAttribute("data-loaded");
  8445. var ring = this.ring;
  8446. var childNodes = ring.childNodes;
  8447. for (var i = childNodes.length - 1; i >= 0; i--) {
  8448. ring.removeChild(childNodes[i]);
  8449. }
  8450. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8451. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  8452. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  8453. if (this.canvas) {
  8454. this.canvas.width = 0;
  8455. this.canvas.height = 0;
  8456. delete this.canvas;
  8457. }
  8458. if (this.image) {
  8459. this.image.removeAttribute("src");
  8460. delete this.image;
  8461. }
  8462. }
  8463. }, {
  8464. key: "update",
  8465. value: function update(rotation) {
  8466. if (typeof rotation !== "undefined") {
  8467. this.rotation = rotation;
  8468. }
  8469. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8470. this.viewport = this.viewport.clone({
  8471. scale: 1,
  8472. rotation: totalRotation
  8473. });
  8474. this.reset();
  8475. }
  8476. }, {
  8477. key: "cancelRendering",
  8478. value: function cancelRendering() {
  8479. if (this.renderTask) {
  8480. this.renderTask.cancel();
  8481. this.renderTask = null;
  8482. }
  8483. this.resume = null;
  8484. }
  8485. }, {
  8486. key: "_getPageDrawContext",
  8487. value: function _getPageDrawContext() {
  8488. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8489. var canvas = document.createElement("canvas");
  8490. this.canvas = canvas;
  8491. canvas.mozOpaque = true;
  8492. var ctx = canvas.getContext("2d", {
  8493. alpha: false
  8494. });
  8495. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  8496. canvas.width = this.canvasWidth * outputScale.sx | 0;
  8497. canvas.height = this.canvasHeight * outputScale.sy | 0;
  8498. canvas.style.width = this.canvasWidth + "px";
  8499. canvas.style.height = this.canvasHeight + "px";
  8500. if (!noCtxScale && outputScale.scaled) {
  8501. ctx.scale(outputScale.sx, outputScale.sy);
  8502. }
  8503. return ctx;
  8504. }
  8505. }, {
  8506. key: "_convertCanvasToImage",
  8507. value: function _convertCanvasToImage() {
  8508. var _this = this;
  8509. if (!this.canvas) {
  8510. return;
  8511. }
  8512. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8513. return;
  8514. }
  8515. var className = "thumbnailImage";
  8516. if (this.disableCanvasToImageConversion) {
  8517. this.canvas.className = className;
  8518. this._thumbPageCanvas.then(function (msg) {
  8519. _this.canvas.setAttribute("aria-label", msg);
  8520. });
  8521. this.div.setAttribute("data-loaded", true);
  8522. this.ring.appendChild(this.canvas);
  8523. return;
  8524. }
  8525. var image = document.createElement("img");
  8526. image.className = className;
  8527. this._thumbPageCanvas.then(function (msg) {
  8528. image.setAttribute("aria-label", msg);
  8529. });
  8530. image.style.width = this.canvasWidth + "px";
  8531. image.style.height = this.canvasHeight + "px";
  8532. image.src = this.canvas.toDataURL();
  8533. this.image = image;
  8534. this.div.setAttribute("data-loaded", true);
  8535. this.ring.appendChild(image);
  8536. this.canvas.width = 0;
  8537. this.canvas.height = 0;
  8538. delete this.canvas;
  8539. }
  8540. }, {
  8541. key: "draw",
  8542. value: function draw() {
  8543. var _this2 = this;
  8544. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8545. console.error("Must be in new state before drawing");
  8546. return Promise.resolve(undefined);
  8547. }
  8548. var pdfPage = this.pdfPage;
  8549. if (!pdfPage) {
  8550. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8551. return Promise.reject(new Error("pdfPage is not loaded"));
  8552. }
  8553. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8554. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  8555. var finishRenderTask = function finishRenderTask(error) {
  8556. if (renderTask === _this2.renderTask) {
  8557. _this2.renderTask = null;
  8558. }
  8559. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  8560. renderCapability.resolve(undefined);
  8561. return;
  8562. }
  8563. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8564. _this2._convertCanvasToImage();
  8565. if (!error) {
  8566. renderCapability.resolve(undefined);
  8567. } else {
  8568. renderCapability.reject(error);
  8569. }
  8570. };
  8571. var ctx = this._getPageDrawContext();
  8572. var drawViewport = this.viewport.clone({
  8573. scale: this.scale
  8574. });
  8575. var renderContinueCallback = function renderContinueCallback(cont) {
  8576. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  8577. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  8578. _this2.resume = function () {
  8579. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8580. cont();
  8581. };
  8582. return;
  8583. }
  8584. cont();
  8585. };
  8586. var renderContext = {
  8587. canvasContext: ctx,
  8588. viewport: drawViewport
  8589. };
  8590. var renderTask = this.renderTask = pdfPage.render(renderContext);
  8591. renderTask.onContinue = renderContinueCallback;
  8592. renderTask.promise.then(function () {
  8593. finishRenderTask(null);
  8594. }, function (error) {
  8595. finishRenderTask(error);
  8596. });
  8597. return renderCapability.promise;
  8598. }
  8599. }, {
  8600. key: "setImage",
  8601. value: function setImage(pageView) {
  8602. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8603. return;
  8604. }
  8605. var img = pageView.canvas;
  8606. if (!img) {
  8607. return;
  8608. }
  8609. if (!this.pdfPage) {
  8610. this.setPdfPage(pageView.pdfPage);
  8611. }
  8612. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8613. var ctx = this._getPageDrawContext(true);
  8614. var canvas = ctx.canvas;
  8615. if (img.width <= 2 * canvas.width) {
  8616. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  8617. this._convertCanvasToImage();
  8618. return;
  8619. }
  8620. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  8621. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  8622. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  8623. var reducedImageCtx = reducedImage.getContext("2d");
  8624. while (reducedWidth > img.width || reducedHeight > img.height) {
  8625. reducedWidth >>= 1;
  8626. reducedHeight >>= 1;
  8627. }
  8628. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  8629. while (reducedWidth > 2 * canvas.width) {
  8630. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  8631. reducedWidth >>= 1;
  8632. reducedHeight >>= 1;
  8633. }
  8634. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  8635. this._convertCanvasToImage();
  8636. }
  8637. }, {
  8638. key: "setPageLabel",
  8639. value: function setPageLabel(label) {
  8640. var _this3 = this;
  8641. this.pageLabel = typeof label === "string" ? label : null;
  8642. this._thumbPageTitle.then(function (msg) {
  8643. _this3.anchor.title = msg;
  8644. });
  8645. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8646. return;
  8647. }
  8648. this._thumbPageCanvas.then(function (msg) {
  8649. if (_this3.image) {
  8650. _this3.image.setAttribute("aria-label", msg);
  8651. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  8652. _this3.canvas.setAttribute("aria-label", msg);
  8653. }
  8654. });
  8655. }
  8656. }, {
  8657. key: "_thumbPageTitle",
  8658. get: function get() {
  8659. return this.l10n.get("thumb_page_title", {
  8660. page: this.pageLabel !== null ? this.pageLabel : this.id
  8661. }, "Page {{page}}");
  8662. }
  8663. }, {
  8664. key: "_thumbPageCanvas",
  8665. get: function get() {
  8666. return this.l10n.get("thumb_page_canvas", {
  8667. page: this.pageLabel !== null ? this.pageLabel : this.id
  8668. }, "Thumbnail of Page {{page}}");
  8669. }
  8670. }], [{
  8671. key: "cleanup",
  8672. value: function cleanup() {
  8673. TempImageFactory.destroyCanvas();
  8674. }
  8675. }]);
  8676. return PDFThumbnailView;
  8677. }();
  8678. exports.PDFThumbnailView = PDFThumbnailView;
  8679. /***/ }),
  8680. /* 27 */
  8681. /***/ (function(module, exports, __webpack_require__) {
  8682. "use strict";
  8683. Object.defineProperty(exports, "__esModule", {
  8684. value: true
  8685. });
  8686. exports.PDFViewer = void 0;
  8687. var _base_viewer = __webpack_require__(28);
  8688. var _pdfjsLib = __webpack_require__(8);
  8689. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8690. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  8691. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  8692. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  8693. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8694. 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); } }
  8695. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8696. 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); }
  8697. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  8698. 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); }
  8699. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8700. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8701. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8702. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8703. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  8704. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8705. var PDFViewer = /*#__PURE__*/function (_BaseViewer) {
  8706. _inherits(PDFViewer, _BaseViewer);
  8707. var _super = _createSuper(PDFViewer);
  8708. function PDFViewer() {
  8709. _classCallCheck(this, PDFViewer);
  8710. return _super.apply(this, arguments);
  8711. }
  8712. _createClass(PDFViewer, [{
  8713. key: "_scrollIntoView",
  8714. value: function _scrollIntoView(_ref) {
  8715. var pageDiv = _ref.pageDiv,
  8716. _ref$pageSpot = _ref.pageSpot,
  8717. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  8718. _ref$pageNumber = _ref.pageNumber,
  8719. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  8720. if (!pageSpot && !this.isInPresentationMode) {
  8721. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  8722. var right = left + pageDiv.clientWidth;
  8723. var _this$container = this.container,
  8724. scrollLeft = _this$container.scrollLeft,
  8725. clientWidth = _this$container.clientWidth;
  8726. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  8727. pageSpot = {
  8728. left: 0,
  8729. top: 0
  8730. };
  8731. }
  8732. }
  8733. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  8734. pageDiv: pageDiv,
  8735. pageSpot: pageSpot,
  8736. pageNumber: pageNumber
  8737. });
  8738. }
  8739. }, {
  8740. key: "_getVisiblePages",
  8741. value: function _getVisiblePages() {
  8742. if (this.isInPresentationMode) {
  8743. return this._getCurrentVisiblePage();
  8744. }
  8745. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  8746. }
  8747. }, {
  8748. key: "_updateHelper",
  8749. value: function _updateHelper(visiblePages) {
  8750. if (this.isInPresentationMode) {
  8751. return;
  8752. }
  8753. var currentId = this._currentPageNumber;
  8754. var stillFullyVisible = false;
  8755. var _iterator = _createForOfIteratorHelper(visiblePages),
  8756. _step;
  8757. try {
  8758. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8759. var page = _step.value;
  8760. if (page.percent < 100) {
  8761. break;
  8762. }
  8763. if (page.id === currentId) {
  8764. stillFullyVisible = true;
  8765. break;
  8766. }
  8767. }
  8768. } catch (err) {
  8769. _iterator.e(err);
  8770. } finally {
  8771. _iterator.f();
  8772. }
  8773. if (!stillFullyVisible) {
  8774. currentId = visiblePages[0].id;
  8775. }
  8776. this._setCurrentPageNumber(currentId);
  8777. }
  8778. }, {
  8779. key: "_viewerElement",
  8780. get: function get() {
  8781. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this.viewer);
  8782. }
  8783. }]);
  8784. return PDFViewer;
  8785. }(_base_viewer.BaseViewer);
  8786. exports.PDFViewer = PDFViewer;
  8787. /***/ }),
  8788. /* 28 */
  8789. /***/ (function(module, exports, __webpack_require__) {
  8790. "use strict";
  8791. Object.defineProperty(exports, "__esModule", {
  8792. value: true
  8793. });
  8794. exports.BaseViewer = void 0;
  8795. var _ui_utils = __webpack_require__(5);
  8796. var _pdf_rendering_queue = __webpack_require__(11);
  8797. var _annotation_layer_builder = __webpack_require__(29);
  8798. var _pdfjsLib = __webpack_require__(8);
  8799. var _pdf_page_view = __webpack_require__(30);
  8800. var _pdf_link_service = __webpack_require__(21);
  8801. var _text_layer_builder = __webpack_require__(31);
  8802. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8803. 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); } }
  8804. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8805. var DEFAULT_CACHE_SIZE = 10;
  8806. function PDFPageViewBuffer(size) {
  8807. var data = [];
  8808. this.push = function (view) {
  8809. var i = data.indexOf(view);
  8810. if (i >= 0) {
  8811. data.splice(i, 1);
  8812. }
  8813. data.push(view);
  8814. if (data.length > size) {
  8815. data.shift().destroy();
  8816. }
  8817. };
  8818. this.resize = function (newSize, pagesToKeep) {
  8819. size = newSize;
  8820. if (pagesToKeep) {
  8821. var pageIdsToKeep = new Set();
  8822. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  8823. pageIdsToKeep.add(pagesToKeep[i].id);
  8824. }
  8825. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  8826. return pageIdsToKeep.has(page.id);
  8827. });
  8828. }
  8829. while (data.length > size) {
  8830. data.shift().destroy();
  8831. }
  8832. };
  8833. }
  8834. function isSameScale(oldScale, newScale) {
  8835. if (newScale === oldScale) {
  8836. return true;
  8837. }
  8838. if (Math.abs(newScale - oldScale) < 1e-15) {
  8839. return true;
  8840. }
  8841. return false;
  8842. }
  8843. var BaseViewer = /*#__PURE__*/function () {
  8844. function BaseViewer(options) {
  8845. var _this = this;
  8846. _classCallCheck(this, BaseViewer);
  8847. if (this.constructor === BaseViewer) {
  8848. throw new Error("Cannot initialize BaseViewer.");
  8849. }
  8850. this._name = this.constructor.name;
  8851. this.container = options.container;
  8852. this.viewer = options.viewer || options.container.firstElementChild;
  8853. this.eventBus = options.eventBus;
  8854. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  8855. this.downloadManager = options.downloadManager || null;
  8856. this.findController = options.findController || null;
  8857. this.removePageBorders = options.removePageBorders || false;
  8858. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  8859. this.imageResourcesPath = options.imageResourcesPath || "";
  8860. this.renderInteractiveForms = options.renderInteractiveForms || false;
  8861. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  8862. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  8863. this.enableWebGL = options.enableWebGL || false;
  8864. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  8865. this.maxCanvasPixels = options.maxCanvasPixels;
  8866. this.l10n = options.l10n || _ui_utils.NullL10n;
  8867. this.defaultRenderingQueue = !options.renderingQueue;
  8868. if (this.defaultRenderingQueue) {
  8869. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  8870. this.renderingQueue.setViewer(this);
  8871. } else {
  8872. this.renderingQueue = options.renderingQueue;
  8873. }
  8874. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  8875. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  8876. this._onBeforeDraw = this._onAfterDraw = null;
  8877. this._resetView();
  8878. if (this.removePageBorders) {
  8879. this.viewer.classList.add("removePageBorders");
  8880. }
  8881. Promise.resolve().then(function () {
  8882. _this.eventBus.dispatch("baseviewerinit", {
  8883. source: _this
  8884. });
  8885. });
  8886. }
  8887. _createClass(BaseViewer, [{
  8888. key: "getPageView",
  8889. value: function getPageView(index) {
  8890. return this._pages[index];
  8891. }
  8892. }, {
  8893. key: "_setCurrentPageNumber",
  8894. value: function _setCurrentPageNumber(val) {
  8895. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8896. if (this._currentPageNumber === val) {
  8897. if (resetCurrentPageView) {
  8898. this._resetCurrentPageView();
  8899. }
  8900. return true;
  8901. }
  8902. if (!(0 < val && val <= this.pagesCount)) {
  8903. return false;
  8904. }
  8905. this._currentPageNumber = val;
  8906. this.eventBus.dispatch("pagechanging", {
  8907. source: this,
  8908. pageNumber: val,
  8909. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  8910. });
  8911. if (resetCurrentPageView) {
  8912. this._resetCurrentPageView();
  8913. }
  8914. return true;
  8915. }
  8916. }, {
  8917. key: "_onePageRenderedOrForceFetch",
  8918. value: function _onePageRenderedOrForceFetch() {
  8919. if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  8920. return Promise.resolve();
  8921. }
  8922. return this._onePageRenderedCapability.promise;
  8923. }
  8924. }, {
  8925. key: "setDocument",
  8926. value: function setDocument(pdfDocument) {
  8927. var _this2 = this;
  8928. if (this.pdfDocument) {
  8929. this._cancelRendering();
  8930. this._resetView();
  8931. if (this.findController) {
  8932. this.findController.setDocument(null);
  8933. }
  8934. }
  8935. this.pdfDocument = pdfDocument;
  8936. if (!pdfDocument) {
  8937. return;
  8938. }
  8939. var pagesCount = pdfDocument.numPages;
  8940. var firstPagePromise = pdfDocument.getPage(1);
  8941. this._pagesCapability.promise.then(function () {
  8942. _this2.eventBus.dispatch("pagesloaded", {
  8943. source: _this2,
  8944. pagesCount: pagesCount
  8945. });
  8946. });
  8947. this._onBeforeDraw = function (evt) {
  8948. var pageView = _this2._pages[evt.pageNumber - 1];
  8949. if (!pageView) {
  8950. return;
  8951. }
  8952. _this2._buffer.push(pageView);
  8953. };
  8954. this.eventBus._on("pagerender", this._onBeforeDraw);
  8955. this._onAfterDraw = function (evt) {
  8956. if (evt.cssTransform || _this2._onePageRenderedCapability.settled) {
  8957. return;
  8958. }
  8959. _this2._onePageRenderedCapability.resolve();
  8960. _this2.eventBus._off("pagerendered", _this2._onAfterDraw);
  8961. _this2._onAfterDraw = null;
  8962. };
  8963. this.eventBus._on("pagerendered", this._onAfterDraw);
  8964. firstPagePromise.then(function (firstPdfPage) {
  8965. _this2._firstPageCapability.resolve(firstPdfPage);
  8966. var scale = _this2.currentScale;
  8967. var viewport = firstPdfPage.getViewport({
  8968. scale: scale * _ui_utils.CSS_UNITS
  8969. });
  8970. var textLayerFactory = _this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? _this2 : null;
  8971. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8972. var pageView = new _pdf_page_view.PDFPageView({
  8973. container: _this2._viewerElement,
  8974. eventBus: _this2.eventBus,
  8975. id: pageNum,
  8976. scale: scale,
  8977. defaultViewport: viewport.clone(),
  8978. renderingQueue: _this2.renderingQueue,
  8979. textLayerFactory: textLayerFactory,
  8980. textLayerMode: _this2.textLayerMode,
  8981. annotationLayerFactory: _this2,
  8982. imageResourcesPath: _this2.imageResourcesPath,
  8983. renderInteractiveForms: _this2.renderInteractiveForms,
  8984. renderer: _this2.renderer,
  8985. enableWebGL: _this2.enableWebGL,
  8986. useOnlyCssZoom: _this2.useOnlyCssZoom,
  8987. maxCanvasPixels: _this2.maxCanvasPixels,
  8988. l10n: _this2.l10n
  8989. });
  8990. _this2._pages.push(pageView);
  8991. }
  8992. var firstPageView = _this2._pages[0];
  8993. if (firstPageView) {
  8994. firstPageView.setPdfPage(firstPdfPage);
  8995. _this2.linkService.cachePageRef(1, firstPdfPage.ref);
  8996. }
  8997. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  8998. _this2._updateSpreadMode();
  8999. }
  9000. _this2._onePageRenderedOrForceFetch().then(function () {
  9001. if (_this2.findController) {
  9002. _this2.findController.setDocument(pdfDocument);
  9003. }
  9004. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
  9005. _this2._pagesCapability.resolve();
  9006. return;
  9007. }
  9008. var getPagesLeft = pagesCount - 1;
  9009. if (getPagesLeft <= 0) {
  9010. _this2._pagesCapability.resolve();
  9011. return;
  9012. }
  9013. var _loop = function _loop(_pageNum) {
  9014. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  9015. var pageView = _this2._pages[_pageNum - 1];
  9016. if (!pageView.pdfPage) {
  9017. pageView.setPdfPage(pdfPage);
  9018. }
  9019. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  9020. if (--getPagesLeft === 0) {
  9021. _this2._pagesCapability.resolve();
  9022. }
  9023. }, function (reason) {
  9024. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  9025. if (--getPagesLeft === 0) {
  9026. _this2._pagesCapability.resolve();
  9027. }
  9028. });
  9029. };
  9030. for (var _pageNum = 2; _pageNum <= pagesCount; ++_pageNum) {
  9031. _loop(_pageNum);
  9032. }
  9033. });
  9034. _this2.eventBus.dispatch("pagesinit", {
  9035. source: _this2
  9036. });
  9037. if (_this2.defaultRenderingQueue) {
  9038. _this2.update();
  9039. }
  9040. })["catch"](function (reason) {
  9041. console.error("Unable to initialize viewer", reason);
  9042. });
  9043. }
  9044. }, {
  9045. key: "setPageLabels",
  9046. value: function setPageLabels(labels) {
  9047. if (!this.pdfDocument) {
  9048. return;
  9049. }
  9050. if (!labels) {
  9051. this._pageLabels = null;
  9052. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  9053. this._pageLabels = null;
  9054. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  9055. } else {
  9056. this._pageLabels = labels;
  9057. }
  9058. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9059. var pageView = this._pages[i];
  9060. var label = this._pageLabels && this._pageLabels[i];
  9061. pageView.setPageLabel(label);
  9062. }
  9063. }
  9064. }, {
  9065. key: "_resetView",
  9066. value: function _resetView() {
  9067. this._pages = [];
  9068. this._currentPageNumber = 1;
  9069. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  9070. this._currentScaleValue = null;
  9071. this._pageLabels = null;
  9072. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  9073. this._location = null;
  9074. this._pagesRotation = 0;
  9075. this._pagesRequests = new WeakMap();
  9076. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  9077. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  9078. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  9079. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  9080. this._spreadMode = _ui_utils.SpreadMode.NONE;
  9081. if (this._onBeforeDraw) {
  9082. this.eventBus._off("pagerender", this._onBeforeDraw);
  9083. this._onBeforeDraw = null;
  9084. }
  9085. if (this._onAfterDraw) {
  9086. this.eventBus._off("pagerendered", this._onAfterDraw);
  9087. this._onAfterDraw = null;
  9088. }
  9089. this.viewer.textContent = "";
  9090. this._updateScrollMode();
  9091. }
  9092. }, {
  9093. key: "_scrollUpdate",
  9094. value: function _scrollUpdate() {
  9095. if (this.pagesCount === 0) {
  9096. return;
  9097. }
  9098. this.update();
  9099. }
  9100. }, {
  9101. key: "_scrollIntoView",
  9102. value: function _scrollIntoView(_ref) {
  9103. var pageDiv = _ref.pageDiv,
  9104. _ref$pageSpot = _ref.pageSpot,
  9105. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  9106. _ref$pageNumber = _ref.pageNumber,
  9107. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  9108. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  9109. }
  9110. }, {
  9111. key: "_setScaleUpdatePages",
  9112. value: function _setScaleUpdatePages(newScale, newValue) {
  9113. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9114. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9115. this._currentScaleValue = newValue.toString();
  9116. if (isSameScale(this._currentScale, newScale)) {
  9117. if (preset) {
  9118. this.eventBus.dispatch("scalechanging", {
  9119. source: this,
  9120. scale: newScale,
  9121. presetValue: newValue
  9122. });
  9123. }
  9124. return;
  9125. }
  9126. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9127. this._pages[i].update(newScale);
  9128. }
  9129. this._currentScale = newScale;
  9130. if (!noScroll) {
  9131. var page = this._currentPageNumber,
  9132. dest;
  9133. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  9134. page = this._location.pageNumber;
  9135. dest = [null, {
  9136. name: "XYZ"
  9137. }, this._location.left, this._location.top, null];
  9138. }
  9139. this.scrollPageIntoView({
  9140. pageNumber: page,
  9141. destArray: dest,
  9142. allowNegativeOffset: true
  9143. });
  9144. }
  9145. this.eventBus.dispatch("scalechanging", {
  9146. source: this,
  9147. scale: newScale,
  9148. presetValue: preset ? newValue : undefined
  9149. });
  9150. if (this.defaultRenderingQueue) {
  9151. this.update();
  9152. }
  9153. }
  9154. }, {
  9155. key: "_setScale",
  9156. value: function _setScale(value) {
  9157. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9158. var scale = parseFloat(value);
  9159. if (scale > 0) {
  9160. this._setScaleUpdatePages(scale, value, noScroll, false);
  9161. } else {
  9162. var currentPage = this._pages[this._currentPageNumber - 1];
  9163. if (!currentPage) {
  9164. return;
  9165. }
  9166. var noPadding = this.isInPresentationMode || this.removePageBorders;
  9167. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  9168. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  9169. if (!noPadding && this._isScrollModeHorizontal) {
  9170. var _ref2 = [vPadding, hPadding];
  9171. hPadding = _ref2[0];
  9172. vPadding = _ref2[1];
  9173. }
  9174. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  9175. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  9176. switch (value) {
  9177. case "page-actual":
  9178. scale = 1;
  9179. break;
  9180. case "page-width":
  9181. scale = pageWidthScale;
  9182. break;
  9183. case "page-height":
  9184. scale = pageHeightScale;
  9185. break;
  9186. case "page-fit":
  9187. scale = Math.min(pageWidthScale, pageHeightScale);
  9188. break;
  9189. case "auto":
  9190. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  9191. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  9192. break;
  9193. default:
  9194. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  9195. return;
  9196. }
  9197. this._setScaleUpdatePages(scale, value, noScroll, true);
  9198. }
  9199. }
  9200. }, {
  9201. key: "_resetCurrentPageView",
  9202. value: function _resetCurrentPageView() {
  9203. if (this.isInPresentationMode) {
  9204. this._setScale(this._currentScaleValue, true);
  9205. }
  9206. var pageView = this._pages[this._currentPageNumber - 1];
  9207. this._scrollIntoView({
  9208. pageDiv: pageView.div
  9209. });
  9210. }
  9211. }, {
  9212. key: "scrollPageIntoView",
  9213. value: function scrollPageIntoView(_ref3) {
  9214. var pageNumber = _ref3.pageNumber,
  9215. _ref3$destArray = _ref3.destArray,
  9216. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  9217. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  9218. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf,
  9219. _ref3$ignoreDestinati = _ref3.ignoreDestinationZoom,
  9220. ignoreDestinationZoom = _ref3$ignoreDestinati === void 0 ? false : _ref3$ignoreDestinati;
  9221. if (!this.pdfDocument) {
  9222. return;
  9223. }
  9224. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  9225. if (!pageView) {
  9226. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  9227. return;
  9228. }
  9229. if (this.isInPresentationMode || !destArray) {
  9230. this._setCurrentPageNumber(pageNumber, true);
  9231. return;
  9232. }
  9233. var x = 0,
  9234. y = 0;
  9235. var width = 0,
  9236. height = 0,
  9237. widthScale,
  9238. heightScale;
  9239. var changeOrientation = pageView.rotation % 180 !== 0;
  9240. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  9241. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  9242. var scale = 0;
  9243. switch (destArray[1].name) {
  9244. case "XYZ":
  9245. x = destArray[2];
  9246. y = destArray[3];
  9247. scale = destArray[4];
  9248. x = x !== null ? x : 0;
  9249. y = y !== null ? y : pageHeight;
  9250. break;
  9251. case "Fit":
  9252. case "FitB":
  9253. scale = "page-fit";
  9254. break;
  9255. case "FitH":
  9256. case "FitBH":
  9257. y = destArray[2];
  9258. scale = "page-width";
  9259. if (y === null && this._location) {
  9260. x = this._location.left;
  9261. y = this._location.top;
  9262. }
  9263. break;
  9264. case "FitV":
  9265. case "FitBV":
  9266. x = destArray[2];
  9267. width = pageWidth;
  9268. height = pageHeight;
  9269. scale = "page-height";
  9270. break;
  9271. case "FitR":
  9272. x = destArray[2];
  9273. y = destArray[3];
  9274. width = destArray[4] - x;
  9275. height = destArray[5] - y;
  9276. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  9277. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  9278. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  9279. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  9280. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  9281. break;
  9282. default:
  9283. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  9284. return;
  9285. }
  9286. if (!ignoreDestinationZoom) {
  9287. if (scale && scale !== this._currentScale) {
  9288. this.currentScaleValue = scale;
  9289. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  9290. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  9291. }
  9292. }
  9293. if (scale === "page-fit" && !destArray[4]) {
  9294. this._scrollIntoView({
  9295. pageDiv: pageView.div,
  9296. pageNumber: pageNumber
  9297. });
  9298. return;
  9299. }
  9300. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  9301. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  9302. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  9303. if (!allowNegativeOffset) {
  9304. left = Math.max(left, 0);
  9305. top = Math.max(top, 0);
  9306. }
  9307. this._scrollIntoView({
  9308. pageDiv: pageView.div,
  9309. pageSpot: {
  9310. left: left,
  9311. top: top
  9312. },
  9313. pageNumber: pageNumber
  9314. });
  9315. }
  9316. }, {
  9317. key: "_updateLocation",
  9318. value: function _updateLocation(firstPage) {
  9319. var currentScale = this._currentScale;
  9320. var currentScaleValue = this._currentScaleValue;
  9321. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  9322. var pageNumber = firstPage.id;
  9323. var pdfOpenParams = "#page=" + pageNumber;
  9324. pdfOpenParams += "&zoom=" + normalizedScaleValue;
  9325. var currentPageView = this._pages[pageNumber - 1];
  9326. var container = this.container;
  9327. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  9328. var intLeft = Math.round(topLeft[0]);
  9329. var intTop = Math.round(topLeft[1]);
  9330. pdfOpenParams += "," + intLeft + "," + intTop;
  9331. this._location = {
  9332. pageNumber: pageNumber,
  9333. scale: normalizedScaleValue,
  9334. top: intTop,
  9335. left: intLeft,
  9336. rotation: this._pagesRotation,
  9337. pdfOpenParams: pdfOpenParams
  9338. };
  9339. }
  9340. }, {
  9341. key: "_updateHelper",
  9342. value: function _updateHelper(visiblePages) {
  9343. throw new Error("Not implemented: _updateHelper");
  9344. }
  9345. }, {
  9346. key: "update",
  9347. value: function update() {
  9348. var visible = this._getVisiblePages();
  9349. var visiblePages = visible.views,
  9350. numVisiblePages = visiblePages.length;
  9351. if (numVisiblePages === 0) {
  9352. return;
  9353. }
  9354. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  9355. this._buffer.resize(newCacheSize, visiblePages);
  9356. this.renderingQueue.renderHighestPriority(visible);
  9357. this._updateHelper(visiblePages);
  9358. this._updateLocation(visible.first);
  9359. this.eventBus.dispatch("updateviewarea", {
  9360. source: this,
  9361. location: this._location
  9362. });
  9363. }
  9364. }, {
  9365. key: "containsElement",
  9366. value: function containsElement(element) {
  9367. return this.container.contains(element);
  9368. }
  9369. }, {
  9370. key: "focus",
  9371. value: function focus() {
  9372. this.container.focus();
  9373. }
  9374. }, {
  9375. key: "_getCurrentVisiblePage",
  9376. value: function _getCurrentVisiblePage() {
  9377. if (!this.pagesCount) {
  9378. return {
  9379. views: []
  9380. };
  9381. }
  9382. var pageView = this._pages[this._currentPageNumber - 1];
  9383. var element = pageView.div;
  9384. var view = {
  9385. id: pageView.id,
  9386. x: element.offsetLeft + element.clientLeft,
  9387. y: element.offsetTop + element.clientTop,
  9388. view: pageView
  9389. };
  9390. return {
  9391. first: view,
  9392. last: view,
  9393. views: [view]
  9394. };
  9395. }
  9396. }, {
  9397. key: "_getVisiblePages",
  9398. value: function _getVisiblePages() {
  9399. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._isScrollModeHorizontal);
  9400. }
  9401. }, {
  9402. key: "isPageVisible",
  9403. value: function isPageVisible(pageNumber) {
  9404. if (!this.pdfDocument) {
  9405. return false;
  9406. }
  9407. if (pageNumber < 1 || pageNumber > this.pagesCount) {
  9408. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is out of bounds."));
  9409. return false;
  9410. }
  9411. return this._getVisiblePages().views.some(function (view) {
  9412. return view.id === pageNumber;
  9413. });
  9414. }
  9415. }, {
  9416. key: "cleanup",
  9417. value: function cleanup() {
  9418. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9419. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9420. this._pages[i].reset();
  9421. }
  9422. }
  9423. }
  9424. }, {
  9425. key: "_cancelRendering",
  9426. value: function _cancelRendering() {
  9427. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9428. if (this._pages[i]) {
  9429. this._pages[i].cancelRendering();
  9430. }
  9431. }
  9432. }
  9433. }, {
  9434. key: "_ensurePdfPageLoaded",
  9435. value: function _ensurePdfPageLoaded(pageView) {
  9436. var _this3 = this;
  9437. if (pageView.pdfPage) {
  9438. return Promise.resolve(pageView.pdfPage);
  9439. }
  9440. if (this._pagesRequests.has(pageView)) {
  9441. return this._pagesRequests.get(pageView);
  9442. }
  9443. var promise = this.pdfDocument.getPage(pageView.id).then(function (pdfPage) {
  9444. if (!pageView.pdfPage) {
  9445. pageView.setPdfPage(pdfPage);
  9446. }
  9447. _this3._pagesRequests["delete"](pageView);
  9448. return pdfPage;
  9449. })["catch"](function (reason) {
  9450. console.error("Unable to get page for page view", reason);
  9451. _this3._pagesRequests["delete"](pageView);
  9452. });
  9453. this._pagesRequests.set(pageView, promise);
  9454. return promise;
  9455. }
  9456. }, {
  9457. key: "forceRendering",
  9458. value: function forceRendering(currentlyVisiblePages) {
  9459. var _this4 = this;
  9460. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  9461. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  9462. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  9463. if (pageView) {
  9464. this._ensurePdfPageLoaded(pageView).then(function () {
  9465. _this4.renderingQueue.renderView(pageView);
  9466. });
  9467. return true;
  9468. }
  9469. return false;
  9470. }
  9471. }, {
  9472. key: "createTextLayerBuilder",
  9473. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  9474. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9475. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  9476. return new _text_layer_builder.TextLayerBuilder({
  9477. textLayerDiv: textLayerDiv,
  9478. eventBus: eventBus,
  9479. pageIndex: pageIndex,
  9480. viewport: viewport,
  9481. findController: this.isInPresentationMode ? null : this.findController,
  9482. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  9483. });
  9484. }
  9485. }, {
  9486. key: "createAnnotationLayerBuilder",
  9487. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9488. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
  9489. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9490. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  9491. return new _annotation_layer_builder.AnnotationLayerBuilder({
  9492. pageDiv: pageDiv,
  9493. pdfPage: pdfPage,
  9494. imageResourcesPath: imageResourcesPath,
  9495. renderInteractiveForms: renderInteractiveForms,
  9496. linkService: this.linkService,
  9497. downloadManager: this.downloadManager,
  9498. l10n: l10n
  9499. });
  9500. }
  9501. }, {
  9502. key: "getPagesOverview",
  9503. value: function getPagesOverview() {
  9504. var pagesOverview = this._pages.map(function (pageView) {
  9505. var viewport = pageView.pdfPage.getViewport({
  9506. scale: 1
  9507. });
  9508. return {
  9509. width: viewport.width,
  9510. height: viewport.height,
  9511. rotation: viewport.rotation
  9512. };
  9513. });
  9514. if (!this.enablePrintAutoRotate) {
  9515. return pagesOverview;
  9516. }
  9517. var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]);
  9518. return pagesOverview.map(function (size) {
  9519. if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) {
  9520. return size;
  9521. }
  9522. return {
  9523. width: size.height,
  9524. height: size.width,
  9525. rotation: (size.rotation + 90) % 360
  9526. };
  9527. });
  9528. }
  9529. }, {
  9530. key: "_updateScrollMode",
  9531. value: function _updateScrollMode() {
  9532. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9533. var scrollMode = this._scrollMode,
  9534. viewer = this.viewer;
  9535. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  9536. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  9537. if (!this.pdfDocument || !pageNumber) {
  9538. return;
  9539. }
  9540. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  9541. this._setScale(this._currentScaleValue, true);
  9542. }
  9543. this._setCurrentPageNumber(pageNumber, true);
  9544. this.update();
  9545. }
  9546. }, {
  9547. key: "_updateSpreadMode",
  9548. value: function _updateSpreadMode() {
  9549. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9550. if (!this.pdfDocument) {
  9551. return;
  9552. }
  9553. var viewer = this.viewer,
  9554. pages = this._pages;
  9555. viewer.textContent = "";
  9556. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  9557. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  9558. viewer.appendChild(pages[i].div);
  9559. }
  9560. } else {
  9561. var parity = this._spreadMode - 1;
  9562. var spread = null;
  9563. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  9564. if (spread === null) {
  9565. spread = document.createElement("div");
  9566. spread.className = "spread";
  9567. viewer.appendChild(spread);
  9568. } else if (_i % 2 === parity) {
  9569. spread = spread.cloneNode(false);
  9570. viewer.appendChild(spread);
  9571. }
  9572. spread.appendChild(pages[_i].div);
  9573. }
  9574. }
  9575. if (!pageNumber) {
  9576. return;
  9577. }
  9578. this._setCurrentPageNumber(pageNumber, true);
  9579. this.update();
  9580. }
  9581. }, {
  9582. key: "pagesCount",
  9583. get: function get() {
  9584. return this._pages.length;
  9585. }
  9586. }, {
  9587. key: "pageViewsReady",
  9588. get: function get() {
  9589. if (!this._pagesCapability.settled) {
  9590. return false;
  9591. }
  9592. return this._pages.every(function (pageView) {
  9593. return pageView && pageView.pdfPage;
  9594. });
  9595. }
  9596. }, {
  9597. key: "currentPageNumber",
  9598. get: function get() {
  9599. return this._currentPageNumber;
  9600. },
  9601. set: function set(val) {
  9602. if (!Number.isInteger(val)) {
  9603. throw new Error("Invalid page number.");
  9604. }
  9605. if (!this.pdfDocument) {
  9606. return;
  9607. }
  9608. if (!this._setCurrentPageNumber(val, true)) {
  9609. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  9610. }
  9611. }
  9612. }, {
  9613. key: "currentPageLabel",
  9614. get: function get() {
  9615. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  9616. },
  9617. set: function set(val) {
  9618. if (!this.pdfDocument) {
  9619. return;
  9620. }
  9621. var page = val | 0;
  9622. if (this._pageLabels) {
  9623. var i = this._pageLabels.indexOf(val);
  9624. if (i >= 0) {
  9625. page = i + 1;
  9626. }
  9627. }
  9628. if (!this._setCurrentPageNumber(page, true)) {
  9629. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  9630. }
  9631. }
  9632. }, {
  9633. key: "currentScale",
  9634. get: function get() {
  9635. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  9636. },
  9637. set: function set(val) {
  9638. if (isNaN(val)) {
  9639. throw new Error("Invalid numeric scale.");
  9640. }
  9641. if (!this.pdfDocument) {
  9642. return;
  9643. }
  9644. this._setScale(val, false);
  9645. }
  9646. }, {
  9647. key: "currentScaleValue",
  9648. get: function get() {
  9649. return this._currentScaleValue;
  9650. },
  9651. set: function set(val) {
  9652. if (!this.pdfDocument) {
  9653. return;
  9654. }
  9655. this._setScale(val, false);
  9656. }
  9657. }, {
  9658. key: "pagesRotation",
  9659. get: function get() {
  9660. return this._pagesRotation;
  9661. },
  9662. set: function set(rotation) {
  9663. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  9664. throw new Error("Invalid pages rotation angle.");
  9665. }
  9666. if (!this.pdfDocument) {
  9667. return;
  9668. }
  9669. if (this._pagesRotation === rotation) {
  9670. return;
  9671. }
  9672. this._pagesRotation = rotation;
  9673. var pageNumber = this._currentPageNumber;
  9674. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9675. var pageView = this._pages[i];
  9676. pageView.update(pageView.scale, rotation);
  9677. }
  9678. if (this._currentScaleValue) {
  9679. this._setScale(this._currentScaleValue, true);
  9680. }
  9681. this.eventBus.dispatch("rotationchanging", {
  9682. source: this,
  9683. pagesRotation: rotation,
  9684. pageNumber: pageNumber
  9685. });
  9686. if (this.defaultRenderingQueue) {
  9687. this.update();
  9688. }
  9689. }
  9690. }, {
  9691. key: "firstPagePromise",
  9692. get: function get() {
  9693. return this.pdfDocument ? this._firstPageCapability.promise : null;
  9694. }
  9695. }, {
  9696. key: "onePageRendered",
  9697. get: function get() {
  9698. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  9699. }
  9700. }, {
  9701. key: "pagesPromise",
  9702. get: function get() {
  9703. return this.pdfDocument ? this._pagesCapability.promise : null;
  9704. }
  9705. }, {
  9706. key: "_viewerElement",
  9707. get: function get() {
  9708. throw new Error("Not implemented: _viewerElement");
  9709. }
  9710. }, {
  9711. key: "_isScrollModeHorizontal",
  9712. get: function get() {
  9713. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  9714. }
  9715. }, {
  9716. key: "isInPresentationMode",
  9717. get: function get() {
  9718. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  9719. }
  9720. }, {
  9721. key: "isChangingPresentationMode",
  9722. get: function get() {
  9723. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  9724. }
  9725. }, {
  9726. key: "isHorizontalScrollbarEnabled",
  9727. get: function get() {
  9728. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  9729. }
  9730. }, {
  9731. key: "isVerticalScrollbarEnabled",
  9732. get: function get() {
  9733. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  9734. }
  9735. }, {
  9736. key: "hasEqualPageSizes",
  9737. get: function get() {
  9738. var firstPageView = this._pages[0];
  9739. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  9740. var pageView = this._pages[i];
  9741. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  9742. return false;
  9743. }
  9744. }
  9745. return true;
  9746. }
  9747. }, {
  9748. key: "scrollMode",
  9749. get: function get() {
  9750. return this._scrollMode;
  9751. },
  9752. set: function set(mode) {
  9753. if (this._scrollMode === mode) {
  9754. return;
  9755. }
  9756. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  9757. throw new Error("Invalid scroll mode: ".concat(mode));
  9758. }
  9759. this._scrollMode = mode;
  9760. this.eventBus.dispatch("scrollmodechanged", {
  9761. source: this,
  9762. mode: mode
  9763. });
  9764. this._updateScrollMode(this._currentPageNumber);
  9765. }
  9766. }, {
  9767. key: "spreadMode",
  9768. get: function get() {
  9769. return this._spreadMode;
  9770. },
  9771. set: function set(mode) {
  9772. if (this._spreadMode === mode) {
  9773. return;
  9774. }
  9775. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  9776. throw new Error("Invalid spread mode: ".concat(mode));
  9777. }
  9778. this._spreadMode = mode;
  9779. this.eventBus.dispatch("spreadmodechanged", {
  9780. source: this,
  9781. mode: mode
  9782. });
  9783. this._updateSpreadMode(this._currentPageNumber);
  9784. }
  9785. }]);
  9786. return BaseViewer;
  9787. }();
  9788. exports.BaseViewer = BaseViewer;
  9789. /***/ }),
  9790. /* 29 */
  9791. /***/ (function(module, exports, __webpack_require__) {
  9792. "use strict";
  9793. Object.defineProperty(exports, "__esModule", {
  9794. value: true
  9795. });
  9796. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  9797. var _pdfjsLib = __webpack_require__(8);
  9798. var _ui_utils = __webpack_require__(5);
  9799. var _pdf_link_service = __webpack_require__(21);
  9800. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9801. 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); } }
  9802. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9803. var AnnotationLayerBuilder = /*#__PURE__*/function () {
  9804. function AnnotationLayerBuilder(_ref) {
  9805. var pageDiv = _ref.pageDiv,
  9806. pdfPage = _ref.pdfPage,
  9807. linkService = _ref.linkService,
  9808. downloadManager = _ref.downloadManager,
  9809. _ref$imageResourcesPa = _ref.imageResourcesPath,
  9810. imageResourcesPath = _ref$imageResourcesPa === void 0 ? "" : _ref$imageResourcesPa,
  9811. _ref$renderInteractiv = _ref.renderInteractiveForms,
  9812. renderInteractiveForms = _ref$renderInteractiv === void 0 ? false : _ref$renderInteractiv,
  9813. _ref$l10n = _ref.l10n,
  9814. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9815. _classCallCheck(this, AnnotationLayerBuilder);
  9816. this.pageDiv = pageDiv;
  9817. this.pdfPage = pdfPage;
  9818. this.linkService = linkService;
  9819. this.downloadManager = downloadManager;
  9820. this.imageResourcesPath = imageResourcesPath;
  9821. this.renderInteractiveForms = renderInteractiveForms;
  9822. this.l10n = l10n;
  9823. this.div = null;
  9824. this._cancelled = false;
  9825. }
  9826. _createClass(AnnotationLayerBuilder, [{
  9827. key: "render",
  9828. value: function render(viewport) {
  9829. var _this = this;
  9830. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  9831. this.pdfPage.getAnnotations({
  9832. intent: intent
  9833. }).then(function (annotations) {
  9834. if (_this._cancelled) {
  9835. return;
  9836. }
  9837. var parameters = {
  9838. viewport: viewport.clone({
  9839. dontFlip: true
  9840. }),
  9841. div: _this.div,
  9842. annotations: annotations,
  9843. page: _this.pdfPage,
  9844. imageResourcesPath: _this.imageResourcesPath,
  9845. renderInteractiveForms: _this.renderInteractiveForms,
  9846. linkService: _this.linkService,
  9847. downloadManager: _this.downloadManager
  9848. };
  9849. if (_this.div) {
  9850. _pdfjsLib.AnnotationLayer.update(parameters);
  9851. } else {
  9852. if (annotations.length === 0) {
  9853. return;
  9854. }
  9855. _this.div = document.createElement("div");
  9856. _this.div.className = "annotationLayer";
  9857. _this.pageDiv.appendChild(_this.div);
  9858. parameters.div = _this.div;
  9859. _pdfjsLib.AnnotationLayer.render(parameters);
  9860. _this.l10n.translate(_this.div);
  9861. }
  9862. });
  9863. }
  9864. }, {
  9865. key: "cancel",
  9866. value: function cancel() {
  9867. this._cancelled = true;
  9868. }
  9869. }, {
  9870. key: "hide",
  9871. value: function hide() {
  9872. if (!this.div) {
  9873. return;
  9874. }
  9875. this.div.setAttribute("hidden", "true");
  9876. }
  9877. }]);
  9878. return AnnotationLayerBuilder;
  9879. }();
  9880. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  9881. var DefaultAnnotationLayerFactory = /*#__PURE__*/function () {
  9882. function DefaultAnnotationLayerFactory() {
  9883. _classCallCheck(this, DefaultAnnotationLayerFactory);
  9884. }
  9885. _createClass(DefaultAnnotationLayerFactory, [{
  9886. key: "createAnnotationLayerBuilder",
  9887. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9888. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
  9889. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9890. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  9891. return new AnnotationLayerBuilder({
  9892. pageDiv: pageDiv,
  9893. pdfPage: pdfPage,
  9894. imageResourcesPath: imageResourcesPath,
  9895. renderInteractiveForms: renderInteractiveForms,
  9896. linkService: new _pdf_link_service.SimpleLinkService(),
  9897. l10n: l10n
  9898. });
  9899. }
  9900. }]);
  9901. return DefaultAnnotationLayerFactory;
  9902. }();
  9903. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  9904. /***/ }),
  9905. /* 30 */
  9906. /***/ (function(module, exports, __webpack_require__) {
  9907. "use strict";
  9908. Object.defineProperty(exports, "__esModule", {
  9909. value: true
  9910. });
  9911. exports.PDFPageView = void 0;
  9912. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  9913. var _ui_utils = __webpack_require__(5);
  9914. var _pdfjsLib = __webpack_require__(8);
  9915. var _pdf_rendering_queue = __webpack_require__(11);
  9916. var _viewer_compatibility = __webpack_require__(7);
  9917. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9918. 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); } }
  9919. 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); }); }; }
  9920. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9921. 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); } }
  9922. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9923. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  9924. var PDFPageView = /*#__PURE__*/function () {
  9925. function PDFPageView(options) {
  9926. _classCallCheck(this, PDFPageView);
  9927. var container = options.container;
  9928. var defaultViewport = options.defaultViewport;
  9929. this.id = options.id;
  9930. this.renderingId = "page" + this.id;
  9931. this.pdfPage = null;
  9932. this.pageLabel = null;
  9933. this.rotation = 0;
  9934. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  9935. this.viewport = defaultViewport;
  9936. this.pdfPageRotate = defaultViewport.rotation;
  9937. this.hasRestrictedScaling = false;
  9938. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  9939. this.imageResourcesPath = options.imageResourcesPath || "";
  9940. this.renderInteractiveForms = options.renderInteractiveForms || false;
  9941. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  9942. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  9943. this.eventBus = options.eventBus;
  9944. this.renderingQueue = options.renderingQueue;
  9945. this.textLayerFactory = options.textLayerFactory;
  9946. this.annotationLayerFactory = options.annotationLayerFactory;
  9947. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  9948. this.enableWebGL = options.enableWebGL || false;
  9949. this.l10n = options.l10n || _ui_utils.NullL10n;
  9950. this.paintTask = null;
  9951. this.paintedViewportMap = new WeakMap();
  9952. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9953. this.resume = null;
  9954. this.error = null;
  9955. this.annotationLayer = null;
  9956. this.textLayer = null;
  9957. this.zoomLayer = null;
  9958. var div = document.createElement("div");
  9959. div.className = "page";
  9960. div.style.width = Math.floor(this.viewport.width) + "px";
  9961. div.style.height = Math.floor(this.viewport.height) + "px";
  9962. div.setAttribute("data-page-number", this.id);
  9963. this.div = div;
  9964. container.appendChild(div);
  9965. }
  9966. _createClass(PDFPageView, [{
  9967. key: "setPdfPage",
  9968. value: function setPdfPage(pdfPage) {
  9969. this.pdfPage = pdfPage;
  9970. this.pdfPageRotate = pdfPage.rotate;
  9971. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9972. this.viewport = pdfPage.getViewport({
  9973. scale: this.scale * _ui_utils.CSS_UNITS,
  9974. rotation: totalRotation
  9975. });
  9976. this.stats = pdfPage.stats;
  9977. this.reset();
  9978. }
  9979. }, {
  9980. key: "destroy",
  9981. value: function destroy() {
  9982. this.reset();
  9983. if (this.pdfPage) {
  9984. this.pdfPage.cleanup();
  9985. }
  9986. }
  9987. }, {
  9988. key: "_resetZoomLayer",
  9989. value: function _resetZoomLayer() {
  9990. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9991. if (!this.zoomLayer) {
  9992. return;
  9993. }
  9994. var zoomLayerCanvas = this.zoomLayer.firstChild;
  9995. this.paintedViewportMap["delete"](zoomLayerCanvas);
  9996. zoomLayerCanvas.width = 0;
  9997. zoomLayerCanvas.height = 0;
  9998. if (removeFromDOM) {
  9999. this.zoomLayer.remove();
  10000. }
  10001. this.zoomLayer = null;
  10002. }
  10003. }, {
  10004. key: "reset",
  10005. value: function reset() {
  10006. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10007. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10008. this.cancelRendering(keepAnnotations);
  10009. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  10010. var div = this.div;
  10011. div.style.width = Math.floor(this.viewport.width) + "px";
  10012. div.style.height = Math.floor(this.viewport.height) + "px";
  10013. var childNodes = div.childNodes;
  10014. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  10015. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  10016. for (var i = childNodes.length - 1; i >= 0; i--) {
  10017. var node = childNodes[i];
  10018. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  10019. continue;
  10020. }
  10021. div.removeChild(node);
  10022. }
  10023. div.removeAttribute("data-loaded");
  10024. if (currentAnnotationNode) {
  10025. this.annotationLayer.hide();
  10026. } else if (this.annotationLayer) {
  10027. this.annotationLayer.cancel();
  10028. this.annotationLayer = null;
  10029. }
  10030. if (!currentZoomLayerNode) {
  10031. if (this.canvas) {
  10032. this.paintedViewportMap["delete"](this.canvas);
  10033. this.canvas.width = 0;
  10034. this.canvas.height = 0;
  10035. delete this.canvas;
  10036. }
  10037. this._resetZoomLayer();
  10038. }
  10039. if (this.svg) {
  10040. this.paintedViewportMap["delete"](this.svg);
  10041. delete this.svg;
  10042. }
  10043. this.loadingIconDiv = document.createElement("div");
  10044. this.loadingIconDiv.className = "loadingIcon";
  10045. div.appendChild(this.loadingIconDiv);
  10046. }
  10047. }, {
  10048. key: "update",
  10049. value: function update(scale, rotation) {
  10050. this.scale = scale || this.scale;
  10051. if (typeof rotation !== "undefined") {
  10052. this.rotation = rotation;
  10053. }
  10054. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10055. this.viewport = this.viewport.clone({
  10056. scale: this.scale * _ui_utils.CSS_UNITS,
  10057. rotation: totalRotation
  10058. });
  10059. if (this.svg) {
  10060. this.cssTransform(this.svg, true);
  10061. this.eventBus.dispatch("pagerendered", {
  10062. source: this,
  10063. pageNumber: this.id,
  10064. cssTransform: true,
  10065. timestamp: performance.now()
  10066. });
  10067. return;
  10068. }
  10069. var isScalingRestricted = false;
  10070. if (this.canvas && this.maxCanvasPixels > 0) {
  10071. var outputScale = this.outputScale;
  10072. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  10073. isScalingRestricted = true;
  10074. }
  10075. }
  10076. if (this.canvas) {
  10077. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  10078. this.cssTransform(this.canvas, true);
  10079. this.eventBus.dispatch("pagerendered", {
  10080. source: this,
  10081. pageNumber: this.id,
  10082. cssTransform: true,
  10083. timestamp: performance.now()
  10084. });
  10085. return;
  10086. }
  10087. if (!this.zoomLayer && !this.canvas.hasAttribute("hidden")) {
  10088. this.zoomLayer = this.canvas.parentNode;
  10089. this.zoomLayer.style.position = "absolute";
  10090. }
  10091. }
  10092. if (this.zoomLayer) {
  10093. this.cssTransform(this.zoomLayer.firstChild);
  10094. }
  10095. this.reset(true, true);
  10096. }
  10097. }, {
  10098. key: "cancelRendering",
  10099. value: function cancelRendering() {
  10100. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10101. if (this.paintTask) {
  10102. this.paintTask.cancel();
  10103. this.paintTask = null;
  10104. }
  10105. this.resume = null;
  10106. if (this.textLayer) {
  10107. this.textLayer.cancel();
  10108. this.textLayer = null;
  10109. }
  10110. if (!keepAnnotations && this.annotationLayer) {
  10111. this.annotationLayer.cancel();
  10112. this.annotationLayer = null;
  10113. }
  10114. }
  10115. }, {
  10116. key: "cssTransform",
  10117. value: function cssTransform(target) {
  10118. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10119. var width = this.viewport.width;
  10120. var height = this.viewport.height;
  10121. var div = this.div;
  10122. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
  10123. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
  10124. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  10125. var absRotation = Math.abs(relativeRotation);
  10126. var scaleX = 1,
  10127. scaleY = 1;
  10128. if (absRotation === 90 || absRotation === 270) {
  10129. scaleX = height / width;
  10130. scaleY = width / height;
  10131. }
  10132. var cssTransform = "rotate(" + relativeRotation + "deg) " + "scale(" + scaleX + "," + scaleY + ")";
  10133. target.style.transform = cssTransform;
  10134. if (this.textLayer) {
  10135. var textLayerViewport = this.textLayer.viewport;
  10136. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  10137. var textAbsRotation = Math.abs(textRelativeRotation);
  10138. var scale = width / textLayerViewport.width;
  10139. if (textAbsRotation === 90 || textAbsRotation === 270) {
  10140. scale = width / textLayerViewport.height;
  10141. }
  10142. var textLayerDiv = this.textLayer.textLayerDiv;
  10143. var transX, transY;
  10144. switch (textAbsRotation) {
  10145. case 0:
  10146. transX = transY = 0;
  10147. break;
  10148. case 90:
  10149. transX = 0;
  10150. transY = "-" + textLayerDiv.style.height;
  10151. break;
  10152. case 180:
  10153. transX = "-" + textLayerDiv.style.width;
  10154. transY = "-" + textLayerDiv.style.height;
  10155. break;
  10156. case 270:
  10157. transX = "-" + textLayerDiv.style.width;
  10158. transY = 0;
  10159. break;
  10160. default:
  10161. console.error("Bad rotation value.");
  10162. break;
  10163. }
  10164. textLayerDiv.style.transform = "rotate(" + textAbsRotation + "deg) " + "scale(" + scale + ", " + scale + ") " + "translate(" + transX + ", " + transY + ")";
  10165. textLayerDiv.style.transformOrigin = "0% 0%";
  10166. }
  10167. if (redrawAnnotations && this.annotationLayer) {
  10168. this.annotationLayer.render(this.viewport, "display");
  10169. }
  10170. }
  10171. }, {
  10172. key: "getPagePoint",
  10173. value: function getPagePoint(x, y) {
  10174. return this.viewport.convertToPdfPoint(x, y);
  10175. }
  10176. }, {
  10177. key: "draw",
  10178. value: function draw() {
  10179. var _this = this;
  10180. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  10181. console.error("Must be in new state before drawing");
  10182. this.reset();
  10183. }
  10184. var div = this.div,
  10185. pdfPage = this.pdfPage;
  10186. if (!pdfPage) {
  10187. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10188. if (this.loadingIconDiv) {
  10189. div.removeChild(this.loadingIconDiv);
  10190. delete this.loadingIconDiv;
  10191. }
  10192. return Promise.reject(new Error("pdfPage is not loaded"));
  10193. }
  10194. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10195. var canvasWrapper = document.createElement("div");
  10196. canvasWrapper.style.width = div.style.width;
  10197. canvasWrapper.style.height = div.style.height;
  10198. canvasWrapper.classList.add("canvasWrapper");
  10199. if (this.annotationLayer && this.annotationLayer.div) {
  10200. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  10201. } else {
  10202. div.appendChild(canvasWrapper);
  10203. }
  10204. var textLayer = null;
  10205. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  10206. var textLayerDiv = document.createElement("div");
  10207. textLayerDiv.className = "textLayer";
  10208. textLayerDiv.style.width = canvasWrapper.style.width;
  10209. textLayerDiv.style.height = canvasWrapper.style.height;
  10210. if (this.annotationLayer && this.annotationLayer.div) {
  10211. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  10212. } else {
  10213. div.appendChild(textLayerDiv);
  10214. }
  10215. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, this.eventBus);
  10216. }
  10217. this.textLayer = textLayer;
  10218. var renderContinueCallback = null;
  10219. if (this.renderingQueue) {
  10220. renderContinueCallback = function renderContinueCallback(cont) {
  10221. if (!_this.renderingQueue.isHighestPriority(_this)) {
  10222. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  10223. _this.resume = function () {
  10224. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10225. cont();
  10226. };
  10227. return;
  10228. }
  10229. cont();
  10230. };
  10231. }
  10232. var finishPaintTask = /*#__PURE__*/function () {
  10233. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(error) {
  10234. return _regenerator["default"].wrap(function _callee$(_context) {
  10235. while (1) {
  10236. switch (_context.prev = _context.next) {
  10237. case 0:
  10238. if (paintTask === _this.paintTask) {
  10239. _this.paintTask = null;
  10240. }
  10241. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  10242. _context.next = 4;
  10243. break;
  10244. }
  10245. _this.error = null;
  10246. return _context.abrupt("return");
  10247. case 4:
  10248. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10249. if (_this.loadingIconDiv) {
  10250. div.removeChild(_this.loadingIconDiv);
  10251. delete _this.loadingIconDiv;
  10252. }
  10253. _this._resetZoomLayer(true);
  10254. _this.error = error;
  10255. _this.stats = pdfPage.stats;
  10256. _this.eventBus.dispatch("pagerendered", {
  10257. source: _this,
  10258. pageNumber: _this.id,
  10259. cssTransform: false,
  10260. timestamp: performance.now()
  10261. });
  10262. if (!error) {
  10263. _context.next = 12;
  10264. break;
  10265. }
  10266. throw error;
  10267. case 12:
  10268. case "end":
  10269. return _context.stop();
  10270. }
  10271. }
  10272. }, _callee);
  10273. }));
  10274. return function finishPaintTask(_x) {
  10275. return _ref.apply(this, arguments);
  10276. };
  10277. }();
  10278. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  10279. paintTask.onRenderContinue = renderContinueCallback;
  10280. this.paintTask = paintTask;
  10281. var resultPromise = paintTask.promise.then(function () {
  10282. return finishPaintTask(null).then(function () {
  10283. if (textLayer) {
  10284. var readableStream = pdfPage.streamTextContent({
  10285. normalizeWhitespace: true
  10286. });
  10287. textLayer.setTextContentStream(readableStream);
  10288. textLayer.render();
  10289. }
  10290. });
  10291. }, function (reason) {
  10292. return finishPaintTask(reason);
  10293. });
  10294. if (this.annotationLayerFactory) {
  10295. if (!this.annotationLayer) {
  10296. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  10297. }
  10298. this.annotationLayer.render(this.viewport, "display");
  10299. }
  10300. div.setAttribute("data-loaded", true);
  10301. this.eventBus.dispatch("pagerender", {
  10302. source: this,
  10303. pageNumber: this.id
  10304. });
  10305. return resultPromise;
  10306. }
  10307. }, {
  10308. key: "paintOnCanvas",
  10309. value: function paintOnCanvas(canvasWrapper) {
  10310. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  10311. var result = {
  10312. promise: renderCapability.promise,
  10313. onRenderContinue: function onRenderContinue(cont) {
  10314. cont();
  10315. },
  10316. cancel: function cancel() {
  10317. renderTask.cancel();
  10318. }
  10319. };
  10320. var viewport = this.viewport;
  10321. var canvas = document.createElement("canvas");
  10322. this.l10n.get("page_canvas", {
  10323. page: this.id
  10324. }, "Page {{page}}").then(function (msg) {
  10325. canvas.setAttribute("aria-label", msg);
  10326. });
  10327. canvas.setAttribute("hidden", "hidden");
  10328. var isCanvasHidden = true;
  10329. var showCanvas = function showCanvas() {
  10330. if (isCanvasHidden) {
  10331. canvas.removeAttribute("hidden");
  10332. isCanvasHidden = false;
  10333. }
  10334. };
  10335. canvasWrapper.appendChild(canvas);
  10336. this.canvas = canvas;
  10337. canvas.mozOpaque = true;
  10338. var ctx = canvas.getContext("2d", {
  10339. alpha: false
  10340. });
  10341. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  10342. this.outputScale = outputScale;
  10343. if (this.useOnlyCssZoom) {
  10344. var actualSizeViewport = viewport.clone({
  10345. scale: _ui_utils.CSS_UNITS
  10346. });
  10347. outputScale.sx *= actualSizeViewport.width / viewport.width;
  10348. outputScale.sy *= actualSizeViewport.height / viewport.height;
  10349. outputScale.scaled = true;
  10350. }
  10351. if (this.maxCanvasPixels > 0) {
  10352. var pixelsInViewport = viewport.width * viewport.height;
  10353. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  10354. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  10355. outputScale.sx = maxScale;
  10356. outputScale.sy = maxScale;
  10357. outputScale.scaled = true;
  10358. this.hasRestrictedScaling = true;
  10359. } else {
  10360. this.hasRestrictedScaling = false;
  10361. }
  10362. }
  10363. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  10364. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  10365. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  10366. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  10367. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
  10368. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
  10369. this.paintedViewportMap.set(canvas, viewport);
  10370. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  10371. var renderContext = {
  10372. canvasContext: ctx,
  10373. transform: transform,
  10374. viewport: this.viewport,
  10375. enableWebGL: this.enableWebGL,
  10376. renderInteractiveForms: this.renderInteractiveForms
  10377. };
  10378. var renderTask = this.pdfPage.render(renderContext);
  10379. renderTask.onContinue = function (cont) {
  10380. showCanvas();
  10381. if (result.onRenderContinue) {
  10382. result.onRenderContinue(cont);
  10383. } else {
  10384. cont();
  10385. }
  10386. };
  10387. renderTask.promise.then(function () {
  10388. showCanvas();
  10389. renderCapability.resolve(undefined);
  10390. }, function (error) {
  10391. showCanvas();
  10392. renderCapability.reject(error);
  10393. });
  10394. return result;
  10395. }
  10396. }, {
  10397. key: "paintOnSvg",
  10398. value: function paintOnSvg(wrapper) {
  10399. var _this2 = this;
  10400. var cancelled = false;
  10401. var ensureNotCancelled = function ensureNotCancelled() {
  10402. if (cancelled) {
  10403. throw new _pdfjsLib.RenderingCancelledException("Rendering cancelled, page ".concat(_this2.id), "svg");
  10404. }
  10405. };
  10406. var pdfPage = this.pdfPage;
  10407. var actualSizeViewport = this.viewport.clone({
  10408. scale: _ui_utils.CSS_UNITS
  10409. });
  10410. var promise = pdfPage.getOperatorList().then(function (opList) {
  10411. ensureNotCancelled();
  10412. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  10413. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  10414. ensureNotCancelled();
  10415. _this2.svg = svg;
  10416. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  10417. svg.style.width = wrapper.style.width;
  10418. svg.style.height = wrapper.style.height;
  10419. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10420. wrapper.appendChild(svg);
  10421. });
  10422. });
  10423. return {
  10424. promise: promise,
  10425. onRenderContinue: function onRenderContinue(cont) {
  10426. cont();
  10427. },
  10428. cancel: function cancel() {
  10429. cancelled = true;
  10430. }
  10431. };
  10432. }
  10433. }, {
  10434. key: "setPageLabel",
  10435. value: function setPageLabel(label) {
  10436. this.pageLabel = typeof label === "string" ? label : null;
  10437. if (this.pageLabel !== null) {
  10438. this.div.setAttribute("data-page-label", this.pageLabel);
  10439. } else {
  10440. this.div.removeAttribute("data-page-label");
  10441. }
  10442. }
  10443. }, {
  10444. key: "width",
  10445. get: function get() {
  10446. return this.viewport.width;
  10447. }
  10448. }, {
  10449. key: "height",
  10450. get: function get() {
  10451. return this.viewport.height;
  10452. }
  10453. }]);
  10454. return PDFPageView;
  10455. }();
  10456. exports.PDFPageView = PDFPageView;
  10457. /***/ }),
  10458. /* 31 */
  10459. /***/ (function(module, exports, __webpack_require__) {
  10460. "use strict";
  10461. Object.defineProperty(exports, "__esModule", {
  10462. value: true
  10463. });
  10464. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
  10465. var _pdfjsLib = __webpack_require__(8);
  10466. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10467. 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); } }
  10468. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10469. var EXPAND_DIVS_TIMEOUT = 300;
  10470. var TextLayerBuilder = /*#__PURE__*/function () {
  10471. function TextLayerBuilder(_ref) {
  10472. var textLayerDiv = _ref.textLayerDiv,
  10473. eventBus = _ref.eventBus,
  10474. pageIndex = _ref.pageIndex,
  10475. viewport = _ref.viewport,
  10476. _ref$findController = _ref.findController,
  10477. findController = _ref$findController === void 0 ? null : _ref$findController,
  10478. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  10479. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  10480. _classCallCheck(this, TextLayerBuilder);
  10481. this.textLayerDiv = textLayerDiv;
  10482. this.eventBus = eventBus;
  10483. this.textContent = null;
  10484. this.textContentItemsStr = [];
  10485. this.textContentStream = null;
  10486. this.renderingDone = false;
  10487. this.pageIdx = pageIndex;
  10488. this.pageNumber = this.pageIdx + 1;
  10489. this.matches = [];
  10490. this.viewport = viewport;
  10491. this.textDivs = [];
  10492. this.findController = findController;
  10493. this.textLayerRenderTask = null;
  10494. this.enhanceTextSelection = enhanceTextSelection;
  10495. this._onUpdateTextLayerMatches = null;
  10496. this._bindMouse();
  10497. }
  10498. _createClass(TextLayerBuilder, [{
  10499. key: "_finishRendering",
  10500. value: function _finishRendering() {
  10501. this.renderingDone = true;
  10502. if (!this.enhanceTextSelection) {
  10503. var endOfContent = document.createElement("div");
  10504. endOfContent.className = "endOfContent";
  10505. this.textLayerDiv.appendChild(endOfContent);
  10506. }
  10507. this.eventBus.dispatch("textlayerrendered", {
  10508. source: this,
  10509. pageNumber: this.pageNumber,
  10510. numTextDivs: this.textDivs.length
  10511. });
  10512. }
  10513. }, {
  10514. key: "render",
  10515. value: function render() {
  10516. var _this = this;
  10517. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10518. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  10519. return;
  10520. }
  10521. this.cancel();
  10522. this.textDivs = [];
  10523. var textLayerFrag = document.createDocumentFragment();
  10524. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  10525. textContent: this.textContent,
  10526. textContentStream: this.textContentStream,
  10527. container: textLayerFrag,
  10528. viewport: this.viewport,
  10529. textDivs: this.textDivs,
  10530. textContentItemsStr: this.textContentItemsStr,
  10531. timeout: timeout,
  10532. enhanceTextSelection: this.enhanceTextSelection
  10533. });
  10534. this.textLayerRenderTask.promise.then(function () {
  10535. _this.textLayerDiv.appendChild(textLayerFrag);
  10536. _this._finishRendering();
  10537. _this._updateMatches();
  10538. }, function (reason) {});
  10539. if (!this._onUpdateTextLayerMatches) {
  10540. this._onUpdateTextLayerMatches = function (evt) {
  10541. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  10542. _this._updateMatches();
  10543. }
  10544. };
  10545. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  10546. }
  10547. }
  10548. }, {
  10549. key: "cancel",
  10550. value: function cancel() {
  10551. if (this.textLayerRenderTask) {
  10552. this.textLayerRenderTask.cancel();
  10553. this.textLayerRenderTask = null;
  10554. }
  10555. if (this._onUpdateTextLayerMatches) {
  10556. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  10557. this._onUpdateTextLayerMatches = null;
  10558. }
  10559. }
  10560. }, {
  10561. key: "setTextContentStream",
  10562. value: function setTextContentStream(readableStream) {
  10563. this.cancel();
  10564. this.textContentStream = readableStream;
  10565. }
  10566. }, {
  10567. key: "setTextContent",
  10568. value: function setTextContent(textContent) {
  10569. this.cancel();
  10570. this.textContent = textContent;
  10571. }
  10572. }, {
  10573. key: "_convertMatches",
  10574. value: function _convertMatches(matches, matchesLength) {
  10575. if (!matches) {
  10576. return [];
  10577. }
  10578. var findController = this.findController,
  10579. textContentItemsStr = this.textContentItemsStr;
  10580. var i = 0,
  10581. iIndex = 0;
  10582. var end = textContentItemsStr.length - 1;
  10583. var queryLen = findController.state.query.length;
  10584. var result = [];
  10585. for (var m = 0, mm = matches.length; m < mm; m++) {
  10586. var matchIdx = matches[m];
  10587. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  10588. iIndex += textContentItemsStr[i].length;
  10589. i++;
  10590. }
  10591. if (i === textContentItemsStr.length) {
  10592. console.error("Could not find a matching mapping");
  10593. }
  10594. var match = {
  10595. begin: {
  10596. divIdx: i,
  10597. offset: matchIdx - iIndex
  10598. }
  10599. };
  10600. if (matchesLength) {
  10601. matchIdx += matchesLength[m];
  10602. } else {
  10603. matchIdx += queryLen;
  10604. }
  10605. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  10606. iIndex += textContentItemsStr[i].length;
  10607. i++;
  10608. }
  10609. match.end = {
  10610. divIdx: i,
  10611. offset: matchIdx - iIndex
  10612. };
  10613. result.push(match);
  10614. }
  10615. return result;
  10616. }
  10617. }, {
  10618. key: "_renderMatches",
  10619. value: function _renderMatches(matches) {
  10620. if (matches.length === 0) {
  10621. return;
  10622. }
  10623. var findController = this.findController,
  10624. pageIdx = this.pageIdx,
  10625. textContentItemsStr = this.textContentItemsStr,
  10626. textDivs = this.textDivs;
  10627. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  10628. var selectedMatchIdx = findController.selected.matchIdx;
  10629. var highlightAll = findController.state.highlightAll;
  10630. var prevEnd = null;
  10631. var infinity = {
  10632. divIdx: -1,
  10633. offset: undefined
  10634. };
  10635. function beginText(begin, className) {
  10636. var divIdx = begin.divIdx;
  10637. textDivs[divIdx].textContent = "";
  10638. appendTextToDiv(divIdx, 0, begin.offset, className);
  10639. }
  10640. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  10641. var div = textDivs[divIdx];
  10642. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  10643. var node = document.createTextNode(content);
  10644. if (className) {
  10645. var span = document.createElement("span");
  10646. span.className = className;
  10647. span.appendChild(node);
  10648. div.appendChild(span);
  10649. return;
  10650. }
  10651. div.appendChild(node);
  10652. }
  10653. var i0 = selectedMatchIdx,
  10654. i1 = i0 + 1;
  10655. if (highlightAll) {
  10656. i0 = 0;
  10657. i1 = matches.length;
  10658. } else if (!isSelectedPage) {
  10659. return;
  10660. }
  10661. for (var i = i0; i < i1; i++) {
  10662. var match = matches[i];
  10663. var begin = match.begin;
  10664. var end = match.end;
  10665. var isSelected = isSelectedPage && i === selectedMatchIdx;
  10666. var highlightSuffix = isSelected ? " selected" : "";
  10667. if (isSelected) {
  10668. findController.scrollMatchIntoView({
  10669. element: textDivs[begin.divIdx],
  10670. pageIndex: pageIdx,
  10671. matchIndex: selectedMatchIdx
  10672. });
  10673. }
  10674. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  10675. if (prevEnd !== null) {
  10676. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  10677. }
  10678. beginText(begin);
  10679. } else {
  10680. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  10681. }
  10682. if (begin.divIdx === end.divIdx) {
  10683. appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  10684. } else {
  10685. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  10686. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  10687. textDivs[n0].className = "highlight middle" + highlightSuffix;
  10688. }
  10689. beginText(end, "highlight end" + highlightSuffix);
  10690. }
  10691. prevEnd = end;
  10692. }
  10693. if (prevEnd) {
  10694. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  10695. }
  10696. }
  10697. }, {
  10698. key: "_updateMatches",
  10699. value: function _updateMatches() {
  10700. if (!this.renderingDone) {
  10701. return;
  10702. }
  10703. var findController = this.findController,
  10704. matches = this.matches,
  10705. pageIdx = this.pageIdx,
  10706. textContentItemsStr = this.textContentItemsStr,
  10707. textDivs = this.textDivs;
  10708. var clearedUntilDivIdx = -1;
  10709. for (var i = 0, ii = matches.length; i < ii; i++) {
  10710. var match = matches[i];
  10711. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  10712. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  10713. var div = textDivs[n];
  10714. div.textContent = textContentItemsStr[n];
  10715. div.className = "";
  10716. }
  10717. clearedUntilDivIdx = match.end.divIdx + 1;
  10718. }
  10719. if (!findController || !findController.highlightMatches) {
  10720. return;
  10721. }
  10722. var pageMatches = findController.pageMatches[pageIdx] || null;
  10723. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  10724. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  10725. this._renderMatches(this.matches);
  10726. }
  10727. }, {
  10728. key: "_bindMouse",
  10729. value: function _bindMouse() {
  10730. var _this2 = this;
  10731. var div = this.textLayerDiv;
  10732. var expandDivsTimer = null;
  10733. div.addEventListener("mousedown", function (evt) {
  10734. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  10735. _this2.textLayerRenderTask.expandTextDivs(true);
  10736. if (expandDivsTimer) {
  10737. clearTimeout(expandDivsTimer);
  10738. expandDivsTimer = null;
  10739. }
  10740. return;
  10741. }
  10742. var end = div.querySelector(".endOfContent");
  10743. if (!end) {
  10744. return;
  10745. }
  10746. var adjustTop = evt.target !== div;
  10747. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  10748. if (adjustTop) {
  10749. var divBounds = div.getBoundingClientRect();
  10750. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  10751. end.style.top = (r * 100).toFixed(2) + "%";
  10752. }
  10753. end.classList.add("active");
  10754. });
  10755. div.addEventListener("mouseup", function () {
  10756. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  10757. expandDivsTimer = setTimeout(function () {
  10758. if (_this2.textLayerRenderTask) {
  10759. _this2.textLayerRenderTask.expandTextDivs(false);
  10760. }
  10761. expandDivsTimer = null;
  10762. }, EXPAND_DIVS_TIMEOUT);
  10763. return;
  10764. }
  10765. var end = div.querySelector(".endOfContent");
  10766. if (!end) {
  10767. return;
  10768. }
  10769. end.style.top = "";
  10770. end.classList.remove("active");
  10771. });
  10772. }
  10773. }]);
  10774. return TextLayerBuilder;
  10775. }();
  10776. exports.TextLayerBuilder = TextLayerBuilder;
  10777. var DefaultTextLayerFactory = /*#__PURE__*/function () {
  10778. function DefaultTextLayerFactory() {
  10779. _classCallCheck(this, DefaultTextLayerFactory);
  10780. }
  10781. _createClass(DefaultTextLayerFactory, [{
  10782. key: "createTextLayerBuilder",
  10783. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  10784. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10785. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  10786. return new TextLayerBuilder({
  10787. textLayerDiv: textLayerDiv,
  10788. pageIndex: pageIndex,
  10789. viewport: viewport,
  10790. enhanceTextSelection: enhanceTextSelection,
  10791. eventBus: eventBus
  10792. });
  10793. }
  10794. }]);
  10795. return DefaultTextLayerFactory;
  10796. }();
  10797. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  10798. /***/ }),
  10799. /* 32 */
  10800. /***/ (function(module, exports, __webpack_require__) {
  10801. "use strict";
  10802. Object.defineProperty(exports, "__esModule", {
  10803. value: true
  10804. });
  10805. exports.SecondaryToolbar = void 0;
  10806. var _ui_utils = __webpack_require__(5);
  10807. var _pdf_cursor_tools = __webpack_require__(9);
  10808. var _pdf_single_page_viewer = __webpack_require__(33);
  10809. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  10810. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  10811. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  10812. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10813. 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); } }
  10814. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10815. var SecondaryToolbar = /*#__PURE__*/function () {
  10816. function SecondaryToolbar(options, mainContainer, eventBus) {
  10817. var _this = this;
  10818. _classCallCheck(this, SecondaryToolbar);
  10819. this.toolbar = options.toolbar;
  10820. this.toggleButton = options.toggleButton;
  10821. this.toolbarButtonContainer = options.toolbarButtonContainer;
  10822. this.buttons = [{
  10823. element: options.presentationModeButton,
  10824. eventName: "presentationmode",
  10825. close: true
  10826. }, {
  10827. element: options.openFileButton,
  10828. eventName: "openfile",
  10829. close: true
  10830. }, {
  10831. element: options.printButton,
  10832. eventName: "print",
  10833. close: true
  10834. }, {
  10835. element: options.downloadButton,
  10836. eventName: "download",
  10837. close: true
  10838. }, {
  10839. element: options.viewBookmarkButton,
  10840. eventName: null,
  10841. close: true
  10842. }, {
  10843. element: options.firstPageButton,
  10844. eventName: "firstpage",
  10845. close: true
  10846. }, {
  10847. element: options.lastPageButton,
  10848. eventName: "lastpage",
  10849. close: true
  10850. }, {
  10851. element: options.pageRotateCwButton,
  10852. eventName: "rotatecw",
  10853. close: false
  10854. }, {
  10855. element: options.pageRotateCcwButton,
  10856. eventName: "rotateccw",
  10857. close: false
  10858. }, {
  10859. element: options.cursorSelectToolButton,
  10860. eventName: "switchcursortool",
  10861. eventDetails: {
  10862. tool: _pdf_cursor_tools.CursorTool.SELECT
  10863. },
  10864. close: true
  10865. }, {
  10866. element: options.cursorHandToolButton,
  10867. eventName: "switchcursortool",
  10868. eventDetails: {
  10869. tool: _pdf_cursor_tools.CursorTool.HAND
  10870. },
  10871. close: true
  10872. }, {
  10873. element: options.scrollVerticalButton,
  10874. eventName: "switchscrollmode",
  10875. eventDetails: {
  10876. mode: _ui_utils.ScrollMode.VERTICAL
  10877. },
  10878. close: true
  10879. }, {
  10880. element: options.scrollHorizontalButton,
  10881. eventName: "switchscrollmode",
  10882. eventDetails: {
  10883. mode: _ui_utils.ScrollMode.HORIZONTAL
  10884. },
  10885. close: true
  10886. }, {
  10887. element: options.scrollWrappedButton,
  10888. eventName: "switchscrollmode",
  10889. eventDetails: {
  10890. mode: _ui_utils.ScrollMode.WRAPPED
  10891. },
  10892. close: true
  10893. }, {
  10894. element: options.spreadNoneButton,
  10895. eventName: "switchspreadmode",
  10896. eventDetails: {
  10897. mode: _ui_utils.SpreadMode.NONE
  10898. },
  10899. close: true
  10900. }, {
  10901. element: options.spreadOddButton,
  10902. eventName: "switchspreadmode",
  10903. eventDetails: {
  10904. mode: _ui_utils.SpreadMode.ODD
  10905. },
  10906. close: true
  10907. }, {
  10908. element: options.spreadEvenButton,
  10909. eventName: "switchspreadmode",
  10910. eventDetails: {
  10911. mode: _ui_utils.SpreadMode.EVEN
  10912. },
  10913. close: true
  10914. }, {
  10915. element: options.documentPropertiesButton,
  10916. eventName: "documentproperties",
  10917. close: true
  10918. }];
  10919. this.items = {
  10920. firstPage: options.firstPageButton,
  10921. lastPage: options.lastPageButton,
  10922. pageRotateCw: options.pageRotateCwButton,
  10923. pageRotateCcw: options.pageRotateCcwButton
  10924. };
  10925. this.mainContainer = mainContainer;
  10926. this.eventBus = eventBus;
  10927. this.opened = false;
  10928. this.containerHeight = null;
  10929. this.previousContainerHeight = null;
  10930. this.reset();
  10931. this._bindClickListeners();
  10932. this._bindCursorToolsListener(options);
  10933. this._bindScrollModeListener(options);
  10934. this._bindSpreadModeListener(options);
  10935. this.eventBus._on("resize", this._setMaxHeight.bind(this));
  10936. this.eventBus._on("baseviewerinit", function (evt) {
  10937. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  10938. _this.toolbarButtonContainer.classList.add("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  10939. } else {
  10940. _this.toolbarButtonContainer.classList.remove("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  10941. }
  10942. });
  10943. }
  10944. _createClass(SecondaryToolbar, [{
  10945. key: "setPageNumber",
  10946. value: function setPageNumber(pageNumber) {
  10947. this.pageNumber = pageNumber;
  10948. this._updateUIState();
  10949. }
  10950. }, {
  10951. key: "setPagesCount",
  10952. value: function setPagesCount(pagesCount) {
  10953. this.pagesCount = pagesCount;
  10954. this._updateUIState();
  10955. }
  10956. }, {
  10957. key: "reset",
  10958. value: function reset() {
  10959. this.pageNumber = 0;
  10960. this.pagesCount = 0;
  10961. this._updateUIState();
  10962. this.eventBus.dispatch("secondarytoolbarreset", {
  10963. source: this
  10964. });
  10965. }
  10966. }, {
  10967. key: "_updateUIState",
  10968. value: function _updateUIState() {
  10969. this.items.firstPage.disabled = this.pageNumber <= 1;
  10970. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  10971. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  10972. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  10973. }
  10974. }, {
  10975. key: "_bindClickListeners",
  10976. value: function _bindClickListeners() {
  10977. var _this2 = this;
  10978. this.toggleButton.addEventListener("click", this.toggle.bind(this));
  10979. var _iterator = _createForOfIteratorHelper(this.buttons),
  10980. _step;
  10981. try {
  10982. var _loop = function _loop() {
  10983. var _step$value = _step.value,
  10984. element = _step$value.element,
  10985. eventName = _step$value.eventName,
  10986. close = _step$value.close,
  10987. eventDetails = _step$value.eventDetails;
  10988. element.addEventListener("click", function (evt) {
  10989. if (eventName !== null) {
  10990. var details = {
  10991. source: _this2
  10992. };
  10993. for (var property in eventDetails) {
  10994. details[property] = eventDetails[property];
  10995. }
  10996. _this2.eventBus.dispatch(eventName, details);
  10997. }
  10998. if (close) {
  10999. _this2.close();
  11000. }
  11001. });
  11002. };
  11003. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11004. _loop();
  11005. }
  11006. } catch (err) {
  11007. _iterator.e(err);
  11008. } finally {
  11009. _iterator.f();
  11010. }
  11011. }
  11012. }, {
  11013. key: "_bindCursorToolsListener",
  11014. value: function _bindCursorToolsListener(buttons) {
  11015. this.eventBus._on("cursortoolchanged", function (_ref) {
  11016. var tool = _ref.tool;
  11017. buttons.cursorSelectToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.SELECT);
  11018. buttons.cursorHandToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.HAND);
  11019. });
  11020. }
  11021. }, {
  11022. key: "_bindScrollModeListener",
  11023. value: function _bindScrollModeListener(buttons) {
  11024. var _this3 = this;
  11025. function scrollModeChanged(_ref2) {
  11026. var mode = _ref2.mode;
  11027. buttons.scrollVerticalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.VERTICAL);
  11028. buttons.scrollHorizontalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.HORIZONTAL);
  11029. buttons.scrollWrappedButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.WRAPPED);
  11030. var isScrollModeHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
  11031. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  11032. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  11033. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  11034. }
  11035. this.eventBus._on("scrollmodechanged", scrollModeChanged);
  11036. this.eventBus._on("secondarytoolbarreset", function (evt) {
  11037. if (evt.source === _this3) {
  11038. scrollModeChanged({
  11039. mode: _ui_utils.ScrollMode.VERTICAL
  11040. });
  11041. }
  11042. });
  11043. }
  11044. }, {
  11045. key: "_bindSpreadModeListener",
  11046. value: function _bindSpreadModeListener(buttons) {
  11047. var _this4 = this;
  11048. function spreadModeChanged(_ref3) {
  11049. var mode = _ref3.mode;
  11050. buttons.spreadNoneButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.NONE);
  11051. buttons.spreadOddButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.ODD);
  11052. buttons.spreadEvenButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.EVEN);
  11053. }
  11054. this.eventBus._on("spreadmodechanged", spreadModeChanged);
  11055. this.eventBus._on("secondarytoolbarreset", function (evt) {
  11056. if (evt.source === _this4) {
  11057. spreadModeChanged({
  11058. mode: _ui_utils.SpreadMode.NONE
  11059. });
  11060. }
  11061. });
  11062. }
  11063. }, {
  11064. key: "open",
  11065. value: function open() {
  11066. if (this.opened) {
  11067. return;
  11068. }
  11069. this.opened = true;
  11070. this._setMaxHeight();
  11071. this.toggleButton.classList.add("toggled");
  11072. this.toolbar.classList.remove("hidden");
  11073. }
  11074. }, {
  11075. key: "close",
  11076. value: function close() {
  11077. if (!this.opened) {
  11078. return;
  11079. }
  11080. this.opened = false;
  11081. this.toolbar.classList.add("hidden");
  11082. this.toggleButton.classList.remove("toggled");
  11083. }
  11084. }, {
  11085. key: "toggle",
  11086. value: function toggle() {
  11087. if (this.opened) {
  11088. this.close();
  11089. } else {
  11090. this.open();
  11091. }
  11092. }
  11093. }, {
  11094. key: "_setMaxHeight",
  11095. value: function _setMaxHeight() {
  11096. if (!this.opened) {
  11097. return;
  11098. }
  11099. this.containerHeight = this.mainContainer.clientHeight;
  11100. if (this.containerHeight === this.previousContainerHeight) {
  11101. return;
  11102. }
  11103. this.toolbarButtonContainer.style.maxHeight = "".concat(this.containerHeight - _ui_utils.SCROLLBAR_PADDING, "px");
  11104. this.previousContainerHeight = this.containerHeight;
  11105. }
  11106. }, {
  11107. key: "isOpen",
  11108. get: function get() {
  11109. return this.opened;
  11110. }
  11111. }]);
  11112. return SecondaryToolbar;
  11113. }();
  11114. exports.SecondaryToolbar = SecondaryToolbar;
  11115. /***/ }),
  11116. /* 33 */
  11117. /***/ (function(module, exports, __webpack_require__) {
  11118. "use strict";
  11119. Object.defineProperty(exports, "__esModule", {
  11120. value: true
  11121. });
  11122. exports.PDFSinglePageViewer = void 0;
  11123. var _base_viewer = __webpack_require__(28);
  11124. var _pdfjsLib = __webpack_require__(8);
  11125. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11126. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11127. 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); } }
  11128. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11129. 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); }
  11130. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  11131. 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); }
  11132. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11133. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  11134. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11135. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11136. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  11137. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11138. var PDFSinglePageViewer = /*#__PURE__*/function (_BaseViewer) {
  11139. _inherits(PDFSinglePageViewer, _BaseViewer);
  11140. var _super = _createSuper(PDFSinglePageViewer);
  11141. function PDFSinglePageViewer(options) {
  11142. var _this;
  11143. _classCallCheck(this, PDFSinglePageViewer);
  11144. _this = _super.call(this, options);
  11145. _this.eventBus._on("pagesinit", function (evt) {
  11146. _this._ensurePageViewVisible();
  11147. });
  11148. return _this;
  11149. }
  11150. _createClass(PDFSinglePageViewer, [{
  11151. key: "_resetView",
  11152. value: function _resetView() {
  11153. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  11154. this._previousPageNumber = 1;
  11155. this._shadowViewer = document.createDocumentFragment();
  11156. this._updateScrollDown = null;
  11157. }
  11158. }, {
  11159. key: "_ensurePageViewVisible",
  11160. value: function _ensurePageViewVisible() {
  11161. var pageView = this._pages[this._currentPageNumber - 1];
  11162. var previousPageView = this._pages[this._previousPageNumber - 1];
  11163. var viewerNodes = this.viewer.childNodes;
  11164. switch (viewerNodes.length) {
  11165. case 0:
  11166. this.viewer.appendChild(pageView.div);
  11167. break;
  11168. case 1:
  11169. if (viewerNodes[0] !== previousPageView.div) {
  11170. throw new Error("_ensurePageViewVisible: Unexpected previously visible page.");
  11171. }
  11172. if (pageView === previousPageView) {
  11173. break;
  11174. }
  11175. this._shadowViewer.appendChild(previousPageView.div);
  11176. this.viewer.appendChild(pageView.div);
  11177. this.container.scrollTop = 0;
  11178. break;
  11179. default:
  11180. throw new Error("_ensurePageViewVisible: Only one page should be visible at a time.");
  11181. }
  11182. this._previousPageNumber = this._currentPageNumber;
  11183. }
  11184. }, {
  11185. key: "_scrollUpdate",
  11186. value: function _scrollUpdate() {
  11187. if (this._updateScrollDown) {
  11188. this._updateScrollDown();
  11189. }
  11190. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  11191. }
  11192. }, {
  11193. key: "_scrollIntoView",
  11194. value: function _scrollIntoView(_ref) {
  11195. var _this2 = this;
  11196. var pageDiv = _ref.pageDiv,
  11197. _ref$pageSpot = _ref.pageSpot,
  11198. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  11199. _ref$pageNumber = _ref.pageNumber,
  11200. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  11201. if (pageNumber) {
  11202. this._setCurrentPageNumber(pageNumber);
  11203. }
  11204. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  11205. this._ensurePageViewVisible();
  11206. this.update();
  11207. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  11208. pageDiv: pageDiv,
  11209. pageSpot: pageSpot,
  11210. pageNumber: pageNumber
  11211. });
  11212. this._updateScrollDown = function () {
  11213. _this2.scroll.down = scrolledDown;
  11214. _this2._updateScrollDown = null;
  11215. };
  11216. }
  11217. }, {
  11218. key: "_getVisiblePages",
  11219. value: function _getVisiblePages() {
  11220. return this._getCurrentVisiblePage();
  11221. }
  11222. }, {
  11223. key: "_updateHelper",
  11224. value: function _updateHelper(visiblePages) {}
  11225. }, {
  11226. key: "_updateScrollMode",
  11227. value: function _updateScrollMode() {}
  11228. }, {
  11229. key: "_updateSpreadMode",
  11230. value: function _updateSpreadMode() {}
  11231. }, {
  11232. key: "_viewerElement",
  11233. get: function get() {
  11234. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this._shadowViewer);
  11235. }
  11236. }, {
  11237. key: "_isScrollModeHorizontal",
  11238. get: function get() {
  11239. return (0, _pdfjsLib.shadow)(this, "_isScrollModeHorizontal", false);
  11240. }
  11241. }]);
  11242. return PDFSinglePageViewer;
  11243. }(_base_viewer.BaseViewer);
  11244. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  11245. /***/ }),
  11246. /* 34 */
  11247. /***/ (function(module, exports, __webpack_require__) {
  11248. "use strict";
  11249. Object.defineProperty(exports, "__esModule", {
  11250. value: true
  11251. });
  11252. exports.Toolbar = void 0;
  11253. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11254. var _ui_utils = __webpack_require__(5);
  11255. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11256. 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); } }
  11257. 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); }); }; }
  11258. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  11259. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  11260. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  11261. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11262. 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); } }
  11263. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11264. var PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
  11265. var SCALE_SELECT_CONTAINER_WIDTH = 140;
  11266. var SCALE_SELECT_WIDTH = 162;
  11267. var Toolbar = /*#__PURE__*/function () {
  11268. function Toolbar(options, eventBus) {
  11269. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  11270. _classCallCheck(this, Toolbar);
  11271. this.toolbar = options.container;
  11272. this.eventBus = eventBus;
  11273. this.l10n = l10n;
  11274. this.buttons = [{
  11275. element: options.previous,
  11276. eventName: "previouspage"
  11277. }, {
  11278. element: options.next,
  11279. eventName: "nextpage"
  11280. }, {
  11281. element: options.zoomIn,
  11282. eventName: "zoomin"
  11283. }, {
  11284. element: options.zoomOut,
  11285. eventName: "zoomout"
  11286. }, {
  11287. element: options.openFile,
  11288. eventName: "openfile"
  11289. }, {
  11290. element: options.print,
  11291. eventName: "print"
  11292. }, {
  11293. element: options.presentationModeButton,
  11294. eventName: "presentationmode"
  11295. }, {
  11296. element: options.download,
  11297. eventName: "download"
  11298. }, {
  11299. element: options.viewBookmark,
  11300. eventName: null
  11301. }];
  11302. this.items = {
  11303. numPages: options.numPages,
  11304. pageNumber: options.pageNumber,
  11305. scaleSelectContainer: options.scaleSelectContainer,
  11306. scaleSelect: options.scaleSelect,
  11307. customScaleOption: options.customScaleOption,
  11308. previous: options.previous,
  11309. next: options.next,
  11310. zoomIn: options.zoomIn,
  11311. zoomOut: options.zoomOut
  11312. };
  11313. this._wasLocalized = false;
  11314. this.reset();
  11315. this._bindListeners();
  11316. }
  11317. _createClass(Toolbar, [{
  11318. key: "setPageNumber",
  11319. value: function setPageNumber(pageNumber, pageLabel) {
  11320. this.pageNumber = pageNumber;
  11321. this.pageLabel = pageLabel;
  11322. this._updateUIState(false);
  11323. }
  11324. }, {
  11325. key: "setPagesCount",
  11326. value: function setPagesCount(pagesCount, hasPageLabels) {
  11327. this.pagesCount = pagesCount;
  11328. this.hasPageLabels = hasPageLabels;
  11329. this._updateUIState(true);
  11330. }
  11331. }, {
  11332. key: "setPageScale",
  11333. value: function setPageScale(pageScaleValue, pageScale) {
  11334. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  11335. this.pageScale = pageScale;
  11336. this._updateUIState(false);
  11337. }
  11338. }, {
  11339. key: "reset",
  11340. value: function reset() {
  11341. this.pageNumber = 0;
  11342. this.pageLabel = null;
  11343. this.hasPageLabels = false;
  11344. this.pagesCount = 0;
  11345. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  11346. this.pageScale = _ui_utils.DEFAULT_SCALE;
  11347. this._updateUIState(true);
  11348. this.updateLoadingIndicatorState();
  11349. }
  11350. }, {
  11351. key: "_bindListeners",
  11352. value: function _bindListeners() {
  11353. var _this = this;
  11354. var _this$items = this.items,
  11355. pageNumber = _this$items.pageNumber,
  11356. scaleSelect = _this$items.scaleSelect;
  11357. var self = this;
  11358. var _iterator = _createForOfIteratorHelper(this.buttons),
  11359. _step;
  11360. try {
  11361. var _loop = function _loop() {
  11362. var _step$value = _step.value,
  11363. element = _step$value.element,
  11364. eventName = _step$value.eventName;
  11365. element.addEventListener("click", function (evt) {
  11366. if (eventName !== null) {
  11367. _this.eventBus.dispatch(eventName, {
  11368. source: _this
  11369. });
  11370. }
  11371. });
  11372. };
  11373. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11374. _loop();
  11375. }
  11376. } catch (err) {
  11377. _iterator.e(err);
  11378. } finally {
  11379. _iterator.f();
  11380. }
  11381. pageNumber.addEventListener("click", function () {
  11382. this.select();
  11383. });
  11384. pageNumber.addEventListener("change", function () {
  11385. self.eventBus.dispatch("pagenumberchanged", {
  11386. source: self,
  11387. value: this.value
  11388. });
  11389. });
  11390. scaleSelect.addEventListener("change", function () {
  11391. if (this.value === "custom") {
  11392. return;
  11393. }
  11394. self.eventBus.dispatch("scalechanged", {
  11395. source: self,
  11396. value: this.value
  11397. });
  11398. });
  11399. scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  11400. this.eventBus._on("localized", function () {
  11401. _this._wasLocalized = true;
  11402. _this._adjustScaleWidth();
  11403. _this._updateUIState(true);
  11404. });
  11405. }
  11406. }, {
  11407. key: "_updateUIState",
  11408. value: function _updateUIState() {
  11409. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11410. if (!this._wasLocalized) {
  11411. return;
  11412. }
  11413. var pageNumber = this.pageNumber,
  11414. pagesCount = this.pagesCount,
  11415. pageScaleValue = this.pageScaleValue,
  11416. pageScale = this.pageScale,
  11417. items = this.items;
  11418. if (resetNumPages) {
  11419. if (this.hasPageLabels) {
  11420. items.pageNumber.type = "text";
  11421. } else {
  11422. items.pageNumber.type = "number";
  11423. this.l10n.get("of_pages", {
  11424. pagesCount: pagesCount
  11425. }, "of {{pagesCount}}").then(function (msg) {
  11426. items.numPages.textContent = msg;
  11427. });
  11428. }
  11429. items.pageNumber.max = pagesCount;
  11430. }
  11431. if (this.hasPageLabels) {
  11432. items.pageNumber.value = this.pageLabel;
  11433. this.l10n.get("page_of_pages", {
  11434. pageNumber: pageNumber,
  11435. pagesCount: pagesCount
  11436. }, "({{pageNumber}} of {{pagesCount}})").then(function (msg) {
  11437. items.numPages.textContent = msg;
  11438. });
  11439. } else {
  11440. items.pageNumber.value = pageNumber;
  11441. }
  11442. items.previous.disabled = pageNumber <= 1;
  11443. items.next.disabled = pageNumber >= pagesCount;
  11444. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  11445. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  11446. var customScale = Math.round(pageScale * 10000) / 100;
  11447. this.l10n.get("page_scale_percent", {
  11448. scale: customScale
  11449. }, "{{scale}}%").then(function (msg) {
  11450. var predefinedValueFound = false;
  11451. var _iterator2 = _createForOfIteratorHelper(items.scaleSelect.options),
  11452. _step2;
  11453. try {
  11454. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  11455. var option = _step2.value;
  11456. if (option.value !== pageScaleValue) {
  11457. option.selected = false;
  11458. continue;
  11459. }
  11460. option.selected = true;
  11461. predefinedValueFound = true;
  11462. }
  11463. } catch (err) {
  11464. _iterator2.e(err);
  11465. } finally {
  11466. _iterator2.f();
  11467. }
  11468. if (!predefinedValueFound) {
  11469. items.customScaleOption.textContent = msg;
  11470. items.customScaleOption.selected = true;
  11471. }
  11472. });
  11473. }
  11474. }, {
  11475. key: "updateLoadingIndicatorState",
  11476. value: function updateLoadingIndicatorState() {
  11477. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11478. var pageNumberInput = this.items.pageNumber;
  11479. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  11480. }
  11481. }, {
  11482. key: "_adjustScaleWidth",
  11483. value: function () {
  11484. var _adjustScaleWidth2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  11485. var items, l10n, predefinedValuesPromise, canvas, ctx, _getComputedStyle, fontSize, fontFamily, maxWidth, _iterator3, _step3, predefinedValue, _ctx$measureText, width, overflow;
  11486. return _regenerator["default"].wrap(function _callee$(_context) {
  11487. while (1) {
  11488. switch (_context.prev = _context.next) {
  11489. case 0:
  11490. items = this.items, l10n = this.l10n;
  11491. predefinedValuesPromise = Promise.all([l10n.get("page_scale_auto", null, "Automatic Zoom"), l10n.get("page_scale_actual", null, "Actual Size"), l10n.get("page_scale_fit", null, "Page Fit"), l10n.get("page_scale_width", null, "Page Width")]);
  11492. canvas = document.createElement("canvas");
  11493. canvas.mozOpaque = true;
  11494. ctx = canvas.getContext("2d", {
  11495. alpha: false
  11496. });
  11497. _context.next = 7;
  11498. return _ui_utils.animationStarted;
  11499. case 7:
  11500. _getComputedStyle = getComputedStyle(items.scaleSelect), fontSize = _getComputedStyle.fontSize, fontFamily = _getComputedStyle.fontFamily;
  11501. ctx.font = "".concat(fontSize, " ").concat(fontFamily);
  11502. maxWidth = 0;
  11503. _context.t0 = _createForOfIteratorHelper;
  11504. _context.next = 13;
  11505. return predefinedValuesPromise;
  11506. case 13:
  11507. _context.t1 = _context.sent;
  11508. _iterator3 = (0, _context.t0)(_context.t1);
  11509. try {
  11510. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  11511. predefinedValue = _step3.value;
  11512. _ctx$measureText = ctx.measureText(predefinedValue), width = _ctx$measureText.width;
  11513. if (width > maxWidth) {
  11514. maxWidth = width;
  11515. }
  11516. }
  11517. } catch (err) {
  11518. _iterator3.e(err);
  11519. } finally {
  11520. _iterator3.f();
  11521. }
  11522. overflow = SCALE_SELECT_WIDTH - SCALE_SELECT_CONTAINER_WIDTH;
  11523. maxWidth += 1.5 * overflow;
  11524. if (maxWidth > SCALE_SELECT_CONTAINER_WIDTH) {
  11525. items.scaleSelect.style.width = "".concat(maxWidth + overflow, "px");
  11526. items.scaleSelectContainer.style.width = "".concat(maxWidth, "px");
  11527. }
  11528. canvas.width = 0;
  11529. canvas.height = 0;
  11530. canvas = ctx = null;
  11531. case 22:
  11532. case "end":
  11533. return _context.stop();
  11534. }
  11535. }
  11536. }, _callee, this);
  11537. }));
  11538. function _adjustScaleWidth() {
  11539. return _adjustScaleWidth2.apply(this, arguments);
  11540. }
  11541. return _adjustScaleWidth;
  11542. }()
  11543. }]);
  11544. return Toolbar;
  11545. }();
  11546. exports.Toolbar = Toolbar;
  11547. /***/ }),
  11548. /* 35 */
  11549. /***/ (function(module, exports, __webpack_require__) {
  11550. "use strict";
  11551. Object.defineProperty(exports, "__esModule", {
  11552. value: true
  11553. });
  11554. exports.ViewHistory = void 0;
  11555. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11556. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11557. 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); } }
  11558. 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); }); }; }
  11559. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11560. 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); } }
  11561. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11562. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  11563. var ViewHistory = /*#__PURE__*/function () {
  11564. function ViewHistory(fingerprint) {
  11565. var _this = this;
  11566. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  11567. _classCallCheck(this, ViewHistory);
  11568. this.fingerprint = fingerprint;
  11569. this.cacheSize = cacheSize;
  11570. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  11571. var database = JSON.parse(databaseStr || "{}");
  11572. var index = -1;
  11573. if (!Array.isArray(database.files)) {
  11574. database.files = [];
  11575. } else {
  11576. while (database.files.length >= _this.cacheSize) {
  11577. database.files.shift();
  11578. }
  11579. for (var i = 0, ii = database.files.length; i < ii; i++) {
  11580. var branch = database.files[i];
  11581. if (branch.fingerprint === _this.fingerprint) {
  11582. index = i;
  11583. break;
  11584. }
  11585. }
  11586. }
  11587. if (index === -1) {
  11588. index = database.files.push({
  11589. fingerprint: _this.fingerprint
  11590. }) - 1;
  11591. }
  11592. _this.file = database.files[index];
  11593. _this.database = database;
  11594. });
  11595. }
  11596. _createClass(ViewHistory, [{
  11597. key: "_writeToStorage",
  11598. value: function () {
  11599. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  11600. var databaseStr;
  11601. return _regenerator["default"].wrap(function _callee$(_context) {
  11602. while (1) {
  11603. switch (_context.prev = _context.next) {
  11604. case 0:
  11605. databaseStr = JSON.stringify(this.database);
  11606. localStorage.setItem("pdfjs.history", databaseStr);
  11607. case 2:
  11608. case "end":
  11609. return _context.stop();
  11610. }
  11611. }
  11612. }, _callee, this);
  11613. }));
  11614. function _writeToStorage() {
  11615. return _writeToStorage2.apply(this, arguments);
  11616. }
  11617. return _writeToStorage;
  11618. }()
  11619. }, {
  11620. key: "_readFromStorage",
  11621. value: function () {
  11622. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  11623. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11624. while (1) {
  11625. switch (_context2.prev = _context2.next) {
  11626. case 0:
  11627. return _context2.abrupt("return", localStorage.getItem("pdfjs.history"));
  11628. case 1:
  11629. case "end":
  11630. return _context2.stop();
  11631. }
  11632. }
  11633. }, _callee2);
  11634. }));
  11635. function _readFromStorage() {
  11636. return _readFromStorage2.apply(this, arguments);
  11637. }
  11638. return _readFromStorage;
  11639. }()
  11640. }, {
  11641. key: "set",
  11642. value: function () {
  11643. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name, val) {
  11644. return _regenerator["default"].wrap(function _callee3$(_context3) {
  11645. while (1) {
  11646. switch (_context3.prev = _context3.next) {
  11647. case 0:
  11648. _context3.next = 2;
  11649. return this._initializedPromise;
  11650. case 2:
  11651. this.file[name] = val;
  11652. return _context3.abrupt("return", this._writeToStorage());
  11653. case 4:
  11654. case "end":
  11655. return _context3.stop();
  11656. }
  11657. }
  11658. }, _callee3, this);
  11659. }));
  11660. function set(_x, _x2) {
  11661. return _set.apply(this, arguments);
  11662. }
  11663. return set;
  11664. }()
  11665. }, {
  11666. key: "setMultiple",
  11667. value: function () {
  11668. var _setMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(properties) {
  11669. var name;
  11670. return _regenerator["default"].wrap(function _callee4$(_context4) {
  11671. while (1) {
  11672. switch (_context4.prev = _context4.next) {
  11673. case 0:
  11674. _context4.next = 2;
  11675. return this._initializedPromise;
  11676. case 2:
  11677. for (name in properties) {
  11678. this.file[name] = properties[name];
  11679. }
  11680. return _context4.abrupt("return", this._writeToStorage());
  11681. case 4:
  11682. case "end":
  11683. return _context4.stop();
  11684. }
  11685. }
  11686. }, _callee4, this);
  11687. }));
  11688. function setMultiple(_x3) {
  11689. return _setMultiple.apply(this, arguments);
  11690. }
  11691. return setMultiple;
  11692. }()
  11693. }, {
  11694. key: "get",
  11695. value: function () {
  11696. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name, defaultValue) {
  11697. var val;
  11698. return _regenerator["default"].wrap(function _callee5$(_context5) {
  11699. while (1) {
  11700. switch (_context5.prev = _context5.next) {
  11701. case 0:
  11702. _context5.next = 2;
  11703. return this._initializedPromise;
  11704. case 2:
  11705. val = this.file[name];
  11706. return _context5.abrupt("return", val !== undefined ? val : defaultValue);
  11707. case 4:
  11708. case "end":
  11709. return _context5.stop();
  11710. }
  11711. }
  11712. }, _callee5, this);
  11713. }));
  11714. function get(_x4, _x5) {
  11715. return _get.apply(this, arguments);
  11716. }
  11717. return get;
  11718. }()
  11719. }, {
  11720. key: "getMultiple",
  11721. value: function () {
  11722. var _getMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6(properties) {
  11723. var values, name, val;
  11724. return _regenerator["default"].wrap(function _callee6$(_context6) {
  11725. while (1) {
  11726. switch (_context6.prev = _context6.next) {
  11727. case 0:
  11728. _context6.next = 2;
  11729. return this._initializedPromise;
  11730. case 2:
  11731. values = Object.create(null);
  11732. for (name in properties) {
  11733. val = this.file[name];
  11734. values[name] = val !== undefined ? val : properties[name];
  11735. }
  11736. return _context6.abrupt("return", values);
  11737. case 5:
  11738. case "end":
  11739. return _context6.stop();
  11740. }
  11741. }
  11742. }, _callee6, this);
  11743. }));
  11744. function getMultiple(_x6) {
  11745. return _getMultiple.apply(this, arguments);
  11746. }
  11747. return getMultiple;
  11748. }()
  11749. }]);
  11750. return ViewHistory;
  11751. }();
  11752. exports.ViewHistory = ViewHistory;
  11753. /***/ }),
  11754. /* 36 */
  11755. /***/ (function(module, exports, __webpack_require__) {
  11756. "use strict";
  11757. Object.defineProperty(exports, "__esModule", {
  11758. value: true
  11759. });
  11760. exports.GenericCom = void 0;
  11761. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11762. var _app = __webpack_require__(1);
  11763. var _preferences = __webpack_require__(37);
  11764. var _download_manager = __webpack_require__(38);
  11765. var _genericl10n = __webpack_require__(39);
  11766. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11767. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11768. 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); } }
  11769. 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); }); }; }
  11770. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11771. 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); } }
  11772. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11773. 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); }
  11774. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11775. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  11776. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11777. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11778. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  11779. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11780. ;
  11781. var GenericCom = {};
  11782. exports.GenericCom = GenericCom;
  11783. var GenericPreferences = /*#__PURE__*/function (_BasePreferences) {
  11784. _inherits(GenericPreferences, _BasePreferences);
  11785. var _super = _createSuper(GenericPreferences);
  11786. function GenericPreferences() {
  11787. _classCallCheck(this, GenericPreferences);
  11788. return _super.apply(this, arguments);
  11789. }
  11790. _createClass(GenericPreferences, [{
  11791. key: "_writeToStorage",
  11792. value: function () {
  11793. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  11794. return _regenerator["default"].wrap(function _callee$(_context) {
  11795. while (1) {
  11796. switch (_context.prev = _context.next) {
  11797. case 0:
  11798. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  11799. case 1:
  11800. case "end":
  11801. return _context.stop();
  11802. }
  11803. }
  11804. }, _callee);
  11805. }));
  11806. function _writeToStorage(_x) {
  11807. return _writeToStorage2.apply(this, arguments);
  11808. }
  11809. return _writeToStorage;
  11810. }()
  11811. }, {
  11812. key: "_readFromStorage",
  11813. value: function () {
  11814. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  11815. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11816. while (1) {
  11817. switch (_context2.prev = _context2.next) {
  11818. case 0:
  11819. return _context2.abrupt("return", JSON.parse(localStorage.getItem("pdfjs.preferences")));
  11820. case 1:
  11821. case "end":
  11822. return _context2.stop();
  11823. }
  11824. }
  11825. }, _callee2);
  11826. }));
  11827. function _readFromStorage(_x2) {
  11828. return _readFromStorage2.apply(this, arguments);
  11829. }
  11830. return _readFromStorage;
  11831. }()
  11832. }]);
  11833. return GenericPreferences;
  11834. }(_preferences.BasePreferences);
  11835. var GenericExternalServices = /*#__PURE__*/function (_DefaultExternalServi) {
  11836. _inherits(GenericExternalServices, _DefaultExternalServi);
  11837. var _super2 = _createSuper(GenericExternalServices);
  11838. function GenericExternalServices() {
  11839. _classCallCheck(this, GenericExternalServices);
  11840. return _super2.apply(this, arguments);
  11841. }
  11842. _createClass(GenericExternalServices, null, [{
  11843. key: "createDownloadManager",
  11844. value: function createDownloadManager(options) {
  11845. return new _download_manager.DownloadManager(options);
  11846. }
  11847. }, {
  11848. key: "createPreferences",
  11849. value: function createPreferences() {
  11850. return new GenericPreferences();
  11851. }
  11852. }, {
  11853. key: "createL10n",
  11854. value: function createL10n(_ref) {
  11855. var _ref$locale = _ref.locale,
  11856. locale = _ref$locale === void 0 ? "en-US" : _ref$locale;
  11857. return new _genericl10n.GenericL10n(locale);
  11858. }
  11859. }]);
  11860. return GenericExternalServices;
  11861. }(_app.DefaultExternalServices);
  11862. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  11863. /***/ }),
  11864. /* 37 */
  11865. /***/ (function(module, exports, __webpack_require__) {
  11866. "use strict";
  11867. Object.defineProperty(exports, "__esModule", {
  11868. value: true
  11869. });
  11870. exports.BasePreferences = void 0;
  11871. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11872. var _app_options = __webpack_require__(6);
  11873. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11874. 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); } }
  11875. 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); }); }; }
  11876. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11877. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11878. 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); } }
  11879. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11880. var defaultPreferences = null;
  11881. function getDefaultPreferences() {
  11882. if (!defaultPreferences) {
  11883. defaultPreferences = Promise.resolve({
  11884. "cursorToolOnLoad": 0,
  11885. "defaultZoomValue": "",
  11886. "disablePageLabels": false,
  11887. "enablePermissions": false,
  11888. "enablePrintAutoRotate": false,
  11889. "enableWebGL": false,
  11890. "externalLinkTarget": 0,
  11891. "historyUpdateUrl": false,
  11892. "ignoreDestinationZoom": false,
  11893. "pdfBugEnabled": false,
  11894. "renderer": "canvas",
  11895. "renderInteractiveForms": false,
  11896. "sidebarViewOnLoad": -1,
  11897. "scrollModeOnLoad": -1,
  11898. "spreadModeOnLoad": -1,
  11899. "textLayerMode": 1,
  11900. "useOnlyCssZoom": false,
  11901. "viewOnLoad": 0,
  11902. "disableAutoFetch": false,
  11903. "disableFontFace": false,
  11904. "disableRange": false,
  11905. "disableStream": false
  11906. });
  11907. }
  11908. return defaultPreferences;
  11909. }
  11910. var BasePreferences = /*#__PURE__*/function () {
  11911. function BasePreferences() {
  11912. var _this = this;
  11913. _classCallCheck(this, BasePreferences);
  11914. if (this.constructor === BasePreferences) {
  11915. throw new Error("Cannot initialize BasePreferences.");
  11916. }
  11917. this.prefs = null;
  11918. this._initializedPromise = getDefaultPreferences().then(function (defaults) {
  11919. Object.defineProperty(_this, "defaults", {
  11920. value: Object.freeze(defaults),
  11921. writable: false,
  11922. enumerable: true,
  11923. configurable: false
  11924. });
  11925. _this.prefs = Object.assign(Object.create(null), defaults);
  11926. return _this._readFromStorage(defaults);
  11927. }).then(function (prefs) {
  11928. if (!prefs) {
  11929. return;
  11930. }
  11931. for (var name in prefs) {
  11932. var defaultValue = _this.defaults[name],
  11933. prefValue = prefs[name];
  11934. if (defaultValue === undefined || _typeof(prefValue) !== _typeof(defaultValue)) {
  11935. continue;
  11936. }
  11937. _this.prefs[name] = prefValue;
  11938. }
  11939. });
  11940. }
  11941. _createClass(BasePreferences, [{
  11942. key: "_writeToStorage",
  11943. value: function () {
  11944. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  11945. return _regenerator["default"].wrap(function _callee$(_context) {
  11946. while (1) {
  11947. switch (_context.prev = _context.next) {
  11948. case 0:
  11949. throw new Error("Not implemented: _writeToStorage");
  11950. case 1:
  11951. case "end":
  11952. return _context.stop();
  11953. }
  11954. }
  11955. }, _callee);
  11956. }));
  11957. function _writeToStorage(_x) {
  11958. return _writeToStorage2.apply(this, arguments);
  11959. }
  11960. return _writeToStorage;
  11961. }()
  11962. }, {
  11963. key: "_readFromStorage",
  11964. value: function () {
  11965. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  11966. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11967. while (1) {
  11968. switch (_context2.prev = _context2.next) {
  11969. case 0:
  11970. throw new Error("Not implemented: _readFromStorage");
  11971. case 1:
  11972. case "end":
  11973. return _context2.stop();
  11974. }
  11975. }
  11976. }, _callee2);
  11977. }));
  11978. function _readFromStorage(_x2) {
  11979. return _readFromStorage2.apply(this, arguments);
  11980. }
  11981. return _readFromStorage;
  11982. }()
  11983. }, {
  11984. key: "reset",
  11985. value: function () {
  11986. var _reset = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  11987. return _regenerator["default"].wrap(function _callee3$(_context3) {
  11988. while (1) {
  11989. switch (_context3.prev = _context3.next) {
  11990. case 0:
  11991. _context3.next = 2;
  11992. return this._initializedPromise;
  11993. case 2:
  11994. this.prefs = Object.assign(Object.create(null), this.defaults);
  11995. return _context3.abrupt("return", this._writeToStorage(this.defaults));
  11996. case 4:
  11997. case "end":
  11998. return _context3.stop();
  11999. }
  12000. }
  12001. }, _callee3, this);
  12002. }));
  12003. function reset() {
  12004. return _reset.apply(this, arguments);
  12005. }
  12006. return reset;
  12007. }()
  12008. }, {
  12009. key: "set",
  12010. value: function () {
  12011. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name, value) {
  12012. var defaultValue, valueType, defaultType;
  12013. return _regenerator["default"].wrap(function _callee4$(_context4) {
  12014. while (1) {
  12015. switch (_context4.prev = _context4.next) {
  12016. case 0:
  12017. _context4.next = 2;
  12018. return this._initializedPromise;
  12019. case 2:
  12020. defaultValue = this.defaults[name];
  12021. if (!(defaultValue === undefined)) {
  12022. _context4.next = 7;
  12023. break;
  12024. }
  12025. throw new Error("Set preference: \"".concat(name, "\" is undefined."));
  12026. case 7:
  12027. if (!(value === undefined)) {
  12028. _context4.next = 9;
  12029. break;
  12030. }
  12031. throw new Error("Set preference: no value is specified.");
  12032. case 9:
  12033. valueType = _typeof(value);
  12034. defaultType = _typeof(defaultValue);
  12035. if (!(valueType !== defaultType)) {
  12036. _context4.next = 19;
  12037. break;
  12038. }
  12039. if (!(valueType === "number" && defaultType === "string")) {
  12040. _context4.next = 16;
  12041. break;
  12042. }
  12043. value = value.toString();
  12044. _context4.next = 17;
  12045. break;
  12046. case 16:
  12047. throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", ") + "expected a ".concat(defaultType, "."));
  12048. case 17:
  12049. _context4.next = 21;
  12050. break;
  12051. case 19:
  12052. if (!(valueType === "number" && !Number.isInteger(value))) {
  12053. _context4.next = 21;
  12054. break;
  12055. }
  12056. throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
  12057. case 21:
  12058. this.prefs[name] = value;
  12059. return _context4.abrupt("return", this._writeToStorage(this.prefs));
  12060. case 23:
  12061. case "end":
  12062. return _context4.stop();
  12063. }
  12064. }
  12065. }, _callee4, this);
  12066. }));
  12067. function set(_x3, _x4) {
  12068. return _set.apply(this, arguments);
  12069. }
  12070. return set;
  12071. }()
  12072. }, {
  12073. key: "get",
  12074. value: function () {
  12075. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name) {
  12076. var defaultValue, prefValue;
  12077. return _regenerator["default"].wrap(function _callee5$(_context5) {
  12078. while (1) {
  12079. switch (_context5.prev = _context5.next) {
  12080. case 0:
  12081. _context5.next = 2;
  12082. return this._initializedPromise;
  12083. case 2:
  12084. defaultValue = this.defaults[name];
  12085. if (!(defaultValue === undefined)) {
  12086. _context5.next = 7;
  12087. break;
  12088. }
  12089. throw new Error("Get preference: \"".concat(name, "\" is undefined."));
  12090. case 7:
  12091. prefValue = this.prefs[name];
  12092. if (!(prefValue !== undefined)) {
  12093. _context5.next = 10;
  12094. break;
  12095. }
  12096. return _context5.abrupt("return", prefValue);
  12097. case 10:
  12098. return _context5.abrupt("return", defaultValue);
  12099. case 11:
  12100. case "end":
  12101. return _context5.stop();
  12102. }
  12103. }
  12104. }, _callee5, this);
  12105. }));
  12106. function get(_x5) {
  12107. return _get.apply(this, arguments);
  12108. }
  12109. return get;
  12110. }()
  12111. }, {
  12112. key: "getAll",
  12113. value: function () {
  12114. var _getAll = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  12115. return _regenerator["default"].wrap(function _callee6$(_context6) {
  12116. while (1) {
  12117. switch (_context6.prev = _context6.next) {
  12118. case 0:
  12119. _context6.next = 2;
  12120. return this._initializedPromise;
  12121. case 2:
  12122. return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs));
  12123. case 3:
  12124. case "end":
  12125. return _context6.stop();
  12126. }
  12127. }
  12128. }, _callee6, this);
  12129. }));
  12130. function getAll() {
  12131. return _getAll.apply(this, arguments);
  12132. }
  12133. return getAll;
  12134. }()
  12135. }]);
  12136. return BasePreferences;
  12137. }();
  12138. exports.BasePreferences = BasePreferences;
  12139. /***/ }),
  12140. /* 38 */
  12141. /***/ (function(module, exports, __webpack_require__) {
  12142. "use strict";
  12143. Object.defineProperty(exports, "__esModule", {
  12144. value: true
  12145. });
  12146. exports.DownloadManager = void 0;
  12147. var _pdfjsLib = __webpack_require__(8);
  12148. var _viewer_compatibility = __webpack_require__(7);
  12149. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12150. 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); } }
  12151. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12152. ;
  12153. var DISABLE_CREATE_OBJECT_URL = _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL || false;
  12154. function _download(blobUrl, filename) {
  12155. var a = document.createElement("a");
  12156. if (!a.click) {
  12157. throw new Error('DownloadManager: "a.click()" is not supported.');
  12158. }
  12159. a.href = blobUrl;
  12160. a.target = "_parent";
  12161. if ("download" in a) {
  12162. a.download = filename;
  12163. }
  12164. (document.body || document.documentElement).appendChild(a);
  12165. a.click();
  12166. a.remove();
  12167. }
  12168. var DownloadManager = /*#__PURE__*/function () {
  12169. function DownloadManager(_ref) {
  12170. var _ref$disableCreateObj = _ref.disableCreateObjectURL,
  12171. disableCreateObjectURL = _ref$disableCreateObj === void 0 ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj;
  12172. _classCallCheck(this, DownloadManager);
  12173. this.disableCreateObjectURL = disableCreateObjectURL;
  12174. }
  12175. _createClass(DownloadManager, [{
  12176. key: "downloadUrl",
  12177. value: function downloadUrl(url, filename) {
  12178. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  12179. return;
  12180. }
  12181. _download(url + "#pdfjs.action=download", filename);
  12182. }
  12183. }, {
  12184. key: "downloadData",
  12185. value: function downloadData(data, filename, contentType) {
  12186. if (navigator.msSaveBlob) {
  12187. navigator.msSaveBlob(new Blob([data], {
  12188. type: contentType
  12189. }), filename);
  12190. return;
  12191. }
  12192. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL);
  12193. _download(blobUrl, filename);
  12194. }
  12195. }, {
  12196. key: "download",
  12197. value: function download(blob, url, filename) {
  12198. if (navigator.msSaveBlob) {
  12199. if (!navigator.msSaveBlob(blob, filename)) {
  12200. this.downloadUrl(url, filename);
  12201. }
  12202. return;
  12203. }
  12204. if (this.disableCreateObjectURL) {
  12205. this.downloadUrl(url, filename);
  12206. return;
  12207. }
  12208. var blobUrl = URL.createObjectURL(blob);
  12209. _download(blobUrl, filename);
  12210. }
  12211. }]);
  12212. return DownloadManager;
  12213. }();
  12214. exports.DownloadManager = DownloadManager;
  12215. /***/ }),
  12216. /* 39 */
  12217. /***/ (function(module, exports, __webpack_require__) {
  12218. "use strict";
  12219. Object.defineProperty(exports, "__esModule", {
  12220. value: true
  12221. });
  12222. exports.GenericL10n = void 0;
  12223. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  12224. __webpack_require__(40);
  12225. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12226. 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); } }
  12227. 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); }); }; }
  12228. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12229. 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); } }
  12230. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12231. var webL10n = document.webL10n;
  12232. var GenericL10n = /*#__PURE__*/function () {
  12233. function GenericL10n(lang) {
  12234. _classCallCheck(this, GenericL10n);
  12235. this._lang = lang;
  12236. this._ready = new Promise(function (resolve, reject) {
  12237. webL10n.setLanguage(lang, function () {
  12238. resolve(webL10n);
  12239. });
  12240. });
  12241. }
  12242. _createClass(GenericL10n, [{
  12243. key: "getLanguage",
  12244. value: function () {
  12245. var _getLanguage = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  12246. var l10n;
  12247. return _regenerator["default"].wrap(function _callee$(_context) {
  12248. while (1) {
  12249. switch (_context.prev = _context.next) {
  12250. case 0:
  12251. _context.next = 2;
  12252. return this._ready;
  12253. case 2:
  12254. l10n = _context.sent;
  12255. return _context.abrupt("return", l10n.getLanguage());
  12256. case 4:
  12257. case "end":
  12258. return _context.stop();
  12259. }
  12260. }
  12261. }, _callee, this);
  12262. }));
  12263. function getLanguage() {
  12264. return _getLanguage.apply(this, arguments);
  12265. }
  12266. return getLanguage;
  12267. }()
  12268. }, {
  12269. key: "getDirection",
  12270. value: function () {
  12271. var _getDirection = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  12272. var l10n;
  12273. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12274. while (1) {
  12275. switch (_context2.prev = _context2.next) {
  12276. case 0:
  12277. _context2.next = 2;
  12278. return this._ready;
  12279. case 2:
  12280. l10n = _context2.sent;
  12281. return _context2.abrupt("return", l10n.getDirection());
  12282. case 4:
  12283. case "end":
  12284. return _context2.stop();
  12285. }
  12286. }
  12287. }, _callee2, this);
  12288. }));
  12289. function getDirection() {
  12290. return _getDirection.apply(this, arguments);
  12291. }
  12292. return getDirection;
  12293. }()
  12294. }, {
  12295. key: "get",
  12296. value: function () {
  12297. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(property, args, fallback) {
  12298. var l10n;
  12299. return _regenerator["default"].wrap(function _callee3$(_context3) {
  12300. while (1) {
  12301. switch (_context3.prev = _context3.next) {
  12302. case 0:
  12303. _context3.next = 2;
  12304. return this._ready;
  12305. case 2:
  12306. l10n = _context3.sent;
  12307. return _context3.abrupt("return", l10n.get(property, args, fallback));
  12308. case 4:
  12309. case "end":
  12310. return _context3.stop();
  12311. }
  12312. }
  12313. }, _callee3, this);
  12314. }));
  12315. function get(_x, _x2, _x3) {
  12316. return _get.apply(this, arguments);
  12317. }
  12318. return get;
  12319. }()
  12320. }, {
  12321. key: "translate",
  12322. value: function () {
  12323. var _translate = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(element) {
  12324. var l10n;
  12325. return _regenerator["default"].wrap(function _callee4$(_context4) {
  12326. while (1) {
  12327. switch (_context4.prev = _context4.next) {
  12328. case 0:
  12329. _context4.next = 2;
  12330. return this._ready;
  12331. case 2:
  12332. l10n = _context4.sent;
  12333. return _context4.abrupt("return", l10n.translate(element));
  12334. case 4:
  12335. case "end":
  12336. return _context4.stop();
  12337. }
  12338. }
  12339. }, _callee4, this);
  12340. }));
  12341. function translate(_x4) {
  12342. return _translate.apply(this, arguments);
  12343. }
  12344. return translate;
  12345. }()
  12346. }]);
  12347. return GenericL10n;
  12348. }();
  12349. exports.GenericL10n = GenericL10n;
  12350. /***/ }),
  12351. /* 40 */
  12352. /***/ (function(module, exports, __webpack_require__) {
  12353. "use strict";
  12354. document.webL10n = function (window, document, undefined) {
  12355. var gL10nData = {};
  12356. var gTextData = '';
  12357. var gTextProp = 'textContent';
  12358. var gLanguage = '';
  12359. var gMacros = {};
  12360. var gReadyState = 'loading';
  12361. var gAsyncResourceLoading = true;
  12362. function getL10nResourceLinks() {
  12363. return document.querySelectorAll('link[type="application/l10n"]');
  12364. }
  12365. function getL10nDictionary() {
  12366. var script = document.querySelector('script[type="application/l10n"]');
  12367. return script ? JSON.parse(script.innerHTML) : null;
  12368. }
  12369. function getTranslatableChildren(element) {
  12370. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  12371. }
  12372. function getL10nAttributes(element) {
  12373. if (!element) return {};
  12374. var l10nId = element.getAttribute('data-l10n-id');
  12375. var l10nArgs = element.getAttribute('data-l10n-args');
  12376. var args = {};
  12377. if (l10nArgs) {
  12378. try {
  12379. args = JSON.parse(l10nArgs);
  12380. } catch (e) {
  12381. console.warn('could not parse arguments for #' + l10nId);
  12382. }
  12383. }
  12384. return {
  12385. id: l10nId,
  12386. args: args
  12387. };
  12388. }
  12389. function xhrLoadText(url, onSuccess, onFailure) {
  12390. onSuccess = onSuccess || function _onSuccess(data) {};
  12391. onFailure = onFailure || function _onFailure() {};
  12392. var xhr = new XMLHttpRequest();
  12393. xhr.open('GET', url, gAsyncResourceLoading);
  12394. if (xhr.overrideMimeType) {
  12395. xhr.overrideMimeType('text/plain; charset=utf-8');
  12396. }
  12397. xhr.onreadystatechange = function () {
  12398. if (xhr.readyState == 4) {
  12399. if (xhr.status == 200 || xhr.status === 0) {
  12400. onSuccess(xhr.responseText);
  12401. } else {
  12402. onFailure();
  12403. }
  12404. }
  12405. };
  12406. xhr.onerror = onFailure;
  12407. xhr.ontimeout = onFailure;
  12408. try {
  12409. xhr.send(null);
  12410. } catch (e) {
  12411. onFailure();
  12412. }
  12413. }
  12414. function parseResource(href, lang, successCallback, failureCallback) {
  12415. var baseURL = href.replace(/[^\/]*$/, '') || './';
  12416. function evalString(text) {
  12417. if (text.lastIndexOf('\\') < 0) return text;
  12418. 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, "'");
  12419. }
  12420. function parseProperties(text, parsedPropertiesCallback) {
  12421. var dictionary = {};
  12422. var reBlank = /^\s*|\s*$/;
  12423. var reComment = /^\s*#|^\s*$/;
  12424. var reSection = /^\s*\[(.*)\]\s*$/;
  12425. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  12426. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  12427. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  12428. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  12429. var currentLang = '*';
  12430. var genericLang = lang.split('-', 1)[0];
  12431. var skipLang = false;
  12432. var match = '';
  12433. function nextEntry() {
  12434. while (true) {
  12435. if (!entries.length) {
  12436. parsedRawLinesCallback();
  12437. return;
  12438. }
  12439. var line = entries.shift();
  12440. if (reComment.test(line)) continue;
  12441. if (extendedSyntax) {
  12442. match = reSection.exec(line);
  12443. if (match) {
  12444. currentLang = match[1].toLowerCase();
  12445. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  12446. continue;
  12447. } else if (skipLang) {
  12448. continue;
  12449. }
  12450. match = reImport.exec(line);
  12451. if (match) {
  12452. loadImport(baseURL + match[1], nextEntry);
  12453. return;
  12454. }
  12455. }
  12456. var tmp = line.match(reSplit);
  12457. if (tmp && tmp.length == 3) {
  12458. dictionary[tmp[1]] = evalString(tmp[2]);
  12459. }
  12460. }
  12461. }
  12462. nextEntry();
  12463. }
  12464. function loadImport(url, callback) {
  12465. xhrLoadText(url, function (content) {
  12466. parseRawLines(content, false, callback);
  12467. }, function () {
  12468. console.warn(url + ' not found.');
  12469. callback();
  12470. });
  12471. }
  12472. parseRawLines(text, true, function () {
  12473. parsedPropertiesCallback(dictionary);
  12474. });
  12475. }
  12476. xhrLoadText(href, function (response) {
  12477. gTextData += response;
  12478. parseProperties(response, function (data) {
  12479. for (var key in data) {
  12480. var id,
  12481. prop,
  12482. index = key.lastIndexOf('.');
  12483. if (index > 0) {
  12484. id = key.substring(0, index);
  12485. prop = key.substring(index + 1);
  12486. } else {
  12487. id = key;
  12488. prop = gTextProp;
  12489. }
  12490. if (!gL10nData[id]) {
  12491. gL10nData[id] = {};
  12492. }
  12493. gL10nData[id][prop] = data[key];
  12494. }
  12495. if (successCallback) {
  12496. successCallback();
  12497. }
  12498. });
  12499. }, failureCallback);
  12500. }
  12501. function loadLocale(lang, callback) {
  12502. if (lang) {
  12503. lang = lang.toLowerCase();
  12504. }
  12505. callback = callback || function _callback() {};
  12506. clear();
  12507. gLanguage = lang;
  12508. var langLinks = getL10nResourceLinks();
  12509. var langCount = langLinks.length;
  12510. if (langCount === 0) {
  12511. var dict = getL10nDictionary();
  12512. if (dict && dict.locales && dict.default_locale) {
  12513. console.log('using the embedded JSON directory, early way out');
  12514. gL10nData = dict.locales[lang];
  12515. if (!gL10nData) {
  12516. var defaultLocale = dict.default_locale.toLowerCase();
  12517. for (var anyCaseLang in dict.locales) {
  12518. anyCaseLang = anyCaseLang.toLowerCase();
  12519. if (anyCaseLang === lang) {
  12520. gL10nData = dict.locales[lang];
  12521. break;
  12522. } else if (anyCaseLang === defaultLocale) {
  12523. gL10nData = dict.locales[defaultLocale];
  12524. }
  12525. }
  12526. }
  12527. callback();
  12528. } else {
  12529. console.log('no resource to load, early way out');
  12530. }
  12531. gReadyState = 'complete';
  12532. return;
  12533. }
  12534. var onResourceLoaded = null;
  12535. var gResourceCount = 0;
  12536. onResourceLoaded = function onResourceLoaded() {
  12537. gResourceCount++;
  12538. if (gResourceCount >= langCount) {
  12539. callback();
  12540. gReadyState = 'complete';
  12541. }
  12542. };
  12543. function L10nResourceLink(link) {
  12544. var href = link.href;
  12545. this.load = function (lang, callback) {
  12546. parseResource(href, lang, callback, function () {
  12547. console.warn(href + ' not found.');
  12548. console.warn('"' + lang + '" resource not found');
  12549. gLanguage = '';
  12550. callback();
  12551. });
  12552. };
  12553. }
  12554. for (var i = 0; i < langCount; i++) {
  12555. var resource = new L10nResourceLink(langLinks[i]);
  12556. resource.load(lang, onResourceLoaded);
  12557. }
  12558. }
  12559. function clear() {
  12560. gL10nData = {};
  12561. gTextData = '';
  12562. gLanguage = '';
  12563. }
  12564. function getPluralRules(lang) {
  12565. var locales2rules = {
  12566. 'af': 3,
  12567. 'ak': 4,
  12568. 'am': 4,
  12569. 'ar': 1,
  12570. 'asa': 3,
  12571. 'az': 0,
  12572. 'be': 11,
  12573. 'bem': 3,
  12574. 'bez': 3,
  12575. 'bg': 3,
  12576. 'bh': 4,
  12577. 'bm': 0,
  12578. 'bn': 3,
  12579. 'bo': 0,
  12580. 'br': 20,
  12581. 'brx': 3,
  12582. 'bs': 11,
  12583. 'ca': 3,
  12584. 'cgg': 3,
  12585. 'chr': 3,
  12586. 'cs': 12,
  12587. 'cy': 17,
  12588. 'da': 3,
  12589. 'de': 3,
  12590. 'dv': 3,
  12591. 'dz': 0,
  12592. 'ee': 3,
  12593. 'el': 3,
  12594. 'en': 3,
  12595. 'eo': 3,
  12596. 'es': 3,
  12597. 'et': 3,
  12598. 'eu': 3,
  12599. 'fa': 0,
  12600. 'ff': 5,
  12601. 'fi': 3,
  12602. 'fil': 4,
  12603. 'fo': 3,
  12604. 'fr': 5,
  12605. 'fur': 3,
  12606. 'fy': 3,
  12607. 'ga': 8,
  12608. 'gd': 24,
  12609. 'gl': 3,
  12610. 'gsw': 3,
  12611. 'gu': 3,
  12612. 'guw': 4,
  12613. 'gv': 23,
  12614. 'ha': 3,
  12615. 'haw': 3,
  12616. 'he': 2,
  12617. 'hi': 4,
  12618. 'hr': 11,
  12619. 'hu': 0,
  12620. 'id': 0,
  12621. 'ig': 0,
  12622. 'ii': 0,
  12623. 'is': 3,
  12624. 'it': 3,
  12625. 'iu': 7,
  12626. 'ja': 0,
  12627. 'jmc': 3,
  12628. 'jv': 0,
  12629. 'ka': 0,
  12630. 'kab': 5,
  12631. 'kaj': 3,
  12632. 'kcg': 3,
  12633. 'kde': 0,
  12634. 'kea': 0,
  12635. 'kk': 3,
  12636. 'kl': 3,
  12637. 'km': 0,
  12638. 'kn': 0,
  12639. 'ko': 0,
  12640. 'ksb': 3,
  12641. 'ksh': 21,
  12642. 'ku': 3,
  12643. 'kw': 7,
  12644. 'lag': 18,
  12645. 'lb': 3,
  12646. 'lg': 3,
  12647. 'ln': 4,
  12648. 'lo': 0,
  12649. 'lt': 10,
  12650. 'lv': 6,
  12651. 'mas': 3,
  12652. 'mg': 4,
  12653. 'mk': 16,
  12654. 'ml': 3,
  12655. 'mn': 3,
  12656. 'mo': 9,
  12657. 'mr': 3,
  12658. 'ms': 0,
  12659. 'mt': 15,
  12660. 'my': 0,
  12661. 'nah': 3,
  12662. 'naq': 7,
  12663. 'nb': 3,
  12664. 'nd': 3,
  12665. 'ne': 3,
  12666. 'nl': 3,
  12667. 'nn': 3,
  12668. 'no': 3,
  12669. 'nr': 3,
  12670. 'nso': 4,
  12671. 'ny': 3,
  12672. 'nyn': 3,
  12673. 'om': 3,
  12674. 'or': 3,
  12675. 'pa': 3,
  12676. 'pap': 3,
  12677. 'pl': 13,
  12678. 'ps': 3,
  12679. 'pt': 3,
  12680. 'rm': 3,
  12681. 'ro': 9,
  12682. 'rof': 3,
  12683. 'ru': 11,
  12684. 'rwk': 3,
  12685. 'sah': 0,
  12686. 'saq': 3,
  12687. 'se': 7,
  12688. 'seh': 3,
  12689. 'ses': 0,
  12690. 'sg': 0,
  12691. 'sh': 11,
  12692. 'shi': 19,
  12693. 'sk': 12,
  12694. 'sl': 14,
  12695. 'sma': 7,
  12696. 'smi': 7,
  12697. 'smj': 7,
  12698. 'smn': 7,
  12699. 'sms': 7,
  12700. 'sn': 3,
  12701. 'so': 3,
  12702. 'sq': 3,
  12703. 'sr': 11,
  12704. 'ss': 3,
  12705. 'ssy': 3,
  12706. 'st': 3,
  12707. 'sv': 3,
  12708. 'sw': 3,
  12709. 'syr': 3,
  12710. 'ta': 3,
  12711. 'te': 3,
  12712. 'teo': 3,
  12713. 'th': 0,
  12714. 'ti': 4,
  12715. 'tig': 3,
  12716. 'tk': 3,
  12717. 'tl': 4,
  12718. 'tn': 3,
  12719. 'to': 0,
  12720. 'tr': 0,
  12721. 'ts': 3,
  12722. 'tzm': 22,
  12723. 'uk': 11,
  12724. 'ur': 3,
  12725. 've': 3,
  12726. 'vi': 0,
  12727. 'vun': 3,
  12728. 'wa': 4,
  12729. 'wae': 3,
  12730. 'wo': 0,
  12731. 'xh': 3,
  12732. 'xog': 3,
  12733. 'yo': 0,
  12734. 'zh': 0,
  12735. 'zu': 3
  12736. };
  12737. function isIn(n, list) {
  12738. return list.indexOf(n) !== -1;
  12739. }
  12740. function isBetween(n, start, end) {
  12741. return start <= n && n <= end;
  12742. }
  12743. var pluralRules = {
  12744. '0': function _(n) {
  12745. return 'other';
  12746. },
  12747. '1': function _(n) {
  12748. if (isBetween(n % 100, 3, 10)) return 'few';
  12749. if (n === 0) return 'zero';
  12750. if (isBetween(n % 100, 11, 99)) return 'many';
  12751. if (n == 2) return 'two';
  12752. if (n == 1) return 'one';
  12753. return 'other';
  12754. },
  12755. '2': function _(n) {
  12756. if (n !== 0 && n % 10 === 0) return 'many';
  12757. if (n == 2) return 'two';
  12758. if (n == 1) return 'one';
  12759. return 'other';
  12760. },
  12761. '3': function _(n) {
  12762. if (n == 1) return 'one';
  12763. return 'other';
  12764. },
  12765. '4': function _(n) {
  12766. if (isBetween(n, 0, 1)) return 'one';
  12767. return 'other';
  12768. },
  12769. '5': function _(n) {
  12770. if (isBetween(n, 0, 2) && n != 2) return 'one';
  12771. return 'other';
  12772. },
  12773. '6': function _(n) {
  12774. if (n === 0) return 'zero';
  12775. if (n % 10 == 1 && n % 100 != 11) return 'one';
  12776. return 'other';
  12777. },
  12778. '7': function _(n) {
  12779. if (n == 2) return 'two';
  12780. if (n == 1) return 'one';
  12781. return 'other';
  12782. },
  12783. '8': function _(n) {
  12784. if (isBetween(n, 3, 6)) return 'few';
  12785. if (isBetween(n, 7, 10)) return 'many';
  12786. if (n == 2) return 'two';
  12787. if (n == 1) return 'one';
  12788. return 'other';
  12789. },
  12790. '9': function _(n) {
  12791. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  12792. if (n == 1) return 'one';
  12793. return 'other';
  12794. },
  12795. '10': function _(n) {
  12796. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  12797. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  12798. return 'other';
  12799. },
  12800. '11': function _(n) {
  12801. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  12802. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  12803. if (n % 10 == 1 && n % 100 != 11) return 'one';
  12804. return 'other';
  12805. },
  12806. '12': function _(n) {
  12807. if (isBetween(n, 2, 4)) return 'few';
  12808. if (n == 1) return 'one';
  12809. return 'other';
  12810. },
  12811. '13': function _(n) {
  12812. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  12813. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  12814. if (n == 1) return 'one';
  12815. return 'other';
  12816. },
  12817. '14': function _(n) {
  12818. if (isBetween(n % 100, 3, 4)) return 'few';
  12819. if (n % 100 == 2) return 'two';
  12820. if (n % 100 == 1) return 'one';
  12821. return 'other';
  12822. },
  12823. '15': function _(n) {
  12824. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  12825. if (isBetween(n % 100, 11, 19)) return 'many';
  12826. if (n == 1) return 'one';
  12827. return 'other';
  12828. },
  12829. '16': function _(n) {
  12830. if (n % 10 == 1 && n != 11) return 'one';
  12831. return 'other';
  12832. },
  12833. '17': function _(n) {
  12834. if (n == 3) return 'few';
  12835. if (n === 0) return 'zero';
  12836. if (n == 6) return 'many';
  12837. if (n == 2) return 'two';
  12838. if (n == 1) return 'one';
  12839. return 'other';
  12840. },
  12841. '18': function _(n) {
  12842. if (n === 0) return 'zero';
  12843. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  12844. return 'other';
  12845. },
  12846. '19': function _(n) {
  12847. if (isBetween(n, 2, 10)) return 'few';
  12848. if (isBetween(n, 0, 1)) return 'one';
  12849. return 'other';
  12850. },
  12851. '20': function _(n) {
  12852. 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';
  12853. if (n % 1000000 === 0 && n !== 0) return 'many';
  12854. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  12855. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  12856. return 'other';
  12857. },
  12858. '21': function _(n) {
  12859. if (n === 0) return 'zero';
  12860. if (n == 1) return 'one';
  12861. return 'other';
  12862. },
  12863. '22': function _(n) {
  12864. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  12865. return 'other';
  12866. },
  12867. '23': function _(n) {
  12868. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  12869. return 'other';
  12870. },
  12871. '24': function _(n) {
  12872. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  12873. if (isIn(n, [2, 12])) return 'two';
  12874. if (isIn(n, [1, 11])) return 'one';
  12875. return 'other';
  12876. }
  12877. };
  12878. var index = locales2rules[lang.replace(/-.*$/, '')];
  12879. if (!(index in pluralRules)) {
  12880. console.warn('plural form unknown for [' + lang + ']');
  12881. return function () {
  12882. return 'other';
  12883. };
  12884. }
  12885. return pluralRules[index];
  12886. }
  12887. gMacros.plural = function (str, param, key, prop) {
  12888. var n = parseFloat(param);
  12889. if (isNaN(n)) return str;
  12890. if (prop != gTextProp) return str;
  12891. if (!gMacros._pluralRules) {
  12892. gMacros._pluralRules = getPluralRules(gLanguage);
  12893. }
  12894. var index = '[' + gMacros._pluralRules(n) + ']';
  12895. if (n === 0 && key + '[zero]' in gL10nData) {
  12896. str = gL10nData[key + '[zero]'][prop];
  12897. } else if (n == 1 && key + '[one]' in gL10nData) {
  12898. str = gL10nData[key + '[one]'][prop];
  12899. } else if (n == 2 && key + '[two]' in gL10nData) {
  12900. str = gL10nData[key + '[two]'][prop];
  12901. } else if (key + index in gL10nData) {
  12902. str = gL10nData[key + index][prop];
  12903. } else if (key + '[other]' in gL10nData) {
  12904. str = gL10nData[key + '[other]'][prop];
  12905. }
  12906. return str;
  12907. };
  12908. function getL10nData(key, args, fallback) {
  12909. var data = gL10nData[key];
  12910. if (!data) {
  12911. console.warn('#' + key + ' is undefined.');
  12912. if (!fallback) {
  12913. return null;
  12914. }
  12915. data = fallback;
  12916. }
  12917. var rv = {};
  12918. for (var prop in data) {
  12919. var str = data[prop];
  12920. str = substIndexes(str, args, key, prop);
  12921. str = substArguments(str, args, key);
  12922. rv[prop] = str;
  12923. }
  12924. return rv;
  12925. }
  12926. function substIndexes(str, args, key, prop) {
  12927. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  12928. var reMatch = reIndex.exec(str);
  12929. if (!reMatch || !reMatch.length) return str;
  12930. var macroName = reMatch[1];
  12931. var paramName = reMatch[2];
  12932. var param;
  12933. if (args && paramName in args) {
  12934. param = args[paramName];
  12935. } else if (paramName in gL10nData) {
  12936. param = gL10nData[paramName];
  12937. }
  12938. if (macroName in gMacros) {
  12939. var macro = gMacros[macroName];
  12940. str = macro(str, param, key, prop);
  12941. }
  12942. return str;
  12943. }
  12944. function substArguments(str, args, key) {
  12945. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  12946. return str.replace(reArgs, function (matched_text, arg) {
  12947. if (args && arg in args) {
  12948. return args[arg];
  12949. }
  12950. if (arg in gL10nData) {
  12951. return gL10nData[arg];
  12952. }
  12953. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  12954. return matched_text;
  12955. });
  12956. }
  12957. function translateElement(element) {
  12958. var l10n = getL10nAttributes(element);
  12959. if (!l10n.id) return;
  12960. var data = getL10nData(l10n.id, l10n.args);
  12961. if (!data) {
  12962. console.warn('#' + l10n.id + ' is undefined.');
  12963. return;
  12964. }
  12965. if (data[gTextProp]) {
  12966. if (getChildElementCount(element) === 0) {
  12967. element[gTextProp] = data[gTextProp];
  12968. } else {
  12969. var children = element.childNodes;
  12970. var found = false;
  12971. for (var i = 0, l = children.length; i < l; i++) {
  12972. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  12973. if (found) {
  12974. children[i].nodeValue = '';
  12975. } else {
  12976. children[i].nodeValue = data[gTextProp];
  12977. found = true;
  12978. }
  12979. }
  12980. }
  12981. if (!found) {
  12982. var textNode = document.createTextNode(data[gTextProp]);
  12983. element.insertBefore(textNode, element.firstChild);
  12984. }
  12985. }
  12986. delete data[gTextProp];
  12987. }
  12988. for (var k in data) {
  12989. element[k] = data[k];
  12990. }
  12991. }
  12992. function getChildElementCount(element) {
  12993. if (element.children) {
  12994. return element.children.length;
  12995. }
  12996. if (typeof element.childElementCount !== 'undefined') {
  12997. return element.childElementCount;
  12998. }
  12999. var count = 0;
  13000. for (var i = 0; i < element.childNodes.length; i++) {
  13001. count += element.nodeType === 1 ? 1 : 0;
  13002. }
  13003. return count;
  13004. }
  13005. function translateFragment(element) {
  13006. element = element || document.documentElement;
  13007. var children = getTranslatableChildren(element);
  13008. var elementCount = children.length;
  13009. for (var i = 0; i < elementCount; i++) {
  13010. translateElement(children[i]);
  13011. }
  13012. translateElement(element);
  13013. }
  13014. return {
  13015. get: function get(key, args, fallbackString) {
  13016. var index = key.lastIndexOf('.');
  13017. var prop = gTextProp;
  13018. if (index > 0) {
  13019. prop = key.substring(index + 1);
  13020. key = key.substring(0, index);
  13021. }
  13022. var fallback;
  13023. if (fallbackString) {
  13024. fallback = {};
  13025. fallback[prop] = fallbackString;
  13026. }
  13027. var data = getL10nData(key, args, fallback);
  13028. if (data && prop in data) {
  13029. return data[prop];
  13030. }
  13031. return '{{' + key + '}}';
  13032. },
  13033. getData: function getData() {
  13034. return gL10nData;
  13035. },
  13036. getText: function getText() {
  13037. return gTextData;
  13038. },
  13039. getLanguage: function getLanguage() {
  13040. return gLanguage;
  13041. },
  13042. setLanguage: function setLanguage(lang, callback) {
  13043. loadLocale(lang, function () {
  13044. if (callback) callback();
  13045. });
  13046. },
  13047. getDirection: function getDirection() {
  13048. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  13049. var shortCode = gLanguage.split('-', 1)[0];
  13050. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  13051. },
  13052. translate: translateFragment,
  13053. getReadyState: function getReadyState() {
  13054. return gReadyState;
  13055. },
  13056. ready: function ready(callback) {
  13057. if (!callback) {
  13058. return;
  13059. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  13060. window.setTimeout(function () {
  13061. callback();
  13062. });
  13063. } else if (document.addEventListener) {
  13064. document.addEventListener('localized', function once() {
  13065. document.removeEventListener('localized', once);
  13066. callback();
  13067. });
  13068. }
  13069. }
  13070. };
  13071. }(window, document);
  13072. /***/ }),
  13073. /* 41 */
  13074. /***/ (function(module, exports, __webpack_require__) {
  13075. "use strict";
  13076. Object.defineProperty(exports, "__esModule", {
  13077. value: true
  13078. });
  13079. exports.PDFPrintService = PDFPrintService;
  13080. var _ui_utils = __webpack_require__(5);
  13081. var _app = __webpack_require__(1);
  13082. var _app_options = __webpack_require__(6);
  13083. var activeService = null;
  13084. var overlayManager = null;
  13085. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
  13086. var scratchCanvas = activeService.scratchCanvas;
  13087. var PRINT_RESOLUTION = _app_options.AppOptions.get("printResolution") || 150;
  13088. var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
  13089. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  13090. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  13091. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + "px";
  13092. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + "px";
  13093. var ctx = scratchCanvas.getContext("2d");
  13094. ctx.save();
  13095. ctx.fillStyle = "rgb(255, 255, 255)";
  13096. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  13097. ctx.restore();
  13098. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  13099. var renderContext = {
  13100. canvasContext: ctx,
  13101. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  13102. viewport: pdfPage.getViewport({
  13103. scale: 1,
  13104. rotation: size.rotation
  13105. }),
  13106. intent: "print"
  13107. };
  13108. return pdfPage.render(renderContext).promise;
  13109. }).then(function () {
  13110. return {
  13111. width: width,
  13112. height: height
  13113. };
  13114. });
  13115. }
  13116. function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  13117. this.pdfDocument = pdfDocument;
  13118. this.pagesOverview = pagesOverview;
  13119. this.printContainer = printContainer;
  13120. this.l10n = l10n || _ui_utils.NullL10n;
  13121. this.disableCreateObjectURL = _app_options.AppOptions.get("disableCreateObjectURL");
  13122. this.currentPage = -1;
  13123. this.scratchCanvas = document.createElement("canvas");
  13124. }
  13125. PDFPrintService.prototype = {
  13126. layout: function layout() {
  13127. this.throwIfInactive();
  13128. var body = document.querySelector("body");
  13129. body.setAttribute("data-pdfjsprinting", true);
  13130. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  13131. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  13132. }, this);
  13133. if (!hasEqualPageSizes) {
  13134. console.warn("Not all pages have the same size. The printed " + "result may be incorrect!");
  13135. }
  13136. this.pageStyleSheet = document.createElement("style");
  13137. var pageSize = this.pagesOverview[0];
  13138. this.pageStyleSheet.textContent = "@supports ((size:A4) and (size:1pt 1pt)) {" + "@page { size: " + pageSize.width + "pt " + pageSize.height + "pt;}" + "}";
  13139. body.appendChild(this.pageStyleSheet);
  13140. },
  13141. destroy: function destroy() {
  13142. if (activeService !== this) {
  13143. return;
  13144. }
  13145. this.printContainer.textContent = "";
  13146. var body = document.querySelector("body");
  13147. body.removeAttribute("data-pdfjsprinting");
  13148. if (this.pageStyleSheet) {
  13149. this.pageStyleSheet.remove();
  13150. this.pageStyleSheet = null;
  13151. }
  13152. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  13153. this.scratchCanvas = null;
  13154. activeService = null;
  13155. ensureOverlay().then(function () {
  13156. if (overlayManager.active !== "printServiceOverlay") {
  13157. return;
  13158. }
  13159. overlayManager.close("printServiceOverlay");
  13160. });
  13161. },
  13162. renderPages: function renderPages() {
  13163. var _this = this;
  13164. var pageCount = this.pagesOverview.length;
  13165. var renderNextPage = function renderNextPage(resolve, reject) {
  13166. _this.throwIfInactive();
  13167. if (++_this.currentPage >= pageCount) {
  13168. renderProgress(pageCount, pageCount, _this.l10n);
  13169. resolve();
  13170. return;
  13171. }
  13172. var index = _this.currentPage;
  13173. renderProgress(index, pageCount, _this.l10n);
  13174. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () {
  13175. renderNextPage(resolve, reject);
  13176. }, reject);
  13177. };
  13178. return new Promise(renderNextPage);
  13179. },
  13180. useRenderedPage: function useRenderedPage(printItem) {
  13181. this.throwIfInactive();
  13182. var img = document.createElement("img");
  13183. img.style.width = printItem.width;
  13184. img.style.height = printItem.height;
  13185. var scratchCanvas = this.scratchCanvas;
  13186. if ("toBlob" in scratchCanvas && !this.disableCreateObjectURL) {
  13187. scratchCanvas.toBlob(function (blob) {
  13188. img.src = URL.createObjectURL(blob);
  13189. });
  13190. } else {
  13191. img.src = scratchCanvas.toDataURL();
  13192. }
  13193. var wrapper = document.createElement("div");
  13194. wrapper.appendChild(img);
  13195. this.printContainer.appendChild(wrapper);
  13196. return new Promise(function (resolve, reject) {
  13197. img.onload = resolve;
  13198. img.onerror = reject;
  13199. });
  13200. },
  13201. performPrint: function performPrint() {
  13202. var _this2 = this;
  13203. this.throwIfInactive();
  13204. return new Promise(function (resolve) {
  13205. setTimeout(function () {
  13206. if (!_this2.active) {
  13207. resolve();
  13208. return;
  13209. }
  13210. print.call(window);
  13211. setTimeout(resolve, 20);
  13212. }, 0);
  13213. });
  13214. },
  13215. get active() {
  13216. return this === activeService;
  13217. },
  13218. throwIfInactive: function throwIfInactive() {
  13219. if (!this.active) {
  13220. throw new Error("This print request was cancelled or completed.");
  13221. }
  13222. }
  13223. };
  13224. var print = window.print;
  13225. window.print = function () {
  13226. if (activeService) {
  13227. console.warn("Ignored window.print() because of a pending print job.");
  13228. return;
  13229. }
  13230. ensureOverlay().then(function () {
  13231. if (activeService) {
  13232. overlayManager.open("printServiceOverlay");
  13233. }
  13234. });
  13235. try {
  13236. dispatchEvent("beforeprint");
  13237. } finally {
  13238. if (!activeService) {
  13239. console.error("Expected print service to be initialized.");
  13240. ensureOverlay().then(function () {
  13241. if (overlayManager.active === "printServiceOverlay") {
  13242. overlayManager.close("printServiceOverlay");
  13243. }
  13244. });
  13245. return;
  13246. }
  13247. var activeServiceOnEntry = activeService;
  13248. activeService.renderPages().then(function () {
  13249. return activeServiceOnEntry.performPrint();
  13250. })["catch"](function () {}).then(function () {
  13251. if (activeServiceOnEntry.active) {
  13252. abort();
  13253. }
  13254. });
  13255. }
  13256. };
  13257. function dispatchEvent(eventType) {
  13258. var event = document.createEvent("CustomEvent");
  13259. event.initCustomEvent(eventType, false, false, "custom");
  13260. window.dispatchEvent(event);
  13261. }
  13262. function abort() {
  13263. if (activeService) {
  13264. activeService.destroy();
  13265. dispatchEvent("afterprint");
  13266. }
  13267. }
  13268. function renderProgress(index, total, l10n) {
  13269. var progressContainer = document.getElementById("printServiceOverlay");
  13270. var progress = Math.round(100 * index / total);
  13271. var progressBar = progressContainer.querySelector("progress");
  13272. var progressPerc = progressContainer.querySelector(".relative-progress");
  13273. progressBar.value = progress;
  13274. l10n.get("print_progress_percent", {
  13275. progress: progress
  13276. }, progress + "%").then(function (msg) {
  13277. progressPerc.textContent = msg;
  13278. });
  13279. }
  13280. window.addEventListener("keydown", function (event) {
  13281. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  13282. window.print();
  13283. event.preventDefault();
  13284. if (event.stopImmediatePropagation) {
  13285. event.stopImmediatePropagation();
  13286. } else {
  13287. event.stopPropagation();
  13288. }
  13289. }
  13290. }, true);
  13291. if ("onbeforeprint" in window) {
  13292. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  13293. if (event.detail !== "custom" && event.stopImmediatePropagation) {
  13294. event.stopImmediatePropagation();
  13295. }
  13296. };
  13297. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  13298. window.addEventListener("afterprint", stopPropagationIfNeeded);
  13299. }
  13300. var overlayPromise;
  13301. function ensureOverlay() {
  13302. if (!overlayPromise) {
  13303. overlayManager = _app.PDFViewerApplication.overlayManager;
  13304. if (!overlayManager) {
  13305. throw new Error("The overlay manager has not yet been initialized.");
  13306. }
  13307. overlayPromise = overlayManager.register("printServiceOverlay", document.getElementById("printServiceOverlay"), abort, true);
  13308. document.getElementById("printCancel").onclick = abort;
  13309. }
  13310. return overlayPromise;
  13311. }
  13312. _app.PDFPrintServiceFactory.instance = {
  13313. supportsPrinting: true,
  13314. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  13315. if (activeService) {
  13316. throw new Error("The print service is created and active.");
  13317. }
  13318. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
  13319. return activeService;
  13320. }
  13321. };
  13322. /***/ })
  13323. /******/ ]);
  13324. //# sourceMappingURL=viewer.js.map