viewer.js 495 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298
  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. var code = Math.floor(Math.random() * (5000 - 1 + 1) + 1);
  1819. //file = "file" in params ? params.file+'?random='+code : _app_options.AppOptions.get("defaultUrl");
  1820. if("file" in params){
  1821. var pdfurl=params.file;
  1822. pdfurl=decodeURIComponent(pdfurl);
  1823. pdfurl = pdfurl.replace(/\+/g,"%2B").replace(/\#/g,"%23");
  1824. if(pdfurl.indexOf("?") == -1){
  1825. file = pdfurl+'?random='+code;
  1826. }else{
  1827. file = pdfurl+'&random='+code;
  1828. }
  1829. }else{
  1830. file = _app_options.AppOptions.get("defaultUrl")
  1831. }
  1832. validateFileURL(file);
  1833. var fileInput = document.createElement("input");
  1834. fileInput.id = appConfig.openFileInputName;
  1835. fileInput.className = "fileInput";
  1836. fileInput.setAttribute("type", "file");
  1837. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  1838. document.body.appendChild(fileInput);
  1839. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  1840. appConfig.toolbar.openFile.setAttribute("hidden", "true");
  1841. appConfig.secondaryToolbar.openFileButton.setAttribute("hidden", "true");
  1842. } else {
  1843. fileInput.value = null;
  1844. }
  1845. fileInput.addEventListener("change", function (evt) {
  1846. var files = evt.target.files;
  1847. if (!files || files.length === 0) {
  1848. return;
  1849. }
  1850. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  1851. source: this,
  1852. fileInput: evt.target
  1853. });
  1854. });
  1855. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  1856. evt.preventDefault();
  1857. evt.dataTransfer.dropEffect = "move";
  1858. });
  1859. appConfig.mainContainer.addEventListener("drop", function (evt) {
  1860. evt.preventDefault();
  1861. var files = evt.dataTransfer.files;
  1862. if (!files || files.length === 0) {
  1863. return;
  1864. }
  1865. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  1866. source: this,
  1867. fileInput: evt.dataTransfer
  1868. });
  1869. });
  1870. if (!PDFViewerApplication.supportsDocumentFonts) {
  1871. _app_options.AppOptions.set("disableFontFace", true);
  1872. PDFViewerApplication.l10n.get("web_fonts_disabled", null, "Web fonts are disabled: unable to use embedded PDF fonts.").then(function (msg) {
  1873. console.warn(msg);
  1874. });
  1875. }
  1876. if (!PDFViewerApplication.supportsPrinting) {
  1877. appConfig.toolbar.print.classList.add("hidden");
  1878. appConfig.secondaryToolbar.printButton.classList.add("hidden");
  1879. }
  1880. if (!PDFViewerApplication.supportsFullscreen) {
  1881. appConfig.toolbar.presentationModeButton.classList.add("hidden");
  1882. appConfig.secondaryToolbar.presentationModeButton.classList.add("hidden");
  1883. }
  1884. if (PDFViewerApplication.supportsIntegratedFind) {
  1885. appConfig.toolbar.viewFind.classList.add("hidden");
  1886. }
  1887. appConfig.mainContainer.addEventListener("transitionend", function (evt) {
  1888. if (evt.target === this) {
  1889. PDFViewerApplication.eventBus.dispatch("resize", {
  1890. source: this
  1891. });
  1892. }
  1893. }, true);
  1894. try {
  1895. webViewerOpenFileViaURL(file);
  1896. } catch (reason) {
  1897. PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(function (msg) {
  1898. PDFViewerApplication.error(msg, reason);
  1899. });
  1900. }
  1901. }
  1902. var webViewerOpenFileViaURL;
  1903. {
  1904. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  1905. if (file && file.lastIndexOf("file:", 0) === 0) {
  1906. PDFViewerApplication.setTitleUsingUrl(file);
  1907. var xhr = new XMLHttpRequest();
  1908. xhr.onload = function () {
  1909. PDFViewerApplication.open(new Uint8Array(xhr.response));
  1910. };
  1911. xhr.open("GET", file);
  1912. xhr.responseType = "arraybuffer";
  1913. xhr.send();
  1914. return;
  1915. }
  1916. if (file) {
  1917. PDFViewerApplication.open(file);
  1918. }
  1919. };
  1920. }
  1921. function webViewerResetPermissions() {
  1922. var appConfig = PDFViewerApplication.appConfig;
  1923. if (!appConfig) {
  1924. return;
  1925. }
  1926. appConfig.viewerContainer.classList.remove(ENABLE_PERMISSIONS_CLASS);
  1927. }
  1928. function webViewerPageRendered(evt) {
  1929. var pageNumber = evt.pageNumber;
  1930. var pageIndex = pageNumber - 1;
  1931. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  1932. if (pageNumber === PDFViewerApplication.page) {
  1933. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  1934. }
  1935. if (!pageView) {
  1936. return;
  1937. }
  1938. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  1939. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  1940. thumbnailView.setImage(pageView);
  1941. }
  1942. if (typeof Stats !== "undefined" && Stats.enabled && pageView.stats) {
  1943. Stats.add(pageNumber, pageView.stats);
  1944. }
  1945. if (pageView.error) {
  1946. PDFViewerApplication.l10n.get("rendering_error", null, "An error occurred while rendering the page.").then(function (msg) {
  1947. PDFViewerApplication.error(msg, pageView.error);
  1948. });
  1949. }
  1950. PDFViewerApplication.externalServices.reportTelemetry({
  1951. type: "pageInfo",
  1952. timestamp: evt.timestamp
  1953. });
  1954. PDFViewerApplication.pdfDocument.getStats().then(function (stats) {
  1955. PDFViewerApplication.externalServices.reportTelemetry({
  1956. type: "documentStats",
  1957. stats: stats
  1958. });
  1959. });
  1960. }
  1961. function webViewerPageMode(_ref7) {
  1962. var mode = _ref7.mode;
  1963. var view;
  1964. switch (mode) {
  1965. case "thumbs":
  1966. view = _pdf_sidebar.SidebarView.THUMBS;
  1967. break;
  1968. case "bookmarks":
  1969. case "outline":
  1970. view = _pdf_sidebar.SidebarView.OUTLINE;
  1971. break;
  1972. case "attachments":
  1973. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  1974. break;
  1975. case "none":
  1976. view = _pdf_sidebar.SidebarView.NONE;
  1977. break;
  1978. default:
  1979. console.error('Invalid "pagemode" hash parameter: ' + mode);
  1980. return;
  1981. }
  1982. PDFViewerApplication.pdfSidebar.switchView(view, true);
  1983. }
  1984. function webViewerNamedAction(evt) {
  1985. var action = evt.action;
  1986. switch (action) {
  1987. case "GoToPage":
  1988. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  1989. break;
  1990. case "Find":
  1991. if (!PDFViewerApplication.supportsIntegratedFind) {
  1992. PDFViewerApplication.findBar.toggle();
  1993. }
  1994. break;
  1995. }
  1996. }
  1997. function webViewerPresentationModeChanged(_ref8) {
  1998. var active = _ref8.active,
  1999. switchInProgress = _ref8.switchInProgress;
  2000. var state = _ui_utils.PresentationModeState.NORMAL;
  2001. if (switchInProgress) {
  2002. state = _ui_utils.PresentationModeState.CHANGING;
  2003. } else if (active) {
  2004. state = _ui_utils.PresentationModeState.FULLSCREEN;
  2005. }
  2006. PDFViewerApplication.pdfViewer.presentationModeState = state;
  2007. }
  2008. function webViewerSidebarViewChanged(evt) {
  2009. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  2010. var store = PDFViewerApplication.store;
  2011. if (store && PDFViewerApplication.isInitialViewSet) {
  2012. store.set("sidebarView", evt.view)["catch"](function () {});
  2013. }
  2014. }
  2015. function webViewerUpdateViewarea(evt) {
  2016. var location = evt.location,
  2017. store = PDFViewerApplication.store;
  2018. if (store && PDFViewerApplication.isInitialViewSet) {
  2019. store.setMultiple({
  2020. page: location.pageNumber,
  2021. zoom: location.scale,
  2022. scrollLeft: location.left,
  2023. scrollTop: location.top,
  2024. rotation: location.rotation
  2025. })["catch"](function () {});
  2026. }
  2027. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  2028. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  2029. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  2030. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  2031. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  2032. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  2033. }
  2034. function webViewerScrollModeChanged(evt) {
  2035. var store = PDFViewerApplication.store;
  2036. if (store && PDFViewerApplication.isInitialViewSet) {
  2037. store.set("scrollMode", evt.mode)["catch"](function () {});
  2038. }
  2039. }
  2040. function webViewerSpreadModeChanged(evt) {
  2041. var store = PDFViewerApplication.store;
  2042. if (store && PDFViewerApplication.isInitialViewSet) {
  2043. store.set("spreadMode", evt.mode)["catch"](function () {});
  2044. }
  2045. }
  2046. function webViewerResize() {
  2047. var pdfDocument = PDFViewerApplication.pdfDocument,
  2048. pdfViewer = PDFViewerApplication.pdfViewer;
  2049. if (!pdfDocument) {
  2050. return;
  2051. }
  2052. var currentScaleValue = pdfViewer.currentScaleValue;
  2053. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  2054. pdfViewer.currentScaleValue = currentScaleValue;
  2055. }
  2056. pdfViewer.update();
  2057. }
  2058. function webViewerHashchange(evt) {
  2059. var hash = evt.hash;
  2060. if (!hash) {
  2061. return;
  2062. }
  2063. if (!PDFViewerApplication.isInitialViewSet) {
  2064. PDFViewerApplication.initialBookmark = hash;
  2065. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  2066. PDFViewerApplication.pdfLinkService.setHash(hash);
  2067. }
  2068. }
  2069. var webViewerFileInputChange, webViewerOpenFile;
  2070. {
  2071. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  2072. if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
  2073. return;
  2074. }
  2075. var file = evt.fileInput.files[0];
  2076. if (!_app_options.AppOptions.get("disableCreateObjectURL")) {
  2077. var url = URL.createObjectURL(file);
  2078. if (file.name) {
  2079. url = {
  2080. url: url,
  2081. originalUrl: file.name
  2082. };
  2083. }
  2084. PDFViewerApplication.open(url);
  2085. } else {
  2086. PDFViewerApplication.setTitleUsingUrl(file.name);
  2087. var fileReader = new FileReader();
  2088. fileReader.onload = function webViewerChangeFileReaderOnload(event) {
  2089. var buffer = event.target.result;
  2090. PDFViewerApplication.open(new Uint8Array(buffer));
  2091. };
  2092. fileReader.readAsArrayBuffer(file);
  2093. }
  2094. var appConfig = PDFViewerApplication.appConfig;
  2095. appConfig.toolbar.viewBookmark.setAttribute("hidden", "true");
  2096. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute("hidden", "true");
  2097. appConfig.toolbar.download.setAttribute("hidden", "true");
  2098. appConfig.secondaryToolbar.downloadButton.setAttribute("hidden", "true");
  2099. };
  2100. webViewerOpenFile = function webViewerOpenFile(evt) {
  2101. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  2102. document.getElementById(openFileInputName).click();
  2103. };
  2104. }
  2105. function webViewerPresentationMode() {
  2106. PDFViewerApplication.requestPresentationMode();
  2107. }
  2108. function webViewerPrint() {
  2109. window.print();
  2110. }
  2111. function webViewerDownload() {
  2112. PDFViewerApplication.download();
  2113. }
  2114. function webViewerFirstPage() {
  2115. if (PDFViewerApplication.pdfDocument) {
  2116. PDFViewerApplication.page = 1;
  2117. }
  2118. }
  2119. function webViewerLastPage() {
  2120. if (PDFViewerApplication.pdfDocument) {
  2121. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2122. }
  2123. }
  2124. function webViewerNextPage() {
  2125. PDFViewerApplication.page++;
  2126. }
  2127. function webViewerPreviousPage() {
  2128. PDFViewerApplication.page--;
  2129. }
  2130. function webViewerZoomIn() {
  2131. PDFViewerApplication.zoomIn();
  2132. }
  2133. function webViewerZoomOut() {
  2134. PDFViewerApplication.zoomOut();
  2135. }
  2136. function webViewerZoomReset() {
  2137. PDFViewerApplication.zoomReset();
  2138. }
  2139. function webViewerPageNumberChanged(evt) {
  2140. var pdfViewer = PDFViewerApplication.pdfViewer;
  2141. if (evt.value !== "") {
  2142. pdfViewer.currentPageLabel = evt.value;
  2143. }
  2144. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  2145. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  2146. }
  2147. }
  2148. function webViewerScaleChanged(evt) {
  2149. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  2150. }
  2151. function webViewerRotateCw() {
  2152. PDFViewerApplication.rotatePages(90);
  2153. }
  2154. function webViewerRotateCcw() {
  2155. PDFViewerApplication.rotatePages(-90);
  2156. }
  2157. function webViewerSwitchScrollMode(evt) {
  2158. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  2159. }
  2160. function webViewerSwitchSpreadMode(evt) {
  2161. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  2162. }
  2163. function webViewerDocumentProperties() {
  2164. PDFViewerApplication.pdfDocumentProperties.open();
  2165. }
  2166. function webViewerFind(evt) {
  2167. PDFViewerApplication.findController.executeCommand("find" + evt.type, {
  2168. query: evt.query,
  2169. phraseSearch: evt.phraseSearch,
  2170. caseSensitive: evt.caseSensitive,
  2171. entireWord: evt.entireWord,
  2172. highlightAll: evt.highlightAll,
  2173. findPrevious: evt.findPrevious
  2174. });
  2175. }
  2176. function webViewerFindFromUrlHash(evt) {
  2177. PDFViewerApplication.findController.executeCommand("find", {
  2178. query: evt.query,
  2179. phraseSearch: evt.phraseSearch,
  2180. caseSensitive: false,
  2181. entireWord: false,
  2182. highlightAll: true,
  2183. findPrevious: false
  2184. });
  2185. }
  2186. function webViewerUpdateFindMatchesCount(_ref9) {
  2187. var matchesCount = _ref9.matchesCount;
  2188. if (PDFViewerApplication.supportsIntegratedFind) {
  2189. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  2190. } else {
  2191. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  2192. }
  2193. }
  2194. function webViewerUpdateFindControlState(_ref10) {
  2195. var state = _ref10.state,
  2196. previous = _ref10.previous,
  2197. matchesCount = _ref10.matchesCount;
  2198. if (PDFViewerApplication.supportsIntegratedFind) {
  2199. PDFViewerApplication.externalServices.updateFindControlState({
  2200. result: state,
  2201. findPrevious: previous,
  2202. matchesCount: matchesCount
  2203. });
  2204. } else {
  2205. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  2206. }
  2207. }
  2208. function webViewerScaleChanging(evt) {
  2209. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  2210. PDFViewerApplication.pdfViewer.update();
  2211. }
  2212. function webViewerRotationChanging(evt) {
  2213. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  2214. PDFViewerApplication.forceRendering();
  2215. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  2216. }
  2217. function webViewerPageChanging(evt) {
  2218. var page = evt.pageNumber;
  2219. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  2220. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  2221. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2222. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
  2223. }
  2224. if (typeof Stats !== "undefined" && Stats.enabled) {
  2225. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  2226. if (pageView && pageView.stats) {
  2227. Stats.add(page, pageView.stats);
  2228. }
  2229. }
  2230. }
  2231. function webViewerVisibilityChange(evt) {
  2232. if (document.visibilityState === "visible") {
  2233. setZoomDisabledTimeout();
  2234. }
  2235. }
  2236. var zoomDisabledTimeout = null;
  2237. function setZoomDisabledTimeout() {
  2238. if (zoomDisabledTimeout) {
  2239. clearTimeout(zoomDisabledTimeout);
  2240. }
  2241. zoomDisabledTimeout = setTimeout(function () {
  2242. zoomDisabledTimeout = null;
  2243. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  2244. }
  2245. function webViewerWheel(evt) {
  2246. var pdfViewer = PDFViewerApplication.pdfViewer,
  2247. supportedMouseWheelZoomModifierKeys = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  2248. if (pdfViewer.isInPresentationMode) {
  2249. return;
  2250. }
  2251. if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
  2252. evt.preventDefault();
  2253. if (zoomDisabledTimeout || document.visibilityState === "hidden") {
  2254. return;
  2255. }
  2256. var previousScale = pdfViewer.currentScale;
  2257. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  2258. var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
  2259. var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
  2260. if (ticks < 0) {
  2261. PDFViewerApplication.zoomOut(-ticks);
  2262. } else {
  2263. PDFViewerApplication.zoomIn(ticks);
  2264. }
  2265. var currentScale = pdfViewer.currentScale;
  2266. if (previousScale !== currentScale) {
  2267. var scaleCorrectionFactor = currentScale / previousScale - 1;
  2268. var rect = pdfViewer.container.getBoundingClientRect();
  2269. var dx = evt.clientX - rect.left;
  2270. var dy = evt.clientY - rect.top;
  2271. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  2272. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  2273. }
  2274. } else {
  2275. setZoomDisabledTimeout();
  2276. }
  2277. }
  2278. function webViewerClick(evt) {
  2279. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  2280. return;
  2281. }
  2282. var appConfig = PDFViewerApplication.appConfig;
  2283. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  2284. PDFViewerApplication.secondaryToolbar.close();
  2285. }
  2286. }
  2287. function webViewerKeyDown(evt) {
  2288. if (PDFViewerApplication.overlayManager.active) {
  2289. return;
  2290. }
  2291. var handled = false,
  2292. ensureViewerFocused = false;
  2293. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  2294. var pdfViewer = PDFViewerApplication.pdfViewer;
  2295. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  2296. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  2297. switch (evt.keyCode) {
  2298. case 70:
  2299. if (!PDFViewerApplication.supportsIntegratedFind) {
  2300. PDFViewerApplication.findBar.open();
  2301. handled = true;
  2302. }
  2303. break;
  2304. case 71:
  2305. if (!PDFViewerApplication.supportsIntegratedFind) {
  2306. var findState = PDFViewerApplication.findController.state;
  2307. if (findState) {
  2308. PDFViewerApplication.findController.executeCommand("findagain", {
  2309. query: findState.query,
  2310. phraseSearch: findState.phraseSearch,
  2311. caseSensitive: findState.caseSensitive,
  2312. entireWord: findState.entireWord,
  2313. highlightAll: findState.highlightAll,
  2314. findPrevious: cmd === 5 || cmd === 12
  2315. });
  2316. }
  2317. handled = true;
  2318. }
  2319. break;
  2320. case 61:
  2321. case 107:
  2322. case 187:
  2323. case 171:
  2324. if (!isViewerInPresentationMode) {
  2325. PDFViewerApplication.zoomIn();
  2326. }
  2327. handled = true;
  2328. break;
  2329. case 173:
  2330. case 109:
  2331. case 189:
  2332. if (!isViewerInPresentationMode) {
  2333. PDFViewerApplication.zoomOut();
  2334. }
  2335. handled = true;
  2336. break;
  2337. case 48:
  2338. case 96:
  2339. if (!isViewerInPresentationMode) {
  2340. setTimeout(function () {
  2341. PDFViewerApplication.zoomReset();
  2342. });
  2343. handled = false;
  2344. }
  2345. break;
  2346. case 38:
  2347. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2348. PDFViewerApplication.page = 1;
  2349. handled = true;
  2350. ensureViewerFocused = true;
  2351. }
  2352. break;
  2353. case 40:
  2354. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2355. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2356. handled = true;
  2357. ensureViewerFocused = true;
  2358. }
  2359. break;
  2360. }
  2361. }
  2362. var eventBus = PDFViewerApplication.eventBus;
  2363. if (cmd === 1 || cmd === 8) {
  2364. switch (evt.keyCode) {
  2365. case 83:
  2366. eventBus.dispatch("download", {
  2367. source: window
  2368. });
  2369. handled = true;
  2370. break;
  2371. case 79:
  2372. {
  2373. eventBus.dispatch("openfile", {
  2374. source: window
  2375. });
  2376. handled = true;
  2377. }
  2378. break;
  2379. }
  2380. }
  2381. if (cmd === 3 || cmd === 10) {
  2382. switch (evt.keyCode) {
  2383. case 80:
  2384. PDFViewerApplication.requestPresentationMode();
  2385. handled = true;
  2386. break;
  2387. case 71:
  2388. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2389. handled = true;
  2390. break;
  2391. }
  2392. }
  2393. if (handled) {
  2394. if (ensureViewerFocused && !isViewerInPresentationMode) {
  2395. pdfViewer.focus();
  2396. }
  2397. evt.preventDefault();
  2398. return;
  2399. }
  2400. var curElement = document.activeElement || document.querySelector(":focus");
  2401. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  2402. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement && curElement.isContentEditable) {
  2403. if (evt.keyCode !== 27) {
  2404. return;
  2405. }
  2406. }
  2407. if (cmd === 0) {
  2408. var turnPage = 0,
  2409. turnOnlyIfPageFit = false;
  2410. switch (evt.keyCode) {
  2411. case 38:
  2412. case 33:
  2413. if (pdfViewer.isVerticalScrollbarEnabled) {
  2414. turnOnlyIfPageFit = true;
  2415. }
  2416. turnPage = -1;
  2417. break;
  2418. case 8:
  2419. if (!isViewerInPresentationMode) {
  2420. turnOnlyIfPageFit = true;
  2421. }
  2422. turnPage = -1;
  2423. break;
  2424. case 37:
  2425. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2426. turnOnlyIfPageFit = true;
  2427. }
  2428. case 75:
  2429. case 80:
  2430. turnPage = -1;
  2431. break;
  2432. case 27:
  2433. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  2434. PDFViewerApplication.secondaryToolbar.close();
  2435. handled = true;
  2436. }
  2437. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  2438. PDFViewerApplication.findBar.close();
  2439. handled = true;
  2440. }
  2441. break;
  2442. case 40:
  2443. case 34:
  2444. if (pdfViewer.isVerticalScrollbarEnabled) {
  2445. turnOnlyIfPageFit = true;
  2446. }
  2447. turnPage = 1;
  2448. break;
  2449. case 13:
  2450. case 32:
  2451. if (!isViewerInPresentationMode) {
  2452. turnOnlyIfPageFit = true;
  2453. }
  2454. turnPage = 1;
  2455. break;
  2456. case 39:
  2457. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2458. turnOnlyIfPageFit = true;
  2459. }
  2460. case 74:
  2461. case 78:
  2462. turnPage = 1;
  2463. break;
  2464. case 36:
  2465. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2466. PDFViewerApplication.page = 1;
  2467. handled = true;
  2468. ensureViewerFocused = true;
  2469. }
  2470. break;
  2471. case 35:
  2472. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2473. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2474. handled = true;
  2475. ensureViewerFocused = true;
  2476. }
  2477. break;
  2478. case 83:
  2479. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  2480. break;
  2481. case 72:
  2482. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  2483. break;
  2484. case 82:
  2485. PDFViewerApplication.rotatePages(90);
  2486. break;
  2487. case 115:
  2488. PDFViewerApplication.pdfSidebar.toggle();
  2489. break;
  2490. }
  2491. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  2492. if (turnPage > 0) {
  2493. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2494. PDFViewerApplication.page++;
  2495. }
  2496. } else {
  2497. if (PDFViewerApplication.page > 1) {
  2498. PDFViewerApplication.page--;
  2499. }
  2500. }
  2501. handled = true;
  2502. }
  2503. }
  2504. if (cmd === 4) {
  2505. switch (evt.keyCode) {
  2506. case 13:
  2507. case 32:
  2508. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  2509. break;
  2510. }
  2511. if (PDFViewerApplication.page > 1) {
  2512. PDFViewerApplication.page--;
  2513. }
  2514. handled = true;
  2515. break;
  2516. case 82:
  2517. PDFViewerApplication.rotatePages(-90);
  2518. break;
  2519. }
  2520. }
  2521. if (!handled && !isViewerInPresentationMode) {
  2522. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  2523. ensureViewerFocused = true;
  2524. }
  2525. }
  2526. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  2527. pdfViewer.focus();
  2528. }
  2529. if (handled) {
  2530. evt.preventDefault();
  2531. }
  2532. }
  2533. function apiPageLayoutToSpreadMode(layout) {
  2534. switch (layout) {
  2535. case "SinglePage":
  2536. case "OneColumn":
  2537. return _ui_utils.SpreadMode.NONE;
  2538. case "TwoColumnLeft":
  2539. case "TwoPageLeft":
  2540. return _ui_utils.SpreadMode.ODD;
  2541. case "TwoColumnRight":
  2542. case "TwoPageRight":
  2543. return _ui_utils.SpreadMode.EVEN;
  2544. }
  2545. return _ui_utils.SpreadMode.NONE;
  2546. }
  2547. function apiPageModeToSidebarView(mode) {
  2548. switch (mode) {
  2549. case "UseNone":
  2550. return _pdf_sidebar.SidebarView.NONE;
  2551. case "UseThumbs":
  2552. return _pdf_sidebar.SidebarView.THUMBS;
  2553. case "UseOutlines":
  2554. return _pdf_sidebar.SidebarView.OUTLINE;
  2555. case "UseAttachments":
  2556. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  2557. case "UseOC":
  2558. }
  2559. return _pdf_sidebar.SidebarView.NONE;
  2560. }
  2561. var PDFPrintServiceFactory = {
  2562. instance: {
  2563. supportsPrinting: false,
  2564. createPrintService: function createPrintService() {
  2565. throw new Error("Not implemented: createPrintService");
  2566. }
  2567. }
  2568. };
  2569. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  2570. /***/ }),
  2571. /* 2 */
  2572. /***/ (function(module, exports, __webpack_require__) {
  2573. "use strict";
  2574. module.exports = __webpack_require__(3);
  2575. /***/ }),
  2576. /* 3 */
  2577. /***/ (function(module, exports, __webpack_require__) {
  2578. "use strict";
  2579. /* WEBPACK VAR INJECTION */(function(module) {
  2580. 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); }
  2581. var runtime = function (exports) {
  2582. "use strict";
  2583. var Op = Object.prototype;
  2584. var hasOwn = Op.hasOwnProperty;
  2585. var undefined;
  2586. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  2587. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  2588. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  2589. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  2590. function wrap(innerFn, outerFn, self, tryLocsList) {
  2591. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  2592. var generator = Object.create(protoGenerator.prototype);
  2593. var context = new Context(tryLocsList || []);
  2594. generator._invoke = makeInvokeMethod(innerFn, self, context);
  2595. return generator;
  2596. }
  2597. exports.wrap = wrap;
  2598. function tryCatch(fn, obj, arg) {
  2599. try {
  2600. return {
  2601. type: "normal",
  2602. arg: fn.call(obj, arg)
  2603. };
  2604. } catch (err) {
  2605. return {
  2606. type: "throw",
  2607. arg: err
  2608. };
  2609. }
  2610. }
  2611. var GenStateSuspendedStart = "suspendedStart";
  2612. var GenStateSuspendedYield = "suspendedYield";
  2613. var GenStateExecuting = "executing";
  2614. var GenStateCompleted = "completed";
  2615. var ContinueSentinel = {};
  2616. function Generator() {}
  2617. function GeneratorFunction() {}
  2618. function GeneratorFunctionPrototype() {}
  2619. var IteratorPrototype = {};
  2620. IteratorPrototype[iteratorSymbol] = function () {
  2621. return this;
  2622. };
  2623. var getProto = Object.getPrototypeOf;
  2624. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  2625. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  2626. IteratorPrototype = NativeIteratorPrototype;
  2627. }
  2628. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  2629. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  2630. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  2631. GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
  2632. function defineIteratorMethods(prototype) {
  2633. ["next", "throw", "return"].forEach(function (method) {
  2634. prototype[method] = function (arg) {
  2635. return this._invoke(method, arg);
  2636. };
  2637. });
  2638. }
  2639. exports.isGeneratorFunction = function (genFun) {
  2640. var ctor = typeof genFun === "function" && genFun.constructor;
  2641. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  2642. };
  2643. exports.mark = function (genFun) {
  2644. if (Object.setPrototypeOf) {
  2645. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  2646. } else {
  2647. genFun.__proto__ = GeneratorFunctionPrototype;
  2648. if (!(toStringTagSymbol in genFun)) {
  2649. genFun[toStringTagSymbol] = "GeneratorFunction";
  2650. }
  2651. }
  2652. genFun.prototype = Object.create(Gp);
  2653. return genFun;
  2654. };
  2655. exports.awrap = function (arg) {
  2656. return {
  2657. __await: arg
  2658. };
  2659. };
  2660. function AsyncIterator(generator, PromiseImpl) {
  2661. function invoke(method, arg, resolve, reject) {
  2662. var record = tryCatch(generator[method], generator, arg);
  2663. if (record.type === "throw") {
  2664. reject(record.arg);
  2665. } else {
  2666. var result = record.arg;
  2667. var value = result.value;
  2668. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  2669. return PromiseImpl.resolve(value.__await).then(function (value) {
  2670. invoke("next", value, resolve, reject);
  2671. }, function (err) {
  2672. invoke("throw", err, resolve, reject);
  2673. });
  2674. }
  2675. return PromiseImpl.resolve(value).then(function (unwrapped) {
  2676. result.value = unwrapped;
  2677. resolve(result);
  2678. }, function (error) {
  2679. return invoke("throw", error, resolve, reject);
  2680. });
  2681. }
  2682. }
  2683. var previousPromise;
  2684. function enqueue(method, arg) {
  2685. function callInvokeWithMethodAndArg() {
  2686. return new PromiseImpl(function (resolve, reject) {
  2687. invoke(method, arg, resolve, reject);
  2688. });
  2689. }
  2690. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  2691. }
  2692. this._invoke = enqueue;
  2693. }
  2694. defineIteratorMethods(AsyncIterator.prototype);
  2695. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  2696. return this;
  2697. };
  2698. exports.AsyncIterator = AsyncIterator;
  2699. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  2700. if (PromiseImpl === void 0) PromiseImpl = Promise;
  2701. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  2702. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  2703. return result.done ? result.value : iter.next();
  2704. });
  2705. };
  2706. function makeInvokeMethod(innerFn, self, context) {
  2707. var state = GenStateSuspendedStart;
  2708. return function invoke(method, arg) {
  2709. if (state === GenStateExecuting) {
  2710. throw new Error("Generator is already running");
  2711. }
  2712. if (state === GenStateCompleted) {
  2713. if (method === "throw") {
  2714. throw arg;
  2715. }
  2716. return doneResult();
  2717. }
  2718. context.method = method;
  2719. context.arg = arg;
  2720. while (true) {
  2721. var delegate = context.delegate;
  2722. if (delegate) {
  2723. var delegateResult = maybeInvokeDelegate(delegate, context);
  2724. if (delegateResult) {
  2725. if (delegateResult === ContinueSentinel) continue;
  2726. return delegateResult;
  2727. }
  2728. }
  2729. if (context.method === "next") {
  2730. context.sent = context._sent = context.arg;
  2731. } else if (context.method === "throw") {
  2732. if (state === GenStateSuspendedStart) {
  2733. state = GenStateCompleted;
  2734. throw context.arg;
  2735. }
  2736. context.dispatchException(context.arg);
  2737. } else if (context.method === "return") {
  2738. context.abrupt("return", context.arg);
  2739. }
  2740. state = GenStateExecuting;
  2741. var record = tryCatch(innerFn, self, context);
  2742. if (record.type === "normal") {
  2743. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  2744. if (record.arg === ContinueSentinel) {
  2745. continue;
  2746. }
  2747. return {
  2748. value: record.arg,
  2749. done: context.done
  2750. };
  2751. } else if (record.type === "throw") {
  2752. state = GenStateCompleted;
  2753. context.method = "throw";
  2754. context.arg = record.arg;
  2755. }
  2756. }
  2757. };
  2758. }
  2759. function maybeInvokeDelegate(delegate, context) {
  2760. var method = delegate.iterator[context.method];
  2761. if (method === undefined) {
  2762. context.delegate = null;
  2763. if (context.method === "throw") {
  2764. if (delegate.iterator["return"]) {
  2765. context.method = "return";
  2766. context.arg = undefined;
  2767. maybeInvokeDelegate(delegate, context);
  2768. if (context.method === "throw") {
  2769. return ContinueSentinel;
  2770. }
  2771. }
  2772. context.method = "throw";
  2773. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  2774. }
  2775. return ContinueSentinel;
  2776. }
  2777. var record = tryCatch(method, delegate.iterator, context.arg);
  2778. if (record.type === "throw") {
  2779. context.method = "throw";
  2780. context.arg = record.arg;
  2781. context.delegate = null;
  2782. return ContinueSentinel;
  2783. }
  2784. var info = record.arg;
  2785. if (!info) {
  2786. context.method = "throw";
  2787. context.arg = new TypeError("iterator result is not an object");
  2788. context.delegate = null;
  2789. return ContinueSentinel;
  2790. }
  2791. if (info.done) {
  2792. context[delegate.resultName] = info.value;
  2793. context.next = delegate.nextLoc;
  2794. if (context.method !== "return") {
  2795. context.method = "next";
  2796. context.arg = undefined;
  2797. }
  2798. } else {
  2799. return info;
  2800. }
  2801. context.delegate = null;
  2802. return ContinueSentinel;
  2803. }
  2804. defineIteratorMethods(Gp);
  2805. Gp[toStringTagSymbol] = "Generator";
  2806. Gp[iteratorSymbol] = function () {
  2807. return this;
  2808. };
  2809. Gp.toString = function () {
  2810. return "[object Generator]";
  2811. };
  2812. function pushTryEntry(locs) {
  2813. var entry = {
  2814. tryLoc: locs[0]
  2815. };
  2816. if (1 in locs) {
  2817. entry.catchLoc = locs[1];
  2818. }
  2819. if (2 in locs) {
  2820. entry.finallyLoc = locs[2];
  2821. entry.afterLoc = locs[3];
  2822. }
  2823. this.tryEntries.push(entry);
  2824. }
  2825. function resetTryEntry(entry) {
  2826. var record = entry.completion || {};
  2827. record.type = "normal";
  2828. delete record.arg;
  2829. entry.completion = record;
  2830. }
  2831. function Context(tryLocsList) {
  2832. this.tryEntries = [{
  2833. tryLoc: "root"
  2834. }];
  2835. tryLocsList.forEach(pushTryEntry, this);
  2836. this.reset(true);
  2837. }
  2838. exports.keys = function (object) {
  2839. var keys = [];
  2840. for (var key in object) {
  2841. keys.push(key);
  2842. }
  2843. keys.reverse();
  2844. return function next() {
  2845. while (keys.length) {
  2846. var key = keys.pop();
  2847. if (key in object) {
  2848. next.value = key;
  2849. next.done = false;
  2850. return next;
  2851. }
  2852. }
  2853. next.done = true;
  2854. return next;
  2855. };
  2856. };
  2857. function values(iterable) {
  2858. if (iterable) {
  2859. var iteratorMethod = iterable[iteratorSymbol];
  2860. if (iteratorMethod) {
  2861. return iteratorMethod.call(iterable);
  2862. }
  2863. if (typeof iterable.next === "function") {
  2864. return iterable;
  2865. }
  2866. if (!isNaN(iterable.length)) {
  2867. var i = -1,
  2868. next = function next() {
  2869. while (++i < iterable.length) {
  2870. if (hasOwn.call(iterable, i)) {
  2871. next.value = iterable[i];
  2872. next.done = false;
  2873. return next;
  2874. }
  2875. }
  2876. next.value = undefined;
  2877. next.done = true;
  2878. return next;
  2879. };
  2880. return next.next = next;
  2881. }
  2882. }
  2883. return {
  2884. next: doneResult
  2885. };
  2886. }
  2887. exports.values = values;
  2888. function doneResult() {
  2889. return {
  2890. value: undefined,
  2891. done: true
  2892. };
  2893. }
  2894. Context.prototype = {
  2895. constructor: Context,
  2896. reset: function reset(skipTempReset) {
  2897. this.prev = 0;
  2898. this.next = 0;
  2899. this.sent = this._sent = undefined;
  2900. this.done = false;
  2901. this.delegate = null;
  2902. this.method = "next";
  2903. this.arg = undefined;
  2904. this.tryEntries.forEach(resetTryEntry);
  2905. if (!skipTempReset) {
  2906. for (var name in this) {
  2907. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  2908. this[name] = undefined;
  2909. }
  2910. }
  2911. }
  2912. },
  2913. stop: function stop() {
  2914. this.done = true;
  2915. var rootEntry = this.tryEntries[0];
  2916. var rootRecord = rootEntry.completion;
  2917. if (rootRecord.type === "throw") {
  2918. throw rootRecord.arg;
  2919. }
  2920. return this.rval;
  2921. },
  2922. dispatchException: function dispatchException(exception) {
  2923. if (this.done) {
  2924. throw exception;
  2925. }
  2926. var context = this;
  2927. function handle(loc, caught) {
  2928. record.type = "throw";
  2929. record.arg = exception;
  2930. context.next = loc;
  2931. if (caught) {
  2932. context.method = "next";
  2933. context.arg = undefined;
  2934. }
  2935. return !!caught;
  2936. }
  2937. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2938. var entry = this.tryEntries[i];
  2939. var record = entry.completion;
  2940. if (entry.tryLoc === "root") {
  2941. return handle("end");
  2942. }
  2943. if (entry.tryLoc <= this.prev) {
  2944. var hasCatch = hasOwn.call(entry, "catchLoc");
  2945. var hasFinally = hasOwn.call(entry, "finallyLoc");
  2946. if (hasCatch && hasFinally) {
  2947. if (this.prev < entry.catchLoc) {
  2948. return handle(entry.catchLoc, true);
  2949. } else if (this.prev < entry.finallyLoc) {
  2950. return handle(entry.finallyLoc);
  2951. }
  2952. } else if (hasCatch) {
  2953. if (this.prev < entry.catchLoc) {
  2954. return handle(entry.catchLoc, true);
  2955. }
  2956. } else if (hasFinally) {
  2957. if (this.prev < entry.finallyLoc) {
  2958. return handle(entry.finallyLoc);
  2959. }
  2960. } else {
  2961. throw new Error("try statement without catch or finally");
  2962. }
  2963. }
  2964. }
  2965. },
  2966. abrupt: function abrupt(type, arg) {
  2967. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2968. var entry = this.tryEntries[i];
  2969. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  2970. var finallyEntry = entry;
  2971. break;
  2972. }
  2973. }
  2974. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  2975. finallyEntry = null;
  2976. }
  2977. var record = finallyEntry ? finallyEntry.completion : {};
  2978. record.type = type;
  2979. record.arg = arg;
  2980. if (finallyEntry) {
  2981. this.method = "next";
  2982. this.next = finallyEntry.finallyLoc;
  2983. return ContinueSentinel;
  2984. }
  2985. return this.complete(record);
  2986. },
  2987. complete: function complete(record, afterLoc) {
  2988. if (record.type === "throw") {
  2989. throw record.arg;
  2990. }
  2991. if (record.type === "break" || record.type === "continue") {
  2992. this.next = record.arg;
  2993. } else if (record.type === "return") {
  2994. this.rval = this.arg = record.arg;
  2995. this.method = "return";
  2996. this.next = "end";
  2997. } else if (record.type === "normal" && afterLoc) {
  2998. this.next = afterLoc;
  2999. }
  3000. return ContinueSentinel;
  3001. },
  3002. finish: function finish(finallyLoc) {
  3003. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3004. var entry = this.tryEntries[i];
  3005. if (entry.finallyLoc === finallyLoc) {
  3006. this.complete(entry.completion, entry.afterLoc);
  3007. resetTryEntry(entry);
  3008. return ContinueSentinel;
  3009. }
  3010. }
  3011. },
  3012. "catch": function _catch(tryLoc) {
  3013. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3014. var entry = this.tryEntries[i];
  3015. if (entry.tryLoc === tryLoc) {
  3016. var record = entry.completion;
  3017. if (record.type === "throw") {
  3018. var thrown = record.arg;
  3019. resetTryEntry(entry);
  3020. }
  3021. return thrown;
  3022. }
  3023. }
  3024. throw new Error("illegal catch attempt");
  3025. },
  3026. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  3027. this.delegate = {
  3028. iterator: values(iterable),
  3029. resultName: resultName,
  3030. nextLoc: nextLoc
  3031. };
  3032. if (this.method === "next") {
  3033. this.arg = undefined;
  3034. }
  3035. return ContinueSentinel;
  3036. }
  3037. };
  3038. return exports;
  3039. }(( false ? undefined : _typeof(module)) === "object" ? module.exports : {});
  3040. try {
  3041. regeneratorRuntime = runtime;
  3042. } catch (accidentalStrictMode) {
  3043. Function("r", "regeneratorRuntime = r")(runtime);
  3044. }
  3045. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4)(module)))
  3046. /***/ }),
  3047. /* 4 */
  3048. /***/ (function(module, exports, __webpack_require__) {
  3049. "use strict";
  3050. module.exports = function (module) {
  3051. if (!module.webpackPolyfill) {
  3052. module.deprecate = function () {};
  3053. module.paths = [];
  3054. if (!module.children) module.children = [];
  3055. Object.defineProperty(module, "loaded", {
  3056. enumerable: true,
  3057. get: function get() {
  3058. return module.l;
  3059. }
  3060. });
  3061. Object.defineProperty(module, "id", {
  3062. enumerable: true,
  3063. get: function get() {
  3064. return module.i;
  3065. }
  3066. });
  3067. module.webpackPolyfill = 1;
  3068. }
  3069. return module;
  3070. };
  3071. /***/ }),
  3072. /* 5 */
  3073. /***/ (function(module, exports, __webpack_require__) {
  3074. "use strict";
  3075. Object.defineProperty(exports, "__esModule", {
  3076. value: true
  3077. });
  3078. exports.isValidRotation = isValidRotation;
  3079. exports.isValidScrollMode = isValidScrollMode;
  3080. exports.isValidSpreadMode = isValidSpreadMode;
  3081. exports.isPortraitOrientation = isPortraitOrientation;
  3082. exports.clamp = clamp;
  3083. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  3084. exports.noContextMenuHandler = noContextMenuHandler;
  3085. exports.parseQueryString = parseQueryString;
  3086. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  3087. exports.getVisibleElements = getVisibleElements;
  3088. exports.roundToDivide = roundToDivide;
  3089. exports.getPageSizeInches = getPageSizeInches;
  3090. exports.approximateFraction = approximateFraction;
  3091. exports.getOutputScale = getOutputScale;
  3092. exports.scrollIntoView = scrollIntoView;
  3093. exports.watchScroll = watchScroll;
  3094. exports.binarySearchFirstItem = binarySearchFirstItem;
  3095. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  3096. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  3097. exports.moveToEndOfArray = moveToEndOfArray;
  3098. 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;
  3099. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  3100. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3101. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3102. 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); } }
  3103. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3104. 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); }
  3105. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  3106. 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."); }
  3107. 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); }
  3108. 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; }
  3109. 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; }
  3110. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  3111. 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); } }
  3112. 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); }); }; }
  3113. var CSS_UNITS = 96.0 / 72.0;
  3114. exports.CSS_UNITS = CSS_UNITS;
  3115. var DEFAULT_SCALE_VALUE = "auto";
  3116. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  3117. var DEFAULT_SCALE = 1.0;
  3118. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  3119. var MIN_SCALE = 0.1;
  3120. exports.MIN_SCALE = MIN_SCALE;
  3121. var MAX_SCALE = 10.0;
  3122. exports.MAX_SCALE = MAX_SCALE;
  3123. var UNKNOWN_SCALE = 0;
  3124. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  3125. var MAX_AUTO_SCALE = 1.25;
  3126. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  3127. var SCROLLBAR_PADDING = 40;
  3128. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  3129. var VERTICAL_PADDING = 5;
  3130. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  3131. var PresentationModeState = {
  3132. UNKNOWN: 0,
  3133. NORMAL: 1,
  3134. CHANGING: 2,
  3135. FULLSCREEN: 3
  3136. };
  3137. exports.PresentationModeState = PresentationModeState;
  3138. var RendererType = {
  3139. CANVAS: "canvas",
  3140. SVG: "svg"
  3141. };
  3142. exports.RendererType = RendererType;
  3143. var TextLayerMode = {
  3144. DISABLE: 0,
  3145. ENABLE: 1,
  3146. ENABLE_ENHANCE: 2
  3147. };
  3148. exports.TextLayerMode = TextLayerMode;
  3149. var ScrollMode = {
  3150. UNKNOWN: -1,
  3151. VERTICAL: 0,
  3152. HORIZONTAL: 1,
  3153. WRAPPED: 2
  3154. };
  3155. exports.ScrollMode = ScrollMode;
  3156. var SpreadMode = {
  3157. UNKNOWN: -1,
  3158. NONE: 0,
  3159. ODD: 1,
  3160. EVEN: 2
  3161. };
  3162. exports.SpreadMode = SpreadMode;
  3163. var AutoPrintRegExp = /\bprint\s*\(/;
  3164. exports.AutoPrintRegExp = AutoPrintRegExp;
  3165. function formatL10nValue(text, args) {
  3166. if (!args) {
  3167. return text;
  3168. }
  3169. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  3170. return name in args ? args[name] : "{{" + name + "}}";
  3171. });
  3172. }
  3173. var NullL10n = {
  3174. getLanguage: function getLanguage() {
  3175. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  3176. return _regenerator["default"].wrap(function _callee$(_context) {
  3177. while (1) {
  3178. switch (_context.prev = _context.next) {
  3179. case 0:
  3180. return _context.abrupt("return", "en-us");
  3181. case 1:
  3182. case "end":
  3183. return _context.stop();
  3184. }
  3185. }
  3186. }, _callee);
  3187. }))();
  3188. },
  3189. getDirection: function getDirection() {
  3190. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  3191. return _regenerator["default"].wrap(function _callee2$(_context2) {
  3192. while (1) {
  3193. switch (_context2.prev = _context2.next) {
  3194. case 0:
  3195. return _context2.abrupt("return", "ltr");
  3196. case 1:
  3197. case "end":
  3198. return _context2.stop();
  3199. }
  3200. }
  3201. }, _callee2);
  3202. }))();
  3203. },
  3204. get: function get(property, args, fallback) {
  3205. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  3206. return _regenerator["default"].wrap(function _callee3$(_context3) {
  3207. while (1) {
  3208. switch (_context3.prev = _context3.next) {
  3209. case 0:
  3210. return _context3.abrupt("return", formatL10nValue(fallback, args));
  3211. case 1:
  3212. case "end":
  3213. return _context3.stop();
  3214. }
  3215. }
  3216. }, _callee3);
  3217. }))();
  3218. },
  3219. translate: function translate(element) {
  3220. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  3221. return _regenerator["default"].wrap(function _callee4$(_context4) {
  3222. while (1) {
  3223. switch (_context4.prev = _context4.next) {
  3224. case 0:
  3225. case "end":
  3226. return _context4.stop();
  3227. }
  3228. }
  3229. }, _callee4);
  3230. }))();
  3231. }
  3232. };
  3233. exports.NullL10n = NullL10n;
  3234. function getOutputScale(ctx) {
  3235. var devicePixelRatio = window.devicePixelRatio || 1;
  3236. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  3237. var pixelRatio = devicePixelRatio / backingStoreRatio;
  3238. return {
  3239. sx: pixelRatio,
  3240. sy: pixelRatio,
  3241. scaled: pixelRatio !== 1
  3242. };
  3243. }
  3244. function scrollIntoView(element, spot) {
  3245. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3246. var parent = element.offsetParent;
  3247. if (!parent) {
  3248. console.error("offsetParent is not set -- cannot scroll");
  3249. return;
  3250. }
  3251. var offsetY = element.offsetTop + element.clientTop;
  3252. var offsetX = element.offsetLeft + element.clientLeft;
  3253. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === "hidden") {
  3254. if (parent.dataset._scaleY) {
  3255. offsetY /= parent.dataset._scaleY;
  3256. offsetX /= parent.dataset._scaleX;
  3257. }
  3258. offsetY += parent.offsetTop;
  3259. offsetX += parent.offsetLeft;
  3260. parent = parent.offsetParent;
  3261. if (!parent) {
  3262. return;
  3263. }
  3264. }
  3265. if (spot) {
  3266. if (spot.top !== undefined) {
  3267. offsetY += spot.top;
  3268. }
  3269. if (spot.left !== undefined) {
  3270. offsetX += spot.left;
  3271. parent.scrollLeft = offsetX;
  3272. }
  3273. }
  3274. parent.scrollTop = offsetY;
  3275. }
  3276. function watchScroll(viewAreaElement, callback) {
  3277. var debounceScroll = function debounceScroll(evt) {
  3278. if (rAF) {
  3279. return;
  3280. }
  3281. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  3282. rAF = null;
  3283. var currentX = viewAreaElement.scrollLeft;
  3284. var lastX = state.lastX;
  3285. if (currentX !== lastX) {
  3286. state.right = currentX > lastX;
  3287. }
  3288. state.lastX = currentX;
  3289. var currentY = viewAreaElement.scrollTop;
  3290. var lastY = state.lastY;
  3291. if (currentY !== lastY) {
  3292. state.down = currentY > lastY;
  3293. }
  3294. state.lastY = currentY;
  3295. callback(state);
  3296. });
  3297. };
  3298. var state = {
  3299. right: true,
  3300. down: true,
  3301. lastX: viewAreaElement.scrollLeft,
  3302. lastY: viewAreaElement.scrollTop,
  3303. _eventHandler: debounceScroll
  3304. };
  3305. var rAF = null;
  3306. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  3307. return state;
  3308. }
  3309. function parseQueryString(query) {
  3310. var parts = query.split("&");
  3311. var params = Object.create(null);
  3312. for (var i = 0, ii = parts.length; i < ii; ++i) {
  3313. var param = parts[i].split("=");
  3314. var key = param[0].toLowerCase();
  3315. var value = param.length > 1 ? param[1] : null;
  3316. params[decodeURIComponent(key)] = decodeURIComponent(value);
  3317. }
  3318. return params;
  3319. }
  3320. function binarySearchFirstItem(items, condition) {
  3321. var minIndex = 0;
  3322. var maxIndex = items.length - 1;
  3323. if (maxIndex < 0 || !condition(items[maxIndex])) {
  3324. return items.length;
  3325. }
  3326. if (condition(items[minIndex])) {
  3327. return minIndex;
  3328. }
  3329. while (minIndex < maxIndex) {
  3330. var currentIndex = minIndex + maxIndex >> 1;
  3331. var currentItem = items[currentIndex];
  3332. if (condition(currentItem)) {
  3333. maxIndex = currentIndex;
  3334. } else {
  3335. minIndex = currentIndex + 1;
  3336. }
  3337. }
  3338. return minIndex;
  3339. }
  3340. function approximateFraction(x) {
  3341. if (Math.floor(x) === x) {
  3342. return [x, 1];
  3343. }
  3344. var xinv = 1 / x;
  3345. var limit = 8;
  3346. if (xinv > limit) {
  3347. return [1, limit];
  3348. } else if (Math.floor(xinv) === xinv) {
  3349. return [1, xinv];
  3350. }
  3351. var x_ = x > 1 ? xinv : x;
  3352. var a = 0,
  3353. b = 1,
  3354. c = 1,
  3355. d = 1;
  3356. while (true) {
  3357. var p = a + c,
  3358. q = b + d;
  3359. if (q > limit) {
  3360. break;
  3361. }
  3362. if (x_ <= p / q) {
  3363. c = p;
  3364. d = q;
  3365. } else {
  3366. a = p;
  3367. b = q;
  3368. }
  3369. }
  3370. var result;
  3371. if (x_ - a / b < c / d - x_) {
  3372. result = x_ === x ? [a, b] : [b, a];
  3373. } else {
  3374. result = x_ === x ? [c, d] : [d, c];
  3375. }
  3376. return result;
  3377. }
  3378. function roundToDivide(x, div) {
  3379. var r = x % div;
  3380. return r === 0 ? x : Math.round(x - r + div);
  3381. }
  3382. function getPageSizeInches(_ref) {
  3383. var view = _ref.view,
  3384. userUnit = _ref.userUnit,
  3385. rotate = _ref.rotate;
  3386. var _view = _slicedToArray(view, 4),
  3387. x1 = _view[0],
  3388. y1 = _view[1],
  3389. x2 = _view[2],
  3390. y2 = _view[3];
  3391. var changeOrientation = rotate % 180 !== 0;
  3392. var width = (x2 - x1) / 72 * userUnit;
  3393. var height = (y2 - y1) / 72 * userUnit;
  3394. return {
  3395. width: changeOrientation ? height : width,
  3396. height: changeOrientation ? width : height
  3397. };
  3398. }
  3399. function backtrackBeforeAllVisibleElements(index, views, top) {
  3400. if (index < 2) {
  3401. return index;
  3402. }
  3403. var elt = views[index].div;
  3404. var pageTop = elt.offsetTop + elt.clientTop;
  3405. if (pageTop >= top) {
  3406. elt = views[index - 1].div;
  3407. pageTop = elt.offsetTop + elt.clientTop;
  3408. }
  3409. for (var i = index - 2; i >= 0; --i) {
  3410. elt = views[i].div;
  3411. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  3412. break;
  3413. }
  3414. index = i;
  3415. }
  3416. return index;
  3417. }
  3418. function getVisibleElements(scrollEl, views) {
  3419. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3420. var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  3421. var top = scrollEl.scrollTop,
  3422. bottom = top + scrollEl.clientHeight;
  3423. var left = scrollEl.scrollLeft,
  3424. right = left + scrollEl.clientWidth;
  3425. function isElementBottomAfterViewTop(view) {
  3426. var element = view.div;
  3427. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  3428. return elementBottom > top;
  3429. }
  3430. function isElementRightAfterViewLeft(view) {
  3431. var element = view.div;
  3432. var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
  3433. return elementRight > left;
  3434. }
  3435. var visible = [],
  3436. numViews = views.length;
  3437. var firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
  3438. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  3439. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  3440. }
  3441. var lastEdge = horizontal ? right : -1;
  3442. for (var i = firstVisibleElementInd; i < numViews; i++) {
  3443. var view = views[i],
  3444. element = view.div;
  3445. var currentWidth = element.offsetLeft + element.clientLeft;
  3446. var currentHeight = element.offsetTop + element.clientTop;
  3447. var viewWidth = element.clientWidth,
  3448. viewHeight = element.clientHeight;
  3449. var viewRight = currentWidth + viewWidth;
  3450. var viewBottom = currentHeight + viewHeight;
  3451. if (lastEdge === -1) {
  3452. if (viewBottom >= bottom) {
  3453. lastEdge = viewBottom;
  3454. }
  3455. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  3456. break;
  3457. }
  3458. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  3459. continue;
  3460. }
  3461. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  3462. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  3463. var percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
  3464. visible.push({
  3465. id: view.id,
  3466. x: currentWidth,
  3467. y: currentHeight,
  3468. view: view,
  3469. percent: percent
  3470. });
  3471. }
  3472. var first = visible[0],
  3473. last = visible[visible.length - 1];
  3474. if (sortByVisibility) {
  3475. visible.sort(function (a, b) {
  3476. var pc = a.percent - b.percent;
  3477. if (Math.abs(pc) > 0.001) {
  3478. return -pc;
  3479. }
  3480. return a.id - b.id;
  3481. });
  3482. }
  3483. return {
  3484. first: first,
  3485. last: last,
  3486. views: visible
  3487. };
  3488. }
  3489. function noContextMenuHandler(evt) {
  3490. evt.preventDefault();
  3491. }
  3492. function isDataSchema(url) {
  3493. var i = 0;
  3494. var ii = url.length;
  3495. while (i < ii && url[i].trim() === "") {
  3496. i++;
  3497. }
  3498. return url.substring(i, i + 5).toLowerCase() === "data:";
  3499. }
  3500. function getPDFFileNameFromURL(url) {
  3501. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "document.pdf";
  3502. if (typeof url !== "string") {
  3503. return defaultFilename;
  3504. }
  3505. if (isDataSchema(url)) {
  3506. console.warn("getPDFFileNameFromURL: " + 'ignoring "data:" URL for performance reasons.');
  3507. return defaultFilename;
  3508. }
  3509. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  3510. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  3511. var splitURI = reURI.exec(url);
  3512. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  3513. if (suggestedFilename) {
  3514. suggestedFilename = suggestedFilename[0];
  3515. if (suggestedFilename.includes("%")) {
  3516. try {
  3517. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  3518. } catch (ex) {}
  3519. }
  3520. }
  3521. return suggestedFilename || defaultFilename;
  3522. }
  3523. function normalizeWheelEventDelta(evt) {
  3524. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  3525. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  3526. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  3527. delta = -delta;
  3528. }
  3529. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  3530. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  3531. var MOUSE_PIXELS_PER_LINE = 30;
  3532. var MOUSE_LINES_PER_PAGE = 30;
  3533. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  3534. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  3535. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  3536. delta /= MOUSE_LINES_PER_PAGE;
  3537. }
  3538. return delta;
  3539. }
  3540. function isValidRotation(angle) {
  3541. return Number.isInteger(angle) && angle % 90 === 0;
  3542. }
  3543. function isValidScrollMode(mode) {
  3544. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  3545. }
  3546. function isValidSpreadMode(mode) {
  3547. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  3548. }
  3549. function isPortraitOrientation(size) {
  3550. return size.width <= size.height;
  3551. }
  3552. var WaitOnType = {
  3553. EVENT: "event",
  3554. TIMEOUT: "timeout"
  3555. };
  3556. exports.WaitOnType = WaitOnType;
  3557. function waitOnEventOrTimeout(_ref2) {
  3558. var target = _ref2.target,
  3559. name = _ref2.name,
  3560. _ref2$delay = _ref2.delay,
  3561. delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
  3562. return new Promise(function (resolve, reject) {
  3563. if (_typeof(target) !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  3564. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  3565. }
  3566. function handler(type) {
  3567. if (target instanceof EventBus) {
  3568. target._off(name, eventHandler);
  3569. } else {
  3570. target.removeEventListener(name, eventHandler);
  3571. }
  3572. if (timeout) {
  3573. clearTimeout(timeout);
  3574. }
  3575. resolve(type);
  3576. }
  3577. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  3578. if (target instanceof EventBus) {
  3579. target._on(name, eventHandler);
  3580. } else {
  3581. target.addEventListener(name, eventHandler);
  3582. }
  3583. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  3584. var timeout = setTimeout(timeoutHandler, delay);
  3585. });
  3586. }
  3587. var animationStarted = new Promise(function (resolve) {
  3588. window.requestAnimationFrame(resolve);
  3589. });
  3590. exports.animationStarted = animationStarted;
  3591. function dispatchDOMEvent(eventName) {
  3592. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3593. throw new Error("Not implemented: dispatchDOMEvent");
  3594. }
  3595. var EventBus = /*#__PURE__*/function () {
  3596. function EventBus(options) {
  3597. _classCallCheck(this, EventBus);
  3598. this._listeners = Object.create(null);
  3599. }
  3600. _createClass(EventBus, [{
  3601. key: "on",
  3602. value: function on(eventName, listener) {
  3603. this._on(eventName, listener, {
  3604. external: true
  3605. });
  3606. }
  3607. }, {
  3608. key: "off",
  3609. value: function off(eventName, listener) {
  3610. this._off(eventName, listener, {
  3611. external: true
  3612. });
  3613. }
  3614. }, {
  3615. key: "dispatch",
  3616. value: function dispatch(eventName) {
  3617. var eventListeners = this._listeners[eventName];
  3618. if (!eventListeners || eventListeners.length === 0) {
  3619. return;
  3620. }
  3621. var args = Array.prototype.slice.call(arguments, 1);
  3622. var externalListeners;
  3623. eventListeners.slice(0).forEach(function (_ref3) {
  3624. var listener = _ref3.listener,
  3625. external = _ref3.external;
  3626. if (external) {
  3627. if (!externalListeners) {
  3628. externalListeners = [];
  3629. }
  3630. externalListeners.push(listener);
  3631. return;
  3632. }
  3633. listener.apply(null, args);
  3634. });
  3635. if (externalListeners) {
  3636. externalListeners.forEach(function (listener) {
  3637. listener.apply(null, args);
  3638. });
  3639. externalListeners = null;
  3640. }
  3641. }
  3642. }, {
  3643. key: "_on",
  3644. value: function _on(eventName, listener) {
  3645. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3646. var eventListeners = this._listeners[eventName];
  3647. if (!eventListeners) {
  3648. this._listeners[eventName] = eventListeners = [];
  3649. }
  3650. eventListeners.push({
  3651. listener: listener,
  3652. external: (options && options.external) === true
  3653. });
  3654. }
  3655. }, {
  3656. key: "_off",
  3657. value: function _off(eventName, listener) {
  3658. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3659. var eventListeners = this._listeners[eventName];
  3660. if (!eventListeners) {
  3661. return;
  3662. }
  3663. for (var i = 0, ii = eventListeners.length; i < ii; i++) {
  3664. if (eventListeners[i].listener === listener) {
  3665. eventListeners.splice(i, 1);
  3666. return;
  3667. }
  3668. }
  3669. }
  3670. }]);
  3671. return EventBus;
  3672. }();
  3673. exports.EventBus = EventBus;
  3674. function clamp(v, min, max) {
  3675. return Math.min(Math.max(v, min), max);
  3676. }
  3677. var ProgressBar = /*#__PURE__*/function () {
  3678. function ProgressBar(id) {
  3679. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  3680. height = _ref4.height,
  3681. width = _ref4.width,
  3682. units = _ref4.units;
  3683. _classCallCheck(this, ProgressBar);
  3684. this.visible = true;
  3685. this.div = document.querySelector(id + " .progress");
  3686. this.bar = this.div.parentNode;
  3687. this.height = height || 100;
  3688. this.width = width || 100;
  3689. this.units = units || "%";
  3690. this.div.style.height = this.height + this.units;
  3691. this.percent = 0;
  3692. }
  3693. _createClass(ProgressBar, [{
  3694. key: "_updateBar",
  3695. value: function _updateBar() {
  3696. if (this._indeterminate) {
  3697. this.div.classList.add("indeterminate");
  3698. this.div.style.width = this.width + this.units;
  3699. return;
  3700. }
  3701. this.div.classList.remove("indeterminate");
  3702. var progressSize = this.width * this._percent / 100;
  3703. this.div.style.width = progressSize + this.units;
  3704. }
  3705. }, {
  3706. key: "setWidth",
  3707. value: function setWidth(viewer) {
  3708. if (!viewer) {
  3709. return;
  3710. }
  3711. var container = viewer.parentNode;
  3712. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  3713. if (scrollbarWidth > 0) {
  3714. this.bar.style.width = "calc(100% - ".concat(scrollbarWidth, "px)");
  3715. }
  3716. }
  3717. }, {
  3718. key: "hide",
  3719. value: function hide() {
  3720. if (!this.visible) {
  3721. return;
  3722. }
  3723. this.visible = false;
  3724. this.bar.classList.add("hidden");
  3725. document.body.classList.remove("loadingInProgress");
  3726. }
  3727. }, {
  3728. key: "show",
  3729. value: function show() {
  3730. if (this.visible) {
  3731. return;
  3732. }
  3733. this.visible = true;
  3734. document.body.classList.add("loadingInProgress");
  3735. this.bar.classList.remove("hidden");
  3736. }
  3737. }, {
  3738. key: "percent",
  3739. get: function get() {
  3740. return this._percent;
  3741. },
  3742. set: function set(val) {
  3743. this._indeterminate = isNaN(val);
  3744. this._percent = clamp(val, 0, 100);
  3745. this._updateBar();
  3746. }
  3747. }]);
  3748. return ProgressBar;
  3749. }();
  3750. exports.ProgressBar = ProgressBar;
  3751. function moveToEndOfArray(arr, condition) {
  3752. var moved = [],
  3753. len = arr.length;
  3754. var write = 0;
  3755. for (var read = 0; read < len; ++read) {
  3756. if (condition(arr[read])) {
  3757. moved.push(arr[read]);
  3758. } else {
  3759. arr[write] = arr[read];
  3760. ++write;
  3761. }
  3762. }
  3763. for (var _read = 0; write < len; ++_read, ++write) {
  3764. arr[write] = moved[_read];
  3765. }
  3766. }
  3767. /***/ }),
  3768. /* 6 */
  3769. /***/ (function(module, exports, __webpack_require__) {
  3770. "use strict";
  3771. Object.defineProperty(exports, "__esModule", {
  3772. value: true
  3773. });
  3774. exports.OptionKind = exports.AppOptions = void 0;
  3775. var _viewer_compatibility = __webpack_require__(7);
  3776. 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); }
  3777. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3778. 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); } }
  3779. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3780. var OptionKind = {
  3781. VIEWER: 0x02,
  3782. API: 0x04,
  3783. WORKER: 0x08,
  3784. PREFERENCE: 0x80
  3785. };
  3786. exports.OptionKind = OptionKind;
  3787. var defaultOptions = {
  3788. cursorToolOnLoad: {
  3789. value: 0,
  3790. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3791. },
  3792. defaultUrl: {
  3793. value: "compressed.tracemonkey-pldi-09.pdf",
  3794. kind: OptionKind.VIEWER
  3795. },
  3796. defaultZoomValue: {
  3797. value: "",
  3798. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3799. },
  3800. disableCreateObjectURL: {
  3801. value: false,
  3802. compatibility: _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL,
  3803. kind: OptionKind.VIEWER
  3804. },
  3805. disableHistory: {
  3806. value: false,
  3807. kind: OptionKind.VIEWER
  3808. },
  3809. disablePageLabels: {
  3810. value: false,
  3811. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3812. },
  3813. enablePermissions: {
  3814. value: false,
  3815. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3816. },
  3817. enablePrintAutoRotate: {
  3818. value: false,
  3819. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3820. },
  3821. enableWebGL: {
  3822. value: false,
  3823. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3824. },
  3825. externalLinkRel: {
  3826. value: "noopener noreferrer nofollow",
  3827. kind: OptionKind.VIEWER
  3828. },
  3829. externalLinkTarget: {
  3830. value: 0,
  3831. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3832. },
  3833. historyUpdateUrl: {
  3834. value: false,
  3835. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3836. },
  3837. ignoreDestinationZoom: {
  3838. value: false,
  3839. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3840. },
  3841. imageResourcesPath: {
  3842. value: "./images/",
  3843. kind: OptionKind.VIEWER
  3844. },
  3845. maxCanvasPixels: {
  3846. value: 16777216,
  3847. compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
  3848. kind: OptionKind.VIEWER
  3849. },
  3850. pdfBugEnabled: {
  3851. value: false,
  3852. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3853. },
  3854. printResolution: {
  3855. value: 150,
  3856. kind: OptionKind.VIEWER
  3857. },
  3858. renderer: {
  3859. value: "canvas",
  3860. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3861. },
  3862. renderInteractiveForms: {
  3863. value: false,
  3864. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3865. },
  3866. sidebarViewOnLoad: {
  3867. value: -1,
  3868. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3869. },
  3870. scrollModeOnLoad: {
  3871. value: -1,
  3872. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3873. },
  3874. spreadModeOnLoad: {
  3875. value: -1,
  3876. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3877. },
  3878. textLayerMode: {
  3879. value: 1,
  3880. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3881. },
  3882. useOnlyCssZoom: {
  3883. value: false,
  3884. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3885. },
  3886. viewOnLoad: {
  3887. value: 0,
  3888. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3889. },
  3890. cMapPacked: {
  3891. value: true,
  3892. kind: OptionKind.API
  3893. },
  3894. cMapUrl: {
  3895. value: "../web/cmaps/",
  3896. kind: OptionKind.API
  3897. },
  3898. disableAutoFetch: {
  3899. value: false,
  3900. kind: OptionKind.API + OptionKind.PREFERENCE
  3901. },
  3902. disableFontFace: {
  3903. value: false,
  3904. kind: OptionKind.API + OptionKind.PREFERENCE
  3905. },
  3906. disableRange: {
  3907. value: false,
  3908. kind: OptionKind.API + OptionKind.PREFERENCE
  3909. },
  3910. disableStream: {
  3911. value: false,
  3912. kind: OptionKind.API + OptionKind.PREFERENCE
  3913. },
  3914. docBaseUrl: {
  3915. value: "",
  3916. kind: OptionKind.API
  3917. },
  3918. fontExtraProperties: {
  3919. value: false,
  3920. kind: OptionKind.API
  3921. },
  3922. isEvalSupported: {
  3923. value: true,
  3924. kind: OptionKind.API
  3925. },
  3926. maxImageSize: {
  3927. value: -1,
  3928. kind: OptionKind.API
  3929. },
  3930. pdfBug: {
  3931. value: false,
  3932. kind: OptionKind.API
  3933. },
  3934. verbosity: {
  3935. value: 1,
  3936. kind: OptionKind.API
  3937. },
  3938. workerPort: {
  3939. value: null,
  3940. kind: OptionKind.WORKER
  3941. },
  3942. workerSrc: {
  3943. value: "../build/pdf.worker.js",
  3944. kind: OptionKind.WORKER
  3945. }
  3946. };
  3947. {
  3948. defaultOptions.disablePreferences = {
  3949. value: false,
  3950. kind: OptionKind.VIEWER
  3951. };
  3952. defaultOptions.locale = {
  3953. value: typeof navigator !== "undefined" ? navigator.language : "en-US",
  3954. kind: OptionKind.VIEWER
  3955. };
  3956. }
  3957. var userOptions = Object.create(null);
  3958. var AppOptions = /*#__PURE__*/function () {
  3959. function AppOptions() {
  3960. _classCallCheck(this, AppOptions);
  3961. throw new Error("Cannot initialize AppOptions.");
  3962. }
  3963. _createClass(AppOptions, null, [{
  3964. key: "get",
  3965. value: function get(name) {
  3966. var userOption = userOptions[name];
  3967. if (userOption !== undefined) {
  3968. return userOption;
  3969. }
  3970. var defaultOption = defaultOptions[name];
  3971. if (defaultOption !== undefined) {
  3972. return defaultOption.compatibility || defaultOption.value;
  3973. }
  3974. return undefined;
  3975. }
  3976. }, {
  3977. key: "getAll",
  3978. value: function getAll() {
  3979. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  3980. var options = Object.create(null);
  3981. for (var name in defaultOptions) {
  3982. var defaultOption = defaultOptions[name];
  3983. if (kind) {
  3984. if ((kind & defaultOption.kind) === 0) {
  3985. continue;
  3986. }
  3987. if (kind === OptionKind.PREFERENCE) {
  3988. var value = defaultOption.value,
  3989. valueType = _typeof(value);
  3990. if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
  3991. options[name] = value;
  3992. continue;
  3993. }
  3994. throw new Error("Invalid type for preference: ".concat(name));
  3995. }
  3996. }
  3997. var userOption = userOptions[name];
  3998. options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
  3999. }
  4000. return options;
  4001. }
  4002. }, {
  4003. key: "set",
  4004. value: function set(name, value) {
  4005. userOptions[name] = value;
  4006. }
  4007. }, {
  4008. key: "remove",
  4009. value: function remove(name) {
  4010. delete userOptions[name];
  4011. }
  4012. }]);
  4013. return AppOptions;
  4014. }();
  4015. exports.AppOptions = AppOptions;
  4016. /***/ }),
  4017. /* 7 */
  4018. /***/ (function(module, exports, __webpack_require__) {
  4019. "use strict";
  4020. Object.defineProperty(exports, "__esModule", {
  4021. value: true
  4022. });
  4023. exports.viewerCompatibilityParams = void 0;
  4024. var compatibilityParams = Object.create(null);
  4025. {
  4026. var userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
  4027. var platform = typeof navigator !== "undefined" && navigator.platform || "";
  4028. var maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
  4029. var isAndroid = /Android/.test(userAgent);
  4030. var isIE = /Trident/.test(userAgent);
  4031. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  4032. var isIOSChrome = /CriOS/.test(userAgent);
  4033. (function checkOnBlobSupport() {
  4034. if (isIE || isIOSChrome) {
  4035. compatibilityParams.disableCreateObjectURL = true;
  4036. }
  4037. })();
  4038. (function checkCanvasSizeLimitation() {
  4039. if (isIOS || isAndroid) {
  4040. compatibilityParams.maxCanvasPixels = 5242880;
  4041. }
  4042. })();
  4043. }
  4044. var viewerCompatibilityParams = Object.freeze(compatibilityParams);
  4045. exports.viewerCompatibilityParams = viewerCompatibilityParams;
  4046. /***/ }),
  4047. /* 8 */
  4048. /***/ (function(module, exports, __webpack_require__) {
  4049. "use strict";
  4050. var pdfjsLib;
  4051. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  4052. pdfjsLib = window["pdfjs-dist/build/pdf"];
  4053. } else {
  4054. pdfjsLib = require("../build/pdf.js");
  4055. }
  4056. module.exports = pdfjsLib;
  4057. /***/ }),
  4058. /* 9 */
  4059. /***/ (function(module, exports, __webpack_require__) {
  4060. "use strict";
  4061. Object.defineProperty(exports, "__esModule", {
  4062. value: true
  4063. });
  4064. exports.PDFCursorTools = exports.CursorTool = void 0;
  4065. var _grab_to_pan = __webpack_require__(10);
  4066. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4067. 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); } }
  4068. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4069. var CursorTool = {
  4070. SELECT: 0,
  4071. HAND: 1,
  4072. ZOOM: 2
  4073. };
  4074. exports.CursorTool = CursorTool;
  4075. var PDFCursorTools = /*#__PURE__*/function () {
  4076. function PDFCursorTools(_ref) {
  4077. var _this = this;
  4078. var container = _ref.container,
  4079. eventBus = _ref.eventBus,
  4080. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  4081. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT : _ref$cursorToolOnLoad;
  4082. _classCallCheck(this, PDFCursorTools);
  4083. this.container = container;
  4084. this.eventBus = eventBus;
  4085. this.active = CursorTool.SELECT;
  4086. this.activeBeforePresentationMode = null;
  4087. this.handTool = new _grab_to_pan.GrabToPan({
  4088. element: this.container
  4089. });
  4090. this._addEventListeners();
  4091. Promise.resolve().then(function () {
  4092. _this.switchTool(cursorToolOnLoad);
  4093. });
  4094. }
  4095. _createClass(PDFCursorTools, [{
  4096. key: "switchTool",
  4097. value: function switchTool(tool) {
  4098. var _this2 = this;
  4099. if (this.activeBeforePresentationMode !== null) {
  4100. return;
  4101. }
  4102. if (tool === this.active) {
  4103. return;
  4104. }
  4105. var disableActiveTool = function disableActiveTool() {
  4106. switch (_this2.active) {
  4107. case CursorTool.SELECT:
  4108. break;
  4109. case CursorTool.HAND:
  4110. _this2.handTool.deactivate();
  4111. break;
  4112. case CursorTool.ZOOM:
  4113. }
  4114. };
  4115. switch (tool) {
  4116. case CursorTool.SELECT:
  4117. disableActiveTool();
  4118. break;
  4119. case CursorTool.HAND:
  4120. disableActiveTool();
  4121. this.handTool.activate();
  4122. break;
  4123. case CursorTool.ZOOM:
  4124. default:
  4125. console.error("switchTool: \"".concat(tool, "\" is an unsupported value."));
  4126. return;
  4127. }
  4128. this.active = tool;
  4129. this._dispatchEvent();
  4130. }
  4131. }, {
  4132. key: "_dispatchEvent",
  4133. value: function _dispatchEvent() {
  4134. this.eventBus.dispatch("cursortoolchanged", {
  4135. source: this,
  4136. tool: this.active
  4137. });
  4138. }
  4139. }, {
  4140. key: "_addEventListeners",
  4141. value: function _addEventListeners() {
  4142. var _this3 = this;
  4143. this.eventBus._on("switchcursortool", function (evt) {
  4144. _this3.switchTool(evt.tool);
  4145. });
  4146. this.eventBus._on("presentationmodechanged", function (evt) {
  4147. if (evt.switchInProgress) {
  4148. return;
  4149. }
  4150. var previouslyActive;
  4151. if (evt.active) {
  4152. previouslyActive = _this3.active;
  4153. _this3.switchTool(CursorTool.SELECT);
  4154. _this3.activeBeforePresentationMode = previouslyActive;
  4155. } else {
  4156. previouslyActive = _this3.activeBeforePresentationMode;
  4157. _this3.activeBeforePresentationMode = null;
  4158. _this3.switchTool(previouslyActive);
  4159. }
  4160. });
  4161. }
  4162. }, {
  4163. key: "activeTool",
  4164. get: function get() {
  4165. return this.active;
  4166. }
  4167. }]);
  4168. return PDFCursorTools;
  4169. }();
  4170. exports.PDFCursorTools = PDFCursorTools;
  4171. /***/ }),
  4172. /* 10 */
  4173. /***/ (function(module, exports, __webpack_require__) {
  4174. "use strict";
  4175. Object.defineProperty(exports, "__esModule", {
  4176. value: true
  4177. });
  4178. exports.GrabToPan = GrabToPan;
  4179. function GrabToPan(options) {
  4180. this.element = options.element;
  4181. this.document = options.element.ownerDocument;
  4182. if (typeof options.ignoreTarget === "function") {
  4183. this.ignoreTarget = options.ignoreTarget;
  4184. }
  4185. this.onActiveChanged = options.onActiveChanged;
  4186. this.activate = this.activate.bind(this);
  4187. this.deactivate = this.deactivate.bind(this);
  4188. this.toggle = this.toggle.bind(this);
  4189. this._onmousedown = this._onmousedown.bind(this);
  4190. this._onmousemove = this._onmousemove.bind(this);
  4191. this._endPan = this._endPan.bind(this);
  4192. var overlay = this.overlay = document.createElement("div");
  4193. overlay.className = "grab-to-pan-grabbing";
  4194. }
  4195. GrabToPan.prototype = {
  4196. CSS_CLASS_GRAB: "grab-to-pan-grab",
  4197. activate: function GrabToPan_activate() {
  4198. if (!this.active) {
  4199. this.active = true;
  4200. this.element.addEventListener("mousedown", this._onmousedown, true);
  4201. this.element.classList.add(this.CSS_CLASS_GRAB);
  4202. if (this.onActiveChanged) {
  4203. this.onActiveChanged(true);
  4204. }
  4205. }
  4206. },
  4207. deactivate: function GrabToPan_deactivate() {
  4208. if (this.active) {
  4209. this.active = false;
  4210. this.element.removeEventListener("mousedown", this._onmousedown, true);
  4211. this._endPan();
  4212. this.element.classList.remove(this.CSS_CLASS_GRAB);
  4213. if (this.onActiveChanged) {
  4214. this.onActiveChanged(false);
  4215. }
  4216. }
  4217. },
  4218. toggle: function GrabToPan_toggle() {
  4219. if (this.active) {
  4220. this.deactivate();
  4221. } else {
  4222. this.activate();
  4223. }
  4224. },
  4225. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  4226. return node[matchesSelector]("a[href], a[href] *, input, textarea, button, button *, select, option");
  4227. },
  4228. _onmousedown: function GrabToPan__onmousedown(event) {
  4229. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  4230. return;
  4231. }
  4232. if (event.originalTarget) {
  4233. try {
  4234. event.originalTarget.tagName;
  4235. } catch (e) {
  4236. return;
  4237. }
  4238. }
  4239. this.scrollLeftStart = this.element.scrollLeft;
  4240. this.scrollTopStart = this.element.scrollTop;
  4241. this.clientXStart = event.clientX;
  4242. this.clientYStart = event.clientY;
  4243. this.document.addEventListener("mousemove", this._onmousemove, true);
  4244. this.document.addEventListener("mouseup", this._endPan, true);
  4245. this.element.addEventListener("scroll", this._endPan, true);
  4246. event.preventDefault();
  4247. event.stopPropagation();
  4248. var focusedElement = document.activeElement;
  4249. if (focusedElement && !focusedElement.contains(event.target)) {
  4250. focusedElement.blur();
  4251. }
  4252. },
  4253. _onmousemove: function GrabToPan__onmousemove(event) {
  4254. this.element.removeEventListener("scroll", this._endPan, true);
  4255. if (isLeftMouseReleased(event)) {
  4256. this._endPan();
  4257. return;
  4258. }
  4259. var xDiff = event.clientX - this.clientXStart;
  4260. var yDiff = event.clientY - this.clientYStart;
  4261. var scrollTop = this.scrollTopStart - yDiff;
  4262. var scrollLeft = this.scrollLeftStart - xDiff;
  4263. if (this.element.scrollTo) {
  4264. this.element.scrollTo({
  4265. top: scrollTop,
  4266. left: scrollLeft,
  4267. behavior: "instant"
  4268. });
  4269. } else {
  4270. this.element.scrollTop = scrollTop;
  4271. this.element.scrollLeft = scrollLeft;
  4272. }
  4273. if (!this.overlay.parentNode) {
  4274. document.body.appendChild(this.overlay);
  4275. }
  4276. },
  4277. _endPan: function GrabToPan__endPan() {
  4278. this.element.removeEventListener("scroll", this._endPan, true);
  4279. this.document.removeEventListener("mousemove", this._onmousemove, true);
  4280. this.document.removeEventListener("mouseup", this._endPan, true);
  4281. this.overlay.remove();
  4282. }
  4283. };
  4284. var matchesSelector;
  4285. ["webkitM", "mozM", "msM", "oM", "m"].some(function (prefix) {
  4286. var name = prefix + "atches";
  4287. if (name in document.documentElement) {
  4288. matchesSelector = name;
  4289. }
  4290. name += "Selector";
  4291. if (name in document.documentElement) {
  4292. matchesSelector = name;
  4293. }
  4294. return matchesSelector;
  4295. });
  4296. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  4297. var chrome = window.chrome;
  4298. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  4299. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  4300. function isLeftMouseReleased(event) {
  4301. if ("buttons" in event && isNotIEorIsIE10plus) {
  4302. return !(event.buttons & 1);
  4303. }
  4304. if (isChrome15OrOpera15plus || isSafari6plus) {
  4305. return event.which === 0;
  4306. }
  4307. return false;
  4308. }
  4309. /***/ }),
  4310. /* 11 */
  4311. /***/ (function(module, exports, __webpack_require__) {
  4312. "use strict";
  4313. Object.defineProperty(exports, "__esModule", {
  4314. value: true
  4315. });
  4316. exports.PDFRenderingQueue = exports.RenderingStates = void 0;
  4317. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4318. 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); } }
  4319. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4320. var CLEANUP_TIMEOUT = 30000;
  4321. var RenderingStates = {
  4322. INITIAL: 0,
  4323. RUNNING: 1,
  4324. PAUSED: 2,
  4325. FINISHED: 3
  4326. };
  4327. exports.RenderingStates = RenderingStates;
  4328. var PDFRenderingQueue = /*#__PURE__*/function () {
  4329. function PDFRenderingQueue() {
  4330. _classCallCheck(this, PDFRenderingQueue);
  4331. this.pdfViewer = null;
  4332. this.pdfThumbnailViewer = null;
  4333. this.onIdle = null;
  4334. this.highestPriorityPage = null;
  4335. this.idleTimeout = null;
  4336. this.printing = false;
  4337. this.isThumbnailViewEnabled = false;
  4338. }
  4339. _createClass(PDFRenderingQueue, [{
  4340. key: "setViewer",
  4341. value: function setViewer(pdfViewer) {
  4342. this.pdfViewer = pdfViewer;
  4343. }
  4344. }, {
  4345. key: "setThumbnailViewer",
  4346. value: function setThumbnailViewer(pdfThumbnailViewer) {
  4347. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4348. }
  4349. }, {
  4350. key: "isHighestPriority",
  4351. value: function isHighestPriority(view) {
  4352. return this.highestPriorityPage === view.renderingId;
  4353. }
  4354. }, {
  4355. key: "renderHighestPriority",
  4356. value: function renderHighestPriority(currentlyVisiblePages) {
  4357. if (this.idleTimeout) {
  4358. clearTimeout(this.idleTimeout);
  4359. this.idleTimeout = null;
  4360. }
  4361. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  4362. return;
  4363. }
  4364. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  4365. if (this.pdfThumbnailViewer.forceRendering()) {
  4366. return;
  4367. }
  4368. }
  4369. if (this.printing) {
  4370. return;
  4371. }
  4372. if (this.onIdle) {
  4373. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  4374. }
  4375. }
  4376. }, {
  4377. key: "getHighestPriority",
  4378. value: function getHighestPriority(visible, views, scrolledDown) {
  4379. var visibleViews = visible.views;
  4380. var numVisible = visibleViews.length;
  4381. if (numVisible === 0) {
  4382. return null;
  4383. }
  4384. for (var i = 0; i < numVisible; ++i) {
  4385. var view = visibleViews[i].view;
  4386. if (!this.isViewFinished(view)) {
  4387. return view;
  4388. }
  4389. }
  4390. if (scrolledDown) {
  4391. var nextPageIndex = visible.last.id;
  4392. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  4393. return views[nextPageIndex];
  4394. }
  4395. } else {
  4396. var previousPageIndex = visible.first.id - 2;
  4397. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  4398. return views[previousPageIndex];
  4399. }
  4400. }
  4401. return null;
  4402. }
  4403. }, {
  4404. key: "isViewFinished",
  4405. value: function isViewFinished(view) {
  4406. return view.renderingState === RenderingStates.FINISHED;
  4407. }
  4408. }, {
  4409. key: "renderView",
  4410. value: function renderView(view) {
  4411. var _this = this;
  4412. switch (view.renderingState) {
  4413. case RenderingStates.FINISHED:
  4414. return false;
  4415. case RenderingStates.PAUSED:
  4416. this.highestPriorityPage = view.renderingId;
  4417. view.resume();
  4418. break;
  4419. case RenderingStates.RUNNING:
  4420. this.highestPriorityPage = view.renderingId;
  4421. break;
  4422. case RenderingStates.INITIAL:
  4423. this.highestPriorityPage = view.renderingId;
  4424. view.draw()["finally"](function () {
  4425. _this.renderHighestPriority();
  4426. })["catch"](function (reason) {
  4427. console.error("renderView: \"".concat(reason, "\""));
  4428. });
  4429. break;
  4430. }
  4431. return true;
  4432. }
  4433. }]);
  4434. return PDFRenderingQueue;
  4435. }();
  4436. exports.PDFRenderingQueue = PDFRenderingQueue;
  4437. /***/ }),
  4438. /* 12 */
  4439. /***/ (function(module, exports, __webpack_require__) {
  4440. "use strict";
  4441. Object.defineProperty(exports, "__esModule", {
  4442. value: true
  4443. });
  4444. exports.PDFSidebar = exports.SidebarView = void 0;
  4445. var _ui_utils = __webpack_require__(5);
  4446. var _pdf_rendering_queue = __webpack_require__(11);
  4447. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4448. 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); } }
  4449. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4450. var UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  4451. var SidebarView = {
  4452. UNKNOWN: -1,
  4453. NONE: 0,
  4454. THUMBS: 1,
  4455. OUTLINE: 2,
  4456. ATTACHMENTS: 3,
  4457. LAYERS: 4
  4458. };
  4459. exports.SidebarView = SidebarView;
  4460. var PDFSidebar = /*#__PURE__*/function () {
  4461. function PDFSidebar(_ref) {
  4462. var elements = _ref.elements,
  4463. pdfViewer = _ref.pdfViewer,
  4464. pdfThumbnailViewer = _ref.pdfThumbnailViewer,
  4465. eventBus = _ref.eventBus,
  4466. _ref$l10n = _ref.l10n,
  4467. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n,
  4468. _ref$disableNotificat = _ref.disableNotification,
  4469. disableNotification = _ref$disableNotificat === void 0 ? false : _ref$disableNotificat;
  4470. _classCallCheck(this, PDFSidebar);
  4471. this.isOpen = false;
  4472. this.active = SidebarView.THUMBS;
  4473. this.isInitialViewSet = false;
  4474. this.onToggled = null;
  4475. this.pdfViewer = pdfViewer;
  4476. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4477. this.outerContainer = elements.outerContainer;
  4478. this.viewerContainer = elements.viewerContainer;
  4479. this.toggleButton = elements.toggleButton;
  4480. this.thumbnailButton = elements.thumbnailButton;
  4481. this.outlineButton = elements.outlineButton;
  4482. this.attachmentsButton = elements.attachmentsButton;
  4483. this.thumbnailView = elements.thumbnailView;
  4484. this.outlineView = elements.outlineView;
  4485. this.attachmentsView = elements.attachmentsView;
  4486. this.eventBus = eventBus;
  4487. this.l10n = l10n;
  4488. this._disableNotification = disableNotification;
  4489. this._addEventListeners();
  4490. }
  4491. _createClass(PDFSidebar, [{
  4492. key: "reset",
  4493. value: function reset() {
  4494. this.isInitialViewSet = false;
  4495. this._hideUINotification(null);
  4496. this.switchView(SidebarView.THUMBS);
  4497. this.outlineButton.disabled = false;
  4498. this.attachmentsButton.disabled = false;
  4499. }
  4500. }, {
  4501. key: "setInitialView",
  4502. value: function setInitialView() {
  4503. var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE;
  4504. if (this.isInitialViewSet) {
  4505. return;
  4506. }
  4507. this.isInitialViewSet = true;
  4508. if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
  4509. this._dispatchEvent();
  4510. return;
  4511. }
  4512. if (!this._switchView(view, true)) {
  4513. this._dispatchEvent();
  4514. }
  4515. }
  4516. }, {
  4517. key: "switchView",
  4518. value: function switchView(view) {
  4519. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4520. this._switchView(view, forceOpen);
  4521. }
  4522. }, {
  4523. key: "_switchView",
  4524. value: function _switchView(view) {
  4525. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4526. var isViewChanged = view !== this.active;
  4527. var shouldForceRendering = false;
  4528. switch (view) {
  4529. case SidebarView.NONE:
  4530. if (this.isOpen) {
  4531. this.close();
  4532. return true;
  4533. }
  4534. return false;
  4535. case SidebarView.THUMBS:
  4536. if (this.isOpen && isViewChanged) {
  4537. shouldForceRendering = true;
  4538. }
  4539. break;
  4540. case SidebarView.OUTLINE:
  4541. if (this.outlineButton.disabled) {
  4542. return false;
  4543. }
  4544. break;
  4545. case SidebarView.ATTACHMENTS:
  4546. if (this.attachmentsButton.disabled) {
  4547. return false;
  4548. }
  4549. break;
  4550. default:
  4551. console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
  4552. return false;
  4553. }
  4554. this.active = view;
  4555. this.thumbnailButton.classList.toggle("toggled", view === SidebarView.THUMBS);
  4556. this.outlineButton.classList.toggle("toggled", view === SidebarView.OUTLINE);
  4557. this.attachmentsButton.classList.toggle("toggled", view === SidebarView.ATTACHMENTS);
  4558. this.thumbnailView.classList.toggle("hidden", view !== SidebarView.THUMBS);
  4559. this.outlineView.classList.toggle("hidden", view !== SidebarView.OUTLINE);
  4560. this.attachmentsView.classList.toggle("hidden", view !== SidebarView.ATTACHMENTS);
  4561. if (forceOpen && !this.isOpen) {
  4562. this.open();
  4563. return true;
  4564. }
  4565. if (shouldForceRendering) {
  4566. this._updateThumbnailViewer();
  4567. this._forceRendering();
  4568. }
  4569. if (isViewChanged) {
  4570. this._dispatchEvent();
  4571. }
  4572. this._hideUINotification(this.active);
  4573. return isViewChanged;
  4574. }
  4575. }, {
  4576. key: "open",
  4577. value: function open() {
  4578. if (this.isOpen) {
  4579. return;
  4580. }
  4581. this.isOpen = true;
  4582. this.toggleButton.classList.add("toggled");
  4583. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  4584. if (this.active === SidebarView.THUMBS) {
  4585. this._updateThumbnailViewer();
  4586. }
  4587. this._forceRendering();
  4588. this._dispatchEvent();
  4589. this._hideUINotification(this.active);
  4590. }
  4591. }, {
  4592. key: "close",
  4593. value: function close() {
  4594. if (!this.isOpen) {
  4595. return;
  4596. }
  4597. this.isOpen = false;
  4598. this.toggleButton.classList.remove("toggled");
  4599. this.outerContainer.classList.add("sidebarMoving");
  4600. this.outerContainer.classList.remove("sidebarOpen");
  4601. this._forceRendering();
  4602. this._dispatchEvent();
  4603. }
  4604. }, {
  4605. key: "toggle",
  4606. value: function toggle() {
  4607. if (this.isOpen) {
  4608. this.close();
  4609. } else {
  4610. this.open();
  4611. }
  4612. }
  4613. }, {
  4614. key: "_dispatchEvent",
  4615. value: function _dispatchEvent() {
  4616. this.eventBus.dispatch("sidebarviewchanged", {
  4617. source: this,
  4618. view: this.visibleView
  4619. });
  4620. }
  4621. }, {
  4622. key: "_forceRendering",
  4623. value: function _forceRendering() {
  4624. if (this.onToggled) {
  4625. this.onToggled();
  4626. } else {
  4627. this.pdfViewer.forceRendering();
  4628. this.pdfThumbnailViewer.forceRendering();
  4629. }
  4630. }
  4631. }, {
  4632. key: "_updateThumbnailViewer",
  4633. value: function _updateThumbnailViewer() {
  4634. var pdfViewer = this.pdfViewer,
  4635. pdfThumbnailViewer = this.pdfThumbnailViewer;
  4636. var pagesCount = pdfViewer.pagesCount;
  4637. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  4638. var pageView = pdfViewer.getPageView(pageIndex);
  4639. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  4640. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  4641. thumbnailView.setImage(pageView);
  4642. }
  4643. }
  4644. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  4645. }
  4646. }, {
  4647. key: "_showUINotification",
  4648. value: function _showUINotification(view) {
  4649. var _this = this;
  4650. if (this._disableNotification) {
  4651. return;
  4652. }
  4653. this.l10n.get("toggle_sidebar_notification.title", null, "Toggle Sidebar (document contains outline/attachments)").then(function (msg) {
  4654. _this.toggleButton.title = msg;
  4655. });
  4656. if (!this.isOpen) {
  4657. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  4658. } else if (view === this.active) {
  4659. return;
  4660. }
  4661. switch (view) {
  4662. case SidebarView.OUTLINE:
  4663. this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
  4664. break;
  4665. case SidebarView.ATTACHMENTS:
  4666. this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
  4667. break;
  4668. }
  4669. }
  4670. }, {
  4671. key: "_hideUINotification",
  4672. value: function _hideUINotification(view) {
  4673. var _this2 = this;
  4674. if (this._disableNotification) {
  4675. return;
  4676. }
  4677. var removeNotification = function removeNotification(sidebarView) {
  4678. switch (sidebarView) {
  4679. case SidebarView.OUTLINE:
  4680. _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
  4681. break;
  4682. case SidebarView.ATTACHMENTS:
  4683. _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
  4684. break;
  4685. }
  4686. };
  4687. if (!this.isOpen && view !== null) {
  4688. return;
  4689. }
  4690. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  4691. if (view !== null) {
  4692. removeNotification(view);
  4693. return;
  4694. }
  4695. for (view in SidebarView) {
  4696. removeNotification(SidebarView[view]);
  4697. }
  4698. this.l10n.get("toggle_sidebar.title", null, "Toggle Sidebar").then(function (msg) {
  4699. _this2.toggleButton.title = msg;
  4700. });
  4701. }
  4702. }, {
  4703. key: "_addEventListeners",
  4704. value: function _addEventListeners() {
  4705. var _this3 = this;
  4706. this.viewerContainer.addEventListener("transitionend", function (evt) {
  4707. if (evt.target === _this3.viewerContainer) {
  4708. _this3.outerContainer.classList.remove("sidebarMoving");
  4709. }
  4710. });
  4711. this.toggleButton.addEventListener("click", function () {
  4712. _this3.toggle();
  4713. });
  4714. this.thumbnailButton.addEventListener("click", function () {
  4715. _this3.switchView(SidebarView.THUMBS);
  4716. });
  4717. this.outlineButton.addEventListener("click", function () {
  4718. _this3.switchView(SidebarView.OUTLINE);
  4719. });
  4720. this.outlineButton.addEventListener("dblclick", function () {
  4721. _this3.eventBus.dispatch("toggleoutlinetree", {
  4722. source: _this3
  4723. });
  4724. });
  4725. this.attachmentsButton.addEventListener("click", function () {
  4726. _this3.switchView(SidebarView.ATTACHMENTS);
  4727. });
  4728. this.eventBus._on("outlineloaded", function (evt) {
  4729. var outlineCount = evt.outlineCount;
  4730. _this3.outlineButton.disabled = !outlineCount;
  4731. if (outlineCount) {
  4732. _this3._showUINotification(SidebarView.OUTLINE);
  4733. } else if (_this3.active === SidebarView.OUTLINE) {
  4734. _this3.switchView(SidebarView.THUMBS);
  4735. }
  4736. });
  4737. this.eventBus._on("attachmentsloaded", function (evt) {
  4738. if (evt.attachmentsCount) {
  4739. _this3.attachmentsButton.disabled = false;
  4740. _this3._showUINotification(SidebarView.ATTACHMENTS);
  4741. return;
  4742. }
  4743. Promise.resolve().then(function () {
  4744. if (_this3.attachmentsView.hasChildNodes()) {
  4745. return;
  4746. }
  4747. _this3.attachmentsButton.disabled = true;
  4748. if (_this3.active === SidebarView.ATTACHMENTS) {
  4749. _this3.switchView(SidebarView.THUMBS);
  4750. }
  4751. });
  4752. });
  4753. this.eventBus._on("presentationmodechanged", function (evt) {
  4754. if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
  4755. _this3._updateThumbnailViewer();
  4756. }
  4757. });
  4758. }
  4759. }, {
  4760. key: "visibleView",
  4761. get: function get() {
  4762. return this.isOpen ? this.active : SidebarView.NONE;
  4763. }
  4764. }, {
  4765. key: "isThumbnailViewVisible",
  4766. get: function get() {
  4767. return this.isOpen && this.active === SidebarView.THUMBS;
  4768. }
  4769. }, {
  4770. key: "isOutlineViewVisible",
  4771. get: function get() {
  4772. return this.isOpen && this.active === SidebarView.OUTLINE;
  4773. }
  4774. }, {
  4775. key: "isAttachmentsViewVisible",
  4776. get: function get() {
  4777. return this.isOpen && this.active === SidebarView.ATTACHMENTS;
  4778. }
  4779. }]);
  4780. return PDFSidebar;
  4781. }();
  4782. exports.PDFSidebar = PDFSidebar;
  4783. /***/ }),
  4784. /* 13 */
  4785. /***/ (function(module, exports, __webpack_require__) {
  4786. "use strict";
  4787. Object.defineProperty(exports, "__esModule", {
  4788. value: true
  4789. });
  4790. exports.OverlayManager = void 0;
  4791. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  4792. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4793. 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); } }
  4794. 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); }); }; }
  4795. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4796. 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); } }
  4797. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4798. var OverlayManager = /*#__PURE__*/function () {
  4799. function OverlayManager() {
  4800. _classCallCheck(this, OverlayManager);
  4801. this._overlays = {};
  4802. this._active = null;
  4803. this._keyDownBound = this._keyDown.bind(this);
  4804. }
  4805. _createClass(OverlayManager, [{
  4806. key: "register",
  4807. value: function () {
  4808. var _register = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, element) {
  4809. var callerCloseMethod,
  4810. canForceClose,
  4811. container,
  4812. _args = arguments;
  4813. return _regenerator["default"].wrap(function _callee$(_context) {
  4814. while (1) {
  4815. switch (_context.prev = _context.next) {
  4816. case 0:
  4817. callerCloseMethod = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
  4818. canForceClose = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
  4819. if (!(!name || !element || !(container = element.parentNode))) {
  4820. _context.next = 6;
  4821. break;
  4822. }
  4823. throw new Error("Not enough parameters.");
  4824. case 6:
  4825. if (!this._overlays[name]) {
  4826. _context.next = 8;
  4827. break;
  4828. }
  4829. throw new Error("The overlay is already registered.");
  4830. case 8:
  4831. this._overlays[name] = {
  4832. element: element,
  4833. container: container,
  4834. callerCloseMethod: callerCloseMethod,
  4835. canForceClose: canForceClose
  4836. };
  4837. case 9:
  4838. case "end":
  4839. return _context.stop();
  4840. }
  4841. }
  4842. }, _callee, this);
  4843. }));
  4844. function register(_x, _x2) {
  4845. return _register.apply(this, arguments);
  4846. }
  4847. return register;
  4848. }()
  4849. }, {
  4850. key: "unregister",
  4851. value: function () {
  4852. var _unregister = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(name) {
  4853. return _regenerator["default"].wrap(function _callee2$(_context2) {
  4854. while (1) {
  4855. switch (_context2.prev = _context2.next) {
  4856. case 0:
  4857. if (this._overlays[name]) {
  4858. _context2.next = 4;
  4859. break;
  4860. }
  4861. throw new Error("The overlay does not exist.");
  4862. case 4:
  4863. if (!(this._active === name)) {
  4864. _context2.next = 6;
  4865. break;
  4866. }
  4867. throw new Error("The overlay cannot be removed while it is active.");
  4868. case 6:
  4869. delete this._overlays[name];
  4870. case 7:
  4871. case "end":
  4872. return _context2.stop();
  4873. }
  4874. }
  4875. }, _callee2, this);
  4876. }));
  4877. function unregister(_x3) {
  4878. return _unregister.apply(this, arguments);
  4879. }
  4880. return unregister;
  4881. }()
  4882. }, {
  4883. key: "open",
  4884. value: function () {
  4885. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name) {
  4886. return _regenerator["default"].wrap(function _callee3$(_context3) {
  4887. while (1) {
  4888. switch (_context3.prev = _context3.next) {
  4889. case 0:
  4890. if (this._overlays[name]) {
  4891. _context3.next = 4;
  4892. break;
  4893. }
  4894. throw new Error("The overlay does not exist.");
  4895. case 4:
  4896. if (!this._active) {
  4897. _context3.next = 14;
  4898. break;
  4899. }
  4900. if (!this._overlays[name].canForceClose) {
  4901. _context3.next = 9;
  4902. break;
  4903. }
  4904. this._closeThroughCaller();
  4905. _context3.next = 14;
  4906. break;
  4907. case 9:
  4908. if (!(this._active === name)) {
  4909. _context3.next = 13;
  4910. break;
  4911. }
  4912. throw new Error("The overlay is already active.");
  4913. case 13:
  4914. throw new Error("Another overlay is currently active.");
  4915. case 14:
  4916. this._active = name;
  4917. this._overlays[this._active].element.classList.remove("hidden");
  4918. this._overlays[this._active].container.classList.remove("hidden");
  4919. window.addEventListener("keydown", this._keyDownBound);
  4920. case 18:
  4921. case "end":
  4922. return _context3.stop();
  4923. }
  4924. }
  4925. }, _callee3, this);
  4926. }));
  4927. function open(_x4) {
  4928. return _open.apply(this, arguments);
  4929. }
  4930. return open;
  4931. }()
  4932. }, {
  4933. key: "close",
  4934. value: function () {
  4935. var _close = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name) {
  4936. return _regenerator["default"].wrap(function _callee4$(_context4) {
  4937. while (1) {
  4938. switch (_context4.prev = _context4.next) {
  4939. case 0:
  4940. if (this._overlays[name]) {
  4941. _context4.next = 4;
  4942. break;
  4943. }
  4944. throw new Error("The overlay does not exist.");
  4945. case 4:
  4946. if (this._active) {
  4947. _context4.next = 8;
  4948. break;
  4949. }
  4950. throw new Error("The overlay is currently not active.");
  4951. case 8:
  4952. if (!(this._active !== name)) {
  4953. _context4.next = 10;
  4954. break;
  4955. }
  4956. throw new Error("Another overlay is currently active.");
  4957. case 10:
  4958. this._overlays[this._active].container.classList.add("hidden");
  4959. this._overlays[this._active].element.classList.add("hidden");
  4960. this._active = null;
  4961. window.removeEventListener("keydown", this._keyDownBound);
  4962. case 14:
  4963. case "end":
  4964. return _context4.stop();
  4965. }
  4966. }
  4967. }, _callee4, this);
  4968. }));
  4969. function close(_x5) {
  4970. return _close.apply(this, arguments);
  4971. }
  4972. return close;
  4973. }()
  4974. }, {
  4975. key: "_keyDown",
  4976. value: function _keyDown(evt) {
  4977. if (this._active && evt.keyCode === 27) {
  4978. this._closeThroughCaller();
  4979. evt.preventDefault();
  4980. }
  4981. }
  4982. }, {
  4983. key: "_closeThroughCaller",
  4984. value: function _closeThroughCaller() {
  4985. if (this._overlays[this._active].callerCloseMethod) {
  4986. this._overlays[this._active].callerCloseMethod();
  4987. }
  4988. if (this._active) {
  4989. this.close(this._active);
  4990. }
  4991. }
  4992. }, {
  4993. key: "active",
  4994. get: function get() {
  4995. return this._active;
  4996. }
  4997. }]);
  4998. return OverlayManager;
  4999. }();
  5000. exports.OverlayManager = OverlayManager;
  5001. /***/ }),
  5002. /* 14 */
  5003. /***/ (function(module, exports, __webpack_require__) {
  5004. "use strict";
  5005. Object.defineProperty(exports, "__esModule", {
  5006. value: true
  5007. });
  5008. exports.PasswordPrompt = void 0;
  5009. var _ui_utils = __webpack_require__(5);
  5010. var _pdfjsLib = __webpack_require__(8);
  5011. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5012. 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); } }
  5013. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5014. var PasswordPrompt = /*#__PURE__*/function () {
  5015. function PasswordPrompt(options, overlayManager) {
  5016. var _this = this;
  5017. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5018. _classCallCheck(this, PasswordPrompt);
  5019. this.overlayName = options.overlayName;
  5020. this.container = options.container;
  5021. this.label = options.label;
  5022. this.input = options.input;
  5023. this.submitButton = options.submitButton;
  5024. this.cancelButton = options.cancelButton;
  5025. this.overlayManager = overlayManager;
  5026. this.l10n = l10n;
  5027. this.updateCallback = null;
  5028. this.reason = null;
  5029. this.submitButton.addEventListener("click", this.verify.bind(this));
  5030. this.cancelButton.addEventListener("click", this.close.bind(this));
  5031. this.input.addEventListener("keydown", function (e) {
  5032. if (e.keyCode === 13) {
  5033. _this.verify();
  5034. }
  5035. });
  5036. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  5037. }
  5038. _createClass(PasswordPrompt, [{
  5039. key: "open",
  5040. value: function open() {
  5041. var _this2 = this;
  5042. this.overlayManager.open(this.overlayName).then(function () {
  5043. _this2.input.focus();
  5044. var promptString;
  5045. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  5046. promptString = _this2.l10n.get("password_invalid", null, "Invalid password. Please try again.");
  5047. } else {
  5048. promptString = _this2.l10n.get("password_label", null, "Enter the password to open this PDF file.");
  5049. }
  5050. promptString.then(function (msg) {
  5051. _this2.label.textContent = msg;
  5052. });
  5053. });
  5054. }
  5055. }, {
  5056. key: "close",
  5057. value: function close() {
  5058. var _this3 = this;
  5059. this.overlayManager.close(this.overlayName).then(function () {
  5060. _this3.input.value = "";
  5061. });
  5062. }
  5063. }, {
  5064. key: "verify",
  5065. value: function verify() {
  5066. var password = this.input.value;
  5067. if (password && password.length > 0) {
  5068. this.close();
  5069. this.updateCallback(password);
  5070. }
  5071. }
  5072. }, {
  5073. key: "setUpdateCallback",
  5074. value: function setUpdateCallback(updateCallback, reason) {
  5075. this.updateCallback = updateCallback;
  5076. this.reason = reason;
  5077. }
  5078. }]);
  5079. return PasswordPrompt;
  5080. }();
  5081. exports.PasswordPrompt = PasswordPrompt;
  5082. /***/ }),
  5083. /* 15 */
  5084. /***/ (function(module, exports, __webpack_require__) {
  5085. "use strict";
  5086. Object.defineProperty(exports, "__esModule", {
  5087. value: true
  5088. });
  5089. exports.PDFAttachmentViewer = void 0;
  5090. var _pdfjsLib = __webpack_require__(8);
  5091. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5092. 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); } }
  5093. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5094. var PDFAttachmentViewer = /*#__PURE__*/function () {
  5095. function PDFAttachmentViewer(_ref) {
  5096. var container = _ref.container,
  5097. eventBus = _ref.eventBus,
  5098. downloadManager = _ref.downloadManager;
  5099. _classCallCheck(this, PDFAttachmentViewer);
  5100. this.container = container;
  5101. this.eventBus = eventBus;
  5102. this.downloadManager = downloadManager;
  5103. this.reset();
  5104. this.eventBus._on("fileattachmentannotation", this._appendAttachment.bind(this));
  5105. }
  5106. _createClass(PDFAttachmentViewer, [{
  5107. key: "reset",
  5108. value: function reset() {
  5109. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5110. this.attachments = null;
  5111. this.container.textContent = "";
  5112. if (!keepRenderedCapability) {
  5113. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  5114. }
  5115. }
  5116. }, {
  5117. key: "_dispatchEvent",
  5118. value: function _dispatchEvent(attachmentsCount) {
  5119. this._renderedCapability.resolve();
  5120. this.eventBus.dispatch("attachmentsloaded", {
  5121. source: this,
  5122. attachmentsCount: attachmentsCount
  5123. });
  5124. }
  5125. }, {
  5126. key: "_bindPdfLink",
  5127. value: function _bindPdfLink(button, content, filename) {
  5128. var _this = this;
  5129. var blobUrl;
  5130. button.onclick = function () {
  5131. if (!blobUrl) {
  5132. blobUrl = URL.createObjectURL(new Blob([content], {
  5133. type: "application/pdf"
  5134. }));
  5135. }
  5136. var viewerUrl;
  5137. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  5138. try {
  5139. window.open(viewerUrl);
  5140. } catch (ex) {
  5141. console.error("_bindPdfLink: ".concat(ex));
  5142. URL.revokeObjectURL(blobUrl);
  5143. blobUrl = null;
  5144. _this.downloadManager.downloadData(content, filename, "application/pdf");
  5145. }
  5146. return false;
  5147. };
  5148. }
  5149. }, {
  5150. key: "_bindLink",
  5151. value: function _bindLink(button, content, filename) {
  5152. var _this2 = this;
  5153. button.onclick = function () {
  5154. _this2.downloadManager.downloadData(content, filename, "");
  5155. return false;
  5156. };
  5157. }
  5158. }, {
  5159. key: "render",
  5160. value: function render(_ref2) {
  5161. var attachments = _ref2.attachments,
  5162. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  5163. keepRenderedCapability = _ref2$keepRenderedCap === void 0 ? false : _ref2$keepRenderedCap;
  5164. var attachmentsCount = 0;
  5165. if (this.attachments) {
  5166. this.reset(keepRenderedCapability === true);
  5167. }
  5168. this.attachments = attachments || null;
  5169. if (!attachments) {
  5170. this._dispatchEvent(attachmentsCount);
  5171. return;
  5172. }
  5173. var names = Object.keys(attachments).sort(function (a, b) {
  5174. return a.toLowerCase().localeCompare(b.toLowerCase());
  5175. });
  5176. attachmentsCount = names.length;
  5177. for (var i = 0; i < attachmentsCount; i++) {
  5178. var item = attachments[names[i]];
  5179. var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib.getFilenameFromUrl)(item.filename));
  5180. var div = document.createElement("div");
  5181. div.className = "attachmentsItem";
  5182. var button = document.createElement("button");
  5183. button.textContent = filename;
  5184. if (/\.pdf$/i.test(filename) && !this.downloadManager.disableCreateObjectURL) {
  5185. this._bindPdfLink(button, item.content, filename);
  5186. } else {
  5187. this._bindLink(button, item.content, filename);
  5188. }
  5189. div.appendChild(button);
  5190. this.container.appendChild(div);
  5191. }
  5192. this._dispatchEvent(attachmentsCount);
  5193. }
  5194. }, {
  5195. key: "_appendAttachment",
  5196. value: function _appendAttachment(_ref3) {
  5197. var _this3 = this;
  5198. var id = _ref3.id,
  5199. filename = _ref3.filename,
  5200. content = _ref3.content;
  5201. this._renderedCapability.promise.then(function () {
  5202. var attachments = _this3.attachments;
  5203. if (!attachments) {
  5204. attachments = Object.create(null);
  5205. } else {
  5206. for (var name in attachments) {
  5207. if (id === name) {
  5208. return;
  5209. }
  5210. }
  5211. }
  5212. attachments[id] = {
  5213. filename: filename,
  5214. content: content
  5215. };
  5216. _this3.render({
  5217. attachments: attachments,
  5218. keepRenderedCapability: true
  5219. });
  5220. });
  5221. }
  5222. }]);
  5223. return PDFAttachmentViewer;
  5224. }();
  5225. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  5226. /***/ }),
  5227. /* 16 */
  5228. /***/ (function(module, exports, __webpack_require__) {
  5229. "use strict";
  5230. Object.defineProperty(exports, "__esModule", {
  5231. value: true
  5232. });
  5233. exports.PDFDocumentProperties = void 0;
  5234. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  5235. var _pdfjsLib = __webpack_require__(8);
  5236. var _ui_utils = __webpack_require__(5);
  5237. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5238. 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); } }
  5239. 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); }); }; }
  5240. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  5241. 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."); }
  5242. 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); }
  5243. 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; }
  5244. 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; }
  5245. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  5246. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5247. 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); } }
  5248. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5249. var DEFAULT_FIELD_CONTENT = "-";
  5250. var NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  5251. var US_PAGE_NAMES = {
  5252. "8.5x11": "Letter",
  5253. "8.5x14": "Legal"
  5254. };
  5255. var METRIC_PAGE_NAMES = {
  5256. "297x420": "A3",
  5257. "210x297": "A4"
  5258. };
  5259. function getPageName(size, isPortrait, pageNames) {
  5260. var width = isPortrait ? size.width : size.height;
  5261. var height = isPortrait ? size.height : size.width;
  5262. return pageNames["".concat(width, "x").concat(height)];
  5263. }
  5264. var PDFDocumentProperties = /*#__PURE__*/function () {
  5265. function PDFDocumentProperties(_ref, overlayManager, eventBus) {
  5266. var _this = this;
  5267. var overlayName = _ref.overlayName,
  5268. fields = _ref.fields,
  5269. container = _ref.container,
  5270. closeButton = _ref.closeButton;
  5271. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  5272. _classCallCheck(this, PDFDocumentProperties);
  5273. this.overlayName = overlayName;
  5274. this.fields = fields;
  5275. this.container = container;
  5276. this.overlayManager = overlayManager;
  5277. this.l10n = l10n;
  5278. this._reset();
  5279. closeButton.addEventListener("click", this.close.bind(this));
  5280. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  5281. eventBus._on("pagechanging", function (evt) {
  5282. _this._currentPageNumber = evt.pageNumber;
  5283. });
  5284. eventBus._on("rotationchanging", function (evt) {
  5285. _this._pagesRotation = evt.pagesRotation;
  5286. });
  5287. this._isNonMetricLocale = true;
  5288. l10n.getLanguage().then(function (locale) {
  5289. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  5290. });
  5291. }
  5292. _createClass(PDFDocumentProperties, [{
  5293. key: "open",
  5294. value: function open() {
  5295. var _this2 = this;
  5296. var freezeFieldData = function freezeFieldData(data) {
  5297. Object.defineProperty(_this2, "fieldData", {
  5298. value: Object.freeze(data),
  5299. writable: false,
  5300. enumerable: true,
  5301. configurable: true
  5302. });
  5303. };
  5304. Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
  5305. var currentPageNumber = _this2._currentPageNumber;
  5306. var pagesRotation = _this2._pagesRotation;
  5307. if (_this2.fieldData && currentPageNumber === _this2.fieldData._currentPageNumber && pagesRotation === _this2.fieldData._pagesRotation) {
  5308. _this2._updateUI();
  5309. return;
  5310. }
  5311. _this2.pdfDocument.getMetadata().then(function (_ref2) {
  5312. var info = _ref2.info,
  5313. metadata = _ref2.metadata,
  5314. contentDispositionFilename = _ref2.contentDispositionFilename;
  5315. 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) {
  5316. return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  5317. }), _this2._parseLinearization(info.IsLinearized)]);
  5318. }).then(function (_ref3) {
  5319. var _ref4 = _slicedToArray(_ref3, 8),
  5320. info = _ref4[0],
  5321. metadata = _ref4[1],
  5322. fileName = _ref4[2],
  5323. fileSize = _ref4[3],
  5324. creationDate = _ref4[4],
  5325. modDate = _ref4[5],
  5326. pageSize = _ref4[6],
  5327. isLinearized = _ref4[7];
  5328. freezeFieldData({
  5329. fileName: fileName,
  5330. fileSize: fileSize,
  5331. title: info.Title,
  5332. author: info.Author,
  5333. subject: info.Subject,
  5334. keywords: info.Keywords,
  5335. creationDate: creationDate,
  5336. modificationDate: modDate,
  5337. creator: info.Creator,
  5338. producer: info.Producer,
  5339. version: info.PDFFormatVersion,
  5340. pageCount: _this2.pdfDocument.numPages,
  5341. pageSize: pageSize,
  5342. linearized: isLinearized,
  5343. _currentPageNumber: currentPageNumber,
  5344. _pagesRotation: pagesRotation
  5345. });
  5346. _this2._updateUI();
  5347. return _this2.pdfDocument.getDownloadInfo();
  5348. }).then(function (_ref5) {
  5349. var length = _ref5.length;
  5350. _this2.maybeFileSize = length;
  5351. return _this2._parseFileSize(length);
  5352. }).then(function (fileSize) {
  5353. if (fileSize === _this2.fieldData.fileSize) {
  5354. return;
  5355. }
  5356. var data = Object.assign(Object.create(null), _this2.fieldData);
  5357. data.fileSize = fileSize;
  5358. freezeFieldData(data);
  5359. _this2._updateUI();
  5360. });
  5361. });
  5362. }
  5363. }, {
  5364. key: "close",
  5365. value: function close() {
  5366. this.overlayManager.close(this.overlayName);
  5367. }
  5368. }, {
  5369. key: "setDocument",
  5370. value: function setDocument(pdfDocument) {
  5371. var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5372. if (this.pdfDocument) {
  5373. this._reset();
  5374. this._updateUI(true);
  5375. }
  5376. if (!pdfDocument) {
  5377. return;
  5378. }
  5379. this.pdfDocument = pdfDocument;
  5380. this.url = url;
  5381. this._dataAvailableCapability.resolve();
  5382. }
  5383. }, {
  5384. key: "setFileSize",
  5385. value: function setFileSize(fileSize) {
  5386. if (Number.isInteger(fileSize) && fileSize > 0) {
  5387. this.maybeFileSize = fileSize;
  5388. }
  5389. }
  5390. }, {
  5391. key: "_reset",
  5392. value: function _reset() {
  5393. this.pdfDocument = null;
  5394. this.url = null;
  5395. this.maybeFileSize = 0;
  5396. delete this.fieldData;
  5397. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5398. this._currentPageNumber = 1;
  5399. this._pagesRotation = 0;
  5400. }
  5401. }, {
  5402. key: "_updateUI",
  5403. value: function _updateUI() {
  5404. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5405. if (reset || !this.fieldData) {
  5406. for (var id in this.fields) {
  5407. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5408. }
  5409. return;
  5410. }
  5411. if (this.overlayManager.active !== this.overlayName) {
  5412. return;
  5413. }
  5414. for (var _id in this.fields) {
  5415. var content = this.fieldData[_id];
  5416. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5417. }
  5418. }
  5419. }, {
  5420. key: "_parseFileSize",
  5421. value: function () {
  5422. var _parseFileSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  5423. var fileSize,
  5424. kb,
  5425. _args = arguments;
  5426. return _regenerator["default"].wrap(function _callee$(_context) {
  5427. while (1) {
  5428. switch (_context.prev = _context.next) {
  5429. case 0:
  5430. fileSize = _args.length > 0 && _args[0] !== undefined ? _args[0] : 0;
  5431. kb = fileSize / 1024;
  5432. if (kb) {
  5433. _context.next = 6;
  5434. break;
  5435. }
  5436. return _context.abrupt("return", undefined);
  5437. case 6:
  5438. if (!(kb < 1024)) {
  5439. _context.next = 8;
  5440. break;
  5441. }
  5442. return _context.abrupt("return", this.l10n.get("document_properties_kb", {
  5443. size_kb: (+kb.toPrecision(3)).toLocaleString(),
  5444. size_b: fileSize.toLocaleString()
  5445. }, "{{size_kb}} KB ({{size_b}} bytes)"));
  5446. case 8:
  5447. return _context.abrupt("return", this.l10n.get("document_properties_mb", {
  5448. size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
  5449. size_b: fileSize.toLocaleString()
  5450. }, "{{size_mb}} MB ({{size_b}} bytes)"));
  5451. case 9:
  5452. case "end":
  5453. return _context.stop();
  5454. }
  5455. }
  5456. }, _callee, this);
  5457. }));
  5458. function _parseFileSize() {
  5459. return _parseFileSize2.apply(this, arguments);
  5460. }
  5461. return _parseFileSize;
  5462. }()
  5463. }, {
  5464. key: "_parsePageSize",
  5465. value: function () {
  5466. var _parsePageSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pageSizeInches, pagesRotation) {
  5467. var _this3 = this;
  5468. var isPortrait, sizeInches, sizeMillimeters, pageName, rawName, exactMillimeters, intMillimeters;
  5469. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5470. while (1) {
  5471. switch (_context2.prev = _context2.next) {
  5472. case 0:
  5473. if (pageSizeInches) {
  5474. _context2.next = 2;
  5475. break;
  5476. }
  5477. return _context2.abrupt("return", undefined);
  5478. case 2:
  5479. if (pagesRotation % 180 !== 0) {
  5480. pageSizeInches = {
  5481. width: pageSizeInches.height,
  5482. height: pageSizeInches.width
  5483. };
  5484. }
  5485. isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  5486. sizeInches = {
  5487. width: Math.round(pageSizeInches.width * 100) / 100,
  5488. height: Math.round(pageSizeInches.height * 100) / 100
  5489. };
  5490. sizeMillimeters = {
  5491. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  5492. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  5493. };
  5494. pageName = null;
  5495. rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5496. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  5497. exactMillimeters = {
  5498. width: pageSizeInches.width * 25.4,
  5499. height: pageSizeInches.height * 25.4
  5500. };
  5501. intMillimeters = {
  5502. width: Math.round(sizeMillimeters.width),
  5503. height: Math.round(sizeMillimeters.height)
  5504. };
  5505. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  5506. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5507. if (rawName) {
  5508. sizeInches = {
  5509. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  5510. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  5511. };
  5512. sizeMillimeters = intMillimeters;
  5513. }
  5514. }
  5515. }
  5516. if (rawName) {
  5517. pageName = this.l10n.get("document_properties_page_size_name_" + rawName.toLowerCase(), null, rawName);
  5518. }
  5519. 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) {
  5520. var _ref7 = _slicedToArray(_ref6, 4),
  5521. _ref7$ = _ref7[0],
  5522. width = _ref7$.width,
  5523. height = _ref7$.height,
  5524. unit = _ref7[1],
  5525. name = _ref7[2],
  5526. orientation = _ref7[3];
  5527. return _this3.l10n.get("document_properties_page_size_dimension_" + (name ? "name_" : "") + "string", {
  5528. width: width.toLocaleString(),
  5529. height: height.toLocaleString(),
  5530. unit: unit,
  5531. name: name,
  5532. orientation: orientation
  5533. }, "{{width}} × {{height}} {{unit}} (" + (name ? "{{name}}, " : "") + "{{orientation}})");
  5534. }));
  5535. case 11:
  5536. case "end":
  5537. return _context2.stop();
  5538. }
  5539. }
  5540. }, _callee2, this);
  5541. }));
  5542. function _parsePageSize(_x, _x2) {
  5543. return _parsePageSize2.apply(this, arguments);
  5544. }
  5545. return _parsePageSize;
  5546. }()
  5547. }, {
  5548. key: "_parseDate",
  5549. value: function () {
  5550. var _parseDate2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(inputDate) {
  5551. var dateObject;
  5552. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5553. while (1) {
  5554. switch (_context3.prev = _context3.next) {
  5555. case 0:
  5556. dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  5557. if (dateObject) {
  5558. _context3.next = 3;
  5559. break;
  5560. }
  5561. return _context3.abrupt("return", undefined);
  5562. case 3:
  5563. return _context3.abrupt("return", this.l10n.get("document_properties_date_string", {
  5564. date: dateObject.toLocaleDateString(),
  5565. time: dateObject.toLocaleTimeString()
  5566. }, "{{date}}, {{time}}"));
  5567. case 4:
  5568. case "end":
  5569. return _context3.stop();
  5570. }
  5571. }
  5572. }, _callee3, this);
  5573. }));
  5574. function _parseDate(_x3) {
  5575. return _parseDate2.apply(this, arguments);
  5576. }
  5577. return _parseDate;
  5578. }()
  5579. }, {
  5580. key: "_parseLinearization",
  5581. value: function _parseLinearization(isLinearized) {
  5582. return this.l10n.get("document_properties_linearized_" + (isLinearized ? "yes" : "no"), null, isLinearized ? "Yes" : "No");
  5583. }
  5584. }]);
  5585. return PDFDocumentProperties;
  5586. }();
  5587. exports.PDFDocumentProperties = PDFDocumentProperties;
  5588. /***/ }),
  5589. /* 17 */
  5590. /***/ (function(module, exports, __webpack_require__) {
  5591. "use strict";
  5592. Object.defineProperty(exports, "__esModule", {
  5593. value: true
  5594. });
  5595. exports.PDFFindBar = void 0;
  5596. var _pdf_find_controller = __webpack_require__(18);
  5597. var _ui_utils = __webpack_require__(5);
  5598. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5599. 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); } }
  5600. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5601. var MATCHES_COUNT_LIMIT = 1000;
  5602. var PDFFindBar = /*#__PURE__*/function () {
  5603. function PDFFindBar(options, eventBus) {
  5604. var _this = this;
  5605. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5606. _classCallCheck(this, PDFFindBar);
  5607. this.opened = false;
  5608. this.bar = options.bar || null;
  5609. this.toggleButton = options.toggleButton || null;
  5610. this.findField = options.findField || null;
  5611. this.highlightAll = options.highlightAllCheckbox || null;
  5612. this.caseSensitive = options.caseSensitiveCheckbox || null;
  5613. this.entireWord = options.entireWordCheckbox || null;
  5614. this.findMsg = options.findMsg || null;
  5615. this.findResultsCount = options.findResultsCount || null;
  5616. this.findPreviousButton = options.findPreviousButton || null;
  5617. this.findNextButton = options.findNextButton || null;
  5618. this.eventBus = eventBus;
  5619. this.l10n = l10n;
  5620. this.toggleButton.addEventListener("click", function () {
  5621. _this.toggle();
  5622. });
  5623. this.findField.addEventListener("input", function () {
  5624. _this.dispatchEvent("");
  5625. });
  5626. this.bar.addEventListener("keydown", function (e) {
  5627. switch (e.keyCode) {
  5628. case 13:
  5629. if (e.target === _this.findField) {
  5630. _this.dispatchEvent("again", e.shiftKey);
  5631. }
  5632. break;
  5633. case 27:
  5634. _this.close();
  5635. break;
  5636. }
  5637. });
  5638. this.findPreviousButton.addEventListener("click", function () {
  5639. _this.dispatchEvent("again", true);
  5640. });
  5641. this.findNextButton.addEventListener("click", function () {
  5642. _this.dispatchEvent("again", false);
  5643. });
  5644. this.highlightAll.addEventListener("click", function () {
  5645. _this.dispatchEvent("highlightallchange");
  5646. });
  5647. this.caseSensitive.addEventListener("click", function () {
  5648. _this.dispatchEvent("casesensitivitychange");
  5649. });
  5650. this.entireWord.addEventListener("click", function () {
  5651. _this.dispatchEvent("entirewordchange");
  5652. });
  5653. this.eventBus._on("resize", this._adjustWidth.bind(this));
  5654. }
  5655. _createClass(PDFFindBar, [{
  5656. key: "reset",
  5657. value: function reset() {
  5658. this.updateUIState();
  5659. }
  5660. }, {
  5661. key: "dispatchEvent",
  5662. value: function dispatchEvent(type, findPrev) {
  5663. this.eventBus.dispatch("find", {
  5664. source: this,
  5665. type: type,
  5666. query: this.findField.value,
  5667. phraseSearch: true,
  5668. caseSensitive: this.caseSensitive.checked,
  5669. entireWord: this.entireWord.checked,
  5670. highlightAll: this.highlightAll.checked,
  5671. findPrevious: findPrev
  5672. });
  5673. }
  5674. }, {
  5675. key: "updateUIState",
  5676. value: function updateUIState(state, previous, matchesCount) {
  5677. var _this2 = this;
  5678. var notFound = false;
  5679. var findMsg = "";
  5680. var status = "";
  5681. switch (state) {
  5682. case _pdf_find_controller.FindState.FOUND:
  5683. break;
  5684. case _pdf_find_controller.FindState.PENDING:
  5685. status = "pending";
  5686. break;
  5687. case _pdf_find_controller.FindState.NOT_FOUND:
  5688. findMsg = this.l10n.get("find_not_found", null, "Phrase not found");
  5689. notFound = true;
  5690. break;
  5691. case _pdf_find_controller.FindState.WRAPPED:
  5692. if (previous) {
  5693. findMsg = this.l10n.get("find_reached_top", null, "Reached top of document, continued from bottom");
  5694. } else {
  5695. findMsg = this.l10n.get("find_reached_bottom", null, "Reached end of document, continued from top");
  5696. }
  5697. break;
  5698. }
  5699. this.findField.classList.toggle("notFound", notFound);
  5700. this.findField.setAttribute("data-status", status);
  5701. Promise.resolve(findMsg).then(function (msg) {
  5702. _this2.findMsg.textContent = msg;
  5703. _this2._adjustWidth();
  5704. });
  5705. this.updateResultsCount(matchesCount);
  5706. }
  5707. }, {
  5708. key: "updateResultsCount",
  5709. value: function updateResultsCount() {
  5710. var _this3 = this;
  5711. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  5712. _ref$current = _ref.current,
  5713. current = _ref$current === void 0 ? 0 : _ref$current,
  5714. _ref$total = _ref.total,
  5715. total = _ref$total === void 0 ? 0 : _ref$total;
  5716. if (!this.findResultsCount) {
  5717. return;
  5718. }
  5719. var limit = MATCHES_COUNT_LIMIT;
  5720. var matchesCountMsg = "";
  5721. if (total > 0) {
  5722. if (total > limit) {
  5723. matchesCountMsg = this.l10n.get("find_match_count_limit", {
  5724. limit: limit
  5725. }, "More than {{limit}} match" + (limit !== 1 ? "es" : ""));
  5726. } else {
  5727. matchesCountMsg = this.l10n.get("find_match_count", {
  5728. current: current,
  5729. total: total
  5730. }, "{{current}} of {{total}} match" + (total !== 1 ? "es" : ""));
  5731. }
  5732. }
  5733. Promise.resolve(matchesCountMsg).then(function (msg) {
  5734. _this3.findResultsCount.textContent = msg;
  5735. _this3.findResultsCount.classList.toggle("hidden", !total);
  5736. _this3._adjustWidth();
  5737. });
  5738. }
  5739. }, {
  5740. key: "open",
  5741. value: function open() {
  5742. if (!this.opened) {
  5743. this.opened = true;
  5744. this.toggleButton.classList.add("toggled");
  5745. this.bar.classList.remove("hidden");
  5746. }
  5747. this.findField.select();
  5748. this.findField.focus();
  5749. this._adjustWidth();
  5750. }
  5751. }, {
  5752. key: "close",
  5753. value: function close() {
  5754. if (!this.opened) {
  5755. return;
  5756. }
  5757. this.opened = false;
  5758. this.toggleButton.classList.remove("toggled");
  5759. this.bar.classList.add("hidden");
  5760. this.eventBus.dispatch("findbarclose", {
  5761. source: this
  5762. });
  5763. }
  5764. }, {
  5765. key: "toggle",
  5766. value: function toggle() {
  5767. if (this.opened) {
  5768. this.close();
  5769. } else {
  5770. this.open();
  5771. }
  5772. }
  5773. }, {
  5774. key: "_adjustWidth",
  5775. value: function _adjustWidth() {
  5776. if (!this.opened) {
  5777. return;
  5778. }
  5779. this.bar.classList.remove("wrapContainers");
  5780. var findbarHeight = this.bar.clientHeight;
  5781. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  5782. if (findbarHeight > inputContainerHeight) {
  5783. this.bar.classList.add("wrapContainers");
  5784. }
  5785. }
  5786. }]);
  5787. return PDFFindBar;
  5788. }();
  5789. exports.PDFFindBar = PDFFindBar;
  5790. /***/ }),
  5791. /* 18 */
  5792. /***/ (function(module, exports, __webpack_require__) {
  5793. "use strict";
  5794. Object.defineProperty(exports, "__esModule", {
  5795. value: true
  5796. });
  5797. exports.PDFFindController = exports.FindState = void 0;
  5798. var _pdfjsLib = __webpack_require__(8);
  5799. var _pdf_find_utils = __webpack_require__(19);
  5800. var _ui_utils = __webpack_require__(5);
  5801. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5802. 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); } }
  5803. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5804. var FindState = {
  5805. FOUND: 0,
  5806. NOT_FOUND: 1,
  5807. WRAPPED: 2,
  5808. PENDING: 3
  5809. };
  5810. exports.FindState = FindState;
  5811. var FIND_TIMEOUT = 250;
  5812. var MATCH_SCROLL_OFFSET_TOP = -50;
  5813. var MATCH_SCROLL_OFFSET_LEFT = -400;
  5814. var CHARACTERS_TO_NORMALIZE = {
  5815. "\u2018": "'",
  5816. "\u2019": "'",
  5817. "\u201A": "'",
  5818. "\u201B": "'",
  5819. "\u201C": '"',
  5820. "\u201D": '"',
  5821. "\u201E": '"',
  5822. "\u201F": '"',
  5823. "\xBC": "1/4",
  5824. "\xBD": "1/2",
  5825. "\xBE": "3/4"
  5826. };
  5827. var normalizationRegex = null;
  5828. function normalize(text) {
  5829. if (!normalizationRegex) {
  5830. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  5831. normalizationRegex = new RegExp("[".concat(replace, "]"), "g");
  5832. }
  5833. return text.replace(normalizationRegex, function (ch) {
  5834. return CHARACTERS_TO_NORMALIZE[ch];
  5835. });
  5836. }
  5837. var PDFFindController = /*#__PURE__*/function () {
  5838. function PDFFindController(_ref) {
  5839. var linkService = _ref.linkService,
  5840. eventBus = _ref.eventBus;
  5841. _classCallCheck(this, PDFFindController);
  5842. this._linkService = linkService;
  5843. this._eventBus = eventBus;
  5844. this._reset();
  5845. eventBus._on("findbarclose", this._onFindBarClose.bind(this));
  5846. }
  5847. _createClass(PDFFindController, [{
  5848. key: "setDocument",
  5849. value: function setDocument(pdfDocument) {
  5850. if (this._pdfDocument) {
  5851. this._reset();
  5852. }
  5853. if (!pdfDocument) {
  5854. return;
  5855. }
  5856. this._pdfDocument = pdfDocument;
  5857. this._firstPageCapability.resolve();
  5858. }
  5859. }, {
  5860. key: "executeCommand",
  5861. value: function executeCommand(cmd, state) {
  5862. var _this = this;
  5863. if (!state) {
  5864. return;
  5865. }
  5866. var pdfDocument = this._pdfDocument;
  5867. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  5868. this._dirtyMatch = true;
  5869. }
  5870. this._state = state;
  5871. if (cmd !== "findhighlightallchange") {
  5872. this._updateUIState(FindState.PENDING);
  5873. }
  5874. this._firstPageCapability.promise.then(function () {
  5875. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  5876. return;
  5877. }
  5878. _this._extractText();
  5879. var findbarClosed = !_this._highlightMatches;
  5880. var pendingTimeout = !!_this._findTimeout;
  5881. if (_this._findTimeout) {
  5882. clearTimeout(_this._findTimeout);
  5883. _this._findTimeout = null;
  5884. }
  5885. if (cmd === "find") {
  5886. _this._findTimeout = setTimeout(function () {
  5887. _this._nextMatch();
  5888. _this._findTimeout = null;
  5889. }, FIND_TIMEOUT);
  5890. } else if (_this._dirtyMatch) {
  5891. _this._nextMatch();
  5892. } else if (cmd === "findagain") {
  5893. _this._nextMatch();
  5894. if (findbarClosed && _this._state.highlightAll) {
  5895. _this._updateAllPages();
  5896. }
  5897. } else if (cmd === "findhighlightallchange") {
  5898. if (pendingTimeout) {
  5899. _this._nextMatch();
  5900. } else {
  5901. _this._highlightMatches = true;
  5902. }
  5903. _this._updateAllPages();
  5904. } else {
  5905. _this._nextMatch();
  5906. }
  5907. });
  5908. }
  5909. }, {
  5910. key: "scrollMatchIntoView",
  5911. value: function scrollMatchIntoView(_ref2) {
  5912. var _ref2$element = _ref2.element,
  5913. element = _ref2$element === void 0 ? null : _ref2$element,
  5914. _ref2$pageIndex = _ref2.pageIndex,
  5915. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  5916. _ref2$matchIndex = _ref2.matchIndex,
  5917. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  5918. if (!this._scrollMatches || !element) {
  5919. return;
  5920. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  5921. return;
  5922. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  5923. return;
  5924. }
  5925. this._scrollMatches = false;
  5926. var spot = {
  5927. top: MATCH_SCROLL_OFFSET_TOP,
  5928. left: MATCH_SCROLL_OFFSET_LEFT
  5929. };
  5930. (0, _ui_utils.scrollIntoView)(element, spot, true);
  5931. }
  5932. }, {
  5933. key: "_reset",
  5934. value: function _reset() {
  5935. this._highlightMatches = false;
  5936. this._scrollMatches = false;
  5937. this._pdfDocument = null;
  5938. this._pageMatches = [];
  5939. this._pageMatchesLength = [];
  5940. this._state = null;
  5941. this._selected = {
  5942. pageIdx: -1,
  5943. matchIdx: -1
  5944. };
  5945. this._offset = {
  5946. pageIdx: null,
  5947. matchIdx: null,
  5948. wrapped: false
  5949. };
  5950. this._extractTextPromises = [];
  5951. this._pageContents = [];
  5952. this._matchesCountTotal = 0;
  5953. this._pagesToSearch = null;
  5954. this._pendingFindMatches = Object.create(null);
  5955. this._resumePageIdx = null;
  5956. this._dirtyMatch = false;
  5957. clearTimeout(this._findTimeout);
  5958. this._findTimeout = null;
  5959. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  5960. }
  5961. }, {
  5962. key: "_shouldDirtyMatch",
  5963. value: function _shouldDirtyMatch(cmd, state) {
  5964. if (state.query !== this._state.query) {
  5965. return true;
  5966. }
  5967. switch (cmd) {
  5968. case "findagain":
  5969. var pageNumber = this._selected.pageIdx + 1;
  5970. var linkService = this._linkService;
  5971. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  5972. return true;
  5973. }
  5974. return false;
  5975. case "findhighlightallchange":
  5976. return false;
  5977. }
  5978. return true;
  5979. }
  5980. }, {
  5981. key: "_prepareMatches",
  5982. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  5983. function isSubTerm(currentIndex) {
  5984. var currentElem = matchesWithLength[currentIndex];
  5985. var nextElem = matchesWithLength[currentIndex + 1];
  5986. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  5987. currentElem.skipped = true;
  5988. return true;
  5989. }
  5990. for (var i = currentIndex - 1; i >= 0; i--) {
  5991. var prevElem = matchesWithLength[i];
  5992. if (prevElem.skipped) {
  5993. continue;
  5994. }
  5995. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  5996. break;
  5997. }
  5998. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  5999. currentElem.skipped = true;
  6000. return true;
  6001. }
  6002. }
  6003. return false;
  6004. }
  6005. matchesWithLength.sort(function (a, b) {
  6006. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  6007. });
  6008. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  6009. if (isSubTerm(i)) {
  6010. continue;
  6011. }
  6012. matches.push(matchesWithLength[i].match);
  6013. matchesLength.push(matchesWithLength[i].matchLength);
  6014. }
  6015. }
  6016. }, {
  6017. key: "_isEntireWord",
  6018. value: function _isEntireWord(content, startIdx, length) {
  6019. if (startIdx > 0) {
  6020. var first = content.charCodeAt(startIdx);
  6021. var limit = content.charCodeAt(startIdx - 1);
  6022. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  6023. return false;
  6024. }
  6025. }
  6026. var endIdx = startIdx + length - 1;
  6027. if (endIdx < content.length - 1) {
  6028. var last = content.charCodeAt(endIdx);
  6029. var _limit = content.charCodeAt(endIdx + 1);
  6030. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  6031. return false;
  6032. }
  6033. }
  6034. return true;
  6035. }
  6036. }, {
  6037. key: "_calculatePhraseMatch",
  6038. value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
  6039. var matches = [];
  6040. var queryLen = query.length;
  6041. var matchIdx = -queryLen;
  6042. while (true) {
  6043. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  6044. if (matchIdx === -1) {
  6045. break;
  6046. }
  6047. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  6048. continue;
  6049. }
  6050. matches.push(matchIdx);
  6051. }
  6052. this._pageMatches[pageIndex] = matches;
  6053. }
  6054. }, {
  6055. key: "_calculateWordMatch",
  6056. value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  6057. var matchesWithLength = [];
  6058. var queryArray = query.match(/\S+/g);
  6059. for (var i = 0, len = queryArray.length; i < len; i++) {
  6060. var subquery = queryArray[i];
  6061. var subqueryLen = subquery.length;
  6062. var matchIdx = -subqueryLen;
  6063. while (true) {
  6064. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  6065. if (matchIdx === -1) {
  6066. break;
  6067. }
  6068. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  6069. continue;
  6070. }
  6071. matchesWithLength.push({
  6072. match: matchIdx,
  6073. matchLength: subqueryLen,
  6074. skipped: false
  6075. });
  6076. }
  6077. }
  6078. this._pageMatchesLength[pageIndex] = [];
  6079. this._pageMatches[pageIndex] = [];
  6080. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  6081. }
  6082. }, {
  6083. key: "_calculateMatch",
  6084. value: function _calculateMatch(pageIndex) {
  6085. var pageContent = this._pageContents[pageIndex];
  6086. var query = this._query;
  6087. var _this$_state = this._state,
  6088. caseSensitive = _this$_state.caseSensitive,
  6089. entireWord = _this$_state.entireWord,
  6090. phraseSearch = _this$_state.phraseSearch;
  6091. if (query.length === 0) {
  6092. return;
  6093. }
  6094. if (!caseSensitive) {
  6095. pageContent = pageContent.toLowerCase();
  6096. query = query.toLowerCase();
  6097. }
  6098. if (phraseSearch) {
  6099. this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
  6100. } else {
  6101. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  6102. }
  6103. if (this._state.highlightAll) {
  6104. this._updatePage(pageIndex);
  6105. }
  6106. if (this._resumePageIdx === pageIndex) {
  6107. this._resumePageIdx = null;
  6108. this._nextPageMatch();
  6109. }
  6110. var pageMatchesCount = this._pageMatches[pageIndex].length;
  6111. if (pageMatchesCount > 0) {
  6112. this._matchesCountTotal += pageMatchesCount;
  6113. this._updateUIResultsCount();
  6114. }
  6115. }
  6116. }, {
  6117. key: "_extractText",
  6118. value: function _extractText() {
  6119. var _this2 = this;
  6120. if (this._extractTextPromises.length > 0) {
  6121. return;
  6122. }
  6123. var promise = Promise.resolve();
  6124. var _loop = function _loop(i, ii) {
  6125. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  6126. _this2._extractTextPromises[i] = extractTextCapability.promise;
  6127. promise = promise.then(function () {
  6128. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  6129. return pdfPage.getTextContent({
  6130. normalizeWhitespace: true
  6131. });
  6132. }).then(function (textContent) {
  6133. var textItems = textContent.items;
  6134. var strBuf = [];
  6135. for (var j = 0, jj = textItems.length; j < jj; j++) {
  6136. strBuf.push(textItems[j].str);
  6137. }
  6138. _this2._pageContents[i] = normalize(strBuf.join(""));
  6139. extractTextCapability.resolve(i);
  6140. }, function (reason) {
  6141. console.error("Unable to get text content for page ".concat(i + 1), reason);
  6142. _this2._pageContents[i] = "";
  6143. extractTextCapability.resolve(i);
  6144. });
  6145. });
  6146. };
  6147. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  6148. _loop(i, ii);
  6149. }
  6150. }
  6151. }, {
  6152. key: "_updatePage",
  6153. value: function _updatePage(index) {
  6154. if (this._scrollMatches && this._selected.pageIdx === index) {
  6155. this._linkService.page = index + 1;
  6156. }
  6157. this._eventBus.dispatch("updatetextlayermatches", {
  6158. source: this,
  6159. pageIndex: index
  6160. });
  6161. }
  6162. }, {
  6163. key: "_updateAllPages",
  6164. value: function _updateAllPages() {
  6165. this._eventBus.dispatch("updatetextlayermatches", {
  6166. source: this,
  6167. pageIndex: -1
  6168. });
  6169. }
  6170. }, {
  6171. key: "_nextMatch",
  6172. value: function _nextMatch() {
  6173. var _this3 = this;
  6174. var previous = this._state.findPrevious;
  6175. var currentPageIndex = this._linkService.page - 1;
  6176. var numPages = this._linkService.pagesCount;
  6177. this._highlightMatches = true;
  6178. if (this._dirtyMatch) {
  6179. this._dirtyMatch = false;
  6180. this._selected.pageIdx = this._selected.matchIdx = -1;
  6181. this._offset.pageIdx = currentPageIndex;
  6182. this._offset.matchIdx = null;
  6183. this._offset.wrapped = false;
  6184. this._resumePageIdx = null;
  6185. this._pageMatches.length = 0;
  6186. this._pageMatchesLength.length = 0;
  6187. this._matchesCountTotal = 0;
  6188. this._updateAllPages();
  6189. for (var i = 0; i < numPages; i++) {
  6190. if (this._pendingFindMatches[i] === true) {
  6191. continue;
  6192. }
  6193. this._pendingFindMatches[i] = true;
  6194. this._extractTextPromises[i].then(function (pageIdx) {
  6195. delete _this3._pendingFindMatches[pageIdx];
  6196. _this3._calculateMatch(pageIdx);
  6197. });
  6198. }
  6199. }
  6200. if (this._query === "") {
  6201. this._updateUIState(FindState.FOUND);
  6202. return;
  6203. }
  6204. if (this._resumePageIdx) {
  6205. return;
  6206. }
  6207. var offset = this._offset;
  6208. this._pagesToSearch = numPages;
  6209. if (offset.matchIdx !== null) {
  6210. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  6211. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  6212. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  6213. this._updateMatch(true);
  6214. return;
  6215. }
  6216. this._advanceOffsetPage(previous);
  6217. }
  6218. this._nextPageMatch();
  6219. }
  6220. }, {
  6221. key: "_matchesReady",
  6222. value: function _matchesReady(matches) {
  6223. var offset = this._offset;
  6224. var numMatches = matches.length;
  6225. var previous = this._state.findPrevious;
  6226. if (numMatches) {
  6227. offset.matchIdx = previous ? numMatches - 1 : 0;
  6228. this._updateMatch(true);
  6229. return true;
  6230. }
  6231. this._advanceOffsetPage(previous);
  6232. if (offset.wrapped) {
  6233. offset.matchIdx = null;
  6234. if (this._pagesToSearch < 0) {
  6235. this._updateMatch(false);
  6236. return true;
  6237. }
  6238. }
  6239. return false;
  6240. }
  6241. }, {
  6242. key: "_nextPageMatch",
  6243. value: function _nextPageMatch() {
  6244. if (this._resumePageIdx !== null) {
  6245. console.error("There can only be one pending page.");
  6246. }
  6247. var matches = null;
  6248. do {
  6249. var pageIdx = this._offset.pageIdx;
  6250. matches = this._pageMatches[pageIdx];
  6251. if (!matches) {
  6252. this._resumePageIdx = pageIdx;
  6253. break;
  6254. }
  6255. } while (!this._matchesReady(matches));
  6256. }
  6257. }, {
  6258. key: "_advanceOffsetPage",
  6259. value: function _advanceOffsetPage(previous) {
  6260. var offset = this._offset;
  6261. var numPages = this._linkService.pagesCount;
  6262. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  6263. offset.matchIdx = null;
  6264. this._pagesToSearch--;
  6265. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  6266. offset.pageIdx = previous ? numPages - 1 : 0;
  6267. offset.wrapped = true;
  6268. }
  6269. }
  6270. }, {
  6271. key: "_updateMatch",
  6272. value: function _updateMatch() {
  6273. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6274. var state = FindState.NOT_FOUND;
  6275. var wrapped = this._offset.wrapped;
  6276. this._offset.wrapped = false;
  6277. if (found) {
  6278. var previousPage = this._selected.pageIdx;
  6279. this._selected.pageIdx = this._offset.pageIdx;
  6280. this._selected.matchIdx = this._offset.matchIdx;
  6281. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  6282. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  6283. this._updatePage(previousPage);
  6284. }
  6285. }
  6286. this._updateUIState(state, this._state.findPrevious);
  6287. if (this._selected.pageIdx !== -1) {
  6288. this._scrollMatches = true;
  6289. this._updatePage(this._selected.pageIdx);
  6290. }
  6291. }
  6292. }, {
  6293. key: "_onFindBarClose",
  6294. value: function _onFindBarClose(evt) {
  6295. var _this4 = this;
  6296. var pdfDocument = this._pdfDocument;
  6297. this._firstPageCapability.promise.then(function () {
  6298. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  6299. return;
  6300. }
  6301. if (_this4._findTimeout) {
  6302. clearTimeout(_this4._findTimeout);
  6303. _this4._findTimeout = null;
  6304. }
  6305. if (_this4._resumePageIdx) {
  6306. _this4._resumePageIdx = null;
  6307. _this4._dirtyMatch = true;
  6308. }
  6309. _this4._updateUIState(FindState.FOUND);
  6310. _this4._highlightMatches = false;
  6311. _this4._updateAllPages();
  6312. });
  6313. }
  6314. }, {
  6315. key: "_requestMatchesCount",
  6316. value: function _requestMatchesCount() {
  6317. var _this$_selected = this._selected,
  6318. pageIdx = _this$_selected.pageIdx,
  6319. matchIdx = _this$_selected.matchIdx;
  6320. var current = 0,
  6321. total = this._matchesCountTotal;
  6322. if (matchIdx !== -1) {
  6323. for (var i = 0; i < pageIdx; i++) {
  6324. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  6325. }
  6326. current += matchIdx + 1;
  6327. }
  6328. if (current < 1 || current > total) {
  6329. current = total = 0;
  6330. }
  6331. return {
  6332. current: current,
  6333. total: total
  6334. };
  6335. }
  6336. }, {
  6337. key: "_updateUIResultsCount",
  6338. value: function _updateUIResultsCount() {
  6339. this._eventBus.dispatch("updatefindmatchescount", {
  6340. source: this,
  6341. matchesCount: this._requestMatchesCount()
  6342. });
  6343. }
  6344. }, {
  6345. key: "_updateUIState",
  6346. value: function _updateUIState(state, previous) {
  6347. this._eventBus.dispatch("updatefindcontrolstate", {
  6348. source: this,
  6349. state: state,
  6350. previous: previous,
  6351. matchesCount: this._requestMatchesCount()
  6352. });
  6353. }
  6354. }, {
  6355. key: "highlightMatches",
  6356. get: function get() {
  6357. return this._highlightMatches;
  6358. }
  6359. }, {
  6360. key: "pageMatches",
  6361. get: function get() {
  6362. return this._pageMatches;
  6363. }
  6364. }, {
  6365. key: "pageMatchesLength",
  6366. get: function get() {
  6367. return this._pageMatchesLength;
  6368. }
  6369. }, {
  6370. key: "selected",
  6371. get: function get() {
  6372. return this._selected;
  6373. }
  6374. }, {
  6375. key: "state",
  6376. get: function get() {
  6377. return this._state;
  6378. }
  6379. }, {
  6380. key: "_query",
  6381. get: function get() {
  6382. if (this._state.query !== this._rawQuery) {
  6383. this._rawQuery = this._state.query;
  6384. this._normalizedQuery = normalize(this._state.query);
  6385. }
  6386. return this._normalizedQuery;
  6387. }
  6388. }]);
  6389. return PDFFindController;
  6390. }();
  6391. exports.PDFFindController = PDFFindController;
  6392. /***/ }),
  6393. /* 19 */
  6394. /***/ (function(module, exports, __webpack_require__) {
  6395. "use strict";
  6396. Object.defineProperty(exports, "__esModule", {
  6397. value: true
  6398. });
  6399. exports.getCharacterType = getCharacterType;
  6400. exports.CharacterType = void 0;
  6401. var CharacterType = {
  6402. SPACE: 0,
  6403. ALPHA_LETTER: 1,
  6404. PUNCT: 2,
  6405. HAN_LETTER: 3,
  6406. KATAKANA_LETTER: 4,
  6407. HIRAGANA_LETTER: 5,
  6408. HALFWIDTH_KATAKANA_LETTER: 6,
  6409. THAI_LETTER: 7
  6410. };
  6411. exports.CharacterType = CharacterType;
  6412. function isAlphabeticalScript(charCode) {
  6413. return charCode < 0x2e80;
  6414. }
  6415. function isAscii(charCode) {
  6416. return (charCode & 0xff80) === 0;
  6417. }
  6418. function isAsciiAlpha(charCode) {
  6419. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  6420. }
  6421. function isAsciiDigit(charCode) {
  6422. return charCode >= 0x30 && charCode <= 0x39;
  6423. }
  6424. function isAsciiSpace(charCode) {
  6425. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  6426. }
  6427. function isHan(charCode) {
  6428. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  6429. }
  6430. function isKatakana(charCode) {
  6431. return charCode >= 0x30a0 && charCode <= 0x30ff;
  6432. }
  6433. function isHiragana(charCode) {
  6434. return charCode >= 0x3040 && charCode <= 0x309f;
  6435. }
  6436. function isHalfwidthKatakana(charCode) {
  6437. return charCode >= 0xff60 && charCode <= 0xff9f;
  6438. }
  6439. function isThai(charCode) {
  6440. return (charCode & 0xff80) === 0x0e00;
  6441. }
  6442. function getCharacterType(charCode) {
  6443. if (isAlphabeticalScript(charCode)) {
  6444. if (isAscii(charCode)) {
  6445. if (isAsciiSpace(charCode)) {
  6446. return CharacterType.SPACE;
  6447. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  6448. return CharacterType.ALPHA_LETTER;
  6449. }
  6450. return CharacterType.PUNCT;
  6451. } else if (isThai(charCode)) {
  6452. return CharacterType.THAI_LETTER;
  6453. } else if (charCode === 0xa0) {
  6454. return CharacterType.SPACE;
  6455. }
  6456. return CharacterType.ALPHA_LETTER;
  6457. }
  6458. if (isHan(charCode)) {
  6459. return CharacterType.HAN_LETTER;
  6460. } else if (isKatakana(charCode)) {
  6461. return CharacterType.KATAKANA_LETTER;
  6462. } else if (isHiragana(charCode)) {
  6463. return CharacterType.HIRAGANA_LETTER;
  6464. } else if (isHalfwidthKatakana(charCode)) {
  6465. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  6466. }
  6467. return CharacterType.ALPHA_LETTER;
  6468. }
  6469. /***/ }),
  6470. /* 20 */
  6471. /***/ (function(module, exports, __webpack_require__) {
  6472. "use strict";
  6473. Object.defineProperty(exports, "__esModule", {
  6474. value: true
  6475. });
  6476. exports.isDestHashesEqual = isDestHashesEqual;
  6477. exports.isDestArraysEqual = isDestArraysEqual;
  6478. exports.PDFHistory = void 0;
  6479. var _ui_utils = __webpack_require__(5);
  6480. 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); }
  6481. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  6482. 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."); }
  6483. 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); }
  6484. 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; }
  6485. 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; }
  6486. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  6487. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6488. 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); } }
  6489. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6490. var HASH_CHANGE_TIMEOUT = 1000;
  6491. var POSITION_UPDATED_THRESHOLD = 50;
  6492. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  6493. function getCurrentHash() {
  6494. return document.location.hash;
  6495. }
  6496. var PDFHistory = /*#__PURE__*/function () {
  6497. function PDFHistory(_ref) {
  6498. var _this = this;
  6499. var linkService = _ref.linkService,
  6500. eventBus = _ref.eventBus;
  6501. _classCallCheck(this, PDFHistory);
  6502. this.linkService = linkService;
  6503. this.eventBus = eventBus;
  6504. this._initialized = false;
  6505. this._fingerprint = "";
  6506. this.reset();
  6507. this._boundEvents = null;
  6508. this._isViewerInPresentationMode = false;
  6509. this.eventBus._on("presentationmodechanged", function (evt) {
  6510. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  6511. });
  6512. this.eventBus._on("pagesinit", function () {
  6513. _this._isPagesLoaded = false;
  6514. var onPagesLoaded = function onPagesLoaded(evt) {
  6515. _this.eventBus._off("pagesloaded", onPagesLoaded);
  6516. _this._isPagesLoaded = !!evt.pagesCount;
  6517. };
  6518. _this.eventBus._on("pagesloaded", onPagesLoaded);
  6519. });
  6520. }
  6521. _createClass(PDFHistory, [{
  6522. key: "initialize",
  6523. value: function initialize(_ref2) {
  6524. var fingerprint = _ref2.fingerprint,
  6525. _ref2$resetHistory = _ref2.resetHistory,
  6526. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  6527. _ref2$updateUrl = _ref2.updateUrl,
  6528. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  6529. if (!fingerprint || typeof fingerprint !== "string") {
  6530. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  6531. return;
  6532. }
  6533. if (this._initialized) {
  6534. this.reset();
  6535. }
  6536. var reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  6537. this._fingerprint = fingerprint;
  6538. this._updateUrl = updateUrl === true;
  6539. this._initialized = true;
  6540. this._bindEvents();
  6541. var state = window.history.state;
  6542. this._popStateInProgress = false;
  6543. this._blockHashChange = 0;
  6544. this._currentHash = getCurrentHash();
  6545. this._numPositionUpdates = 0;
  6546. this._uid = this._maxUid = 0;
  6547. this._destination = null;
  6548. this._position = null;
  6549. if (!this._isValidState(state, true) || resetHistory) {
  6550. var _this$_parseCurrentHa = this._parseCurrentHash(true),
  6551. hash = _this$_parseCurrentHa.hash,
  6552. page = _this$_parseCurrentHa.page,
  6553. rotation = _this$_parseCurrentHa.rotation;
  6554. if (!hash || reInitialized || resetHistory) {
  6555. this._pushOrReplaceState(null, true);
  6556. return;
  6557. }
  6558. this._pushOrReplaceState({
  6559. hash: hash,
  6560. page: page,
  6561. rotation: rotation
  6562. }, true);
  6563. return;
  6564. }
  6565. var destination = state.destination;
  6566. this._updateInternalState(destination, state.uid, true);
  6567. if (this._uid > this._maxUid) {
  6568. this._maxUid = this._uid;
  6569. }
  6570. if (destination.rotation !== undefined) {
  6571. this._initialRotation = destination.rotation;
  6572. }
  6573. if (destination.dest) {
  6574. this._initialBookmark = JSON.stringify(destination.dest);
  6575. this._destination.page = null;
  6576. } else if (destination.hash) {
  6577. this._initialBookmark = destination.hash;
  6578. } else if (destination.page) {
  6579. this._initialBookmark = "page=".concat(destination.page);
  6580. }
  6581. }
  6582. }, {
  6583. key: "reset",
  6584. value: function reset() {
  6585. if (this._initialized) {
  6586. this._pageHide();
  6587. this._initialized = false;
  6588. this._unbindEvents();
  6589. }
  6590. if (this._updateViewareaTimeout) {
  6591. clearTimeout(this._updateViewareaTimeout);
  6592. this._updateViewareaTimeout = null;
  6593. }
  6594. this._initialBookmark = null;
  6595. this._initialRotation = null;
  6596. }
  6597. }, {
  6598. key: "push",
  6599. value: function push(_ref3) {
  6600. var _this2 = this;
  6601. var _ref3$namedDest = _ref3.namedDest,
  6602. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  6603. explicitDest = _ref3.explicitDest,
  6604. pageNumber = _ref3.pageNumber;
  6605. if (!this._initialized) {
  6606. return;
  6607. }
  6608. if (namedDest && typeof namedDest !== "string") {
  6609. console.error("PDFHistory.push: " + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  6610. return;
  6611. } else if (!Array.isArray(explicitDest)) {
  6612. console.error("PDFHistory.push: " + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  6613. return;
  6614. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  6615. if (pageNumber !== null || this._destination) {
  6616. console.error("PDFHistory.push: " + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  6617. return;
  6618. }
  6619. }
  6620. var hash = namedDest || JSON.stringify(explicitDest);
  6621. if (!hash) {
  6622. return;
  6623. }
  6624. var forceReplace = false;
  6625. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  6626. if (this._destination.page) {
  6627. return;
  6628. }
  6629. forceReplace = true;
  6630. }
  6631. if (this._popStateInProgress && !forceReplace) {
  6632. return;
  6633. }
  6634. this._pushOrReplaceState({
  6635. dest: explicitDest,
  6636. hash: hash,
  6637. page: pageNumber,
  6638. rotation: this.linkService.rotation
  6639. }, forceReplace);
  6640. if (!this._popStateInProgress) {
  6641. this._popStateInProgress = true;
  6642. Promise.resolve().then(function () {
  6643. _this2._popStateInProgress = false;
  6644. });
  6645. }
  6646. }
  6647. }, {
  6648. key: "pushCurrentPosition",
  6649. value: function pushCurrentPosition() {
  6650. if (!this._initialized || this._popStateInProgress) {
  6651. return;
  6652. }
  6653. this._tryPushCurrentPosition();
  6654. }
  6655. }, {
  6656. key: "back",
  6657. value: function back() {
  6658. if (!this._initialized || this._popStateInProgress) {
  6659. return;
  6660. }
  6661. var state = window.history.state;
  6662. if (this._isValidState(state) && state.uid > 0) {
  6663. window.history.back();
  6664. }
  6665. }
  6666. }, {
  6667. key: "forward",
  6668. value: function forward() {
  6669. if (!this._initialized || this._popStateInProgress) {
  6670. return;
  6671. }
  6672. var state = window.history.state;
  6673. if (this._isValidState(state) && state.uid < this._maxUid) {
  6674. window.history.forward();
  6675. }
  6676. }
  6677. }, {
  6678. key: "_pushOrReplaceState",
  6679. value: function _pushOrReplaceState(destination) {
  6680. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6681. var shouldReplace = forceReplace || !this._destination;
  6682. var newState = {
  6683. fingerprint: this._fingerprint,
  6684. uid: shouldReplace ? this._uid : this._uid + 1,
  6685. destination: destination
  6686. };
  6687. this._updateInternalState(destination, newState.uid);
  6688. var newUrl;
  6689. if (this._updateUrl && destination && destination.hash) {
  6690. var baseUrl = document.location.href.split("#")[0];
  6691. if (!baseUrl.startsWith("file://")) {
  6692. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  6693. }
  6694. }
  6695. if (shouldReplace) {
  6696. window.history.replaceState(newState, "", newUrl);
  6697. } else {
  6698. this._maxUid = this._uid;
  6699. window.history.pushState(newState, "", newUrl);
  6700. }
  6701. }
  6702. }, {
  6703. key: "_tryPushCurrentPosition",
  6704. value: function _tryPushCurrentPosition() {
  6705. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6706. if (!this._position) {
  6707. return;
  6708. }
  6709. var position = this._position;
  6710. if (temporary) {
  6711. position = Object.assign(Object.create(null), this._position);
  6712. position.temporary = true;
  6713. }
  6714. if (!this._destination) {
  6715. this._pushOrReplaceState(position);
  6716. return;
  6717. }
  6718. if (this._destination.temporary) {
  6719. this._pushOrReplaceState(position, true);
  6720. return;
  6721. }
  6722. if (this._destination.hash === position.hash) {
  6723. return;
  6724. }
  6725. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  6726. return;
  6727. }
  6728. var forceReplace = false;
  6729. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  6730. if (this._destination.dest || !this._destination.first) {
  6731. return;
  6732. }
  6733. forceReplace = true;
  6734. }
  6735. this._pushOrReplaceState(position, forceReplace);
  6736. }
  6737. }, {
  6738. key: "_isValidState",
  6739. value: function _isValidState(state) {
  6740. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6741. if (!state) {
  6742. return false;
  6743. }
  6744. if (state.fingerprint !== this._fingerprint) {
  6745. if (checkReload) {
  6746. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  6747. return false;
  6748. }
  6749. var _performance$getEntri = performance.getEntriesByType("navigation"),
  6750. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  6751. perfEntry = _performance$getEntri2[0];
  6752. if (!perfEntry || perfEntry.type !== "reload") {
  6753. return false;
  6754. }
  6755. } else {
  6756. return false;
  6757. }
  6758. }
  6759. if (!Number.isInteger(state.uid) || state.uid < 0) {
  6760. return false;
  6761. }
  6762. if (state.destination === null || _typeof(state.destination) !== "object") {
  6763. return false;
  6764. }
  6765. return true;
  6766. }
  6767. }, {
  6768. key: "_updateInternalState",
  6769. value: function _updateInternalState(destination, uid) {
  6770. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6771. if (this._updateViewareaTimeout) {
  6772. clearTimeout(this._updateViewareaTimeout);
  6773. this._updateViewareaTimeout = null;
  6774. }
  6775. if (removeTemporary && destination && destination.temporary) {
  6776. delete destination.temporary;
  6777. }
  6778. this._destination = destination;
  6779. this._uid = uid;
  6780. this._numPositionUpdates = 0;
  6781. }
  6782. }, {
  6783. key: "_parseCurrentHash",
  6784. value: function _parseCurrentHash() {
  6785. var checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6786. var hash = unescape(getCurrentHash()).substring(1);
  6787. var params = (0, _ui_utils.parseQueryString)(hash);
  6788. var nameddest = params.nameddest || "";
  6789. var page = params.page | 0;
  6790. if (!(Number.isInteger(page) && page > 0 && page <= this.linkService.pagesCount) || checkNameddest && nameddest.length > 0) {
  6791. page = null;
  6792. }
  6793. return {
  6794. hash: hash,
  6795. page: page,
  6796. rotation: this.linkService.rotation
  6797. };
  6798. }
  6799. }, {
  6800. key: "_updateViewarea",
  6801. value: function _updateViewarea(_ref4) {
  6802. var _this3 = this;
  6803. var location = _ref4.location;
  6804. if (this._updateViewareaTimeout) {
  6805. clearTimeout(this._updateViewareaTimeout);
  6806. this._updateViewareaTimeout = null;
  6807. }
  6808. this._position = {
  6809. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  6810. page: this.linkService.page,
  6811. first: location.pageNumber,
  6812. rotation: location.rotation
  6813. };
  6814. if (this._popStateInProgress) {
  6815. return;
  6816. }
  6817. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  6818. this._numPositionUpdates++;
  6819. }
  6820. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  6821. this._updateViewareaTimeout = setTimeout(function () {
  6822. if (!_this3._popStateInProgress) {
  6823. _this3._tryPushCurrentPosition(true);
  6824. }
  6825. _this3._updateViewareaTimeout = null;
  6826. }, UPDATE_VIEWAREA_TIMEOUT);
  6827. }
  6828. }
  6829. }, {
  6830. key: "_popState",
  6831. value: function _popState(_ref5) {
  6832. var _this4 = this;
  6833. var state = _ref5.state;
  6834. var newHash = getCurrentHash(),
  6835. hashChanged = this._currentHash !== newHash;
  6836. this._currentHash = newHash;
  6837. if (!state) {
  6838. this._uid++;
  6839. var _this$_parseCurrentHa2 = this._parseCurrentHash(),
  6840. hash = _this$_parseCurrentHa2.hash,
  6841. page = _this$_parseCurrentHa2.page,
  6842. rotation = _this$_parseCurrentHa2.rotation;
  6843. this._pushOrReplaceState({
  6844. hash: hash,
  6845. page: page,
  6846. rotation: rotation
  6847. }, true);
  6848. return;
  6849. }
  6850. if (!this._isValidState(state)) {
  6851. return;
  6852. }
  6853. this._popStateInProgress = true;
  6854. if (hashChanged) {
  6855. this._blockHashChange++;
  6856. (0, _ui_utils.waitOnEventOrTimeout)({
  6857. target: window,
  6858. name: "hashchange",
  6859. delay: HASH_CHANGE_TIMEOUT
  6860. }).then(function () {
  6861. _this4._blockHashChange--;
  6862. });
  6863. }
  6864. var destination = state.destination;
  6865. this._updateInternalState(destination, state.uid, true);
  6866. if (this._uid > this._maxUid) {
  6867. this._maxUid = this._uid;
  6868. }
  6869. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  6870. this.linkService.rotation = destination.rotation;
  6871. }
  6872. if (destination.dest) {
  6873. this.linkService.navigateTo(destination.dest);
  6874. } else if (destination.hash) {
  6875. this.linkService.setHash(destination.hash);
  6876. } else if (destination.page) {
  6877. this.linkService.page = destination.page;
  6878. }
  6879. Promise.resolve().then(function () {
  6880. _this4._popStateInProgress = false;
  6881. });
  6882. }
  6883. }, {
  6884. key: "_pageHide",
  6885. value: function _pageHide() {
  6886. if (!this._destination || this._destination.temporary) {
  6887. this._tryPushCurrentPosition();
  6888. }
  6889. }
  6890. }, {
  6891. key: "_bindEvents",
  6892. value: function _bindEvents() {
  6893. if (this._boundEvents) {
  6894. return;
  6895. }
  6896. this._boundEvents = {
  6897. updateViewarea: this._updateViewarea.bind(this),
  6898. popState: this._popState.bind(this),
  6899. pageHide: this._pageHide.bind(this)
  6900. };
  6901. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  6902. window.addEventListener("popstate", this._boundEvents.popState);
  6903. window.addEventListener("pagehide", this._boundEvents.pageHide);
  6904. }
  6905. }, {
  6906. key: "_unbindEvents",
  6907. value: function _unbindEvents() {
  6908. if (!this._boundEvents) {
  6909. return;
  6910. }
  6911. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  6912. window.removeEventListener("popstate", this._boundEvents.popState);
  6913. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  6914. this._boundEvents = null;
  6915. }
  6916. }, {
  6917. key: "popStateInProgress",
  6918. get: function get() {
  6919. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  6920. }
  6921. }, {
  6922. key: "initialBookmark",
  6923. get: function get() {
  6924. return this._initialized ? this._initialBookmark : null;
  6925. }
  6926. }, {
  6927. key: "initialRotation",
  6928. get: function get() {
  6929. return this._initialized ? this._initialRotation : null;
  6930. }
  6931. }]);
  6932. return PDFHistory;
  6933. }();
  6934. exports.PDFHistory = PDFHistory;
  6935. function isDestHashesEqual(destHash, pushHash) {
  6936. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  6937. return false;
  6938. }
  6939. if (destHash === pushHash) {
  6940. return true;
  6941. }
  6942. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  6943. nameddest = _parseQueryString.nameddest;
  6944. if (nameddest === pushHash) {
  6945. return true;
  6946. }
  6947. return false;
  6948. }
  6949. function isDestArraysEqual(firstDest, secondDest) {
  6950. function isEntryEqual(first, second) {
  6951. if (_typeof(first) !== _typeof(second)) {
  6952. return false;
  6953. }
  6954. if (Array.isArray(first) || Array.isArray(second)) {
  6955. return false;
  6956. }
  6957. if (first !== null && _typeof(first) === "object" && second !== null) {
  6958. if (Object.keys(first).length !== Object.keys(second).length) {
  6959. return false;
  6960. }
  6961. for (var key in first) {
  6962. if (!isEntryEqual(first[key], second[key])) {
  6963. return false;
  6964. }
  6965. }
  6966. return true;
  6967. }
  6968. return first === second || Number.isNaN(first) && Number.isNaN(second);
  6969. }
  6970. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  6971. return false;
  6972. }
  6973. if (firstDest.length !== secondDest.length) {
  6974. return false;
  6975. }
  6976. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  6977. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  6978. return false;
  6979. }
  6980. }
  6981. return true;
  6982. }
  6983. /***/ }),
  6984. /* 21 */
  6985. /***/ (function(module, exports, __webpack_require__) {
  6986. "use strict";
  6987. Object.defineProperty(exports, "__esModule", {
  6988. value: true
  6989. });
  6990. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  6991. var _ui_utils = __webpack_require__(5);
  6992. 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); }
  6993. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6994. 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); } }
  6995. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6996. var PDFLinkService = /*#__PURE__*/function () {
  6997. function PDFLinkService() {
  6998. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  6999. eventBus = _ref.eventBus,
  7000. _ref$externalLinkTarg = _ref.externalLinkTarget,
  7001. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  7002. _ref$externalLinkRel = _ref.externalLinkRel,
  7003. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel,
  7004. _ref$externalLinkEnab = _ref.externalLinkEnabled,
  7005. externalLinkEnabled = _ref$externalLinkEnab === void 0 ? true : _ref$externalLinkEnab,
  7006. _ref$ignoreDestinatio = _ref.ignoreDestinationZoom,
  7007. ignoreDestinationZoom = _ref$ignoreDestinatio === void 0 ? false : _ref$ignoreDestinatio;
  7008. _classCallCheck(this, PDFLinkService);
  7009. this.eventBus = eventBus;
  7010. this.externalLinkTarget = externalLinkTarget;
  7011. this.externalLinkRel = externalLinkRel;
  7012. this.externalLinkEnabled = externalLinkEnabled;
  7013. this._ignoreDestinationZoom = ignoreDestinationZoom;
  7014. this.baseUrl = null;
  7015. this.pdfDocument = null;
  7016. this.pdfViewer = null;
  7017. this.pdfHistory = null;
  7018. this._pagesRefCache = null;
  7019. }
  7020. _createClass(PDFLinkService, [{
  7021. key: "setDocument",
  7022. value: function setDocument(pdfDocument) {
  7023. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  7024. this.baseUrl = baseUrl;
  7025. this.pdfDocument = pdfDocument;
  7026. this._pagesRefCache = Object.create(null);
  7027. }
  7028. }, {
  7029. key: "setViewer",
  7030. value: function setViewer(pdfViewer) {
  7031. this.pdfViewer = pdfViewer;
  7032. }
  7033. }, {
  7034. key: "setHistory",
  7035. value: function setHistory(pdfHistory) {
  7036. this.pdfHistory = pdfHistory;
  7037. }
  7038. }, {
  7039. key: "navigateTo",
  7040. value: function navigateTo(dest) {
  7041. var _this = this;
  7042. var goToDestination = function goToDestination(_ref2) {
  7043. var namedDest = _ref2.namedDest,
  7044. explicitDest = _ref2.explicitDest;
  7045. var destRef = explicitDest[0];
  7046. var pageNumber;
  7047. if (destRef instanceof Object) {
  7048. pageNumber = _this._cachedPageNumber(destRef);
  7049. if (pageNumber === null) {
  7050. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  7051. _this.cachePageRef(pageIndex + 1, destRef);
  7052. goToDestination({
  7053. namedDest: namedDest,
  7054. explicitDest: explicitDest
  7055. });
  7056. })["catch"](function () {
  7057. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(dest, "\"."));
  7058. });
  7059. return;
  7060. }
  7061. } else if (Number.isInteger(destRef)) {
  7062. pageNumber = destRef + 1;
  7063. } else {
  7064. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(dest, "\"."));
  7065. return;
  7066. }
  7067. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  7068. console.error("PDFLinkService.navigateTo: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(dest, "\"."));
  7069. return;
  7070. }
  7071. if (_this.pdfHistory) {
  7072. _this.pdfHistory.pushCurrentPosition();
  7073. _this.pdfHistory.push({
  7074. namedDest: namedDest,
  7075. explicitDest: explicitDest,
  7076. pageNumber: pageNumber
  7077. });
  7078. }
  7079. _this.pdfViewer.scrollPageIntoView({
  7080. pageNumber: pageNumber,
  7081. destArray: explicitDest,
  7082. ignoreDestinationZoom: _this._ignoreDestinationZoom
  7083. });
  7084. };
  7085. new Promise(function (resolve, reject) {
  7086. if (typeof dest === "string") {
  7087. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  7088. resolve({
  7089. namedDest: dest,
  7090. explicitDest: destArray
  7091. });
  7092. });
  7093. return;
  7094. }
  7095. resolve({
  7096. namedDest: "",
  7097. explicitDest: dest
  7098. });
  7099. }).then(function (data) {
  7100. if (!Array.isArray(data.explicitDest)) {
  7101. console.error("PDFLinkService.navigateTo: \"".concat(data.explicitDest, "\" is") + " not a valid destination array, for dest=\"".concat(dest, "\"."));
  7102. return;
  7103. }
  7104. goToDestination(data);
  7105. });
  7106. }
  7107. }, {
  7108. key: "getDestinationHash",
  7109. value: function getDestinationHash(dest) {
  7110. if (typeof dest === "string") {
  7111. return this.getAnchorUrl("#" + escape(dest));
  7112. }
  7113. if (Array.isArray(dest)) {
  7114. var str = JSON.stringify(dest);
  7115. return this.getAnchorUrl("#" + escape(str));
  7116. }
  7117. return this.getAnchorUrl("");
  7118. }
  7119. }, {
  7120. key: "getAnchorUrl",
  7121. value: function getAnchorUrl(anchor) {
  7122. return (this.baseUrl || "") + anchor;
  7123. }
  7124. }, {
  7125. key: "setHash",
  7126. value: function setHash(hash) {
  7127. var pageNumber, dest;
  7128. if (hash.includes("=")) {
  7129. var params = (0, _ui_utils.parseQueryString)(hash);
  7130. if ("search" in params) {
  7131. this.eventBus.dispatch("findfromurlhash", {
  7132. source: this,
  7133. query: params.search.replace(/"/g, ""),
  7134. phraseSearch: params.phrase === "true"
  7135. });
  7136. }
  7137. if ("page" in params) {
  7138. pageNumber = params.page | 0 || 1;
  7139. }
  7140. if ("zoom" in params) {
  7141. var zoomArgs = params.zoom.split(",");
  7142. var zoomArg = zoomArgs[0];
  7143. var zoomArgNumber = parseFloat(zoomArg);
  7144. if (!zoomArg.includes("Fit")) {
  7145. dest = [null, {
  7146. name: "XYZ"
  7147. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  7148. } else {
  7149. if (zoomArg === "Fit" || zoomArg === "FitB") {
  7150. dest = [null, {
  7151. name: zoomArg
  7152. }];
  7153. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  7154. dest = [null, {
  7155. name: zoomArg
  7156. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  7157. } else if (zoomArg === "FitR") {
  7158. if (zoomArgs.length !== 5) {
  7159. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  7160. } else {
  7161. dest = [null, {
  7162. name: zoomArg
  7163. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  7164. }
  7165. } else {
  7166. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + "a valid zoom value.");
  7167. }
  7168. }
  7169. }
  7170. if (dest) {
  7171. this.pdfViewer.scrollPageIntoView({
  7172. pageNumber: pageNumber || this.page,
  7173. destArray: dest,
  7174. allowNegativeOffset: true
  7175. });
  7176. } else if (pageNumber) {
  7177. this.page = pageNumber;
  7178. }
  7179. if ("pagemode" in params) {
  7180. this.eventBus.dispatch("pagemode", {
  7181. source: this,
  7182. mode: params.pagemode
  7183. });
  7184. }
  7185. if ("nameddest" in params) {
  7186. this.navigateTo(params.nameddest);
  7187. }
  7188. } else {
  7189. dest = unescape(hash);
  7190. try {
  7191. dest = JSON.parse(dest);
  7192. if (!Array.isArray(dest)) {
  7193. dest = dest.toString();
  7194. }
  7195. } catch (ex) {}
  7196. if (typeof dest === "string" || isValidExplicitDestination(dest)) {
  7197. this.navigateTo(dest);
  7198. return;
  7199. }
  7200. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + "a valid destination.");
  7201. }
  7202. }
  7203. }, {
  7204. key: "executeNamedAction",
  7205. value: function executeNamedAction(action) {
  7206. switch (action) {
  7207. case "GoBack":
  7208. if (this.pdfHistory) {
  7209. this.pdfHistory.back();
  7210. }
  7211. break;
  7212. case "GoForward":
  7213. if (this.pdfHistory) {
  7214. this.pdfHistory.forward();
  7215. }
  7216. break;
  7217. case "NextPage":
  7218. if (this.page < this.pagesCount) {
  7219. this.page++;
  7220. }
  7221. break;
  7222. case "PrevPage":
  7223. if (this.page > 1) {
  7224. this.page--;
  7225. }
  7226. break;
  7227. case "LastPage":
  7228. this.page = this.pagesCount;
  7229. break;
  7230. case "FirstPage":
  7231. this.page = 1;
  7232. break;
  7233. default:
  7234. break;
  7235. }
  7236. this.eventBus.dispatch("namedaction", {
  7237. source: this,
  7238. action: action
  7239. });
  7240. }
  7241. }, {
  7242. key: "cachePageRef",
  7243. value: function cachePageRef(pageNum, pageRef) {
  7244. if (!pageRef) {
  7245. return;
  7246. }
  7247. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  7248. this._pagesRefCache[refStr] = pageNum;
  7249. }
  7250. }, {
  7251. key: "_cachedPageNumber",
  7252. value: function _cachedPageNumber(pageRef) {
  7253. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  7254. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  7255. }
  7256. }, {
  7257. key: "isPageVisible",
  7258. value: function isPageVisible(pageNumber) {
  7259. return this.pdfViewer.isPageVisible(pageNumber);
  7260. }
  7261. }, {
  7262. key: "pagesCount",
  7263. get: function get() {
  7264. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  7265. }
  7266. }, {
  7267. key: "page",
  7268. get: function get() {
  7269. return this.pdfViewer.currentPageNumber;
  7270. },
  7271. set: function set(value) {
  7272. this.pdfViewer.currentPageNumber = value;
  7273. }
  7274. }, {
  7275. key: "rotation",
  7276. get: function get() {
  7277. return this.pdfViewer.pagesRotation;
  7278. },
  7279. set: function set(value) {
  7280. this.pdfViewer.pagesRotation = value;
  7281. }
  7282. }]);
  7283. return PDFLinkService;
  7284. }();
  7285. exports.PDFLinkService = PDFLinkService;
  7286. function isValidExplicitDestination(dest) {
  7287. if (!Array.isArray(dest)) {
  7288. return false;
  7289. }
  7290. var destLength = dest.length;
  7291. if (destLength < 2) {
  7292. return false;
  7293. }
  7294. var page = dest[0];
  7295. if (!(_typeof(page) === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  7296. return false;
  7297. }
  7298. var zoom = dest[1];
  7299. if (!(_typeof(zoom) === "object" && typeof zoom.name === "string")) {
  7300. return false;
  7301. }
  7302. var allowNull = true;
  7303. switch (zoom.name) {
  7304. case "XYZ":
  7305. if (destLength !== 5) {
  7306. return false;
  7307. }
  7308. break;
  7309. case "Fit":
  7310. case "FitB":
  7311. return destLength === 2;
  7312. case "FitH":
  7313. case "FitBH":
  7314. case "FitV":
  7315. case "FitBV":
  7316. if (destLength !== 3) {
  7317. return false;
  7318. }
  7319. break;
  7320. case "FitR":
  7321. if (destLength !== 6) {
  7322. return false;
  7323. }
  7324. allowNull = false;
  7325. break;
  7326. default:
  7327. return false;
  7328. }
  7329. for (var i = 2; i < destLength; i++) {
  7330. var param = dest[i];
  7331. if (!(typeof param === "number" || allowNull && param === null)) {
  7332. return false;
  7333. }
  7334. }
  7335. return true;
  7336. }
  7337. var SimpleLinkService = /*#__PURE__*/function () {
  7338. function SimpleLinkService() {
  7339. _classCallCheck(this, SimpleLinkService);
  7340. this.externalLinkTarget = null;
  7341. this.externalLinkRel = null;
  7342. this.externalLinkEnabled = true;
  7343. this._ignoreDestinationZoom = false;
  7344. }
  7345. _createClass(SimpleLinkService, [{
  7346. key: "navigateTo",
  7347. value: function navigateTo(dest) {}
  7348. }, {
  7349. key: "getDestinationHash",
  7350. value: function getDestinationHash(dest) {
  7351. return "#";
  7352. }
  7353. }, {
  7354. key: "getAnchorUrl",
  7355. value: function getAnchorUrl(hash) {
  7356. return "#";
  7357. }
  7358. }, {
  7359. key: "setHash",
  7360. value: function setHash(hash) {}
  7361. }, {
  7362. key: "executeNamedAction",
  7363. value: function executeNamedAction(action) {}
  7364. }, {
  7365. key: "cachePageRef",
  7366. value: function cachePageRef(pageNum, pageRef) {}
  7367. }, {
  7368. key: "isPageVisible",
  7369. value: function isPageVisible(pageNumber) {
  7370. return true;
  7371. }
  7372. }, {
  7373. key: "pagesCount",
  7374. get: function get() {
  7375. return 0;
  7376. }
  7377. }, {
  7378. key: "page",
  7379. get: function get() {
  7380. return 0;
  7381. },
  7382. set: function set(value) {}
  7383. }, {
  7384. key: "rotation",
  7385. get: function get() {
  7386. return 0;
  7387. },
  7388. set: function set(value) {}
  7389. }]);
  7390. return SimpleLinkService;
  7391. }();
  7392. exports.SimpleLinkService = SimpleLinkService;
  7393. /***/ }),
  7394. /* 22 */
  7395. /***/ (function(module, exports, __webpack_require__) {
  7396. "use strict";
  7397. Object.defineProperty(exports, "__esModule", {
  7398. value: true
  7399. });
  7400. exports.PDFOutlineViewer = void 0;
  7401. var _pdfjsLib = __webpack_require__(8);
  7402. 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; } } }; }
  7403. 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); }
  7404. 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; }
  7405. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7406. 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); } }
  7407. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7408. var DEFAULT_TITLE = "\u2013";
  7409. var PDFOutlineViewer = /*#__PURE__*/function () {
  7410. function PDFOutlineViewer(_ref) {
  7411. var container = _ref.container,
  7412. linkService = _ref.linkService,
  7413. eventBus = _ref.eventBus;
  7414. _classCallCheck(this, PDFOutlineViewer);
  7415. this.container = container;
  7416. this.linkService = linkService;
  7417. this.eventBus = eventBus;
  7418. this.reset();
  7419. eventBus._on("toggleoutlinetree", this.toggleOutlineTree.bind(this));
  7420. }
  7421. _createClass(PDFOutlineViewer, [{
  7422. key: "reset",
  7423. value: function reset() {
  7424. this.outline = null;
  7425. this.lastToggleIsShow = true;
  7426. this.container.textContent = "";
  7427. this.container.classList.remove("outlineWithDeepNesting");
  7428. }
  7429. }, {
  7430. key: "_dispatchEvent",
  7431. value: function _dispatchEvent(outlineCount) {
  7432. this.eventBus.dispatch("outlineloaded", {
  7433. source: this,
  7434. outlineCount: outlineCount
  7435. });
  7436. }
  7437. }, {
  7438. key: "_bindLink",
  7439. value: function _bindLink(element, _ref2) {
  7440. var url = _ref2.url,
  7441. newWindow = _ref2.newWindow,
  7442. dest = _ref2.dest;
  7443. var linkService = this.linkService;
  7444. if (url) {
  7445. (0, _pdfjsLib.addLinkAttributes)(element, {
  7446. url: url,
  7447. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
  7448. rel: linkService.externalLinkRel,
  7449. enabled: linkService.externalLinkEnabled
  7450. });
  7451. return;
  7452. }
  7453. element.href = linkService.getDestinationHash(dest);
  7454. element.onclick = function () {
  7455. if (dest) {
  7456. linkService.navigateTo(dest);
  7457. }
  7458. return false;
  7459. };
  7460. }
  7461. }, {
  7462. key: "_setStyles",
  7463. value: function _setStyles(element, _ref3) {
  7464. var bold = _ref3.bold,
  7465. italic = _ref3.italic;
  7466. if (bold) {
  7467. element.style.fontWeight = "bold";
  7468. }
  7469. if (italic) {
  7470. element.style.fontStyle = "italic";
  7471. }
  7472. }
  7473. }, {
  7474. key: "_addToggleButton",
  7475. value: function _addToggleButton(div, _ref4) {
  7476. var _this = this;
  7477. var count = _ref4.count,
  7478. items = _ref4.items;
  7479. var toggler = document.createElement("div");
  7480. toggler.className = "outlineItemToggler";
  7481. if (count < 0 && Math.abs(count) === items.length) {
  7482. toggler.classList.add("outlineItemsHidden");
  7483. }
  7484. toggler.onclick = function (evt) {
  7485. evt.stopPropagation();
  7486. toggler.classList.toggle("outlineItemsHidden");
  7487. if (evt.shiftKey) {
  7488. var shouldShowAll = !toggler.classList.contains("outlineItemsHidden");
  7489. _this._toggleOutlineItem(div, shouldShowAll);
  7490. }
  7491. };
  7492. div.insertBefore(toggler, div.firstChild);
  7493. }
  7494. }, {
  7495. key: "_toggleOutlineItem",
  7496. value: function _toggleOutlineItem(root) {
  7497. var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7498. this.lastToggleIsShow = show;
  7499. var _iterator = _createForOfIteratorHelper(root.querySelectorAll(".outlineItemToggler")),
  7500. _step;
  7501. try {
  7502. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7503. var toggler = _step.value;
  7504. toggler.classList.toggle("outlineItemsHidden", !show);
  7505. }
  7506. } catch (err) {
  7507. _iterator.e(err);
  7508. } finally {
  7509. _iterator.f();
  7510. }
  7511. }
  7512. }, {
  7513. key: "toggleOutlineTree",
  7514. value: function toggleOutlineTree() {
  7515. if (!this.outline) {
  7516. return;
  7517. }
  7518. this._toggleOutlineItem(this.container, !this.lastToggleIsShow);
  7519. }
  7520. }, {
  7521. key: "render",
  7522. value: function render(_ref5) {
  7523. var outline = _ref5.outline;
  7524. var outlineCount = 0;
  7525. if (this.outline) {
  7526. this.reset();
  7527. }
  7528. this.outline = outline || null;
  7529. if (!outline) {
  7530. this._dispatchEvent(outlineCount);
  7531. return;
  7532. }
  7533. var fragment = document.createDocumentFragment();
  7534. var queue = [{
  7535. parent: fragment,
  7536. items: this.outline
  7537. }];
  7538. var hasAnyNesting = false;
  7539. while (queue.length > 0) {
  7540. var levelData = queue.shift();
  7541. var _iterator2 = _createForOfIteratorHelper(levelData.items),
  7542. _step2;
  7543. try {
  7544. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  7545. var item = _step2.value;
  7546. var div = document.createElement("div");
  7547. div.className = "outlineItem";
  7548. var element = document.createElement("a");
  7549. this._bindLink(element, item);
  7550. this._setStyles(element, item);
  7551. element.textContent = (0, _pdfjsLib.removeNullCharacters)(item.title) || DEFAULT_TITLE;
  7552. div.appendChild(element);
  7553. if (item.items.length > 0) {
  7554. hasAnyNesting = true;
  7555. this._addToggleButton(div, item);
  7556. var itemsDiv = document.createElement("div");
  7557. itemsDiv.className = "outlineItems";
  7558. div.appendChild(itemsDiv);
  7559. queue.push({
  7560. parent: itemsDiv,
  7561. items: item.items
  7562. });
  7563. }
  7564. levelData.parent.appendChild(div);
  7565. outlineCount++;
  7566. }
  7567. } catch (err) {
  7568. _iterator2.e(err);
  7569. } finally {
  7570. _iterator2.f();
  7571. }
  7572. }
  7573. if (hasAnyNesting) {
  7574. this.container.classList.add("outlineWithDeepNesting");
  7575. this.lastToggleIsShow = fragment.querySelectorAll(".outlineItemsHidden").length === 0;
  7576. }
  7577. this.container.appendChild(fragment);
  7578. this._dispatchEvent(outlineCount);
  7579. }
  7580. }]);
  7581. return PDFOutlineViewer;
  7582. }();
  7583. exports.PDFOutlineViewer = PDFOutlineViewer;
  7584. /***/ }),
  7585. /* 23 */
  7586. /***/ (function(module, exports, __webpack_require__) {
  7587. "use strict";
  7588. Object.defineProperty(exports, "__esModule", {
  7589. value: true
  7590. });
  7591. exports.PDFPresentationMode = void 0;
  7592. var _ui_utils = __webpack_require__(5);
  7593. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7594. 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); } }
  7595. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7596. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  7597. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  7598. var ACTIVE_SELECTOR = "pdfPresentationMode";
  7599. var CONTROLS_SELECTOR = "pdfPresentationModeControls";
  7600. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  7601. var PAGE_SWITCH_THRESHOLD = 0.1;
  7602. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  7603. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  7604. var PDFPresentationMode = /*#__PURE__*/function () {
  7605. function PDFPresentationMode(_ref) {
  7606. var _this = this;
  7607. var container = _ref.container,
  7608. pdfViewer = _ref.pdfViewer,
  7609. eventBus = _ref.eventBus,
  7610. _ref$contextMenuItems = _ref.contextMenuItems,
  7611. contextMenuItems = _ref$contextMenuItems === void 0 ? null : _ref$contextMenuItems;
  7612. _classCallCheck(this, PDFPresentationMode);
  7613. this.container = container;
  7614. this.pdfViewer = pdfViewer;
  7615. this.eventBus = eventBus;
  7616. this.active = false;
  7617. this.args = null;
  7618. this.contextMenuOpen = false;
  7619. this.mouseScrollTimeStamp = 0;
  7620. this.mouseScrollDelta = 0;
  7621. this.touchSwipeState = null;
  7622. if (contextMenuItems) {
  7623. contextMenuItems.contextFirstPage.addEventListener("click", function () {
  7624. _this.contextMenuOpen = false;
  7625. _this.eventBus.dispatch("firstpage", {
  7626. source: _this
  7627. });
  7628. });
  7629. contextMenuItems.contextLastPage.addEventListener("click", function () {
  7630. _this.contextMenuOpen = false;
  7631. _this.eventBus.dispatch("lastpage", {
  7632. source: _this
  7633. });
  7634. });
  7635. contextMenuItems.contextPageRotateCw.addEventListener("click", function () {
  7636. _this.contextMenuOpen = false;
  7637. _this.eventBus.dispatch("rotatecw", {
  7638. source: _this
  7639. });
  7640. });
  7641. contextMenuItems.contextPageRotateCcw.addEventListener("click", function () {
  7642. _this.contextMenuOpen = false;
  7643. _this.eventBus.dispatch("rotateccw", {
  7644. source: _this
  7645. });
  7646. });
  7647. }
  7648. }
  7649. _createClass(PDFPresentationMode, [{
  7650. key: "request",
  7651. value: function request() {
  7652. if (this.switchInProgress || this.active || !this.pdfViewer.pagesCount) {
  7653. return false;
  7654. }
  7655. this._addFullscreenChangeListeners();
  7656. this._setSwitchInProgress();
  7657. this._notifyStateChange();
  7658. if (this.container.requestFullscreen) {
  7659. this.container.requestFullscreen();
  7660. } else if (this.container.mozRequestFullScreen) {
  7661. this.container.mozRequestFullScreen();
  7662. } else if (this.container.webkitRequestFullscreen) {
  7663. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  7664. } else if (this.container.msRequestFullscreen) {
  7665. this.container.msRequestFullscreen();
  7666. } else {
  7667. return false;
  7668. }
  7669. this.args = {
  7670. page: this.pdfViewer.currentPageNumber,
  7671. previousScale: this.pdfViewer.currentScaleValue
  7672. };
  7673. return true;
  7674. }
  7675. }, {
  7676. key: "_mouseWheel",
  7677. value: function _mouseWheel(evt) {
  7678. if (!this.active) {
  7679. return;
  7680. }
  7681. evt.preventDefault();
  7682. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  7683. var currentTime = new Date().getTime();
  7684. var storedTime = this.mouseScrollTimeStamp;
  7685. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  7686. return;
  7687. }
  7688. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  7689. this._resetMouseScrollState();
  7690. }
  7691. this.mouseScrollDelta += delta;
  7692. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  7693. var totalDelta = this.mouseScrollDelta;
  7694. this._resetMouseScrollState();
  7695. var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
  7696. if (success) {
  7697. this.mouseScrollTimeStamp = currentTime;
  7698. }
  7699. }
  7700. }
  7701. }, {
  7702. key: "_goToPreviousPage",
  7703. value: function _goToPreviousPage() {
  7704. var page = this.pdfViewer.currentPageNumber;
  7705. if (page <= 1) {
  7706. return false;
  7707. }
  7708. this.pdfViewer.currentPageNumber = page - 1;
  7709. return true;
  7710. }
  7711. }, {
  7712. key: "_goToNextPage",
  7713. value: function _goToNextPage() {
  7714. var page = this.pdfViewer.currentPageNumber;
  7715. if (page >= this.pdfViewer.pagesCount) {
  7716. return false;
  7717. }
  7718. this.pdfViewer.currentPageNumber = page + 1;
  7719. return true;
  7720. }
  7721. }, {
  7722. key: "_notifyStateChange",
  7723. value: function _notifyStateChange() {
  7724. this.eventBus.dispatch("presentationmodechanged", {
  7725. source: this,
  7726. active: this.active,
  7727. switchInProgress: !!this.switchInProgress
  7728. });
  7729. }
  7730. }, {
  7731. key: "_setSwitchInProgress",
  7732. value: function _setSwitchInProgress() {
  7733. var _this2 = this;
  7734. if (this.switchInProgress) {
  7735. clearTimeout(this.switchInProgress);
  7736. }
  7737. this.switchInProgress = setTimeout(function () {
  7738. _this2._removeFullscreenChangeListeners();
  7739. delete _this2.switchInProgress;
  7740. _this2._notifyStateChange();
  7741. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  7742. }
  7743. }, {
  7744. key: "_resetSwitchInProgress",
  7745. value: function _resetSwitchInProgress() {
  7746. if (this.switchInProgress) {
  7747. clearTimeout(this.switchInProgress);
  7748. delete this.switchInProgress;
  7749. }
  7750. }
  7751. }, {
  7752. key: "_enter",
  7753. value: function _enter() {
  7754. var _this3 = this;
  7755. this.active = true;
  7756. this._resetSwitchInProgress();
  7757. this._notifyStateChange();
  7758. this.container.classList.add(ACTIVE_SELECTOR);
  7759. setTimeout(function () {
  7760. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  7761. _this3.pdfViewer.currentScaleValue = "page-fit";
  7762. }, 0);
  7763. this._addWindowListeners();
  7764. this._showControls();
  7765. this.contextMenuOpen = false;
  7766. this.container.setAttribute("contextmenu", "viewerContextMenu");
  7767. window.getSelection().removeAllRanges();
  7768. }
  7769. }, {
  7770. key: "_exit",
  7771. value: function _exit() {
  7772. var _this4 = this;
  7773. var page = this.pdfViewer.currentPageNumber;
  7774. this.container.classList.remove(ACTIVE_SELECTOR);
  7775. setTimeout(function () {
  7776. _this4.active = false;
  7777. _this4._removeFullscreenChangeListeners();
  7778. _this4._notifyStateChange();
  7779. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  7780. _this4.pdfViewer.currentPageNumber = page;
  7781. _this4.args = null;
  7782. }, 0);
  7783. this._removeWindowListeners();
  7784. this._hideControls();
  7785. this._resetMouseScrollState();
  7786. this.container.removeAttribute("contextmenu");
  7787. this.contextMenuOpen = false;
  7788. }
  7789. }, {
  7790. key: "_mouseDown",
  7791. value: function _mouseDown(evt) {
  7792. if (this.contextMenuOpen) {
  7793. this.contextMenuOpen = false;
  7794. evt.preventDefault();
  7795. return;
  7796. }
  7797. if (evt.button === 0) {
  7798. var isInternalLink = evt.target.href && evt.target.classList.contains("internalLink");
  7799. if (!isInternalLink) {
  7800. evt.preventDefault();
  7801. if (evt.shiftKey) {
  7802. this._goToPreviousPage();
  7803. } else {
  7804. this._goToNextPage();
  7805. }
  7806. }
  7807. }
  7808. }
  7809. }, {
  7810. key: "_contextMenu",
  7811. value: function _contextMenu() {
  7812. this.contextMenuOpen = true;
  7813. }
  7814. }, {
  7815. key: "_showControls",
  7816. value: function _showControls() {
  7817. var _this5 = this;
  7818. if (this.controlsTimeout) {
  7819. clearTimeout(this.controlsTimeout);
  7820. } else {
  7821. this.container.classList.add(CONTROLS_SELECTOR);
  7822. }
  7823. this.controlsTimeout = setTimeout(function () {
  7824. _this5.container.classList.remove(CONTROLS_SELECTOR);
  7825. delete _this5.controlsTimeout;
  7826. }, DELAY_BEFORE_HIDING_CONTROLS);
  7827. }
  7828. }, {
  7829. key: "_hideControls",
  7830. value: function _hideControls() {
  7831. if (!this.controlsTimeout) {
  7832. return;
  7833. }
  7834. clearTimeout(this.controlsTimeout);
  7835. this.container.classList.remove(CONTROLS_SELECTOR);
  7836. delete this.controlsTimeout;
  7837. }
  7838. }, {
  7839. key: "_resetMouseScrollState",
  7840. value: function _resetMouseScrollState() {
  7841. this.mouseScrollTimeStamp = 0;
  7842. this.mouseScrollDelta = 0;
  7843. }
  7844. }, {
  7845. key: "_touchSwipe",
  7846. value: function _touchSwipe(evt) {
  7847. if (!this.active) {
  7848. return;
  7849. }
  7850. if (evt.touches.length > 1) {
  7851. this.touchSwipeState = null;
  7852. return;
  7853. }
  7854. switch (evt.type) {
  7855. case "touchstart":
  7856. this.touchSwipeState = {
  7857. startX: evt.touches[0].pageX,
  7858. startY: evt.touches[0].pageY,
  7859. endX: evt.touches[0].pageX,
  7860. endY: evt.touches[0].pageY
  7861. };
  7862. break;
  7863. case "touchmove":
  7864. if (this.touchSwipeState === null) {
  7865. return;
  7866. }
  7867. this.touchSwipeState.endX = evt.touches[0].pageX;
  7868. this.touchSwipeState.endY = evt.touches[0].pageY;
  7869. evt.preventDefault();
  7870. break;
  7871. case "touchend":
  7872. if (this.touchSwipeState === null) {
  7873. return;
  7874. }
  7875. var delta = 0;
  7876. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  7877. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  7878. var absAngle = Math.abs(Math.atan2(dy, dx));
  7879. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  7880. delta = dx;
  7881. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  7882. delta = dy;
  7883. }
  7884. if (delta > 0) {
  7885. this._goToPreviousPage();
  7886. } else if (delta < 0) {
  7887. this._goToNextPage();
  7888. }
  7889. break;
  7890. }
  7891. }
  7892. }, {
  7893. key: "_addWindowListeners",
  7894. value: function _addWindowListeners() {
  7895. this.showControlsBind = this._showControls.bind(this);
  7896. this.mouseDownBind = this._mouseDown.bind(this);
  7897. this.mouseWheelBind = this._mouseWheel.bind(this);
  7898. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  7899. this.contextMenuBind = this._contextMenu.bind(this);
  7900. this.touchSwipeBind = this._touchSwipe.bind(this);
  7901. window.addEventListener("mousemove", this.showControlsBind);
  7902. window.addEventListener("mousedown", this.mouseDownBind);
  7903. window.addEventListener("wheel", this.mouseWheelBind, {
  7904. passive: false
  7905. });
  7906. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  7907. window.addEventListener("contextmenu", this.contextMenuBind);
  7908. window.addEventListener("touchstart", this.touchSwipeBind);
  7909. window.addEventListener("touchmove", this.touchSwipeBind);
  7910. window.addEventListener("touchend", this.touchSwipeBind);
  7911. }
  7912. }, {
  7913. key: "_removeWindowListeners",
  7914. value: function _removeWindowListeners() {
  7915. window.removeEventListener("mousemove", this.showControlsBind);
  7916. window.removeEventListener("mousedown", this.mouseDownBind);
  7917. window.removeEventListener("wheel", this.mouseWheelBind, {
  7918. passive: false
  7919. });
  7920. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  7921. window.removeEventListener("contextmenu", this.contextMenuBind);
  7922. window.removeEventListener("touchstart", this.touchSwipeBind);
  7923. window.removeEventListener("touchmove", this.touchSwipeBind);
  7924. window.removeEventListener("touchend", this.touchSwipeBind);
  7925. delete this.showControlsBind;
  7926. delete this.mouseDownBind;
  7927. delete this.mouseWheelBind;
  7928. delete this.resetMouseScrollStateBind;
  7929. delete this.contextMenuBind;
  7930. delete this.touchSwipeBind;
  7931. }
  7932. }, {
  7933. key: "_fullscreenChange",
  7934. value: function _fullscreenChange() {
  7935. if (this.isFullscreen) {
  7936. this._enter();
  7937. } else {
  7938. this._exit();
  7939. }
  7940. }
  7941. }, {
  7942. key: "_addFullscreenChangeListeners",
  7943. value: function _addFullscreenChangeListeners() {
  7944. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  7945. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  7946. window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  7947. window.addEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  7948. window.addEventListener("MSFullscreenChange", this.fullscreenChangeBind);
  7949. }
  7950. }, {
  7951. key: "_removeFullscreenChangeListeners",
  7952. value: function _removeFullscreenChangeListeners() {
  7953. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  7954. window.removeEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  7955. window.removeEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  7956. window.removeEventListener("MSFullscreenChange", this.fullscreenChangeBind);
  7957. delete this.fullscreenChangeBind;
  7958. }
  7959. }, {
  7960. key: "isFullscreen",
  7961. get: function get() {
  7962. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
  7963. }
  7964. }]);
  7965. return PDFPresentationMode;
  7966. }();
  7967. exports.PDFPresentationMode = PDFPresentationMode;
  7968. /***/ }),
  7969. /* 24 */
  7970. /***/ (function(module, exports, __webpack_require__) {
  7971. "use strict";
  7972. Object.defineProperty(exports, "__esModule", {
  7973. value: true
  7974. });
  7975. exports.PDFSidebarResizer = void 0;
  7976. var _ui_utils = __webpack_require__(5);
  7977. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7978. 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); } }
  7979. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7980. var SIDEBAR_WIDTH_VAR = "--sidebar-width";
  7981. var SIDEBAR_MIN_WIDTH = 200;
  7982. var SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  7983. var PDFSidebarResizer = /*#__PURE__*/function () {
  7984. function PDFSidebarResizer(options, eventBus) {
  7985. var _this = this;
  7986. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  7987. _classCallCheck(this, PDFSidebarResizer);
  7988. this.enabled = false;
  7989. this.isRTL = false;
  7990. this.sidebarOpen = false;
  7991. this.doc = document.documentElement;
  7992. this._width = null;
  7993. this._outerContainerWidth = null;
  7994. this._boundEvents = Object.create(null);
  7995. this.outerContainer = options.outerContainer;
  7996. this.resizer = options.resizer;
  7997. this.eventBus = eventBus;
  7998. this.l10n = l10n;
  7999. if (typeof CSS === "undefined" || typeof CSS.supports !== "function" || !CSS.supports(SIDEBAR_WIDTH_VAR, "calc(-1 * ".concat(SIDEBAR_MIN_WIDTH, "px)"))) {
  8000. console.warn("PDFSidebarResizer: " + "The browser does not support resizing of the sidebar.");
  8001. return;
  8002. }
  8003. this.enabled = true;
  8004. this.resizer.classList.remove("hidden");
  8005. this.l10n.getDirection().then(function (dir) {
  8006. _this.isRTL = dir === "rtl";
  8007. });
  8008. this._addEventListeners();
  8009. }
  8010. _createClass(PDFSidebarResizer, [{
  8011. key: "_updateWidth",
  8012. value: function _updateWidth() {
  8013. var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  8014. if (!this.enabled) {
  8015. return false;
  8016. }
  8017. var newWidth = (0, _ui_utils.clamp)(width, SIDEBAR_MIN_WIDTH, Math.floor(this.outerContainerWidth / 2));
  8018. if (newWidth === this._width) {
  8019. return false;
  8020. }
  8021. this._width = newWidth;
  8022. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(newWidth, "px"));
  8023. return true;
  8024. }
  8025. }, {
  8026. key: "_mouseMove",
  8027. value: function _mouseMove(evt) {
  8028. var width = evt.clientX;
  8029. if (this.isRTL) {
  8030. width = this.outerContainerWidth - width;
  8031. }
  8032. this._updateWidth(width);
  8033. }
  8034. }, {
  8035. key: "_mouseUp",
  8036. value: function _mouseUp(evt) {
  8037. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  8038. this.eventBus.dispatch("resize", {
  8039. source: this
  8040. });
  8041. var _boundEvents = this._boundEvents;
  8042. window.removeEventListener("mousemove", _boundEvents.mouseMove);
  8043. window.removeEventListener("mouseup", _boundEvents.mouseUp);
  8044. }
  8045. }, {
  8046. key: "_addEventListeners",
  8047. value: function _addEventListeners() {
  8048. var _this2 = this;
  8049. if (!this.enabled) {
  8050. return;
  8051. }
  8052. var _boundEvents = this._boundEvents;
  8053. _boundEvents.mouseMove = this._mouseMove.bind(this);
  8054. _boundEvents.mouseUp = this._mouseUp.bind(this);
  8055. this.resizer.addEventListener("mousedown", function (evt) {
  8056. if (evt.button !== 0) {
  8057. return;
  8058. }
  8059. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  8060. window.addEventListener("mousemove", _boundEvents.mouseMove);
  8061. window.addEventListener("mouseup", _boundEvents.mouseUp);
  8062. });
  8063. this.eventBus._on("sidebarviewchanged", function (evt) {
  8064. _this2.sidebarOpen = !!(evt && evt.view);
  8065. });
  8066. this.eventBus._on("resize", function (evt) {
  8067. if (!evt || evt.source !== window) {
  8068. return;
  8069. }
  8070. _this2._outerContainerWidth = null;
  8071. if (!_this2._width) {
  8072. return;
  8073. }
  8074. if (!_this2.sidebarOpen) {
  8075. _this2._updateWidth(_this2._width);
  8076. return;
  8077. }
  8078. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  8079. var updated = _this2._updateWidth(_this2._width);
  8080. Promise.resolve().then(function () {
  8081. _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  8082. if (updated) {
  8083. _this2.eventBus.dispatch("resize", {
  8084. source: _this2
  8085. });
  8086. }
  8087. });
  8088. });
  8089. }
  8090. }, {
  8091. key: "outerContainerWidth",
  8092. get: function get() {
  8093. if (!this._outerContainerWidth) {
  8094. this._outerContainerWidth = this.outerContainer.clientWidth;
  8095. }
  8096. return this._outerContainerWidth;
  8097. }
  8098. }]);
  8099. return PDFSidebarResizer;
  8100. }();
  8101. exports.PDFSidebarResizer = PDFSidebarResizer;
  8102. /***/ }),
  8103. /* 25 */
  8104. /***/ (function(module, exports, __webpack_require__) {
  8105. "use strict";
  8106. Object.defineProperty(exports, "__esModule", {
  8107. value: true
  8108. });
  8109. exports.PDFThumbnailViewer = void 0;
  8110. var _ui_utils = __webpack_require__(5);
  8111. var _pdf_thumbnail_view = __webpack_require__(26);
  8112. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8113. 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); } }
  8114. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8115. var THUMBNAIL_SCROLL_MARGIN = -19;
  8116. var THUMBNAIL_SELECTED_CLASS = "selected";
  8117. var PDFThumbnailViewer = /*#__PURE__*/function () {
  8118. function PDFThumbnailViewer(_ref) {
  8119. var container = _ref.container,
  8120. linkService = _ref.linkService,
  8121. renderingQueue = _ref.renderingQueue,
  8122. _ref$l10n = _ref.l10n,
  8123. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  8124. _classCallCheck(this, PDFThumbnailViewer);
  8125. this.container = container;
  8126. this.linkService = linkService;
  8127. this.renderingQueue = renderingQueue;
  8128. this.l10n = l10n;
  8129. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  8130. this._resetView();
  8131. }
  8132. _createClass(PDFThumbnailViewer, [{
  8133. key: "_scrollUpdated",
  8134. value: function _scrollUpdated() {
  8135. this.renderingQueue.renderHighestPriority();
  8136. }
  8137. }, {
  8138. key: "getThumbnail",
  8139. value: function getThumbnail(index) {
  8140. return this._thumbnails[index];
  8141. }
  8142. }, {
  8143. key: "_getVisibleThumbs",
  8144. value: function _getVisibleThumbs() {
  8145. return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
  8146. }
  8147. }, {
  8148. key: "scrollThumbnailIntoView",
  8149. value: function scrollThumbnailIntoView(pageNumber) {
  8150. if (!this.pdfDocument) {
  8151. return;
  8152. }
  8153. var thumbnailView = this._thumbnails[pageNumber - 1];
  8154. if (!thumbnailView) {
  8155. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  8156. return;
  8157. }
  8158. if (pageNumber !== this._currentPageNumber) {
  8159. var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  8160. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  8161. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  8162. }
  8163. var visibleThumbs = this._getVisibleThumbs();
  8164. var numVisibleThumbs = visibleThumbs.views.length;
  8165. if (numVisibleThumbs > 0) {
  8166. var first = visibleThumbs.first.id;
  8167. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  8168. var shouldScroll = false;
  8169. if (pageNumber <= first || pageNumber >= last) {
  8170. shouldScroll = true;
  8171. } else {
  8172. visibleThumbs.views.some(function (view) {
  8173. if (view.id !== pageNumber) {
  8174. return false;
  8175. }
  8176. shouldScroll = view.percent < 100;
  8177. return true;
  8178. });
  8179. }
  8180. if (shouldScroll) {
  8181. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  8182. top: THUMBNAIL_SCROLL_MARGIN
  8183. });
  8184. }
  8185. }
  8186. this._currentPageNumber = pageNumber;
  8187. }
  8188. }, {
  8189. key: "cleanup",
  8190. value: function cleanup() {
  8191. _pdf_thumbnail_view.PDFThumbnailView.cleanup();
  8192. }
  8193. }, {
  8194. key: "_resetView",
  8195. value: function _resetView() {
  8196. this._thumbnails = [];
  8197. this._currentPageNumber = 1;
  8198. this._pageLabels = null;
  8199. this._pagesRotation = 0;
  8200. this._pagesRequests = new WeakMap();
  8201. this.container.textContent = "";
  8202. }
  8203. }, {
  8204. key: "setDocument",
  8205. value: function setDocument(pdfDocument) {
  8206. var _this = this;
  8207. if (this.pdfDocument) {
  8208. this._cancelRendering();
  8209. this._resetView();
  8210. }
  8211. this.pdfDocument = pdfDocument;
  8212. if (!pdfDocument) {
  8213. return;
  8214. }
  8215. pdfDocument.getPage(1).then(function (firstPdfPage) {
  8216. var pagesCount = pdfDocument.numPages;
  8217. var viewport = firstPdfPage.getViewport({
  8218. scale: 1
  8219. });
  8220. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8221. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  8222. container: _this.container,
  8223. id: pageNum,
  8224. defaultViewport: viewport.clone(),
  8225. linkService: _this.linkService,
  8226. renderingQueue: _this.renderingQueue,
  8227. disableCanvasToImageConversion: false,
  8228. l10n: _this.l10n
  8229. });
  8230. _this._thumbnails.push(thumbnail);
  8231. }
  8232. var firstThumbnailView = _this._thumbnails[0];
  8233. if (firstThumbnailView) {
  8234. firstThumbnailView.setPdfPage(firstPdfPage);
  8235. }
  8236. var thumbnailView = _this._thumbnails[_this._currentPageNumber - 1];
  8237. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  8238. })["catch"](function (reason) {
  8239. console.error("Unable to initialize thumbnail viewer", reason);
  8240. });
  8241. }
  8242. }, {
  8243. key: "_cancelRendering",
  8244. value: function _cancelRendering() {
  8245. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8246. if (this._thumbnails[i]) {
  8247. this._thumbnails[i].cancelRendering();
  8248. }
  8249. }
  8250. }
  8251. }, {
  8252. key: "setPageLabels",
  8253. value: function setPageLabels(labels) {
  8254. if (!this.pdfDocument) {
  8255. return;
  8256. }
  8257. if (!labels) {
  8258. this._pageLabels = null;
  8259. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  8260. this._pageLabels = null;
  8261. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  8262. } else {
  8263. this._pageLabels = labels;
  8264. }
  8265. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8266. var label = this._pageLabels && this._pageLabels[i];
  8267. this._thumbnails[i].setPageLabel(label);
  8268. }
  8269. }
  8270. }, {
  8271. key: "_ensurePdfPageLoaded",
  8272. value: function _ensurePdfPageLoaded(thumbView) {
  8273. var _this2 = this;
  8274. if (thumbView.pdfPage) {
  8275. return Promise.resolve(thumbView.pdfPage);
  8276. }
  8277. if (this._pagesRequests.has(thumbView)) {
  8278. return this._pagesRequests.get(thumbView);
  8279. }
  8280. var promise = this.pdfDocument.getPage(thumbView.id).then(function (pdfPage) {
  8281. if (!thumbView.pdfPage) {
  8282. thumbView.setPdfPage(pdfPage);
  8283. }
  8284. _this2._pagesRequests["delete"](thumbView);
  8285. return pdfPage;
  8286. })["catch"](function (reason) {
  8287. console.error("Unable to get page for thumb view", reason);
  8288. _this2._pagesRequests["delete"](thumbView);
  8289. });
  8290. this._pagesRequests.set(thumbView, promise);
  8291. return promise;
  8292. }
  8293. }, {
  8294. key: "forceRendering",
  8295. value: function forceRendering() {
  8296. var _this3 = this;
  8297. var visibleThumbs = this._getVisibleThumbs();
  8298. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  8299. if (thumbView) {
  8300. this._ensurePdfPageLoaded(thumbView).then(function () {
  8301. _this3.renderingQueue.renderView(thumbView);
  8302. });
  8303. return true;
  8304. }
  8305. return false;
  8306. }
  8307. }, {
  8308. key: "pagesRotation",
  8309. get: function get() {
  8310. return this._pagesRotation;
  8311. },
  8312. set: function set(rotation) {
  8313. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  8314. throw new Error("Invalid thumbnails rotation angle.");
  8315. }
  8316. if (!this.pdfDocument) {
  8317. return;
  8318. }
  8319. if (this._pagesRotation === rotation) {
  8320. return;
  8321. }
  8322. this._pagesRotation = rotation;
  8323. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8324. this._thumbnails[i].update(rotation);
  8325. }
  8326. }
  8327. }]);
  8328. return PDFThumbnailViewer;
  8329. }();
  8330. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  8331. /***/ }),
  8332. /* 26 */
  8333. /***/ (function(module, exports, __webpack_require__) {
  8334. "use strict";
  8335. Object.defineProperty(exports, "__esModule", {
  8336. value: true
  8337. });
  8338. exports.PDFThumbnailView = void 0;
  8339. var _pdfjsLib = __webpack_require__(8);
  8340. var _ui_utils = __webpack_require__(5);
  8341. var _pdf_rendering_queue = __webpack_require__(11);
  8342. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8343. 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); } }
  8344. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8345. var MAX_NUM_SCALING_STEPS = 3;
  8346. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  8347. var THUMBNAIL_WIDTH = 98;
  8348. var TempImageFactory = function TempImageFactoryClosure() {
  8349. var tempCanvasCache = null;
  8350. return {
  8351. getCanvas: function getCanvas(width, height) {
  8352. var tempCanvas = tempCanvasCache;
  8353. if (!tempCanvas) {
  8354. tempCanvas = document.createElement("canvas");
  8355. tempCanvasCache = tempCanvas;
  8356. }
  8357. tempCanvas.width = width;
  8358. tempCanvas.height = height;
  8359. tempCanvas.mozOpaque = true;
  8360. var ctx = tempCanvas.getContext("2d", {
  8361. alpha: false
  8362. });
  8363. ctx.save();
  8364. ctx.fillStyle = "rgb(255, 255, 255)";
  8365. ctx.fillRect(0, 0, width, height);
  8366. ctx.restore();
  8367. return tempCanvas;
  8368. },
  8369. destroyCanvas: function destroyCanvas() {
  8370. var tempCanvas = tempCanvasCache;
  8371. if (tempCanvas) {
  8372. tempCanvas.width = 0;
  8373. tempCanvas.height = 0;
  8374. }
  8375. tempCanvasCache = null;
  8376. }
  8377. };
  8378. }();
  8379. var PDFThumbnailView = /*#__PURE__*/function () {
  8380. function PDFThumbnailView(_ref) {
  8381. var container = _ref.container,
  8382. id = _ref.id,
  8383. defaultViewport = _ref.defaultViewport,
  8384. linkService = _ref.linkService,
  8385. renderingQueue = _ref.renderingQueue,
  8386. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  8387. disableCanvasToImageConversion = _ref$disableCanvasToI === void 0 ? false : _ref$disableCanvasToI,
  8388. _ref$l10n = _ref.l10n,
  8389. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  8390. _classCallCheck(this, PDFThumbnailView);
  8391. this.id = id;
  8392. this.renderingId = "thumbnail" + id;
  8393. this.pageLabel = null;
  8394. this.pdfPage = null;
  8395. this.rotation = 0;
  8396. this.viewport = defaultViewport;
  8397. this.pdfPageRotate = defaultViewport.rotation;
  8398. this.linkService = linkService;
  8399. this.renderingQueue = renderingQueue;
  8400. this.renderTask = null;
  8401. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8402. this.resume = null;
  8403. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  8404. this.pageWidth = this.viewport.width;
  8405. this.pageHeight = this.viewport.height;
  8406. this.pageRatio = this.pageWidth / this.pageHeight;
  8407. this.canvasWidth = THUMBNAIL_WIDTH;
  8408. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  8409. this.scale = this.canvasWidth / this.pageWidth;
  8410. this.l10n = l10n;
  8411. var anchor = document.createElement("a");
  8412. anchor.href = linkService.getAnchorUrl("#page=" + id);
  8413. this._thumbPageTitle.then(function (msg) {
  8414. anchor.title = msg;
  8415. });
  8416. anchor.onclick = function () {
  8417. linkService.page = id;
  8418. return false;
  8419. };
  8420. this.anchor = anchor;
  8421. var div = document.createElement("div");
  8422. div.className = "thumbnail";
  8423. div.setAttribute("data-page-number", this.id);
  8424. this.div = div;
  8425. var ring = document.createElement("div");
  8426. ring.className = "thumbnailSelectionRing";
  8427. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8428. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  8429. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  8430. this.ring = ring;
  8431. div.appendChild(ring);
  8432. anchor.appendChild(div);
  8433. container.appendChild(anchor);
  8434. }
  8435. _createClass(PDFThumbnailView, [{
  8436. key: "setPdfPage",
  8437. value: function setPdfPage(pdfPage) {
  8438. this.pdfPage = pdfPage;
  8439. this.pdfPageRotate = pdfPage.rotate;
  8440. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8441. this.viewport = pdfPage.getViewport({
  8442. scale: 1,
  8443. rotation: totalRotation
  8444. });
  8445. this.reset();
  8446. }
  8447. }, {
  8448. key: "reset",
  8449. value: function reset() {
  8450. this.cancelRendering();
  8451. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8452. this.pageWidth = this.viewport.width;
  8453. this.pageHeight = this.viewport.height;
  8454. this.pageRatio = this.pageWidth / this.pageHeight;
  8455. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  8456. this.scale = this.canvasWidth / this.pageWidth;
  8457. this.div.removeAttribute("data-loaded");
  8458. var ring = this.ring;
  8459. var childNodes = ring.childNodes;
  8460. for (var i = childNodes.length - 1; i >= 0; i--) {
  8461. ring.removeChild(childNodes[i]);
  8462. }
  8463. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8464. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  8465. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  8466. if (this.canvas) {
  8467. this.canvas.width = 0;
  8468. this.canvas.height = 0;
  8469. delete this.canvas;
  8470. }
  8471. if (this.image) {
  8472. this.image.removeAttribute("src");
  8473. delete this.image;
  8474. }
  8475. }
  8476. }, {
  8477. key: "update",
  8478. value: function update(rotation) {
  8479. if (typeof rotation !== "undefined") {
  8480. this.rotation = rotation;
  8481. }
  8482. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8483. this.viewport = this.viewport.clone({
  8484. scale: 1,
  8485. rotation: totalRotation
  8486. });
  8487. this.reset();
  8488. }
  8489. }, {
  8490. key: "cancelRendering",
  8491. value: function cancelRendering() {
  8492. if (this.renderTask) {
  8493. this.renderTask.cancel();
  8494. this.renderTask = null;
  8495. }
  8496. this.resume = null;
  8497. }
  8498. }, {
  8499. key: "_getPageDrawContext",
  8500. value: function _getPageDrawContext() {
  8501. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8502. var canvas = document.createElement("canvas");
  8503. this.canvas = canvas;
  8504. canvas.mozOpaque = true;
  8505. var ctx = canvas.getContext("2d", {
  8506. alpha: false
  8507. });
  8508. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  8509. canvas.width = this.canvasWidth * outputScale.sx | 0;
  8510. canvas.height = this.canvasHeight * outputScale.sy | 0;
  8511. canvas.style.width = this.canvasWidth + "px";
  8512. canvas.style.height = this.canvasHeight + "px";
  8513. if (!noCtxScale && outputScale.scaled) {
  8514. ctx.scale(outputScale.sx, outputScale.sy);
  8515. }
  8516. return ctx;
  8517. }
  8518. }, {
  8519. key: "_convertCanvasToImage",
  8520. value: function _convertCanvasToImage() {
  8521. var _this = this;
  8522. if (!this.canvas) {
  8523. return;
  8524. }
  8525. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8526. return;
  8527. }
  8528. var className = "thumbnailImage";
  8529. if (this.disableCanvasToImageConversion) {
  8530. this.canvas.className = className;
  8531. this._thumbPageCanvas.then(function (msg) {
  8532. _this.canvas.setAttribute("aria-label", msg);
  8533. });
  8534. this.div.setAttribute("data-loaded", true);
  8535. this.ring.appendChild(this.canvas);
  8536. return;
  8537. }
  8538. var image = document.createElement("img");
  8539. image.className = className;
  8540. this._thumbPageCanvas.then(function (msg) {
  8541. image.setAttribute("aria-label", msg);
  8542. });
  8543. image.style.width = this.canvasWidth + "px";
  8544. image.style.height = this.canvasHeight + "px";
  8545. image.src = this.canvas.toDataURL();
  8546. this.image = image;
  8547. this.div.setAttribute("data-loaded", true);
  8548. this.ring.appendChild(image);
  8549. this.canvas.width = 0;
  8550. this.canvas.height = 0;
  8551. delete this.canvas;
  8552. }
  8553. }, {
  8554. key: "draw",
  8555. value: function draw() {
  8556. var _this2 = this;
  8557. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8558. console.error("Must be in new state before drawing");
  8559. return Promise.resolve(undefined);
  8560. }
  8561. var pdfPage = this.pdfPage;
  8562. if (!pdfPage) {
  8563. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8564. return Promise.reject(new Error("pdfPage is not loaded"));
  8565. }
  8566. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8567. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  8568. var finishRenderTask = function finishRenderTask(error) {
  8569. if (renderTask === _this2.renderTask) {
  8570. _this2.renderTask = null;
  8571. }
  8572. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  8573. renderCapability.resolve(undefined);
  8574. return;
  8575. }
  8576. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8577. _this2._convertCanvasToImage();
  8578. if (!error) {
  8579. renderCapability.resolve(undefined);
  8580. } else {
  8581. renderCapability.reject(error);
  8582. }
  8583. };
  8584. var ctx = this._getPageDrawContext();
  8585. var drawViewport = this.viewport.clone({
  8586. scale: this.scale
  8587. });
  8588. var renderContinueCallback = function renderContinueCallback(cont) {
  8589. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  8590. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  8591. _this2.resume = function () {
  8592. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8593. cont();
  8594. };
  8595. return;
  8596. }
  8597. cont();
  8598. };
  8599. var renderContext = {
  8600. canvasContext: ctx,
  8601. viewport: drawViewport
  8602. };
  8603. var renderTask = this.renderTask = pdfPage.render(renderContext);
  8604. renderTask.onContinue = renderContinueCallback;
  8605. renderTask.promise.then(function () {
  8606. finishRenderTask(null);
  8607. }, function (error) {
  8608. finishRenderTask(error);
  8609. });
  8610. return renderCapability.promise;
  8611. }
  8612. }, {
  8613. key: "setImage",
  8614. value: function setImage(pageView) {
  8615. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8616. return;
  8617. }
  8618. var img = pageView.canvas;
  8619. if (!img) {
  8620. return;
  8621. }
  8622. if (!this.pdfPage) {
  8623. this.setPdfPage(pageView.pdfPage);
  8624. }
  8625. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8626. var ctx = this._getPageDrawContext(true);
  8627. var canvas = ctx.canvas;
  8628. if (img.width <= 2 * canvas.width) {
  8629. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  8630. this._convertCanvasToImage();
  8631. return;
  8632. }
  8633. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  8634. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  8635. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  8636. var reducedImageCtx = reducedImage.getContext("2d");
  8637. while (reducedWidth > img.width || reducedHeight > img.height) {
  8638. reducedWidth >>= 1;
  8639. reducedHeight >>= 1;
  8640. }
  8641. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  8642. while (reducedWidth > 2 * canvas.width) {
  8643. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  8644. reducedWidth >>= 1;
  8645. reducedHeight >>= 1;
  8646. }
  8647. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  8648. this._convertCanvasToImage();
  8649. }
  8650. }, {
  8651. key: "setPageLabel",
  8652. value: function setPageLabel(label) {
  8653. var _this3 = this;
  8654. this.pageLabel = typeof label === "string" ? label : null;
  8655. this._thumbPageTitle.then(function (msg) {
  8656. _this3.anchor.title = msg;
  8657. });
  8658. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8659. return;
  8660. }
  8661. this._thumbPageCanvas.then(function (msg) {
  8662. if (_this3.image) {
  8663. _this3.image.setAttribute("aria-label", msg);
  8664. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  8665. _this3.canvas.setAttribute("aria-label", msg);
  8666. }
  8667. });
  8668. }
  8669. }, {
  8670. key: "_thumbPageTitle",
  8671. get: function get() {
  8672. return this.l10n.get("thumb_page_title", {
  8673. page: this.pageLabel !== null ? this.pageLabel : this.id
  8674. }, "Page {{page}}");
  8675. }
  8676. }, {
  8677. key: "_thumbPageCanvas",
  8678. get: function get() {
  8679. return this.l10n.get("thumb_page_canvas", {
  8680. page: this.pageLabel !== null ? this.pageLabel : this.id
  8681. }, "Thumbnail of Page {{page}}");
  8682. }
  8683. }], [{
  8684. key: "cleanup",
  8685. value: function cleanup() {
  8686. TempImageFactory.destroyCanvas();
  8687. }
  8688. }]);
  8689. return PDFThumbnailView;
  8690. }();
  8691. exports.PDFThumbnailView = PDFThumbnailView;
  8692. /***/ }),
  8693. /* 27 */
  8694. /***/ (function(module, exports, __webpack_require__) {
  8695. "use strict";
  8696. Object.defineProperty(exports, "__esModule", {
  8697. value: true
  8698. });
  8699. exports.PDFViewer = void 0;
  8700. var _base_viewer = __webpack_require__(28);
  8701. var _pdfjsLib = __webpack_require__(8);
  8702. 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); }
  8703. 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; } } }; }
  8704. 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); }
  8705. 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; }
  8706. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8707. 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); } }
  8708. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8709. 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); }
  8710. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  8711. 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); }
  8712. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8713. 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); }; }
  8714. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8715. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8716. 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; } }
  8717. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8718. var PDFViewer = /*#__PURE__*/function (_BaseViewer) {
  8719. _inherits(PDFViewer, _BaseViewer);
  8720. var _super = _createSuper(PDFViewer);
  8721. function PDFViewer() {
  8722. _classCallCheck(this, PDFViewer);
  8723. return _super.apply(this, arguments);
  8724. }
  8725. _createClass(PDFViewer, [{
  8726. key: "_scrollIntoView",
  8727. value: function _scrollIntoView(_ref) {
  8728. var pageDiv = _ref.pageDiv,
  8729. _ref$pageSpot = _ref.pageSpot,
  8730. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  8731. _ref$pageNumber = _ref.pageNumber,
  8732. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  8733. if (!pageSpot && !this.isInPresentationMode) {
  8734. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  8735. var right = left + pageDiv.clientWidth;
  8736. var _this$container = this.container,
  8737. scrollLeft = _this$container.scrollLeft,
  8738. clientWidth = _this$container.clientWidth;
  8739. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  8740. pageSpot = {
  8741. left: 0,
  8742. top: 0
  8743. };
  8744. }
  8745. }
  8746. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  8747. pageDiv: pageDiv,
  8748. pageSpot: pageSpot,
  8749. pageNumber: pageNumber
  8750. });
  8751. }
  8752. }, {
  8753. key: "_getVisiblePages",
  8754. value: function _getVisiblePages() {
  8755. if (this.isInPresentationMode) {
  8756. return this._getCurrentVisiblePage();
  8757. }
  8758. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  8759. }
  8760. }, {
  8761. key: "_updateHelper",
  8762. value: function _updateHelper(visiblePages) {
  8763. if (this.isInPresentationMode) {
  8764. return;
  8765. }
  8766. var currentId = this._currentPageNumber;
  8767. var stillFullyVisible = false;
  8768. var _iterator = _createForOfIteratorHelper(visiblePages),
  8769. _step;
  8770. try {
  8771. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8772. var page = _step.value;
  8773. if (page.percent < 100) {
  8774. break;
  8775. }
  8776. if (page.id === currentId) {
  8777. stillFullyVisible = true;
  8778. break;
  8779. }
  8780. }
  8781. } catch (err) {
  8782. _iterator.e(err);
  8783. } finally {
  8784. _iterator.f();
  8785. }
  8786. if (!stillFullyVisible) {
  8787. currentId = visiblePages[0].id;
  8788. }
  8789. this._setCurrentPageNumber(currentId);
  8790. }
  8791. }, {
  8792. key: "_viewerElement",
  8793. get: function get() {
  8794. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this.viewer);
  8795. }
  8796. }]);
  8797. return PDFViewer;
  8798. }(_base_viewer.BaseViewer);
  8799. exports.PDFViewer = PDFViewer;
  8800. /***/ }),
  8801. /* 28 */
  8802. /***/ (function(module, exports, __webpack_require__) {
  8803. "use strict";
  8804. Object.defineProperty(exports, "__esModule", {
  8805. value: true
  8806. });
  8807. exports.BaseViewer = void 0;
  8808. var _ui_utils = __webpack_require__(5);
  8809. var _pdf_rendering_queue = __webpack_require__(11);
  8810. var _annotation_layer_builder = __webpack_require__(29);
  8811. var _pdfjsLib = __webpack_require__(8);
  8812. var _pdf_page_view = __webpack_require__(30);
  8813. var _pdf_link_service = __webpack_require__(21);
  8814. var _text_layer_builder = __webpack_require__(31);
  8815. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8816. 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); } }
  8817. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8818. var DEFAULT_CACHE_SIZE = 10;
  8819. function PDFPageViewBuffer(size) {
  8820. var data = [];
  8821. this.push = function (view) {
  8822. var i = data.indexOf(view);
  8823. if (i >= 0) {
  8824. data.splice(i, 1);
  8825. }
  8826. data.push(view);
  8827. if (data.length > size) {
  8828. data.shift().destroy();
  8829. }
  8830. };
  8831. this.resize = function (newSize, pagesToKeep) {
  8832. size = newSize;
  8833. if (pagesToKeep) {
  8834. var pageIdsToKeep = new Set();
  8835. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  8836. pageIdsToKeep.add(pagesToKeep[i].id);
  8837. }
  8838. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  8839. return pageIdsToKeep.has(page.id);
  8840. });
  8841. }
  8842. while (data.length > size) {
  8843. data.shift().destroy();
  8844. }
  8845. };
  8846. }
  8847. function isSameScale(oldScale, newScale) {
  8848. if (newScale === oldScale) {
  8849. return true;
  8850. }
  8851. if (Math.abs(newScale - oldScale) < 1e-15) {
  8852. return true;
  8853. }
  8854. return false;
  8855. }
  8856. var BaseViewer = /*#__PURE__*/function () {
  8857. function BaseViewer(options) {
  8858. var _this = this;
  8859. _classCallCheck(this, BaseViewer);
  8860. if (this.constructor === BaseViewer) {
  8861. throw new Error("Cannot initialize BaseViewer.");
  8862. }
  8863. this._name = this.constructor.name;
  8864. this.container = options.container;
  8865. this.viewer = options.viewer || options.container.firstElementChild;
  8866. this.eventBus = options.eventBus;
  8867. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  8868. this.downloadManager = options.downloadManager || null;
  8869. this.findController = options.findController || null;
  8870. this.removePageBorders = options.removePageBorders || false;
  8871. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  8872. this.imageResourcesPath = options.imageResourcesPath || "";
  8873. this.renderInteractiveForms = options.renderInteractiveForms || false;
  8874. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  8875. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  8876. this.enableWebGL = options.enableWebGL || false;
  8877. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  8878. this.maxCanvasPixels = options.maxCanvasPixels;
  8879. this.l10n = options.l10n || _ui_utils.NullL10n;
  8880. this.defaultRenderingQueue = !options.renderingQueue;
  8881. if (this.defaultRenderingQueue) {
  8882. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  8883. this.renderingQueue.setViewer(this);
  8884. } else {
  8885. this.renderingQueue = options.renderingQueue;
  8886. }
  8887. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  8888. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  8889. this._onBeforeDraw = this._onAfterDraw = null;
  8890. this._resetView();
  8891. if (this.removePageBorders) {
  8892. this.viewer.classList.add("removePageBorders");
  8893. }
  8894. Promise.resolve().then(function () {
  8895. _this.eventBus.dispatch("baseviewerinit", {
  8896. source: _this
  8897. });
  8898. });
  8899. }
  8900. _createClass(BaseViewer, [{
  8901. key: "getPageView",
  8902. value: function getPageView(index) {
  8903. return this._pages[index];
  8904. }
  8905. }, {
  8906. key: "_setCurrentPageNumber",
  8907. value: function _setCurrentPageNumber(val) {
  8908. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8909. if (this._currentPageNumber === val) {
  8910. if (resetCurrentPageView) {
  8911. this._resetCurrentPageView();
  8912. }
  8913. return true;
  8914. }
  8915. if (!(0 < val && val <= this.pagesCount)) {
  8916. return false;
  8917. }
  8918. this._currentPageNumber = val;
  8919. this.eventBus.dispatch("pagechanging", {
  8920. source: this,
  8921. pageNumber: val,
  8922. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  8923. });
  8924. if (resetCurrentPageView) {
  8925. this._resetCurrentPageView();
  8926. }
  8927. return true;
  8928. }
  8929. }, {
  8930. key: "_onePageRenderedOrForceFetch",
  8931. value: function _onePageRenderedOrForceFetch() {
  8932. if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  8933. return Promise.resolve();
  8934. }
  8935. return this._onePageRenderedCapability.promise;
  8936. }
  8937. }, {
  8938. key: "setDocument",
  8939. value: function setDocument(pdfDocument) {
  8940. var _this2 = this;
  8941. if (this.pdfDocument) {
  8942. this._cancelRendering();
  8943. this._resetView();
  8944. if (this.findController) {
  8945. this.findController.setDocument(null);
  8946. }
  8947. }
  8948. this.pdfDocument = pdfDocument;
  8949. if (!pdfDocument) {
  8950. return;
  8951. }
  8952. var pagesCount = pdfDocument.numPages;
  8953. var firstPagePromise = pdfDocument.getPage(1);
  8954. this._pagesCapability.promise.then(function () {
  8955. _this2.eventBus.dispatch("pagesloaded", {
  8956. source: _this2,
  8957. pagesCount: pagesCount
  8958. });
  8959. });
  8960. this._onBeforeDraw = function (evt) {
  8961. var pageView = _this2._pages[evt.pageNumber - 1];
  8962. if (!pageView) {
  8963. return;
  8964. }
  8965. _this2._buffer.push(pageView);
  8966. };
  8967. this.eventBus._on("pagerender", this._onBeforeDraw);
  8968. this._onAfterDraw = function (evt) {
  8969. if (evt.cssTransform || _this2._onePageRenderedCapability.settled) {
  8970. return;
  8971. }
  8972. _this2._onePageRenderedCapability.resolve();
  8973. _this2.eventBus._off("pagerendered", _this2._onAfterDraw);
  8974. _this2._onAfterDraw = null;
  8975. };
  8976. this.eventBus._on("pagerendered", this._onAfterDraw);
  8977. firstPagePromise.then(function (firstPdfPage) {
  8978. _this2._firstPageCapability.resolve(firstPdfPage);
  8979. var scale = _this2.currentScale;
  8980. var viewport = firstPdfPage.getViewport({
  8981. scale: scale * _ui_utils.CSS_UNITS
  8982. });
  8983. var textLayerFactory = _this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? _this2 : null;
  8984. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8985. var pageView = new _pdf_page_view.PDFPageView({
  8986. container: _this2._viewerElement,
  8987. eventBus: _this2.eventBus,
  8988. id: pageNum,
  8989. scale: scale,
  8990. defaultViewport: viewport.clone(),
  8991. renderingQueue: _this2.renderingQueue,
  8992. textLayerFactory: textLayerFactory,
  8993. textLayerMode: _this2.textLayerMode,
  8994. annotationLayerFactory: _this2,
  8995. imageResourcesPath: _this2.imageResourcesPath,
  8996. renderInteractiveForms: _this2.renderInteractiveForms,
  8997. renderer: _this2.renderer,
  8998. enableWebGL: _this2.enableWebGL,
  8999. useOnlyCssZoom: _this2.useOnlyCssZoom,
  9000. maxCanvasPixels: _this2.maxCanvasPixels,
  9001. l10n: _this2.l10n
  9002. });
  9003. _this2._pages.push(pageView);
  9004. }
  9005. var firstPageView = _this2._pages[0];
  9006. if (firstPageView) {
  9007. firstPageView.setPdfPage(firstPdfPage);
  9008. _this2.linkService.cachePageRef(1, firstPdfPage.ref);
  9009. }
  9010. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  9011. _this2._updateSpreadMode();
  9012. }
  9013. _this2._onePageRenderedOrForceFetch().then(function () {
  9014. if (_this2.findController) {
  9015. _this2.findController.setDocument(pdfDocument);
  9016. }
  9017. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
  9018. _this2._pagesCapability.resolve();
  9019. return;
  9020. }
  9021. var getPagesLeft = pagesCount - 1;
  9022. if (getPagesLeft <= 0) {
  9023. _this2._pagesCapability.resolve();
  9024. return;
  9025. }
  9026. var _loop = function _loop(_pageNum) {
  9027. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  9028. var pageView = _this2._pages[_pageNum - 1];
  9029. if (!pageView.pdfPage) {
  9030. pageView.setPdfPage(pdfPage);
  9031. }
  9032. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  9033. if (--getPagesLeft === 0) {
  9034. _this2._pagesCapability.resolve();
  9035. }
  9036. }, function (reason) {
  9037. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  9038. if (--getPagesLeft === 0) {
  9039. _this2._pagesCapability.resolve();
  9040. }
  9041. });
  9042. };
  9043. for (var _pageNum = 2; _pageNum <= pagesCount; ++_pageNum) {
  9044. _loop(_pageNum);
  9045. }
  9046. });
  9047. _this2.eventBus.dispatch("pagesinit", {
  9048. source: _this2
  9049. });
  9050. if (_this2.defaultRenderingQueue) {
  9051. _this2.update();
  9052. }
  9053. })["catch"](function (reason) {
  9054. console.error("Unable to initialize viewer", reason);
  9055. });
  9056. }
  9057. }, {
  9058. key: "setPageLabels",
  9059. value: function setPageLabels(labels) {
  9060. if (!this.pdfDocument) {
  9061. return;
  9062. }
  9063. if (!labels) {
  9064. this._pageLabels = null;
  9065. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  9066. this._pageLabels = null;
  9067. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  9068. } else {
  9069. this._pageLabels = labels;
  9070. }
  9071. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9072. var pageView = this._pages[i];
  9073. var label = this._pageLabels && this._pageLabels[i];
  9074. pageView.setPageLabel(label);
  9075. }
  9076. }
  9077. }, {
  9078. key: "_resetView",
  9079. value: function _resetView() {
  9080. this._pages = [];
  9081. this._currentPageNumber = 1;
  9082. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  9083. this._currentScaleValue = null;
  9084. this._pageLabels = null;
  9085. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  9086. this._location = null;
  9087. this._pagesRotation = 0;
  9088. this._pagesRequests = new WeakMap();
  9089. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  9090. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  9091. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  9092. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  9093. this._spreadMode = _ui_utils.SpreadMode.NONE;
  9094. if (this._onBeforeDraw) {
  9095. this.eventBus._off("pagerender", this._onBeforeDraw);
  9096. this._onBeforeDraw = null;
  9097. }
  9098. if (this._onAfterDraw) {
  9099. this.eventBus._off("pagerendered", this._onAfterDraw);
  9100. this._onAfterDraw = null;
  9101. }
  9102. this.viewer.textContent = "";
  9103. this._updateScrollMode();
  9104. }
  9105. }, {
  9106. key: "_scrollUpdate",
  9107. value: function _scrollUpdate() {
  9108. if (this.pagesCount === 0) {
  9109. return;
  9110. }
  9111. this.update();
  9112. }
  9113. }, {
  9114. key: "_scrollIntoView",
  9115. value: function _scrollIntoView(_ref) {
  9116. var pageDiv = _ref.pageDiv,
  9117. _ref$pageSpot = _ref.pageSpot,
  9118. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  9119. _ref$pageNumber = _ref.pageNumber,
  9120. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  9121. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  9122. }
  9123. }, {
  9124. key: "_setScaleUpdatePages",
  9125. value: function _setScaleUpdatePages(newScale, newValue) {
  9126. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9127. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9128. this._currentScaleValue = newValue.toString();
  9129. if (isSameScale(this._currentScale, newScale)) {
  9130. if (preset) {
  9131. this.eventBus.dispatch("scalechanging", {
  9132. source: this,
  9133. scale: newScale,
  9134. presetValue: newValue
  9135. });
  9136. }
  9137. return;
  9138. }
  9139. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9140. this._pages[i].update(newScale);
  9141. }
  9142. this._currentScale = newScale;
  9143. if (!noScroll) {
  9144. var page = this._currentPageNumber,
  9145. dest;
  9146. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  9147. page = this._location.pageNumber;
  9148. dest = [null, {
  9149. name: "XYZ"
  9150. }, this._location.left, this._location.top, null];
  9151. }
  9152. this.scrollPageIntoView({
  9153. pageNumber: page,
  9154. destArray: dest,
  9155. allowNegativeOffset: true
  9156. });
  9157. }
  9158. this.eventBus.dispatch("scalechanging", {
  9159. source: this,
  9160. scale: newScale,
  9161. presetValue: preset ? newValue : undefined
  9162. });
  9163. if (this.defaultRenderingQueue) {
  9164. this.update();
  9165. }
  9166. }
  9167. }, {
  9168. key: "_setScale",
  9169. value: function _setScale(value) {
  9170. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9171. var scale = parseFloat(value);
  9172. if (scale > 0) {
  9173. this._setScaleUpdatePages(scale, value, noScroll, false);
  9174. } else {
  9175. var currentPage = this._pages[this._currentPageNumber - 1];
  9176. if (!currentPage) {
  9177. return;
  9178. }
  9179. var noPadding = this.isInPresentationMode || this.removePageBorders;
  9180. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  9181. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  9182. if (!noPadding && this._isScrollModeHorizontal) {
  9183. var _ref2 = [vPadding, hPadding];
  9184. hPadding = _ref2[0];
  9185. vPadding = _ref2[1];
  9186. }
  9187. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  9188. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  9189. switch (value) {
  9190. case "page-actual":
  9191. scale = 1;
  9192. break;
  9193. case "page-width":
  9194. scale = pageWidthScale;
  9195. break;
  9196. case "page-height":
  9197. scale = pageHeightScale;
  9198. break;
  9199. case "page-fit":
  9200. scale = Math.min(pageWidthScale, pageHeightScale);
  9201. break;
  9202. case "auto":
  9203. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  9204. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  9205. break;
  9206. default:
  9207. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  9208. return;
  9209. }
  9210. this._setScaleUpdatePages(scale, value, noScroll, true);
  9211. }
  9212. }
  9213. }, {
  9214. key: "_resetCurrentPageView",
  9215. value: function _resetCurrentPageView() {
  9216. if (this.isInPresentationMode) {
  9217. this._setScale(this._currentScaleValue, true);
  9218. }
  9219. var pageView = this._pages[this._currentPageNumber - 1];
  9220. this._scrollIntoView({
  9221. pageDiv: pageView.div
  9222. });
  9223. }
  9224. }, {
  9225. key: "scrollPageIntoView",
  9226. value: function scrollPageIntoView(_ref3) {
  9227. var pageNumber = _ref3.pageNumber,
  9228. _ref3$destArray = _ref3.destArray,
  9229. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  9230. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  9231. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf,
  9232. _ref3$ignoreDestinati = _ref3.ignoreDestinationZoom,
  9233. ignoreDestinationZoom = _ref3$ignoreDestinati === void 0 ? false : _ref3$ignoreDestinati;
  9234. if (!this.pdfDocument) {
  9235. return;
  9236. }
  9237. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  9238. if (!pageView) {
  9239. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  9240. return;
  9241. }
  9242. if (this.isInPresentationMode || !destArray) {
  9243. this._setCurrentPageNumber(pageNumber, true);
  9244. return;
  9245. }
  9246. var x = 0,
  9247. y = 0;
  9248. var width = 0,
  9249. height = 0,
  9250. widthScale,
  9251. heightScale;
  9252. var changeOrientation = pageView.rotation % 180 !== 0;
  9253. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  9254. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  9255. var scale = 0;
  9256. switch (destArray[1].name) {
  9257. case "XYZ":
  9258. x = destArray[2];
  9259. y = destArray[3];
  9260. scale = destArray[4];
  9261. x = x !== null ? x : 0;
  9262. y = y !== null ? y : pageHeight;
  9263. break;
  9264. case "Fit":
  9265. case "FitB":
  9266. scale = "page-fit";
  9267. break;
  9268. case "FitH":
  9269. case "FitBH":
  9270. y = destArray[2];
  9271. scale = "page-width";
  9272. if (y === null && this._location) {
  9273. x = this._location.left;
  9274. y = this._location.top;
  9275. }
  9276. break;
  9277. case "FitV":
  9278. case "FitBV":
  9279. x = destArray[2];
  9280. width = pageWidth;
  9281. height = pageHeight;
  9282. scale = "page-height";
  9283. break;
  9284. case "FitR":
  9285. x = destArray[2];
  9286. y = destArray[3];
  9287. width = destArray[4] - x;
  9288. height = destArray[5] - y;
  9289. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  9290. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  9291. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  9292. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  9293. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  9294. break;
  9295. default:
  9296. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  9297. return;
  9298. }
  9299. if (!ignoreDestinationZoom) {
  9300. if (scale && scale !== this._currentScale) {
  9301. this.currentScaleValue = scale;
  9302. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  9303. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  9304. }
  9305. }
  9306. if (scale === "page-fit" && !destArray[4]) {
  9307. this._scrollIntoView({
  9308. pageDiv: pageView.div,
  9309. pageNumber: pageNumber
  9310. });
  9311. return;
  9312. }
  9313. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  9314. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  9315. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  9316. if (!allowNegativeOffset) {
  9317. left = Math.max(left, 0);
  9318. top = Math.max(top, 0);
  9319. }
  9320. this._scrollIntoView({
  9321. pageDiv: pageView.div,
  9322. pageSpot: {
  9323. left: left,
  9324. top: top
  9325. },
  9326. pageNumber: pageNumber
  9327. });
  9328. }
  9329. }, {
  9330. key: "_updateLocation",
  9331. value: function _updateLocation(firstPage) {
  9332. var currentScale = this._currentScale;
  9333. var currentScaleValue = this._currentScaleValue;
  9334. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  9335. var pageNumber = firstPage.id;
  9336. var pdfOpenParams = "#page=" + pageNumber;
  9337. pdfOpenParams += "&zoom=" + normalizedScaleValue;
  9338. var currentPageView = this._pages[pageNumber - 1];
  9339. var container = this.container;
  9340. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  9341. var intLeft = Math.round(topLeft[0]);
  9342. var intTop = Math.round(topLeft[1]);
  9343. pdfOpenParams += "," + intLeft + "," + intTop;
  9344. this._location = {
  9345. pageNumber: pageNumber,
  9346. scale: normalizedScaleValue,
  9347. top: intTop,
  9348. left: intLeft,
  9349. rotation: this._pagesRotation,
  9350. pdfOpenParams: pdfOpenParams
  9351. };
  9352. }
  9353. }, {
  9354. key: "_updateHelper",
  9355. value: function _updateHelper(visiblePages) {
  9356. throw new Error("Not implemented: _updateHelper");
  9357. }
  9358. }, {
  9359. key: "update",
  9360. value: function update() {
  9361. var visible = this._getVisiblePages();
  9362. var visiblePages = visible.views,
  9363. numVisiblePages = visiblePages.length;
  9364. if (numVisiblePages === 0) {
  9365. return;
  9366. }
  9367. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  9368. this._buffer.resize(newCacheSize, visiblePages);
  9369. this.renderingQueue.renderHighestPriority(visible);
  9370. this._updateHelper(visiblePages);
  9371. this._updateLocation(visible.first);
  9372. this.eventBus.dispatch("updateviewarea", {
  9373. source: this,
  9374. location: this._location
  9375. });
  9376. }
  9377. }, {
  9378. key: "containsElement",
  9379. value: function containsElement(element) {
  9380. return this.container.contains(element);
  9381. }
  9382. }, {
  9383. key: "focus",
  9384. value: function focus() {
  9385. this.container.focus();
  9386. }
  9387. }, {
  9388. key: "_getCurrentVisiblePage",
  9389. value: function _getCurrentVisiblePage() {
  9390. if (!this.pagesCount) {
  9391. return {
  9392. views: []
  9393. };
  9394. }
  9395. var pageView = this._pages[this._currentPageNumber - 1];
  9396. var element = pageView.div;
  9397. var view = {
  9398. id: pageView.id,
  9399. x: element.offsetLeft + element.clientLeft,
  9400. y: element.offsetTop + element.clientTop,
  9401. view: pageView
  9402. };
  9403. return {
  9404. first: view,
  9405. last: view,
  9406. views: [view]
  9407. };
  9408. }
  9409. }, {
  9410. key: "_getVisiblePages",
  9411. value: function _getVisiblePages() {
  9412. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._isScrollModeHorizontal);
  9413. }
  9414. }, {
  9415. key: "isPageVisible",
  9416. value: function isPageVisible(pageNumber) {
  9417. if (!this.pdfDocument) {
  9418. return false;
  9419. }
  9420. if (pageNumber < 1 || pageNumber > this.pagesCount) {
  9421. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is out of bounds."));
  9422. return false;
  9423. }
  9424. return this._getVisiblePages().views.some(function (view) {
  9425. return view.id === pageNumber;
  9426. });
  9427. }
  9428. }, {
  9429. key: "cleanup",
  9430. value: function cleanup() {
  9431. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9432. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9433. this._pages[i].reset();
  9434. }
  9435. }
  9436. }
  9437. }, {
  9438. key: "_cancelRendering",
  9439. value: function _cancelRendering() {
  9440. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9441. if (this._pages[i]) {
  9442. this._pages[i].cancelRendering();
  9443. }
  9444. }
  9445. }
  9446. }, {
  9447. key: "_ensurePdfPageLoaded",
  9448. value: function _ensurePdfPageLoaded(pageView) {
  9449. var _this3 = this;
  9450. if (pageView.pdfPage) {
  9451. return Promise.resolve(pageView.pdfPage);
  9452. }
  9453. if (this._pagesRequests.has(pageView)) {
  9454. return this._pagesRequests.get(pageView);
  9455. }
  9456. var promise = this.pdfDocument.getPage(pageView.id).then(function (pdfPage) {
  9457. if (!pageView.pdfPage) {
  9458. pageView.setPdfPage(pdfPage);
  9459. }
  9460. _this3._pagesRequests["delete"](pageView);
  9461. return pdfPage;
  9462. })["catch"](function (reason) {
  9463. console.error("Unable to get page for page view", reason);
  9464. _this3._pagesRequests["delete"](pageView);
  9465. });
  9466. this._pagesRequests.set(pageView, promise);
  9467. return promise;
  9468. }
  9469. }, {
  9470. key: "forceRendering",
  9471. value: function forceRendering(currentlyVisiblePages) {
  9472. var _this4 = this;
  9473. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  9474. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  9475. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  9476. if (pageView) {
  9477. this._ensurePdfPageLoaded(pageView).then(function () {
  9478. _this4.renderingQueue.renderView(pageView);
  9479. });
  9480. return true;
  9481. }
  9482. return false;
  9483. }
  9484. }, {
  9485. key: "createTextLayerBuilder",
  9486. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  9487. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9488. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  9489. return new _text_layer_builder.TextLayerBuilder({
  9490. textLayerDiv: textLayerDiv,
  9491. eventBus: eventBus,
  9492. pageIndex: pageIndex,
  9493. viewport: viewport,
  9494. findController: this.isInPresentationMode ? null : this.findController,
  9495. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  9496. });
  9497. }
  9498. }, {
  9499. key: "createAnnotationLayerBuilder",
  9500. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9501. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
  9502. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9503. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  9504. return new _annotation_layer_builder.AnnotationLayerBuilder({
  9505. pageDiv: pageDiv,
  9506. pdfPage: pdfPage,
  9507. imageResourcesPath: imageResourcesPath,
  9508. renderInteractiveForms: renderInteractiveForms,
  9509. linkService: this.linkService,
  9510. downloadManager: this.downloadManager,
  9511. l10n: l10n
  9512. });
  9513. }
  9514. }, {
  9515. key: "getPagesOverview",
  9516. value: function getPagesOverview() {
  9517. var pagesOverview = this._pages.map(function (pageView) {
  9518. var viewport = pageView.pdfPage.getViewport({
  9519. scale: 1
  9520. });
  9521. return {
  9522. width: viewport.width,
  9523. height: viewport.height,
  9524. rotation: viewport.rotation
  9525. };
  9526. });
  9527. if (!this.enablePrintAutoRotate) {
  9528. return pagesOverview;
  9529. }
  9530. var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]);
  9531. return pagesOverview.map(function (size) {
  9532. if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) {
  9533. return size;
  9534. }
  9535. return {
  9536. width: size.height,
  9537. height: size.width,
  9538. rotation: (size.rotation + 90) % 360
  9539. };
  9540. });
  9541. }
  9542. }, {
  9543. key: "_updateScrollMode",
  9544. value: function _updateScrollMode() {
  9545. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9546. var scrollMode = this._scrollMode,
  9547. viewer = this.viewer;
  9548. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  9549. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  9550. if (!this.pdfDocument || !pageNumber) {
  9551. return;
  9552. }
  9553. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  9554. this._setScale(this._currentScaleValue, true);
  9555. }
  9556. this._setCurrentPageNumber(pageNumber, true);
  9557. this.update();
  9558. }
  9559. }, {
  9560. key: "_updateSpreadMode",
  9561. value: function _updateSpreadMode() {
  9562. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9563. if (!this.pdfDocument) {
  9564. return;
  9565. }
  9566. var viewer = this.viewer,
  9567. pages = this._pages;
  9568. viewer.textContent = "";
  9569. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  9570. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  9571. viewer.appendChild(pages[i].div);
  9572. }
  9573. } else {
  9574. var parity = this._spreadMode - 1;
  9575. var spread = null;
  9576. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  9577. if (spread === null) {
  9578. spread = document.createElement("div");
  9579. spread.className = "spread";
  9580. viewer.appendChild(spread);
  9581. } else if (_i % 2 === parity) {
  9582. spread = spread.cloneNode(false);
  9583. viewer.appendChild(spread);
  9584. }
  9585. spread.appendChild(pages[_i].div);
  9586. }
  9587. }
  9588. if (!pageNumber) {
  9589. return;
  9590. }
  9591. this._setCurrentPageNumber(pageNumber, true);
  9592. this.update();
  9593. }
  9594. }, {
  9595. key: "pagesCount",
  9596. get: function get() {
  9597. return this._pages.length;
  9598. }
  9599. }, {
  9600. key: "pageViewsReady",
  9601. get: function get() {
  9602. if (!this._pagesCapability.settled) {
  9603. return false;
  9604. }
  9605. return this._pages.every(function (pageView) {
  9606. return pageView && pageView.pdfPage;
  9607. });
  9608. }
  9609. }, {
  9610. key: "currentPageNumber",
  9611. get: function get() {
  9612. return this._currentPageNumber;
  9613. },
  9614. set: function set(val) {
  9615. if (!Number.isInteger(val)) {
  9616. throw new Error("Invalid page number.");
  9617. }
  9618. if (!this.pdfDocument) {
  9619. return;
  9620. }
  9621. if (!this._setCurrentPageNumber(val, true)) {
  9622. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  9623. }
  9624. }
  9625. }, {
  9626. key: "currentPageLabel",
  9627. get: function get() {
  9628. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  9629. },
  9630. set: function set(val) {
  9631. if (!this.pdfDocument) {
  9632. return;
  9633. }
  9634. var page = val | 0;
  9635. if (this._pageLabels) {
  9636. var i = this._pageLabels.indexOf(val);
  9637. if (i >= 0) {
  9638. page = i + 1;
  9639. }
  9640. }
  9641. if (!this._setCurrentPageNumber(page, true)) {
  9642. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  9643. }
  9644. }
  9645. }, {
  9646. key: "currentScale",
  9647. get: function get() {
  9648. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  9649. },
  9650. set: function set(val) {
  9651. if (isNaN(val)) {
  9652. throw new Error("Invalid numeric scale.");
  9653. }
  9654. if (!this.pdfDocument) {
  9655. return;
  9656. }
  9657. this._setScale(val, false);
  9658. }
  9659. }, {
  9660. key: "currentScaleValue",
  9661. get: function get() {
  9662. return this._currentScaleValue;
  9663. },
  9664. set: function set(val) {
  9665. if (!this.pdfDocument) {
  9666. return;
  9667. }
  9668. this._setScale(val, false);
  9669. }
  9670. }, {
  9671. key: "pagesRotation",
  9672. get: function get() {
  9673. return this._pagesRotation;
  9674. },
  9675. set: function set(rotation) {
  9676. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  9677. throw new Error("Invalid pages rotation angle.");
  9678. }
  9679. if (!this.pdfDocument) {
  9680. return;
  9681. }
  9682. if (this._pagesRotation === rotation) {
  9683. return;
  9684. }
  9685. this._pagesRotation = rotation;
  9686. var pageNumber = this._currentPageNumber;
  9687. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9688. var pageView = this._pages[i];
  9689. pageView.update(pageView.scale, rotation);
  9690. }
  9691. if (this._currentScaleValue) {
  9692. this._setScale(this._currentScaleValue, true);
  9693. }
  9694. this.eventBus.dispatch("rotationchanging", {
  9695. source: this,
  9696. pagesRotation: rotation,
  9697. pageNumber: pageNumber
  9698. });
  9699. if (this.defaultRenderingQueue) {
  9700. this.update();
  9701. }
  9702. }
  9703. }, {
  9704. key: "firstPagePromise",
  9705. get: function get() {
  9706. return this.pdfDocument ? this._firstPageCapability.promise : null;
  9707. }
  9708. }, {
  9709. key: "onePageRendered",
  9710. get: function get() {
  9711. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  9712. }
  9713. }, {
  9714. key: "pagesPromise",
  9715. get: function get() {
  9716. return this.pdfDocument ? this._pagesCapability.promise : null;
  9717. }
  9718. }, {
  9719. key: "_viewerElement",
  9720. get: function get() {
  9721. throw new Error("Not implemented: _viewerElement");
  9722. }
  9723. }, {
  9724. key: "_isScrollModeHorizontal",
  9725. get: function get() {
  9726. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  9727. }
  9728. }, {
  9729. key: "isInPresentationMode",
  9730. get: function get() {
  9731. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  9732. }
  9733. }, {
  9734. key: "isChangingPresentationMode",
  9735. get: function get() {
  9736. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  9737. }
  9738. }, {
  9739. key: "isHorizontalScrollbarEnabled",
  9740. get: function get() {
  9741. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  9742. }
  9743. }, {
  9744. key: "isVerticalScrollbarEnabled",
  9745. get: function get() {
  9746. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  9747. }
  9748. }, {
  9749. key: "hasEqualPageSizes",
  9750. get: function get() {
  9751. var firstPageView = this._pages[0];
  9752. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  9753. var pageView = this._pages[i];
  9754. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  9755. return false;
  9756. }
  9757. }
  9758. return true;
  9759. }
  9760. }, {
  9761. key: "scrollMode",
  9762. get: function get() {
  9763. return this._scrollMode;
  9764. },
  9765. set: function set(mode) {
  9766. if (this._scrollMode === mode) {
  9767. return;
  9768. }
  9769. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  9770. throw new Error("Invalid scroll mode: ".concat(mode));
  9771. }
  9772. this._scrollMode = mode;
  9773. this.eventBus.dispatch("scrollmodechanged", {
  9774. source: this,
  9775. mode: mode
  9776. });
  9777. this._updateScrollMode(this._currentPageNumber);
  9778. }
  9779. }, {
  9780. key: "spreadMode",
  9781. get: function get() {
  9782. return this._spreadMode;
  9783. },
  9784. set: function set(mode) {
  9785. if (this._spreadMode === mode) {
  9786. return;
  9787. }
  9788. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  9789. throw new Error("Invalid spread mode: ".concat(mode));
  9790. }
  9791. this._spreadMode = mode;
  9792. this.eventBus.dispatch("spreadmodechanged", {
  9793. source: this,
  9794. mode: mode
  9795. });
  9796. this._updateSpreadMode(this._currentPageNumber);
  9797. }
  9798. }]);
  9799. return BaseViewer;
  9800. }();
  9801. exports.BaseViewer = BaseViewer;
  9802. /***/ }),
  9803. /* 29 */
  9804. /***/ (function(module, exports, __webpack_require__) {
  9805. "use strict";
  9806. Object.defineProperty(exports, "__esModule", {
  9807. value: true
  9808. });
  9809. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  9810. var _pdfjsLib = __webpack_require__(8);
  9811. var _ui_utils = __webpack_require__(5);
  9812. var _pdf_link_service = __webpack_require__(21);
  9813. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9814. 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); } }
  9815. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9816. var AnnotationLayerBuilder = /*#__PURE__*/function () {
  9817. function AnnotationLayerBuilder(_ref) {
  9818. var pageDiv = _ref.pageDiv,
  9819. pdfPage = _ref.pdfPage,
  9820. linkService = _ref.linkService,
  9821. downloadManager = _ref.downloadManager,
  9822. _ref$imageResourcesPa = _ref.imageResourcesPath,
  9823. imageResourcesPath = _ref$imageResourcesPa === void 0 ? "" : _ref$imageResourcesPa,
  9824. _ref$renderInteractiv = _ref.renderInteractiveForms,
  9825. renderInteractiveForms = _ref$renderInteractiv === void 0 ? false : _ref$renderInteractiv,
  9826. _ref$l10n = _ref.l10n,
  9827. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9828. _classCallCheck(this, AnnotationLayerBuilder);
  9829. this.pageDiv = pageDiv;
  9830. this.pdfPage = pdfPage;
  9831. this.linkService = linkService;
  9832. this.downloadManager = downloadManager;
  9833. this.imageResourcesPath = imageResourcesPath;
  9834. this.renderInteractiveForms = renderInteractiveForms;
  9835. this.l10n = l10n;
  9836. this.div = null;
  9837. this._cancelled = false;
  9838. }
  9839. _createClass(AnnotationLayerBuilder, [{
  9840. key: "render",
  9841. value: function render(viewport) {
  9842. var _this = this;
  9843. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  9844. this.pdfPage.getAnnotations({
  9845. intent: intent
  9846. }).then(function (annotations) {
  9847. if (_this._cancelled) {
  9848. return;
  9849. }
  9850. var parameters = {
  9851. viewport: viewport.clone({
  9852. dontFlip: true
  9853. }),
  9854. div: _this.div,
  9855. annotations: annotations,
  9856. page: _this.pdfPage,
  9857. imageResourcesPath: _this.imageResourcesPath,
  9858. renderInteractiveForms: _this.renderInteractiveForms,
  9859. linkService: _this.linkService,
  9860. downloadManager: _this.downloadManager
  9861. };
  9862. if (_this.div) {
  9863. _pdfjsLib.AnnotationLayer.update(parameters);
  9864. } else {
  9865. if (annotations.length === 0) {
  9866. return;
  9867. }
  9868. _this.div = document.createElement("div");
  9869. _this.div.className = "annotationLayer";
  9870. _this.pageDiv.appendChild(_this.div);
  9871. parameters.div = _this.div;
  9872. _pdfjsLib.AnnotationLayer.render(parameters);
  9873. _this.l10n.translate(_this.div);
  9874. }
  9875. });
  9876. }
  9877. }, {
  9878. key: "cancel",
  9879. value: function cancel() {
  9880. this._cancelled = true;
  9881. }
  9882. }, {
  9883. key: "hide",
  9884. value: function hide() {
  9885. if (!this.div) {
  9886. return;
  9887. }
  9888. this.div.setAttribute("hidden", "true");
  9889. }
  9890. }]);
  9891. return AnnotationLayerBuilder;
  9892. }();
  9893. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  9894. var DefaultAnnotationLayerFactory = /*#__PURE__*/function () {
  9895. function DefaultAnnotationLayerFactory() {
  9896. _classCallCheck(this, DefaultAnnotationLayerFactory);
  9897. }
  9898. _createClass(DefaultAnnotationLayerFactory, [{
  9899. key: "createAnnotationLayerBuilder",
  9900. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9901. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
  9902. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9903. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  9904. return new AnnotationLayerBuilder({
  9905. pageDiv: pageDiv,
  9906. pdfPage: pdfPage,
  9907. imageResourcesPath: imageResourcesPath,
  9908. renderInteractiveForms: renderInteractiveForms,
  9909. linkService: new _pdf_link_service.SimpleLinkService(),
  9910. l10n: l10n
  9911. });
  9912. }
  9913. }]);
  9914. return DefaultAnnotationLayerFactory;
  9915. }();
  9916. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  9917. /***/ }),
  9918. /* 30 */
  9919. /***/ (function(module, exports, __webpack_require__) {
  9920. "use strict";
  9921. Object.defineProperty(exports, "__esModule", {
  9922. value: true
  9923. });
  9924. exports.PDFPageView = void 0;
  9925. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  9926. var _ui_utils = __webpack_require__(5);
  9927. var _pdfjsLib = __webpack_require__(8);
  9928. var _pdf_rendering_queue = __webpack_require__(11);
  9929. var _viewer_compatibility = __webpack_require__(7);
  9930. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9931. 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); } }
  9932. 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); }); }; }
  9933. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9934. 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); } }
  9935. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9936. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  9937. var PDFPageView = /*#__PURE__*/function () {
  9938. function PDFPageView(options) {
  9939. _classCallCheck(this, PDFPageView);
  9940. var container = options.container;
  9941. var defaultViewport = options.defaultViewport;
  9942. this.id = options.id;
  9943. this.renderingId = "page" + this.id;
  9944. this.pdfPage = null;
  9945. this.pageLabel = null;
  9946. this.rotation = 0;
  9947. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  9948. this.viewport = defaultViewport;
  9949. this.pdfPageRotate = defaultViewport.rotation;
  9950. this.hasRestrictedScaling = false;
  9951. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  9952. this.imageResourcesPath = options.imageResourcesPath || "";
  9953. this.renderInteractiveForms = options.renderInteractiveForms || false;
  9954. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  9955. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  9956. this.eventBus = options.eventBus;
  9957. this.renderingQueue = options.renderingQueue;
  9958. this.textLayerFactory = options.textLayerFactory;
  9959. this.annotationLayerFactory = options.annotationLayerFactory;
  9960. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  9961. this.enableWebGL = options.enableWebGL || false;
  9962. this.l10n = options.l10n || _ui_utils.NullL10n;
  9963. this.paintTask = null;
  9964. this.paintedViewportMap = new WeakMap();
  9965. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9966. this.resume = null;
  9967. this.error = null;
  9968. this.annotationLayer = null;
  9969. this.textLayer = null;
  9970. this.zoomLayer = null;
  9971. var div = document.createElement("div");
  9972. div.className = "page";
  9973. div.style.width = Math.floor(this.viewport.width) + "px";
  9974. div.style.height = Math.floor(this.viewport.height) + "px";
  9975. div.setAttribute("data-page-number", this.id);
  9976. this.div = div;
  9977. container.appendChild(div);
  9978. }
  9979. _createClass(PDFPageView, [{
  9980. key: "setPdfPage",
  9981. value: function setPdfPage(pdfPage) {
  9982. this.pdfPage = pdfPage;
  9983. this.pdfPageRotate = pdfPage.rotate;
  9984. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9985. this.viewport = pdfPage.getViewport({
  9986. scale: this.scale * _ui_utils.CSS_UNITS,
  9987. rotation: totalRotation
  9988. });
  9989. this.stats = pdfPage.stats;
  9990. this.reset();
  9991. }
  9992. }, {
  9993. key: "destroy",
  9994. value: function destroy() {
  9995. this.reset();
  9996. if (this.pdfPage) {
  9997. this.pdfPage.cleanup();
  9998. }
  9999. }
  10000. }, {
  10001. key: "_resetZoomLayer",
  10002. value: function _resetZoomLayer() {
  10003. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10004. if (!this.zoomLayer) {
  10005. return;
  10006. }
  10007. var zoomLayerCanvas = this.zoomLayer.firstChild;
  10008. this.paintedViewportMap["delete"](zoomLayerCanvas);
  10009. zoomLayerCanvas.width = 0;
  10010. zoomLayerCanvas.height = 0;
  10011. if (removeFromDOM) {
  10012. this.zoomLayer.remove();
  10013. }
  10014. this.zoomLayer = null;
  10015. }
  10016. }, {
  10017. key: "reset",
  10018. value: function reset() {
  10019. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10020. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10021. this.cancelRendering(keepAnnotations);
  10022. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  10023. var div = this.div;
  10024. div.style.width = Math.floor(this.viewport.width) + "px";
  10025. div.style.height = Math.floor(this.viewport.height) + "px";
  10026. var childNodes = div.childNodes;
  10027. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  10028. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  10029. for (var i = childNodes.length - 1; i >= 0; i--) {
  10030. var node = childNodes[i];
  10031. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  10032. continue;
  10033. }
  10034. div.removeChild(node);
  10035. }
  10036. div.removeAttribute("data-loaded");
  10037. if (currentAnnotationNode) {
  10038. this.annotationLayer.hide();
  10039. } else if (this.annotationLayer) {
  10040. this.annotationLayer.cancel();
  10041. this.annotationLayer = null;
  10042. }
  10043. if (!currentZoomLayerNode) {
  10044. if (this.canvas) {
  10045. this.paintedViewportMap["delete"](this.canvas);
  10046. this.canvas.width = 0;
  10047. this.canvas.height = 0;
  10048. delete this.canvas;
  10049. }
  10050. this._resetZoomLayer();
  10051. }
  10052. if (this.svg) {
  10053. this.paintedViewportMap["delete"](this.svg);
  10054. delete this.svg;
  10055. }
  10056. this.loadingIconDiv = document.createElement("div");
  10057. this.loadingIconDiv.className = "loadingIcon";
  10058. div.appendChild(this.loadingIconDiv);
  10059. }
  10060. }, {
  10061. key: "update",
  10062. value: function update(scale, rotation) {
  10063. this.scale = scale || this.scale;
  10064. if (typeof rotation !== "undefined") {
  10065. this.rotation = rotation;
  10066. }
  10067. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10068. this.viewport = this.viewport.clone({
  10069. scale: this.scale * _ui_utils.CSS_UNITS,
  10070. rotation: totalRotation
  10071. });
  10072. if (this.svg) {
  10073. this.cssTransform(this.svg, true);
  10074. this.eventBus.dispatch("pagerendered", {
  10075. source: this,
  10076. pageNumber: this.id,
  10077. cssTransform: true,
  10078. timestamp: performance.now()
  10079. });
  10080. return;
  10081. }
  10082. var isScalingRestricted = false;
  10083. if (this.canvas && this.maxCanvasPixels > 0) {
  10084. var outputScale = this.outputScale;
  10085. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  10086. isScalingRestricted = true;
  10087. }
  10088. }
  10089. if (this.canvas) {
  10090. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  10091. this.cssTransform(this.canvas, true);
  10092. this.eventBus.dispatch("pagerendered", {
  10093. source: this,
  10094. pageNumber: this.id,
  10095. cssTransform: true,
  10096. timestamp: performance.now()
  10097. });
  10098. return;
  10099. }
  10100. if (!this.zoomLayer && !this.canvas.hasAttribute("hidden")) {
  10101. this.zoomLayer = this.canvas.parentNode;
  10102. this.zoomLayer.style.position = "absolute";
  10103. }
  10104. }
  10105. if (this.zoomLayer) {
  10106. this.cssTransform(this.zoomLayer.firstChild);
  10107. }
  10108. this.reset(true, true);
  10109. }
  10110. }, {
  10111. key: "cancelRendering",
  10112. value: function cancelRendering() {
  10113. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10114. if (this.paintTask) {
  10115. this.paintTask.cancel();
  10116. this.paintTask = null;
  10117. }
  10118. this.resume = null;
  10119. if (this.textLayer) {
  10120. this.textLayer.cancel();
  10121. this.textLayer = null;
  10122. }
  10123. if (!keepAnnotations && this.annotationLayer) {
  10124. this.annotationLayer.cancel();
  10125. this.annotationLayer = null;
  10126. }
  10127. }
  10128. }, {
  10129. key: "cssTransform",
  10130. value: function cssTransform(target) {
  10131. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10132. var width = this.viewport.width;
  10133. var height = this.viewport.height;
  10134. var div = this.div;
  10135. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
  10136. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
  10137. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  10138. var absRotation = Math.abs(relativeRotation);
  10139. var scaleX = 1,
  10140. scaleY = 1;
  10141. if (absRotation === 90 || absRotation === 270) {
  10142. scaleX = height / width;
  10143. scaleY = width / height;
  10144. }
  10145. var cssTransform = "rotate(" + relativeRotation + "deg) " + "scale(" + scaleX + "," + scaleY + ")";
  10146. target.style.transform = cssTransform;
  10147. if (this.textLayer) {
  10148. var textLayerViewport = this.textLayer.viewport;
  10149. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  10150. var textAbsRotation = Math.abs(textRelativeRotation);
  10151. var scale = width / textLayerViewport.width;
  10152. if (textAbsRotation === 90 || textAbsRotation === 270) {
  10153. scale = width / textLayerViewport.height;
  10154. }
  10155. var textLayerDiv = this.textLayer.textLayerDiv;
  10156. var transX, transY;
  10157. switch (textAbsRotation) {
  10158. case 0:
  10159. transX = transY = 0;
  10160. break;
  10161. case 90:
  10162. transX = 0;
  10163. transY = "-" + textLayerDiv.style.height;
  10164. break;
  10165. case 180:
  10166. transX = "-" + textLayerDiv.style.width;
  10167. transY = "-" + textLayerDiv.style.height;
  10168. break;
  10169. case 270:
  10170. transX = "-" + textLayerDiv.style.width;
  10171. transY = 0;
  10172. break;
  10173. default:
  10174. console.error("Bad rotation value.");
  10175. break;
  10176. }
  10177. textLayerDiv.style.transform = "rotate(" + textAbsRotation + "deg) " + "scale(" + scale + ", " + scale + ") " + "translate(" + transX + ", " + transY + ")";
  10178. textLayerDiv.style.transformOrigin = "0% 0%";
  10179. }
  10180. if (redrawAnnotations && this.annotationLayer) {
  10181. this.annotationLayer.render(this.viewport, "display");
  10182. }
  10183. }
  10184. }, {
  10185. key: "getPagePoint",
  10186. value: function getPagePoint(x, y) {
  10187. return this.viewport.convertToPdfPoint(x, y);
  10188. }
  10189. }, {
  10190. key: "draw",
  10191. value: function draw() {
  10192. var _this = this;
  10193. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  10194. console.error("Must be in new state before drawing");
  10195. this.reset();
  10196. }
  10197. var div = this.div,
  10198. pdfPage = this.pdfPage;
  10199. if (!pdfPage) {
  10200. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10201. if (this.loadingIconDiv) {
  10202. div.removeChild(this.loadingIconDiv);
  10203. delete this.loadingIconDiv;
  10204. }
  10205. return Promise.reject(new Error("pdfPage is not loaded"));
  10206. }
  10207. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10208. var canvasWrapper = document.createElement("div");
  10209. canvasWrapper.style.width = div.style.width;
  10210. canvasWrapper.style.height = div.style.height;
  10211. canvasWrapper.classList.add("canvasWrapper");
  10212. if (this.annotationLayer && this.annotationLayer.div) {
  10213. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  10214. } else {
  10215. div.appendChild(canvasWrapper);
  10216. }
  10217. var textLayer = null;
  10218. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  10219. var textLayerDiv = document.createElement("div");
  10220. textLayerDiv.className = "textLayer";
  10221. textLayerDiv.style.width = canvasWrapper.style.width;
  10222. textLayerDiv.style.height = canvasWrapper.style.height;
  10223. if (this.annotationLayer && this.annotationLayer.div) {
  10224. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  10225. } else {
  10226. div.appendChild(textLayerDiv);
  10227. }
  10228. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, this.eventBus);
  10229. }
  10230. this.textLayer = textLayer;
  10231. var renderContinueCallback = null;
  10232. if (this.renderingQueue) {
  10233. renderContinueCallback = function renderContinueCallback(cont) {
  10234. if (!_this.renderingQueue.isHighestPriority(_this)) {
  10235. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  10236. _this.resume = function () {
  10237. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10238. cont();
  10239. };
  10240. return;
  10241. }
  10242. cont();
  10243. };
  10244. }
  10245. var finishPaintTask = /*#__PURE__*/function () {
  10246. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(error) {
  10247. return _regenerator["default"].wrap(function _callee$(_context) {
  10248. while (1) {
  10249. switch (_context.prev = _context.next) {
  10250. case 0:
  10251. if (paintTask === _this.paintTask) {
  10252. _this.paintTask = null;
  10253. }
  10254. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  10255. _context.next = 4;
  10256. break;
  10257. }
  10258. _this.error = null;
  10259. return _context.abrupt("return");
  10260. case 4:
  10261. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10262. if (_this.loadingIconDiv) {
  10263. div.removeChild(_this.loadingIconDiv);
  10264. delete _this.loadingIconDiv;
  10265. }
  10266. _this._resetZoomLayer(true);
  10267. _this.error = error;
  10268. _this.stats = pdfPage.stats;
  10269. _this.eventBus.dispatch("pagerendered", {
  10270. source: _this,
  10271. pageNumber: _this.id,
  10272. cssTransform: false,
  10273. timestamp: performance.now()
  10274. });
  10275. if (!error) {
  10276. _context.next = 12;
  10277. break;
  10278. }
  10279. throw error;
  10280. case 12:
  10281. case "end":
  10282. return _context.stop();
  10283. }
  10284. }
  10285. }, _callee);
  10286. }));
  10287. return function finishPaintTask(_x) {
  10288. return _ref.apply(this, arguments);
  10289. };
  10290. }();
  10291. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  10292. paintTask.onRenderContinue = renderContinueCallback;
  10293. this.paintTask = paintTask;
  10294. var resultPromise = paintTask.promise.then(function () {
  10295. return finishPaintTask(null).then(function () {
  10296. if (textLayer) {
  10297. var readableStream = pdfPage.streamTextContent({
  10298. normalizeWhitespace: true
  10299. });
  10300. textLayer.setTextContentStream(readableStream);
  10301. textLayer.render();
  10302. }
  10303. });
  10304. }, function (reason) {
  10305. return finishPaintTask(reason);
  10306. });
  10307. if (this.annotationLayerFactory) {
  10308. if (!this.annotationLayer) {
  10309. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  10310. }
  10311. this.annotationLayer.render(this.viewport, "display");
  10312. }
  10313. div.setAttribute("data-loaded", true);
  10314. this.eventBus.dispatch("pagerender", {
  10315. source: this,
  10316. pageNumber: this.id
  10317. });
  10318. return resultPromise;
  10319. }
  10320. }, {
  10321. key: "paintOnCanvas",
  10322. value: function paintOnCanvas(canvasWrapper) {
  10323. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  10324. var result = {
  10325. promise: renderCapability.promise,
  10326. onRenderContinue: function onRenderContinue(cont) {
  10327. cont();
  10328. },
  10329. cancel: function cancel() {
  10330. renderTask.cancel();
  10331. }
  10332. };
  10333. var viewport = this.viewport;
  10334. var canvas = document.createElement("canvas");
  10335. this.l10n.get("page_canvas", {
  10336. page: this.id
  10337. }, "Page {{page}}").then(function (msg) {
  10338. canvas.setAttribute("aria-label", msg);
  10339. });
  10340. canvas.setAttribute("hidden", "hidden");
  10341. var isCanvasHidden = true;
  10342. var showCanvas = function showCanvas() {
  10343. if (isCanvasHidden) {
  10344. canvas.removeAttribute("hidden");
  10345. isCanvasHidden = false;
  10346. }
  10347. };
  10348. canvasWrapper.appendChild(canvas);
  10349. this.canvas = canvas;
  10350. canvas.mozOpaque = true;
  10351. var ctx = canvas.getContext("2d", {
  10352. alpha: false
  10353. });
  10354. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  10355. this.outputScale = outputScale;
  10356. if (this.useOnlyCssZoom) {
  10357. var actualSizeViewport = viewport.clone({
  10358. scale: _ui_utils.CSS_UNITS
  10359. });
  10360. outputScale.sx *= actualSizeViewport.width / viewport.width;
  10361. outputScale.sy *= actualSizeViewport.height / viewport.height;
  10362. outputScale.scaled = true;
  10363. }
  10364. if (this.maxCanvasPixels > 0) {
  10365. var pixelsInViewport = viewport.width * viewport.height;
  10366. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  10367. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  10368. outputScale.sx = maxScale;
  10369. outputScale.sy = maxScale;
  10370. outputScale.scaled = true;
  10371. this.hasRestrictedScaling = true;
  10372. } else {
  10373. this.hasRestrictedScaling = false;
  10374. }
  10375. }
  10376. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  10377. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  10378. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  10379. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  10380. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
  10381. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
  10382. this.paintedViewportMap.set(canvas, viewport);
  10383. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  10384. var renderContext = {
  10385. canvasContext: ctx,
  10386. transform: transform,
  10387. viewport: this.viewport,
  10388. enableWebGL: this.enableWebGL,
  10389. renderInteractiveForms: this.renderInteractiveForms
  10390. };
  10391. var renderTask = this.pdfPage.render(renderContext);
  10392. renderTask.onContinue = function (cont) {
  10393. showCanvas();
  10394. if (result.onRenderContinue) {
  10395. result.onRenderContinue(cont);
  10396. } else {
  10397. cont();
  10398. }
  10399. };
  10400. renderTask.promise.then(function () {
  10401. showCanvas();
  10402. renderCapability.resolve(undefined);
  10403. }, function (error) {
  10404. showCanvas();
  10405. renderCapability.reject(error);
  10406. });
  10407. return result;
  10408. }
  10409. }, {
  10410. key: "paintOnSvg",
  10411. value: function paintOnSvg(wrapper) {
  10412. var _this2 = this;
  10413. var cancelled = false;
  10414. var ensureNotCancelled = function ensureNotCancelled() {
  10415. if (cancelled) {
  10416. throw new _pdfjsLib.RenderingCancelledException("Rendering cancelled, page ".concat(_this2.id), "svg");
  10417. }
  10418. };
  10419. var pdfPage = this.pdfPage;
  10420. var actualSizeViewport = this.viewport.clone({
  10421. scale: _ui_utils.CSS_UNITS
  10422. });
  10423. var promise = pdfPage.getOperatorList().then(function (opList) {
  10424. ensureNotCancelled();
  10425. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  10426. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  10427. ensureNotCancelled();
  10428. _this2.svg = svg;
  10429. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  10430. svg.style.width = wrapper.style.width;
  10431. svg.style.height = wrapper.style.height;
  10432. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10433. wrapper.appendChild(svg);
  10434. });
  10435. });
  10436. return {
  10437. promise: promise,
  10438. onRenderContinue: function onRenderContinue(cont) {
  10439. cont();
  10440. },
  10441. cancel: function cancel() {
  10442. cancelled = true;
  10443. }
  10444. };
  10445. }
  10446. }, {
  10447. key: "setPageLabel",
  10448. value: function setPageLabel(label) {
  10449. this.pageLabel = typeof label === "string" ? label : null;
  10450. if (this.pageLabel !== null) {
  10451. this.div.setAttribute("data-page-label", this.pageLabel);
  10452. } else {
  10453. this.div.removeAttribute("data-page-label");
  10454. }
  10455. }
  10456. }, {
  10457. key: "width",
  10458. get: function get() {
  10459. return this.viewport.width;
  10460. }
  10461. }, {
  10462. key: "height",
  10463. get: function get() {
  10464. return this.viewport.height;
  10465. }
  10466. }]);
  10467. return PDFPageView;
  10468. }();
  10469. exports.PDFPageView = PDFPageView;
  10470. /***/ }),
  10471. /* 31 */
  10472. /***/ (function(module, exports, __webpack_require__) {
  10473. "use strict";
  10474. Object.defineProperty(exports, "__esModule", {
  10475. value: true
  10476. });
  10477. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
  10478. var _pdfjsLib = __webpack_require__(8);
  10479. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10480. 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); } }
  10481. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10482. var EXPAND_DIVS_TIMEOUT = 300;
  10483. var TextLayerBuilder = /*#__PURE__*/function () {
  10484. function TextLayerBuilder(_ref) {
  10485. var textLayerDiv = _ref.textLayerDiv,
  10486. eventBus = _ref.eventBus,
  10487. pageIndex = _ref.pageIndex,
  10488. viewport = _ref.viewport,
  10489. _ref$findController = _ref.findController,
  10490. findController = _ref$findController === void 0 ? null : _ref$findController,
  10491. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  10492. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  10493. _classCallCheck(this, TextLayerBuilder);
  10494. this.textLayerDiv = textLayerDiv;
  10495. this.eventBus = eventBus;
  10496. this.textContent = null;
  10497. this.textContentItemsStr = [];
  10498. this.textContentStream = null;
  10499. this.renderingDone = false;
  10500. this.pageIdx = pageIndex;
  10501. this.pageNumber = this.pageIdx + 1;
  10502. this.matches = [];
  10503. this.viewport = viewport;
  10504. this.textDivs = [];
  10505. this.findController = findController;
  10506. this.textLayerRenderTask = null;
  10507. this.enhanceTextSelection = enhanceTextSelection;
  10508. this._onUpdateTextLayerMatches = null;
  10509. this._bindMouse();
  10510. }
  10511. _createClass(TextLayerBuilder, [{
  10512. key: "_finishRendering",
  10513. value: function _finishRendering() {
  10514. this.renderingDone = true;
  10515. if (!this.enhanceTextSelection) {
  10516. var endOfContent = document.createElement("div");
  10517. endOfContent.className = "endOfContent";
  10518. this.textLayerDiv.appendChild(endOfContent);
  10519. }
  10520. this.eventBus.dispatch("textlayerrendered", {
  10521. source: this,
  10522. pageNumber: this.pageNumber,
  10523. numTextDivs: this.textDivs.length
  10524. });
  10525. }
  10526. }, {
  10527. key: "render",
  10528. value: function render() {
  10529. var _this = this;
  10530. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10531. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  10532. return;
  10533. }
  10534. this.cancel();
  10535. this.textDivs = [];
  10536. var textLayerFrag = document.createDocumentFragment();
  10537. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  10538. textContent: this.textContent,
  10539. textContentStream: this.textContentStream,
  10540. container: textLayerFrag,
  10541. viewport: this.viewport,
  10542. textDivs: this.textDivs,
  10543. textContentItemsStr: this.textContentItemsStr,
  10544. timeout: timeout,
  10545. enhanceTextSelection: this.enhanceTextSelection
  10546. });
  10547. this.textLayerRenderTask.promise.then(function () {
  10548. _this.textLayerDiv.appendChild(textLayerFrag);
  10549. _this._finishRendering();
  10550. _this._updateMatches();
  10551. }, function (reason) {});
  10552. if (!this._onUpdateTextLayerMatches) {
  10553. this._onUpdateTextLayerMatches = function (evt) {
  10554. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  10555. _this._updateMatches();
  10556. }
  10557. };
  10558. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  10559. }
  10560. }
  10561. }, {
  10562. key: "cancel",
  10563. value: function cancel() {
  10564. if (this.textLayerRenderTask) {
  10565. this.textLayerRenderTask.cancel();
  10566. this.textLayerRenderTask = null;
  10567. }
  10568. if (this._onUpdateTextLayerMatches) {
  10569. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  10570. this._onUpdateTextLayerMatches = null;
  10571. }
  10572. }
  10573. }, {
  10574. key: "setTextContentStream",
  10575. value: function setTextContentStream(readableStream) {
  10576. this.cancel();
  10577. this.textContentStream = readableStream;
  10578. }
  10579. }, {
  10580. key: "setTextContent",
  10581. value: function setTextContent(textContent) {
  10582. this.cancel();
  10583. this.textContent = textContent;
  10584. }
  10585. }, {
  10586. key: "_convertMatches",
  10587. value: function _convertMatches(matches, matchesLength) {
  10588. if (!matches) {
  10589. return [];
  10590. }
  10591. var findController = this.findController,
  10592. textContentItemsStr = this.textContentItemsStr;
  10593. var i = 0,
  10594. iIndex = 0;
  10595. var end = textContentItemsStr.length - 1;
  10596. var queryLen = findController.state.query.length;
  10597. var result = [];
  10598. for (var m = 0, mm = matches.length; m < mm; m++) {
  10599. var matchIdx = matches[m];
  10600. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  10601. iIndex += textContentItemsStr[i].length;
  10602. i++;
  10603. }
  10604. if (i === textContentItemsStr.length) {
  10605. console.error("Could not find a matching mapping");
  10606. }
  10607. var match = {
  10608. begin: {
  10609. divIdx: i,
  10610. offset: matchIdx - iIndex
  10611. }
  10612. };
  10613. if (matchesLength) {
  10614. matchIdx += matchesLength[m];
  10615. } else {
  10616. matchIdx += queryLen;
  10617. }
  10618. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  10619. iIndex += textContentItemsStr[i].length;
  10620. i++;
  10621. }
  10622. match.end = {
  10623. divIdx: i,
  10624. offset: matchIdx - iIndex
  10625. };
  10626. result.push(match);
  10627. }
  10628. return result;
  10629. }
  10630. }, {
  10631. key: "_renderMatches",
  10632. value: function _renderMatches(matches) {
  10633. if (matches.length === 0) {
  10634. return;
  10635. }
  10636. var findController = this.findController,
  10637. pageIdx = this.pageIdx,
  10638. textContentItemsStr = this.textContentItemsStr,
  10639. textDivs = this.textDivs;
  10640. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  10641. var selectedMatchIdx = findController.selected.matchIdx;
  10642. var highlightAll = findController.state.highlightAll;
  10643. var prevEnd = null;
  10644. var infinity = {
  10645. divIdx: -1,
  10646. offset: undefined
  10647. };
  10648. function beginText(begin, className) {
  10649. var divIdx = begin.divIdx;
  10650. textDivs[divIdx].textContent = "";
  10651. appendTextToDiv(divIdx, 0, begin.offset, className);
  10652. }
  10653. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  10654. var div = textDivs[divIdx];
  10655. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  10656. var node = document.createTextNode(content);
  10657. if (className) {
  10658. var span = document.createElement("span");
  10659. span.className = className;
  10660. span.appendChild(node);
  10661. div.appendChild(span);
  10662. return;
  10663. }
  10664. div.appendChild(node);
  10665. }
  10666. var i0 = selectedMatchIdx,
  10667. i1 = i0 + 1;
  10668. if (highlightAll) {
  10669. i0 = 0;
  10670. i1 = matches.length;
  10671. } else if (!isSelectedPage) {
  10672. return;
  10673. }
  10674. for (var i = i0; i < i1; i++) {
  10675. var match = matches[i];
  10676. var begin = match.begin;
  10677. var end = match.end;
  10678. var isSelected = isSelectedPage && i === selectedMatchIdx;
  10679. var highlightSuffix = isSelected ? " selected" : "";
  10680. if (isSelected) {
  10681. findController.scrollMatchIntoView({
  10682. element: textDivs[begin.divIdx],
  10683. pageIndex: pageIdx,
  10684. matchIndex: selectedMatchIdx
  10685. });
  10686. }
  10687. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  10688. if (prevEnd !== null) {
  10689. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  10690. }
  10691. beginText(begin);
  10692. } else {
  10693. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  10694. }
  10695. if (begin.divIdx === end.divIdx) {
  10696. appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  10697. } else {
  10698. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  10699. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  10700. textDivs[n0].className = "highlight middle" + highlightSuffix;
  10701. }
  10702. beginText(end, "highlight end" + highlightSuffix);
  10703. }
  10704. prevEnd = end;
  10705. }
  10706. if (prevEnd) {
  10707. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  10708. }
  10709. }
  10710. }, {
  10711. key: "_updateMatches",
  10712. value: function _updateMatches() {
  10713. if (!this.renderingDone) {
  10714. return;
  10715. }
  10716. var findController = this.findController,
  10717. matches = this.matches,
  10718. pageIdx = this.pageIdx,
  10719. textContentItemsStr = this.textContentItemsStr,
  10720. textDivs = this.textDivs;
  10721. var clearedUntilDivIdx = -1;
  10722. for (var i = 0, ii = matches.length; i < ii; i++) {
  10723. var match = matches[i];
  10724. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  10725. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  10726. var div = textDivs[n];
  10727. div.textContent = textContentItemsStr[n];
  10728. div.className = "";
  10729. }
  10730. clearedUntilDivIdx = match.end.divIdx + 1;
  10731. }
  10732. if (!findController || !findController.highlightMatches) {
  10733. return;
  10734. }
  10735. var pageMatches = findController.pageMatches[pageIdx] || null;
  10736. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  10737. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  10738. this._renderMatches(this.matches);
  10739. }
  10740. }, {
  10741. key: "_bindMouse",
  10742. value: function _bindMouse() {
  10743. var _this2 = this;
  10744. var div = this.textLayerDiv;
  10745. var expandDivsTimer = null;
  10746. div.addEventListener("mousedown", function (evt) {
  10747. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  10748. _this2.textLayerRenderTask.expandTextDivs(true);
  10749. if (expandDivsTimer) {
  10750. clearTimeout(expandDivsTimer);
  10751. expandDivsTimer = null;
  10752. }
  10753. return;
  10754. }
  10755. var end = div.querySelector(".endOfContent");
  10756. if (!end) {
  10757. return;
  10758. }
  10759. var adjustTop = evt.target !== div;
  10760. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  10761. if (adjustTop) {
  10762. var divBounds = div.getBoundingClientRect();
  10763. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  10764. end.style.top = (r * 100).toFixed(2) + "%";
  10765. }
  10766. end.classList.add("active");
  10767. });
  10768. div.addEventListener("mouseup", function () {
  10769. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  10770. expandDivsTimer = setTimeout(function () {
  10771. if (_this2.textLayerRenderTask) {
  10772. _this2.textLayerRenderTask.expandTextDivs(false);
  10773. }
  10774. expandDivsTimer = null;
  10775. }, EXPAND_DIVS_TIMEOUT);
  10776. return;
  10777. }
  10778. var end = div.querySelector(".endOfContent");
  10779. if (!end) {
  10780. return;
  10781. }
  10782. end.style.top = "";
  10783. end.classList.remove("active");
  10784. });
  10785. }
  10786. }]);
  10787. return TextLayerBuilder;
  10788. }();
  10789. exports.TextLayerBuilder = TextLayerBuilder;
  10790. var DefaultTextLayerFactory = /*#__PURE__*/function () {
  10791. function DefaultTextLayerFactory() {
  10792. _classCallCheck(this, DefaultTextLayerFactory);
  10793. }
  10794. _createClass(DefaultTextLayerFactory, [{
  10795. key: "createTextLayerBuilder",
  10796. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  10797. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10798. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  10799. return new TextLayerBuilder({
  10800. textLayerDiv: textLayerDiv,
  10801. pageIndex: pageIndex,
  10802. viewport: viewport,
  10803. enhanceTextSelection: enhanceTextSelection,
  10804. eventBus: eventBus
  10805. });
  10806. }
  10807. }]);
  10808. return DefaultTextLayerFactory;
  10809. }();
  10810. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  10811. /***/ }),
  10812. /* 32 */
  10813. /***/ (function(module, exports, __webpack_require__) {
  10814. "use strict";
  10815. Object.defineProperty(exports, "__esModule", {
  10816. value: true
  10817. });
  10818. exports.SecondaryToolbar = void 0;
  10819. var _ui_utils = __webpack_require__(5);
  10820. var _pdf_cursor_tools = __webpack_require__(9);
  10821. var _pdf_single_page_viewer = __webpack_require__(33);
  10822. 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; } } }; }
  10823. 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); }
  10824. 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; }
  10825. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10826. 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); } }
  10827. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10828. var SecondaryToolbar = /*#__PURE__*/function () {
  10829. function SecondaryToolbar(options, mainContainer, eventBus) {
  10830. var _this = this;
  10831. _classCallCheck(this, SecondaryToolbar);
  10832. this.toolbar = options.toolbar;
  10833. this.toggleButton = options.toggleButton;
  10834. this.toolbarButtonContainer = options.toolbarButtonContainer;
  10835. this.buttons = [{
  10836. element: options.presentationModeButton,
  10837. eventName: "presentationmode",
  10838. close: true
  10839. }, {
  10840. element: options.openFileButton,
  10841. eventName: "openfile",
  10842. close: true
  10843. }, {
  10844. element: options.printButton,
  10845. eventName: "print",
  10846. close: true
  10847. }, {
  10848. element: options.downloadButton,
  10849. eventName: "download",
  10850. close: true
  10851. }, {
  10852. element: options.viewBookmarkButton,
  10853. eventName: null,
  10854. close: true
  10855. }, {
  10856. element: options.firstPageButton,
  10857. eventName: "firstpage",
  10858. close: true
  10859. }, {
  10860. element: options.lastPageButton,
  10861. eventName: "lastpage",
  10862. close: true
  10863. }, {
  10864. element: options.pageRotateCwButton,
  10865. eventName: "rotatecw",
  10866. close: false
  10867. }, {
  10868. element: options.pageRotateCcwButton,
  10869. eventName: "rotateccw",
  10870. close: false
  10871. }, {
  10872. element: options.cursorSelectToolButton,
  10873. eventName: "switchcursortool",
  10874. eventDetails: {
  10875. tool: _pdf_cursor_tools.CursorTool.SELECT
  10876. },
  10877. close: true
  10878. }, {
  10879. element: options.cursorHandToolButton,
  10880. eventName: "switchcursortool",
  10881. eventDetails: {
  10882. tool: _pdf_cursor_tools.CursorTool.HAND
  10883. },
  10884. close: true
  10885. }, {
  10886. element: options.scrollVerticalButton,
  10887. eventName: "switchscrollmode",
  10888. eventDetails: {
  10889. mode: _ui_utils.ScrollMode.VERTICAL
  10890. },
  10891. close: true
  10892. }, {
  10893. element: options.scrollHorizontalButton,
  10894. eventName: "switchscrollmode",
  10895. eventDetails: {
  10896. mode: _ui_utils.ScrollMode.HORIZONTAL
  10897. },
  10898. close: true
  10899. }, {
  10900. element: options.scrollWrappedButton,
  10901. eventName: "switchscrollmode",
  10902. eventDetails: {
  10903. mode: _ui_utils.ScrollMode.WRAPPED
  10904. },
  10905. close: true
  10906. }, {
  10907. element: options.spreadNoneButton,
  10908. eventName: "switchspreadmode",
  10909. eventDetails: {
  10910. mode: _ui_utils.SpreadMode.NONE
  10911. },
  10912. close: true
  10913. }, {
  10914. element: options.spreadOddButton,
  10915. eventName: "switchspreadmode",
  10916. eventDetails: {
  10917. mode: _ui_utils.SpreadMode.ODD
  10918. },
  10919. close: true
  10920. }, {
  10921. element: options.spreadEvenButton,
  10922. eventName: "switchspreadmode",
  10923. eventDetails: {
  10924. mode: _ui_utils.SpreadMode.EVEN
  10925. },
  10926. close: true
  10927. }, {
  10928. element: options.documentPropertiesButton,
  10929. eventName: "documentproperties",
  10930. close: true
  10931. }];
  10932. this.items = {
  10933. firstPage: options.firstPageButton,
  10934. lastPage: options.lastPageButton,
  10935. pageRotateCw: options.pageRotateCwButton,
  10936. pageRotateCcw: options.pageRotateCcwButton
  10937. };
  10938. this.mainContainer = mainContainer;
  10939. this.eventBus = eventBus;
  10940. this.opened = false;
  10941. this.containerHeight = null;
  10942. this.previousContainerHeight = null;
  10943. this.reset();
  10944. this._bindClickListeners();
  10945. this._bindCursorToolsListener(options);
  10946. this._bindScrollModeListener(options);
  10947. this._bindSpreadModeListener(options);
  10948. this.eventBus._on("resize", this._setMaxHeight.bind(this));
  10949. this.eventBus._on("baseviewerinit", function (evt) {
  10950. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  10951. _this.toolbarButtonContainer.classList.add("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  10952. } else {
  10953. _this.toolbarButtonContainer.classList.remove("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  10954. }
  10955. });
  10956. }
  10957. _createClass(SecondaryToolbar, [{
  10958. key: "setPageNumber",
  10959. value: function setPageNumber(pageNumber) {
  10960. this.pageNumber = pageNumber;
  10961. this._updateUIState();
  10962. }
  10963. }, {
  10964. key: "setPagesCount",
  10965. value: function setPagesCount(pagesCount) {
  10966. this.pagesCount = pagesCount;
  10967. this._updateUIState();
  10968. }
  10969. }, {
  10970. key: "reset",
  10971. value: function reset() {
  10972. this.pageNumber = 0;
  10973. this.pagesCount = 0;
  10974. this._updateUIState();
  10975. this.eventBus.dispatch("secondarytoolbarreset", {
  10976. source: this
  10977. });
  10978. }
  10979. }, {
  10980. key: "_updateUIState",
  10981. value: function _updateUIState() {
  10982. this.items.firstPage.disabled = this.pageNumber <= 1;
  10983. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  10984. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  10985. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  10986. }
  10987. }, {
  10988. key: "_bindClickListeners",
  10989. value: function _bindClickListeners() {
  10990. var _this2 = this;
  10991. this.toggleButton.addEventListener("click", this.toggle.bind(this));
  10992. var _iterator = _createForOfIteratorHelper(this.buttons),
  10993. _step;
  10994. try {
  10995. var _loop = function _loop() {
  10996. var _step$value = _step.value,
  10997. element = _step$value.element,
  10998. eventName = _step$value.eventName,
  10999. close = _step$value.close,
  11000. eventDetails = _step$value.eventDetails;
  11001. element.addEventListener("click", function (evt) {
  11002. if (eventName !== null) {
  11003. var details = {
  11004. source: _this2
  11005. };
  11006. for (var property in eventDetails) {
  11007. details[property] = eventDetails[property];
  11008. }
  11009. _this2.eventBus.dispatch(eventName, details);
  11010. }
  11011. if (close) {
  11012. _this2.close();
  11013. }
  11014. });
  11015. };
  11016. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11017. _loop();
  11018. }
  11019. } catch (err) {
  11020. _iterator.e(err);
  11021. } finally {
  11022. _iterator.f();
  11023. }
  11024. }
  11025. }, {
  11026. key: "_bindCursorToolsListener",
  11027. value: function _bindCursorToolsListener(buttons) {
  11028. this.eventBus._on("cursortoolchanged", function (_ref) {
  11029. var tool = _ref.tool;
  11030. buttons.cursorSelectToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.SELECT);
  11031. buttons.cursorHandToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.HAND);
  11032. });
  11033. }
  11034. }, {
  11035. key: "_bindScrollModeListener",
  11036. value: function _bindScrollModeListener(buttons) {
  11037. var _this3 = this;
  11038. function scrollModeChanged(_ref2) {
  11039. var mode = _ref2.mode;
  11040. buttons.scrollVerticalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.VERTICAL);
  11041. buttons.scrollHorizontalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.HORIZONTAL);
  11042. buttons.scrollWrappedButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.WRAPPED);
  11043. var isScrollModeHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
  11044. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  11045. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  11046. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  11047. }
  11048. this.eventBus._on("scrollmodechanged", scrollModeChanged);
  11049. this.eventBus._on("secondarytoolbarreset", function (evt) {
  11050. if (evt.source === _this3) {
  11051. scrollModeChanged({
  11052. mode: _ui_utils.ScrollMode.VERTICAL
  11053. });
  11054. }
  11055. });
  11056. }
  11057. }, {
  11058. key: "_bindSpreadModeListener",
  11059. value: function _bindSpreadModeListener(buttons) {
  11060. var _this4 = this;
  11061. function spreadModeChanged(_ref3) {
  11062. var mode = _ref3.mode;
  11063. buttons.spreadNoneButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.NONE);
  11064. buttons.spreadOddButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.ODD);
  11065. buttons.spreadEvenButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.EVEN);
  11066. }
  11067. this.eventBus._on("spreadmodechanged", spreadModeChanged);
  11068. this.eventBus._on("secondarytoolbarreset", function (evt) {
  11069. if (evt.source === _this4) {
  11070. spreadModeChanged({
  11071. mode: _ui_utils.SpreadMode.NONE
  11072. });
  11073. }
  11074. });
  11075. }
  11076. }, {
  11077. key: "open",
  11078. value: function open() {
  11079. if (this.opened) {
  11080. return;
  11081. }
  11082. this.opened = true;
  11083. this._setMaxHeight();
  11084. this.toggleButton.classList.add("toggled");
  11085. this.toolbar.classList.remove("hidden");
  11086. }
  11087. }, {
  11088. key: "close",
  11089. value: function close() {
  11090. if (!this.opened) {
  11091. return;
  11092. }
  11093. this.opened = false;
  11094. this.toolbar.classList.add("hidden");
  11095. this.toggleButton.classList.remove("toggled");
  11096. }
  11097. }, {
  11098. key: "toggle",
  11099. value: function toggle() {
  11100. if (this.opened) {
  11101. this.close();
  11102. } else {
  11103. this.open();
  11104. }
  11105. }
  11106. }, {
  11107. key: "_setMaxHeight",
  11108. value: function _setMaxHeight() {
  11109. if (!this.opened) {
  11110. return;
  11111. }
  11112. this.containerHeight = this.mainContainer.clientHeight;
  11113. if (this.containerHeight === this.previousContainerHeight) {
  11114. return;
  11115. }
  11116. this.toolbarButtonContainer.style.maxHeight = "".concat(this.containerHeight - _ui_utils.SCROLLBAR_PADDING, "px");
  11117. this.previousContainerHeight = this.containerHeight;
  11118. }
  11119. }, {
  11120. key: "isOpen",
  11121. get: function get() {
  11122. return this.opened;
  11123. }
  11124. }]);
  11125. return SecondaryToolbar;
  11126. }();
  11127. exports.SecondaryToolbar = SecondaryToolbar;
  11128. /***/ }),
  11129. /* 33 */
  11130. /***/ (function(module, exports, __webpack_require__) {
  11131. "use strict";
  11132. Object.defineProperty(exports, "__esModule", {
  11133. value: true
  11134. });
  11135. exports.PDFSinglePageViewer = void 0;
  11136. var _base_viewer = __webpack_require__(28);
  11137. var _pdfjsLib = __webpack_require__(8);
  11138. 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); }
  11139. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11140. 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); } }
  11141. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11142. 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); }
  11143. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  11144. 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); }
  11145. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11146. 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); }; }
  11147. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11148. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11149. 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; } }
  11150. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11151. var PDFSinglePageViewer = /*#__PURE__*/function (_BaseViewer) {
  11152. _inherits(PDFSinglePageViewer, _BaseViewer);
  11153. var _super = _createSuper(PDFSinglePageViewer);
  11154. function PDFSinglePageViewer(options) {
  11155. var _this;
  11156. _classCallCheck(this, PDFSinglePageViewer);
  11157. _this = _super.call(this, options);
  11158. _this.eventBus._on("pagesinit", function (evt) {
  11159. _this._ensurePageViewVisible();
  11160. });
  11161. return _this;
  11162. }
  11163. _createClass(PDFSinglePageViewer, [{
  11164. key: "_resetView",
  11165. value: function _resetView() {
  11166. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  11167. this._previousPageNumber = 1;
  11168. this._shadowViewer = document.createDocumentFragment();
  11169. this._updateScrollDown = null;
  11170. }
  11171. }, {
  11172. key: "_ensurePageViewVisible",
  11173. value: function _ensurePageViewVisible() {
  11174. var pageView = this._pages[this._currentPageNumber - 1];
  11175. var previousPageView = this._pages[this._previousPageNumber - 1];
  11176. var viewerNodes = this.viewer.childNodes;
  11177. switch (viewerNodes.length) {
  11178. case 0:
  11179. this.viewer.appendChild(pageView.div);
  11180. break;
  11181. case 1:
  11182. if (viewerNodes[0] !== previousPageView.div) {
  11183. throw new Error("_ensurePageViewVisible: Unexpected previously visible page.");
  11184. }
  11185. if (pageView === previousPageView) {
  11186. break;
  11187. }
  11188. this._shadowViewer.appendChild(previousPageView.div);
  11189. this.viewer.appendChild(pageView.div);
  11190. this.container.scrollTop = 0;
  11191. break;
  11192. default:
  11193. throw new Error("_ensurePageViewVisible: Only one page should be visible at a time.");
  11194. }
  11195. this._previousPageNumber = this._currentPageNumber;
  11196. }
  11197. }, {
  11198. key: "_scrollUpdate",
  11199. value: function _scrollUpdate() {
  11200. if (this._updateScrollDown) {
  11201. this._updateScrollDown();
  11202. }
  11203. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  11204. }
  11205. }, {
  11206. key: "_scrollIntoView",
  11207. value: function _scrollIntoView(_ref) {
  11208. var _this2 = this;
  11209. var pageDiv = _ref.pageDiv,
  11210. _ref$pageSpot = _ref.pageSpot,
  11211. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  11212. _ref$pageNumber = _ref.pageNumber,
  11213. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  11214. if (pageNumber) {
  11215. this._setCurrentPageNumber(pageNumber);
  11216. }
  11217. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  11218. this._ensurePageViewVisible();
  11219. this.update();
  11220. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  11221. pageDiv: pageDiv,
  11222. pageSpot: pageSpot,
  11223. pageNumber: pageNumber
  11224. });
  11225. this._updateScrollDown = function () {
  11226. _this2.scroll.down = scrolledDown;
  11227. _this2._updateScrollDown = null;
  11228. };
  11229. }
  11230. }, {
  11231. key: "_getVisiblePages",
  11232. value: function _getVisiblePages() {
  11233. return this._getCurrentVisiblePage();
  11234. }
  11235. }, {
  11236. key: "_updateHelper",
  11237. value: function _updateHelper(visiblePages) {}
  11238. }, {
  11239. key: "_updateScrollMode",
  11240. value: function _updateScrollMode() {}
  11241. }, {
  11242. key: "_updateSpreadMode",
  11243. value: function _updateSpreadMode() {}
  11244. }, {
  11245. key: "_viewerElement",
  11246. get: function get() {
  11247. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this._shadowViewer);
  11248. }
  11249. }, {
  11250. key: "_isScrollModeHorizontal",
  11251. get: function get() {
  11252. return (0, _pdfjsLib.shadow)(this, "_isScrollModeHorizontal", false);
  11253. }
  11254. }]);
  11255. return PDFSinglePageViewer;
  11256. }(_base_viewer.BaseViewer);
  11257. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  11258. /***/ }),
  11259. /* 34 */
  11260. /***/ (function(module, exports, __webpack_require__) {
  11261. "use strict";
  11262. Object.defineProperty(exports, "__esModule", {
  11263. value: true
  11264. });
  11265. exports.Toolbar = void 0;
  11266. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11267. var _ui_utils = __webpack_require__(5);
  11268. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11269. 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); } }
  11270. 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); }); }; }
  11271. 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; } } }; }
  11272. 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); }
  11273. 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; }
  11274. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11275. 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); } }
  11276. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11277. var PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
  11278. var SCALE_SELECT_CONTAINER_WIDTH = 140;
  11279. var SCALE_SELECT_WIDTH = 162;
  11280. var Toolbar = /*#__PURE__*/function () {
  11281. function Toolbar(options, eventBus) {
  11282. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  11283. _classCallCheck(this, Toolbar);
  11284. this.toolbar = options.container;
  11285. this.eventBus = eventBus;
  11286. this.l10n = l10n;
  11287. this.buttons = [{
  11288. element: options.previous,
  11289. eventName: "previouspage"
  11290. }, {
  11291. element: options.next,
  11292. eventName: "nextpage"
  11293. }, {
  11294. element: options.zoomIn,
  11295. eventName: "zoomin"
  11296. }, {
  11297. element: options.zoomOut,
  11298. eventName: "zoomout"
  11299. }, {
  11300. element: options.openFile,
  11301. eventName: "openfile"
  11302. }, {
  11303. element: options.print,
  11304. eventName: "print"
  11305. }, {
  11306. element: options.presentationModeButton,
  11307. eventName: "presentationmode"
  11308. }, {
  11309. element: options.download,
  11310. eventName: "download"
  11311. }, {
  11312. element: options.viewBookmark,
  11313. eventName: null
  11314. }];
  11315. this.items = {
  11316. numPages: options.numPages,
  11317. pageNumber: options.pageNumber,
  11318. scaleSelectContainer: options.scaleSelectContainer,
  11319. scaleSelect: options.scaleSelect,
  11320. customScaleOption: options.customScaleOption,
  11321. previous: options.previous,
  11322. next: options.next,
  11323. zoomIn: options.zoomIn,
  11324. zoomOut: options.zoomOut
  11325. };
  11326. this._wasLocalized = false;
  11327. this.reset();
  11328. this._bindListeners();
  11329. }
  11330. _createClass(Toolbar, [{
  11331. key: "setPageNumber",
  11332. value: function setPageNumber(pageNumber, pageLabel) {
  11333. this.pageNumber = pageNumber;
  11334. this.pageLabel = pageLabel;
  11335. this._updateUIState(false);
  11336. }
  11337. }, {
  11338. key: "setPagesCount",
  11339. value: function setPagesCount(pagesCount, hasPageLabels) {
  11340. this.pagesCount = pagesCount;
  11341. this.hasPageLabels = hasPageLabels;
  11342. this._updateUIState(true);
  11343. }
  11344. }, {
  11345. key: "setPageScale",
  11346. value: function setPageScale(pageScaleValue, pageScale) {
  11347. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  11348. this.pageScale = pageScale;
  11349. this._updateUIState(false);
  11350. }
  11351. }, {
  11352. key: "reset",
  11353. value: function reset() {
  11354. this.pageNumber = 0;
  11355. this.pageLabel = null;
  11356. this.hasPageLabels = false;
  11357. this.pagesCount = 0;
  11358. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  11359. this.pageScale = _ui_utils.DEFAULT_SCALE;
  11360. this._updateUIState(true);
  11361. this.updateLoadingIndicatorState();
  11362. }
  11363. }, {
  11364. key: "_bindListeners",
  11365. value: function _bindListeners() {
  11366. var _this = this;
  11367. var _this$items = this.items,
  11368. pageNumber = _this$items.pageNumber,
  11369. scaleSelect = _this$items.scaleSelect;
  11370. var self = this;
  11371. var _iterator = _createForOfIteratorHelper(this.buttons),
  11372. _step;
  11373. try {
  11374. var _loop = function _loop() {
  11375. var _step$value = _step.value,
  11376. element = _step$value.element,
  11377. eventName = _step$value.eventName;
  11378. element.addEventListener("click", function (evt) {
  11379. if (eventName !== null) {
  11380. _this.eventBus.dispatch(eventName, {
  11381. source: _this
  11382. });
  11383. }
  11384. });
  11385. };
  11386. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11387. _loop();
  11388. }
  11389. } catch (err) {
  11390. _iterator.e(err);
  11391. } finally {
  11392. _iterator.f();
  11393. }
  11394. pageNumber.addEventListener("click", function () {
  11395. this.select();
  11396. });
  11397. pageNumber.addEventListener("change", function () {
  11398. self.eventBus.dispatch("pagenumberchanged", {
  11399. source: self,
  11400. value: this.value
  11401. });
  11402. });
  11403. scaleSelect.addEventListener("change", function () {
  11404. if (this.value === "custom") {
  11405. return;
  11406. }
  11407. self.eventBus.dispatch("scalechanged", {
  11408. source: self,
  11409. value: this.value
  11410. });
  11411. });
  11412. scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  11413. this.eventBus._on("localized", function () {
  11414. _this._wasLocalized = true;
  11415. _this._adjustScaleWidth();
  11416. _this._updateUIState(true);
  11417. });
  11418. }
  11419. }, {
  11420. key: "_updateUIState",
  11421. value: function _updateUIState() {
  11422. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11423. if (!this._wasLocalized) {
  11424. return;
  11425. }
  11426. var pageNumber = this.pageNumber,
  11427. pagesCount = this.pagesCount,
  11428. pageScaleValue = this.pageScaleValue,
  11429. pageScale = this.pageScale,
  11430. items = this.items;
  11431. if (resetNumPages) {
  11432. if (this.hasPageLabels) {
  11433. items.pageNumber.type = "text";
  11434. } else {
  11435. items.pageNumber.type = "number";
  11436. this.l10n.get("of_pages", {
  11437. pagesCount: pagesCount
  11438. }, "of {{pagesCount}}").then(function (msg) {
  11439. items.numPages.textContent = msg;
  11440. });
  11441. }
  11442. items.pageNumber.max = pagesCount;
  11443. }
  11444. if (this.hasPageLabels) {
  11445. items.pageNumber.value = this.pageLabel;
  11446. this.l10n.get("page_of_pages", {
  11447. pageNumber: pageNumber,
  11448. pagesCount: pagesCount
  11449. }, "({{pageNumber}} of {{pagesCount}})").then(function (msg) {
  11450. items.numPages.textContent = msg;
  11451. });
  11452. } else {
  11453. items.pageNumber.value = pageNumber;
  11454. }
  11455. items.previous.disabled = pageNumber <= 1;
  11456. items.next.disabled = pageNumber >= pagesCount;
  11457. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  11458. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  11459. var customScale = Math.round(pageScale * 10000) / 100;
  11460. this.l10n.get("page_scale_percent", {
  11461. scale: customScale
  11462. }, "{{scale}}%").then(function (msg) {
  11463. var predefinedValueFound = false;
  11464. var _iterator2 = _createForOfIteratorHelper(items.scaleSelect.options),
  11465. _step2;
  11466. try {
  11467. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  11468. var option = _step2.value;
  11469. if (option.value !== pageScaleValue) {
  11470. option.selected = false;
  11471. continue;
  11472. }
  11473. option.selected = true;
  11474. predefinedValueFound = true;
  11475. }
  11476. } catch (err) {
  11477. _iterator2.e(err);
  11478. } finally {
  11479. _iterator2.f();
  11480. }
  11481. if (!predefinedValueFound) {
  11482. items.customScaleOption.textContent = msg;
  11483. items.customScaleOption.selected = true;
  11484. }
  11485. });
  11486. }
  11487. }, {
  11488. key: "updateLoadingIndicatorState",
  11489. value: function updateLoadingIndicatorState() {
  11490. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11491. var pageNumberInput = this.items.pageNumber;
  11492. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  11493. }
  11494. }, {
  11495. key: "_adjustScaleWidth",
  11496. value: function () {
  11497. var _adjustScaleWidth2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  11498. var items, l10n, predefinedValuesPromise, canvas, ctx, _getComputedStyle, fontSize, fontFamily, maxWidth, _iterator3, _step3, predefinedValue, _ctx$measureText, width, overflow;
  11499. return _regenerator["default"].wrap(function _callee$(_context) {
  11500. while (1) {
  11501. switch (_context.prev = _context.next) {
  11502. case 0:
  11503. items = this.items, l10n = this.l10n;
  11504. 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")]);
  11505. canvas = document.createElement("canvas");
  11506. canvas.mozOpaque = true;
  11507. ctx = canvas.getContext("2d", {
  11508. alpha: false
  11509. });
  11510. _context.next = 7;
  11511. return _ui_utils.animationStarted;
  11512. case 7:
  11513. _getComputedStyle = getComputedStyle(items.scaleSelect), fontSize = _getComputedStyle.fontSize, fontFamily = _getComputedStyle.fontFamily;
  11514. ctx.font = "".concat(fontSize, " ").concat(fontFamily);
  11515. maxWidth = 0;
  11516. _context.t0 = _createForOfIteratorHelper;
  11517. _context.next = 13;
  11518. return predefinedValuesPromise;
  11519. case 13:
  11520. _context.t1 = _context.sent;
  11521. _iterator3 = (0, _context.t0)(_context.t1);
  11522. try {
  11523. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  11524. predefinedValue = _step3.value;
  11525. _ctx$measureText = ctx.measureText(predefinedValue), width = _ctx$measureText.width;
  11526. if (width > maxWidth) {
  11527. maxWidth = width;
  11528. }
  11529. }
  11530. } catch (err) {
  11531. _iterator3.e(err);
  11532. } finally {
  11533. _iterator3.f();
  11534. }
  11535. overflow = SCALE_SELECT_WIDTH - SCALE_SELECT_CONTAINER_WIDTH;
  11536. maxWidth += 1.5 * overflow;
  11537. if (maxWidth > SCALE_SELECT_CONTAINER_WIDTH) {
  11538. items.scaleSelect.style.width = "".concat(maxWidth + overflow, "px");
  11539. items.scaleSelectContainer.style.width = "".concat(maxWidth, "px");
  11540. }
  11541. canvas.width = 0;
  11542. canvas.height = 0;
  11543. canvas = ctx = null;
  11544. case 22:
  11545. case "end":
  11546. return _context.stop();
  11547. }
  11548. }
  11549. }, _callee, this);
  11550. }));
  11551. function _adjustScaleWidth() {
  11552. return _adjustScaleWidth2.apply(this, arguments);
  11553. }
  11554. return _adjustScaleWidth;
  11555. }()
  11556. }]);
  11557. return Toolbar;
  11558. }();
  11559. exports.Toolbar = Toolbar;
  11560. /***/ }),
  11561. /* 35 */
  11562. /***/ (function(module, exports, __webpack_require__) {
  11563. "use strict";
  11564. Object.defineProperty(exports, "__esModule", {
  11565. value: true
  11566. });
  11567. exports.ViewHistory = void 0;
  11568. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11569. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11570. 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); } }
  11571. 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); }); }; }
  11572. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11573. 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); } }
  11574. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11575. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  11576. var ViewHistory = /*#__PURE__*/function () {
  11577. function ViewHistory(fingerprint) {
  11578. var _this = this;
  11579. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  11580. _classCallCheck(this, ViewHistory);
  11581. this.fingerprint = fingerprint;
  11582. this.cacheSize = cacheSize;
  11583. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  11584. var database = JSON.parse(databaseStr || "{}");
  11585. var index = -1;
  11586. if (!Array.isArray(database.files)) {
  11587. database.files = [];
  11588. } else {
  11589. while (database.files.length >= _this.cacheSize) {
  11590. database.files.shift();
  11591. }
  11592. for (var i = 0, ii = database.files.length; i < ii; i++) {
  11593. var branch = database.files[i];
  11594. if (branch.fingerprint === _this.fingerprint) {
  11595. index = i;
  11596. break;
  11597. }
  11598. }
  11599. }
  11600. if (index === -1) {
  11601. index = database.files.push({
  11602. fingerprint: _this.fingerprint
  11603. }) - 1;
  11604. }
  11605. _this.file = database.files[index];
  11606. _this.database = database;
  11607. });
  11608. }
  11609. _createClass(ViewHistory, [{
  11610. key: "_writeToStorage",
  11611. value: function () {
  11612. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  11613. var databaseStr;
  11614. return _regenerator["default"].wrap(function _callee$(_context) {
  11615. while (1) {
  11616. switch (_context.prev = _context.next) {
  11617. case 0:
  11618. databaseStr = JSON.stringify(this.database);
  11619. localStorage.setItem("pdfjs.history", databaseStr);
  11620. case 2:
  11621. case "end":
  11622. return _context.stop();
  11623. }
  11624. }
  11625. }, _callee, this);
  11626. }));
  11627. function _writeToStorage() {
  11628. return _writeToStorage2.apply(this, arguments);
  11629. }
  11630. return _writeToStorage;
  11631. }()
  11632. }, {
  11633. key: "_readFromStorage",
  11634. value: function () {
  11635. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  11636. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11637. while (1) {
  11638. switch (_context2.prev = _context2.next) {
  11639. case 0:
  11640. return _context2.abrupt("return", localStorage.getItem("pdfjs.history"));
  11641. case 1:
  11642. case "end":
  11643. return _context2.stop();
  11644. }
  11645. }
  11646. }, _callee2);
  11647. }));
  11648. function _readFromStorage() {
  11649. return _readFromStorage2.apply(this, arguments);
  11650. }
  11651. return _readFromStorage;
  11652. }()
  11653. }, {
  11654. key: "set",
  11655. value: function () {
  11656. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name, val) {
  11657. return _regenerator["default"].wrap(function _callee3$(_context3) {
  11658. while (1) {
  11659. switch (_context3.prev = _context3.next) {
  11660. case 0:
  11661. _context3.next = 2;
  11662. return this._initializedPromise;
  11663. case 2:
  11664. this.file[name] = val;
  11665. return _context3.abrupt("return", this._writeToStorage());
  11666. case 4:
  11667. case "end":
  11668. return _context3.stop();
  11669. }
  11670. }
  11671. }, _callee3, this);
  11672. }));
  11673. function set(_x, _x2) {
  11674. return _set.apply(this, arguments);
  11675. }
  11676. return set;
  11677. }()
  11678. }, {
  11679. key: "setMultiple",
  11680. value: function () {
  11681. var _setMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(properties) {
  11682. var name;
  11683. return _regenerator["default"].wrap(function _callee4$(_context4) {
  11684. while (1) {
  11685. switch (_context4.prev = _context4.next) {
  11686. case 0:
  11687. _context4.next = 2;
  11688. return this._initializedPromise;
  11689. case 2:
  11690. for (name in properties) {
  11691. this.file[name] = properties[name];
  11692. }
  11693. return _context4.abrupt("return", this._writeToStorage());
  11694. case 4:
  11695. case "end":
  11696. return _context4.stop();
  11697. }
  11698. }
  11699. }, _callee4, this);
  11700. }));
  11701. function setMultiple(_x3) {
  11702. return _setMultiple.apply(this, arguments);
  11703. }
  11704. return setMultiple;
  11705. }()
  11706. }, {
  11707. key: "get",
  11708. value: function () {
  11709. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name, defaultValue) {
  11710. var val;
  11711. return _regenerator["default"].wrap(function _callee5$(_context5) {
  11712. while (1) {
  11713. switch (_context5.prev = _context5.next) {
  11714. case 0:
  11715. _context5.next = 2;
  11716. return this._initializedPromise;
  11717. case 2:
  11718. val = this.file[name];
  11719. return _context5.abrupt("return", val !== undefined ? val : defaultValue);
  11720. case 4:
  11721. case "end":
  11722. return _context5.stop();
  11723. }
  11724. }
  11725. }, _callee5, this);
  11726. }));
  11727. function get(_x4, _x5) {
  11728. return _get.apply(this, arguments);
  11729. }
  11730. return get;
  11731. }()
  11732. }, {
  11733. key: "getMultiple",
  11734. value: function () {
  11735. var _getMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6(properties) {
  11736. var values, name, val;
  11737. return _regenerator["default"].wrap(function _callee6$(_context6) {
  11738. while (1) {
  11739. switch (_context6.prev = _context6.next) {
  11740. case 0:
  11741. _context6.next = 2;
  11742. return this._initializedPromise;
  11743. case 2:
  11744. values = Object.create(null);
  11745. for (name in properties) {
  11746. val = this.file[name];
  11747. values[name] = val !== undefined ? val : properties[name];
  11748. }
  11749. return _context6.abrupt("return", values);
  11750. case 5:
  11751. case "end":
  11752. return _context6.stop();
  11753. }
  11754. }
  11755. }, _callee6, this);
  11756. }));
  11757. function getMultiple(_x6) {
  11758. return _getMultiple.apply(this, arguments);
  11759. }
  11760. return getMultiple;
  11761. }()
  11762. }]);
  11763. return ViewHistory;
  11764. }();
  11765. exports.ViewHistory = ViewHistory;
  11766. /***/ }),
  11767. /* 36 */
  11768. /***/ (function(module, exports, __webpack_require__) {
  11769. "use strict";
  11770. Object.defineProperty(exports, "__esModule", {
  11771. value: true
  11772. });
  11773. exports.GenericCom = void 0;
  11774. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11775. var _app = __webpack_require__(1);
  11776. var _preferences = __webpack_require__(37);
  11777. var _download_manager = __webpack_require__(38);
  11778. var _genericl10n = __webpack_require__(39);
  11779. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11780. 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); }
  11781. 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); } }
  11782. 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); }); }; }
  11783. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11784. 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); } }
  11785. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11786. 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); }
  11787. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11788. 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); }; }
  11789. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11790. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11791. 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; } }
  11792. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11793. ;
  11794. var GenericCom = {};
  11795. exports.GenericCom = GenericCom;
  11796. var GenericPreferences = /*#__PURE__*/function (_BasePreferences) {
  11797. _inherits(GenericPreferences, _BasePreferences);
  11798. var _super = _createSuper(GenericPreferences);
  11799. function GenericPreferences() {
  11800. _classCallCheck(this, GenericPreferences);
  11801. return _super.apply(this, arguments);
  11802. }
  11803. _createClass(GenericPreferences, [{
  11804. key: "_writeToStorage",
  11805. value: function () {
  11806. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  11807. return _regenerator["default"].wrap(function _callee$(_context) {
  11808. while (1) {
  11809. switch (_context.prev = _context.next) {
  11810. case 0:
  11811. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  11812. case 1:
  11813. case "end":
  11814. return _context.stop();
  11815. }
  11816. }
  11817. }, _callee);
  11818. }));
  11819. function _writeToStorage(_x) {
  11820. return _writeToStorage2.apply(this, arguments);
  11821. }
  11822. return _writeToStorage;
  11823. }()
  11824. }, {
  11825. key: "_readFromStorage",
  11826. value: function () {
  11827. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  11828. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11829. while (1) {
  11830. switch (_context2.prev = _context2.next) {
  11831. case 0:
  11832. return _context2.abrupt("return", JSON.parse(localStorage.getItem("pdfjs.preferences")));
  11833. case 1:
  11834. case "end":
  11835. return _context2.stop();
  11836. }
  11837. }
  11838. }, _callee2);
  11839. }));
  11840. function _readFromStorage(_x2) {
  11841. return _readFromStorage2.apply(this, arguments);
  11842. }
  11843. return _readFromStorage;
  11844. }()
  11845. }]);
  11846. return GenericPreferences;
  11847. }(_preferences.BasePreferences);
  11848. var GenericExternalServices = /*#__PURE__*/function (_DefaultExternalServi) {
  11849. _inherits(GenericExternalServices, _DefaultExternalServi);
  11850. var _super2 = _createSuper(GenericExternalServices);
  11851. function GenericExternalServices() {
  11852. _classCallCheck(this, GenericExternalServices);
  11853. return _super2.apply(this, arguments);
  11854. }
  11855. _createClass(GenericExternalServices, null, [{
  11856. key: "createDownloadManager",
  11857. value: function createDownloadManager(options) {
  11858. return new _download_manager.DownloadManager(options);
  11859. }
  11860. }, {
  11861. key: "createPreferences",
  11862. value: function createPreferences() {
  11863. return new GenericPreferences();
  11864. }
  11865. }, {
  11866. key: "createL10n",
  11867. value: function createL10n(_ref) {
  11868. var _ref$locale = _ref.locale,
  11869. locale = _ref$locale === void 0 ? "en-US" : _ref$locale;
  11870. return new _genericl10n.GenericL10n(locale);
  11871. }
  11872. }]);
  11873. return GenericExternalServices;
  11874. }(_app.DefaultExternalServices);
  11875. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  11876. /***/ }),
  11877. /* 37 */
  11878. /***/ (function(module, exports, __webpack_require__) {
  11879. "use strict";
  11880. Object.defineProperty(exports, "__esModule", {
  11881. value: true
  11882. });
  11883. exports.BasePreferences = void 0;
  11884. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11885. var _app_options = __webpack_require__(6);
  11886. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11887. 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); } }
  11888. 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); }); }; }
  11889. 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); }
  11890. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11891. 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); } }
  11892. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11893. var defaultPreferences = null;
  11894. function getDefaultPreferences() {
  11895. if (!defaultPreferences) {
  11896. defaultPreferences = Promise.resolve({
  11897. "cursorToolOnLoad": 0,
  11898. "defaultZoomValue": "",
  11899. "disablePageLabels": false,
  11900. "enablePermissions": false,
  11901. "enablePrintAutoRotate": false,
  11902. "enableWebGL": false,
  11903. "externalLinkTarget": 0,
  11904. "historyUpdateUrl": false,
  11905. "ignoreDestinationZoom": false,
  11906. "pdfBugEnabled": false,
  11907. "renderer": "canvas",
  11908. "renderInteractiveForms": false,
  11909. "sidebarViewOnLoad": -1,
  11910. "scrollModeOnLoad": -1,
  11911. "spreadModeOnLoad": -1,
  11912. "textLayerMode": 1,
  11913. "useOnlyCssZoom": false,
  11914. "viewOnLoad": 0,
  11915. "disableAutoFetch": false,
  11916. "disableFontFace": false,
  11917. "disableRange": false,
  11918. "disableStream": false
  11919. });
  11920. }
  11921. return defaultPreferences;
  11922. }
  11923. var BasePreferences = /*#__PURE__*/function () {
  11924. function BasePreferences() {
  11925. var _this = this;
  11926. _classCallCheck(this, BasePreferences);
  11927. if (this.constructor === BasePreferences) {
  11928. throw new Error("Cannot initialize BasePreferences.");
  11929. }
  11930. this.prefs = null;
  11931. this._initializedPromise = getDefaultPreferences().then(function (defaults) {
  11932. Object.defineProperty(_this, "defaults", {
  11933. value: Object.freeze(defaults),
  11934. writable: false,
  11935. enumerable: true,
  11936. configurable: false
  11937. });
  11938. _this.prefs = Object.assign(Object.create(null), defaults);
  11939. return _this._readFromStorage(defaults);
  11940. }).then(function (prefs) {
  11941. if (!prefs) {
  11942. return;
  11943. }
  11944. for (var name in prefs) {
  11945. var defaultValue = _this.defaults[name],
  11946. prefValue = prefs[name];
  11947. if (defaultValue === undefined || _typeof(prefValue) !== _typeof(defaultValue)) {
  11948. continue;
  11949. }
  11950. _this.prefs[name] = prefValue;
  11951. }
  11952. });
  11953. }
  11954. _createClass(BasePreferences, [{
  11955. key: "_writeToStorage",
  11956. value: function () {
  11957. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  11958. return _regenerator["default"].wrap(function _callee$(_context) {
  11959. while (1) {
  11960. switch (_context.prev = _context.next) {
  11961. case 0:
  11962. throw new Error("Not implemented: _writeToStorage");
  11963. case 1:
  11964. case "end":
  11965. return _context.stop();
  11966. }
  11967. }
  11968. }, _callee);
  11969. }));
  11970. function _writeToStorage(_x) {
  11971. return _writeToStorage2.apply(this, arguments);
  11972. }
  11973. return _writeToStorage;
  11974. }()
  11975. }, {
  11976. key: "_readFromStorage",
  11977. value: function () {
  11978. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  11979. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11980. while (1) {
  11981. switch (_context2.prev = _context2.next) {
  11982. case 0:
  11983. throw new Error("Not implemented: _readFromStorage");
  11984. case 1:
  11985. case "end":
  11986. return _context2.stop();
  11987. }
  11988. }
  11989. }, _callee2);
  11990. }));
  11991. function _readFromStorage(_x2) {
  11992. return _readFromStorage2.apply(this, arguments);
  11993. }
  11994. return _readFromStorage;
  11995. }()
  11996. }, {
  11997. key: "reset",
  11998. value: function () {
  11999. var _reset = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  12000. return _regenerator["default"].wrap(function _callee3$(_context3) {
  12001. while (1) {
  12002. switch (_context3.prev = _context3.next) {
  12003. case 0:
  12004. _context3.next = 2;
  12005. return this._initializedPromise;
  12006. case 2:
  12007. this.prefs = Object.assign(Object.create(null), this.defaults);
  12008. return _context3.abrupt("return", this._writeToStorage(this.defaults));
  12009. case 4:
  12010. case "end":
  12011. return _context3.stop();
  12012. }
  12013. }
  12014. }, _callee3, this);
  12015. }));
  12016. function reset() {
  12017. return _reset.apply(this, arguments);
  12018. }
  12019. return reset;
  12020. }()
  12021. }, {
  12022. key: "set",
  12023. value: function () {
  12024. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name, value) {
  12025. var defaultValue, valueType, defaultType;
  12026. return _regenerator["default"].wrap(function _callee4$(_context4) {
  12027. while (1) {
  12028. switch (_context4.prev = _context4.next) {
  12029. case 0:
  12030. _context4.next = 2;
  12031. return this._initializedPromise;
  12032. case 2:
  12033. defaultValue = this.defaults[name];
  12034. if (!(defaultValue === undefined)) {
  12035. _context4.next = 7;
  12036. break;
  12037. }
  12038. throw new Error("Set preference: \"".concat(name, "\" is undefined."));
  12039. case 7:
  12040. if (!(value === undefined)) {
  12041. _context4.next = 9;
  12042. break;
  12043. }
  12044. throw new Error("Set preference: no value is specified.");
  12045. case 9:
  12046. valueType = _typeof(value);
  12047. defaultType = _typeof(defaultValue);
  12048. if (!(valueType !== defaultType)) {
  12049. _context4.next = 19;
  12050. break;
  12051. }
  12052. if (!(valueType === "number" && defaultType === "string")) {
  12053. _context4.next = 16;
  12054. break;
  12055. }
  12056. value = value.toString();
  12057. _context4.next = 17;
  12058. break;
  12059. case 16:
  12060. throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", ") + "expected a ".concat(defaultType, "."));
  12061. case 17:
  12062. _context4.next = 21;
  12063. break;
  12064. case 19:
  12065. if (!(valueType === "number" && !Number.isInteger(value))) {
  12066. _context4.next = 21;
  12067. break;
  12068. }
  12069. throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
  12070. case 21:
  12071. this.prefs[name] = value;
  12072. return _context4.abrupt("return", this._writeToStorage(this.prefs));
  12073. case 23:
  12074. case "end":
  12075. return _context4.stop();
  12076. }
  12077. }
  12078. }, _callee4, this);
  12079. }));
  12080. function set(_x3, _x4) {
  12081. return _set.apply(this, arguments);
  12082. }
  12083. return set;
  12084. }()
  12085. }, {
  12086. key: "get",
  12087. value: function () {
  12088. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name) {
  12089. var defaultValue, prefValue;
  12090. return _regenerator["default"].wrap(function _callee5$(_context5) {
  12091. while (1) {
  12092. switch (_context5.prev = _context5.next) {
  12093. case 0:
  12094. _context5.next = 2;
  12095. return this._initializedPromise;
  12096. case 2:
  12097. defaultValue = this.defaults[name];
  12098. if (!(defaultValue === undefined)) {
  12099. _context5.next = 7;
  12100. break;
  12101. }
  12102. throw new Error("Get preference: \"".concat(name, "\" is undefined."));
  12103. case 7:
  12104. prefValue = this.prefs[name];
  12105. if (!(prefValue !== undefined)) {
  12106. _context5.next = 10;
  12107. break;
  12108. }
  12109. return _context5.abrupt("return", prefValue);
  12110. case 10:
  12111. return _context5.abrupt("return", defaultValue);
  12112. case 11:
  12113. case "end":
  12114. return _context5.stop();
  12115. }
  12116. }
  12117. }, _callee5, this);
  12118. }));
  12119. function get(_x5) {
  12120. return _get.apply(this, arguments);
  12121. }
  12122. return get;
  12123. }()
  12124. }, {
  12125. key: "getAll",
  12126. value: function () {
  12127. var _getAll = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  12128. return _regenerator["default"].wrap(function _callee6$(_context6) {
  12129. while (1) {
  12130. switch (_context6.prev = _context6.next) {
  12131. case 0:
  12132. _context6.next = 2;
  12133. return this._initializedPromise;
  12134. case 2:
  12135. return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs));
  12136. case 3:
  12137. case "end":
  12138. return _context6.stop();
  12139. }
  12140. }
  12141. }, _callee6, this);
  12142. }));
  12143. function getAll() {
  12144. return _getAll.apply(this, arguments);
  12145. }
  12146. return getAll;
  12147. }()
  12148. }]);
  12149. return BasePreferences;
  12150. }();
  12151. exports.BasePreferences = BasePreferences;
  12152. /***/ }),
  12153. /* 38 */
  12154. /***/ (function(module, exports, __webpack_require__) {
  12155. "use strict";
  12156. Object.defineProperty(exports, "__esModule", {
  12157. value: true
  12158. });
  12159. exports.DownloadManager = void 0;
  12160. var _pdfjsLib = __webpack_require__(8);
  12161. var _viewer_compatibility = __webpack_require__(7);
  12162. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12163. 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); } }
  12164. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12165. ;
  12166. var DISABLE_CREATE_OBJECT_URL = _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL || false;
  12167. function _download(blobUrl, filename) {
  12168. var a = document.createElement("a");
  12169. if (!a.click) {
  12170. throw new Error('DownloadManager: "a.click()" is not supported.');
  12171. }
  12172. a.href = blobUrl;
  12173. a.target = "_parent";
  12174. if ("download" in a) {
  12175. a.download = filename;
  12176. }
  12177. (document.body || document.documentElement).appendChild(a);
  12178. a.click();
  12179. a.remove();
  12180. }
  12181. var DownloadManager = /*#__PURE__*/function () {
  12182. function DownloadManager(_ref) {
  12183. var _ref$disableCreateObj = _ref.disableCreateObjectURL,
  12184. disableCreateObjectURL = _ref$disableCreateObj === void 0 ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj;
  12185. _classCallCheck(this, DownloadManager);
  12186. this.disableCreateObjectURL = disableCreateObjectURL;
  12187. }
  12188. _createClass(DownloadManager, [{
  12189. key: "downloadUrl",
  12190. value: function downloadUrl(url, filename) {
  12191. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  12192. return;
  12193. }
  12194. _download(url + "#pdfjs.action=download", filename);
  12195. }
  12196. }, {
  12197. key: "downloadData",
  12198. value: function downloadData(data, filename, contentType) {
  12199. if (navigator.msSaveBlob) {
  12200. navigator.msSaveBlob(new Blob([data], {
  12201. type: contentType
  12202. }), filename);
  12203. return;
  12204. }
  12205. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL);
  12206. _download(blobUrl, filename);
  12207. }
  12208. }, {
  12209. key: "download",
  12210. value: function download(blob, url, filename) {
  12211. if (navigator.msSaveBlob) {
  12212. if (!navigator.msSaveBlob(blob, filename)) {
  12213. this.downloadUrl(url, filename);
  12214. }
  12215. return;
  12216. }
  12217. if (this.disableCreateObjectURL) {
  12218. this.downloadUrl(url, filename);
  12219. return;
  12220. }
  12221. var blobUrl = URL.createObjectURL(blob);
  12222. _download(blobUrl, filename);
  12223. }
  12224. }]);
  12225. return DownloadManager;
  12226. }();
  12227. exports.DownloadManager = DownloadManager;
  12228. /***/ }),
  12229. /* 39 */
  12230. /***/ (function(module, exports, __webpack_require__) {
  12231. "use strict";
  12232. Object.defineProperty(exports, "__esModule", {
  12233. value: true
  12234. });
  12235. exports.GenericL10n = void 0;
  12236. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  12237. __webpack_require__(40);
  12238. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12239. 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); } }
  12240. 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); }); }; }
  12241. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12242. 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); } }
  12243. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12244. var webL10n = document.webL10n;
  12245. var GenericL10n = /*#__PURE__*/function () {
  12246. function GenericL10n(lang) {
  12247. _classCallCheck(this, GenericL10n);
  12248. this._lang = lang;
  12249. this._ready = new Promise(function (resolve, reject) {
  12250. webL10n.setLanguage(lang, function () {
  12251. resolve(webL10n);
  12252. });
  12253. });
  12254. }
  12255. _createClass(GenericL10n, [{
  12256. key: "getLanguage",
  12257. value: function () {
  12258. var _getLanguage = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  12259. var l10n;
  12260. return _regenerator["default"].wrap(function _callee$(_context) {
  12261. while (1) {
  12262. switch (_context.prev = _context.next) {
  12263. case 0:
  12264. _context.next = 2;
  12265. return this._ready;
  12266. case 2:
  12267. l10n = _context.sent;
  12268. return _context.abrupt("return", l10n.getLanguage());
  12269. case 4:
  12270. case "end":
  12271. return _context.stop();
  12272. }
  12273. }
  12274. }, _callee, this);
  12275. }));
  12276. function getLanguage() {
  12277. return _getLanguage.apply(this, arguments);
  12278. }
  12279. return getLanguage;
  12280. }()
  12281. }, {
  12282. key: "getDirection",
  12283. value: function () {
  12284. var _getDirection = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  12285. var l10n;
  12286. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12287. while (1) {
  12288. switch (_context2.prev = _context2.next) {
  12289. case 0:
  12290. _context2.next = 2;
  12291. return this._ready;
  12292. case 2:
  12293. l10n = _context2.sent;
  12294. return _context2.abrupt("return", l10n.getDirection());
  12295. case 4:
  12296. case "end":
  12297. return _context2.stop();
  12298. }
  12299. }
  12300. }, _callee2, this);
  12301. }));
  12302. function getDirection() {
  12303. return _getDirection.apply(this, arguments);
  12304. }
  12305. return getDirection;
  12306. }()
  12307. }, {
  12308. key: "get",
  12309. value: function () {
  12310. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(property, args, fallback) {
  12311. var l10n;
  12312. return _regenerator["default"].wrap(function _callee3$(_context3) {
  12313. while (1) {
  12314. switch (_context3.prev = _context3.next) {
  12315. case 0:
  12316. _context3.next = 2;
  12317. return this._ready;
  12318. case 2:
  12319. l10n = _context3.sent;
  12320. return _context3.abrupt("return", l10n.get(property, args, fallback));
  12321. case 4:
  12322. case "end":
  12323. return _context3.stop();
  12324. }
  12325. }
  12326. }, _callee3, this);
  12327. }));
  12328. function get(_x, _x2, _x3) {
  12329. return _get.apply(this, arguments);
  12330. }
  12331. return get;
  12332. }()
  12333. }, {
  12334. key: "translate",
  12335. value: function () {
  12336. var _translate = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(element) {
  12337. var l10n;
  12338. return _regenerator["default"].wrap(function _callee4$(_context4) {
  12339. while (1) {
  12340. switch (_context4.prev = _context4.next) {
  12341. case 0:
  12342. _context4.next = 2;
  12343. return this._ready;
  12344. case 2:
  12345. l10n = _context4.sent;
  12346. return _context4.abrupt("return", l10n.translate(element));
  12347. case 4:
  12348. case "end":
  12349. return _context4.stop();
  12350. }
  12351. }
  12352. }, _callee4, this);
  12353. }));
  12354. function translate(_x4) {
  12355. return _translate.apply(this, arguments);
  12356. }
  12357. return translate;
  12358. }()
  12359. }]);
  12360. return GenericL10n;
  12361. }();
  12362. exports.GenericL10n = GenericL10n;
  12363. /***/ }),
  12364. /* 40 */
  12365. /***/ (function(module, exports, __webpack_require__) {
  12366. "use strict";
  12367. document.webL10n = function (window, document, undefined) {
  12368. var gL10nData = {};
  12369. var gTextData = '';
  12370. var gTextProp = 'textContent';
  12371. var gLanguage = '';
  12372. var gMacros = {};
  12373. var gReadyState = 'loading';
  12374. var gAsyncResourceLoading = true;
  12375. function getL10nResourceLinks() {
  12376. return document.querySelectorAll('link[type="application/l10n"]');
  12377. }
  12378. function getL10nDictionary() {
  12379. var script = document.querySelector('script[type="application/l10n"]');
  12380. return script ? JSON.parse(script.innerHTML) : null;
  12381. }
  12382. function getTranslatableChildren(element) {
  12383. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  12384. }
  12385. function getL10nAttributes(element) {
  12386. if (!element) return {};
  12387. var l10nId = element.getAttribute('data-l10n-id');
  12388. var l10nArgs = element.getAttribute('data-l10n-args');
  12389. var args = {};
  12390. if (l10nArgs) {
  12391. try {
  12392. args = JSON.parse(l10nArgs);
  12393. } catch (e) {
  12394. console.warn('could not parse arguments for #' + l10nId);
  12395. }
  12396. }
  12397. return {
  12398. id: l10nId,
  12399. args: args
  12400. };
  12401. }
  12402. function xhrLoadText(url, onSuccess, onFailure) {
  12403. onSuccess = onSuccess || function _onSuccess(data) {};
  12404. onFailure = onFailure || function _onFailure() {};
  12405. var xhr = new XMLHttpRequest();
  12406. xhr.open('GET', url, gAsyncResourceLoading);
  12407. if (xhr.overrideMimeType) {
  12408. xhr.overrideMimeType('text/plain; charset=utf-8');
  12409. }
  12410. xhr.onreadystatechange = function () {
  12411. if (xhr.readyState == 4) {
  12412. if (xhr.status == 200 || xhr.status === 0) {
  12413. onSuccess(xhr.responseText);
  12414. } else {
  12415. onFailure();
  12416. }
  12417. }
  12418. };
  12419. xhr.onerror = onFailure;
  12420. xhr.ontimeout = onFailure;
  12421. try {
  12422. xhr.send(null);
  12423. } catch (e) {
  12424. onFailure();
  12425. }
  12426. }
  12427. function parseResource(href, lang, successCallback, failureCallback) {
  12428. var baseURL = href.replace(/[^\/]*$/, '') || './';
  12429. function evalString(text) {
  12430. if (text.lastIndexOf('\\') < 0) return text;
  12431. 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, "'");
  12432. }
  12433. function parseProperties(text, parsedPropertiesCallback) {
  12434. var dictionary = {};
  12435. var reBlank = /^\s*|\s*$/;
  12436. var reComment = /^\s*#|^\s*$/;
  12437. var reSection = /^\s*\[(.*)\]\s*$/;
  12438. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  12439. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  12440. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  12441. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  12442. var currentLang = '*';
  12443. var genericLang = lang.split('-', 1)[0];
  12444. var skipLang = false;
  12445. var match = '';
  12446. function nextEntry() {
  12447. while (true) {
  12448. if (!entries.length) {
  12449. parsedRawLinesCallback();
  12450. return;
  12451. }
  12452. var line = entries.shift();
  12453. if (reComment.test(line)) continue;
  12454. if (extendedSyntax) {
  12455. match = reSection.exec(line);
  12456. if (match) {
  12457. currentLang = match[1].toLowerCase();
  12458. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  12459. continue;
  12460. } else if (skipLang) {
  12461. continue;
  12462. }
  12463. match = reImport.exec(line);
  12464. if (match) {
  12465. loadImport(baseURL + match[1], nextEntry);
  12466. return;
  12467. }
  12468. }
  12469. var tmp = line.match(reSplit);
  12470. if (tmp && tmp.length == 3) {
  12471. dictionary[tmp[1]] = evalString(tmp[2]);
  12472. }
  12473. }
  12474. }
  12475. nextEntry();
  12476. }
  12477. function loadImport(url, callback) {
  12478. xhrLoadText(url, function (content) {
  12479. parseRawLines(content, false, callback);
  12480. }, function () {
  12481. console.warn(url + ' not found.');
  12482. callback();
  12483. });
  12484. }
  12485. parseRawLines(text, true, function () {
  12486. parsedPropertiesCallback(dictionary);
  12487. });
  12488. }
  12489. xhrLoadText(href, function (response) {
  12490. gTextData += response;
  12491. parseProperties(response, function (data) {
  12492. for (var key in data) {
  12493. var id,
  12494. prop,
  12495. index = key.lastIndexOf('.');
  12496. if (index > 0) {
  12497. id = key.substring(0, index);
  12498. prop = key.substring(index + 1);
  12499. } else {
  12500. id = key;
  12501. prop = gTextProp;
  12502. }
  12503. if (!gL10nData[id]) {
  12504. gL10nData[id] = {};
  12505. }
  12506. gL10nData[id][prop] = data[key];
  12507. }
  12508. if (successCallback) {
  12509. successCallback();
  12510. }
  12511. });
  12512. }, failureCallback);
  12513. }
  12514. function loadLocale(lang, callback) {
  12515. if (lang) {
  12516. lang = lang.toLowerCase();
  12517. }
  12518. callback = callback || function _callback() {};
  12519. clear();
  12520. gLanguage = lang;
  12521. var langLinks = getL10nResourceLinks();
  12522. var langCount = langLinks.length;
  12523. if (langCount === 0) {
  12524. var dict = getL10nDictionary();
  12525. if (dict && dict.locales && dict.default_locale) {
  12526. console.log('using the embedded JSON directory, early way out');
  12527. gL10nData = dict.locales[lang];
  12528. if (!gL10nData) {
  12529. var defaultLocale = dict.default_locale.toLowerCase();
  12530. for (var anyCaseLang in dict.locales) {
  12531. anyCaseLang = anyCaseLang.toLowerCase();
  12532. if (anyCaseLang === lang) {
  12533. gL10nData = dict.locales[lang];
  12534. break;
  12535. } else if (anyCaseLang === defaultLocale) {
  12536. gL10nData = dict.locales[defaultLocale];
  12537. }
  12538. }
  12539. }
  12540. callback();
  12541. } else {
  12542. console.log('no resource to load, early way out');
  12543. }
  12544. gReadyState = 'complete';
  12545. return;
  12546. }
  12547. var onResourceLoaded = null;
  12548. var gResourceCount = 0;
  12549. onResourceLoaded = function onResourceLoaded() {
  12550. gResourceCount++;
  12551. if (gResourceCount >= langCount) {
  12552. callback();
  12553. gReadyState = 'complete';
  12554. }
  12555. };
  12556. function L10nResourceLink(link) {
  12557. var href = link.href;
  12558. this.load = function (lang, callback) {
  12559. parseResource(href, lang, callback, function () {
  12560. console.warn(href + ' not found.');
  12561. console.warn('"' + lang + '" resource not found');
  12562. gLanguage = '';
  12563. callback();
  12564. });
  12565. };
  12566. }
  12567. for (var i = 0; i < langCount; i++) {
  12568. var resource = new L10nResourceLink(langLinks[i]);
  12569. resource.load(lang, onResourceLoaded);
  12570. }
  12571. }
  12572. function clear() {
  12573. gL10nData = {};
  12574. gTextData = '';
  12575. gLanguage = '';
  12576. }
  12577. function getPluralRules(lang) {
  12578. var locales2rules = {
  12579. 'af': 3,
  12580. 'ak': 4,
  12581. 'am': 4,
  12582. 'ar': 1,
  12583. 'asa': 3,
  12584. 'az': 0,
  12585. 'be': 11,
  12586. 'bem': 3,
  12587. 'bez': 3,
  12588. 'bg': 3,
  12589. 'bh': 4,
  12590. 'bm': 0,
  12591. 'bn': 3,
  12592. 'bo': 0,
  12593. 'br': 20,
  12594. 'brx': 3,
  12595. 'bs': 11,
  12596. 'ca': 3,
  12597. 'cgg': 3,
  12598. 'chr': 3,
  12599. 'cs': 12,
  12600. 'cy': 17,
  12601. 'da': 3,
  12602. 'de': 3,
  12603. 'dv': 3,
  12604. 'dz': 0,
  12605. 'ee': 3,
  12606. 'el': 3,
  12607. 'en': 3,
  12608. 'eo': 3,
  12609. 'es': 3,
  12610. 'et': 3,
  12611. 'eu': 3,
  12612. 'fa': 0,
  12613. 'ff': 5,
  12614. 'fi': 3,
  12615. 'fil': 4,
  12616. 'fo': 3,
  12617. 'fr': 5,
  12618. 'fur': 3,
  12619. 'fy': 3,
  12620. 'ga': 8,
  12621. 'gd': 24,
  12622. 'gl': 3,
  12623. 'gsw': 3,
  12624. 'gu': 3,
  12625. 'guw': 4,
  12626. 'gv': 23,
  12627. 'ha': 3,
  12628. 'haw': 3,
  12629. 'he': 2,
  12630. 'hi': 4,
  12631. 'hr': 11,
  12632. 'hu': 0,
  12633. 'id': 0,
  12634. 'ig': 0,
  12635. 'ii': 0,
  12636. 'is': 3,
  12637. 'it': 3,
  12638. 'iu': 7,
  12639. 'ja': 0,
  12640. 'jmc': 3,
  12641. 'jv': 0,
  12642. 'ka': 0,
  12643. 'kab': 5,
  12644. 'kaj': 3,
  12645. 'kcg': 3,
  12646. 'kde': 0,
  12647. 'kea': 0,
  12648. 'kk': 3,
  12649. 'kl': 3,
  12650. 'km': 0,
  12651. 'kn': 0,
  12652. 'ko': 0,
  12653. 'ksb': 3,
  12654. 'ksh': 21,
  12655. 'ku': 3,
  12656. 'kw': 7,
  12657. 'lag': 18,
  12658. 'lb': 3,
  12659. 'lg': 3,
  12660. 'ln': 4,
  12661. 'lo': 0,
  12662. 'lt': 10,
  12663. 'lv': 6,
  12664. 'mas': 3,
  12665. 'mg': 4,
  12666. 'mk': 16,
  12667. 'ml': 3,
  12668. 'mn': 3,
  12669. 'mo': 9,
  12670. 'mr': 3,
  12671. 'ms': 0,
  12672. 'mt': 15,
  12673. 'my': 0,
  12674. 'nah': 3,
  12675. 'naq': 7,
  12676. 'nb': 3,
  12677. 'nd': 3,
  12678. 'ne': 3,
  12679. 'nl': 3,
  12680. 'nn': 3,
  12681. 'no': 3,
  12682. 'nr': 3,
  12683. 'nso': 4,
  12684. 'ny': 3,
  12685. 'nyn': 3,
  12686. 'om': 3,
  12687. 'or': 3,
  12688. 'pa': 3,
  12689. 'pap': 3,
  12690. 'pl': 13,
  12691. 'ps': 3,
  12692. 'pt': 3,
  12693. 'rm': 3,
  12694. 'ro': 9,
  12695. 'rof': 3,
  12696. 'ru': 11,
  12697. 'rwk': 3,
  12698. 'sah': 0,
  12699. 'saq': 3,
  12700. 'se': 7,
  12701. 'seh': 3,
  12702. 'ses': 0,
  12703. 'sg': 0,
  12704. 'sh': 11,
  12705. 'shi': 19,
  12706. 'sk': 12,
  12707. 'sl': 14,
  12708. 'sma': 7,
  12709. 'smi': 7,
  12710. 'smj': 7,
  12711. 'smn': 7,
  12712. 'sms': 7,
  12713. 'sn': 3,
  12714. 'so': 3,
  12715. 'sq': 3,
  12716. 'sr': 11,
  12717. 'ss': 3,
  12718. 'ssy': 3,
  12719. 'st': 3,
  12720. 'sv': 3,
  12721. 'sw': 3,
  12722. 'syr': 3,
  12723. 'ta': 3,
  12724. 'te': 3,
  12725. 'teo': 3,
  12726. 'th': 0,
  12727. 'ti': 4,
  12728. 'tig': 3,
  12729. 'tk': 3,
  12730. 'tl': 4,
  12731. 'tn': 3,
  12732. 'to': 0,
  12733. 'tr': 0,
  12734. 'ts': 3,
  12735. 'tzm': 22,
  12736. 'uk': 11,
  12737. 'ur': 3,
  12738. 've': 3,
  12739. 'vi': 0,
  12740. 'vun': 3,
  12741. 'wa': 4,
  12742. 'wae': 3,
  12743. 'wo': 0,
  12744. 'xh': 3,
  12745. 'xog': 3,
  12746. 'yo': 0,
  12747. 'zh': 0,
  12748. 'zu': 3
  12749. };
  12750. function isIn(n, list) {
  12751. return list.indexOf(n) !== -1;
  12752. }
  12753. function isBetween(n, start, end) {
  12754. return start <= n && n <= end;
  12755. }
  12756. var pluralRules = {
  12757. '0': function _(n) {
  12758. return 'other';
  12759. },
  12760. '1': function _(n) {
  12761. if (isBetween(n % 100, 3, 10)) return 'few';
  12762. if (n === 0) return 'zero';
  12763. if (isBetween(n % 100, 11, 99)) return 'many';
  12764. if (n == 2) return 'two';
  12765. if (n == 1) return 'one';
  12766. return 'other';
  12767. },
  12768. '2': function _(n) {
  12769. if (n !== 0 && n % 10 === 0) return 'many';
  12770. if (n == 2) return 'two';
  12771. if (n == 1) return 'one';
  12772. return 'other';
  12773. },
  12774. '3': function _(n) {
  12775. if (n == 1) return 'one';
  12776. return 'other';
  12777. },
  12778. '4': function _(n) {
  12779. if (isBetween(n, 0, 1)) return 'one';
  12780. return 'other';
  12781. },
  12782. '5': function _(n) {
  12783. if (isBetween(n, 0, 2) && n != 2) return 'one';
  12784. return 'other';
  12785. },
  12786. '6': function _(n) {
  12787. if (n === 0) return 'zero';
  12788. if (n % 10 == 1 && n % 100 != 11) return 'one';
  12789. return 'other';
  12790. },
  12791. '7': function _(n) {
  12792. if (n == 2) return 'two';
  12793. if (n == 1) return 'one';
  12794. return 'other';
  12795. },
  12796. '8': function _(n) {
  12797. if (isBetween(n, 3, 6)) return 'few';
  12798. if (isBetween(n, 7, 10)) return 'many';
  12799. if (n == 2) return 'two';
  12800. if (n == 1) return 'one';
  12801. return 'other';
  12802. },
  12803. '9': function _(n) {
  12804. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  12805. if (n == 1) return 'one';
  12806. return 'other';
  12807. },
  12808. '10': function _(n) {
  12809. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  12810. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  12811. return 'other';
  12812. },
  12813. '11': function _(n) {
  12814. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  12815. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  12816. if (n % 10 == 1 && n % 100 != 11) return 'one';
  12817. return 'other';
  12818. },
  12819. '12': function _(n) {
  12820. if (isBetween(n, 2, 4)) return 'few';
  12821. if (n == 1) return 'one';
  12822. return 'other';
  12823. },
  12824. '13': function _(n) {
  12825. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  12826. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  12827. if (n == 1) return 'one';
  12828. return 'other';
  12829. },
  12830. '14': function _(n) {
  12831. if (isBetween(n % 100, 3, 4)) return 'few';
  12832. if (n % 100 == 2) return 'two';
  12833. if (n % 100 == 1) return 'one';
  12834. return 'other';
  12835. },
  12836. '15': function _(n) {
  12837. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  12838. if (isBetween(n % 100, 11, 19)) return 'many';
  12839. if (n == 1) return 'one';
  12840. return 'other';
  12841. },
  12842. '16': function _(n) {
  12843. if (n % 10 == 1 && n != 11) return 'one';
  12844. return 'other';
  12845. },
  12846. '17': function _(n) {
  12847. if (n == 3) return 'few';
  12848. if (n === 0) return 'zero';
  12849. if (n == 6) return 'many';
  12850. if (n == 2) return 'two';
  12851. if (n == 1) return 'one';
  12852. return 'other';
  12853. },
  12854. '18': function _(n) {
  12855. if (n === 0) return 'zero';
  12856. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  12857. return 'other';
  12858. },
  12859. '19': function _(n) {
  12860. if (isBetween(n, 2, 10)) return 'few';
  12861. if (isBetween(n, 0, 1)) return 'one';
  12862. return 'other';
  12863. },
  12864. '20': function _(n) {
  12865. 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';
  12866. if (n % 1000000 === 0 && n !== 0) return 'many';
  12867. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  12868. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  12869. return 'other';
  12870. },
  12871. '21': function _(n) {
  12872. if (n === 0) return 'zero';
  12873. if (n == 1) return 'one';
  12874. return 'other';
  12875. },
  12876. '22': function _(n) {
  12877. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  12878. return 'other';
  12879. },
  12880. '23': function _(n) {
  12881. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  12882. return 'other';
  12883. },
  12884. '24': function _(n) {
  12885. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  12886. if (isIn(n, [2, 12])) return 'two';
  12887. if (isIn(n, [1, 11])) return 'one';
  12888. return 'other';
  12889. }
  12890. };
  12891. var index = locales2rules[lang.replace(/-.*$/, '')];
  12892. if (!(index in pluralRules)) {
  12893. console.warn('plural form unknown for [' + lang + ']');
  12894. return function () {
  12895. return 'other';
  12896. };
  12897. }
  12898. return pluralRules[index];
  12899. }
  12900. gMacros.plural = function (str, param, key, prop) {
  12901. var n = parseFloat(param);
  12902. if (isNaN(n)) return str;
  12903. if (prop != gTextProp) return str;
  12904. if (!gMacros._pluralRules) {
  12905. gMacros._pluralRules = getPluralRules(gLanguage);
  12906. }
  12907. var index = '[' + gMacros._pluralRules(n) + ']';
  12908. if (n === 0 && key + '[zero]' in gL10nData) {
  12909. str = gL10nData[key + '[zero]'][prop];
  12910. } else if (n == 1 && key + '[one]' in gL10nData) {
  12911. str = gL10nData[key + '[one]'][prop];
  12912. } else if (n == 2 && key + '[two]' in gL10nData) {
  12913. str = gL10nData[key + '[two]'][prop];
  12914. } else if (key + index in gL10nData) {
  12915. str = gL10nData[key + index][prop];
  12916. } else if (key + '[other]' in gL10nData) {
  12917. str = gL10nData[key + '[other]'][prop];
  12918. }
  12919. return str;
  12920. };
  12921. function getL10nData(key, args, fallback) {
  12922. var data = gL10nData[key];
  12923. if (!data) {
  12924. console.warn('#' + key + ' is undefined.');
  12925. if (!fallback) {
  12926. return null;
  12927. }
  12928. data = fallback;
  12929. }
  12930. var rv = {};
  12931. for (var prop in data) {
  12932. var str = data[prop];
  12933. str = substIndexes(str, args, key, prop);
  12934. str = substArguments(str, args, key);
  12935. rv[prop] = str;
  12936. }
  12937. return rv;
  12938. }
  12939. function substIndexes(str, args, key, prop) {
  12940. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  12941. var reMatch = reIndex.exec(str);
  12942. if (!reMatch || !reMatch.length) return str;
  12943. var macroName = reMatch[1];
  12944. var paramName = reMatch[2];
  12945. var param;
  12946. if (args && paramName in args) {
  12947. param = args[paramName];
  12948. } else if (paramName in gL10nData) {
  12949. param = gL10nData[paramName];
  12950. }
  12951. if (macroName in gMacros) {
  12952. var macro = gMacros[macroName];
  12953. str = macro(str, param, key, prop);
  12954. }
  12955. return str;
  12956. }
  12957. function substArguments(str, args, key) {
  12958. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  12959. return str.replace(reArgs, function (matched_text, arg) {
  12960. if (args && arg in args) {
  12961. return args[arg];
  12962. }
  12963. if (arg in gL10nData) {
  12964. return gL10nData[arg];
  12965. }
  12966. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  12967. return matched_text;
  12968. });
  12969. }
  12970. function translateElement(element) {
  12971. var l10n = getL10nAttributes(element);
  12972. if (!l10n.id) return;
  12973. var data = getL10nData(l10n.id, l10n.args);
  12974. if (!data) {
  12975. console.warn('#' + l10n.id + ' is undefined.');
  12976. return;
  12977. }
  12978. if (data[gTextProp]) {
  12979. if (getChildElementCount(element) === 0) {
  12980. element[gTextProp] = data[gTextProp];
  12981. } else {
  12982. var children = element.childNodes;
  12983. var found = false;
  12984. for (var i = 0, l = children.length; i < l; i++) {
  12985. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  12986. if (found) {
  12987. children[i].nodeValue = '';
  12988. } else {
  12989. children[i].nodeValue = data[gTextProp];
  12990. found = true;
  12991. }
  12992. }
  12993. }
  12994. if (!found) {
  12995. var textNode = document.createTextNode(data[gTextProp]);
  12996. element.insertBefore(textNode, element.firstChild);
  12997. }
  12998. }
  12999. delete data[gTextProp];
  13000. }
  13001. for (var k in data) {
  13002. element[k] = data[k];
  13003. }
  13004. }
  13005. function getChildElementCount(element) {
  13006. if (element.children) {
  13007. return element.children.length;
  13008. }
  13009. if (typeof element.childElementCount !== 'undefined') {
  13010. return element.childElementCount;
  13011. }
  13012. var count = 0;
  13013. for (var i = 0; i < element.childNodes.length; i++) {
  13014. count += element.nodeType === 1 ? 1 : 0;
  13015. }
  13016. return count;
  13017. }
  13018. function translateFragment(element) {
  13019. element = element || document.documentElement;
  13020. var children = getTranslatableChildren(element);
  13021. var elementCount = children.length;
  13022. for (var i = 0; i < elementCount; i++) {
  13023. translateElement(children[i]);
  13024. }
  13025. translateElement(element);
  13026. }
  13027. return {
  13028. get: function get(key, args, fallbackString) {
  13029. var index = key.lastIndexOf('.');
  13030. var prop = gTextProp;
  13031. if (index > 0) {
  13032. prop = key.substring(index + 1);
  13033. key = key.substring(0, index);
  13034. }
  13035. var fallback;
  13036. if (fallbackString) {
  13037. fallback = {};
  13038. fallback[prop] = fallbackString;
  13039. }
  13040. var data = getL10nData(key, args, fallback);
  13041. if (data && prop in data) {
  13042. return data[prop];
  13043. }
  13044. return '{{' + key + '}}';
  13045. },
  13046. getData: function getData() {
  13047. return gL10nData;
  13048. },
  13049. getText: function getText() {
  13050. return gTextData;
  13051. },
  13052. getLanguage: function getLanguage() {
  13053. return gLanguage;
  13054. },
  13055. setLanguage: function setLanguage(lang, callback) {
  13056. loadLocale(lang, function () {
  13057. if (callback) callback();
  13058. });
  13059. },
  13060. getDirection: function getDirection() {
  13061. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  13062. var shortCode = gLanguage.split('-', 1)[0];
  13063. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  13064. },
  13065. translate: translateFragment,
  13066. getReadyState: function getReadyState() {
  13067. return gReadyState;
  13068. },
  13069. ready: function ready(callback) {
  13070. if (!callback) {
  13071. return;
  13072. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  13073. window.setTimeout(function () {
  13074. callback();
  13075. });
  13076. } else if (document.addEventListener) {
  13077. document.addEventListener('localized', function once() {
  13078. document.removeEventListener('localized', once);
  13079. callback();
  13080. });
  13081. }
  13082. }
  13083. };
  13084. }(window, document);
  13085. /***/ }),
  13086. /* 41 */
  13087. /***/ (function(module, exports, __webpack_require__) {
  13088. "use strict";
  13089. Object.defineProperty(exports, "__esModule", {
  13090. value: true
  13091. });
  13092. exports.PDFPrintService = PDFPrintService;
  13093. var _ui_utils = __webpack_require__(5);
  13094. var _app = __webpack_require__(1);
  13095. var _app_options = __webpack_require__(6);
  13096. var activeService = null;
  13097. var overlayManager = null;
  13098. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
  13099. var scratchCanvas = activeService.scratchCanvas;
  13100. var PRINT_RESOLUTION = _app_options.AppOptions.get("printResolution") || 150;
  13101. var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
  13102. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  13103. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  13104. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + "px";
  13105. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + "px";
  13106. var ctx = scratchCanvas.getContext("2d");
  13107. ctx.save();
  13108. ctx.fillStyle = "rgb(255, 255, 255)";
  13109. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  13110. ctx.restore();
  13111. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  13112. var renderContext = {
  13113. canvasContext: ctx,
  13114. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  13115. viewport: pdfPage.getViewport({
  13116. scale: 1,
  13117. rotation: size.rotation
  13118. }),
  13119. intent: "print"
  13120. };
  13121. return pdfPage.render(renderContext).promise;
  13122. }).then(function () {
  13123. return {
  13124. width: width,
  13125. height: height
  13126. };
  13127. });
  13128. }
  13129. function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  13130. this.pdfDocument = pdfDocument;
  13131. this.pagesOverview = pagesOverview;
  13132. this.printContainer = printContainer;
  13133. this.l10n = l10n || _ui_utils.NullL10n;
  13134. this.disableCreateObjectURL = _app_options.AppOptions.get("disableCreateObjectURL");
  13135. this.currentPage = -1;
  13136. this.scratchCanvas = document.createElement("canvas");
  13137. }
  13138. PDFPrintService.prototype = {
  13139. layout: function layout() {
  13140. this.throwIfInactive();
  13141. var body = document.querySelector("body");
  13142. body.setAttribute("data-pdfjsprinting", true);
  13143. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  13144. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  13145. }, this);
  13146. if (!hasEqualPageSizes) {
  13147. console.warn("Not all pages have the same size. The printed " + "result may be incorrect!");
  13148. }
  13149. this.pageStyleSheet = document.createElement("style");
  13150. var pageSize = this.pagesOverview[0];
  13151. this.pageStyleSheet.textContent = "@supports ((size:A4) and (size:1pt 1pt)) {" + "@page { size: " + pageSize.width + "pt " + pageSize.height + "pt;}" + "}";
  13152. body.appendChild(this.pageStyleSheet);
  13153. },
  13154. destroy: function destroy() {
  13155. if (activeService !== this) {
  13156. return;
  13157. }
  13158. this.printContainer.textContent = "";
  13159. var body = document.querySelector("body");
  13160. body.removeAttribute("data-pdfjsprinting");
  13161. if (this.pageStyleSheet) {
  13162. this.pageStyleSheet.remove();
  13163. this.pageStyleSheet = null;
  13164. }
  13165. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  13166. this.scratchCanvas = null;
  13167. activeService = null;
  13168. ensureOverlay().then(function () {
  13169. if (overlayManager.active !== "printServiceOverlay") {
  13170. return;
  13171. }
  13172. overlayManager.close("printServiceOverlay");
  13173. });
  13174. },
  13175. renderPages: function renderPages() {
  13176. var _this = this;
  13177. var pageCount = this.pagesOverview.length;
  13178. var renderNextPage = function renderNextPage(resolve, reject) {
  13179. _this.throwIfInactive();
  13180. if (++_this.currentPage >= pageCount) {
  13181. renderProgress(pageCount, pageCount, _this.l10n);
  13182. resolve();
  13183. return;
  13184. }
  13185. var index = _this.currentPage;
  13186. renderProgress(index, pageCount, _this.l10n);
  13187. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () {
  13188. renderNextPage(resolve, reject);
  13189. }, reject);
  13190. };
  13191. return new Promise(renderNextPage);
  13192. },
  13193. useRenderedPage: function useRenderedPage(printItem) {
  13194. this.throwIfInactive();
  13195. var img = document.createElement("img");
  13196. img.style.width = printItem.width;
  13197. img.style.height = printItem.height;
  13198. var scratchCanvas = this.scratchCanvas;
  13199. if ("toBlob" in scratchCanvas && !this.disableCreateObjectURL) {
  13200. scratchCanvas.toBlob(function (blob) {
  13201. img.src = URL.createObjectURL(blob);
  13202. });
  13203. } else {
  13204. img.src = scratchCanvas.toDataURL();
  13205. }
  13206. var wrapper = document.createElement("div");
  13207. wrapper.appendChild(img);
  13208. this.printContainer.appendChild(wrapper);
  13209. return new Promise(function (resolve, reject) {
  13210. img.onload = resolve;
  13211. img.onerror = reject;
  13212. });
  13213. },
  13214. performPrint: function performPrint() {
  13215. var _this2 = this;
  13216. this.throwIfInactive();
  13217. return new Promise(function (resolve) {
  13218. setTimeout(function () {
  13219. if (!_this2.active) {
  13220. resolve();
  13221. return;
  13222. }
  13223. print.call(window);
  13224. setTimeout(resolve, 20);
  13225. }, 0);
  13226. });
  13227. },
  13228. get active() {
  13229. return this === activeService;
  13230. },
  13231. throwIfInactive: function throwIfInactive() {
  13232. if (!this.active) {
  13233. throw new Error("This print request was cancelled or completed.");
  13234. }
  13235. }
  13236. };
  13237. var print = window.print;
  13238. window.print = function () {
  13239. if (activeService) {
  13240. console.warn("Ignored window.print() because of a pending print job.");
  13241. return;
  13242. }
  13243. ensureOverlay().then(function () {
  13244. if (activeService) {
  13245. overlayManager.open("printServiceOverlay");
  13246. }
  13247. });
  13248. try {
  13249. dispatchEvent("beforeprint");
  13250. } finally {
  13251. if (!activeService) {
  13252. console.error("Expected print service to be initialized.");
  13253. ensureOverlay().then(function () {
  13254. if (overlayManager.active === "printServiceOverlay") {
  13255. overlayManager.close("printServiceOverlay");
  13256. }
  13257. });
  13258. return;
  13259. }
  13260. var activeServiceOnEntry = activeService;
  13261. activeService.renderPages().then(function () {
  13262. return activeServiceOnEntry.performPrint();
  13263. })["catch"](function () {}).then(function () {
  13264. if (activeServiceOnEntry.active) {
  13265. abort();
  13266. }
  13267. });
  13268. }
  13269. };
  13270. function dispatchEvent(eventType) {
  13271. var event = document.createEvent("CustomEvent");
  13272. event.initCustomEvent(eventType, false, false, "custom");
  13273. window.dispatchEvent(event);
  13274. }
  13275. function abort() {
  13276. if (activeService) {
  13277. activeService.destroy();
  13278. dispatchEvent("afterprint");
  13279. }
  13280. }
  13281. function renderProgress(index, total, l10n) {
  13282. var progressContainer = document.getElementById("printServiceOverlay");
  13283. var progress = Math.round(100 * index / total);
  13284. var progressBar = progressContainer.querySelector("progress");
  13285. var progressPerc = progressContainer.querySelector(".relative-progress");
  13286. progressBar.value = progress;
  13287. l10n.get("print_progress_percent", {
  13288. progress: progress
  13289. }, progress + "%").then(function (msg) {
  13290. progressPerc.textContent = msg;
  13291. });
  13292. }
  13293. window.addEventListener("keydown", function (event) {
  13294. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  13295. window.print();
  13296. event.preventDefault();
  13297. if (event.stopImmediatePropagation) {
  13298. event.stopImmediatePropagation();
  13299. } else {
  13300. event.stopPropagation();
  13301. }
  13302. }
  13303. }, true);
  13304. if ("onbeforeprint" in window) {
  13305. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  13306. if (event.detail !== "custom" && event.stopImmediatePropagation) {
  13307. event.stopImmediatePropagation();
  13308. }
  13309. };
  13310. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  13311. window.addEventListener("afterprint", stopPropagationIfNeeded);
  13312. }
  13313. var overlayPromise;
  13314. function ensureOverlay() {
  13315. if (!overlayPromise) {
  13316. overlayManager = _app.PDFViewerApplication.overlayManager;
  13317. if (!overlayManager) {
  13318. throw new Error("The overlay manager has not yet been initialized.");
  13319. }
  13320. overlayPromise = overlayManager.register("printServiceOverlay", document.getElementById("printServiceOverlay"), abort, true);
  13321. document.getElementById("printCancel").onclick = abort;
  13322. }
  13323. return overlayPromise;
  13324. }
  13325. _app.PDFPrintServiceFactory.instance = {
  13326. supportsPrinting: true,
  13327. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  13328. if (activeService) {
  13329. throw new Error("The print service is created and active.");
  13330. }
  13331. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
  13332. return activeService;
  13333. }
  13334. };
  13335. /***/ })
  13336. /******/ ]);
  13337. //# sourceMappingURL=viewer.js.map