viewer.js 608 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2020 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. /******/ (() => { // webpackBootstrap
  23. /******/ "use strict";
  24. /******/ var __webpack_modules__ = ([
  25. /* 0 */
  26. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  27. Object.defineProperty(exports, "__esModule", ({
  28. value: true
  29. }));
  30. Object.defineProperty(exports, "PDFViewerApplicationOptions", ({
  31. enumerable: true,
  32. get: function get() {
  33. return _app_options.AppOptions;
  34. }
  35. }));
  36. Object.defineProperty(exports, "PDFViewerApplication", ({
  37. enumerable: true,
  38. get: function get() {
  39. return _app.PDFViewerApplication;
  40. }
  41. }));
  42. var _app_options = __webpack_require__(1);
  43. var _app = __webpack_require__(3);
  44. var pdfjsVersion = '2.7.570';
  45. var pdfjsBuild = 'f2c7338b0';
  46. window.PDFViewerApplication = _app.PDFViewerApplication;
  47. window.PDFViewerApplicationOptions = _app_options.AppOptions;
  48. ;
  49. ;
  50. {
  51. __webpack_require__(37);
  52. }
  53. ;
  54. {
  55. __webpack_require__(43);
  56. }
  57. function getViewerConfiguration() {
  58. return {
  59. appContainer: document.body,
  60. mainContainer: document.getElementById("viewerContainer"),
  61. viewerContainer: document.getElementById("viewer"),
  62. eventBus: null,
  63. toolbar: {
  64. container: document.getElementById("toolbarViewer"),
  65. numPages: document.getElementById("numPages"),
  66. pageNumber: document.getElementById("pageNumber"),
  67. scaleSelectContainer: document.getElementById("scaleSelectContainer"),
  68. scaleSelect: document.getElementById("scaleSelect"),
  69. customScaleOption: document.getElementById("customScaleOption"),
  70. previous: document.getElementById("previous"),
  71. next: document.getElementById("next"),
  72. zoomIn: document.getElementById("zoomIn"),
  73. zoomOut: document.getElementById("zoomOut"),
  74. viewFind: document.getElementById("viewFind"),
  75. openFile: document.getElementById("openFile"),
  76. print: document.getElementById("print"),
  77. presentationModeButton: document.getElementById("presentationMode"),
  78. download: document.getElementById("download"),
  79. viewBookmark: document.getElementById("viewBookmark")
  80. },
  81. secondaryToolbar: {
  82. toolbar: document.getElementById("secondaryToolbar"),
  83. toggleButton: document.getElementById("secondaryToolbarToggle"),
  84. toolbarButtonContainer: document.getElementById("secondaryToolbarButtonContainer"),
  85. presentationModeButton: document.getElementById("secondaryPresentationMode"),
  86. openFileButton: document.getElementById("secondaryOpenFile"),
  87. printButton: document.getElementById("secondaryPrint"),
  88. downloadButton: document.getElementById("secondaryDownload"),
  89. viewBookmarkButton: document.getElementById("secondaryViewBookmark"),
  90. firstPageButton: document.getElementById("firstPage"),
  91. lastPageButton: document.getElementById("lastPage"),
  92. pageRotateCwButton: document.getElementById("pageRotateCw"),
  93. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  94. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  95. cursorHandToolButton: document.getElementById("cursorHandTool"),
  96. scrollVerticalButton: document.getElementById("scrollVertical"),
  97. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  98. scrollWrappedButton: document.getElementById("scrollWrapped"),
  99. spreadNoneButton: document.getElementById("spreadNone"),
  100. spreadOddButton: document.getElementById("spreadOdd"),
  101. spreadEvenButton: document.getElementById("spreadEven"),
  102. documentPropertiesButton: document.getElementById("documentProperties")
  103. },
  104. fullscreen: {
  105. contextFirstPage: document.getElementById("contextFirstPage"),
  106. contextLastPage: document.getElementById("contextLastPage"),
  107. contextPageRotateCw: document.getElementById("contextPageRotateCw"),
  108. contextPageRotateCcw: document.getElementById("contextPageRotateCcw")
  109. },
  110. sidebar: {
  111. outerContainer: document.getElementById("outerContainer"),
  112. viewerContainer: document.getElementById("viewerContainer"),
  113. toggleButton: document.getElementById("sidebarToggle"),
  114. thumbnailButton: document.getElementById("viewThumbnail"),
  115. outlineButton: document.getElementById("viewOutline"),
  116. attachmentsButton: document.getElementById("viewAttachments"),
  117. layersButton: document.getElementById("viewLayers"),
  118. thumbnailView: document.getElementById("thumbnailView"),
  119. outlineView: document.getElementById("outlineView"),
  120. attachmentsView: document.getElementById("attachmentsView"),
  121. layersView: document.getElementById("layersView"),
  122. outlineOptionsContainer: document.getElementById("outlineOptionsContainer"),
  123. currentOutlineItemButton: document.getElementById("currentOutlineItem")
  124. },
  125. sidebarResizer: {
  126. outerContainer: document.getElementById("outerContainer"),
  127. resizer: document.getElementById("sidebarResizer")
  128. },
  129. findBar: {
  130. bar: document.getElementById("findbar"),
  131. toggleButton: document.getElementById("viewFind"),
  132. findField: document.getElementById("findInput"),
  133. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  134. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  135. entireWordCheckbox: document.getElementById("findEntireWord"),
  136. findMsg: document.getElementById("findMsg"),
  137. findResultsCount: document.getElementById("findResultsCount"),
  138. findPreviousButton: document.getElementById("findPrevious"),
  139. findNextButton: document.getElementById("findNext")
  140. },
  141. passwordOverlay: {
  142. overlayName: "passwordOverlay",
  143. container: document.getElementById("passwordOverlay"),
  144. label: document.getElementById("passwordText"),
  145. input: document.getElementById("password"),
  146. submitButton: document.getElementById("passwordSubmit"),
  147. cancelButton: document.getElementById("passwordCancel")
  148. },
  149. documentProperties: {
  150. overlayName: "documentPropertiesOverlay",
  151. container: document.getElementById("documentPropertiesOverlay"),
  152. closeButton: document.getElementById("documentPropertiesClose"),
  153. fields: {
  154. fileName: document.getElementById("fileNameField"),
  155. fileSize: document.getElementById("fileSizeField"),
  156. title: document.getElementById("titleField"),
  157. author: document.getElementById("authorField"),
  158. subject: document.getElementById("subjectField"),
  159. keywords: document.getElementById("keywordsField"),
  160. creationDate: document.getElementById("creationDateField"),
  161. modificationDate: document.getElementById("modificationDateField"),
  162. creator: document.getElementById("creatorField"),
  163. producer: document.getElementById("producerField"),
  164. version: document.getElementById("versionField"),
  165. pageCount: document.getElementById("pageCountField"),
  166. pageSize: document.getElementById("pageSizeField"),
  167. linearized: document.getElementById("linearizedField")
  168. }
  169. },
  170. errorWrapper: {
  171. container: document.getElementById("errorWrapper"),
  172. errorMessage: document.getElementById("errorMessage"),
  173. closeButton: document.getElementById("errorClose"),
  174. errorMoreInfo: document.getElementById("errorMoreInfo"),
  175. moreInfoButton: document.getElementById("errorShowMore"),
  176. lessInfoButton: document.getElementById("errorShowLess")
  177. },
  178. printContainer: document.getElementById("printContainer"),
  179. openFileInputName: "fileInput",
  180. debuggerScriptPath: "./debugger.js"
  181. };
  182. }
  183. function webViewerLoad() {
  184. var config = getViewerConfiguration();
  185. var event = document.createEvent("CustomEvent");
  186. event.initCustomEvent("webviewerloaded", true, true, {
  187. source: window
  188. });
  189. try {
  190. parent.document.dispatchEvent(event);
  191. } catch (ex) {
  192. console.error("webviewerloaded: ".concat(ex));
  193. document.dispatchEvent(event);
  194. }
  195. _app.PDFViewerApplication.run(config);
  196. }
  197. if (document.readyState === "interactive" || document.readyState === "complete") {
  198. webViewerLoad();
  199. } else {
  200. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  201. }
  202. /***/ }),
  203. /* 1 */
  204. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  205. Object.defineProperty(exports, "__esModule", ({
  206. value: true
  207. }));
  208. exports.OptionKind = exports.AppOptions = void 0;
  209. var _viewer_compatibility = __webpack_require__(2);
  210. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  211. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  212. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  213. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  214. var OptionKind = {
  215. VIEWER: 0x02,
  216. API: 0x04,
  217. WORKER: 0x08,
  218. PREFERENCE: 0x80
  219. };
  220. exports.OptionKind = OptionKind;
  221. /*
  222. Code added for extracting file information from the header of ArozOS dataurl
  223. */
  224. var inputFiles = ao_module_loadInputFiles();
  225. var openURL = "nofile.pdf";
  226. if (inputFiles == null){
  227. //Leave the openURL to be nofile.pdf
  228. }else{
  229. //Open the file using media server
  230. openURL = (ao_module_getAORootFromScriptPath() + "media/?file=" + encodeURIComponent(inputFiles[0].filepath));
  231. }
  232. var defaultOptions = {
  233. cursorToolOnLoad: {
  234. value: 0,
  235. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  236. },
  237. defaultUrl: {
  238. value: openURL,
  239. kind: OptionKind.VIEWER
  240. },
  241. defaultZoomValue: {
  242. value: "",
  243. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  244. },
  245. disableHistory: {
  246. value: false,
  247. kind: OptionKind.VIEWER
  248. },
  249. disablePageLabels: {
  250. value: false,
  251. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  252. },
  253. enablePermissions: {
  254. value: false,
  255. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  256. },
  257. enablePrintAutoRotate: {
  258. value: false,
  259. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  260. },
  261. enableScripting: {
  262. value: false,
  263. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  264. },
  265. enableWebGL: {
  266. value: false,
  267. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  268. },
  269. externalLinkRel: {
  270. value: "noopener noreferrer nofollow",
  271. kind: OptionKind.VIEWER
  272. },
  273. externalLinkTarget: {
  274. value: 0,
  275. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  276. },
  277. historyUpdateUrl: {
  278. value: false,
  279. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  280. },
  281. ignoreDestinationZoom: {
  282. value: false,
  283. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  284. },
  285. imageResourcesPath: {
  286. value: "./images/",
  287. kind: OptionKind.VIEWER
  288. },
  289. maxCanvasPixels: {
  290. value: 16777216,
  291. compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
  292. kind: OptionKind.VIEWER
  293. },
  294. pdfBugEnabled: {
  295. value: false,
  296. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  297. },
  298. printResolution: {
  299. value: 150,
  300. kind: OptionKind.VIEWER
  301. },
  302. renderer: {
  303. value: "canvas",
  304. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  305. },
  306. renderInteractiveForms: {
  307. value: true,
  308. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  309. },
  310. sidebarViewOnLoad: {
  311. value: -1,
  312. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  313. },
  314. scrollModeOnLoad: {
  315. value: -1,
  316. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  317. },
  318. spreadModeOnLoad: {
  319. value: -1,
  320. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  321. },
  322. textLayerMode: {
  323. value: 1,
  324. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  325. },
  326. useOnlyCssZoom: {
  327. value: false,
  328. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  329. },
  330. viewerCssTheme: {
  331. value: 0,
  332. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  333. },
  334. viewOnLoad: {
  335. value: 0,
  336. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  337. },
  338. cMapPacked: {
  339. value: true,
  340. kind: OptionKind.API
  341. },
  342. cMapUrl: {
  343. value: "../web/cmaps/",
  344. kind: OptionKind.API
  345. },
  346. disableAutoFetch: {
  347. value: false,
  348. kind: OptionKind.API + OptionKind.PREFERENCE
  349. },
  350. disableFontFace: {
  351. value: false,
  352. kind: OptionKind.API + OptionKind.PREFERENCE
  353. },
  354. disableRange: {
  355. value: false,
  356. kind: OptionKind.API + OptionKind.PREFERENCE
  357. },
  358. disableStream: {
  359. value: false,
  360. kind: OptionKind.API + OptionKind.PREFERENCE
  361. },
  362. docBaseUrl: {
  363. value: "",
  364. kind: OptionKind.API
  365. },
  366. fontExtraProperties: {
  367. value: false,
  368. kind: OptionKind.API
  369. },
  370. isEvalSupported: {
  371. value: true,
  372. kind: OptionKind.API
  373. },
  374. maxImageSize: {
  375. value: -1,
  376. kind: OptionKind.API
  377. },
  378. pdfBug: {
  379. value: false,
  380. kind: OptionKind.API
  381. },
  382. verbosity: {
  383. value: 1,
  384. kind: OptionKind.API
  385. },
  386. workerPort: {
  387. value: null,
  388. kind: OptionKind.WORKER
  389. },
  390. workerSrc: {
  391. value: "js/pdf.worker.js",
  392. kind: OptionKind.WORKER
  393. }
  394. };
  395. {
  396. defaultOptions.disablePreferences = {
  397. value: false,
  398. kind: OptionKind.VIEWER
  399. };
  400. defaultOptions.locale = {
  401. value: typeof navigator !== "undefined" ? navigator.language : "en-US",
  402. kind: OptionKind.VIEWER
  403. };
  404. defaultOptions.sandboxBundleSrc = {
  405. value: "../build/pdf.sandbox.js",
  406. kind: OptionKind.VIEWER
  407. };
  408. }
  409. var userOptions = Object.create(null);
  410. var AppOptions = /*#__PURE__*/function () {
  411. function AppOptions() {
  412. _classCallCheck(this, AppOptions);
  413. throw new Error("Cannot initialize AppOptions.");
  414. }
  415. _createClass(AppOptions, null, [{
  416. key: "get",
  417. value: function get(name) {
  418. var userOption = userOptions[name];
  419. if (userOption !== undefined) {
  420. return userOption;
  421. }
  422. var defaultOption = defaultOptions[name];
  423. if (defaultOption !== undefined) {
  424. return defaultOption.compatibility || defaultOption.value;
  425. }
  426. return undefined;
  427. }
  428. }, {
  429. key: "getAll",
  430. value: function getAll() {
  431. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  432. var options = Object.create(null);
  433. for (var name in defaultOptions) {
  434. var defaultOption = defaultOptions[name];
  435. if (kind) {
  436. if ((kind & defaultOption.kind) === 0) {
  437. continue;
  438. }
  439. if (kind === OptionKind.PREFERENCE) {
  440. var value = defaultOption.value,
  441. valueType = _typeof(value);
  442. if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
  443. options[name] = value;
  444. continue;
  445. }
  446. throw new Error("Invalid type for preference: ".concat(name));
  447. }
  448. }
  449. var userOption = userOptions[name];
  450. options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
  451. }
  452. return options;
  453. }
  454. }, {
  455. key: "set",
  456. value: function set(name, value) {
  457. userOptions[name] = value;
  458. }
  459. }, {
  460. key: "setAll",
  461. value: function setAll(options) {
  462. for (var name in options) {
  463. userOptions[name] = options[name];
  464. }
  465. }
  466. }, {
  467. key: "remove",
  468. value: function remove(name) {
  469. delete userOptions[name];
  470. }
  471. }]);
  472. return AppOptions;
  473. }();
  474. exports.AppOptions = AppOptions;
  475. /***/ }),
  476. /* 2 */
  477. /***/ ((__unused_webpack_module, exports) => {
  478. Object.defineProperty(exports, "__esModule", ({
  479. value: true
  480. }));
  481. exports.viewerCompatibilityParams = void 0;
  482. var compatibilityParams = Object.create(null);
  483. {
  484. var userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
  485. var platform = typeof navigator !== "undefined" && navigator.platform || "";
  486. var maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
  487. var isAndroid = /Android/.test(userAgent);
  488. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  489. var isIOSChrome = /CriOS/.test(userAgent);
  490. (function checkOnBlobSupport() {
  491. if (isIOSChrome) {
  492. compatibilityParams.disableCreateObjectURL = true;
  493. }
  494. })();
  495. (function checkCanvasSizeLimitation() {
  496. if (isIOS || isAndroid) {
  497. compatibilityParams.maxCanvasPixels = 5242880;
  498. }
  499. })();
  500. }
  501. var viewerCompatibilityParams = Object.freeze(compatibilityParams);
  502. exports.viewerCompatibilityParams = viewerCompatibilityParams;
  503. /***/ }),
  504. /* 3 */
  505. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  506. Object.defineProperty(exports, "__esModule", ({
  507. value: true
  508. }));
  509. exports.PDFViewerApplication = exports.PDFPrintServiceFactory = exports.DefaultExternalServices = void 0;
  510. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  511. var _ui_utils = __webpack_require__(6);
  512. var _app_options = __webpack_require__(1);
  513. var _pdfjsLib = __webpack_require__(7);
  514. var _pdf_cursor_tools = __webpack_require__(8);
  515. var _pdf_rendering_queue = __webpack_require__(10);
  516. var _overlay_manager = __webpack_require__(11);
  517. var _password_prompt = __webpack_require__(12);
  518. var _pdf_attachment_viewer = __webpack_require__(13);
  519. var _pdf_document_properties = __webpack_require__(15);
  520. var _pdf_find_bar = __webpack_require__(16);
  521. var _pdf_find_controller = __webpack_require__(17);
  522. var _pdf_history = __webpack_require__(19);
  523. var _pdf_layer_viewer = __webpack_require__(20);
  524. var _pdf_link_service = __webpack_require__(21);
  525. var _pdf_outline_viewer = __webpack_require__(22);
  526. var _pdf_presentation_mode = __webpack_require__(23);
  527. var _pdf_sidebar = __webpack_require__(24);
  528. var _pdf_sidebar_resizer = __webpack_require__(25);
  529. var _pdf_thumbnail_viewer = __webpack_require__(26);
  530. var _pdf_viewer = __webpack_require__(28);
  531. var _secondary_toolbar = __webpack_require__(33);
  532. var _toolbar = __webpack_require__(35);
  533. var _viewer_compatibility = __webpack_require__(2);
  534. var _view_history = __webpack_require__(36);
  535. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  536. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  537. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  538. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  539. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  540. 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."); }
  541. 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; }
  542. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  543. 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; } } }; }
  544. 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); }
  545. 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; }
  546. 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); } }
  547. 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); }); }; }
  548. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  549. 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); } }
  550. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  551. var DEFAULT_SCALE_DELTA = 1.1;
  552. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  553. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  554. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  555. var ENABLE_PERMISSIONS_CLASS = "enablePermissions";
  556. var ViewOnLoad = {
  557. UNKNOWN: -1,
  558. PREVIOUS: 0,
  559. INITIAL: 1
  560. };
  561. var ViewerCssTheme = {
  562. AUTOMATIC: 0,
  563. LIGHT: 1,
  564. DARK: 2
  565. };
  566. var KNOWN_VERSIONS = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2.0", "2.1", "2.2", "2.3"];
  567. var KNOWN_GENERATORS = ["acrobat distiller", "acrobat pdfwriter", "adobe livecycle", "adobe pdf library", "adobe photoshop", "ghostscript", "tcpdf", "cairo", "dvipdfm", "dvips", "pdftex", "pdfkit", "itext", "prince", "quarkxpress", "mac os x", "microsoft", "openoffice", "oracle", "luradocument", "pdf-xchange", "antenna house", "aspose.cells", "fpdf"];
  568. var DefaultExternalServices = /*#__PURE__*/function () {
  569. function DefaultExternalServices() {
  570. _classCallCheck(this, DefaultExternalServices);
  571. throw new Error("Cannot initialize DefaultExternalServices.");
  572. }
  573. _createClass(DefaultExternalServices, null, [{
  574. key: "updateFindControlState",
  575. value: function updateFindControlState(data) {}
  576. }, {
  577. key: "updateFindMatchesCount",
  578. value: function updateFindMatchesCount(data) {}
  579. }, {
  580. key: "initPassiveLoading",
  581. value: function initPassiveLoading(callbacks) {}
  582. }, {
  583. key: "fallback",
  584. value: function () {
  585. var _fallback = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(data) {
  586. return _regenerator["default"].wrap(function _callee$(_context) {
  587. while (1) {
  588. switch (_context.prev = _context.next) {
  589. case 0:
  590. case "end":
  591. return _context.stop();
  592. }
  593. }
  594. }, _callee);
  595. }));
  596. function fallback(_x) {
  597. return _fallback.apply(this, arguments);
  598. }
  599. return fallback;
  600. }()
  601. }, {
  602. key: "reportTelemetry",
  603. value: function reportTelemetry(data) {}
  604. }, {
  605. key: "createDownloadManager",
  606. value: function createDownloadManager(options) {
  607. throw new Error("Not implemented: createDownloadManager");
  608. }
  609. }, {
  610. key: "createPreferences",
  611. value: function createPreferences() {
  612. throw new Error("Not implemented: createPreferences");
  613. }
  614. }, {
  615. key: "createL10n",
  616. value: function createL10n(options) {
  617. throw new Error("Not implemented: createL10n");
  618. }
  619. }, {
  620. key: "createScripting",
  621. value: function createScripting(options) {
  622. throw new Error("Not implemented: createScripting");
  623. }
  624. }, {
  625. key: "supportsIntegratedFind",
  626. get: function get() {
  627. return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false);
  628. }
  629. }, {
  630. key: "supportsDocumentFonts",
  631. get: function get() {
  632. return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts", true);
  633. }
  634. }, {
  635. key: "supportedMouseWheelZoomModifierKeys",
  636. get: function get() {
  637. return (0, _pdfjsLib.shadow)(this, "supportedMouseWheelZoomModifierKeys", {
  638. ctrlKey: true,
  639. metaKey: true
  640. });
  641. }
  642. }, {
  643. key: "isInAutomation",
  644. get: function get() {
  645. return (0, _pdfjsLib.shadow)(this, "isInAutomation", false);
  646. }
  647. }]);
  648. return DefaultExternalServices;
  649. }();
  650. exports.DefaultExternalServices = DefaultExternalServices;
  651. var PDFViewerApplication = {
  652. initialBookmark: document.location.hash.substring(1),
  653. _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(),
  654. fellback: false,
  655. appConfig: null,
  656. pdfDocument: null,
  657. pdfLoadingTask: null,
  658. printService: null,
  659. pdfViewer: null,
  660. pdfThumbnailViewer: null,
  661. pdfRenderingQueue: null,
  662. pdfPresentationMode: null,
  663. pdfDocumentProperties: null,
  664. pdfLinkService: null,
  665. pdfHistory: null,
  666. pdfSidebar: null,
  667. pdfSidebarResizer: null,
  668. pdfOutlineViewer: null,
  669. pdfAttachmentViewer: null,
  670. pdfLayerViewer: null,
  671. pdfCursorTools: null,
  672. store: null,
  673. downloadManager: null,
  674. overlayManager: null,
  675. preferences: null,
  676. toolbar: null,
  677. secondaryToolbar: null,
  678. eventBus: null,
  679. l10n: null,
  680. isInitialViewSet: false,
  681. downloadComplete: false,
  682. isViewerEmbedded: window.parent !== window,
  683. url: "",
  684. baseUrl: "",
  685. externalServices: DefaultExternalServices,
  686. _boundEvents: Object.create(null),
  687. documentInfo: null,
  688. metadata: null,
  689. _contentDispositionFilename: null,
  690. _contentLength: null,
  691. triggerDelayedFallback: null,
  692. _saveInProgress: false,
  693. _wheelUnusedTicks: 0,
  694. _idleCallbacks: new Set(),
  695. _scriptingInstance: null,
  696. _mouseState: Object.create(null),
  697. initialize: function initialize(appConfig) {
  698. var _this = this;
  699. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  700. var appContainer;
  701. return _regenerator["default"].wrap(function _callee2$(_context2) {
  702. while (1) {
  703. switch (_context2.prev = _context2.next) {
  704. case 0:
  705. _this.preferences = _this.externalServices.createPreferences();
  706. _this.appConfig = appConfig;
  707. _context2.next = 4;
  708. return _this._readPreferences();
  709. case 4:
  710. _context2.next = 6;
  711. return _this._parseHashParameters();
  712. case 6:
  713. _this._forceCssTheme();
  714. _context2.next = 9;
  715. return _this._initializeL10n();
  716. case 9:
  717. if (_this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdfjsLib.LinkTarget.NONE) {
  718. _app_options.AppOptions.set("externalLinkTarget", _pdfjsLib.LinkTarget.TOP);
  719. }
  720. _context2.next = 12;
  721. return _this._initializeViewerComponents();
  722. case 12:
  723. _this.bindEvents();
  724. _this.bindWindowEvents();
  725. appContainer = appConfig.appContainer || document.documentElement;
  726. _this.l10n.translate(appContainer).then(function () {
  727. _this.eventBus.dispatch("localized", {
  728. source: _this
  729. });
  730. });
  731. _this._initializedCapability.resolve();
  732. case 17:
  733. case "end":
  734. return _context2.stop();
  735. }
  736. }
  737. }, _callee2);
  738. }))();
  739. },
  740. _readPreferences: function _readPreferences() {
  741. var _this2 = this;
  742. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  743. return _regenerator["default"].wrap(function _callee3$(_context3) {
  744. while (1) {
  745. switch (_context3.prev = _context3.next) {
  746. case 0:
  747. if (!_app_options.AppOptions.get("disablePreferences")) {
  748. _context3.next = 2;
  749. break;
  750. }
  751. return _context3.abrupt("return");
  752. case 2:
  753. _context3.prev = 2;
  754. _context3.t0 = _app_options.AppOptions;
  755. _context3.next = 6;
  756. return _this2.preferences.getAll();
  757. case 6:
  758. _context3.t1 = _context3.sent;
  759. _context3.t0.setAll.call(_context3.t0, _context3.t1);
  760. _context3.next = 13;
  761. break;
  762. case 10:
  763. _context3.prev = 10;
  764. _context3.t2 = _context3["catch"](2);
  765. console.error("_readPreferences: \"".concat(_context3.t2 === null || _context3.t2 === void 0 ? void 0 : _context3.t2.message, "\"."));
  766. case 13:
  767. case "end":
  768. return _context3.stop();
  769. }
  770. }
  771. }, _callee3, null, [[2, 10]]);
  772. }))();
  773. },
  774. _parseHashParameters: function _parseHashParameters() {
  775. var _this3 = this;
  776. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  777. var hash, hashParams, waitOn, viewer, enabled;
  778. return _regenerator["default"].wrap(function _callee4$(_context4) {
  779. while (1) {
  780. switch (_context4.prev = _context4.next) {
  781. case 0:
  782. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  783. _context4.next = 2;
  784. break;
  785. }
  786. return _context4.abrupt("return", undefined);
  787. case 2:
  788. hash = document.location.hash.substring(1);
  789. if (hash) {
  790. _context4.next = 5;
  791. break;
  792. }
  793. return _context4.abrupt("return", undefined);
  794. case 5:
  795. hashParams = (0, _ui_utils.parseQueryString)(hash), waitOn = [];
  796. if ("disableworker" in hashParams && hashParams.disableworker === "true") {
  797. waitOn.push(loadFakeWorker());
  798. }
  799. if ("disablerange" in hashParams) {
  800. _app_options.AppOptions.set("disableRange", hashParams.disablerange === "true");
  801. }
  802. if ("disablestream" in hashParams) {
  803. _app_options.AppOptions.set("disableStream", hashParams.disablestream === "true");
  804. }
  805. if ("disableautofetch" in hashParams) {
  806. _app_options.AppOptions.set("disableAutoFetch", hashParams.disableautofetch === "true");
  807. }
  808. if ("disablefontface" in hashParams) {
  809. _app_options.AppOptions.set("disableFontFace", hashParams.disablefontface === "true");
  810. }
  811. if ("disablehistory" in hashParams) {
  812. _app_options.AppOptions.set("disableHistory", hashParams.disablehistory === "true");
  813. }
  814. if ("webgl" in hashParams) {
  815. _app_options.AppOptions.set("enableWebGL", hashParams.webgl === "true");
  816. }
  817. if ("verbosity" in hashParams) {
  818. _app_options.AppOptions.set("verbosity", hashParams.verbosity | 0);
  819. }
  820. if (!("textlayer" in hashParams)) {
  821. _context4.next = 23;
  822. break;
  823. }
  824. _context4.t0 = hashParams.textlayer;
  825. _context4.next = _context4.t0 === "off" ? 18 : _context4.t0 === "visible" ? 20 : _context4.t0 === "shadow" ? 20 : _context4.t0 === "hover" ? 20 : 23;
  826. break;
  827. case 18:
  828. _app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
  829. return _context4.abrupt("break", 23);
  830. case 20:
  831. viewer = _this3.appConfig.viewerContainer;
  832. viewer.classList.add("textLayer-" + hashParams.textlayer);
  833. return _context4.abrupt("break", 23);
  834. case 23:
  835. if ("pdfbug" in hashParams) {
  836. _app_options.AppOptions.set("pdfBug", true);
  837. _app_options.AppOptions.set("fontExtraProperties", true);
  838. enabled = hashParams.pdfbug.split(",");
  839. waitOn.push(loadAndEnablePDFBug(enabled));
  840. }
  841. if ("locale" in hashParams) {
  842. _app_options.AppOptions.set("locale", hashParams.locale);
  843. }
  844. if (!(waitOn.length === 0)) {
  845. _context4.next = 27;
  846. break;
  847. }
  848. return _context4.abrupt("return", undefined);
  849. case 27:
  850. return _context4.abrupt("return", Promise.all(waitOn)["catch"](function (reason) {
  851. console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
  852. }));
  853. case 28:
  854. case "end":
  855. return _context4.stop();
  856. }
  857. }
  858. }, _callee4);
  859. }))();
  860. },
  861. _initializeL10n: function _initializeL10n() {
  862. var _this4 = this;
  863. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
  864. var dir;
  865. return _regenerator["default"].wrap(function _callee5$(_context5) {
  866. while (1) {
  867. switch (_context5.prev = _context5.next) {
  868. case 0:
  869. _this4.l10n = _this4.externalServices.createL10n({
  870. locale: _app_options.AppOptions.get("locale")
  871. });
  872. _context5.next = 3;
  873. return _this4.l10n.getDirection();
  874. case 3:
  875. dir = _context5.sent;
  876. document.getElementsByTagName("html")[0].dir = dir;
  877. case 5:
  878. case "end":
  879. return _context5.stop();
  880. }
  881. }
  882. }, _callee5);
  883. }))();
  884. },
  885. _forceCssTheme: function _forceCssTheme() {
  886. var cssTheme = _app_options.AppOptions.get("viewerCssTheme");
  887. if (cssTheme === ViewerCssTheme.AUTOMATIC || !Object.values(ViewerCssTheme).includes(cssTheme)) {
  888. return;
  889. }
  890. try {
  891. var styleSheet = document.styleSheets[0];
  892. var cssRules = (styleSheet === null || styleSheet === void 0 ? void 0 : styleSheet.cssRules) || [];
  893. for (var i = 0, ii = cssRules.length; i < ii; i++) {
  894. var _rule$media;
  895. var rule = cssRules[i];
  896. if (rule instanceof CSSMediaRule && ((_rule$media = rule.media) === null || _rule$media === void 0 ? void 0 : _rule$media[0]) === "(prefers-color-scheme: dark)") {
  897. if (cssTheme === ViewerCssTheme.LIGHT) {
  898. styleSheet.deleteRule(i);
  899. return;
  900. }
  901. var darkRules = /^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/.exec(rule.cssText);
  902. if (darkRules !== null && darkRules !== void 0 && darkRules[1]) {
  903. styleSheet.deleteRule(i);
  904. styleSheet.insertRule(darkRules[1], i);
  905. }
  906. return;
  907. }
  908. }
  909. } catch (reason) {
  910. console.error("_forceCssTheme: \"".concat(reason === null || reason === void 0 ? void 0 : reason.message, "\"."));
  911. }
  912. },
  913. _initializeViewerComponents: function _initializeViewerComponents() {
  914. var _this5 = this;
  915. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  916. var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer;
  917. return _regenerator["default"].wrap(function _callee6$(_context6) {
  918. while (1) {
  919. switch (_context6.prev = _context6.next) {
  920. case 0:
  921. appConfig = _this5.appConfig;
  922. eventBus = appConfig.eventBus || new _ui_utils.EventBus({
  923. isInAutomation: _this5.externalServices.isInAutomation
  924. });
  925. _this5.eventBus = eventBus;
  926. _this5.overlayManager = new _overlay_manager.OverlayManager();
  927. pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  928. pdfRenderingQueue.onIdle = _this5.cleanup.bind(_this5);
  929. _this5.pdfRenderingQueue = pdfRenderingQueue;
  930. pdfLinkService = new _pdf_link_service.PDFLinkService({
  931. eventBus: eventBus,
  932. externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"),
  933. externalLinkRel: _app_options.AppOptions.get("externalLinkRel"),
  934. ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom")
  935. });
  936. _this5.pdfLinkService = pdfLinkService;
  937. downloadManager = _this5.externalServices.createDownloadManager();
  938. _this5.downloadManager = downloadManager;
  939. findController = new _pdf_find_controller.PDFFindController({
  940. linkService: pdfLinkService,
  941. eventBus: eventBus
  942. });
  943. _this5.findController = findController;
  944. container = appConfig.mainContainer;
  945. viewer = appConfig.viewerContainer;
  946. _this5.pdfViewer = new _pdf_viewer.PDFViewer({
  947. container: container,
  948. viewer: viewer,
  949. eventBus: eventBus,
  950. renderingQueue: pdfRenderingQueue,
  951. linkService: pdfLinkService,
  952. downloadManager: downloadManager,
  953. findController: findController,
  954. renderer: _app_options.AppOptions.get("renderer"),
  955. enableWebGL: _app_options.AppOptions.get("enableWebGL"),
  956. l10n: _this5.l10n,
  957. textLayerMode: _app_options.AppOptions.get("textLayerMode"),
  958. imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"),
  959. renderInteractiveForms: _app_options.AppOptions.get("renderInteractiveForms"),
  960. enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"),
  961. useOnlyCssZoom: _app_options.AppOptions.get("useOnlyCssZoom"),
  962. maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels"),
  963. enableScripting: _app_options.AppOptions.get("enableScripting"),
  964. mouseState: _this5._mouseState
  965. });
  966. pdfRenderingQueue.setViewer(_this5.pdfViewer);
  967. pdfLinkService.setViewer(_this5.pdfViewer);
  968. _this5.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  969. container: appConfig.sidebar.thumbnailView,
  970. eventBus: eventBus,
  971. renderingQueue: pdfRenderingQueue,
  972. linkService: pdfLinkService,
  973. l10n: _this5.l10n
  974. });
  975. pdfRenderingQueue.setThumbnailViewer(_this5.pdfThumbnailViewer);
  976. _this5.pdfHistory = new _pdf_history.PDFHistory({
  977. linkService: pdfLinkService,
  978. eventBus: eventBus
  979. });
  980. pdfLinkService.setHistory(_this5.pdfHistory);
  981. if (!_this5.supportsIntegratedFind) {
  982. _this5.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, _this5.l10n);
  983. }
  984. _this5.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this5.overlayManager, eventBus, _this5.l10n);
  985. _this5.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  986. container: container,
  987. eventBus: eventBus,
  988. cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad")
  989. });
  990. _this5.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, _this5.l10n);
  991. _this5.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  992. if (_this5.supportsFullscreen) {
  993. _this5.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  994. container: container,
  995. pdfViewer: _this5.pdfViewer,
  996. eventBus: eventBus,
  997. contextMenuItems: appConfig.fullscreen
  998. });
  999. }
  1000. _this5.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this5.overlayManager, _this5.l10n);
  1001. _this5.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  1002. container: appConfig.sidebar.outlineView,
  1003. eventBus: eventBus,
  1004. linkService: pdfLinkService
  1005. });
  1006. _this5.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  1007. container: appConfig.sidebar.attachmentsView,
  1008. eventBus: eventBus,
  1009. downloadManager: downloadManager
  1010. });
  1011. _this5.pdfLayerViewer = new _pdf_layer_viewer.PDFLayerViewer({
  1012. container: appConfig.sidebar.layersView,
  1013. eventBus: eventBus,
  1014. l10n: _this5.l10n
  1015. });
  1016. _this5.pdfSidebar = new _pdf_sidebar.PDFSidebar({
  1017. elements: appConfig.sidebar,
  1018. pdfViewer: _this5.pdfViewer,
  1019. pdfThumbnailViewer: _this5.pdfThumbnailViewer,
  1020. eventBus: eventBus,
  1021. l10n: _this5.l10n
  1022. });
  1023. _this5.pdfSidebar.onToggled = _this5.forceRendering.bind(_this5);
  1024. _this5.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, _this5.l10n);
  1025. case 35:
  1026. case "end":
  1027. return _context6.stop();
  1028. }
  1029. }
  1030. }, _callee6);
  1031. }))();
  1032. },
  1033. run: function run(config) {
  1034. this.initialize(config).then(webViewerInitialized);
  1035. },
  1036. get initialized() {
  1037. return this._initializedCapability.settled;
  1038. },
  1039. get initializedPromise() {
  1040. return this._initializedCapability.promise;
  1041. },
  1042. zoomIn: function zoomIn(ticks) {
  1043. if (this.pdfViewer.isInPresentationMode) {
  1044. return;
  1045. }
  1046. var newScale = this.pdfViewer.currentScale;
  1047. do {
  1048. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  1049. newScale = Math.ceil(newScale * 10) / 10;
  1050. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  1051. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  1052. this.pdfViewer.currentScaleValue = newScale;
  1053. },
  1054. zoomOut: function zoomOut(ticks) {
  1055. if (this.pdfViewer.isInPresentationMode) {
  1056. return;
  1057. }
  1058. var newScale = this.pdfViewer.currentScale;
  1059. do {
  1060. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  1061. newScale = Math.floor(newScale * 10) / 10;
  1062. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  1063. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  1064. this.pdfViewer.currentScaleValue = newScale;
  1065. },
  1066. zoomReset: function zoomReset() {
  1067. if (this.pdfViewer.isInPresentationMode) {
  1068. return;
  1069. }
  1070. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1071. },
  1072. get pagesCount() {
  1073. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  1074. },
  1075. get page() {
  1076. return this.pdfViewer.currentPageNumber;
  1077. },
  1078. set page(val) {
  1079. this.pdfViewer.currentPageNumber = val;
  1080. },
  1081. get supportsPrinting() {
  1082. return PDFPrintServiceFactory.instance.supportsPrinting;
  1083. },
  1084. get supportsFullscreen() {
  1085. var support;
  1086. var doc = document.documentElement;
  1087. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen);
  1088. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false) {
  1089. support = false;
  1090. }
  1091. return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", support);
  1092. },
  1093. get supportsIntegratedFind() {
  1094. return this.externalServices.supportsIntegratedFind;
  1095. },
  1096. get supportsDocumentFonts() {
  1097. return this.externalServices.supportsDocumentFonts;
  1098. },
  1099. get loadingBar() {
  1100. var bar = new _ui_utils.ProgressBar("#loadingBar");
  1101. return (0, _pdfjsLib.shadow)(this, "loadingBar", bar);
  1102. },
  1103. get supportedMouseWheelZoomModifierKeys() {
  1104. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  1105. },
  1106. initPassiveLoading: function initPassiveLoading() {
  1107. throw new Error("Not implemented: initPassiveLoading");
  1108. },
  1109. setTitleUsingUrl: function setTitleUsingUrl() {
  1110. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  1111. this.url = url;
  1112. this.baseUrl = url.split("#")[0];
  1113. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, "");
  1114. if (!title) {
  1115. try {
  1116. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  1117. } catch (ex) {
  1118. title = url;
  1119. }
  1120. }
  1121. this.setTitle(title);
  1122. },
  1123. setTitle: function setTitle(title) {
  1124. if (this.isViewerEmbedded) {
  1125. return;
  1126. }
  1127. document.title = title;
  1128. },
  1129. get _docFilename() {
  1130. return this._contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  1131. },
  1132. _cancelIdleCallbacks: function _cancelIdleCallbacks() {
  1133. if (!this._idleCallbacks.size) {
  1134. return;
  1135. }
  1136. var _iterator = _createForOfIteratorHelper(this._idleCallbacks),
  1137. _step;
  1138. try {
  1139. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  1140. var callback = _step.value;
  1141. window.cancelIdleCallback(callback);
  1142. }
  1143. } catch (err) {
  1144. _iterator.e(err);
  1145. } finally {
  1146. _iterator.f();
  1147. }
  1148. this._idleCallbacks.clear();
  1149. },
  1150. _destroyScriptingInstance: function _destroyScriptingInstance() {
  1151. var _this6 = this;
  1152. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
  1153. var _this6$_scriptingInst, scripting, internalEvents, domEvents, _iterator2, _step2, _step2$value, name, listener, _iterator3, _step3, _step3$value, _name, _listener;
  1154. return _regenerator["default"].wrap(function _callee7$(_context7) {
  1155. while (1) {
  1156. switch (_context7.prev = _context7.next) {
  1157. case 0:
  1158. if (_this6._scriptingInstance) {
  1159. _context7.next = 2;
  1160. break;
  1161. }
  1162. return _context7.abrupt("return");
  1163. case 2:
  1164. _this6$_scriptingInst = _this6._scriptingInstance, scripting = _this6$_scriptingInst.scripting, internalEvents = _this6$_scriptingInst.internalEvents, domEvents = _this6$_scriptingInst.domEvents;
  1165. _context7.prev = 3;
  1166. _context7.next = 6;
  1167. return scripting.destroySandbox();
  1168. case 6:
  1169. _context7.next = 10;
  1170. break;
  1171. case 8:
  1172. _context7.prev = 8;
  1173. _context7.t0 = _context7["catch"](3);
  1174. case 10:
  1175. _iterator2 = _createForOfIteratorHelper(internalEvents);
  1176. try {
  1177. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  1178. _step2$value = _slicedToArray(_step2.value, 2), name = _step2$value[0], listener = _step2$value[1];
  1179. _this6.eventBus._off(name, listener);
  1180. }
  1181. } catch (err) {
  1182. _iterator2.e(err);
  1183. } finally {
  1184. _iterator2.f();
  1185. }
  1186. internalEvents.clear();
  1187. _iterator3 = _createForOfIteratorHelper(domEvents);
  1188. try {
  1189. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  1190. _step3$value = _slicedToArray(_step3.value, 2), _name = _step3$value[0], _listener = _step3$value[1];
  1191. window.removeEventListener(_name, _listener);
  1192. }
  1193. } catch (err) {
  1194. _iterator3.e(err);
  1195. } finally {
  1196. _iterator3.f();
  1197. }
  1198. domEvents.clear();
  1199. delete _this6._mouseState.isDown;
  1200. _this6._scriptingInstance = null;
  1201. case 18:
  1202. case "end":
  1203. return _context7.stop();
  1204. }
  1205. }
  1206. }, _callee7, null, [[3, 8]]);
  1207. }))();
  1208. },
  1209. close: function close() {
  1210. var _this7 = this;
  1211. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
  1212. var errorWrapper, promises;
  1213. return _regenerator["default"].wrap(function _callee8$(_context8) {
  1214. while (1) {
  1215. switch (_context8.prev = _context8.next) {
  1216. case 0:
  1217. errorWrapper = _this7.appConfig.errorWrapper.container;
  1218. errorWrapper.setAttribute("hidden", "true");
  1219. if (_this7.pdfLoadingTask) {
  1220. _context8.next = 4;
  1221. break;
  1222. }
  1223. return _context8.abrupt("return", undefined);
  1224. case 4:
  1225. promises = [];
  1226. promises.push(_this7.pdfLoadingTask.destroy());
  1227. _this7.pdfLoadingTask = null;
  1228. if (_this7.pdfDocument) {
  1229. _this7.pdfDocument = null;
  1230. _this7.pdfThumbnailViewer.setDocument(null);
  1231. _this7.pdfViewer.setDocument(null);
  1232. _this7.pdfLinkService.setDocument(null);
  1233. _this7.pdfDocumentProperties.setDocument(null);
  1234. }
  1235. webViewerResetPermissions();
  1236. _this7.store = null;
  1237. _this7.isInitialViewSet = false;
  1238. _this7.downloadComplete = false;
  1239. _this7.url = "";
  1240. _this7.baseUrl = "";
  1241. _this7.documentInfo = null;
  1242. _this7.metadata = null;
  1243. _this7._contentDispositionFilename = null;
  1244. _this7._contentLength = null;
  1245. _this7.triggerDelayedFallback = null;
  1246. _this7._saveInProgress = false;
  1247. _this7._cancelIdleCallbacks();
  1248. promises.push(_this7._destroyScriptingInstance());
  1249. _this7.pdfSidebar.reset();
  1250. _this7.pdfOutlineViewer.reset();
  1251. _this7.pdfAttachmentViewer.reset();
  1252. _this7.pdfLayerViewer.reset();
  1253. if (_this7.pdfHistory) {
  1254. _this7.pdfHistory.reset();
  1255. }
  1256. if (_this7.findBar) {
  1257. _this7.findBar.reset();
  1258. }
  1259. _this7.toolbar.reset();
  1260. _this7.secondaryToolbar.reset();
  1261. if (typeof PDFBug !== "undefined") {
  1262. PDFBug.cleanup();
  1263. }
  1264. _context8.next = 33;
  1265. return Promise.all(promises);
  1266. case 33:
  1267. return _context8.abrupt("return", undefined);
  1268. case 34:
  1269. case "end":
  1270. return _context8.stop();
  1271. }
  1272. }
  1273. }, _callee8);
  1274. }))();
  1275. },
  1276. open: function open(file, args) {
  1277. var _this8 = this;
  1278. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
  1279. var workerParameters, key, parameters, apiParameters, _key, value, _key2, loadingTask;
  1280. return _regenerator["default"].wrap(function _callee9$(_context9) {
  1281. while (1) {
  1282. switch (_context9.prev = _context9.next) {
  1283. case 0:
  1284. if (!_this8.pdfLoadingTask) {
  1285. _context9.next = 3;
  1286. break;
  1287. }
  1288. _context9.next = 3;
  1289. return _this8.close();
  1290. case 3:
  1291. workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
  1292. for (key in workerParameters) {
  1293. _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key];
  1294. }
  1295. parameters = Object.create(null);
  1296. if (typeof file === "string") {
  1297. _this8.setTitleUsingUrl(file);
  1298. parameters.url = file;
  1299. } else if (file && "byteLength" in file) {
  1300. parameters.data = file;
  1301. } else if (file.url && file.originalUrl) {
  1302. _this8.setTitleUsingUrl(file.originalUrl);
  1303. parameters.url = file.url;
  1304. }
  1305. apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
  1306. for (_key in apiParameters) {
  1307. value = apiParameters[_key];
  1308. if (_key === "docBaseUrl" && !value) {}
  1309. parameters[_key] = value;
  1310. }
  1311. if (args) {
  1312. for (_key2 in args) {
  1313. parameters[_key2] = args[_key2];
  1314. }
  1315. }
  1316. loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  1317. _this8.pdfLoadingTask = loadingTask;
  1318. loadingTask.onPassword = function (updateCallback, reason) {
  1319. _this8.pdfLinkService.externalLinkEnabled = false;
  1320. _this8.passwordPrompt.setUpdateCallback(updateCallback, reason);
  1321. _this8.passwordPrompt.open();
  1322. };
  1323. loadingTask.onProgress = function (_ref) {
  1324. var loaded = _ref.loaded,
  1325. total = _ref.total;
  1326. _this8.progress(loaded / total);
  1327. };
  1328. loadingTask.onUnsupportedFeature = _this8.fallback.bind(_this8);
  1329. return _context9.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
  1330. _this8.load(pdfDocument);
  1331. }, function (exception) {
  1332. if (loadingTask !== _this8.pdfLoadingTask) {
  1333. return undefined;
  1334. }
  1335. var message = exception === null || exception === void 0 ? void 0 : exception.message;
  1336. var loadingErrorMessage;
  1337. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  1338. loadingErrorMessage = _this8.l10n.get("invalid_file_error", null, "Invalid or corrupted PDF file.");
  1339. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  1340. loadingErrorMessage = _this8.l10n.get("missing_file_error", null, "Missing PDF file.");
  1341. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  1342. loadingErrorMessage = _this8.l10n.get("unexpected_response_error", null, "Unexpected server response.");
  1343. } else {
  1344. loadingErrorMessage = _this8.l10n.get("loading_error", null, "An error occurred while loading the PDF.");
  1345. }
  1346. return loadingErrorMessage.then(function (msg) {
  1347. _this8.error(msg, {
  1348. message: message
  1349. });
  1350. throw exception;
  1351. });
  1352. }));
  1353. case 16:
  1354. case "end":
  1355. return _context9.stop();
  1356. }
  1357. }
  1358. }, _callee9);
  1359. }))();
  1360. },
  1361. download: function download() {
  1362. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  1363. _ref2$sourceEventType = _ref2.sourceEventType,
  1364. sourceEventType = _ref2$sourceEventType === void 0 ? "download" : _ref2$sourceEventType;
  1365. function downloadByUrl() {
  1366. downloadManager.downloadUrl(url, filename);
  1367. }
  1368. var downloadManager = this.downloadManager,
  1369. url = this.baseUrl,
  1370. filename = this._docFilename;
  1371. if (!this.pdfDocument || !this.downloadComplete) {
  1372. downloadByUrl();
  1373. return;
  1374. }
  1375. this.pdfDocument.getData().then(function (data) {
  1376. var blob = new Blob([data], {
  1377. type: "application/pdf"
  1378. });
  1379. downloadManager.download(blob, url, filename, sourceEventType);
  1380. })["catch"](downloadByUrl);
  1381. },
  1382. save: function save() {
  1383. var _arguments = arguments,
  1384. _this9 = this;
  1385. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
  1386. var _this9$_scriptingInst;
  1387. var _ref3, _ref3$sourceEventType, sourceEventType, downloadManager, url, filename;
  1388. return _regenerator["default"].wrap(function _callee11$(_context11) {
  1389. while (1) {
  1390. switch (_context11.prev = _context11.next) {
  1391. case 0:
  1392. _ref3 = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {}, _ref3$sourceEventType = _ref3.sourceEventType, sourceEventType = _ref3$sourceEventType === void 0 ? "download" : _ref3$sourceEventType;
  1393. if (!_this9._saveInProgress) {
  1394. _context11.next = 3;
  1395. break;
  1396. }
  1397. return _context11.abrupt("return");
  1398. case 3:
  1399. downloadManager = _this9.downloadManager, url = _this9.baseUrl, filename = _this9._docFilename;
  1400. if (!(!_this9.pdfDocument || !_this9.downloadComplete)) {
  1401. _context11.next = 7;
  1402. break;
  1403. }
  1404. _this9.download({
  1405. sourceEventType: sourceEventType
  1406. });
  1407. return _context11.abrupt("return");
  1408. case 7:
  1409. _this9._saveInProgress = true;
  1410. _context11.next = 10;
  1411. return (_this9$_scriptingInst = _this9._scriptingInstance) === null || _this9$_scriptingInst === void 0 ? void 0 : _this9$_scriptingInst.scripting.dispatchEventInSandbox({
  1412. id: "doc",
  1413. name: "WillSave"
  1414. });
  1415. case 10:
  1416. _this9.pdfDocument.saveDocument(_this9.pdfDocument.annotationStorage).then(function (data) {
  1417. var blob = new Blob([data], {
  1418. type: "application/pdf"
  1419. });
  1420. downloadManager.download(blob, url, filename, sourceEventType);
  1421. })["catch"](function () {
  1422. _this9.download({
  1423. sourceEventType: sourceEventType
  1424. });
  1425. })["finally"]( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee10() {
  1426. var _this9$_scriptingInst2;
  1427. return _regenerator["default"].wrap(function _callee10$(_context10) {
  1428. while (1) {
  1429. switch (_context10.prev = _context10.next) {
  1430. case 0:
  1431. _context10.next = 2;
  1432. return (_this9$_scriptingInst2 = _this9._scriptingInstance) === null || _this9$_scriptingInst2 === void 0 ? void 0 : _this9$_scriptingInst2.scripting.dispatchEventInSandbox({
  1433. id: "doc",
  1434. name: "DidSave"
  1435. });
  1436. case 2:
  1437. _this9._saveInProgress = false;
  1438. case 3:
  1439. case "end":
  1440. return _context10.stop();
  1441. }
  1442. }
  1443. }, _callee10);
  1444. })));
  1445. case 11:
  1446. case "end":
  1447. return _context11.stop();
  1448. }
  1449. }
  1450. }, _callee11);
  1451. }))();
  1452. },
  1453. downloadOrSave: function downloadOrSave(options) {
  1454. var _this$pdfDocument;
  1455. if (((_this$pdfDocument = this.pdfDocument) === null || _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage.size) > 0) {
  1456. this.save(options);
  1457. } else {
  1458. this.download(options);
  1459. }
  1460. },
  1461. _delayedFallback: function _delayedFallback(featureId) {
  1462. var _this10 = this;
  1463. this.externalServices.reportTelemetry({
  1464. type: "unsupportedFeature",
  1465. featureId: featureId
  1466. });
  1467. if (!this.triggerDelayedFallback) {
  1468. this.triggerDelayedFallback = function () {
  1469. _this10.fallback(featureId);
  1470. _this10.triggerDelayedFallback = null;
  1471. };
  1472. }
  1473. },
  1474. fallback: function fallback(featureId) {
  1475. var _this11 = this;
  1476. this.externalServices.reportTelemetry({
  1477. type: "unsupportedFeature",
  1478. featureId: featureId
  1479. });
  1480. if (this.fellback) {
  1481. return;
  1482. }
  1483. this.fellback = true;
  1484. this.externalServices.fallback({
  1485. featureId: featureId,
  1486. url: this.baseUrl
  1487. }).then(function (download) {
  1488. if (!download) {
  1489. return;
  1490. }
  1491. _this11.download({
  1492. sourceEventType: "download"
  1493. });
  1494. });
  1495. },
  1496. error: function error(message, moreInfo) {
  1497. var moreInfoText = [this.l10n.get("error_version_info", {
  1498. version: _pdfjsLib.version || "?",
  1499. build: _pdfjsLib.build || "?"
  1500. }, "PDF.js v{{version}} (build: {{build}})")];
  1501. if (moreInfo) {
  1502. moreInfoText.push(this.l10n.get("error_message", {
  1503. message: moreInfo.message
  1504. }, "Message: {{message}}"));
  1505. if (moreInfo.stack) {
  1506. moreInfoText.push(this.l10n.get("error_stack", {
  1507. stack: moreInfo.stack
  1508. }, "Stack: {{stack}}"));
  1509. } else {
  1510. if (moreInfo.filename) {
  1511. moreInfoText.push(this.l10n.get("error_file", {
  1512. file: moreInfo.filename
  1513. }, "File: {{file}}"));
  1514. }
  1515. if (moreInfo.lineNumber) {
  1516. moreInfoText.push(this.l10n.get("error_line", {
  1517. line: moreInfo.lineNumber
  1518. }, "Line: {{line}}"));
  1519. }
  1520. }
  1521. }
  1522. var errorWrapperConfig = this.appConfig.errorWrapper;
  1523. var errorWrapper = errorWrapperConfig.container;
  1524. errorWrapper.removeAttribute("hidden");
  1525. var errorMessage = errorWrapperConfig.errorMessage;
  1526. errorMessage.textContent = message;
  1527. var closeButton = errorWrapperConfig.closeButton;
  1528. closeButton.onclick = function () {
  1529. errorWrapper.setAttribute("hidden", "true");
  1530. };
  1531. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  1532. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  1533. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  1534. moreInfoButton.onclick = function () {
  1535. errorMoreInfo.removeAttribute("hidden");
  1536. moreInfoButton.setAttribute("hidden", "true");
  1537. lessInfoButton.removeAttribute("hidden");
  1538. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + "px";
  1539. };
  1540. lessInfoButton.onclick = function () {
  1541. errorMoreInfo.setAttribute("hidden", "true");
  1542. moreInfoButton.removeAttribute("hidden");
  1543. lessInfoButton.setAttribute("hidden", "true");
  1544. };
  1545. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1546. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1547. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1548. moreInfoButton.removeAttribute("hidden");
  1549. lessInfoButton.setAttribute("hidden", "true");
  1550. Promise.all(moreInfoText).then(function (parts) {
  1551. errorMoreInfo.value = parts.join("\n");
  1552. });
  1553. },
  1554. progress: function progress(level) {
  1555. var _this12 = this;
  1556. if (this.downloadComplete) {
  1557. return;
  1558. }
  1559. var percent = Math.round(level * 100);
  1560. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1561. this.loadingBar.percent = percent;
  1562. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams.disableAutoFetch : _app_options.AppOptions.get("disableAutoFetch");
  1563. if (disableAutoFetch && percent) {
  1564. if (this.disableAutoFetchLoadingBarTimeout) {
  1565. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1566. this.disableAutoFetchLoadingBarTimeout = null;
  1567. }
  1568. this.loadingBar.show();
  1569. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  1570. _this12.loadingBar.hide();
  1571. _this12.disableAutoFetchLoadingBarTimeout = null;
  1572. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1573. }
  1574. }
  1575. },
  1576. load: function load(pdfDocument) {
  1577. var _this13 = this;
  1578. this.pdfDocument = pdfDocument;
  1579. pdfDocument.getDownloadInfo().then(function (_ref5) {
  1580. var length = _ref5.length;
  1581. _this13._contentLength = length;
  1582. _this13.downloadComplete = true;
  1583. _this13.loadingBar.hide();
  1584. firstPagePromise.then(function () {
  1585. _this13.eventBus.dispatch("documentloaded", {
  1586. source: _this13
  1587. });
  1588. });
  1589. });
  1590. var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function () {});
  1591. var pageModePromise = pdfDocument.getPageMode()["catch"](function () {});
  1592. var openActionPromise = pdfDocument.getOpenAction()["catch"](function () {});
  1593. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1594. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1595. var baseDocumentUrl;
  1596. baseDocumentUrl = null;
  1597. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1598. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1599. var pdfViewer = this.pdfViewer;
  1600. pdfViewer.setDocument(pdfDocument);
  1601. var firstPagePromise = pdfViewer.firstPagePromise,
  1602. onePageRendered = pdfViewer.onePageRendered,
  1603. pagesPromise = pdfViewer.pagesPromise;
  1604. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1605. pdfThumbnailViewer.setDocument(pdfDocument);
  1606. var storedPromise = (this.store = new _view_history.ViewHistory(pdfDocument.fingerprint)).getMultiple({
  1607. page: null,
  1608. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1609. scrollLeft: "0",
  1610. scrollTop: "0",
  1611. rotation: null,
  1612. sidebarView: _ui_utils.SidebarView.UNKNOWN,
  1613. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  1614. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  1615. })["catch"](function () {
  1616. return Object.create(null);
  1617. });
  1618. firstPagePromise.then(function (pdfPage) {
  1619. _this13.loadingBar.setWidth(_this13.appConfig.viewerContainer);
  1620. _this13._initializeAnnotationStorageCallbacks(pdfDocument);
  1621. Promise.all([_ui_utils.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then( /*#__PURE__*/function () {
  1622. var _ref7 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee12(_ref6) {
  1623. var _ref8, timeStamp, stored, pageLayout, pageMode, openAction, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
  1624. return _regenerator["default"].wrap(function _callee12$(_context12) {
  1625. while (1) {
  1626. switch (_context12.prev = _context12.next) {
  1627. case 0:
  1628. _ref8 = _slicedToArray(_ref6, 5), timeStamp = _ref8[0], stored = _ref8[1], pageLayout = _ref8[2], pageMode = _ref8[3], openAction = _ref8[4];
  1629. viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
  1630. _this13._initializePdfHistory({
  1631. fingerprint: pdfDocument.fingerprint,
  1632. viewOnLoad: viewOnLoad,
  1633. initialDest: openAction && openAction.dest
  1634. });
  1635. initialBookmark = _this13.initialBookmark;
  1636. zoom = _app_options.AppOptions.get("defaultZoomValue");
  1637. hash = zoom ? "zoom=".concat(zoom) : null;
  1638. rotation = null;
  1639. sidebarView = _app_options.AppOptions.get("sidebarViewOnLoad");
  1640. scrollMode = _app_options.AppOptions.get("scrollModeOnLoad");
  1641. spreadMode = _app_options.AppOptions.get("spreadModeOnLoad");
  1642. if (stored.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  1643. hash = "page=".concat(stored.page, "&zoom=").concat(zoom || stored.zoom, ",") + "".concat(stored.scrollLeft, ",").concat(stored.scrollTop);
  1644. rotation = parseInt(stored.rotation, 10);
  1645. if (sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  1646. sidebarView = stored.sidebarView | 0;
  1647. }
  1648. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  1649. scrollMode = stored.scrollMode | 0;
  1650. }
  1651. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1652. spreadMode = stored.spreadMode | 0;
  1653. }
  1654. }
  1655. if (pageMode && sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  1656. sidebarView = apiPageModeToSidebarView(pageMode);
  1657. }
  1658. if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1659. spreadMode = apiPageLayoutToSpreadMode(pageLayout);
  1660. }
  1661. _this13.setInitialView(hash, {
  1662. rotation: rotation,
  1663. sidebarView: sidebarView,
  1664. scrollMode: scrollMode,
  1665. spreadMode: spreadMode
  1666. });
  1667. _this13.eventBus.dispatch("documentinit", {
  1668. source: _this13
  1669. });
  1670. if (!_this13.isViewerEmbedded) {
  1671. pdfViewer.focus();
  1672. }
  1673. _this13._initializePermissions(pdfDocument);
  1674. _context12.next = 19;
  1675. return Promise.race([pagesPromise, new Promise(function (resolve) {
  1676. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  1677. })]);
  1678. case 19:
  1679. if (!(!initialBookmark && !hash)) {
  1680. _context12.next = 21;
  1681. break;
  1682. }
  1683. return _context12.abrupt("return");
  1684. case 21:
  1685. if (!pdfViewer.hasEqualPageSizes) {
  1686. _context12.next = 23;
  1687. break;
  1688. }
  1689. return _context12.abrupt("return");
  1690. case 23:
  1691. _this13.initialBookmark = initialBookmark;
  1692. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  1693. _this13.setInitialView(hash);
  1694. case 26:
  1695. case "end":
  1696. return _context12.stop();
  1697. }
  1698. }
  1699. }, _callee12);
  1700. }));
  1701. return function (_x2) {
  1702. return _ref7.apply(this, arguments);
  1703. };
  1704. }())["catch"](function () {
  1705. _this13.setInitialView();
  1706. }).then(function () {
  1707. pdfViewer.update();
  1708. });
  1709. });
  1710. pagesPromise.then(function () {
  1711. _this13._initializeAutoPrint(pdfDocument, openActionPromise);
  1712. });
  1713. onePageRendered.then(function () {
  1714. pdfDocument.getOutline().then(function (outline) {
  1715. _this13.pdfOutlineViewer.render({
  1716. outline: outline,
  1717. pdfDocument: pdfDocument
  1718. });
  1719. });
  1720. pdfDocument.getAttachments().then(function (attachments) {
  1721. _this13.pdfAttachmentViewer.render({
  1722. attachments: attachments
  1723. });
  1724. });
  1725. pdfViewer.optionalContentConfigPromise.then(function (optionalContentConfig) {
  1726. _this13.pdfLayerViewer.render({
  1727. optionalContentConfig: optionalContentConfig,
  1728. pdfDocument: pdfDocument
  1729. });
  1730. });
  1731. if ("requestIdleCallback" in window) {
  1732. var callback = window.requestIdleCallback(function () {
  1733. _this13._collectTelemetry(pdfDocument);
  1734. _this13._idleCallbacks["delete"](callback);
  1735. }, {
  1736. timeout: 1000
  1737. });
  1738. _this13._idleCallbacks.add(callback);
  1739. }
  1740. _this13._initializeJavaScript(pdfDocument);
  1741. });
  1742. this._initializePageLabels(pdfDocument);
  1743. this._initializeMetadata(pdfDocument);
  1744. },
  1745. _initializeJavaScript: function _initializeJavaScript(pdfDocument) {
  1746. var _this14 = this;
  1747. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee15() {
  1748. var _yield$Promise$all, _yield$Promise$all2, objects, calculationOrder, docActions, scripting, internalEvents, domEvents, updateFromSandbox, visitedPages, pageOpen, pageClose, dispatchEventInSandbox, mouseDown, mouseUp, _iterator4, _step4, _step4$value, name, listener, _iterator5, _step5, _step5$value, _name2, _listener2, _this14$metadata, _this14$metadata2;
  1749. return _regenerator["default"].wrap(function _callee15$(_context15) {
  1750. while (1) {
  1751. switch (_context15.prev = _context15.next) {
  1752. case 0:
  1753. if (_app_options.AppOptions.get("enableScripting")) {
  1754. _context15.next = 2;
  1755. break;
  1756. }
  1757. return _context15.abrupt("return");
  1758. case 2:
  1759. _context15.next = 4;
  1760. return Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
  1761. case 4:
  1762. _yield$Promise$all = _context15.sent;
  1763. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
  1764. objects = _yield$Promise$all2[0];
  1765. calculationOrder = _yield$Promise$all2[1];
  1766. docActions = _yield$Promise$all2[2];
  1767. if (!(!objects && !docActions)) {
  1768. _context15.next = 11;
  1769. break;
  1770. }
  1771. return _context15.abrupt("return");
  1772. case 11:
  1773. if (!(pdfDocument !== _this14.pdfDocument)) {
  1774. _context15.next = 13;
  1775. break;
  1776. }
  1777. return _context15.abrupt("return");
  1778. case 13:
  1779. scripting = _this14.externalServices.createScripting({
  1780. sandboxBundleSrc: _app_options.AppOptions.get("sandboxBundleSrc")
  1781. });
  1782. internalEvents = new Map(), domEvents = new Map();
  1783. _this14._scriptingInstance = {
  1784. scripting: scripting,
  1785. ready: false,
  1786. internalEvents: internalEvents,
  1787. domEvents: domEvents
  1788. };
  1789. if (_this14.documentInfo) {
  1790. _context15.next = 21;
  1791. break;
  1792. }
  1793. _context15.next = 19;
  1794. return new Promise(function (resolve) {
  1795. _this14.eventBus._on("metadataloaded", function (evt) {
  1796. resolve();
  1797. }, {
  1798. once: true
  1799. });
  1800. });
  1801. case 19:
  1802. if (!(pdfDocument !== _this14.pdfDocument)) {
  1803. _context15.next = 21;
  1804. break;
  1805. }
  1806. return _context15.abrupt("return");
  1807. case 21:
  1808. if (_this14._contentLength) {
  1809. _context15.next = 26;
  1810. break;
  1811. }
  1812. _context15.next = 24;
  1813. return new Promise(function (resolve) {
  1814. _this14.eventBus._on("documentloaded", function (evt) {
  1815. resolve();
  1816. }, {
  1817. once: true
  1818. });
  1819. });
  1820. case 24:
  1821. if (!(pdfDocument !== _this14.pdfDocument)) {
  1822. _context15.next = 26;
  1823. break;
  1824. }
  1825. return _context15.abrupt("return");
  1826. case 26:
  1827. updateFromSandbox = function updateFromSandbox(_ref9) {
  1828. var detail = _ref9.detail;
  1829. var id = detail.id,
  1830. command = detail.command,
  1831. value = detail.value;
  1832. if (!id) {
  1833. switch (command) {
  1834. case "clear":
  1835. console.clear();
  1836. break;
  1837. case "error":
  1838. console.error(value);
  1839. break;
  1840. case "layout":
  1841. _this14.pdfViewer.spreadMode = apiPageLayoutToSpreadMode(value);
  1842. break;
  1843. case "page-num":
  1844. _this14.pdfViewer.currentPageNumber = value + 1;
  1845. break;
  1846. case "print":
  1847. _this14.pdfViewer.pagesPromise.then(function () {
  1848. _this14.triggerPrinting();
  1849. });
  1850. break;
  1851. case "println":
  1852. console.log(value);
  1853. break;
  1854. case "zoom":
  1855. _this14.pdfViewer.currentScaleValue = value;
  1856. break;
  1857. }
  1858. return;
  1859. }
  1860. var element = document.getElementById(id);
  1861. if (element) {
  1862. element.dispatchEvent(new CustomEvent("updatefromsandbox", {
  1863. detail: detail
  1864. }));
  1865. } else {
  1866. if (value !== undefined && value !== null) {
  1867. pdfDocument.annotationStorage.setValue(id, value);
  1868. }
  1869. }
  1870. };
  1871. internalEvents.set("updatefromsandbox", updateFromSandbox);
  1872. visitedPages = new Map();
  1873. pageOpen = function pageOpen(_ref10) {
  1874. var pageNumber = _ref10.pageNumber,
  1875. actionsPromise = _ref10.actionsPromise;
  1876. visitedPages.set(pageNumber, _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
  1877. var _this14$_scriptingIns;
  1878. var actions;
  1879. return _regenerator["default"].wrap(function _callee13$(_context13) {
  1880. while (1) {
  1881. switch (_context13.prev = _context13.next) {
  1882. case 0:
  1883. actions = null;
  1884. if (visitedPages.has(pageNumber)) {
  1885. _context13.next = 7;
  1886. break;
  1887. }
  1888. _context13.next = 4;
  1889. return actionsPromise;
  1890. case 4:
  1891. actions = _context13.sent;
  1892. if (!(pdfDocument !== _this14.pdfDocument)) {
  1893. _context13.next = 7;
  1894. break;
  1895. }
  1896. return _context13.abrupt("return");
  1897. case 7:
  1898. _context13.next = 9;
  1899. return (_this14$_scriptingIns = _this14._scriptingInstance) === null || _this14$_scriptingIns === void 0 ? void 0 : _this14$_scriptingIns.scripting.dispatchEventInSandbox({
  1900. id: "page",
  1901. name: "PageOpen",
  1902. pageNumber: pageNumber,
  1903. actions: actions
  1904. });
  1905. case 9:
  1906. case "end":
  1907. return _context13.stop();
  1908. }
  1909. }
  1910. }, _callee13);
  1911. }))());
  1912. };
  1913. pageClose = /*#__PURE__*/function () {
  1914. var _ref13 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee14(_ref12) {
  1915. var _this14$_scriptingIns2;
  1916. var pageNumber, actionsPromise;
  1917. return _regenerator["default"].wrap(function _callee14$(_context14) {
  1918. while (1) {
  1919. switch (_context14.prev = _context14.next) {
  1920. case 0:
  1921. pageNumber = _ref12.pageNumber;
  1922. actionsPromise = visitedPages.get(pageNumber);
  1923. if (actionsPromise) {
  1924. _context14.next = 4;
  1925. break;
  1926. }
  1927. return _context14.abrupt("return");
  1928. case 4:
  1929. visitedPages.set(pageNumber, null);
  1930. _context14.next = 7;
  1931. return actionsPromise;
  1932. case 7:
  1933. if (!(pdfDocument !== _this14.pdfDocument)) {
  1934. _context14.next = 9;
  1935. break;
  1936. }
  1937. return _context14.abrupt("return");
  1938. case 9:
  1939. _context14.next = 11;
  1940. return (_this14$_scriptingIns2 = _this14._scriptingInstance) === null || _this14$_scriptingIns2 === void 0 ? void 0 : _this14$_scriptingIns2.scripting.dispatchEventInSandbox({
  1941. id: "page",
  1942. name: "PageClose",
  1943. pageNumber: pageNumber
  1944. });
  1945. case 11:
  1946. case "end":
  1947. return _context14.stop();
  1948. }
  1949. }
  1950. }, _callee14);
  1951. }));
  1952. return function pageClose(_x3) {
  1953. return _ref13.apply(this, arguments);
  1954. };
  1955. }();
  1956. internalEvents.set("pageopen", pageOpen);
  1957. internalEvents.set("pageclose", pageClose);
  1958. dispatchEventInSandbox = function dispatchEventInSandbox(_ref14) {
  1959. var detail = _ref14.detail;
  1960. scripting.dispatchEventInSandbox(detail);
  1961. };
  1962. internalEvents.set("dispatcheventinsandbox", dispatchEventInSandbox);
  1963. mouseDown = function mouseDown(event) {
  1964. _this14._mouseState.isDown = true;
  1965. };
  1966. domEvents.set("mousedown", mouseDown);
  1967. mouseUp = function mouseUp(event) {
  1968. _this14._mouseState.isDown = false;
  1969. };
  1970. domEvents.set("mouseup", mouseUp);
  1971. _iterator4 = _createForOfIteratorHelper(internalEvents);
  1972. try {
  1973. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  1974. _step4$value = _slicedToArray(_step4.value, 2), name = _step4$value[0], listener = _step4$value[1];
  1975. _this14.eventBus._on(name, listener);
  1976. }
  1977. } catch (err) {
  1978. _iterator4.e(err);
  1979. } finally {
  1980. _iterator4.f();
  1981. }
  1982. _iterator5 = _createForOfIteratorHelper(domEvents);
  1983. try {
  1984. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  1985. _step5$value = _slicedToArray(_step5.value, 2), _name2 = _step5$value[0], _listener2 = _step5$value[1];
  1986. window.addEventListener(_name2, _listener2);
  1987. }
  1988. } catch (err) {
  1989. _iterator5.e(err);
  1990. } finally {
  1991. _iterator5.f();
  1992. }
  1993. _context15.prev = 43;
  1994. _context15.next = 46;
  1995. return scripting.createSandbox({
  1996. objects: objects,
  1997. calculationOrder: calculationOrder,
  1998. appInfo: {
  1999. platform: navigator.platform,
  2000. language: navigator.language
  2001. },
  2002. docInfo: _objectSpread(_objectSpread({}, _this14.documentInfo), {}, {
  2003. baseURL: _this14.baseUrl,
  2004. filesize: _this14._contentLength,
  2005. filename: _this14._docFilename,
  2006. metadata: (_this14$metadata = _this14.metadata) === null || _this14$metadata === void 0 ? void 0 : _this14$metadata.getRaw(),
  2007. authors: (_this14$metadata2 = _this14.metadata) === null || _this14$metadata2 === void 0 ? void 0 : _this14$metadata2.get("dc:creator"),
  2008. numPages: pdfDocument.numPages,
  2009. URL: _this14.url,
  2010. actions: docActions
  2011. })
  2012. });
  2013. case 46:
  2014. if (_this14.externalServices.isInAutomation) {
  2015. _this14.eventBus.dispatch("sandboxcreated", {
  2016. source: _this14
  2017. });
  2018. }
  2019. _context15.next = 54;
  2020. break;
  2021. case 49:
  2022. _context15.prev = 49;
  2023. _context15.t0 = _context15["catch"](43);
  2024. console.error("_initializeJavaScript: \"".concat(_context15.t0 === null || _context15.t0 === void 0 ? void 0 : _context15.t0.message, "\"."));
  2025. _this14._destroyScriptingInstance();
  2026. return _context15.abrupt("return");
  2027. case 54:
  2028. _context15.next = 56;
  2029. return scripting.dispatchEventInSandbox({
  2030. id: "doc",
  2031. name: "Open"
  2032. });
  2033. case 56:
  2034. _context15.next = 58;
  2035. return _this14.pdfViewer.initializeScriptingEvents();
  2036. case 58:
  2037. Promise.resolve().then(function () {
  2038. if (_this14._scriptingInstance) {
  2039. _this14._scriptingInstance.ready = true;
  2040. }
  2041. });
  2042. case 59:
  2043. case "end":
  2044. return _context15.stop();
  2045. }
  2046. }
  2047. }, _callee15, null, [[43, 49]]);
  2048. }))();
  2049. },
  2050. _collectTelemetry: function _collectTelemetry(pdfDocument) {
  2051. var _this15 = this;
  2052. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee16() {
  2053. var markInfo, tagged;
  2054. return _regenerator["default"].wrap(function _callee16$(_context16) {
  2055. while (1) {
  2056. switch (_context16.prev = _context16.next) {
  2057. case 0:
  2058. _context16.next = 2;
  2059. return _this15.pdfDocument.getMarkInfo();
  2060. case 2:
  2061. markInfo = _context16.sent;
  2062. if (!(pdfDocument !== _this15.pdfDocument)) {
  2063. _context16.next = 5;
  2064. break;
  2065. }
  2066. return _context16.abrupt("return");
  2067. case 5:
  2068. tagged = (markInfo === null || markInfo === void 0 ? void 0 : markInfo.Marked) || false;
  2069. _this15.externalServices.reportTelemetry({
  2070. type: "tagged",
  2071. tagged: tagged
  2072. });
  2073. case 7:
  2074. case "end":
  2075. return _context16.stop();
  2076. }
  2077. }
  2078. }, _callee16);
  2079. }))();
  2080. },
  2081. _initializeAutoPrint: function _initializeAutoPrint(pdfDocument, openActionPromise) {
  2082. var _this16 = this;
  2083. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee17() {
  2084. var _yield$Promise$all3, _yield$Promise$all4, openAction, javaScript, triggerAutoPrint, _iterator6, _step6, js;
  2085. return _regenerator["default"].wrap(function _callee17$(_context17) {
  2086. while (1) {
  2087. switch (_context17.prev = _context17.next) {
  2088. case 0:
  2089. _context17.next = 2;
  2090. return Promise.all([openActionPromise, !_app_options.AppOptions.get("enableScripting") ? pdfDocument.getJavaScript() : null]);
  2091. case 2:
  2092. _yield$Promise$all3 = _context17.sent;
  2093. _yield$Promise$all4 = _slicedToArray(_yield$Promise$all3, 2);
  2094. openAction = _yield$Promise$all4[0];
  2095. javaScript = _yield$Promise$all4[1];
  2096. if (!(pdfDocument !== _this16.pdfDocument)) {
  2097. _context17.next = 8;
  2098. break;
  2099. }
  2100. return _context17.abrupt("return");
  2101. case 8:
  2102. triggerAutoPrint = false;
  2103. if ((openAction === null || openAction === void 0 ? void 0 : openAction.action) === "Print") {
  2104. triggerAutoPrint = true;
  2105. }
  2106. if (!javaScript) {
  2107. _context17.next = 31;
  2108. break;
  2109. }
  2110. javaScript.some(function (js) {
  2111. if (!js) {
  2112. return false;
  2113. }
  2114. console.warn("Warning: JavaScript is not supported");
  2115. _this16._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  2116. return true;
  2117. });
  2118. if (triggerAutoPrint) {
  2119. _context17.next = 31;
  2120. break;
  2121. }
  2122. _iterator6 = _createForOfIteratorHelper(javaScript);
  2123. _context17.prev = 14;
  2124. _iterator6.s();
  2125. case 16:
  2126. if ((_step6 = _iterator6.n()).done) {
  2127. _context17.next = 23;
  2128. break;
  2129. }
  2130. js = _step6.value;
  2131. if (!(js && _ui_utils.AutoPrintRegExp.test(js))) {
  2132. _context17.next = 21;
  2133. break;
  2134. }
  2135. triggerAutoPrint = true;
  2136. return _context17.abrupt("break", 23);
  2137. case 21:
  2138. _context17.next = 16;
  2139. break;
  2140. case 23:
  2141. _context17.next = 28;
  2142. break;
  2143. case 25:
  2144. _context17.prev = 25;
  2145. _context17.t0 = _context17["catch"](14);
  2146. _iterator6.e(_context17.t0);
  2147. case 28:
  2148. _context17.prev = 28;
  2149. _iterator6.f();
  2150. return _context17.finish(28);
  2151. case 31:
  2152. if (triggerAutoPrint) {
  2153. _this16.triggerPrinting();
  2154. }
  2155. case 32:
  2156. case "end":
  2157. return _context17.stop();
  2158. }
  2159. }
  2160. }, _callee17, null, [[14, 25, 28, 31]]);
  2161. }))();
  2162. },
  2163. _initializeMetadata: function _initializeMetadata(pdfDocument) {
  2164. var _this17 = this;
  2165. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee18() {
  2166. var _this17$_contentLengt;
  2167. var _yield$pdfDocument$ge, info, metadata, contentDispositionFilename, contentLength, pdfTitle, infoTitle, metadataTitle, versionId, generatorId, producer, formType;
  2168. return _regenerator["default"].wrap(function _callee18$(_context18) {
  2169. while (1) {
  2170. switch (_context18.prev = _context18.next) {
  2171. case 0:
  2172. _context18.next = 2;
  2173. return pdfDocument.getMetadata();
  2174. case 2:
  2175. _yield$pdfDocument$ge = _context18.sent;
  2176. info = _yield$pdfDocument$ge.info;
  2177. metadata = _yield$pdfDocument$ge.metadata;
  2178. contentDispositionFilename = _yield$pdfDocument$ge.contentDispositionFilename;
  2179. contentLength = _yield$pdfDocument$ge.contentLength;
  2180. if (!(pdfDocument !== _this17.pdfDocument)) {
  2181. _context18.next = 9;
  2182. break;
  2183. }
  2184. return _context18.abrupt("return");
  2185. case 9:
  2186. _this17.documentInfo = info;
  2187. _this17.metadata = metadata;
  2188. _this17._contentDispositionFilename = contentDispositionFilename;
  2189. (_this17$_contentLengt = _this17._contentLength) !== null && _this17$_contentLengt !== void 0 ? _this17$_contentLengt : _this17._contentLength = contentLength;
  2190. console.log("PDF ".concat(pdfDocument.fingerprint, " [").concat(info.PDFFormatVersion, " ") + "".concat((info.Producer || "-").trim(), " / ").concat((info.Creator || "-").trim(), "] ") + "(PDF.js: ".concat(_pdfjsLib.version || "-") + "".concat(_this17.pdfViewer.enableWebGL ? " [WebGL]" : "", ")"));
  2191. infoTitle = info && info.Title;
  2192. if (infoTitle) {
  2193. pdfTitle = infoTitle;
  2194. }
  2195. metadataTitle = metadata && metadata.get("dc:title");
  2196. if (metadataTitle) {
  2197. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
  2198. pdfTitle = metadataTitle;
  2199. }
  2200. }
  2201. if (pdfTitle) {
  2202. _this17.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
  2203. } else if (contentDispositionFilename) {
  2204. _this17.setTitle(contentDispositionFilename);
  2205. }
  2206. if (info.IsXFAPresent && !info.IsAcroFormPresent) {
  2207. console.warn("Warning: XFA is not supported");
  2208. _this17._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  2209. } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !_this17.pdfViewer.renderInteractiveForms) {
  2210. console.warn("Warning: Interactive form support is not enabled");
  2211. _this17._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  2212. }
  2213. versionId = "other";
  2214. if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
  2215. versionId = "v".concat(info.PDFFormatVersion.replace(".", "_"));
  2216. }
  2217. generatorId = "other";
  2218. if (info.Producer) {
  2219. producer = info.Producer.toLowerCase();
  2220. KNOWN_GENERATORS.some(function (generator) {
  2221. if (!producer.includes(generator)) {
  2222. return false;
  2223. }
  2224. generatorId = generator.replace(/[ .-]/g, "_");
  2225. return true;
  2226. });
  2227. }
  2228. formType = null;
  2229. if (info.IsXFAPresent) {
  2230. formType = "xfa";
  2231. } else if (info.IsAcroFormPresent) {
  2232. formType = "acroform";
  2233. }
  2234. _this17.externalServices.reportTelemetry({
  2235. type: "documentInfo",
  2236. version: versionId,
  2237. generator: generatorId,
  2238. formType: formType
  2239. });
  2240. _this17.eventBus.dispatch("metadataloaded", {
  2241. source: _this17
  2242. });
  2243. case 28:
  2244. case "end":
  2245. return _context18.stop();
  2246. }
  2247. }
  2248. }, _callee18);
  2249. }))();
  2250. },
  2251. _initializePageLabels: function _initializePageLabels(pdfDocument) {
  2252. var _this18 = this;
  2253. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee19() {
  2254. var labels, numLabels, i, pdfViewer, pdfThumbnailViewer, toolbar;
  2255. return _regenerator["default"].wrap(function _callee19$(_context19) {
  2256. while (1) {
  2257. switch (_context19.prev = _context19.next) {
  2258. case 0:
  2259. _context19.next = 2;
  2260. return pdfDocument.getPageLabels();
  2261. case 2:
  2262. labels = _context19.sent;
  2263. if (!(pdfDocument !== _this18.pdfDocument)) {
  2264. _context19.next = 5;
  2265. break;
  2266. }
  2267. return _context19.abrupt("return");
  2268. case 5:
  2269. if (!(!labels || _app_options.AppOptions.get("disablePageLabels"))) {
  2270. _context19.next = 7;
  2271. break;
  2272. }
  2273. return _context19.abrupt("return");
  2274. case 7:
  2275. numLabels = labels.length;
  2276. if (!(numLabels !== _this18.pagesCount)) {
  2277. _context19.next = 11;
  2278. break;
  2279. }
  2280. console.error("The number of Page Labels does not match the number of pages in the document.");
  2281. return _context19.abrupt("return");
  2282. case 11:
  2283. i = 0;
  2284. while (i < numLabels && labels[i] === (i + 1).toString()) {
  2285. i++;
  2286. }
  2287. if (!(i === numLabels)) {
  2288. _context19.next = 15;
  2289. break;
  2290. }
  2291. return _context19.abrupt("return");
  2292. case 15:
  2293. pdfViewer = _this18.pdfViewer, pdfThumbnailViewer = _this18.pdfThumbnailViewer, toolbar = _this18.toolbar;
  2294. pdfViewer.setPageLabels(labels);
  2295. pdfThumbnailViewer.setPageLabels(labels);
  2296. toolbar.setPagesCount(numLabels, true);
  2297. toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  2298. case 20:
  2299. case "end":
  2300. return _context19.stop();
  2301. }
  2302. }
  2303. }, _callee19);
  2304. }))();
  2305. },
  2306. _initializePdfHistory: function _initializePdfHistory(_ref15) {
  2307. var fingerprint = _ref15.fingerprint,
  2308. viewOnLoad = _ref15.viewOnLoad,
  2309. _ref15$initialDest = _ref15.initialDest,
  2310. initialDest = _ref15$initialDest === void 0 ? null : _ref15$initialDest;
  2311. if (this.isViewerEmbedded || _app_options.AppOptions.get("disableHistory")) {
  2312. return;
  2313. }
  2314. this.pdfHistory.initialize({
  2315. fingerprint: fingerprint,
  2316. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  2317. updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
  2318. });
  2319. if (this.pdfHistory.initialBookmark) {
  2320. this.initialBookmark = this.pdfHistory.initialBookmark;
  2321. this.initialRotation = this.pdfHistory.initialRotation;
  2322. }
  2323. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  2324. this.initialBookmark = JSON.stringify(initialDest);
  2325. this.pdfHistory.push({
  2326. explicitDest: initialDest,
  2327. pageNumber: null
  2328. });
  2329. }
  2330. },
  2331. _initializePermissions: function _initializePermissions(pdfDocument) {
  2332. var _this19 = this;
  2333. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee20() {
  2334. var permissions;
  2335. return _regenerator["default"].wrap(function _callee20$(_context20) {
  2336. while (1) {
  2337. switch (_context20.prev = _context20.next) {
  2338. case 0:
  2339. _context20.next = 2;
  2340. return pdfDocument.getPermissions();
  2341. case 2:
  2342. permissions = _context20.sent;
  2343. if (!(pdfDocument !== _this19.pdfDocument)) {
  2344. _context20.next = 5;
  2345. break;
  2346. }
  2347. return _context20.abrupt("return");
  2348. case 5:
  2349. if (!(!permissions || !_app_options.AppOptions.get("enablePermissions"))) {
  2350. _context20.next = 7;
  2351. break;
  2352. }
  2353. return _context20.abrupt("return");
  2354. case 7:
  2355. if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY)) {
  2356. _this19.appConfig.viewerContainer.classList.add(ENABLE_PERMISSIONS_CLASS);
  2357. }
  2358. case 8:
  2359. case "end":
  2360. return _context20.stop();
  2361. }
  2362. }
  2363. }, _callee20);
  2364. }))();
  2365. },
  2366. _initializeAnnotationStorageCallbacks: function _initializeAnnotationStorageCallbacks(pdfDocument) {
  2367. if (pdfDocument !== this.pdfDocument) {
  2368. return;
  2369. }
  2370. var annotationStorage = pdfDocument.annotationStorage;
  2371. annotationStorage.onSetModified = function () {
  2372. window.addEventListener("beforeunload", beforeUnload);
  2373. };
  2374. annotationStorage.onResetModified = function () {
  2375. window.removeEventListener("beforeunload", beforeUnload);
  2376. };
  2377. },
  2378. setInitialView: function setInitialView(storedHash) {
  2379. var _this20 = this;
  2380. var _ref16 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  2381. rotation = _ref16.rotation,
  2382. sidebarView = _ref16.sidebarView,
  2383. scrollMode = _ref16.scrollMode,
  2384. spreadMode = _ref16.spreadMode;
  2385. var setRotation = function setRotation(angle) {
  2386. if ((0, _ui_utils.isValidRotation)(angle)) {
  2387. _this20.pdfViewer.pagesRotation = angle;
  2388. }
  2389. };
  2390. var setViewerModes = function setViewerModes(scroll, spread) {
  2391. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  2392. _this20.pdfViewer.scrollMode = scroll;
  2393. }
  2394. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  2395. _this20.pdfViewer.spreadMode = spread;
  2396. }
  2397. };
  2398. this.isInitialViewSet = true;
  2399. this.pdfSidebar.setInitialView(sidebarView);
  2400. setViewerModes(scrollMode, spreadMode);
  2401. if (this.initialBookmark) {
  2402. setRotation(this.initialRotation);
  2403. delete this.initialRotation;
  2404. this.pdfLinkService.setHash(this.initialBookmark);
  2405. this.initialBookmark = null;
  2406. } else if (storedHash) {
  2407. setRotation(rotation);
  2408. this.pdfLinkService.setHash(storedHash);
  2409. }
  2410. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  2411. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  2412. if (!this.pdfViewer.currentScaleValue) {
  2413. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2414. }
  2415. },
  2416. cleanup: function cleanup() {
  2417. if (!this.pdfDocument) {
  2418. return;
  2419. }
  2420. this.pdfViewer.cleanup();
  2421. this.pdfThumbnailViewer.cleanup();
  2422. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  2423. this.pdfDocument.cleanup();
  2424. }
  2425. },
  2426. forceRendering: function forceRendering() {
  2427. this.pdfRenderingQueue.printing = !!this.printService;
  2428. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  2429. this.pdfRenderingQueue.renderHighestPriority();
  2430. },
  2431. beforePrint: function beforePrint() {
  2432. var _this$_scriptingInsta,
  2433. _this21 = this;
  2434. (_this$_scriptingInsta = this._scriptingInstance) === null || _this$_scriptingInsta === void 0 ? void 0 : _this$_scriptingInsta.scripting.dispatchEventInSandbox({
  2435. id: "doc",
  2436. name: "WillPrint"
  2437. });
  2438. if (this.printService) {
  2439. return;
  2440. }
  2441. if (!this.supportsPrinting) {
  2442. this.l10n.get("printing_not_supported", null, "Warning: Printing is not fully supported by this browser.").then(function (printMessage) {
  2443. _this21.error(printMessage);
  2444. });
  2445. return;
  2446. }
  2447. if (!this.pdfViewer.pageViewsReady) {
  2448. this.l10n.get("printing_not_ready", null, "Warning: The PDF is not fully loaded for printing.").then(function (notReadyMessage) {
  2449. window.alert(notReadyMessage);
  2450. });
  2451. return;
  2452. }
  2453. var pagesOverview = this.pdfViewer.getPagesOverview();
  2454. var printContainer = this.appConfig.printContainer;
  2455. var printResolution = _app_options.AppOptions.get("printResolution");
  2456. var optionalContentConfigPromise = this.pdfViewer.optionalContentConfigPromise;
  2457. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, this.l10n);
  2458. this.printService = printService;
  2459. this.forceRendering();
  2460. printService.layout();
  2461. this.externalServices.reportTelemetry({
  2462. type: "print"
  2463. });
  2464. },
  2465. afterPrint: function afterPrint() {
  2466. var _this$_scriptingInsta2;
  2467. (_this$_scriptingInsta2 = this._scriptingInstance) === null || _this$_scriptingInsta2 === void 0 ? void 0 : _this$_scriptingInsta2.scripting.dispatchEventInSandbox({
  2468. id: "doc",
  2469. name: "DidPrint"
  2470. });
  2471. if (this.printService) {
  2472. this.printService.destroy();
  2473. this.printService = null;
  2474. if (this.pdfDocument) {
  2475. this.pdfDocument.annotationStorage.resetModified();
  2476. }
  2477. }
  2478. this.forceRendering();
  2479. },
  2480. rotatePages: function rotatePages(delta) {
  2481. if (!this.pdfDocument) {
  2482. return;
  2483. }
  2484. var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
  2485. this.pdfViewer.pagesRotation = newRotation;
  2486. },
  2487. requestPresentationMode: function requestPresentationMode() {
  2488. if (!this.pdfPresentationMode) {
  2489. return;
  2490. }
  2491. this.pdfPresentationMode.request();
  2492. },
  2493. triggerPrinting: function triggerPrinting() {
  2494. if (!this.supportsPrinting) {
  2495. return;
  2496. }
  2497. window.print();
  2498. },
  2499. bindEvents: function bindEvents() {
  2500. var eventBus = this.eventBus,
  2501. _boundEvents = this._boundEvents;
  2502. _boundEvents.beforePrint = this.beforePrint.bind(this);
  2503. _boundEvents.afterPrint = this.afterPrint.bind(this);
  2504. eventBus._on("resize", webViewerResize);
  2505. eventBus._on("hashchange", webViewerHashchange);
  2506. eventBus._on("beforeprint", _boundEvents.beforePrint);
  2507. eventBus._on("afterprint", _boundEvents.afterPrint);
  2508. eventBus._on("pagerendered", webViewerPageRendered);
  2509. eventBus._on("updateviewarea", webViewerUpdateViewarea);
  2510. eventBus._on("pagechanging", webViewerPageChanging);
  2511. eventBus._on("scalechanging", webViewerScaleChanging);
  2512. eventBus._on("rotationchanging", webViewerRotationChanging);
  2513. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
  2514. eventBus._on("pagemode", webViewerPageMode);
  2515. eventBus._on("namedaction", webViewerNamedAction);
  2516. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
  2517. eventBus._on("presentationmode", webViewerPresentationMode);
  2518. eventBus._on("print", webViewerPrint);
  2519. eventBus._on("download", webViewerDownload);
  2520. eventBus._on("save", webViewerSave);
  2521. eventBus._on("firstpage", webViewerFirstPage);
  2522. eventBus._on("lastpage", webViewerLastPage);
  2523. eventBus._on("nextpage", webViewerNextPage);
  2524. eventBus._on("previouspage", webViewerPreviousPage);
  2525. eventBus._on("zoomin", webViewerZoomIn);
  2526. eventBus._on("zoomout", webViewerZoomOut);
  2527. eventBus._on("zoomreset", webViewerZoomReset);
  2528. eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
  2529. eventBus._on("scalechanged", webViewerScaleChanged);
  2530. eventBus._on("rotatecw", webViewerRotateCw);
  2531. eventBus._on("rotateccw", webViewerRotateCcw);
  2532. eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig);
  2533. eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
  2534. eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
  2535. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
  2536. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
  2537. eventBus._on("documentproperties", webViewerDocumentProperties);
  2538. eventBus._on("find", webViewerFind);
  2539. eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
  2540. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2541. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
  2542. if (_app_options.AppOptions.get("pdfBug")) {
  2543. _boundEvents.reportPageStatsPDFBug = reportPageStatsPDFBug;
  2544. eventBus._on("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2545. eventBus._on("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2546. }
  2547. eventBus._on("fileinputchange", webViewerFileInputChange);
  2548. eventBus._on("openfile", webViewerOpenFile);
  2549. },
  2550. bindWindowEvents: function bindWindowEvents() {
  2551. var eventBus = this.eventBus,
  2552. _boundEvents = this._boundEvents;
  2553. _boundEvents.windowResize = function () {
  2554. eventBus.dispatch("resize", {
  2555. source: window
  2556. });
  2557. };
  2558. _boundEvents.windowHashChange = function () {
  2559. eventBus.dispatch("hashchange", {
  2560. source: window,
  2561. hash: document.location.hash.substring(1)
  2562. });
  2563. };
  2564. _boundEvents.windowBeforePrint = function () {
  2565. eventBus.dispatch("beforeprint", {
  2566. source: window
  2567. });
  2568. };
  2569. _boundEvents.windowAfterPrint = function () {
  2570. eventBus.dispatch("afterprint", {
  2571. source: window
  2572. });
  2573. };
  2574. _boundEvents.windowUpdateFromSandbox = function (event) {
  2575. eventBus.dispatch("updatefromsandbox", {
  2576. source: window,
  2577. detail: event.detail
  2578. });
  2579. };
  2580. window.addEventListener("visibilitychange", webViewerVisibilityChange);
  2581. window.addEventListener("wheel", webViewerWheel, {
  2582. passive: false
  2583. });
  2584. window.addEventListener("touchstart", webViewerTouchStart, {
  2585. passive: false
  2586. });
  2587. window.addEventListener("click", webViewerClick);
  2588. window.addEventListener("keydown", webViewerKeyDown);
  2589. window.addEventListener("keyup", webViewerKeyUp);
  2590. window.addEventListener("resize", _boundEvents.windowResize);
  2591. window.addEventListener("hashchange", _boundEvents.windowHashChange);
  2592. window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2593. window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
  2594. window.addEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  2595. },
  2596. unbindEvents: function unbindEvents() {
  2597. var eventBus = this.eventBus,
  2598. _boundEvents = this._boundEvents;
  2599. eventBus._off("resize", webViewerResize);
  2600. eventBus._off("hashchange", webViewerHashchange);
  2601. eventBus._off("beforeprint", _boundEvents.beforePrint);
  2602. eventBus._off("afterprint", _boundEvents.afterPrint);
  2603. eventBus._off("pagerendered", webViewerPageRendered);
  2604. eventBus._off("updateviewarea", webViewerUpdateViewarea);
  2605. eventBus._off("pagechanging", webViewerPageChanging);
  2606. eventBus._off("scalechanging", webViewerScaleChanging);
  2607. eventBus._off("rotationchanging", webViewerRotationChanging);
  2608. eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
  2609. eventBus._off("pagemode", webViewerPageMode);
  2610. eventBus._off("namedaction", webViewerNamedAction);
  2611. eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
  2612. eventBus._off("presentationmode", webViewerPresentationMode);
  2613. eventBus._off("print", webViewerPrint);
  2614. eventBus._off("download", webViewerDownload);
  2615. eventBus._off("save", webViewerSave);
  2616. eventBus._off("firstpage", webViewerFirstPage);
  2617. eventBus._off("lastpage", webViewerLastPage);
  2618. eventBus._off("nextpage", webViewerNextPage);
  2619. eventBus._off("previouspage", webViewerPreviousPage);
  2620. eventBus._off("zoomin", webViewerZoomIn);
  2621. eventBus._off("zoomout", webViewerZoomOut);
  2622. eventBus._off("zoomreset", webViewerZoomReset);
  2623. eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
  2624. eventBus._off("scalechanged", webViewerScaleChanged);
  2625. eventBus._off("rotatecw", webViewerRotateCw);
  2626. eventBus._off("rotateccw", webViewerRotateCcw);
  2627. eventBus._off("optionalcontentconfig", webViewerOptionalContentConfig);
  2628. eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
  2629. eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
  2630. eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
  2631. eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
  2632. eventBus._off("documentproperties", webViewerDocumentProperties);
  2633. eventBus._off("find", webViewerFind);
  2634. eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
  2635. eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2636. eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
  2637. if (_boundEvents.reportPageStatsPDFBug) {
  2638. eventBus._off("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2639. eventBus._off("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2640. _boundEvents.reportPageStatsPDFBug = null;
  2641. }
  2642. eventBus._off("fileinputchange", webViewerFileInputChange);
  2643. eventBus._off("openfile", webViewerOpenFile);
  2644. _boundEvents.beforePrint = null;
  2645. _boundEvents.afterPrint = null;
  2646. },
  2647. unbindWindowEvents: function unbindWindowEvents() {
  2648. var _boundEvents = this._boundEvents;
  2649. window.removeEventListener("visibilitychange", webViewerVisibilityChange);
  2650. window.removeEventListener("wheel", webViewerWheel, {
  2651. passive: false
  2652. });
  2653. window.removeEventListener("touchstart", webViewerTouchStart, {
  2654. passive: false
  2655. });
  2656. window.removeEventListener("click", webViewerClick);
  2657. window.removeEventListener("keydown", webViewerKeyDown);
  2658. window.removeEventListener("keyup", webViewerKeyUp);
  2659. window.removeEventListener("resize", _boundEvents.windowResize);
  2660. window.removeEventListener("hashchange", _boundEvents.windowHashChange);
  2661. window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2662. window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
  2663. window.removeEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  2664. _boundEvents.windowResize = null;
  2665. _boundEvents.windowHashChange = null;
  2666. _boundEvents.windowBeforePrint = null;
  2667. _boundEvents.windowAfterPrint = null;
  2668. _boundEvents.windowUpdateFromSandbox = null;
  2669. },
  2670. accumulateWheelTicks: function accumulateWheelTicks(ticks) {
  2671. if (this._wheelUnusedTicks > 0 && ticks < 0 || this._wheelUnusedTicks < 0 && ticks > 0) {
  2672. this._wheelUnusedTicks = 0;
  2673. }
  2674. this._wheelUnusedTicks += ticks;
  2675. var wholeTicks = Math.sign(this._wheelUnusedTicks) * Math.floor(Math.abs(this._wheelUnusedTicks));
  2676. this._wheelUnusedTicks -= wholeTicks;
  2677. return wholeTicks;
  2678. },
  2679. get scriptingReady() {
  2680. var _this$_scriptingInsta3;
  2681. return ((_this$_scriptingInsta3 = this._scriptingInstance) === null || _this$_scriptingInsta3 === void 0 ? void 0 : _this$_scriptingInsta3.ready) || false;
  2682. }
  2683. };
  2684. exports.PDFViewerApplication = PDFViewerApplication;
  2685. var validateFileURL;
  2686. {
  2687. var HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
  2688. validateFileURL = function validateFileURL(file) {
  2689. if (file === undefined) {
  2690. return;
  2691. }
  2692. try {
  2693. var viewerOrigin = new URL(window.location.href).origin || "null";
  2694. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  2695. return;
  2696. }
  2697. var _URL = new URL(file, window.location.href),
  2698. origin = _URL.origin,
  2699. protocol = _URL.protocol;
  2700. if (origin !== viewerOrigin && protocol !== "blob:") {
  2701. throw new Error("file origin does not match viewer's");
  2702. }
  2703. } catch (ex) {
  2704. var message = ex && ex.message;
  2705. PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(function (loadingErrorMessage) {
  2706. PDFViewerApplication.error(loadingErrorMessage, {
  2707. message: message
  2708. });
  2709. });
  2710. throw ex;
  2711. }
  2712. };
  2713. }
  2714. function loadFakeWorker() {
  2715. return _loadFakeWorker.apply(this, arguments);
  2716. }
  2717. function _loadFakeWorker() {
  2718. _loadFakeWorker = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee21() {
  2719. return _regenerator["default"].wrap(function _callee21$(_context21) {
  2720. while (1) {
  2721. switch (_context21.prev = _context21.next) {
  2722. case 0:
  2723. if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
  2724. _pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get("workerSrc");
  2725. }
  2726. return _context21.abrupt("return", (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc()));
  2727. case 2:
  2728. case "end":
  2729. return _context21.stop();
  2730. }
  2731. }
  2732. }, _callee21);
  2733. }));
  2734. return _loadFakeWorker.apply(this, arguments);
  2735. }
  2736. function loadAndEnablePDFBug(enabledTabs) {
  2737. var appConfig = PDFViewerApplication.appConfig;
  2738. return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function () {
  2739. PDFBug.enable(enabledTabs);
  2740. PDFBug.init({
  2741. OPS: _pdfjsLib.OPS
  2742. }, appConfig.mainContainer);
  2743. });
  2744. }
  2745. function reportPageStatsPDFBug(_ref17) {
  2746. var pageNumber = _ref17.pageNumber;
  2747. if (typeof Stats === "undefined" || !Stats.enabled) {
  2748. return;
  2749. }
  2750. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  2751. var pageStats = pageView && pageView.pdfPage && pageView.pdfPage.stats;
  2752. if (!pageStats) {
  2753. return;
  2754. }
  2755. Stats.add(pageNumber, pageStats);
  2756. }
  2757. function webViewerInitialized() {
  2758. var appConfig = PDFViewerApplication.appConfig;
  2759. var file;
  2760. var queryString = document.location.search.substring(1);
  2761. var params = (0, _ui_utils.parseQueryString)(queryString);
  2762. file = "file" in params ? params.file : _app_options.AppOptions.get("defaultUrl");
  2763. validateFileURL(file);
  2764. var fileInput = document.createElement("input");
  2765. fileInput.id = appConfig.openFileInputName;
  2766. fileInput.className = "fileInput";
  2767. fileInput.setAttribute("type", "file");
  2768. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  2769. document.body.appendChild(fileInput);
  2770. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  2771. appConfig.toolbar.openFile.setAttribute("hidden", "true");
  2772. appConfig.secondaryToolbar.openFileButton.setAttribute("hidden", "true");
  2773. } else {
  2774. fileInput.value = null;
  2775. }
  2776. fileInput.addEventListener("change", function (evt) {
  2777. var files = evt.target.files;
  2778. if (!files || files.length === 0) {
  2779. return;
  2780. }
  2781. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  2782. source: this,
  2783. fileInput: evt.target
  2784. });
  2785. });
  2786. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  2787. evt.preventDefault();
  2788. evt.dataTransfer.dropEffect = "move";
  2789. });
  2790. appConfig.mainContainer.addEventListener("drop", function (evt) {
  2791. evt.preventDefault();
  2792. var files = evt.dataTransfer.files;
  2793. if (!files || files.length === 0) {
  2794. return;
  2795. }
  2796. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  2797. source: this,
  2798. fileInput: evt.dataTransfer
  2799. });
  2800. });
  2801. if (!PDFViewerApplication.supportsDocumentFonts) {
  2802. _app_options.AppOptions.set("disableFontFace", true);
  2803. PDFViewerApplication.l10n.get("web_fonts_disabled", null, "Web fonts are disabled: unable to use embedded PDF fonts.").then(function (msg) {
  2804. console.warn(msg);
  2805. });
  2806. }
  2807. if (!PDFViewerApplication.supportsPrinting) {
  2808. appConfig.toolbar.print.classList.add("hidden");
  2809. appConfig.secondaryToolbar.printButton.classList.add("hidden");
  2810. }
  2811. if (!PDFViewerApplication.supportsFullscreen) {
  2812. appConfig.toolbar.presentationModeButton.classList.add("hidden");
  2813. appConfig.secondaryToolbar.presentationModeButton.classList.add("hidden");
  2814. }
  2815. if (PDFViewerApplication.supportsIntegratedFind) {
  2816. appConfig.toolbar.viewFind.classList.add("hidden");
  2817. }
  2818. appConfig.mainContainer.addEventListener("transitionend", function (evt) {
  2819. if (evt.target === this) {
  2820. PDFViewerApplication.eventBus.dispatch("resize", {
  2821. source: this
  2822. });
  2823. }
  2824. }, true);
  2825. try {
  2826. webViewerOpenFileViaURL(file);
  2827. } catch (reason) {
  2828. PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(function (msg) {
  2829. PDFViewerApplication.error(msg, reason);
  2830. });
  2831. }
  2832. }
  2833. var webViewerOpenFileViaURL;
  2834. {
  2835. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  2836. if (file && file.lastIndexOf("file:", 0) === 0) {
  2837. PDFViewerApplication.setTitleUsingUrl(file);
  2838. var xhr = new XMLHttpRequest();
  2839. xhr.onload = function () {
  2840. PDFViewerApplication.open(new Uint8Array(xhr.response));
  2841. };
  2842. xhr.open("GET", file);
  2843. xhr.responseType = "arraybuffer";
  2844. xhr.send();
  2845. return;
  2846. }
  2847. if (file) {
  2848. PDFViewerApplication.open(file);
  2849. }
  2850. };
  2851. }
  2852. function webViewerResetPermissions() {
  2853. var appConfig = PDFViewerApplication.appConfig;
  2854. if (!appConfig) {
  2855. return;
  2856. }
  2857. appConfig.viewerContainer.classList.remove(ENABLE_PERMISSIONS_CLASS);
  2858. }
  2859. function webViewerPageRendered(_ref18) {
  2860. var pageNumber = _ref18.pageNumber,
  2861. timestamp = _ref18.timestamp,
  2862. error = _ref18.error;
  2863. if (pageNumber === PDFViewerApplication.page) {
  2864. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  2865. }
  2866. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2867. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  2868. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageNumber - 1);
  2869. if (pageView && thumbnailView) {
  2870. thumbnailView.setImage(pageView);
  2871. }
  2872. }
  2873. if (error) {
  2874. PDFViewerApplication.l10n.get("rendering_error", null, "An error occurred while rendering the page.").then(function (msg) {
  2875. PDFViewerApplication.error(msg, error);
  2876. });
  2877. }
  2878. PDFViewerApplication.externalServices.reportTelemetry({
  2879. type: "pageInfo",
  2880. timestamp: timestamp
  2881. });
  2882. PDFViewerApplication.pdfDocument.getStats().then(function (stats) {
  2883. PDFViewerApplication.externalServices.reportTelemetry({
  2884. type: "documentStats",
  2885. stats: stats
  2886. });
  2887. });
  2888. }
  2889. function webViewerPageMode(_ref19) {
  2890. var mode = _ref19.mode;
  2891. var view;
  2892. switch (mode) {
  2893. case "thumbs":
  2894. view = _ui_utils.SidebarView.THUMBS;
  2895. break;
  2896. case "bookmarks":
  2897. case "outline":
  2898. view = _ui_utils.SidebarView.OUTLINE;
  2899. break;
  2900. case "attachments":
  2901. view = _ui_utils.SidebarView.ATTACHMENTS;
  2902. break;
  2903. case "layers":
  2904. view = _ui_utils.SidebarView.LAYERS;
  2905. break;
  2906. case "none":
  2907. view = _ui_utils.SidebarView.NONE;
  2908. break;
  2909. default:
  2910. console.error('Invalid "pagemode" hash parameter: ' + mode);
  2911. return;
  2912. }
  2913. PDFViewerApplication.pdfSidebar.switchView(view, true);
  2914. }
  2915. function webViewerNamedAction(evt) {
  2916. switch (evt.action) {
  2917. case "GoToPage":
  2918. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2919. break;
  2920. case "Find":
  2921. if (!PDFViewerApplication.supportsIntegratedFind) {
  2922. PDFViewerApplication.findBar.toggle();
  2923. }
  2924. break;
  2925. case "Print":
  2926. PDFViewerApplication.triggerPrinting();
  2927. break;
  2928. case "SaveAs":
  2929. webViewerSave();
  2930. break;
  2931. }
  2932. }
  2933. function webViewerPresentationModeChanged(evt) {
  2934. PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
  2935. }
  2936. function webViewerSidebarViewChanged(evt) {
  2937. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  2938. var store = PDFViewerApplication.store;
  2939. if (store && PDFViewerApplication.isInitialViewSet) {
  2940. store.set("sidebarView", evt.view)["catch"](function () {});
  2941. }
  2942. }
  2943. function webViewerUpdateViewarea(evt) {
  2944. var location = evt.location,
  2945. store = PDFViewerApplication.store;
  2946. if (store && PDFViewerApplication.isInitialViewSet) {
  2947. store.setMultiple({
  2948. page: location.pageNumber,
  2949. zoom: location.scale,
  2950. scrollLeft: location.left,
  2951. scrollTop: location.top,
  2952. rotation: location.rotation
  2953. })["catch"](function () {});
  2954. }
  2955. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  2956. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  2957. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  2958. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  2959. var loading = (currentPage && currentPage.renderingState) !== _pdf_rendering_queue.RenderingStates.FINISHED;
  2960. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  2961. }
  2962. function webViewerScrollModeChanged(evt) {
  2963. var store = PDFViewerApplication.store;
  2964. if (store && PDFViewerApplication.isInitialViewSet) {
  2965. store.set("scrollMode", evt.mode)["catch"](function () {});
  2966. }
  2967. }
  2968. function webViewerSpreadModeChanged(evt) {
  2969. var store = PDFViewerApplication.store;
  2970. if (store && PDFViewerApplication.isInitialViewSet) {
  2971. store.set("spreadMode", evt.mode)["catch"](function () {});
  2972. }
  2973. }
  2974. function webViewerResize() {
  2975. var pdfDocument = PDFViewerApplication.pdfDocument,
  2976. pdfViewer = PDFViewerApplication.pdfViewer;
  2977. if (!pdfDocument) {
  2978. return;
  2979. }
  2980. var currentScaleValue = pdfViewer.currentScaleValue;
  2981. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  2982. pdfViewer.currentScaleValue = currentScaleValue;
  2983. }
  2984. pdfViewer.update();
  2985. }
  2986. function webViewerHashchange(evt) {
  2987. var hash = evt.hash;
  2988. if (!hash) {
  2989. return;
  2990. }
  2991. if (!PDFViewerApplication.isInitialViewSet) {
  2992. PDFViewerApplication.initialBookmark = hash;
  2993. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  2994. PDFViewerApplication.pdfLinkService.setHash(hash);
  2995. }
  2996. }
  2997. var webViewerFileInputChange, webViewerOpenFile;
  2998. {
  2999. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  3000. if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
  3001. return;
  3002. }
  3003. var file = evt.fileInput.files[0];
  3004. if (!_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  3005. var url = URL.createObjectURL(file);
  3006. if (file.name) {
  3007. url = {
  3008. url: url,
  3009. originalUrl: file.name
  3010. };
  3011. }
  3012. PDFViewerApplication.open(url);
  3013. } else {
  3014. PDFViewerApplication.setTitleUsingUrl(file.name);
  3015. var fileReader = new FileReader();
  3016. fileReader.onload = function webViewerChangeFileReaderOnload(event) {
  3017. var buffer = event.target.result;
  3018. PDFViewerApplication.open(new Uint8Array(buffer));
  3019. };
  3020. fileReader.readAsArrayBuffer(file);
  3021. }
  3022. var appConfig = PDFViewerApplication.appConfig;
  3023. appConfig.toolbar.viewBookmark.setAttribute("hidden", "true");
  3024. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute("hidden", "true");
  3025. appConfig.toolbar.download.setAttribute("hidden", "true");
  3026. appConfig.secondaryToolbar.downloadButton.setAttribute("hidden", "true");
  3027. };
  3028. webViewerOpenFile = function webViewerOpenFile(evt) {
  3029. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  3030. document.getElementById(openFileInputName).click();
  3031. };
  3032. }
  3033. function webViewerPresentationMode() {
  3034. PDFViewerApplication.requestPresentationMode();
  3035. }
  3036. function webViewerPrint() {
  3037. PDFViewerApplication.triggerPrinting();
  3038. }
  3039. function webViewerDownload() {
  3040. PDFViewerApplication.downloadOrSave({
  3041. sourceEventType: "download"
  3042. });
  3043. }
  3044. function webViewerSave() {
  3045. PDFViewerApplication.downloadOrSave({
  3046. sourceEventType: "save"
  3047. });
  3048. }
  3049. function webViewerFirstPage() {
  3050. if (PDFViewerApplication.pdfDocument) {
  3051. PDFViewerApplication.page = 1;
  3052. }
  3053. }
  3054. function webViewerLastPage() {
  3055. if (PDFViewerApplication.pdfDocument) {
  3056. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3057. }
  3058. }
  3059. function webViewerNextPage() {
  3060. PDFViewerApplication.pdfViewer.nextPage();
  3061. }
  3062. function webViewerPreviousPage() {
  3063. PDFViewerApplication.pdfViewer.previousPage();
  3064. }
  3065. function webViewerZoomIn() {
  3066. PDFViewerApplication.zoomIn();
  3067. }
  3068. function webViewerZoomOut() {
  3069. PDFViewerApplication.zoomOut();
  3070. }
  3071. function webViewerZoomReset() {
  3072. PDFViewerApplication.zoomReset();
  3073. }
  3074. function webViewerPageNumberChanged(evt) {
  3075. var pdfViewer = PDFViewerApplication.pdfViewer;
  3076. if (evt.value !== "") {
  3077. PDFViewerApplication.pdfLinkService.goToPage(evt.value);
  3078. }
  3079. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  3080. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  3081. }
  3082. }
  3083. function webViewerScaleChanged(evt) {
  3084. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  3085. }
  3086. function webViewerRotateCw() {
  3087. PDFViewerApplication.rotatePages(90);
  3088. }
  3089. function webViewerRotateCcw() {
  3090. PDFViewerApplication.rotatePages(-90);
  3091. }
  3092. function webViewerOptionalContentConfig(evt) {
  3093. PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
  3094. }
  3095. function webViewerSwitchScrollMode(evt) {
  3096. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  3097. }
  3098. function webViewerSwitchSpreadMode(evt) {
  3099. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  3100. }
  3101. function webViewerDocumentProperties() {
  3102. PDFViewerApplication.pdfDocumentProperties.open();
  3103. }
  3104. function webViewerFind(evt) {
  3105. PDFViewerApplication.findController.executeCommand("find" + evt.type, {
  3106. query: evt.query,
  3107. phraseSearch: evt.phraseSearch,
  3108. caseSensitive: evt.caseSensitive,
  3109. entireWord: evt.entireWord,
  3110. highlightAll: evt.highlightAll,
  3111. findPrevious: evt.findPrevious
  3112. });
  3113. }
  3114. function webViewerFindFromUrlHash(evt) {
  3115. PDFViewerApplication.findController.executeCommand("find", {
  3116. query: evt.query,
  3117. phraseSearch: evt.phraseSearch,
  3118. caseSensitive: false,
  3119. entireWord: false,
  3120. highlightAll: true,
  3121. findPrevious: false
  3122. });
  3123. }
  3124. function webViewerUpdateFindMatchesCount(_ref20) {
  3125. var matchesCount = _ref20.matchesCount;
  3126. if (PDFViewerApplication.supportsIntegratedFind) {
  3127. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  3128. } else {
  3129. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  3130. }
  3131. }
  3132. function webViewerUpdateFindControlState(_ref21) {
  3133. var state = _ref21.state,
  3134. previous = _ref21.previous,
  3135. matchesCount = _ref21.matchesCount,
  3136. rawQuery = _ref21.rawQuery;
  3137. if (PDFViewerApplication.supportsIntegratedFind) {
  3138. PDFViewerApplication.externalServices.updateFindControlState({
  3139. result: state,
  3140. findPrevious: previous,
  3141. matchesCount: matchesCount,
  3142. rawQuery: rawQuery
  3143. });
  3144. } else {
  3145. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  3146. }
  3147. }
  3148. function webViewerScaleChanging(evt) {
  3149. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  3150. PDFViewerApplication.pdfViewer.update();
  3151. }
  3152. function webViewerRotationChanging(evt) {
  3153. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  3154. PDFViewerApplication.forceRendering();
  3155. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  3156. }
  3157. function webViewerPageChanging(_ref22) {
  3158. var pageNumber = _ref22.pageNumber,
  3159. pageLabel = _ref22.pageLabel;
  3160. PDFViewerApplication.toolbar.setPageNumber(pageNumber, pageLabel);
  3161. PDFViewerApplication.secondaryToolbar.setPageNumber(pageNumber);
  3162. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  3163. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(pageNumber);
  3164. }
  3165. }
  3166. function webViewerVisibilityChange(evt) {
  3167. if (document.visibilityState === "visible") {
  3168. setZoomDisabledTimeout();
  3169. }
  3170. }
  3171. var zoomDisabledTimeout = null;
  3172. function setZoomDisabledTimeout() {
  3173. if (zoomDisabledTimeout) {
  3174. clearTimeout(zoomDisabledTimeout);
  3175. }
  3176. zoomDisabledTimeout = setTimeout(function () {
  3177. zoomDisabledTimeout = null;
  3178. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  3179. }
  3180. function webViewerWheel(evt) {
  3181. var pdfViewer = PDFViewerApplication.pdfViewer,
  3182. supportedMouseWheelZoomModifierKeys = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  3183. if (pdfViewer.isInPresentationMode) {
  3184. return;
  3185. }
  3186. if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
  3187. evt.preventDefault();
  3188. if (zoomDisabledTimeout || document.visibilityState === "hidden") {
  3189. return;
  3190. }
  3191. var previousScale = pdfViewer.currentScale;
  3192. var delta = (0, _ui_utils.normalizeWheelEventDirection)(evt);
  3193. var ticks = 0;
  3194. if (evt.deltaMode === WheelEvent.DOM_DELTA_LINE || evt.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
  3195. if (Math.abs(delta) >= 1) {
  3196. ticks = Math.sign(delta);
  3197. } else {
  3198. ticks = PDFViewerApplication.accumulateWheelTicks(delta);
  3199. }
  3200. } else {
  3201. var PIXELS_PER_LINE_SCALE = 30;
  3202. ticks = PDFViewerApplication.accumulateWheelTicks(delta / PIXELS_PER_LINE_SCALE);
  3203. }
  3204. if (ticks < 0) {
  3205. PDFViewerApplication.zoomOut(-ticks);
  3206. } else if (ticks > 0) {
  3207. PDFViewerApplication.zoomIn(ticks);
  3208. }
  3209. var currentScale = pdfViewer.currentScale;
  3210. if (previousScale !== currentScale) {
  3211. var scaleCorrectionFactor = currentScale / previousScale - 1;
  3212. var rect = pdfViewer.container.getBoundingClientRect();
  3213. var dx = evt.clientX - rect.left;
  3214. var dy = evt.clientY - rect.top;
  3215. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  3216. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  3217. }
  3218. } else {
  3219. setZoomDisabledTimeout();
  3220. }
  3221. }
  3222. function webViewerTouchStart(evt) {
  3223. if (evt.touches.length > 1) {
  3224. evt.preventDefault();
  3225. }
  3226. }
  3227. function webViewerClick(evt) {
  3228. if (PDFViewerApplication.triggerDelayedFallback && PDFViewerApplication.pdfViewer.containsElement(evt.target)) {
  3229. PDFViewerApplication.triggerDelayedFallback();
  3230. }
  3231. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  3232. return;
  3233. }
  3234. var appConfig = PDFViewerApplication.appConfig;
  3235. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  3236. PDFViewerApplication.secondaryToolbar.close();
  3237. }
  3238. }
  3239. function webViewerKeyUp(evt) {
  3240. if (evt.keyCode === 9) {
  3241. if (PDFViewerApplication.triggerDelayedFallback) {
  3242. PDFViewerApplication.triggerDelayedFallback();
  3243. }
  3244. }
  3245. }
  3246. function webViewerKeyDown(evt) {
  3247. if (PDFViewerApplication.overlayManager.active) {
  3248. return;
  3249. }
  3250. var handled = false,
  3251. ensureViewerFocused = false;
  3252. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  3253. var pdfViewer = PDFViewerApplication.pdfViewer;
  3254. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  3255. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  3256. switch (evt.keyCode) {
  3257. case 70:
  3258. if (!PDFViewerApplication.supportsIntegratedFind && !evt.shiftKey) {
  3259. PDFViewerApplication.findBar.open();
  3260. handled = true;
  3261. }
  3262. break;
  3263. case 71:
  3264. if (!PDFViewerApplication.supportsIntegratedFind) {
  3265. var findState = PDFViewerApplication.findController.state;
  3266. if (findState) {
  3267. PDFViewerApplication.findController.executeCommand("findagain", {
  3268. query: findState.query,
  3269. phraseSearch: findState.phraseSearch,
  3270. caseSensitive: findState.caseSensitive,
  3271. entireWord: findState.entireWord,
  3272. highlightAll: findState.highlightAll,
  3273. findPrevious: cmd === 5 || cmd === 12
  3274. });
  3275. }
  3276. handled = true;
  3277. }
  3278. break;
  3279. case 61:
  3280. case 107:
  3281. case 187:
  3282. case 171:
  3283. if (!isViewerInPresentationMode) {
  3284. PDFViewerApplication.zoomIn();
  3285. }
  3286. handled = true;
  3287. break;
  3288. case 173:
  3289. case 109:
  3290. case 189:
  3291. if (!isViewerInPresentationMode) {
  3292. PDFViewerApplication.zoomOut();
  3293. }
  3294. handled = true;
  3295. break;
  3296. case 48:
  3297. case 96:
  3298. if (!isViewerInPresentationMode) {
  3299. setTimeout(function () {
  3300. PDFViewerApplication.zoomReset();
  3301. });
  3302. handled = false;
  3303. }
  3304. break;
  3305. case 38:
  3306. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3307. PDFViewerApplication.page = 1;
  3308. handled = true;
  3309. ensureViewerFocused = true;
  3310. }
  3311. break;
  3312. case 40:
  3313. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  3314. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3315. handled = true;
  3316. ensureViewerFocused = true;
  3317. }
  3318. break;
  3319. }
  3320. }
  3321. var eventBus = PDFViewerApplication.eventBus;
  3322. if (cmd === 1 || cmd === 8) {
  3323. switch (evt.keyCode) {
  3324. case 83:
  3325. eventBus.dispatch("download", {
  3326. source: window
  3327. });
  3328. handled = true;
  3329. break;
  3330. case 79:
  3331. {
  3332. eventBus.dispatch("openfile", {
  3333. source: window
  3334. });
  3335. handled = true;
  3336. }
  3337. break;
  3338. }
  3339. }
  3340. if (cmd === 3 || cmd === 10) {
  3341. switch (evt.keyCode) {
  3342. case 80:
  3343. PDFViewerApplication.requestPresentationMode();
  3344. handled = true;
  3345. break;
  3346. case 71:
  3347. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  3348. handled = true;
  3349. break;
  3350. }
  3351. }
  3352. if (handled) {
  3353. if (ensureViewerFocused && !isViewerInPresentationMode) {
  3354. pdfViewer.focus();
  3355. }
  3356. evt.preventDefault();
  3357. return;
  3358. }
  3359. var curElement = (0, _ui_utils.getActiveOrFocusedElement)();
  3360. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  3361. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement && curElement.isContentEditable) {
  3362. if (evt.keyCode !== 27) {
  3363. return;
  3364. }
  3365. }
  3366. if (cmd === 0) {
  3367. var turnPage = 0,
  3368. turnOnlyIfPageFit = false;
  3369. switch (evt.keyCode) {
  3370. case 38:
  3371. case 33:
  3372. if (pdfViewer.isVerticalScrollbarEnabled) {
  3373. turnOnlyIfPageFit = true;
  3374. }
  3375. turnPage = -1;
  3376. break;
  3377. case 8:
  3378. if (!isViewerInPresentationMode) {
  3379. turnOnlyIfPageFit = true;
  3380. }
  3381. turnPage = -1;
  3382. break;
  3383. case 37:
  3384. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3385. turnOnlyIfPageFit = true;
  3386. }
  3387. case 75:
  3388. case 80:
  3389. turnPage = -1;
  3390. break;
  3391. case 27:
  3392. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  3393. PDFViewerApplication.secondaryToolbar.close();
  3394. handled = true;
  3395. }
  3396. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  3397. PDFViewerApplication.findBar.close();
  3398. handled = true;
  3399. }
  3400. break;
  3401. case 40:
  3402. case 34:
  3403. if (pdfViewer.isVerticalScrollbarEnabled) {
  3404. turnOnlyIfPageFit = true;
  3405. }
  3406. turnPage = 1;
  3407. break;
  3408. case 13:
  3409. case 32:
  3410. if (!isViewerInPresentationMode) {
  3411. turnOnlyIfPageFit = true;
  3412. }
  3413. turnPage = 1;
  3414. break;
  3415. case 39:
  3416. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3417. turnOnlyIfPageFit = true;
  3418. }
  3419. case 74:
  3420. case 78:
  3421. turnPage = 1;
  3422. break;
  3423. case 36:
  3424. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3425. PDFViewerApplication.page = 1;
  3426. handled = true;
  3427. ensureViewerFocused = true;
  3428. }
  3429. break;
  3430. case 35:
  3431. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  3432. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3433. handled = true;
  3434. ensureViewerFocused = true;
  3435. }
  3436. break;
  3437. case 83:
  3438. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  3439. break;
  3440. case 72:
  3441. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  3442. break;
  3443. case 82:
  3444. PDFViewerApplication.rotatePages(90);
  3445. break;
  3446. case 115:
  3447. PDFViewerApplication.pdfSidebar.toggle();
  3448. break;
  3449. }
  3450. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  3451. if (turnPage > 0) {
  3452. pdfViewer.nextPage();
  3453. } else {
  3454. pdfViewer.previousPage();
  3455. }
  3456. handled = true;
  3457. }
  3458. }
  3459. if (cmd === 4) {
  3460. switch (evt.keyCode) {
  3461. case 13:
  3462. case 32:
  3463. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  3464. break;
  3465. }
  3466. if (PDFViewerApplication.page > 1) {
  3467. PDFViewerApplication.page--;
  3468. }
  3469. handled = true;
  3470. break;
  3471. case 82:
  3472. PDFViewerApplication.rotatePages(-90);
  3473. break;
  3474. }
  3475. }
  3476. if (!handled && !isViewerInPresentationMode) {
  3477. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  3478. ensureViewerFocused = true;
  3479. }
  3480. }
  3481. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  3482. pdfViewer.focus();
  3483. }
  3484. if (handled) {
  3485. evt.preventDefault();
  3486. }
  3487. }
  3488. function beforeUnload(evt) {
  3489. evt.preventDefault();
  3490. evt.returnValue = "";
  3491. return false;
  3492. }
  3493. function apiPageLayoutToSpreadMode(layout) {
  3494. switch (layout) {
  3495. case "SinglePage":
  3496. case "OneColumn":
  3497. return _ui_utils.SpreadMode.NONE;
  3498. case "TwoColumnLeft":
  3499. case "TwoPageLeft":
  3500. return _ui_utils.SpreadMode.ODD;
  3501. case "TwoColumnRight":
  3502. case "TwoPageRight":
  3503. return _ui_utils.SpreadMode.EVEN;
  3504. }
  3505. return _ui_utils.SpreadMode.NONE;
  3506. }
  3507. function apiPageModeToSidebarView(mode) {
  3508. switch (mode) {
  3509. case "UseNone":
  3510. return _ui_utils.SidebarView.NONE;
  3511. case "UseThumbs":
  3512. return _ui_utils.SidebarView.THUMBS;
  3513. case "UseOutlines":
  3514. return _ui_utils.SidebarView.OUTLINE;
  3515. case "UseAttachments":
  3516. return _ui_utils.SidebarView.ATTACHMENTS;
  3517. case "UseOC":
  3518. return _ui_utils.SidebarView.LAYERS;
  3519. }
  3520. return _ui_utils.SidebarView.NONE;
  3521. }
  3522. var PDFPrintServiceFactory = {
  3523. instance: {
  3524. supportsPrinting: false,
  3525. createPrintService: function createPrintService() {
  3526. throw new Error("Not implemented: createPrintService");
  3527. }
  3528. }
  3529. };
  3530. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  3531. /***/ }),
  3532. /* 4 */
  3533. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3534. module.exports = __webpack_require__(5);
  3535. /***/ }),
  3536. /* 5 */
  3537. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3538. /* module decorator */ module = __webpack_require__.nmd(module);
  3539. 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); }
  3540. var runtime = function (exports) {
  3541. "use strict";
  3542. var Op = Object.prototype;
  3543. var hasOwn = Op.hasOwnProperty;
  3544. var undefined;
  3545. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  3546. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  3547. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  3548. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  3549. function define(obj, key, value) {
  3550. Object.defineProperty(obj, key, {
  3551. value: value,
  3552. enumerable: true,
  3553. configurable: true,
  3554. writable: true
  3555. });
  3556. return obj[key];
  3557. }
  3558. try {
  3559. define({}, "");
  3560. } catch (err) {
  3561. define = function define(obj, key, value) {
  3562. return obj[key] = value;
  3563. };
  3564. }
  3565. function wrap(innerFn, outerFn, self, tryLocsList) {
  3566. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  3567. var generator = Object.create(protoGenerator.prototype);
  3568. var context = new Context(tryLocsList || []);
  3569. generator._invoke = makeInvokeMethod(innerFn, self, context);
  3570. return generator;
  3571. }
  3572. exports.wrap = wrap;
  3573. function tryCatch(fn, obj, arg) {
  3574. try {
  3575. return {
  3576. type: "normal",
  3577. arg: fn.call(obj, arg)
  3578. };
  3579. } catch (err) {
  3580. return {
  3581. type: "throw",
  3582. arg: err
  3583. };
  3584. }
  3585. }
  3586. var GenStateSuspendedStart = "suspendedStart";
  3587. var GenStateSuspendedYield = "suspendedYield";
  3588. var GenStateExecuting = "executing";
  3589. var GenStateCompleted = "completed";
  3590. var ContinueSentinel = {};
  3591. function Generator() {}
  3592. function GeneratorFunction() {}
  3593. function GeneratorFunctionPrototype() {}
  3594. var IteratorPrototype = {};
  3595. IteratorPrototype[iteratorSymbol] = function () {
  3596. return this;
  3597. };
  3598. var getProto = Object.getPrototypeOf;
  3599. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  3600. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  3601. IteratorPrototype = NativeIteratorPrototype;
  3602. }
  3603. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  3604. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  3605. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  3606. GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
  3607. function defineIteratorMethods(prototype) {
  3608. ["next", "throw", "return"].forEach(function (method) {
  3609. define(prototype, method, function (arg) {
  3610. return this._invoke(method, arg);
  3611. });
  3612. });
  3613. }
  3614. exports.isGeneratorFunction = function (genFun) {
  3615. var ctor = typeof genFun === "function" && genFun.constructor;
  3616. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  3617. };
  3618. exports.mark = function (genFun) {
  3619. if (Object.setPrototypeOf) {
  3620. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  3621. } else {
  3622. genFun.__proto__ = GeneratorFunctionPrototype;
  3623. define(genFun, toStringTagSymbol, "GeneratorFunction");
  3624. }
  3625. genFun.prototype = Object.create(Gp);
  3626. return genFun;
  3627. };
  3628. exports.awrap = function (arg) {
  3629. return {
  3630. __await: arg
  3631. };
  3632. };
  3633. function AsyncIterator(generator, PromiseImpl) {
  3634. function invoke(method, arg, resolve, reject) {
  3635. var record = tryCatch(generator[method], generator, arg);
  3636. if (record.type === "throw") {
  3637. reject(record.arg);
  3638. } else {
  3639. var result = record.arg;
  3640. var value = result.value;
  3641. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  3642. return PromiseImpl.resolve(value.__await).then(function (value) {
  3643. invoke("next", value, resolve, reject);
  3644. }, function (err) {
  3645. invoke("throw", err, resolve, reject);
  3646. });
  3647. }
  3648. return PromiseImpl.resolve(value).then(function (unwrapped) {
  3649. result.value = unwrapped;
  3650. resolve(result);
  3651. }, function (error) {
  3652. return invoke("throw", error, resolve, reject);
  3653. });
  3654. }
  3655. }
  3656. var previousPromise;
  3657. function enqueue(method, arg) {
  3658. function callInvokeWithMethodAndArg() {
  3659. return new PromiseImpl(function (resolve, reject) {
  3660. invoke(method, arg, resolve, reject);
  3661. });
  3662. }
  3663. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  3664. }
  3665. this._invoke = enqueue;
  3666. }
  3667. defineIteratorMethods(AsyncIterator.prototype);
  3668. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  3669. return this;
  3670. };
  3671. exports.AsyncIterator = AsyncIterator;
  3672. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  3673. if (PromiseImpl === void 0) PromiseImpl = Promise;
  3674. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  3675. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  3676. return result.done ? result.value : iter.next();
  3677. });
  3678. };
  3679. function makeInvokeMethod(innerFn, self, context) {
  3680. var state = GenStateSuspendedStart;
  3681. return function invoke(method, arg) {
  3682. if (state === GenStateExecuting) {
  3683. throw new Error("Generator is already running");
  3684. }
  3685. if (state === GenStateCompleted) {
  3686. if (method === "throw") {
  3687. throw arg;
  3688. }
  3689. return doneResult();
  3690. }
  3691. context.method = method;
  3692. context.arg = arg;
  3693. while (true) {
  3694. var delegate = context.delegate;
  3695. if (delegate) {
  3696. var delegateResult = maybeInvokeDelegate(delegate, context);
  3697. if (delegateResult) {
  3698. if (delegateResult === ContinueSentinel) continue;
  3699. return delegateResult;
  3700. }
  3701. }
  3702. if (context.method === "next") {
  3703. context.sent = context._sent = context.arg;
  3704. } else if (context.method === "throw") {
  3705. if (state === GenStateSuspendedStart) {
  3706. state = GenStateCompleted;
  3707. throw context.arg;
  3708. }
  3709. context.dispatchException(context.arg);
  3710. } else if (context.method === "return") {
  3711. context.abrupt("return", context.arg);
  3712. }
  3713. state = GenStateExecuting;
  3714. var record = tryCatch(innerFn, self, context);
  3715. if (record.type === "normal") {
  3716. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  3717. if (record.arg === ContinueSentinel) {
  3718. continue;
  3719. }
  3720. return {
  3721. value: record.arg,
  3722. done: context.done
  3723. };
  3724. } else if (record.type === "throw") {
  3725. state = GenStateCompleted;
  3726. context.method = "throw";
  3727. context.arg = record.arg;
  3728. }
  3729. }
  3730. };
  3731. }
  3732. function maybeInvokeDelegate(delegate, context) {
  3733. var method = delegate.iterator[context.method];
  3734. if (method === undefined) {
  3735. context.delegate = null;
  3736. if (context.method === "throw") {
  3737. if (delegate.iterator["return"]) {
  3738. context.method = "return";
  3739. context.arg = undefined;
  3740. maybeInvokeDelegate(delegate, context);
  3741. if (context.method === "throw") {
  3742. return ContinueSentinel;
  3743. }
  3744. }
  3745. context.method = "throw";
  3746. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  3747. }
  3748. return ContinueSentinel;
  3749. }
  3750. var record = tryCatch(method, delegate.iterator, context.arg);
  3751. if (record.type === "throw") {
  3752. context.method = "throw";
  3753. context.arg = record.arg;
  3754. context.delegate = null;
  3755. return ContinueSentinel;
  3756. }
  3757. var info = record.arg;
  3758. if (!info) {
  3759. context.method = "throw";
  3760. context.arg = new TypeError("iterator result is not an object");
  3761. context.delegate = null;
  3762. return ContinueSentinel;
  3763. }
  3764. if (info.done) {
  3765. context[delegate.resultName] = info.value;
  3766. context.next = delegate.nextLoc;
  3767. if (context.method !== "return") {
  3768. context.method = "next";
  3769. context.arg = undefined;
  3770. }
  3771. } else {
  3772. return info;
  3773. }
  3774. context.delegate = null;
  3775. return ContinueSentinel;
  3776. }
  3777. defineIteratorMethods(Gp);
  3778. define(Gp, toStringTagSymbol, "Generator");
  3779. Gp[iteratorSymbol] = function () {
  3780. return this;
  3781. };
  3782. Gp.toString = function () {
  3783. return "[object Generator]";
  3784. };
  3785. function pushTryEntry(locs) {
  3786. var entry = {
  3787. tryLoc: locs[0]
  3788. };
  3789. if (1 in locs) {
  3790. entry.catchLoc = locs[1];
  3791. }
  3792. if (2 in locs) {
  3793. entry.finallyLoc = locs[2];
  3794. entry.afterLoc = locs[3];
  3795. }
  3796. this.tryEntries.push(entry);
  3797. }
  3798. function resetTryEntry(entry) {
  3799. var record = entry.completion || {};
  3800. record.type = "normal";
  3801. delete record.arg;
  3802. entry.completion = record;
  3803. }
  3804. function Context(tryLocsList) {
  3805. this.tryEntries = [{
  3806. tryLoc: "root"
  3807. }];
  3808. tryLocsList.forEach(pushTryEntry, this);
  3809. this.reset(true);
  3810. }
  3811. exports.keys = function (object) {
  3812. var keys = [];
  3813. for (var key in object) {
  3814. keys.push(key);
  3815. }
  3816. keys.reverse();
  3817. return function next() {
  3818. while (keys.length) {
  3819. var key = keys.pop();
  3820. if (key in object) {
  3821. next.value = key;
  3822. next.done = false;
  3823. return next;
  3824. }
  3825. }
  3826. next.done = true;
  3827. return next;
  3828. };
  3829. };
  3830. function values(iterable) {
  3831. if (iterable) {
  3832. var iteratorMethod = iterable[iteratorSymbol];
  3833. if (iteratorMethod) {
  3834. return iteratorMethod.call(iterable);
  3835. }
  3836. if (typeof iterable.next === "function") {
  3837. return iterable;
  3838. }
  3839. if (!isNaN(iterable.length)) {
  3840. var i = -1,
  3841. next = function next() {
  3842. while (++i < iterable.length) {
  3843. if (hasOwn.call(iterable, i)) {
  3844. next.value = iterable[i];
  3845. next.done = false;
  3846. return next;
  3847. }
  3848. }
  3849. next.value = undefined;
  3850. next.done = true;
  3851. return next;
  3852. };
  3853. return next.next = next;
  3854. }
  3855. }
  3856. return {
  3857. next: doneResult
  3858. };
  3859. }
  3860. exports.values = values;
  3861. function doneResult() {
  3862. return {
  3863. value: undefined,
  3864. done: true
  3865. };
  3866. }
  3867. Context.prototype = {
  3868. constructor: Context,
  3869. reset: function reset(skipTempReset) {
  3870. this.prev = 0;
  3871. this.next = 0;
  3872. this.sent = this._sent = undefined;
  3873. this.done = false;
  3874. this.delegate = null;
  3875. this.method = "next";
  3876. this.arg = undefined;
  3877. this.tryEntries.forEach(resetTryEntry);
  3878. if (!skipTempReset) {
  3879. for (var name in this) {
  3880. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  3881. this[name] = undefined;
  3882. }
  3883. }
  3884. }
  3885. },
  3886. stop: function stop() {
  3887. this.done = true;
  3888. var rootEntry = this.tryEntries[0];
  3889. var rootRecord = rootEntry.completion;
  3890. if (rootRecord.type === "throw") {
  3891. throw rootRecord.arg;
  3892. }
  3893. return this.rval;
  3894. },
  3895. dispatchException: function dispatchException(exception) {
  3896. if (this.done) {
  3897. throw exception;
  3898. }
  3899. var context = this;
  3900. function handle(loc, caught) {
  3901. record.type = "throw";
  3902. record.arg = exception;
  3903. context.next = loc;
  3904. if (caught) {
  3905. context.method = "next";
  3906. context.arg = undefined;
  3907. }
  3908. return !!caught;
  3909. }
  3910. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3911. var entry = this.tryEntries[i];
  3912. var record = entry.completion;
  3913. if (entry.tryLoc === "root") {
  3914. return handle("end");
  3915. }
  3916. if (entry.tryLoc <= this.prev) {
  3917. var hasCatch = hasOwn.call(entry, "catchLoc");
  3918. var hasFinally = hasOwn.call(entry, "finallyLoc");
  3919. if (hasCatch && hasFinally) {
  3920. if (this.prev < entry.catchLoc) {
  3921. return handle(entry.catchLoc, true);
  3922. } else if (this.prev < entry.finallyLoc) {
  3923. return handle(entry.finallyLoc);
  3924. }
  3925. } else if (hasCatch) {
  3926. if (this.prev < entry.catchLoc) {
  3927. return handle(entry.catchLoc, true);
  3928. }
  3929. } else if (hasFinally) {
  3930. if (this.prev < entry.finallyLoc) {
  3931. return handle(entry.finallyLoc);
  3932. }
  3933. } else {
  3934. throw new Error("try statement without catch or finally");
  3935. }
  3936. }
  3937. }
  3938. },
  3939. abrupt: function abrupt(type, arg) {
  3940. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3941. var entry = this.tryEntries[i];
  3942. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  3943. var finallyEntry = entry;
  3944. break;
  3945. }
  3946. }
  3947. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  3948. finallyEntry = null;
  3949. }
  3950. var record = finallyEntry ? finallyEntry.completion : {};
  3951. record.type = type;
  3952. record.arg = arg;
  3953. if (finallyEntry) {
  3954. this.method = "next";
  3955. this.next = finallyEntry.finallyLoc;
  3956. return ContinueSentinel;
  3957. }
  3958. return this.complete(record);
  3959. },
  3960. complete: function complete(record, afterLoc) {
  3961. if (record.type === "throw") {
  3962. throw record.arg;
  3963. }
  3964. if (record.type === "break" || record.type === "continue") {
  3965. this.next = record.arg;
  3966. } else if (record.type === "return") {
  3967. this.rval = this.arg = record.arg;
  3968. this.method = "return";
  3969. this.next = "end";
  3970. } else if (record.type === "normal" && afterLoc) {
  3971. this.next = afterLoc;
  3972. }
  3973. return ContinueSentinel;
  3974. },
  3975. finish: function finish(finallyLoc) {
  3976. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3977. var entry = this.tryEntries[i];
  3978. if (entry.finallyLoc === finallyLoc) {
  3979. this.complete(entry.completion, entry.afterLoc);
  3980. resetTryEntry(entry);
  3981. return ContinueSentinel;
  3982. }
  3983. }
  3984. },
  3985. "catch": function _catch(tryLoc) {
  3986. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3987. var entry = this.tryEntries[i];
  3988. if (entry.tryLoc === tryLoc) {
  3989. var record = entry.completion;
  3990. if (record.type === "throw") {
  3991. var thrown = record.arg;
  3992. resetTryEntry(entry);
  3993. }
  3994. return thrown;
  3995. }
  3996. }
  3997. throw new Error("illegal catch attempt");
  3998. },
  3999. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  4000. this.delegate = {
  4001. iterator: values(iterable),
  4002. resultName: resultName,
  4003. nextLoc: nextLoc
  4004. };
  4005. if (this.method === "next") {
  4006. this.arg = undefined;
  4007. }
  4008. return ContinueSentinel;
  4009. }
  4010. };
  4011. return exports;
  4012. }(( false ? 0 : _typeof(module)) === "object" ? module.exports : {});
  4013. try {
  4014. regeneratorRuntime = runtime;
  4015. } catch (accidentalStrictMode) {
  4016. Function("r", "regeneratorRuntime = r")(runtime);
  4017. }
  4018. /***/ }),
  4019. /* 6 */
  4020. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4021. Object.defineProperty(exports, "__esModule", ({
  4022. value: true
  4023. }));
  4024. exports.approximateFraction = approximateFraction;
  4025. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  4026. exports.binarySearchFirstItem = binarySearchFirstItem;
  4027. exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
  4028. exports.getOutputScale = getOutputScale;
  4029. exports.getPageSizeInches = getPageSizeInches;
  4030. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  4031. exports.getVisibleElements = getVisibleElements;
  4032. exports.isPortraitOrientation = isPortraitOrientation;
  4033. exports.isValidRotation = isValidRotation;
  4034. exports.isValidScrollMode = isValidScrollMode;
  4035. exports.isValidSpreadMode = isValidSpreadMode;
  4036. exports.moveToEndOfArray = moveToEndOfArray;
  4037. exports.noContextMenuHandler = noContextMenuHandler;
  4038. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  4039. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  4040. exports.parseQueryString = parseQueryString;
  4041. exports.roundToDivide = roundToDivide;
  4042. exports.scrollIntoView = scrollIntoView;
  4043. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  4044. exports.watchScroll = watchScroll;
  4045. exports.WaitOnType = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports.TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports.SCROLLBAR_PADDING = exports.RendererType = exports.ProgressBar = exports.PresentationModeState = exports.NullL10n = exports.MIN_SCALE = exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.EventBus = exports.DEFAULT_SCALE_VALUE = exports.DEFAULT_SCALE = exports.CSS_UNITS = exports.AutoPrintRegExp = exports.animationStarted = void 0;
  4046. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  4047. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4048. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4049. 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); } }
  4050. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4051. 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); }
  4052. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  4053. 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."); }
  4054. 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); }
  4055. 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; }
  4056. 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; }
  4057. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  4058. 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); } }
  4059. 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); }); }; }
  4060. var CSS_UNITS = 96.0 / 72.0;
  4061. exports.CSS_UNITS = CSS_UNITS;
  4062. var DEFAULT_SCALE_VALUE = "auto";
  4063. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  4064. var DEFAULT_SCALE = 1.0;
  4065. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  4066. var MIN_SCALE = 0.1;
  4067. exports.MIN_SCALE = MIN_SCALE;
  4068. var MAX_SCALE = 10.0;
  4069. exports.MAX_SCALE = MAX_SCALE;
  4070. var UNKNOWN_SCALE = 0;
  4071. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  4072. var MAX_AUTO_SCALE = 1.25;
  4073. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  4074. var SCROLLBAR_PADDING = 40;
  4075. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  4076. var VERTICAL_PADDING = 5;
  4077. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  4078. var LOADINGBAR_END_OFFSET_VAR = "--loadingBar-end-offset";
  4079. var PresentationModeState = {
  4080. UNKNOWN: 0,
  4081. NORMAL: 1,
  4082. CHANGING: 2,
  4083. FULLSCREEN: 3
  4084. };
  4085. exports.PresentationModeState = PresentationModeState;
  4086. var SidebarView = {
  4087. UNKNOWN: -1,
  4088. NONE: 0,
  4089. THUMBS: 1,
  4090. OUTLINE: 2,
  4091. ATTACHMENTS: 3,
  4092. LAYERS: 4
  4093. };
  4094. exports.SidebarView = SidebarView;
  4095. var RendererType = {
  4096. CANVAS: "canvas",
  4097. SVG: "svg"
  4098. };
  4099. exports.RendererType = RendererType;
  4100. var TextLayerMode = {
  4101. DISABLE: 0,
  4102. ENABLE: 1,
  4103. ENABLE_ENHANCE: 2
  4104. };
  4105. exports.TextLayerMode = TextLayerMode;
  4106. var ScrollMode = {
  4107. UNKNOWN: -1,
  4108. VERTICAL: 0,
  4109. HORIZONTAL: 1,
  4110. WRAPPED: 2
  4111. };
  4112. exports.ScrollMode = ScrollMode;
  4113. var SpreadMode = {
  4114. UNKNOWN: -1,
  4115. NONE: 0,
  4116. ODD: 1,
  4117. EVEN: 2
  4118. };
  4119. exports.SpreadMode = SpreadMode;
  4120. var AutoPrintRegExp = /\bprint\s*\(/;
  4121. exports.AutoPrintRegExp = AutoPrintRegExp;
  4122. function formatL10nValue(text, args) {
  4123. if (!args) {
  4124. return text;
  4125. }
  4126. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  4127. return name in args ? args[name] : "{{" + name + "}}";
  4128. });
  4129. }
  4130. var NullL10n = {
  4131. getLanguage: function getLanguage() {
  4132. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  4133. return _regenerator["default"].wrap(function _callee$(_context) {
  4134. while (1) {
  4135. switch (_context.prev = _context.next) {
  4136. case 0:
  4137. return _context.abrupt("return", "en-us");
  4138. case 1:
  4139. case "end":
  4140. return _context.stop();
  4141. }
  4142. }
  4143. }, _callee);
  4144. }))();
  4145. },
  4146. getDirection: function getDirection() {
  4147. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  4148. return _regenerator["default"].wrap(function _callee2$(_context2) {
  4149. while (1) {
  4150. switch (_context2.prev = _context2.next) {
  4151. case 0:
  4152. return _context2.abrupt("return", "ltr");
  4153. case 1:
  4154. case "end":
  4155. return _context2.stop();
  4156. }
  4157. }
  4158. }, _callee2);
  4159. }))();
  4160. },
  4161. get: function get(property, args, fallback) {
  4162. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  4163. return _regenerator["default"].wrap(function _callee3$(_context3) {
  4164. while (1) {
  4165. switch (_context3.prev = _context3.next) {
  4166. case 0:
  4167. return _context3.abrupt("return", formatL10nValue(fallback, args));
  4168. case 1:
  4169. case "end":
  4170. return _context3.stop();
  4171. }
  4172. }
  4173. }, _callee3);
  4174. }))();
  4175. },
  4176. translate: function translate(element) {
  4177. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  4178. return _regenerator["default"].wrap(function _callee4$(_context4) {
  4179. while (1) {
  4180. switch (_context4.prev = _context4.next) {
  4181. case 0:
  4182. case "end":
  4183. return _context4.stop();
  4184. }
  4185. }
  4186. }, _callee4);
  4187. }))();
  4188. }
  4189. };
  4190. exports.NullL10n = NullL10n;
  4191. function getOutputScale(ctx) {
  4192. var devicePixelRatio = window.devicePixelRatio || 1;
  4193. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  4194. var pixelRatio = devicePixelRatio / backingStoreRatio;
  4195. return {
  4196. sx: pixelRatio,
  4197. sy: pixelRatio,
  4198. scaled: pixelRatio !== 1
  4199. };
  4200. }
  4201. function scrollIntoView(element, spot) {
  4202. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4203. var parent = element.offsetParent;
  4204. if (!parent) {
  4205. console.error("offsetParent is not set -- cannot scroll");
  4206. return;
  4207. }
  4208. var offsetY = element.offsetTop + element.clientTop;
  4209. var offsetX = element.offsetLeft + element.clientLeft;
  4210. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === "hidden") {
  4211. if (parent.dataset._scaleY) {
  4212. offsetY /= parent.dataset._scaleY;
  4213. offsetX /= parent.dataset._scaleX;
  4214. }
  4215. offsetY += parent.offsetTop;
  4216. offsetX += parent.offsetLeft;
  4217. parent = parent.offsetParent;
  4218. if (!parent) {
  4219. return;
  4220. }
  4221. }
  4222. if (spot) {
  4223. if (spot.top !== undefined) {
  4224. offsetY += spot.top;
  4225. }
  4226. if (spot.left !== undefined) {
  4227. offsetX += spot.left;
  4228. parent.scrollLeft = offsetX;
  4229. }
  4230. }
  4231. parent.scrollTop = offsetY;
  4232. }
  4233. function watchScroll(viewAreaElement, callback) {
  4234. var debounceScroll = function debounceScroll(evt) {
  4235. if (rAF) {
  4236. return;
  4237. }
  4238. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  4239. rAF = null;
  4240. var currentX = viewAreaElement.scrollLeft;
  4241. var lastX = state.lastX;
  4242. if (currentX !== lastX) {
  4243. state.right = currentX > lastX;
  4244. }
  4245. state.lastX = currentX;
  4246. var currentY = viewAreaElement.scrollTop;
  4247. var lastY = state.lastY;
  4248. if (currentY !== lastY) {
  4249. state.down = currentY > lastY;
  4250. }
  4251. state.lastY = currentY;
  4252. callback(state);
  4253. });
  4254. };
  4255. var state = {
  4256. right: true,
  4257. down: true,
  4258. lastX: viewAreaElement.scrollLeft,
  4259. lastY: viewAreaElement.scrollTop,
  4260. _eventHandler: debounceScroll
  4261. };
  4262. var rAF = null;
  4263. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  4264. return state;
  4265. }
  4266. function parseQueryString(query) {
  4267. var parts = query.split("&");
  4268. var params = Object.create(null);
  4269. for (var i = 0, ii = parts.length; i < ii; ++i) {
  4270. var param = parts[i].split("=");
  4271. var key = param[0].toLowerCase();
  4272. var value = param.length > 1 ? param[1] : null;
  4273. params[decodeURIComponent(key)] = decodeURIComponent(value);
  4274. }
  4275. return params;
  4276. }
  4277. function binarySearchFirstItem(items, condition) {
  4278. var minIndex = 0;
  4279. var maxIndex = items.length - 1;
  4280. if (maxIndex < 0 || !condition(items[maxIndex])) {
  4281. return items.length;
  4282. }
  4283. if (condition(items[minIndex])) {
  4284. return minIndex;
  4285. }
  4286. while (minIndex < maxIndex) {
  4287. var currentIndex = minIndex + maxIndex >> 1;
  4288. var currentItem = items[currentIndex];
  4289. if (condition(currentItem)) {
  4290. maxIndex = currentIndex;
  4291. } else {
  4292. minIndex = currentIndex + 1;
  4293. }
  4294. }
  4295. return minIndex;
  4296. }
  4297. function approximateFraction(x) {
  4298. if (Math.floor(x) === x) {
  4299. return [x, 1];
  4300. }
  4301. var xinv = 1 / x;
  4302. var limit = 8;
  4303. if (xinv > limit) {
  4304. return [1, limit];
  4305. } else if (Math.floor(xinv) === xinv) {
  4306. return [1, xinv];
  4307. }
  4308. var x_ = x > 1 ? xinv : x;
  4309. var a = 0,
  4310. b = 1,
  4311. c = 1,
  4312. d = 1;
  4313. while (true) {
  4314. var p = a + c,
  4315. q = b + d;
  4316. if (q > limit) {
  4317. break;
  4318. }
  4319. if (x_ <= p / q) {
  4320. c = p;
  4321. d = q;
  4322. } else {
  4323. a = p;
  4324. b = q;
  4325. }
  4326. }
  4327. var result;
  4328. if (x_ - a / b < c / d - x_) {
  4329. result = x_ === x ? [a, b] : [b, a];
  4330. } else {
  4331. result = x_ === x ? [c, d] : [d, c];
  4332. }
  4333. return result;
  4334. }
  4335. function roundToDivide(x, div) {
  4336. var r = x % div;
  4337. return r === 0 ? x : Math.round(x - r + div);
  4338. }
  4339. function getPageSizeInches(_ref) {
  4340. var view = _ref.view,
  4341. userUnit = _ref.userUnit,
  4342. rotate = _ref.rotate;
  4343. var _view = _slicedToArray(view, 4),
  4344. x1 = _view[0],
  4345. y1 = _view[1],
  4346. x2 = _view[2],
  4347. y2 = _view[3];
  4348. var changeOrientation = rotate % 180 !== 0;
  4349. var width = (x2 - x1) / 72 * userUnit;
  4350. var height = (y2 - y1) / 72 * userUnit;
  4351. return {
  4352. width: changeOrientation ? height : width,
  4353. height: changeOrientation ? width : height
  4354. };
  4355. }
  4356. function backtrackBeforeAllVisibleElements(index, views, top) {
  4357. if (index < 2) {
  4358. return index;
  4359. }
  4360. var elt = views[index].div;
  4361. var pageTop = elt.offsetTop + elt.clientTop;
  4362. if (pageTop >= top) {
  4363. elt = views[index - 1].div;
  4364. pageTop = elt.offsetTop + elt.clientTop;
  4365. }
  4366. for (var i = index - 2; i >= 0; --i) {
  4367. elt = views[i].div;
  4368. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  4369. break;
  4370. }
  4371. index = i;
  4372. }
  4373. return index;
  4374. }
  4375. function getVisibleElements(_ref2) {
  4376. var scrollEl = _ref2.scrollEl,
  4377. views = _ref2.views,
  4378. _ref2$sortByVisibilit = _ref2.sortByVisibility,
  4379. sortByVisibility = _ref2$sortByVisibilit === void 0 ? false : _ref2$sortByVisibilit,
  4380. _ref2$horizontal = _ref2.horizontal,
  4381. horizontal = _ref2$horizontal === void 0 ? false : _ref2$horizontal,
  4382. _ref2$rtl = _ref2.rtl,
  4383. rtl = _ref2$rtl === void 0 ? false : _ref2$rtl;
  4384. var top = scrollEl.scrollTop,
  4385. bottom = top + scrollEl.clientHeight;
  4386. var left = scrollEl.scrollLeft,
  4387. right = left + scrollEl.clientWidth;
  4388. function isElementBottomAfterViewTop(view) {
  4389. var element = view.div;
  4390. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  4391. return elementBottom > top;
  4392. }
  4393. function isElementNextAfterViewHorizontally(view) {
  4394. var element = view.div;
  4395. var elementLeft = element.offsetLeft + element.clientLeft;
  4396. var elementRight = elementLeft + element.clientWidth;
  4397. return rtl ? elementLeft < right : elementRight > left;
  4398. }
  4399. var visible = [],
  4400. numViews = views.length;
  4401. var firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  4402. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  4403. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  4404. }
  4405. var lastEdge = horizontal ? right : -1;
  4406. for (var i = firstVisibleElementInd; i < numViews; i++) {
  4407. var view = views[i],
  4408. element = view.div;
  4409. var currentWidth = element.offsetLeft + element.clientLeft;
  4410. var currentHeight = element.offsetTop + element.clientTop;
  4411. var viewWidth = element.clientWidth,
  4412. viewHeight = element.clientHeight;
  4413. var viewRight = currentWidth + viewWidth;
  4414. var viewBottom = currentHeight + viewHeight;
  4415. if (lastEdge === -1) {
  4416. if (viewBottom >= bottom) {
  4417. lastEdge = viewBottom;
  4418. }
  4419. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  4420. break;
  4421. }
  4422. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  4423. continue;
  4424. }
  4425. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  4426. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  4427. var fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  4428. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  4429. var percent = fractionHeight * fractionWidth * 100 | 0;
  4430. visible.push({
  4431. id: view.id,
  4432. x: currentWidth,
  4433. y: currentHeight,
  4434. view: view,
  4435. percent: percent,
  4436. widthPercent: fractionWidth * 100 | 0
  4437. });
  4438. }
  4439. var first = visible[0],
  4440. last = visible[visible.length - 1];
  4441. if (sortByVisibility) {
  4442. visible.sort(function (a, b) {
  4443. var pc = a.percent - b.percent;
  4444. if (Math.abs(pc) > 0.001) {
  4445. return -pc;
  4446. }
  4447. return a.id - b.id;
  4448. });
  4449. }
  4450. return {
  4451. first: first,
  4452. last: last,
  4453. views: visible
  4454. };
  4455. }
  4456. function noContextMenuHandler(evt) {
  4457. evt.preventDefault();
  4458. }
  4459. function isDataSchema(url) {
  4460. var i = 0;
  4461. var ii = url.length;
  4462. while (i < ii && url[i].trim() === "") {
  4463. i++;
  4464. }
  4465. return url.substring(i, i + 5).toLowerCase() === "data:";
  4466. }
  4467. function getPDFFileNameFromURL(url) {
  4468. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "document.pdf";
  4469. if (typeof url !== "string") {
  4470. return defaultFilename;
  4471. }
  4472. if (isDataSchema(url)) {
  4473. console.warn("getPDFFileNameFromURL: " + 'ignoring "data:" URL for performance reasons.');
  4474. return defaultFilename;
  4475. }
  4476. var reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  4477. var reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  4478. var splitURI = reURI.exec(url);
  4479. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  4480. if (suggestedFilename) {
  4481. suggestedFilename = suggestedFilename[0];
  4482. if (suggestedFilename.includes("%")) {
  4483. try {
  4484. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  4485. } catch (ex) {}
  4486. }
  4487. }
  4488. return suggestedFilename || defaultFilename;
  4489. }
  4490. function normalizeWheelEventDirection(evt) {
  4491. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  4492. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  4493. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  4494. delta = -delta;
  4495. }
  4496. return delta;
  4497. }
  4498. function normalizeWheelEventDelta(evt) {
  4499. var delta = normalizeWheelEventDirection(evt);
  4500. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  4501. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  4502. var MOUSE_PIXELS_PER_LINE = 30;
  4503. var MOUSE_LINES_PER_PAGE = 30;
  4504. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  4505. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  4506. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  4507. delta /= MOUSE_LINES_PER_PAGE;
  4508. }
  4509. return delta;
  4510. }
  4511. function isValidRotation(angle) {
  4512. return Number.isInteger(angle) && angle % 90 === 0;
  4513. }
  4514. function isValidScrollMode(mode) {
  4515. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  4516. }
  4517. function isValidSpreadMode(mode) {
  4518. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  4519. }
  4520. function isPortraitOrientation(size) {
  4521. return size.width <= size.height;
  4522. }
  4523. var WaitOnType = {
  4524. EVENT: "event",
  4525. TIMEOUT: "timeout"
  4526. };
  4527. exports.WaitOnType = WaitOnType;
  4528. function waitOnEventOrTimeout(_ref3) {
  4529. var target = _ref3.target,
  4530. name = _ref3.name,
  4531. _ref3$delay = _ref3.delay,
  4532. delay = _ref3$delay === void 0 ? 0 : _ref3$delay;
  4533. return new Promise(function (resolve, reject) {
  4534. if (_typeof(target) !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  4535. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  4536. }
  4537. function handler(type) {
  4538. if (target instanceof EventBus) {
  4539. target._off(name, eventHandler);
  4540. } else {
  4541. target.removeEventListener(name, eventHandler);
  4542. }
  4543. if (timeout) {
  4544. clearTimeout(timeout);
  4545. }
  4546. resolve(type);
  4547. }
  4548. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  4549. if (target instanceof EventBus) {
  4550. target._on(name, eventHandler);
  4551. } else {
  4552. target.addEventListener(name, eventHandler);
  4553. }
  4554. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  4555. var timeout = setTimeout(timeoutHandler, delay);
  4556. });
  4557. }
  4558. var animationStarted = new Promise(function (resolve) {
  4559. window.requestAnimationFrame(resolve);
  4560. });
  4561. exports.animationStarted = animationStarted;
  4562. function dispatchDOMEvent(eventName) {
  4563. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  4564. throw new Error("Not implemented: dispatchDOMEvent");
  4565. }
  4566. var EventBus = /*#__PURE__*/function () {
  4567. function EventBus(options) {
  4568. _classCallCheck(this, EventBus);
  4569. this._listeners = Object.create(null);
  4570. }
  4571. _createClass(EventBus, [{
  4572. key: "on",
  4573. value: function on(eventName, listener) {
  4574. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4575. this._on(eventName, listener, {
  4576. external: true,
  4577. once: options === null || options === void 0 ? void 0 : options.once
  4578. });
  4579. }
  4580. }, {
  4581. key: "off",
  4582. value: function off(eventName, listener) {
  4583. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4584. this._off(eventName, listener, {
  4585. external: true,
  4586. once: options === null || options === void 0 ? void 0 : options.once
  4587. });
  4588. }
  4589. }, {
  4590. key: "dispatch",
  4591. value: function dispatch(eventName) {
  4592. var _this = this;
  4593. var eventListeners = this._listeners[eventName];
  4594. if (!eventListeners || eventListeners.length === 0) {
  4595. return;
  4596. }
  4597. var args = Array.prototype.slice.call(arguments, 1);
  4598. var externalListeners;
  4599. eventListeners.slice(0).forEach(function (_ref4) {
  4600. var listener = _ref4.listener,
  4601. external = _ref4.external,
  4602. once = _ref4.once;
  4603. if (once) {
  4604. _this._off(eventName, listener);
  4605. }
  4606. if (external) {
  4607. (externalListeners || (externalListeners = [])).push(listener);
  4608. return;
  4609. }
  4610. listener.apply(null, args);
  4611. });
  4612. if (externalListeners) {
  4613. externalListeners.forEach(function (listener) {
  4614. listener.apply(null, args);
  4615. });
  4616. externalListeners = null;
  4617. }
  4618. }
  4619. }, {
  4620. key: "_on",
  4621. value: function _on(eventName, listener) {
  4622. var _this$_listeners;
  4623. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4624. var eventListeners = (_this$_listeners = this._listeners)[eventName] || (_this$_listeners[eventName] = []);
  4625. eventListeners.push({
  4626. listener: listener,
  4627. external: (options === null || options === void 0 ? void 0 : options.external) === true,
  4628. once: (options === null || options === void 0 ? void 0 : options.once) === true
  4629. });
  4630. }
  4631. }, {
  4632. key: "_off",
  4633. value: function _off(eventName, listener) {
  4634. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4635. var eventListeners = this._listeners[eventName];
  4636. if (!eventListeners) {
  4637. return;
  4638. }
  4639. for (var i = 0, ii = eventListeners.length; i < ii; i++) {
  4640. if (eventListeners[i].listener === listener) {
  4641. eventListeners.splice(i, 1);
  4642. return;
  4643. }
  4644. }
  4645. }
  4646. }]);
  4647. return EventBus;
  4648. }();
  4649. exports.EventBus = EventBus;
  4650. function clamp(v, min, max) {
  4651. return Math.min(Math.max(v, min), max);
  4652. }
  4653. var ProgressBar = /*#__PURE__*/function () {
  4654. function ProgressBar(id) {
  4655. var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  4656. height = _ref5.height,
  4657. width = _ref5.width,
  4658. units = _ref5.units;
  4659. _classCallCheck(this, ProgressBar);
  4660. this.visible = true;
  4661. this.div = document.querySelector(id + " .progress");
  4662. this.bar = this.div.parentNode;
  4663. this.height = height || 100;
  4664. this.width = width || 100;
  4665. this.units = units || "%";
  4666. this.div.style.height = this.height + this.units;
  4667. this.percent = 0;
  4668. }
  4669. _createClass(ProgressBar, [{
  4670. key: "_updateBar",
  4671. value: function _updateBar() {
  4672. if (this._indeterminate) {
  4673. this.div.classList.add("indeterminate");
  4674. this.div.style.width = this.width + this.units;
  4675. return;
  4676. }
  4677. this.div.classList.remove("indeterminate");
  4678. var progressSize = this.width * this._percent / 100;
  4679. this.div.style.width = progressSize + this.units;
  4680. }
  4681. }, {
  4682. key: "setWidth",
  4683. value: function setWidth(viewer) {
  4684. if (!viewer) {
  4685. return;
  4686. }
  4687. var container = viewer.parentNode;
  4688. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  4689. if (scrollbarWidth > 0) {
  4690. var doc = document.documentElement;
  4691. doc.style.setProperty(LOADINGBAR_END_OFFSET_VAR, "".concat(scrollbarWidth, "px"));
  4692. }
  4693. }
  4694. }, {
  4695. key: "hide",
  4696. value: function hide() {
  4697. if (!this.visible) {
  4698. return;
  4699. }
  4700. this.visible = false;
  4701. this.bar.classList.add("hidden");
  4702. }
  4703. }, {
  4704. key: "show",
  4705. value: function show() {
  4706. if (this.visible) {
  4707. return;
  4708. }
  4709. this.visible = true;
  4710. this.bar.classList.remove("hidden");
  4711. }
  4712. }, {
  4713. key: "percent",
  4714. get: function get() {
  4715. return this._percent;
  4716. },
  4717. set: function set(val) {
  4718. this._indeterminate = isNaN(val);
  4719. this._percent = clamp(val, 0, 100);
  4720. this._updateBar();
  4721. }
  4722. }]);
  4723. return ProgressBar;
  4724. }();
  4725. exports.ProgressBar = ProgressBar;
  4726. function moveToEndOfArray(arr, condition) {
  4727. var moved = [],
  4728. len = arr.length;
  4729. var write = 0;
  4730. for (var read = 0; read < len; ++read) {
  4731. if (condition(arr[read])) {
  4732. moved.push(arr[read]);
  4733. } else {
  4734. arr[write] = arr[read];
  4735. ++write;
  4736. }
  4737. }
  4738. for (var _read = 0; write < len; ++_read, ++write) {
  4739. arr[write] = moved[_read];
  4740. }
  4741. }
  4742. function getActiveOrFocusedElement() {
  4743. var curRoot = document;
  4744. var curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  4745. while (curActiveOrFocused && curActiveOrFocused.shadowRoot) {
  4746. curRoot = curActiveOrFocused.shadowRoot;
  4747. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  4748. }
  4749. return curActiveOrFocused;
  4750. }
  4751. /***/ }),
  4752. /* 7 */
  4753. /***/ ((module) => {
  4754. var pdfjsLib;
  4755. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  4756. pdfjsLib = window["pdfjs-dist/build/pdf"];
  4757. } else {
  4758. pdfjsLib = require("../build/pdf.js");
  4759. }
  4760. module.exports = pdfjsLib;
  4761. /***/ }),
  4762. /* 8 */
  4763. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4764. Object.defineProperty(exports, "__esModule", ({
  4765. value: true
  4766. }));
  4767. exports.PDFCursorTools = exports.CursorTool = void 0;
  4768. var _grab_to_pan = __webpack_require__(9);
  4769. var _ui_utils = __webpack_require__(6);
  4770. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4771. 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); } }
  4772. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4773. var CursorTool = {
  4774. SELECT: 0,
  4775. HAND: 1,
  4776. ZOOM: 2
  4777. };
  4778. exports.CursorTool = CursorTool;
  4779. var PDFCursorTools = /*#__PURE__*/function () {
  4780. function PDFCursorTools(_ref) {
  4781. var _this = this;
  4782. var container = _ref.container,
  4783. eventBus = _ref.eventBus,
  4784. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  4785. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT : _ref$cursorToolOnLoad;
  4786. _classCallCheck(this, PDFCursorTools);
  4787. this.container = container;
  4788. this.eventBus = eventBus;
  4789. this.active = CursorTool.SELECT;
  4790. this.activeBeforePresentationMode = null;
  4791. this.handTool = new _grab_to_pan.GrabToPan({
  4792. element: this.container
  4793. });
  4794. this._addEventListeners();
  4795. Promise.resolve().then(function () {
  4796. _this.switchTool(cursorToolOnLoad);
  4797. });
  4798. }
  4799. _createClass(PDFCursorTools, [{
  4800. key: "switchTool",
  4801. value: function switchTool(tool) {
  4802. var _this2 = this;
  4803. if (this.activeBeforePresentationMode !== null) {
  4804. return;
  4805. }
  4806. if (tool === this.active) {
  4807. return;
  4808. }
  4809. var disableActiveTool = function disableActiveTool() {
  4810. switch (_this2.active) {
  4811. case CursorTool.SELECT:
  4812. break;
  4813. case CursorTool.HAND:
  4814. _this2.handTool.deactivate();
  4815. break;
  4816. case CursorTool.ZOOM:
  4817. }
  4818. };
  4819. switch (tool) {
  4820. case CursorTool.SELECT:
  4821. disableActiveTool();
  4822. break;
  4823. case CursorTool.HAND:
  4824. disableActiveTool();
  4825. this.handTool.activate();
  4826. break;
  4827. case CursorTool.ZOOM:
  4828. default:
  4829. console.error("switchTool: \"".concat(tool, "\" is an unsupported value."));
  4830. return;
  4831. }
  4832. this.active = tool;
  4833. this._dispatchEvent();
  4834. }
  4835. }, {
  4836. key: "_dispatchEvent",
  4837. value: function _dispatchEvent() {
  4838. this.eventBus.dispatch("cursortoolchanged", {
  4839. source: this,
  4840. tool: this.active
  4841. });
  4842. }
  4843. }, {
  4844. key: "_addEventListeners",
  4845. value: function _addEventListeners() {
  4846. var _this3 = this;
  4847. this.eventBus._on("switchcursortool", function (evt) {
  4848. _this3.switchTool(evt.tool);
  4849. });
  4850. this.eventBus._on("presentationmodechanged", function (evt) {
  4851. switch (evt.state) {
  4852. case _ui_utils.PresentationModeState.CHANGING:
  4853. break;
  4854. case _ui_utils.PresentationModeState.FULLSCREEN:
  4855. {
  4856. var previouslyActive = _this3.active;
  4857. _this3.switchTool(CursorTool.SELECT);
  4858. _this3.activeBeforePresentationMode = previouslyActive;
  4859. break;
  4860. }
  4861. case _ui_utils.PresentationModeState.NORMAL:
  4862. {
  4863. var _previouslyActive = _this3.activeBeforePresentationMode;
  4864. _this3.activeBeforePresentationMode = null;
  4865. _this3.switchTool(_previouslyActive);
  4866. break;
  4867. }
  4868. }
  4869. });
  4870. }
  4871. }, {
  4872. key: "activeTool",
  4873. get: function get() {
  4874. return this.active;
  4875. }
  4876. }]);
  4877. return PDFCursorTools;
  4878. }();
  4879. exports.PDFCursorTools = PDFCursorTools;
  4880. /***/ }),
  4881. /* 9 */
  4882. /***/ ((__unused_webpack_module, exports) => {
  4883. Object.defineProperty(exports, "__esModule", ({
  4884. value: true
  4885. }));
  4886. exports.GrabToPan = GrabToPan;
  4887. function GrabToPan(options) {
  4888. this.element = options.element;
  4889. this.document = options.element.ownerDocument;
  4890. if (typeof options.ignoreTarget === "function") {
  4891. this.ignoreTarget = options.ignoreTarget;
  4892. }
  4893. this.onActiveChanged = options.onActiveChanged;
  4894. this.activate = this.activate.bind(this);
  4895. this.deactivate = this.deactivate.bind(this);
  4896. this.toggle = this.toggle.bind(this);
  4897. this._onmousedown = this._onmousedown.bind(this);
  4898. this._onmousemove = this._onmousemove.bind(this);
  4899. this._endPan = this._endPan.bind(this);
  4900. var overlay = this.overlay = document.createElement("div");
  4901. overlay.className = "grab-to-pan-grabbing";
  4902. }
  4903. GrabToPan.prototype = {
  4904. CSS_CLASS_GRAB: "grab-to-pan-grab",
  4905. activate: function GrabToPan_activate() {
  4906. if (!this.active) {
  4907. this.active = true;
  4908. this.element.addEventListener("mousedown", this._onmousedown, true);
  4909. this.element.classList.add(this.CSS_CLASS_GRAB);
  4910. if (this.onActiveChanged) {
  4911. this.onActiveChanged(true);
  4912. }
  4913. }
  4914. },
  4915. deactivate: function GrabToPan_deactivate() {
  4916. if (this.active) {
  4917. this.active = false;
  4918. this.element.removeEventListener("mousedown", this._onmousedown, true);
  4919. this._endPan();
  4920. this.element.classList.remove(this.CSS_CLASS_GRAB);
  4921. if (this.onActiveChanged) {
  4922. this.onActiveChanged(false);
  4923. }
  4924. }
  4925. },
  4926. toggle: function GrabToPan_toggle() {
  4927. if (this.active) {
  4928. this.deactivate();
  4929. } else {
  4930. this.activate();
  4931. }
  4932. },
  4933. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  4934. return node[matchesSelector]("a[href], a[href] *, input, textarea, button, button *, select, option");
  4935. },
  4936. _onmousedown: function GrabToPan__onmousedown(event) {
  4937. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  4938. return;
  4939. }
  4940. if (event.originalTarget) {
  4941. try {
  4942. event.originalTarget.tagName;
  4943. } catch (e) {
  4944. return;
  4945. }
  4946. }
  4947. this.scrollLeftStart = this.element.scrollLeft;
  4948. this.scrollTopStart = this.element.scrollTop;
  4949. this.clientXStart = event.clientX;
  4950. this.clientYStart = event.clientY;
  4951. this.document.addEventListener("mousemove", this._onmousemove, true);
  4952. this.document.addEventListener("mouseup", this._endPan, true);
  4953. this.element.addEventListener("scroll", this._endPan, true);
  4954. event.preventDefault();
  4955. event.stopPropagation();
  4956. var focusedElement = document.activeElement;
  4957. if (focusedElement && !focusedElement.contains(event.target)) {
  4958. focusedElement.blur();
  4959. }
  4960. },
  4961. _onmousemove: function GrabToPan__onmousemove(event) {
  4962. this.element.removeEventListener("scroll", this._endPan, true);
  4963. if (isLeftMouseReleased(event)) {
  4964. this._endPan();
  4965. return;
  4966. }
  4967. var xDiff = event.clientX - this.clientXStart;
  4968. var yDiff = event.clientY - this.clientYStart;
  4969. var scrollTop = this.scrollTopStart - yDiff;
  4970. var scrollLeft = this.scrollLeftStart - xDiff;
  4971. if (this.element.scrollTo) {
  4972. this.element.scrollTo({
  4973. top: scrollTop,
  4974. left: scrollLeft,
  4975. behavior: "instant"
  4976. });
  4977. } else {
  4978. this.element.scrollTop = scrollTop;
  4979. this.element.scrollLeft = scrollLeft;
  4980. }
  4981. if (!this.overlay.parentNode) {
  4982. document.body.appendChild(this.overlay);
  4983. }
  4984. },
  4985. _endPan: function GrabToPan__endPan() {
  4986. this.element.removeEventListener("scroll", this._endPan, true);
  4987. this.document.removeEventListener("mousemove", this._onmousemove, true);
  4988. this.document.removeEventListener("mouseup", this._endPan, true);
  4989. this.overlay.remove();
  4990. }
  4991. };
  4992. var matchesSelector;
  4993. ["webkitM", "mozM", "m"].some(function (prefix) {
  4994. var name = prefix + "atches";
  4995. if (name in document.documentElement) {
  4996. matchesSelector = name;
  4997. }
  4998. name += "Selector";
  4999. if (name in document.documentElement) {
  5000. matchesSelector = name;
  5001. }
  5002. return matchesSelector;
  5003. });
  5004. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  5005. var chrome = window.chrome;
  5006. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  5007. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  5008. function isLeftMouseReleased(event) {
  5009. if ("buttons" in event && isNotIEorIsIE10plus) {
  5010. return !(event.buttons & 1);
  5011. }
  5012. if (isChrome15OrOpera15plus || isSafari6plus) {
  5013. return event.which === 0;
  5014. }
  5015. return false;
  5016. }
  5017. /***/ }),
  5018. /* 10 */
  5019. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5020. Object.defineProperty(exports, "__esModule", ({
  5021. value: true
  5022. }));
  5023. exports.RenderingStates = exports.PDFRenderingQueue = void 0;
  5024. var _pdfjsLib = __webpack_require__(7);
  5025. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5026. 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); } }
  5027. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5028. var CLEANUP_TIMEOUT = 30000;
  5029. var RenderingStates = {
  5030. INITIAL: 0,
  5031. RUNNING: 1,
  5032. PAUSED: 2,
  5033. FINISHED: 3
  5034. };
  5035. exports.RenderingStates = RenderingStates;
  5036. var PDFRenderingQueue = /*#__PURE__*/function () {
  5037. function PDFRenderingQueue() {
  5038. _classCallCheck(this, PDFRenderingQueue);
  5039. this.pdfViewer = null;
  5040. this.pdfThumbnailViewer = null;
  5041. this.onIdle = null;
  5042. this.highestPriorityPage = null;
  5043. this.idleTimeout = null;
  5044. this.printing = false;
  5045. this.isThumbnailViewEnabled = false;
  5046. }
  5047. _createClass(PDFRenderingQueue, [{
  5048. key: "setViewer",
  5049. value: function setViewer(pdfViewer) {
  5050. this.pdfViewer = pdfViewer;
  5051. }
  5052. }, {
  5053. key: "setThumbnailViewer",
  5054. value: function setThumbnailViewer(pdfThumbnailViewer) {
  5055. this.pdfThumbnailViewer = pdfThumbnailViewer;
  5056. }
  5057. }, {
  5058. key: "isHighestPriority",
  5059. value: function isHighestPriority(view) {
  5060. return this.highestPriorityPage === view.renderingId;
  5061. }
  5062. }, {
  5063. key: "renderHighestPriority",
  5064. value: function renderHighestPriority(currentlyVisiblePages) {
  5065. if (this.idleTimeout) {
  5066. clearTimeout(this.idleTimeout);
  5067. this.idleTimeout = null;
  5068. }
  5069. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  5070. return;
  5071. }
  5072. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  5073. if (this.pdfThumbnailViewer.forceRendering()) {
  5074. return;
  5075. }
  5076. }
  5077. if (this.printing) {
  5078. return;
  5079. }
  5080. if (this.onIdle) {
  5081. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  5082. }
  5083. }
  5084. }, {
  5085. key: "getHighestPriority",
  5086. value: function getHighestPriority(visible, views, scrolledDown) {
  5087. var visibleViews = visible.views;
  5088. var numVisible = visibleViews.length;
  5089. if (numVisible === 0) {
  5090. return null;
  5091. }
  5092. for (var i = 0; i < numVisible; ++i) {
  5093. var view = visibleViews[i].view;
  5094. if (!this.isViewFinished(view)) {
  5095. return view;
  5096. }
  5097. }
  5098. if (scrolledDown) {
  5099. var nextPageIndex = visible.last.id;
  5100. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  5101. return views[nextPageIndex];
  5102. }
  5103. } else {
  5104. var previousPageIndex = visible.first.id - 2;
  5105. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  5106. return views[previousPageIndex];
  5107. }
  5108. }
  5109. return null;
  5110. }
  5111. }, {
  5112. key: "isViewFinished",
  5113. value: function isViewFinished(view) {
  5114. return view.renderingState === RenderingStates.FINISHED;
  5115. }
  5116. }, {
  5117. key: "renderView",
  5118. value: function renderView(view) {
  5119. var _this = this;
  5120. switch (view.renderingState) {
  5121. case RenderingStates.FINISHED:
  5122. return false;
  5123. case RenderingStates.PAUSED:
  5124. this.highestPriorityPage = view.renderingId;
  5125. view.resume();
  5126. break;
  5127. case RenderingStates.RUNNING:
  5128. this.highestPriorityPage = view.renderingId;
  5129. break;
  5130. case RenderingStates.INITIAL:
  5131. this.highestPriorityPage = view.renderingId;
  5132. view.draw()["finally"](function () {
  5133. _this.renderHighestPriority();
  5134. })["catch"](function (reason) {
  5135. if (reason instanceof _pdfjsLib.RenderingCancelledException) {
  5136. return;
  5137. }
  5138. console.error("renderView: \"".concat(reason, "\""));
  5139. });
  5140. break;
  5141. }
  5142. return true;
  5143. }
  5144. }]);
  5145. return PDFRenderingQueue;
  5146. }();
  5147. exports.PDFRenderingQueue = PDFRenderingQueue;
  5148. /***/ }),
  5149. /* 11 */
  5150. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5151. Object.defineProperty(exports, "__esModule", ({
  5152. value: true
  5153. }));
  5154. exports.OverlayManager = void 0;
  5155. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  5156. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5157. 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); } }
  5158. 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); }); }; }
  5159. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5160. 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); } }
  5161. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5162. var OverlayManager = /*#__PURE__*/function () {
  5163. function OverlayManager() {
  5164. _classCallCheck(this, OverlayManager);
  5165. this._overlays = {};
  5166. this._active = null;
  5167. this._keyDownBound = this._keyDown.bind(this);
  5168. }
  5169. _createClass(OverlayManager, [{
  5170. key: "register",
  5171. value: function () {
  5172. var _register = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, element) {
  5173. var callerCloseMethod,
  5174. canForceClose,
  5175. container,
  5176. _args = arguments;
  5177. return _regenerator["default"].wrap(function _callee$(_context) {
  5178. while (1) {
  5179. switch (_context.prev = _context.next) {
  5180. case 0:
  5181. callerCloseMethod = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
  5182. canForceClose = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
  5183. if (!(!name || !element || !(container = element.parentNode))) {
  5184. _context.next = 6;
  5185. break;
  5186. }
  5187. throw new Error("Not enough parameters.");
  5188. case 6:
  5189. if (!this._overlays[name]) {
  5190. _context.next = 8;
  5191. break;
  5192. }
  5193. throw new Error("The overlay is already registered.");
  5194. case 8:
  5195. this._overlays[name] = {
  5196. element: element,
  5197. container: container,
  5198. callerCloseMethod: callerCloseMethod,
  5199. canForceClose: canForceClose
  5200. };
  5201. case 9:
  5202. case "end":
  5203. return _context.stop();
  5204. }
  5205. }
  5206. }, _callee, this);
  5207. }));
  5208. function register(_x, _x2) {
  5209. return _register.apply(this, arguments);
  5210. }
  5211. return register;
  5212. }()
  5213. }, {
  5214. key: "unregister",
  5215. value: function () {
  5216. var _unregister = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(name) {
  5217. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5218. while (1) {
  5219. switch (_context2.prev = _context2.next) {
  5220. case 0:
  5221. if (this._overlays[name]) {
  5222. _context2.next = 4;
  5223. break;
  5224. }
  5225. throw new Error("The overlay does not exist.");
  5226. case 4:
  5227. if (!(this._active === name)) {
  5228. _context2.next = 6;
  5229. break;
  5230. }
  5231. throw new Error("The overlay cannot be removed while it is active.");
  5232. case 6:
  5233. delete this._overlays[name];
  5234. case 7:
  5235. case "end":
  5236. return _context2.stop();
  5237. }
  5238. }
  5239. }, _callee2, this);
  5240. }));
  5241. function unregister(_x3) {
  5242. return _unregister.apply(this, arguments);
  5243. }
  5244. return unregister;
  5245. }()
  5246. }, {
  5247. key: "open",
  5248. value: function () {
  5249. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name) {
  5250. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5251. while (1) {
  5252. switch (_context3.prev = _context3.next) {
  5253. case 0:
  5254. if (this._overlays[name]) {
  5255. _context3.next = 4;
  5256. break;
  5257. }
  5258. throw new Error("The overlay does not exist.");
  5259. case 4:
  5260. if (!this._active) {
  5261. _context3.next = 14;
  5262. break;
  5263. }
  5264. if (!this._overlays[name].canForceClose) {
  5265. _context3.next = 9;
  5266. break;
  5267. }
  5268. this._closeThroughCaller();
  5269. _context3.next = 14;
  5270. break;
  5271. case 9:
  5272. if (!(this._active === name)) {
  5273. _context3.next = 13;
  5274. break;
  5275. }
  5276. throw new Error("The overlay is already active.");
  5277. case 13:
  5278. throw new Error("Another overlay is currently active.");
  5279. case 14:
  5280. this._active = name;
  5281. this._overlays[this._active].element.classList.remove("hidden");
  5282. this._overlays[this._active].container.classList.remove("hidden");
  5283. window.addEventListener("keydown", this._keyDownBound);
  5284. case 18:
  5285. case "end":
  5286. return _context3.stop();
  5287. }
  5288. }
  5289. }, _callee3, this);
  5290. }));
  5291. function open(_x4) {
  5292. return _open.apply(this, arguments);
  5293. }
  5294. return open;
  5295. }()
  5296. }, {
  5297. key: "close",
  5298. value: function () {
  5299. var _close = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name) {
  5300. return _regenerator["default"].wrap(function _callee4$(_context4) {
  5301. while (1) {
  5302. switch (_context4.prev = _context4.next) {
  5303. case 0:
  5304. if (this._overlays[name]) {
  5305. _context4.next = 4;
  5306. break;
  5307. }
  5308. throw new Error("The overlay does not exist.");
  5309. case 4:
  5310. if (this._active) {
  5311. _context4.next = 8;
  5312. break;
  5313. }
  5314. throw new Error("The overlay is currently not active.");
  5315. case 8:
  5316. if (!(this._active !== name)) {
  5317. _context4.next = 10;
  5318. break;
  5319. }
  5320. throw new Error("Another overlay is currently active.");
  5321. case 10:
  5322. this._overlays[this._active].container.classList.add("hidden");
  5323. this._overlays[this._active].element.classList.add("hidden");
  5324. this._active = null;
  5325. window.removeEventListener("keydown", this._keyDownBound);
  5326. case 14:
  5327. case "end":
  5328. return _context4.stop();
  5329. }
  5330. }
  5331. }, _callee4, this);
  5332. }));
  5333. function close(_x5) {
  5334. return _close.apply(this, arguments);
  5335. }
  5336. return close;
  5337. }()
  5338. }, {
  5339. key: "_keyDown",
  5340. value: function _keyDown(evt) {
  5341. if (this._active && evt.keyCode === 27) {
  5342. this._closeThroughCaller();
  5343. evt.preventDefault();
  5344. }
  5345. }
  5346. }, {
  5347. key: "_closeThroughCaller",
  5348. value: function _closeThroughCaller() {
  5349. if (this._overlays[this._active].callerCloseMethod) {
  5350. this._overlays[this._active].callerCloseMethod();
  5351. }
  5352. if (this._active) {
  5353. this.close(this._active);
  5354. }
  5355. }
  5356. }, {
  5357. key: "active",
  5358. get: function get() {
  5359. return this._active;
  5360. }
  5361. }]);
  5362. return OverlayManager;
  5363. }();
  5364. exports.OverlayManager = OverlayManager;
  5365. /***/ }),
  5366. /* 12 */
  5367. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5368. Object.defineProperty(exports, "__esModule", ({
  5369. value: true
  5370. }));
  5371. exports.PasswordPrompt = void 0;
  5372. var _ui_utils = __webpack_require__(6);
  5373. var _pdfjsLib = __webpack_require__(7);
  5374. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5375. 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); } }
  5376. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5377. var PasswordPrompt = /*#__PURE__*/function () {
  5378. function PasswordPrompt(options, overlayManager) {
  5379. var _this = this;
  5380. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5381. _classCallCheck(this, PasswordPrompt);
  5382. this.overlayName = options.overlayName;
  5383. this.container = options.container;
  5384. this.label = options.label;
  5385. this.input = options.input;
  5386. this.submitButton = options.submitButton;
  5387. this.cancelButton = options.cancelButton;
  5388. this.overlayManager = overlayManager;
  5389. this.l10n = l10n;
  5390. this.updateCallback = null;
  5391. this.reason = null;
  5392. this.submitButton.addEventListener("click", this.verify.bind(this));
  5393. this.cancelButton.addEventListener("click", this.close.bind(this));
  5394. this.input.addEventListener("keydown", function (e) {
  5395. if (e.keyCode === 13) {
  5396. _this.verify();
  5397. }
  5398. });
  5399. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  5400. }
  5401. _createClass(PasswordPrompt, [{
  5402. key: "open",
  5403. value: function open() {
  5404. var _this2 = this;
  5405. this.overlayManager.open(this.overlayName).then(function () {
  5406. _this2.input.focus();
  5407. var promptString;
  5408. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  5409. promptString = _this2.l10n.get("password_invalid", null, "Invalid password. Please try again.");
  5410. } else {
  5411. promptString = _this2.l10n.get("password_label", null, "Enter the password to open this PDF file.");
  5412. }
  5413. promptString.then(function (msg) {
  5414. _this2.label.textContent = msg;
  5415. });
  5416. });
  5417. }
  5418. }, {
  5419. key: "close",
  5420. value: function close() {
  5421. var _this3 = this;
  5422. this.overlayManager.close(this.overlayName).then(function () {
  5423. _this3.input.value = "";
  5424. });
  5425. }
  5426. }, {
  5427. key: "verify",
  5428. value: function verify() {
  5429. var password = this.input.value;
  5430. if (password && password.length > 0) {
  5431. this.close();
  5432. this.updateCallback(password);
  5433. }
  5434. }
  5435. }, {
  5436. key: "setUpdateCallback",
  5437. value: function setUpdateCallback(updateCallback, reason) {
  5438. this.updateCallback = updateCallback;
  5439. this.reason = reason;
  5440. }
  5441. }]);
  5442. return PasswordPrompt;
  5443. }();
  5444. exports.PasswordPrompt = PasswordPrompt;
  5445. /***/ }),
  5446. /* 13 */
  5447. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5448. 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); }
  5449. Object.defineProperty(exports, "__esModule", ({
  5450. value: true
  5451. }));
  5452. exports.PDFAttachmentViewer = void 0;
  5453. var _pdfjsLib = __webpack_require__(7);
  5454. var _base_tree_viewer = __webpack_require__(14);
  5455. var _viewer_compatibility = __webpack_require__(2);
  5456. 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; } } }; }
  5457. 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); }
  5458. 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; }
  5459. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5460. 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); } }
  5461. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5462. 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); }
  5463. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  5464. 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); }
  5465. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  5466. 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); }; }
  5467. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  5468. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  5469. 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; } }
  5470. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  5471. var PdfFileRegExp = /\.pdf$/i;
  5472. var PDFAttachmentViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  5473. _inherits(PDFAttachmentViewer, _BaseTreeViewer);
  5474. var _super = _createSuper(PDFAttachmentViewer);
  5475. function PDFAttachmentViewer(options) {
  5476. var _this;
  5477. _classCallCheck(this, PDFAttachmentViewer);
  5478. _this = _super.call(this, options);
  5479. _this.downloadManager = options.downloadManager;
  5480. _this.eventBus._on("fileattachmentannotation", _this._appendAttachment.bind(_assertThisInitialized(_this)));
  5481. return _this;
  5482. }
  5483. _createClass(PDFAttachmentViewer, [{
  5484. key: "reset",
  5485. value: function reset() {
  5486. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5487. _get(_getPrototypeOf(PDFAttachmentViewer.prototype), "reset", this).call(this);
  5488. this._attachments = null;
  5489. if (!keepRenderedCapability) {
  5490. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  5491. }
  5492. if (this._pendingDispatchEvent) {
  5493. clearTimeout(this._pendingDispatchEvent);
  5494. }
  5495. this._pendingDispatchEvent = null;
  5496. }
  5497. }, {
  5498. key: "_dispatchEvent",
  5499. value: function _dispatchEvent(attachmentsCount) {
  5500. var _this2 = this;
  5501. this._renderedCapability.resolve();
  5502. if (this._pendingDispatchEvent) {
  5503. clearTimeout(this._pendingDispatchEvent);
  5504. this._pendingDispatchEvent = null;
  5505. }
  5506. if (attachmentsCount === 0) {
  5507. this._pendingDispatchEvent = setTimeout(function () {
  5508. _this2.eventBus.dispatch("attachmentsloaded", {
  5509. source: _this2,
  5510. attachmentsCount: 0
  5511. });
  5512. _this2._pendingDispatchEvent = null;
  5513. });
  5514. return;
  5515. }
  5516. this.eventBus.dispatch("attachmentsloaded", {
  5517. source: this,
  5518. attachmentsCount: attachmentsCount
  5519. });
  5520. }
  5521. }, {
  5522. key: "_bindPdfLink",
  5523. value: function _bindPdfLink(element, _ref) {
  5524. var _this3 = this;
  5525. var content = _ref.content,
  5526. filename = _ref.filename;
  5527. var blobUrl;
  5528. element.onclick = function () {
  5529. if (!blobUrl) {
  5530. blobUrl = URL.createObjectURL(new Blob([content], {
  5531. type: "application/pdf"
  5532. }));
  5533. }
  5534. var viewerUrl;
  5535. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  5536. try {
  5537. window.open(viewerUrl);
  5538. } catch (ex) {
  5539. console.error("_bindPdfLink: ".concat(ex));
  5540. URL.revokeObjectURL(blobUrl);
  5541. blobUrl = null;
  5542. _this3.downloadManager.downloadData(content, filename, "application/pdf");
  5543. }
  5544. return false;
  5545. };
  5546. }
  5547. }, {
  5548. key: "_bindLink",
  5549. value: function _bindLink(element, _ref2) {
  5550. var _this4 = this;
  5551. var content = _ref2.content,
  5552. filename = _ref2.filename;
  5553. element.onclick = function () {
  5554. var contentType = PdfFileRegExp.test(filename) ? "application/pdf" : "";
  5555. _this4.downloadManager.downloadData(content, filename, contentType);
  5556. return false;
  5557. };
  5558. }
  5559. }, {
  5560. key: "render",
  5561. value: function render(_ref3) {
  5562. var attachments = _ref3.attachments,
  5563. _ref3$keepRenderedCap = _ref3.keepRenderedCapability,
  5564. keepRenderedCapability = _ref3$keepRenderedCap === void 0 ? false : _ref3$keepRenderedCap;
  5565. if (this._attachments) {
  5566. this.reset(keepRenderedCapability);
  5567. }
  5568. this._attachments = attachments || null;
  5569. if (!attachments) {
  5570. this._dispatchEvent(0);
  5571. return;
  5572. }
  5573. var names = Object.keys(attachments).sort(function (a, b) {
  5574. return a.toLowerCase().localeCompare(b.toLowerCase());
  5575. });
  5576. var fragment = document.createDocumentFragment();
  5577. var attachmentsCount = 0;
  5578. var _iterator = _createForOfIteratorHelper(names),
  5579. _step;
  5580. try {
  5581. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5582. var name = _step.value;
  5583. var item = attachments[name];
  5584. var filename = (0, _pdfjsLib.getFilenameFromUrl)(item.filename);
  5585. var div = document.createElement("div");
  5586. div.className = "treeItem";
  5587. var element = document.createElement("a");
  5588. if (PdfFileRegExp.test(filename) && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  5589. this._bindPdfLink(element, {
  5590. content: item.content,
  5591. filename: filename
  5592. });
  5593. } else {
  5594. this._bindLink(element, {
  5595. content: item.content,
  5596. filename: filename
  5597. });
  5598. }
  5599. element.textContent = this._normalizeTextContent(filename);
  5600. div.appendChild(element);
  5601. fragment.appendChild(div);
  5602. attachmentsCount++;
  5603. }
  5604. } catch (err) {
  5605. _iterator.e(err);
  5606. } finally {
  5607. _iterator.f();
  5608. }
  5609. this._finishRendering(fragment, attachmentsCount);
  5610. }
  5611. }, {
  5612. key: "_appendAttachment",
  5613. value: function _appendAttachment(_ref4) {
  5614. var _this5 = this;
  5615. var id = _ref4.id,
  5616. filename = _ref4.filename,
  5617. content = _ref4.content;
  5618. var renderedPromise = this._renderedCapability.promise;
  5619. renderedPromise.then(function () {
  5620. if (renderedPromise !== _this5._renderedCapability.promise) {
  5621. return;
  5622. }
  5623. var attachments = _this5._attachments;
  5624. if (!attachments) {
  5625. attachments = Object.create(null);
  5626. } else {
  5627. for (var name in attachments) {
  5628. if (id === name) {
  5629. return;
  5630. }
  5631. }
  5632. }
  5633. attachments[id] = {
  5634. filename: filename,
  5635. content: content
  5636. };
  5637. _this5.render({
  5638. attachments: attachments,
  5639. keepRenderedCapability: true
  5640. });
  5641. });
  5642. }
  5643. }]);
  5644. return PDFAttachmentViewer;
  5645. }(_base_tree_viewer.BaseTreeViewer);
  5646. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  5647. /***/ }),
  5648. /* 14 */
  5649. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5650. Object.defineProperty(exports, "__esModule", ({
  5651. value: true
  5652. }));
  5653. exports.BaseTreeViewer = void 0;
  5654. var _pdfjsLib = __webpack_require__(7);
  5655. 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; } } }; }
  5656. 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); }
  5657. 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; }
  5658. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5659. 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); } }
  5660. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5661. var TREEITEM_OFFSET_TOP = -100;
  5662. var TREEITEM_SELECTED_CLASS = "selected";
  5663. var BaseTreeViewer = /*#__PURE__*/function () {
  5664. function BaseTreeViewer(options) {
  5665. _classCallCheck(this, BaseTreeViewer);
  5666. if (this.constructor === BaseTreeViewer) {
  5667. throw new Error("Cannot initialize BaseTreeViewer.");
  5668. }
  5669. this.container = options.container;
  5670. this.eventBus = options.eventBus;
  5671. this.reset();
  5672. }
  5673. _createClass(BaseTreeViewer, [{
  5674. key: "reset",
  5675. value: function reset() {
  5676. this._pdfDocument = null;
  5677. this._lastToggleIsShow = true;
  5678. this._currentTreeItem = null;
  5679. this.container.textContent = "";
  5680. this.container.classList.remove("treeWithDeepNesting");
  5681. }
  5682. }, {
  5683. key: "_dispatchEvent",
  5684. value: function _dispatchEvent(count) {
  5685. throw new Error("Not implemented: _dispatchEvent");
  5686. }
  5687. }, {
  5688. key: "_bindLink",
  5689. value: function _bindLink(element, params) {
  5690. throw new Error("Not implemented: _bindLink");
  5691. }
  5692. }, {
  5693. key: "_normalizeTextContent",
  5694. value: function _normalizeTextContent(str) {
  5695. return (0, _pdfjsLib.removeNullCharacters)(str) || "\u2013";
  5696. }
  5697. }, {
  5698. key: "_addToggleButton",
  5699. value: function _addToggleButton(div) {
  5700. var _this = this;
  5701. var hidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5702. var toggler = document.createElement("div");
  5703. toggler.className = "treeItemToggler";
  5704. if (hidden) {
  5705. toggler.classList.add("treeItemsHidden");
  5706. }
  5707. toggler.onclick = function (evt) {
  5708. evt.stopPropagation();
  5709. toggler.classList.toggle("treeItemsHidden");
  5710. if (evt.shiftKey) {
  5711. var shouldShowAll = !toggler.classList.contains("treeItemsHidden");
  5712. _this._toggleTreeItem(div, shouldShowAll);
  5713. }
  5714. };
  5715. div.insertBefore(toggler, div.firstChild);
  5716. }
  5717. }, {
  5718. key: "_toggleTreeItem",
  5719. value: function _toggleTreeItem(root) {
  5720. var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5721. this._lastToggleIsShow = show;
  5722. var _iterator = _createForOfIteratorHelper(root.querySelectorAll(".treeItemToggler")),
  5723. _step;
  5724. try {
  5725. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5726. var toggler = _step.value;
  5727. toggler.classList.toggle("treeItemsHidden", !show);
  5728. }
  5729. } catch (err) {
  5730. _iterator.e(err);
  5731. } finally {
  5732. _iterator.f();
  5733. }
  5734. }
  5735. }, {
  5736. key: "_toggleAllTreeItems",
  5737. value: function _toggleAllTreeItems() {
  5738. this._toggleTreeItem(this.container, !this._lastToggleIsShow);
  5739. }
  5740. }, {
  5741. key: "_finishRendering",
  5742. value: function _finishRendering(fragment, count) {
  5743. var hasAnyNesting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5744. if (hasAnyNesting) {
  5745. this.container.classList.add("treeWithDeepNesting");
  5746. this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
  5747. }
  5748. this.container.appendChild(fragment);
  5749. this._dispatchEvent(count);
  5750. }
  5751. }, {
  5752. key: "render",
  5753. value: function render(params) {
  5754. throw new Error("Not implemented: render");
  5755. }
  5756. }, {
  5757. key: "_updateCurrentTreeItem",
  5758. value: function _updateCurrentTreeItem() {
  5759. var treeItem = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  5760. if (this._currentTreeItem) {
  5761. this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS);
  5762. this._currentTreeItem = null;
  5763. }
  5764. if (treeItem) {
  5765. treeItem.classList.add(TREEITEM_SELECTED_CLASS);
  5766. this._currentTreeItem = treeItem;
  5767. }
  5768. }
  5769. }, {
  5770. key: "_scrollToCurrentTreeItem",
  5771. value: function _scrollToCurrentTreeItem(treeItem) {
  5772. if (!treeItem) {
  5773. return;
  5774. }
  5775. var currentNode = treeItem.parentNode;
  5776. while (currentNode && currentNode !== this.container) {
  5777. if (currentNode.classList.contains("treeItem")) {
  5778. var toggler = currentNode.firstElementChild;
  5779. toggler === null || toggler === void 0 ? void 0 : toggler.classList.remove("treeItemsHidden");
  5780. }
  5781. currentNode = currentNode.parentNode;
  5782. }
  5783. this._updateCurrentTreeItem(treeItem);
  5784. this.container.scrollTo(treeItem.offsetLeft, treeItem.offsetTop + TREEITEM_OFFSET_TOP);
  5785. }
  5786. }]);
  5787. return BaseTreeViewer;
  5788. }();
  5789. exports.BaseTreeViewer = BaseTreeViewer;
  5790. /***/ }),
  5791. /* 15 */
  5792. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5793. Object.defineProperty(exports, "__esModule", ({
  5794. value: true
  5795. }));
  5796. exports.PDFDocumentProperties = void 0;
  5797. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  5798. var _pdfjsLib = __webpack_require__(7);
  5799. var _ui_utils = __webpack_require__(6);
  5800. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5801. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  5802. 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."); }
  5803. 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); }
  5804. 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; }
  5805. 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; }
  5806. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  5807. 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); } }
  5808. 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); }); }; }
  5809. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5810. 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); } }
  5811. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5812. var DEFAULT_FIELD_CONTENT = "-";
  5813. var NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  5814. var US_PAGE_NAMES = {
  5815. "8.5x11": "Letter",
  5816. "8.5x14": "Legal"
  5817. };
  5818. var METRIC_PAGE_NAMES = {
  5819. "297x420": "A3",
  5820. "210x297": "A4"
  5821. };
  5822. function getPageName(size, isPortrait, pageNames) {
  5823. var width = isPortrait ? size.width : size.height;
  5824. var height = isPortrait ? size.height : size.width;
  5825. return pageNames["".concat(width, "x").concat(height)];
  5826. }
  5827. var PDFDocumentProperties = /*#__PURE__*/function () {
  5828. function PDFDocumentProperties(_ref, overlayManager, eventBus) {
  5829. var _this = this;
  5830. var overlayName = _ref.overlayName,
  5831. fields = _ref.fields,
  5832. container = _ref.container,
  5833. closeButton = _ref.closeButton;
  5834. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  5835. _classCallCheck(this, PDFDocumentProperties);
  5836. this.overlayName = overlayName;
  5837. this.fields = fields;
  5838. this.container = container;
  5839. this.overlayManager = overlayManager;
  5840. this.l10n = l10n;
  5841. this._reset();
  5842. closeButton.addEventListener("click", this.close.bind(this));
  5843. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  5844. eventBus._on("pagechanging", function (evt) {
  5845. _this._currentPageNumber = evt.pageNumber;
  5846. });
  5847. eventBus._on("rotationchanging", function (evt) {
  5848. _this._pagesRotation = evt.pagesRotation;
  5849. });
  5850. this._isNonMetricLocale = true;
  5851. l10n.getLanguage().then(function (locale) {
  5852. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  5853. });
  5854. }
  5855. _createClass(PDFDocumentProperties, [{
  5856. key: "open",
  5857. value: function () {
  5858. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  5859. var _this2 = this;
  5860. var freezeFieldData, currentPageNumber, pagesRotation, _yield$this$pdfDocume, info, contentDispositionFilename, contentLength, _yield$Promise$all, _yield$Promise$all2, fileName, fileSize, creationDate, modificationDate, pageSize, isLinearized, _yield$this$pdfDocume2, length, data;
  5861. return _regenerator["default"].wrap(function _callee$(_context) {
  5862. while (1) {
  5863. switch (_context.prev = _context.next) {
  5864. case 0:
  5865. freezeFieldData = function freezeFieldData(data) {
  5866. Object.defineProperty(_this2, "fieldData", {
  5867. value: Object.freeze(data),
  5868. writable: false,
  5869. enumerable: true,
  5870. configurable: true
  5871. });
  5872. };
  5873. _context.next = 3;
  5874. return Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]);
  5875. case 3:
  5876. currentPageNumber = this._currentPageNumber;
  5877. pagesRotation = this._pagesRotation;
  5878. if (!(this.fieldData && currentPageNumber === this.fieldData._currentPageNumber && pagesRotation === this.fieldData._pagesRotation)) {
  5879. _context.next = 8;
  5880. break;
  5881. }
  5882. this._updateUI();
  5883. return _context.abrupt("return");
  5884. case 8:
  5885. _context.next = 10;
  5886. return this.pdfDocument.getMetadata();
  5887. case 10:
  5888. _yield$this$pdfDocume = _context.sent;
  5889. info = _yield$this$pdfDocume.info;
  5890. contentDispositionFilename = _yield$this$pdfDocume.contentDispositionFilename;
  5891. contentLength = _yield$this$pdfDocume.contentLength;
  5892. _context.next = 16;
  5893. return Promise.all([contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url), this._parseFileSize(contentLength), this._parseDate(info.CreationDate), this._parseDate(info.ModDate), this.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
  5894. return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  5895. }), this._parseLinearization(info.IsLinearized)]);
  5896. case 16:
  5897. _yield$Promise$all = _context.sent;
  5898. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 6);
  5899. fileName = _yield$Promise$all2[0];
  5900. fileSize = _yield$Promise$all2[1];
  5901. creationDate = _yield$Promise$all2[2];
  5902. modificationDate = _yield$Promise$all2[3];
  5903. pageSize = _yield$Promise$all2[4];
  5904. isLinearized = _yield$Promise$all2[5];
  5905. freezeFieldData({
  5906. fileName: fileName,
  5907. fileSize: fileSize,
  5908. title: info.Title,
  5909. author: info.Author,
  5910. subject: info.Subject,
  5911. keywords: info.Keywords,
  5912. creationDate: creationDate,
  5913. modificationDate: modificationDate,
  5914. creator: info.Creator,
  5915. producer: info.Producer,
  5916. version: info.PDFFormatVersion,
  5917. pageCount: this.pdfDocument.numPages,
  5918. pageSize: pageSize,
  5919. linearized: isLinearized,
  5920. _currentPageNumber: currentPageNumber,
  5921. _pagesRotation: pagesRotation
  5922. });
  5923. this._updateUI();
  5924. _context.next = 28;
  5925. return this.pdfDocument.getDownloadInfo();
  5926. case 28:
  5927. _yield$this$pdfDocume2 = _context.sent;
  5928. length = _yield$this$pdfDocume2.length;
  5929. if (!(contentLength === length)) {
  5930. _context.next = 32;
  5931. break;
  5932. }
  5933. return _context.abrupt("return");
  5934. case 32:
  5935. data = Object.assign(Object.create(null), this.fieldData);
  5936. _context.next = 35;
  5937. return this._parseFileSize(length);
  5938. case 35:
  5939. data.fileSize = _context.sent;
  5940. freezeFieldData(data);
  5941. this._updateUI();
  5942. case 38:
  5943. case "end":
  5944. return _context.stop();
  5945. }
  5946. }
  5947. }, _callee, this);
  5948. }));
  5949. function open() {
  5950. return _open.apply(this, arguments);
  5951. }
  5952. return open;
  5953. }()
  5954. }, {
  5955. key: "close",
  5956. value: function close() {
  5957. this.overlayManager.close(this.overlayName);
  5958. }
  5959. }, {
  5960. key: "setDocument",
  5961. value: function setDocument(pdfDocument) {
  5962. var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5963. if (this.pdfDocument) {
  5964. this._reset();
  5965. this._updateUI(true);
  5966. }
  5967. if (!pdfDocument) {
  5968. return;
  5969. }
  5970. this.pdfDocument = pdfDocument;
  5971. this.url = url;
  5972. this._dataAvailableCapability.resolve();
  5973. }
  5974. }, {
  5975. key: "_reset",
  5976. value: function _reset() {
  5977. this.pdfDocument = null;
  5978. this.url = null;
  5979. delete this.fieldData;
  5980. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5981. this._currentPageNumber = 1;
  5982. this._pagesRotation = 0;
  5983. }
  5984. }, {
  5985. key: "_updateUI",
  5986. value: function _updateUI() {
  5987. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5988. if (reset || !this.fieldData) {
  5989. for (var id in this.fields) {
  5990. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5991. }
  5992. return;
  5993. }
  5994. if (this.overlayManager.active !== this.overlayName) {
  5995. return;
  5996. }
  5997. for (var _id in this.fields) {
  5998. var content = this.fieldData[_id];
  5999. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  6000. }
  6001. }
  6002. }, {
  6003. key: "_parseFileSize",
  6004. value: function () {
  6005. var _parseFileSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  6006. var fileSize,
  6007. kb,
  6008. _args2 = arguments;
  6009. return _regenerator["default"].wrap(function _callee2$(_context2) {
  6010. while (1) {
  6011. switch (_context2.prev = _context2.next) {
  6012. case 0:
  6013. fileSize = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : 0;
  6014. kb = fileSize / 1024;
  6015. if (kb) {
  6016. _context2.next = 6;
  6017. break;
  6018. }
  6019. return _context2.abrupt("return", undefined);
  6020. case 6:
  6021. if (!(kb < 1024)) {
  6022. _context2.next = 8;
  6023. break;
  6024. }
  6025. return _context2.abrupt("return", this.l10n.get("document_properties_kb", {
  6026. size_kb: (+kb.toPrecision(3)).toLocaleString(),
  6027. size_b: fileSize.toLocaleString()
  6028. }, "{{size_kb}} KB ({{size_b}} bytes)"));
  6029. case 8:
  6030. return _context2.abrupt("return", this.l10n.get("document_properties_mb", {
  6031. size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
  6032. size_b: fileSize.toLocaleString()
  6033. }, "{{size_mb}} MB ({{size_b}} bytes)"));
  6034. case 9:
  6035. case "end":
  6036. return _context2.stop();
  6037. }
  6038. }
  6039. }, _callee2, this);
  6040. }));
  6041. function _parseFileSize() {
  6042. return _parseFileSize2.apply(this, arguments);
  6043. }
  6044. return _parseFileSize;
  6045. }()
  6046. }, {
  6047. key: "_parsePageSize",
  6048. value: function () {
  6049. var _parsePageSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(pageSizeInches, pagesRotation) {
  6050. var _this3 = this;
  6051. var isPortrait, sizeInches, sizeMillimeters, pageName, rawName, exactMillimeters, intMillimeters;
  6052. return _regenerator["default"].wrap(function _callee3$(_context3) {
  6053. while (1) {
  6054. switch (_context3.prev = _context3.next) {
  6055. case 0:
  6056. if (pageSizeInches) {
  6057. _context3.next = 2;
  6058. break;
  6059. }
  6060. return _context3.abrupt("return", undefined);
  6061. case 2:
  6062. if (pagesRotation % 180 !== 0) {
  6063. pageSizeInches = {
  6064. width: pageSizeInches.height,
  6065. height: pageSizeInches.width
  6066. };
  6067. }
  6068. isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  6069. sizeInches = {
  6070. width: Math.round(pageSizeInches.width * 100) / 100,
  6071. height: Math.round(pageSizeInches.height * 100) / 100
  6072. };
  6073. sizeMillimeters = {
  6074. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  6075. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  6076. };
  6077. pageName = null;
  6078. rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  6079. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  6080. exactMillimeters = {
  6081. width: pageSizeInches.width * 25.4,
  6082. height: pageSizeInches.height * 25.4
  6083. };
  6084. intMillimeters = {
  6085. width: Math.round(sizeMillimeters.width),
  6086. height: Math.round(sizeMillimeters.height)
  6087. };
  6088. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  6089. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  6090. if (rawName) {
  6091. sizeInches = {
  6092. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  6093. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  6094. };
  6095. sizeMillimeters = intMillimeters;
  6096. }
  6097. }
  6098. }
  6099. if (rawName) {
  6100. pageName = this.l10n.get("document_properties_page_size_name_" + rawName.toLowerCase(), null, rawName);
  6101. }
  6102. return _context3.abrupt("return", Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get("document_properties_page_size_unit_" + (this._isNonMetricLocale ? "inches" : "millimeters"), null, this._isNonMetricLocale ? "in" : "mm"), pageName, this.l10n.get("document_properties_page_size_orientation_" + (isPortrait ? "portrait" : "landscape"), null, isPortrait ? "portrait" : "landscape")]).then(function (_ref2) {
  6103. var _ref3 = _slicedToArray(_ref2, 4),
  6104. _ref3$ = _ref3[0],
  6105. width = _ref3$.width,
  6106. height = _ref3$.height,
  6107. unit = _ref3[1],
  6108. name = _ref3[2],
  6109. orientation = _ref3[3];
  6110. return _this3.l10n.get("document_properties_page_size_dimension_" + (name ? "name_" : "") + "string", {
  6111. width: width.toLocaleString(),
  6112. height: height.toLocaleString(),
  6113. unit: unit,
  6114. name: name,
  6115. orientation: orientation
  6116. }, "{{width}} × {{height}} {{unit}} (" + (name ? "{{name}}, " : "") + "{{orientation}})");
  6117. }));
  6118. case 11:
  6119. case "end":
  6120. return _context3.stop();
  6121. }
  6122. }
  6123. }, _callee3, this);
  6124. }));
  6125. function _parsePageSize(_x, _x2) {
  6126. return _parsePageSize2.apply(this, arguments);
  6127. }
  6128. return _parsePageSize;
  6129. }()
  6130. }, {
  6131. key: "_parseDate",
  6132. value: function () {
  6133. var _parseDate2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(inputDate) {
  6134. var dateObject;
  6135. return _regenerator["default"].wrap(function _callee4$(_context4) {
  6136. while (1) {
  6137. switch (_context4.prev = _context4.next) {
  6138. case 0:
  6139. dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  6140. if (dateObject) {
  6141. _context4.next = 3;
  6142. break;
  6143. }
  6144. return _context4.abrupt("return", undefined);
  6145. case 3:
  6146. return _context4.abrupt("return", this.l10n.get("document_properties_date_string", {
  6147. date: dateObject.toLocaleDateString(),
  6148. time: dateObject.toLocaleTimeString()
  6149. }, "{{date}}, {{time}}"));
  6150. case 4:
  6151. case "end":
  6152. return _context4.stop();
  6153. }
  6154. }
  6155. }, _callee4, this);
  6156. }));
  6157. function _parseDate(_x3) {
  6158. return _parseDate2.apply(this, arguments);
  6159. }
  6160. return _parseDate;
  6161. }()
  6162. }, {
  6163. key: "_parseLinearization",
  6164. value: function _parseLinearization(isLinearized) {
  6165. return this.l10n.get("document_properties_linearized_" + (isLinearized ? "yes" : "no"), null, isLinearized ? "Yes" : "No");
  6166. }
  6167. }]);
  6168. return PDFDocumentProperties;
  6169. }();
  6170. exports.PDFDocumentProperties = PDFDocumentProperties;
  6171. /***/ }),
  6172. /* 16 */
  6173. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6174. Object.defineProperty(exports, "__esModule", ({
  6175. value: true
  6176. }));
  6177. exports.PDFFindBar = void 0;
  6178. var _pdf_find_controller = __webpack_require__(17);
  6179. var _ui_utils = __webpack_require__(6);
  6180. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6181. 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); } }
  6182. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6183. var MATCHES_COUNT_LIMIT = 1000;
  6184. var PDFFindBar = /*#__PURE__*/function () {
  6185. function PDFFindBar(options, eventBus) {
  6186. var _this = this;
  6187. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  6188. _classCallCheck(this, PDFFindBar);
  6189. this.opened = false;
  6190. this.bar = options.bar || null;
  6191. this.toggleButton = options.toggleButton || null;
  6192. this.findField = options.findField || null;
  6193. this.highlightAll = options.highlightAllCheckbox || null;
  6194. this.caseSensitive = options.caseSensitiveCheckbox || null;
  6195. this.entireWord = options.entireWordCheckbox || null;
  6196. this.findMsg = options.findMsg || null;
  6197. this.findResultsCount = options.findResultsCount || null;
  6198. this.findPreviousButton = options.findPreviousButton || null;
  6199. this.findNextButton = options.findNextButton || null;
  6200. this.eventBus = eventBus;
  6201. this.l10n = l10n;
  6202. this.toggleButton.addEventListener("click", function () {
  6203. _this.toggle();
  6204. });
  6205. this.findField.addEventListener("input", function () {
  6206. _this.dispatchEvent("");
  6207. });
  6208. this.bar.addEventListener("keydown", function (e) {
  6209. switch (e.keyCode) {
  6210. case 13:
  6211. if (e.target === _this.findField) {
  6212. _this.dispatchEvent("again", e.shiftKey);
  6213. }
  6214. break;
  6215. case 27:
  6216. _this.close();
  6217. break;
  6218. }
  6219. });
  6220. this.findPreviousButton.addEventListener("click", function () {
  6221. _this.dispatchEvent("again", true);
  6222. });
  6223. this.findNextButton.addEventListener("click", function () {
  6224. _this.dispatchEvent("again", false);
  6225. });
  6226. this.highlightAll.addEventListener("click", function () {
  6227. _this.dispatchEvent("highlightallchange");
  6228. });
  6229. this.caseSensitive.addEventListener("click", function () {
  6230. _this.dispatchEvent("casesensitivitychange");
  6231. });
  6232. this.entireWord.addEventListener("click", function () {
  6233. _this.dispatchEvent("entirewordchange");
  6234. });
  6235. this.eventBus._on("resize", this._adjustWidth.bind(this));
  6236. }
  6237. _createClass(PDFFindBar, [{
  6238. key: "reset",
  6239. value: function reset() {
  6240. this.updateUIState();
  6241. }
  6242. }, {
  6243. key: "dispatchEvent",
  6244. value: function dispatchEvent(type, findPrev) {
  6245. this.eventBus.dispatch("find", {
  6246. source: this,
  6247. type: type,
  6248. query: this.findField.value,
  6249. phraseSearch: true,
  6250. caseSensitive: this.caseSensitive.checked,
  6251. entireWord: this.entireWord.checked,
  6252. highlightAll: this.highlightAll.checked,
  6253. findPrevious: findPrev
  6254. });
  6255. }
  6256. }, {
  6257. key: "updateUIState",
  6258. value: function updateUIState(state, previous, matchesCount) {
  6259. var _this2 = this;
  6260. var findMsg = "";
  6261. var status = "";
  6262. switch (state) {
  6263. case _pdf_find_controller.FindState.FOUND:
  6264. break;
  6265. case _pdf_find_controller.FindState.PENDING:
  6266. status = "pending";
  6267. break;
  6268. case _pdf_find_controller.FindState.NOT_FOUND:
  6269. findMsg = this.l10n.get("find_not_found", null, "Phrase not found");
  6270. status = "notFound";
  6271. break;
  6272. case _pdf_find_controller.FindState.WRAPPED:
  6273. if (previous) {
  6274. findMsg = this.l10n.get("find_reached_top", null, "Reached top of document, continued from bottom");
  6275. } else {
  6276. findMsg = this.l10n.get("find_reached_bottom", null, "Reached end of document, continued from top");
  6277. }
  6278. break;
  6279. }
  6280. this.findField.setAttribute("data-status", status);
  6281. Promise.resolve(findMsg).then(function (msg) {
  6282. _this2.findMsg.textContent = msg;
  6283. _this2._adjustWidth();
  6284. });
  6285. this.updateResultsCount(matchesCount);
  6286. }
  6287. }, {
  6288. key: "updateResultsCount",
  6289. value: function updateResultsCount() {
  6290. var _this3 = this;
  6291. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  6292. _ref$current = _ref.current,
  6293. current = _ref$current === void 0 ? 0 : _ref$current,
  6294. _ref$total = _ref.total,
  6295. total = _ref$total === void 0 ? 0 : _ref$total;
  6296. if (!this.findResultsCount) {
  6297. return;
  6298. }
  6299. var limit = MATCHES_COUNT_LIMIT;
  6300. var matchesCountMsg = "";
  6301. if (total > 0) {
  6302. if (total > limit) {
  6303. matchesCountMsg = this.l10n.get("find_match_count_limit", {
  6304. limit: limit
  6305. }, "More than {{limit}} match" + (limit !== 1 ? "es" : ""));
  6306. } else {
  6307. matchesCountMsg = this.l10n.get("find_match_count", {
  6308. current: current,
  6309. total: total
  6310. }, "{{current}} of {{total}} match" + (total !== 1 ? "es" : ""));
  6311. }
  6312. }
  6313. Promise.resolve(matchesCountMsg).then(function (msg) {
  6314. _this3.findResultsCount.textContent = msg;
  6315. _this3.findResultsCount.classList.toggle("hidden", !total);
  6316. _this3._adjustWidth();
  6317. });
  6318. }
  6319. }, {
  6320. key: "open",
  6321. value: function open() {
  6322. if (!this.opened) {
  6323. this.opened = true;
  6324. this.toggleButton.classList.add("toggled");
  6325. this.bar.classList.remove("hidden");
  6326. }
  6327. this.findField.select();
  6328. this.findField.focus();
  6329. this._adjustWidth();
  6330. }
  6331. }, {
  6332. key: "close",
  6333. value: function close() {
  6334. if (!this.opened) {
  6335. return;
  6336. }
  6337. this.opened = false;
  6338. this.toggleButton.classList.remove("toggled");
  6339. this.bar.classList.add("hidden");
  6340. this.eventBus.dispatch("findbarclose", {
  6341. source: this
  6342. });
  6343. }
  6344. }, {
  6345. key: "toggle",
  6346. value: function toggle() {
  6347. if (this.opened) {
  6348. this.close();
  6349. } else {
  6350. this.open();
  6351. }
  6352. }
  6353. }, {
  6354. key: "_adjustWidth",
  6355. value: function _adjustWidth() {
  6356. if (!this.opened) {
  6357. return;
  6358. }
  6359. this.bar.classList.remove("wrapContainers");
  6360. var findbarHeight = this.bar.clientHeight;
  6361. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  6362. if (findbarHeight > inputContainerHeight) {
  6363. this.bar.classList.add("wrapContainers");
  6364. }
  6365. }
  6366. }]);
  6367. return PDFFindBar;
  6368. }();
  6369. exports.PDFFindBar = PDFFindBar;
  6370. /***/ }),
  6371. /* 17 */
  6372. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6373. Object.defineProperty(exports, "__esModule", ({
  6374. value: true
  6375. }));
  6376. exports.PDFFindController = exports.FindState = void 0;
  6377. var _pdfjsLib = __webpack_require__(7);
  6378. var _pdf_find_utils = __webpack_require__(18);
  6379. var _ui_utils = __webpack_require__(6);
  6380. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6381. 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); } }
  6382. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6383. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  6384. 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."); }
  6385. 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; }
  6386. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  6387. 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; } } }; }
  6388. 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); }
  6389. 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; }
  6390. var FindState = {
  6391. FOUND: 0,
  6392. NOT_FOUND: 1,
  6393. WRAPPED: 2,
  6394. PENDING: 3
  6395. };
  6396. exports.FindState = FindState;
  6397. var FIND_TIMEOUT = 250;
  6398. var MATCH_SCROLL_OFFSET_TOP = -50;
  6399. var MATCH_SCROLL_OFFSET_LEFT = -400;
  6400. var CHARACTERS_TO_NORMALIZE = {
  6401. "\u2018": "'",
  6402. "\u2019": "'",
  6403. "\u201A": "'",
  6404. "\u201B": "'",
  6405. "\u201C": '"',
  6406. "\u201D": '"',
  6407. "\u201E": '"',
  6408. "\u201F": '"',
  6409. "\xBC": "1/4",
  6410. "\xBD": "1/2",
  6411. "\xBE": "3/4"
  6412. };
  6413. var normalizationRegex = null;
  6414. function normalize(text) {
  6415. if (!normalizationRegex) {
  6416. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  6417. normalizationRegex = new RegExp("[".concat(replace, "]"), "g");
  6418. }
  6419. var diffs = null;
  6420. var normalizedText = text.replace(normalizationRegex, function (ch, index) {
  6421. var normalizedCh = CHARACTERS_TO_NORMALIZE[ch],
  6422. diff = normalizedCh.length - ch.length;
  6423. if (diff !== 0) {
  6424. (diffs || (diffs = [])).push([index, diff]);
  6425. }
  6426. return normalizedCh;
  6427. });
  6428. return [normalizedText, diffs];
  6429. }
  6430. function getOriginalIndex(matchIndex) {
  6431. var diffs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6432. if (!diffs) {
  6433. return matchIndex;
  6434. }
  6435. var totalDiff = 0;
  6436. var _iterator = _createForOfIteratorHelper(diffs),
  6437. _step;
  6438. try {
  6439. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  6440. var _step$value = _slicedToArray(_step.value, 2),
  6441. index = _step$value[0],
  6442. diff = _step$value[1];
  6443. var currentIndex = index + totalDiff;
  6444. if (currentIndex >= matchIndex) {
  6445. break;
  6446. }
  6447. if (currentIndex + diff > matchIndex) {
  6448. totalDiff += matchIndex - currentIndex;
  6449. break;
  6450. }
  6451. totalDiff += diff;
  6452. }
  6453. } catch (err) {
  6454. _iterator.e(err);
  6455. } finally {
  6456. _iterator.f();
  6457. }
  6458. return matchIndex - totalDiff;
  6459. }
  6460. var PDFFindController = /*#__PURE__*/function () {
  6461. function PDFFindController(_ref) {
  6462. var linkService = _ref.linkService,
  6463. eventBus = _ref.eventBus;
  6464. _classCallCheck(this, PDFFindController);
  6465. this._linkService = linkService;
  6466. this._eventBus = eventBus;
  6467. this._reset();
  6468. eventBus._on("findbarclose", this._onFindBarClose.bind(this));
  6469. }
  6470. _createClass(PDFFindController, [{
  6471. key: "setDocument",
  6472. value: function setDocument(pdfDocument) {
  6473. if (this._pdfDocument) {
  6474. this._reset();
  6475. }
  6476. if (!pdfDocument) {
  6477. return;
  6478. }
  6479. this._pdfDocument = pdfDocument;
  6480. this._firstPageCapability.resolve();
  6481. }
  6482. }, {
  6483. key: "executeCommand",
  6484. value: function executeCommand(cmd, state) {
  6485. var _this = this;
  6486. if (!state) {
  6487. return;
  6488. }
  6489. var pdfDocument = this._pdfDocument;
  6490. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  6491. this._dirtyMatch = true;
  6492. }
  6493. this._state = state;
  6494. if (cmd !== "findhighlightallchange") {
  6495. this._updateUIState(FindState.PENDING);
  6496. }
  6497. this._firstPageCapability.promise.then(function () {
  6498. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  6499. return;
  6500. }
  6501. _this._extractText();
  6502. var findbarClosed = !_this._highlightMatches;
  6503. var pendingTimeout = !!_this._findTimeout;
  6504. if (_this._findTimeout) {
  6505. clearTimeout(_this._findTimeout);
  6506. _this._findTimeout = null;
  6507. }
  6508. if (cmd === "find") {
  6509. _this._findTimeout = setTimeout(function () {
  6510. _this._nextMatch();
  6511. _this._findTimeout = null;
  6512. }, FIND_TIMEOUT);
  6513. } else if (_this._dirtyMatch) {
  6514. _this._nextMatch();
  6515. } else if (cmd === "findagain") {
  6516. _this._nextMatch();
  6517. if (findbarClosed && _this._state.highlightAll) {
  6518. _this._updateAllPages();
  6519. }
  6520. } else if (cmd === "findhighlightallchange") {
  6521. if (pendingTimeout) {
  6522. _this._nextMatch();
  6523. } else {
  6524. _this._highlightMatches = true;
  6525. }
  6526. _this._updateAllPages();
  6527. } else {
  6528. _this._nextMatch();
  6529. }
  6530. });
  6531. }
  6532. }, {
  6533. key: "scrollMatchIntoView",
  6534. value: function scrollMatchIntoView(_ref2) {
  6535. var _ref2$element = _ref2.element,
  6536. element = _ref2$element === void 0 ? null : _ref2$element,
  6537. _ref2$pageIndex = _ref2.pageIndex,
  6538. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  6539. _ref2$matchIndex = _ref2.matchIndex,
  6540. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  6541. if (!this._scrollMatches || !element) {
  6542. return;
  6543. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  6544. return;
  6545. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  6546. return;
  6547. }
  6548. this._scrollMatches = false;
  6549. var spot = {
  6550. top: MATCH_SCROLL_OFFSET_TOP,
  6551. left: MATCH_SCROLL_OFFSET_LEFT
  6552. };
  6553. (0, _ui_utils.scrollIntoView)(element, spot, true);
  6554. }
  6555. }, {
  6556. key: "_reset",
  6557. value: function _reset() {
  6558. this._highlightMatches = false;
  6559. this._scrollMatches = false;
  6560. this._pdfDocument = null;
  6561. this._pageMatches = [];
  6562. this._pageMatchesLength = [];
  6563. this._state = null;
  6564. this._selected = {
  6565. pageIdx: -1,
  6566. matchIdx: -1
  6567. };
  6568. this._offset = {
  6569. pageIdx: null,
  6570. matchIdx: null,
  6571. wrapped: false
  6572. };
  6573. this._extractTextPromises = [];
  6574. this._pageContents = [];
  6575. this._pageDiffs = [];
  6576. this._matchesCountTotal = 0;
  6577. this._pagesToSearch = null;
  6578. this._pendingFindMatches = Object.create(null);
  6579. this._resumePageIdx = null;
  6580. this._dirtyMatch = false;
  6581. clearTimeout(this._findTimeout);
  6582. this._findTimeout = null;
  6583. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  6584. }
  6585. }, {
  6586. key: "_shouldDirtyMatch",
  6587. value: function _shouldDirtyMatch(cmd, state) {
  6588. if (state.query !== this._state.query) {
  6589. return true;
  6590. }
  6591. switch (cmd) {
  6592. case "findagain":
  6593. var pageNumber = this._selected.pageIdx + 1;
  6594. var linkService = this._linkService;
  6595. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  6596. return true;
  6597. }
  6598. return false;
  6599. case "findhighlightallchange":
  6600. return false;
  6601. }
  6602. return true;
  6603. }
  6604. }, {
  6605. key: "_prepareMatches",
  6606. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  6607. function isSubTerm(currentIndex) {
  6608. var currentElem = matchesWithLength[currentIndex];
  6609. var nextElem = matchesWithLength[currentIndex + 1];
  6610. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  6611. currentElem.skipped = true;
  6612. return true;
  6613. }
  6614. for (var i = currentIndex - 1; i >= 0; i--) {
  6615. var prevElem = matchesWithLength[i];
  6616. if (prevElem.skipped) {
  6617. continue;
  6618. }
  6619. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  6620. break;
  6621. }
  6622. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  6623. currentElem.skipped = true;
  6624. return true;
  6625. }
  6626. }
  6627. return false;
  6628. }
  6629. matchesWithLength.sort(function (a, b) {
  6630. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  6631. });
  6632. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  6633. if (isSubTerm(i)) {
  6634. continue;
  6635. }
  6636. matches.push(matchesWithLength[i].match);
  6637. matchesLength.push(matchesWithLength[i].matchLength);
  6638. }
  6639. }
  6640. }, {
  6641. key: "_isEntireWord",
  6642. value: function _isEntireWord(content, startIdx, length) {
  6643. if (startIdx > 0) {
  6644. var first = content.charCodeAt(startIdx);
  6645. var limit = content.charCodeAt(startIdx - 1);
  6646. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  6647. return false;
  6648. }
  6649. }
  6650. var endIdx = startIdx + length - 1;
  6651. if (endIdx < content.length - 1) {
  6652. var last = content.charCodeAt(endIdx);
  6653. var _limit = content.charCodeAt(endIdx + 1);
  6654. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  6655. return false;
  6656. }
  6657. }
  6658. return true;
  6659. }
  6660. }, {
  6661. key: "_calculatePhraseMatch",
  6662. value: function _calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord) {
  6663. var matches = [],
  6664. matchesLength = [];
  6665. var queryLen = query.length;
  6666. var matchIdx = -queryLen;
  6667. while (true) {
  6668. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  6669. if (matchIdx === -1) {
  6670. break;
  6671. }
  6672. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  6673. continue;
  6674. }
  6675. var originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs),
  6676. matchEnd = matchIdx + queryLen - 1,
  6677. originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1;
  6678. matches.push(originalMatchIdx);
  6679. matchesLength.push(originalQueryLen);
  6680. }
  6681. this._pageMatches[pageIndex] = matches;
  6682. this._pageMatchesLength[pageIndex] = matchesLength;
  6683. }
  6684. }, {
  6685. key: "_calculateWordMatch",
  6686. value: function _calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord) {
  6687. var matchesWithLength = [];
  6688. var queryArray = query.match(/\S+/g);
  6689. for (var i = 0, len = queryArray.length; i < len; i++) {
  6690. var subquery = queryArray[i];
  6691. var subqueryLen = subquery.length;
  6692. var matchIdx = -subqueryLen;
  6693. while (true) {
  6694. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  6695. if (matchIdx === -1) {
  6696. break;
  6697. }
  6698. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  6699. continue;
  6700. }
  6701. var originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs),
  6702. matchEnd = matchIdx + subqueryLen - 1,
  6703. originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1;
  6704. matchesWithLength.push({
  6705. match: originalMatchIdx,
  6706. matchLength: originalQueryLen,
  6707. skipped: false
  6708. });
  6709. }
  6710. }
  6711. this._pageMatchesLength[pageIndex] = [];
  6712. this._pageMatches[pageIndex] = [];
  6713. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  6714. }
  6715. }, {
  6716. key: "_calculateMatch",
  6717. value: function _calculateMatch(pageIndex) {
  6718. var pageContent = this._pageContents[pageIndex];
  6719. var pageDiffs = this._pageDiffs[pageIndex];
  6720. var query = this._query;
  6721. var _this$_state = this._state,
  6722. caseSensitive = _this$_state.caseSensitive,
  6723. entireWord = _this$_state.entireWord,
  6724. phraseSearch = _this$_state.phraseSearch;
  6725. if (query.length === 0) {
  6726. return;
  6727. }
  6728. if (!caseSensitive) {
  6729. pageContent = pageContent.toLowerCase();
  6730. query = query.toLowerCase();
  6731. }
  6732. if (phraseSearch) {
  6733. this._calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord);
  6734. } else {
  6735. this._calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord);
  6736. }
  6737. if (this._state.highlightAll) {
  6738. this._updatePage(pageIndex);
  6739. }
  6740. if (this._resumePageIdx === pageIndex) {
  6741. this._resumePageIdx = null;
  6742. this._nextPageMatch();
  6743. }
  6744. var pageMatchesCount = this._pageMatches[pageIndex].length;
  6745. if (pageMatchesCount > 0) {
  6746. this._matchesCountTotal += pageMatchesCount;
  6747. this._updateUIResultsCount();
  6748. }
  6749. }
  6750. }, {
  6751. key: "_extractText",
  6752. value: function _extractText() {
  6753. var _this2 = this;
  6754. if (this._extractTextPromises.length > 0) {
  6755. return;
  6756. }
  6757. var promise = Promise.resolve();
  6758. var _loop = function _loop(i, ii) {
  6759. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  6760. _this2._extractTextPromises[i] = extractTextCapability.promise;
  6761. promise = promise.then(function () {
  6762. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  6763. return pdfPage.getTextContent({
  6764. normalizeWhitespace: true
  6765. });
  6766. }).then(function (textContent) {
  6767. var textItems = textContent.items;
  6768. var strBuf = [];
  6769. for (var j = 0, jj = textItems.length; j < jj; j++) {
  6770. strBuf.push(textItems[j].str);
  6771. }
  6772. var _normalize = normalize(strBuf.join(""));
  6773. var _normalize2 = _slicedToArray(_normalize, 2);
  6774. _this2._pageContents[i] = _normalize2[0];
  6775. _this2._pageDiffs[i] = _normalize2[1];
  6776. extractTextCapability.resolve(i);
  6777. }, function (reason) {
  6778. console.error("Unable to get text content for page ".concat(i + 1), reason);
  6779. _this2._pageContents[i] = "";
  6780. _this2._pageDiffs[i] = null;
  6781. extractTextCapability.resolve(i);
  6782. });
  6783. });
  6784. };
  6785. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  6786. _loop(i, ii);
  6787. }
  6788. }
  6789. }, {
  6790. key: "_updatePage",
  6791. value: function _updatePage(index) {
  6792. if (this._scrollMatches && this._selected.pageIdx === index) {
  6793. this._linkService.page = index + 1;
  6794. }
  6795. this._eventBus.dispatch("updatetextlayermatches", {
  6796. source: this,
  6797. pageIndex: index
  6798. });
  6799. }
  6800. }, {
  6801. key: "_updateAllPages",
  6802. value: function _updateAllPages() {
  6803. this._eventBus.dispatch("updatetextlayermatches", {
  6804. source: this,
  6805. pageIndex: -1
  6806. });
  6807. }
  6808. }, {
  6809. key: "_nextMatch",
  6810. value: function _nextMatch() {
  6811. var _this3 = this;
  6812. var previous = this._state.findPrevious;
  6813. var currentPageIndex = this._linkService.page - 1;
  6814. var numPages = this._linkService.pagesCount;
  6815. this._highlightMatches = true;
  6816. if (this._dirtyMatch) {
  6817. this._dirtyMatch = false;
  6818. this._selected.pageIdx = this._selected.matchIdx = -1;
  6819. this._offset.pageIdx = currentPageIndex;
  6820. this._offset.matchIdx = null;
  6821. this._offset.wrapped = false;
  6822. this._resumePageIdx = null;
  6823. this._pageMatches.length = 0;
  6824. this._pageMatchesLength.length = 0;
  6825. this._matchesCountTotal = 0;
  6826. this._updateAllPages();
  6827. for (var i = 0; i < numPages; i++) {
  6828. if (this._pendingFindMatches[i] === true) {
  6829. continue;
  6830. }
  6831. this._pendingFindMatches[i] = true;
  6832. this._extractTextPromises[i].then(function (pageIdx) {
  6833. delete _this3._pendingFindMatches[pageIdx];
  6834. _this3._calculateMatch(pageIdx);
  6835. });
  6836. }
  6837. }
  6838. if (this._query === "") {
  6839. this._updateUIState(FindState.FOUND);
  6840. return;
  6841. }
  6842. if (this._resumePageIdx) {
  6843. return;
  6844. }
  6845. var offset = this._offset;
  6846. this._pagesToSearch = numPages;
  6847. if (offset.matchIdx !== null) {
  6848. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  6849. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  6850. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  6851. this._updateMatch(true);
  6852. return;
  6853. }
  6854. this._advanceOffsetPage(previous);
  6855. }
  6856. this._nextPageMatch();
  6857. }
  6858. }, {
  6859. key: "_matchesReady",
  6860. value: function _matchesReady(matches) {
  6861. var offset = this._offset;
  6862. var numMatches = matches.length;
  6863. var previous = this._state.findPrevious;
  6864. if (numMatches) {
  6865. offset.matchIdx = previous ? numMatches - 1 : 0;
  6866. this._updateMatch(true);
  6867. return true;
  6868. }
  6869. this._advanceOffsetPage(previous);
  6870. if (offset.wrapped) {
  6871. offset.matchIdx = null;
  6872. if (this._pagesToSearch < 0) {
  6873. this._updateMatch(false);
  6874. return true;
  6875. }
  6876. }
  6877. return false;
  6878. }
  6879. }, {
  6880. key: "_nextPageMatch",
  6881. value: function _nextPageMatch() {
  6882. if (this._resumePageIdx !== null) {
  6883. console.error("There can only be one pending page.");
  6884. }
  6885. var matches = null;
  6886. do {
  6887. var pageIdx = this._offset.pageIdx;
  6888. matches = this._pageMatches[pageIdx];
  6889. if (!matches) {
  6890. this._resumePageIdx = pageIdx;
  6891. break;
  6892. }
  6893. } while (!this._matchesReady(matches));
  6894. }
  6895. }, {
  6896. key: "_advanceOffsetPage",
  6897. value: function _advanceOffsetPage(previous) {
  6898. var offset = this._offset;
  6899. var numPages = this._linkService.pagesCount;
  6900. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  6901. offset.matchIdx = null;
  6902. this._pagesToSearch--;
  6903. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  6904. offset.pageIdx = previous ? numPages - 1 : 0;
  6905. offset.wrapped = true;
  6906. }
  6907. }
  6908. }, {
  6909. key: "_updateMatch",
  6910. value: function _updateMatch() {
  6911. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6912. var state = FindState.NOT_FOUND;
  6913. var wrapped = this._offset.wrapped;
  6914. this._offset.wrapped = false;
  6915. if (found) {
  6916. var previousPage = this._selected.pageIdx;
  6917. this._selected.pageIdx = this._offset.pageIdx;
  6918. this._selected.matchIdx = this._offset.matchIdx;
  6919. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  6920. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  6921. this._updatePage(previousPage);
  6922. }
  6923. }
  6924. this._updateUIState(state, this._state.findPrevious);
  6925. if (this._selected.pageIdx !== -1) {
  6926. this._scrollMatches = true;
  6927. this._updatePage(this._selected.pageIdx);
  6928. }
  6929. }
  6930. }, {
  6931. key: "_onFindBarClose",
  6932. value: function _onFindBarClose(evt) {
  6933. var _this4 = this;
  6934. var pdfDocument = this._pdfDocument;
  6935. this._firstPageCapability.promise.then(function () {
  6936. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  6937. return;
  6938. }
  6939. if (_this4._findTimeout) {
  6940. clearTimeout(_this4._findTimeout);
  6941. _this4._findTimeout = null;
  6942. }
  6943. if (_this4._resumePageIdx) {
  6944. _this4._resumePageIdx = null;
  6945. _this4._dirtyMatch = true;
  6946. }
  6947. _this4._updateUIState(FindState.FOUND);
  6948. _this4._highlightMatches = false;
  6949. _this4._updateAllPages();
  6950. });
  6951. }
  6952. }, {
  6953. key: "_requestMatchesCount",
  6954. value: function _requestMatchesCount() {
  6955. var _this$_selected = this._selected,
  6956. pageIdx = _this$_selected.pageIdx,
  6957. matchIdx = _this$_selected.matchIdx;
  6958. var current = 0,
  6959. total = this._matchesCountTotal;
  6960. if (matchIdx !== -1) {
  6961. for (var i = 0; i < pageIdx; i++) {
  6962. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  6963. }
  6964. current += matchIdx + 1;
  6965. }
  6966. if (current < 1 || current > total) {
  6967. current = total = 0;
  6968. }
  6969. return {
  6970. current: current,
  6971. total: total
  6972. };
  6973. }
  6974. }, {
  6975. key: "_updateUIResultsCount",
  6976. value: function _updateUIResultsCount() {
  6977. this._eventBus.dispatch("updatefindmatchescount", {
  6978. source: this,
  6979. matchesCount: this._requestMatchesCount()
  6980. });
  6981. }
  6982. }, {
  6983. key: "_updateUIState",
  6984. value: function _updateUIState(state, previous) {
  6985. this._eventBus.dispatch("updatefindcontrolstate", {
  6986. source: this,
  6987. state: state,
  6988. previous: previous,
  6989. matchesCount: this._requestMatchesCount(),
  6990. rawQuery: this._state ? this._state.query : null
  6991. });
  6992. }
  6993. }, {
  6994. key: "highlightMatches",
  6995. get: function get() {
  6996. return this._highlightMatches;
  6997. }
  6998. }, {
  6999. key: "pageMatches",
  7000. get: function get() {
  7001. return this._pageMatches;
  7002. }
  7003. }, {
  7004. key: "pageMatchesLength",
  7005. get: function get() {
  7006. return this._pageMatchesLength;
  7007. }
  7008. }, {
  7009. key: "selected",
  7010. get: function get() {
  7011. return this._selected;
  7012. }
  7013. }, {
  7014. key: "state",
  7015. get: function get() {
  7016. return this._state;
  7017. }
  7018. }, {
  7019. key: "_query",
  7020. get: function get() {
  7021. if (this._state.query !== this._rawQuery) {
  7022. this._rawQuery = this._state.query;
  7023. var _normalize3 = normalize(this._state.query);
  7024. var _normalize4 = _slicedToArray(_normalize3, 1);
  7025. this._normalizedQuery = _normalize4[0];
  7026. }
  7027. return this._normalizedQuery;
  7028. }
  7029. }]);
  7030. return PDFFindController;
  7031. }();
  7032. exports.PDFFindController = PDFFindController;
  7033. /***/ }),
  7034. /* 18 */
  7035. /***/ ((__unused_webpack_module, exports) => {
  7036. Object.defineProperty(exports, "__esModule", ({
  7037. value: true
  7038. }));
  7039. exports.getCharacterType = getCharacterType;
  7040. exports.CharacterType = void 0;
  7041. var CharacterType = {
  7042. SPACE: 0,
  7043. ALPHA_LETTER: 1,
  7044. PUNCT: 2,
  7045. HAN_LETTER: 3,
  7046. KATAKANA_LETTER: 4,
  7047. HIRAGANA_LETTER: 5,
  7048. HALFWIDTH_KATAKANA_LETTER: 6,
  7049. THAI_LETTER: 7
  7050. };
  7051. exports.CharacterType = CharacterType;
  7052. function isAlphabeticalScript(charCode) {
  7053. return charCode < 0x2e80;
  7054. }
  7055. function isAscii(charCode) {
  7056. return (charCode & 0xff80) === 0;
  7057. }
  7058. function isAsciiAlpha(charCode) {
  7059. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  7060. }
  7061. function isAsciiDigit(charCode) {
  7062. return charCode >= 0x30 && charCode <= 0x39;
  7063. }
  7064. function isAsciiSpace(charCode) {
  7065. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  7066. }
  7067. function isHan(charCode) {
  7068. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  7069. }
  7070. function isKatakana(charCode) {
  7071. return charCode >= 0x30a0 && charCode <= 0x30ff;
  7072. }
  7073. function isHiragana(charCode) {
  7074. return charCode >= 0x3040 && charCode <= 0x309f;
  7075. }
  7076. function isHalfwidthKatakana(charCode) {
  7077. return charCode >= 0xff60 && charCode <= 0xff9f;
  7078. }
  7079. function isThai(charCode) {
  7080. return (charCode & 0xff80) === 0x0e00;
  7081. }
  7082. function getCharacterType(charCode) {
  7083. if (isAlphabeticalScript(charCode)) {
  7084. if (isAscii(charCode)) {
  7085. if (isAsciiSpace(charCode)) {
  7086. return CharacterType.SPACE;
  7087. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  7088. return CharacterType.ALPHA_LETTER;
  7089. }
  7090. return CharacterType.PUNCT;
  7091. } else if (isThai(charCode)) {
  7092. return CharacterType.THAI_LETTER;
  7093. } else if (charCode === 0xa0) {
  7094. return CharacterType.SPACE;
  7095. }
  7096. return CharacterType.ALPHA_LETTER;
  7097. }
  7098. if (isHan(charCode)) {
  7099. return CharacterType.HAN_LETTER;
  7100. } else if (isKatakana(charCode)) {
  7101. return CharacterType.KATAKANA_LETTER;
  7102. } else if (isHiragana(charCode)) {
  7103. return CharacterType.HIRAGANA_LETTER;
  7104. } else if (isHalfwidthKatakana(charCode)) {
  7105. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  7106. }
  7107. return CharacterType.ALPHA_LETTER;
  7108. }
  7109. /***/ }),
  7110. /* 19 */
  7111. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7112. Object.defineProperty(exports, "__esModule", ({
  7113. value: true
  7114. }));
  7115. exports.isDestArraysEqual = isDestArraysEqual;
  7116. exports.isDestHashesEqual = isDestHashesEqual;
  7117. exports.PDFHistory = void 0;
  7118. var _ui_utils = __webpack_require__(6);
  7119. 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); }
  7120. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  7121. 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."); }
  7122. 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); }
  7123. 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; }
  7124. 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; }
  7125. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  7126. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7127. 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); } }
  7128. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7129. var HASH_CHANGE_TIMEOUT = 1000;
  7130. var POSITION_UPDATED_THRESHOLD = 50;
  7131. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  7132. function getCurrentHash() {
  7133. return document.location.hash;
  7134. }
  7135. var PDFHistory = /*#__PURE__*/function () {
  7136. function PDFHistory(_ref) {
  7137. var _this = this;
  7138. var linkService = _ref.linkService,
  7139. eventBus = _ref.eventBus;
  7140. _classCallCheck(this, PDFHistory);
  7141. this.linkService = linkService;
  7142. this.eventBus = eventBus;
  7143. this._initialized = false;
  7144. this._fingerprint = "";
  7145. this.reset();
  7146. this._boundEvents = null;
  7147. this._isViewerInPresentationMode = false;
  7148. this.eventBus._on("presentationmodechanged", function (evt) {
  7149. _this._isViewerInPresentationMode = evt.state !== _ui_utils.PresentationModeState.NORMAL;
  7150. });
  7151. this.eventBus._on("pagesinit", function () {
  7152. _this._isPagesLoaded = false;
  7153. _this.eventBus._on("pagesloaded", function (evt) {
  7154. _this._isPagesLoaded = !!evt.pagesCount;
  7155. }, {
  7156. once: true
  7157. });
  7158. });
  7159. }
  7160. _createClass(PDFHistory, [{
  7161. key: "initialize",
  7162. value: function initialize(_ref2) {
  7163. var fingerprint = _ref2.fingerprint,
  7164. _ref2$resetHistory = _ref2.resetHistory,
  7165. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  7166. _ref2$updateUrl = _ref2.updateUrl,
  7167. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  7168. if (!fingerprint || typeof fingerprint !== "string") {
  7169. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  7170. return;
  7171. }
  7172. if (this._initialized) {
  7173. this.reset();
  7174. }
  7175. var reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  7176. this._fingerprint = fingerprint;
  7177. this._updateUrl = updateUrl === true;
  7178. this._initialized = true;
  7179. this._bindEvents();
  7180. var state = window.history.state;
  7181. this._popStateInProgress = false;
  7182. this._blockHashChange = 0;
  7183. this._currentHash = getCurrentHash();
  7184. this._numPositionUpdates = 0;
  7185. this._uid = this._maxUid = 0;
  7186. this._destination = null;
  7187. this._position = null;
  7188. if (!this._isValidState(state, true) || resetHistory) {
  7189. var _this$_parseCurrentHa = this._parseCurrentHash(true),
  7190. hash = _this$_parseCurrentHa.hash,
  7191. page = _this$_parseCurrentHa.page,
  7192. rotation = _this$_parseCurrentHa.rotation;
  7193. if (!hash || reInitialized || resetHistory) {
  7194. this._pushOrReplaceState(null, true);
  7195. return;
  7196. }
  7197. this._pushOrReplaceState({
  7198. hash: hash,
  7199. page: page,
  7200. rotation: rotation
  7201. }, true);
  7202. return;
  7203. }
  7204. var destination = state.destination;
  7205. this._updateInternalState(destination, state.uid, true);
  7206. if (destination.rotation !== undefined) {
  7207. this._initialRotation = destination.rotation;
  7208. }
  7209. if (destination.dest) {
  7210. this._initialBookmark = JSON.stringify(destination.dest);
  7211. this._destination.page = null;
  7212. } else if (destination.hash) {
  7213. this._initialBookmark = destination.hash;
  7214. } else if (destination.page) {
  7215. this._initialBookmark = "page=".concat(destination.page);
  7216. }
  7217. }
  7218. }, {
  7219. key: "reset",
  7220. value: function reset() {
  7221. if (this._initialized) {
  7222. this._pageHide();
  7223. this._initialized = false;
  7224. this._unbindEvents();
  7225. }
  7226. if (this._updateViewareaTimeout) {
  7227. clearTimeout(this._updateViewareaTimeout);
  7228. this._updateViewareaTimeout = null;
  7229. }
  7230. this._initialBookmark = null;
  7231. this._initialRotation = null;
  7232. }
  7233. }, {
  7234. key: "push",
  7235. value: function push(_ref3) {
  7236. var _this2 = this;
  7237. var _ref3$namedDest = _ref3.namedDest,
  7238. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  7239. explicitDest = _ref3.explicitDest,
  7240. pageNumber = _ref3.pageNumber;
  7241. if (!this._initialized) {
  7242. return;
  7243. }
  7244. if (namedDest && typeof namedDest !== "string") {
  7245. console.error("PDFHistory.push: " + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  7246. return;
  7247. } else if (!Array.isArray(explicitDest)) {
  7248. console.error("PDFHistory.push: " + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  7249. return;
  7250. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  7251. if (pageNumber !== null || this._destination) {
  7252. console.error("PDFHistory.push: " + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  7253. return;
  7254. }
  7255. }
  7256. var hash = namedDest || JSON.stringify(explicitDest);
  7257. if (!hash) {
  7258. return;
  7259. }
  7260. var forceReplace = false;
  7261. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  7262. if (this._destination.page) {
  7263. return;
  7264. }
  7265. forceReplace = true;
  7266. }
  7267. if (this._popStateInProgress && !forceReplace) {
  7268. return;
  7269. }
  7270. this._pushOrReplaceState({
  7271. dest: explicitDest,
  7272. hash: hash,
  7273. page: pageNumber,
  7274. rotation: this.linkService.rotation
  7275. }, forceReplace);
  7276. if (!this._popStateInProgress) {
  7277. this._popStateInProgress = true;
  7278. Promise.resolve().then(function () {
  7279. _this2._popStateInProgress = false;
  7280. });
  7281. }
  7282. }
  7283. }, {
  7284. key: "pushPage",
  7285. value: function pushPage(pageNumber) {
  7286. var _this$_destination,
  7287. _this3 = this;
  7288. if (!this._initialized) {
  7289. return;
  7290. }
  7291. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  7292. console.error("PDFHistory.pushPage: \"".concat(pageNumber, "\" is not a valid page number."));
  7293. return;
  7294. }
  7295. if (((_this$_destination = this._destination) === null || _this$_destination === void 0 ? void 0 : _this$_destination.page) === pageNumber) {
  7296. return;
  7297. }
  7298. if (this._popStateInProgress) {
  7299. return;
  7300. }
  7301. this._pushOrReplaceState({
  7302. hash: "page=".concat(pageNumber),
  7303. page: pageNumber,
  7304. rotation: this.linkService.rotation
  7305. });
  7306. if (!this._popStateInProgress) {
  7307. this._popStateInProgress = true;
  7308. Promise.resolve().then(function () {
  7309. _this3._popStateInProgress = false;
  7310. });
  7311. }
  7312. }
  7313. }, {
  7314. key: "pushCurrentPosition",
  7315. value: function pushCurrentPosition() {
  7316. if (!this._initialized || this._popStateInProgress) {
  7317. return;
  7318. }
  7319. this._tryPushCurrentPosition();
  7320. }
  7321. }, {
  7322. key: "back",
  7323. value: function back() {
  7324. if (!this._initialized || this._popStateInProgress) {
  7325. return;
  7326. }
  7327. var state = window.history.state;
  7328. if (this._isValidState(state) && state.uid > 0) {
  7329. window.history.back();
  7330. }
  7331. }
  7332. }, {
  7333. key: "forward",
  7334. value: function forward() {
  7335. if (!this._initialized || this._popStateInProgress) {
  7336. return;
  7337. }
  7338. var state = window.history.state;
  7339. if (this._isValidState(state) && state.uid < this._maxUid) {
  7340. window.history.forward();
  7341. }
  7342. }
  7343. }, {
  7344. key: "_pushOrReplaceState",
  7345. value: function _pushOrReplaceState(destination) {
  7346. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7347. var shouldReplace = forceReplace || !this._destination;
  7348. var newState = {
  7349. fingerprint: this._fingerprint,
  7350. uid: shouldReplace ? this._uid : this._uid + 1,
  7351. destination: destination
  7352. };
  7353. this._updateInternalState(destination, newState.uid);
  7354. var newUrl;
  7355. if (this._updateUrl && destination !== null && destination !== void 0 && destination.hash) {
  7356. var baseUrl = document.location.href.split("#")[0];
  7357. if (!baseUrl.startsWith("file://")) {
  7358. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  7359. }
  7360. }
  7361. if (shouldReplace) {
  7362. window.history.replaceState(newState, "", newUrl);
  7363. } else {
  7364. window.history.pushState(newState, "", newUrl);
  7365. }
  7366. }
  7367. }, {
  7368. key: "_tryPushCurrentPosition",
  7369. value: function _tryPushCurrentPosition() {
  7370. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7371. if (!this._position) {
  7372. return;
  7373. }
  7374. var position = this._position;
  7375. if (temporary) {
  7376. position = Object.assign(Object.create(null), this._position);
  7377. position.temporary = true;
  7378. }
  7379. if (!this._destination) {
  7380. this._pushOrReplaceState(position);
  7381. return;
  7382. }
  7383. if (this._destination.temporary) {
  7384. this._pushOrReplaceState(position, true);
  7385. return;
  7386. }
  7387. if (this._destination.hash === position.hash) {
  7388. return;
  7389. }
  7390. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  7391. return;
  7392. }
  7393. var forceReplace = false;
  7394. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  7395. if (this._destination.dest || !this._destination.first) {
  7396. return;
  7397. }
  7398. forceReplace = true;
  7399. }
  7400. this._pushOrReplaceState(position, forceReplace);
  7401. }
  7402. }, {
  7403. key: "_isValidState",
  7404. value: function _isValidState(state) {
  7405. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7406. if (!state) {
  7407. return false;
  7408. }
  7409. if (state.fingerprint !== this._fingerprint) {
  7410. if (checkReload) {
  7411. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  7412. return false;
  7413. }
  7414. var _performance$getEntri = performance.getEntriesByType("navigation"),
  7415. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  7416. perfEntry = _performance$getEntri2[0];
  7417. if ((perfEntry === null || perfEntry === void 0 ? void 0 : perfEntry.type) !== "reload") {
  7418. return false;
  7419. }
  7420. } else {
  7421. return false;
  7422. }
  7423. }
  7424. if (!Number.isInteger(state.uid) || state.uid < 0) {
  7425. return false;
  7426. }
  7427. if (state.destination === null || _typeof(state.destination) !== "object") {
  7428. return false;
  7429. }
  7430. return true;
  7431. }
  7432. }, {
  7433. key: "_updateInternalState",
  7434. value: function _updateInternalState(destination, uid) {
  7435. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7436. if (this._updateViewareaTimeout) {
  7437. clearTimeout(this._updateViewareaTimeout);
  7438. this._updateViewareaTimeout = null;
  7439. }
  7440. if (removeTemporary && destination !== null && destination !== void 0 && destination.temporary) {
  7441. delete destination.temporary;
  7442. }
  7443. this._destination = destination;
  7444. this._uid = uid;
  7445. this._maxUid = Math.max(this._maxUid, uid);
  7446. this._numPositionUpdates = 0;
  7447. }
  7448. }, {
  7449. key: "_parseCurrentHash",
  7450. value: function _parseCurrentHash() {
  7451. var checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7452. var hash = unescape(getCurrentHash()).substring(1);
  7453. var params = (0, _ui_utils.parseQueryString)(hash);
  7454. var nameddest = params.nameddest || "";
  7455. var page = params.page | 0;
  7456. if (!(Number.isInteger(page) && page > 0 && page <= this.linkService.pagesCount) || checkNameddest && nameddest.length > 0) {
  7457. page = null;
  7458. }
  7459. return {
  7460. hash: hash,
  7461. page: page,
  7462. rotation: this.linkService.rotation
  7463. };
  7464. }
  7465. }, {
  7466. key: "_updateViewarea",
  7467. value: function _updateViewarea(_ref4) {
  7468. var _this4 = this;
  7469. var location = _ref4.location;
  7470. if (this._updateViewareaTimeout) {
  7471. clearTimeout(this._updateViewareaTimeout);
  7472. this._updateViewareaTimeout = null;
  7473. }
  7474. this._position = {
  7475. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  7476. page: this.linkService.page,
  7477. first: location.pageNumber,
  7478. rotation: location.rotation
  7479. };
  7480. if (this._popStateInProgress) {
  7481. return;
  7482. }
  7483. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  7484. this._numPositionUpdates++;
  7485. }
  7486. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  7487. this._updateViewareaTimeout = setTimeout(function () {
  7488. if (!_this4._popStateInProgress) {
  7489. _this4._tryPushCurrentPosition(true);
  7490. }
  7491. _this4._updateViewareaTimeout = null;
  7492. }, UPDATE_VIEWAREA_TIMEOUT);
  7493. }
  7494. }
  7495. }, {
  7496. key: "_popState",
  7497. value: function _popState(_ref5) {
  7498. var _this5 = this;
  7499. var state = _ref5.state;
  7500. var newHash = getCurrentHash(),
  7501. hashChanged = this._currentHash !== newHash;
  7502. this._currentHash = newHash;
  7503. if (!state) {
  7504. this._uid++;
  7505. var _this$_parseCurrentHa2 = this._parseCurrentHash(),
  7506. hash = _this$_parseCurrentHa2.hash,
  7507. page = _this$_parseCurrentHa2.page,
  7508. rotation = _this$_parseCurrentHa2.rotation;
  7509. this._pushOrReplaceState({
  7510. hash: hash,
  7511. page: page,
  7512. rotation: rotation
  7513. }, true);
  7514. return;
  7515. }
  7516. if (!this._isValidState(state)) {
  7517. return;
  7518. }
  7519. this._popStateInProgress = true;
  7520. if (hashChanged) {
  7521. this._blockHashChange++;
  7522. (0, _ui_utils.waitOnEventOrTimeout)({
  7523. target: window,
  7524. name: "hashchange",
  7525. delay: HASH_CHANGE_TIMEOUT
  7526. }).then(function () {
  7527. _this5._blockHashChange--;
  7528. });
  7529. }
  7530. var destination = state.destination;
  7531. this._updateInternalState(destination, state.uid, true);
  7532. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  7533. this.linkService.rotation = destination.rotation;
  7534. }
  7535. if (destination.dest) {
  7536. this.linkService.goToDestination(destination.dest);
  7537. } else if (destination.hash) {
  7538. this.linkService.setHash(destination.hash);
  7539. } else if (destination.page) {
  7540. this.linkService.page = destination.page;
  7541. }
  7542. Promise.resolve().then(function () {
  7543. _this5._popStateInProgress = false;
  7544. });
  7545. }
  7546. }, {
  7547. key: "_pageHide",
  7548. value: function _pageHide() {
  7549. if (!this._destination || this._destination.temporary) {
  7550. this._tryPushCurrentPosition();
  7551. }
  7552. }
  7553. }, {
  7554. key: "_bindEvents",
  7555. value: function _bindEvents() {
  7556. if (this._boundEvents) {
  7557. return;
  7558. }
  7559. this._boundEvents = {
  7560. updateViewarea: this._updateViewarea.bind(this),
  7561. popState: this._popState.bind(this),
  7562. pageHide: this._pageHide.bind(this)
  7563. };
  7564. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  7565. window.addEventListener("popstate", this._boundEvents.popState);
  7566. window.addEventListener("pagehide", this._boundEvents.pageHide);
  7567. }
  7568. }, {
  7569. key: "_unbindEvents",
  7570. value: function _unbindEvents() {
  7571. if (!this._boundEvents) {
  7572. return;
  7573. }
  7574. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  7575. window.removeEventListener("popstate", this._boundEvents.popState);
  7576. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  7577. this._boundEvents = null;
  7578. }
  7579. }, {
  7580. key: "popStateInProgress",
  7581. get: function get() {
  7582. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  7583. }
  7584. }, {
  7585. key: "initialBookmark",
  7586. get: function get() {
  7587. return this._initialized ? this._initialBookmark : null;
  7588. }
  7589. }, {
  7590. key: "initialRotation",
  7591. get: function get() {
  7592. return this._initialized ? this._initialRotation : null;
  7593. }
  7594. }]);
  7595. return PDFHistory;
  7596. }();
  7597. exports.PDFHistory = PDFHistory;
  7598. function isDestHashesEqual(destHash, pushHash) {
  7599. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  7600. return false;
  7601. }
  7602. if (destHash === pushHash) {
  7603. return true;
  7604. }
  7605. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  7606. nameddest = _parseQueryString.nameddest;
  7607. if (nameddest === pushHash) {
  7608. return true;
  7609. }
  7610. return false;
  7611. }
  7612. function isDestArraysEqual(firstDest, secondDest) {
  7613. function isEntryEqual(first, second) {
  7614. if (_typeof(first) !== _typeof(second)) {
  7615. return false;
  7616. }
  7617. if (Array.isArray(first) || Array.isArray(second)) {
  7618. return false;
  7619. }
  7620. if (first !== null && _typeof(first) === "object" && second !== null) {
  7621. if (Object.keys(first).length !== Object.keys(second).length) {
  7622. return false;
  7623. }
  7624. for (var key in first) {
  7625. if (!isEntryEqual(first[key], second[key])) {
  7626. return false;
  7627. }
  7628. }
  7629. return true;
  7630. }
  7631. return first === second || Number.isNaN(first) && Number.isNaN(second);
  7632. }
  7633. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  7634. return false;
  7635. }
  7636. if (firstDest.length !== secondDest.length) {
  7637. return false;
  7638. }
  7639. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  7640. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  7641. return false;
  7642. }
  7643. }
  7644. return true;
  7645. }
  7646. /***/ }),
  7647. /* 20 */
  7648. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7649. Object.defineProperty(exports, "__esModule", ({
  7650. value: true
  7651. }));
  7652. exports.PDFLayerViewer = void 0;
  7653. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  7654. var _base_tree_viewer = __webpack_require__(14);
  7655. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7656. 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); }
  7657. 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; } } }; }
  7658. 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); }
  7659. 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; }
  7660. 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); } }
  7661. 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); }); }; }
  7662. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7663. 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); } }
  7664. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7665. 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); }
  7666. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  7667. 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); }
  7668. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7669. 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); }; }
  7670. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7671. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7672. 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; } }
  7673. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7674. var PDFLayerViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  7675. _inherits(PDFLayerViewer, _BaseTreeViewer);
  7676. var _super = _createSuper(PDFLayerViewer);
  7677. function PDFLayerViewer(options) {
  7678. var _this;
  7679. _classCallCheck(this, PDFLayerViewer);
  7680. _this = _super.call(this, options);
  7681. _this.l10n = options.l10n;
  7682. _this.eventBus._on("resetlayers", _this._resetLayers.bind(_assertThisInitialized(_this)));
  7683. _this.eventBus._on("togglelayerstree", _this._toggleAllTreeItems.bind(_assertThisInitialized(_this)));
  7684. return _this;
  7685. }
  7686. _createClass(PDFLayerViewer, [{
  7687. key: "reset",
  7688. value: function reset() {
  7689. _get(_getPrototypeOf(PDFLayerViewer.prototype), "reset", this).call(this);
  7690. this._optionalContentConfig = null;
  7691. }
  7692. }, {
  7693. key: "_dispatchEvent",
  7694. value: function _dispatchEvent(layersCount) {
  7695. this.eventBus.dispatch("layersloaded", {
  7696. source: this,
  7697. layersCount: layersCount
  7698. });
  7699. }
  7700. }, {
  7701. key: "_bindLink",
  7702. value: function _bindLink(element, _ref) {
  7703. var _this2 = this;
  7704. var groupId = _ref.groupId,
  7705. input = _ref.input;
  7706. var setVisibility = function setVisibility() {
  7707. _this2._optionalContentConfig.setVisibility(groupId, input.checked);
  7708. _this2.eventBus.dispatch("optionalcontentconfig", {
  7709. source: _this2,
  7710. promise: Promise.resolve(_this2._optionalContentConfig)
  7711. });
  7712. };
  7713. element.onclick = function (evt) {
  7714. if (evt.target === input) {
  7715. setVisibility();
  7716. return true;
  7717. } else if (evt.target !== element) {
  7718. return true;
  7719. }
  7720. input.checked = !input.checked;
  7721. setVisibility();
  7722. return false;
  7723. };
  7724. }
  7725. }, {
  7726. key: "_setNestedName",
  7727. value: function () {
  7728. var _setNestedName2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(element, _ref2) {
  7729. var _ref2$name, name;
  7730. return _regenerator["default"].wrap(function _callee$(_context) {
  7731. while (1) {
  7732. switch (_context.prev = _context.next) {
  7733. case 0:
  7734. _ref2$name = _ref2.name, name = _ref2$name === void 0 ? null : _ref2$name;
  7735. if (!(typeof name === "string")) {
  7736. _context.next = 4;
  7737. break;
  7738. }
  7739. element.textContent = this._normalizeTextContent(name);
  7740. return _context.abrupt("return");
  7741. case 4:
  7742. _context.next = 6;
  7743. return this.l10n.get("additional_layers", null, "Additional Layers");
  7744. case 6:
  7745. element.textContent = _context.sent;
  7746. element.style.fontStyle = "italic";
  7747. case 8:
  7748. case "end":
  7749. return _context.stop();
  7750. }
  7751. }
  7752. }, _callee, this);
  7753. }));
  7754. function _setNestedName(_x, _x2) {
  7755. return _setNestedName2.apply(this, arguments);
  7756. }
  7757. return _setNestedName;
  7758. }()
  7759. }, {
  7760. key: "_addToggleButton",
  7761. value: function _addToggleButton(div, _ref3) {
  7762. var _ref3$name = _ref3.name,
  7763. name = _ref3$name === void 0 ? null : _ref3$name;
  7764. _get(_getPrototypeOf(PDFLayerViewer.prototype), "_addToggleButton", this).call(this, div, name === null);
  7765. }
  7766. }, {
  7767. key: "_toggleAllTreeItems",
  7768. value: function _toggleAllTreeItems() {
  7769. if (!this._optionalContentConfig) {
  7770. return;
  7771. }
  7772. _get(_getPrototypeOf(PDFLayerViewer.prototype), "_toggleAllTreeItems", this).call(this);
  7773. }
  7774. }, {
  7775. key: "render",
  7776. value: function render(_ref4) {
  7777. var optionalContentConfig = _ref4.optionalContentConfig,
  7778. pdfDocument = _ref4.pdfDocument;
  7779. if (this._optionalContentConfig) {
  7780. this.reset();
  7781. }
  7782. this._optionalContentConfig = optionalContentConfig || null;
  7783. this._pdfDocument = pdfDocument || null;
  7784. var groups = optionalContentConfig && optionalContentConfig.getOrder();
  7785. if (!groups) {
  7786. this._dispatchEvent(0);
  7787. return;
  7788. }
  7789. var fragment = document.createDocumentFragment(),
  7790. queue = [{
  7791. parent: fragment,
  7792. groups: groups
  7793. }];
  7794. var layersCount = 0,
  7795. hasAnyNesting = false;
  7796. while (queue.length > 0) {
  7797. var levelData = queue.shift();
  7798. var _iterator = _createForOfIteratorHelper(levelData.groups),
  7799. _step;
  7800. try {
  7801. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7802. var groupId = _step.value;
  7803. var div = document.createElement("div");
  7804. div.className = "treeItem";
  7805. var element = document.createElement("a");
  7806. div.appendChild(element);
  7807. if (_typeof(groupId) === "object") {
  7808. hasAnyNesting = true;
  7809. this._addToggleButton(div, groupId);
  7810. this._setNestedName(element, groupId);
  7811. var itemsDiv = document.createElement("div");
  7812. itemsDiv.className = "treeItems";
  7813. div.appendChild(itemsDiv);
  7814. queue.push({
  7815. parent: itemsDiv,
  7816. groups: groupId.order
  7817. });
  7818. } else {
  7819. var group = optionalContentConfig.getGroup(groupId);
  7820. var input = document.createElement("input");
  7821. this._bindLink(element, {
  7822. groupId: groupId,
  7823. input: input
  7824. });
  7825. input.type = "checkbox";
  7826. input.id = groupId;
  7827. input.checked = group.visible;
  7828. var label = document.createElement("label");
  7829. label.setAttribute("for", groupId);
  7830. label.textContent = this._normalizeTextContent(group.name);
  7831. element.appendChild(input);
  7832. element.appendChild(label);
  7833. layersCount++;
  7834. }
  7835. levelData.parent.appendChild(div);
  7836. }
  7837. } catch (err) {
  7838. _iterator.e(err);
  7839. } finally {
  7840. _iterator.f();
  7841. }
  7842. }
  7843. this._finishRendering(fragment, layersCount, hasAnyNesting);
  7844. }
  7845. }, {
  7846. key: "_resetLayers",
  7847. value: function () {
  7848. var _resetLayers2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  7849. var optionalContentConfig;
  7850. return _regenerator["default"].wrap(function _callee2$(_context2) {
  7851. while (1) {
  7852. switch (_context2.prev = _context2.next) {
  7853. case 0:
  7854. if (this._optionalContentConfig) {
  7855. _context2.next = 2;
  7856. break;
  7857. }
  7858. return _context2.abrupt("return");
  7859. case 2:
  7860. _context2.next = 4;
  7861. return this._pdfDocument.getOptionalContentConfig();
  7862. case 4:
  7863. optionalContentConfig = _context2.sent;
  7864. this.eventBus.dispatch("optionalcontentconfig", {
  7865. source: this,
  7866. promise: Promise.resolve(optionalContentConfig)
  7867. });
  7868. this.render({
  7869. optionalContentConfig: optionalContentConfig,
  7870. pdfDocument: this._pdfDocument
  7871. });
  7872. case 7:
  7873. case "end":
  7874. return _context2.stop();
  7875. }
  7876. }
  7877. }, _callee2, this);
  7878. }));
  7879. function _resetLayers() {
  7880. return _resetLayers2.apply(this, arguments);
  7881. }
  7882. return _resetLayers;
  7883. }()
  7884. }]);
  7885. return PDFLayerViewer;
  7886. }(_base_tree_viewer.BaseTreeViewer);
  7887. exports.PDFLayerViewer = PDFLayerViewer;
  7888. /***/ }),
  7889. /* 21 */
  7890. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7891. Object.defineProperty(exports, "__esModule", ({
  7892. value: true
  7893. }));
  7894. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  7895. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  7896. var _ui_utils = __webpack_require__(6);
  7897. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7898. 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); }
  7899. 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); } }
  7900. 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); }); }; }
  7901. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7902. 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); } }
  7903. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7904. var PDFLinkService = /*#__PURE__*/function () {
  7905. function PDFLinkService() {
  7906. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  7907. eventBus = _ref.eventBus,
  7908. _ref$externalLinkTarg = _ref.externalLinkTarget,
  7909. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  7910. _ref$externalLinkRel = _ref.externalLinkRel,
  7911. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel,
  7912. _ref$externalLinkEnab = _ref.externalLinkEnabled,
  7913. externalLinkEnabled = _ref$externalLinkEnab === void 0 ? true : _ref$externalLinkEnab,
  7914. _ref$ignoreDestinatio = _ref.ignoreDestinationZoom,
  7915. ignoreDestinationZoom = _ref$ignoreDestinatio === void 0 ? false : _ref$ignoreDestinatio;
  7916. _classCallCheck(this, PDFLinkService);
  7917. this.eventBus = eventBus;
  7918. this.externalLinkTarget = externalLinkTarget;
  7919. this.externalLinkRel = externalLinkRel;
  7920. this.externalLinkEnabled = externalLinkEnabled;
  7921. this._ignoreDestinationZoom = ignoreDestinationZoom;
  7922. this.baseUrl = null;
  7923. this.pdfDocument = null;
  7924. this.pdfViewer = null;
  7925. this.pdfHistory = null;
  7926. this._pagesRefCache = null;
  7927. }
  7928. _createClass(PDFLinkService, [{
  7929. key: "setDocument",
  7930. value: function setDocument(pdfDocument) {
  7931. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  7932. this.baseUrl = baseUrl;
  7933. this.pdfDocument = pdfDocument;
  7934. this._pagesRefCache = Object.create(null);
  7935. }
  7936. }, {
  7937. key: "setViewer",
  7938. value: function setViewer(pdfViewer) {
  7939. this.pdfViewer = pdfViewer;
  7940. }
  7941. }, {
  7942. key: "setHistory",
  7943. value: function setHistory(pdfHistory) {
  7944. this.pdfHistory = pdfHistory;
  7945. }
  7946. }, {
  7947. key: "navigateTo",
  7948. value: function navigateTo(dest) {
  7949. console.error("Deprecated method: `navigateTo`, use `goToDestination` instead.");
  7950. this.goToDestination(dest);
  7951. }
  7952. }, {
  7953. key: "_goToDestinationHelper",
  7954. value: function _goToDestinationHelper(rawDest) {
  7955. var _this = this;
  7956. var namedDest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  7957. var explicitDest = arguments.length > 2 ? arguments[2] : undefined;
  7958. var destRef = explicitDest[0];
  7959. var pageNumber;
  7960. if (destRef instanceof Object) {
  7961. pageNumber = this._cachedPageNumber(destRef);
  7962. if (pageNumber === null) {
  7963. this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  7964. _this.cachePageRef(pageIndex + 1, destRef);
  7965. _this._goToDestinationHelper(rawDest, namedDest, explicitDest);
  7966. })["catch"](function () {
  7967. console.error("PDFLinkService._goToDestinationHelper: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(rawDest, "\"."));
  7968. });
  7969. return;
  7970. }
  7971. } else if (Number.isInteger(destRef)) {
  7972. pageNumber = destRef + 1;
  7973. } else {
  7974. console.error("PDFLinkService._goToDestinationHelper: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(rawDest, "\"."));
  7975. return;
  7976. }
  7977. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  7978. console.error("PDFLinkService._goToDestinationHelper: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(rawDest, "\"."));
  7979. return;
  7980. }
  7981. if (this.pdfHistory) {
  7982. this.pdfHistory.pushCurrentPosition();
  7983. this.pdfHistory.push({
  7984. namedDest: namedDest,
  7985. explicitDest: explicitDest,
  7986. pageNumber: pageNumber
  7987. });
  7988. }
  7989. this.pdfViewer.scrollPageIntoView({
  7990. pageNumber: pageNumber,
  7991. destArray: explicitDest,
  7992. ignoreDestinationZoom: this._ignoreDestinationZoom
  7993. });
  7994. }
  7995. }, {
  7996. key: "goToDestination",
  7997. value: function () {
  7998. var _goToDestination = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(dest) {
  7999. var namedDest, explicitDest;
  8000. return _regenerator["default"].wrap(function _callee$(_context) {
  8001. while (1) {
  8002. switch (_context.prev = _context.next) {
  8003. case 0:
  8004. if (this.pdfDocument) {
  8005. _context.next = 2;
  8006. break;
  8007. }
  8008. return _context.abrupt("return");
  8009. case 2:
  8010. if (!(typeof dest === "string")) {
  8011. _context.next = 9;
  8012. break;
  8013. }
  8014. namedDest = dest;
  8015. _context.next = 6;
  8016. return this.pdfDocument.getDestination(dest);
  8017. case 6:
  8018. explicitDest = _context.sent;
  8019. _context.next = 13;
  8020. break;
  8021. case 9:
  8022. namedDest = null;
  8023. _context.next = 12;
  8024. return dest;
  8025. case 12:
  8026. explicitDest = _context.sent;
  8027. case 13:
  8028. if (Array.isArray(explicitDest)) {
  8029. _context.next = 16;
  8030. break;
  8031. }
  8032. console.error("PDFLinkService.goToDestination: \"".concat(explicitDest, "\" is not ") + "a valid destination array, for dest=\"".concat(dest, "\"."));
  8033. return _context.abrupt("return");
  8034. case 16:
  8035. this._goToDestinationHelper(dest, namedDest, explicitDest);
  8036. case 17:
  8037. case "end":
  8038. return _context.stop();
  8039. }
  8040. }
  8041. }, _callee, this);
  8042. }));
  8043. function goToDestination(_x) {
  8044. return _goToDestination.apply(this, arguments);
  8045. }
  8046. return goToDestination;
  8047. }()
  8048. }, {
  8049. key: "goToPage",
  8050. value: function goToPage(val) {
  8051. if (!this.pdfDocument) {
  8052. return;
  8053. }
  8054. var pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
  8055. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  8056. console.error("PDFLinkService.goToPage: \"".concat(val, "\" is not a valid page."));
  8057. return;
  8058. }
  8059. if (this.pdfHistory) {
  8060. this.pdfHistory.pushCurrentPosition();
  8061. this.pdfHistory.pushPage(pageNumber);
  8062. }
  8063. this.pdfViewer.scrollPageIntoView({
  8064. pageNumber: pageNumber
  8065. });
  8066. }
  8067. }, {
  8068. key: "getDestinationHash",
  8069. value: function getDestinationHash(dest) {
  8070. if (typeof dest === "string") {
  8071. if (dest.length > 0) {
  8072. return this.getAnchorUrl("#" + escape(dest));
  8073. }
  8074. } else if (Array.isArray(dest)) {
  8075. var str = JSON.stringify(dest);
  8076. if (str.length > 0) {
  8077. return this.getAnchorUrl("#" + escape(str));
  8078. }
  8079. }
  8080. return this.getAnchorUrl("");
  8081. }
  8082. }, {
  8083. key: "getAnchorUrl",
  8084. value: function getAnchorUrl(anchor) {
  8085. return (this.baseUrl || "") + anchor;
  8086. }
  8087. }, {
  8088. key: "setHash",
  8089. value: function setHash(hash) {
  8090. if (!this.pdfDocument) {
  8091. return;
  8092. }
  8093. var pageNumber, dest;
  8094. if (hash.includes("=")) {
  8095. var params = (0, _ui_utils.parseQueryString)(hash);
  8096. if ("search" in params) {
  8097. this.eventBus.dispatch("findfromurlhash", {
  8098. source: this,
  8099. query: params.search.replace(/"/g, ""),
  8100. phraseSearch: params.phrase === "true"
  8101. });
  8102. }
  8103. if ("page" in params) {
  8104. pageNumber = params.page | 0 || 1;
  8105. }
  8106. if ("zoom" in params) {
  8107. var zoomArgs = params.zoom.split(",");
  8108. var zoomArg = zoomArgs[0];
  8109. var zoomArgNumber = parseFloat(zoomArg);
  8110. if (!zoomArg.includes("Fit")) {
  8111. dest = [null, {
  8112. name: "XYZ"
  8113. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  8114. } else {
  8115. if (zoomArg === "Fit" || zoomArg === "FitB") {
  8116. dest = [null, {
  8117. name: zoomArg
  8118. }];
  8119. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  8120. dest = [null, {
  8121. name: zoomArg
  8122. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  8123. } else if (zoomArg === "FitR") {
  8124. if (zoomArgs.length !== 5) {
  8125. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  8126. } else {
  8127. dest = [null, {
  8128. name: zoomArg
  8129. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  8130. }
  8131. } else {
  8132. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + "a valid zoom value.");
  8133. }
  8134. }
  8135. }
  8136. if (dest) {
  8137. this.pdfViewer.scrollPageIntoView({
  8138. pageNumber: pageNumber || this.page,
  8139. destArray: dest,
  8140. allowNegativeOffset: true
  8141. });
  8142. } else if (pageNumber) {
  8143. this.page = pageNumber;
  8144. }
  8145. if ("pagemode" in params) {
  8146. this.eventBus.dispatch("pagemode", {
  8147. source: this,
  8148. mode: params.pagemode
  8149. });
  8150. }
  8151. if ("nameddest" in params) {
  8152. this.goToDestination(params.nameddest);
  8153. }
  8154. } else {
  8155. dest = unescape(hash);
  8156. try {
  8157. dest = JSON.parse(dest);
  8158. if (!Array.isArray(dest)) {
  8159. dest = dest.toString();
  8160. }
  8161. } catch (ex) {}
  8162. if (typeof dest === "string" || isValidExplicitDestination(dest)) {
  8163. this.goToDestination(dest);
  8164. return;
  8165. }
  8166. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + "a valid destination.");
  8167. }
  8168. }
  8169. }, {
  8170. key: "executeNamedAction",
  8171. value: function executeNamedAction(action) {
  8172. switch (action) {
  8173. case "GoBack":
  8174. if (this.pdfHistory) {
  8175. this.pdfHistory.back();
  8176. }
  8177. break;
  8178. case "GoForward":
  8179. if (this.pdfHistory) {
  8180. this.pdfHistory.forward();
  8181. }
  8182. break;
  8183. case "NextPage":
  8184. this.pdfViewer.nextPage();
  8185. break;
  8186. case "PrevPage":
  8187. this.pdfViewer.previousPage();
  8188. break;
  8189. case "LastPage":
  8190. this.page = this.pagesCount;
  8191. break;
  8192. case "FirstPage":
  8193. this.page = 1;
  8194. break;
  8195. default:
  8196. break;
  8197. }
  8198. this.eventBus.dispatch("namedaction", {
  8199. source: this,
  8200. action: action
  8201. });
  8202. }
  8203. }, {
  8204. key: "cachePageRef",
  8205. value: function cachePageRef(pageNum, pageRef) {
  8206. if (!pageRef) {
  8207. return;
  8208. }
  8209. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  8210. this._pagesRefCache[refStr] = pageNum;
  8211. }
  8212. }, {
  8213. key: "_cachedPageNumber",
  8214. value: function _cachedPageNumber(pageRef) {
  8215. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  8216. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  8217. }
  8218. }, {
  8219. key: "isPageVisible",
  8220. value: function isPageVisible(pageNumber) {
  8221. return this.pdfViewer.isPageVisible(pageNumber);
  8222. }
  8223. }, {
  8224. key: "isPageCached",
  8225. value: function isPageCached(pageNumber) {
  8226. return this.pdfViewer.isPageCached(pageNumber);
  8227. }
  8228. }, {
  8229. key: "pagesCount",
  8230. get: function get() {
  8231. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  8232. }
  8233. }, {
  8234. key: "page",
  8235. get: function get() {
  8236. return this.pdfViewer.currentPageNumber;
  8237. },
  8238. set: function set(value) {
  8239. this.pdfViewer.currentPageNumber = value;
  8240. }
  8241. }, {
  8242. key: "rotation",
  8243. get: function get() {
  8244. return this.pdfViewer.pagesRotation;
  8245. },
  8246. set: function set(value) {
  8247. this.pdfViewer.pagesRotation = value;
  8248. }
  8249. }]);
  8250. return PDFLinkService;
  8251. }();
  8252. exports.PDFLinkService = PDFLinkService;
  8253. function isValidExplicitDestination(dest) {
  8254. if (!Array.isArray(dest)) {
  8255. return false;
  8256. }
  8257. var destLength = dest.length;
  8258. if (destLength < 2) {
  8259. return false;
  8260. }
  8261. var page = dest[0];
  8262. if (!(_typeof(page) === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  8263. return false;
  8264. }
  8265. var zoom = dest[1];
  8266. if (!(_typeof(zoom) === "object" && typeof zoom.name === "string")) {
  8267. return false;
  8268. }
  8269. var allowNull = true;
  8270. switch (zoom.name) {
  8271. case "XYZ":
  8272. if (destLength !== 5) {
  8273. return false;
  8274. }
  8275. break;
  8276. case "Fit":
  8277. case "FitB":
  8278. return destLength === 2;
  8279. case "FitH":
  8280. case "FitBH":
  8281. case "FitV":
  8282. case "FitBV":
  8283. if (destLength !== 3) {
  8284. return false;
  8285. }
  8286. break;
  8287. case "FitR":
  8288. if (destLength !== 6) {
  8289. return false;
  8290. }
  8291. allowNull = false;
  8292. break;
  8293. default:
  8294. return false;
  8295. }
  8296. for (var i = 2; i < destLength; i++) {
  8297. var param = dest[i];
  8298. if (!(typeof param === "number" || allowNull && param === null)) {
  8299. return false;
  8300. }
  8301. }
  8302. return true;
  8303. }
  8304. var SimpleLinkService = /*#__PURE__*/function () {
  8305. function SimpleLinkService() {
  8306. _classCallCheck(this, SimpleLinkService);
  8307. this.externalLinkTarget = null;
  8308. this.externalLinkRel = null;
  8309. this.externalLinkEnabled = true;
  8310. this._ignoreDestinationZoom = false;
  8311. }
  8312. _createClass(SimpleLinkService, [{
  8313. key: "goToDestination",
  8314. value: function () {
  8315. var _goToDestination2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(dest) {
  8316. return _regenerator["default"].wrap(function _callee2$(_context2) {
  8317. while (1) {
  8318. switch (_context2.prev = _context2.next) {
  8319. case 0:
  8320. case "end":
  8321. return _context2.stop();
  8322. }
  8323. }
  8324. }, _callee2);
  8325. }));
  8326. function goToDestination(_x2) {
  8327. return _goToDestination2.apply(this, arguments);
  8328. }
  8329. return goToDestination;
  8330. }()
  8331. }, {
  8332. key: "goToPage",
  8333. value: function goToPage(val) {}
  8334. }, {
  8335. key: "getDestinationHash",
  8336. value: function getDestinationHash(dest) {
  8337. return "#";
  8338. }
  8339. }, {
  8340. key: "getAnchorUrl",
  8341. value: function getAnchorUrl(hash) {
  8342. return "#";
  8343. }
  8344. }, {
  8345. key: "setHash",
  8346. value: function setHash(hash) {}
  8347. }, {
  8348. key: "executeNamedAction",
  8349. value: function executeNamedAction(action) {}
  8350. }, {
  8351. key: "cachePageRef",
  8352. value: function cachePageRef(pageNum, pageRef) {}
  8353. }, {
  8354. key: "isPageVisible",
  8355. value: function isPageVisible(pageNumber) {
  8356. return true;
  8357. }
  8358. }, {
  8359. key: "isPageCached",
  8360. value: function isPageCached(pageNumber) {
  8361. return true;
  8362. }
  8363. }, {
  8364. key: "pagesCount",
  8365. get: function get() {
  8366. return 0;
  8367. }
  8368. }, {
  8369. key: "page",
  8370. get: function get() {
  8371. return 0;
  8372. },
  8373. set: function set(value) {}
  8374. }, {
  8375. key: "rotation",
  8376. get: function get() {
  8377. return 0;
  8378. },
  8379. set: function set(value) {}
  8380. }]);
  8381. return SimpleLinkService;
  8382. }();
  8383. exports.SimpleLinkService = SimpleLinkService;
  8384. /***/ }),
  8385. /* 22 */
  8386. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8387. Object.defineProperty(exports, "__esModule", ({
  8388. value: true
  8389. }));
  8390. exports.PDFOutlineViewer = void 0;
  8391. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  8392. var _pdfjsLib = __webpack_require__(7);
  8393. var _base_tree_viewer = __webpack_require__(14);
  8394. var _ui_utils = __webpack_require__(6);
  8395. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8396. 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); }
  8397. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  8398. 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."); }
  8399. 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; }
  8400. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  8401. 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); } }
  8402. 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); }); }; }
  8403. 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; } } }; }
  8404. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  8405. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  8406. 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); }
  8407. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
  8408. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  8409. 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; }
  8410. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8411. 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); } }
  8412. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8413. 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); }
  8414. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  8415. 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); }
  8416. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8417. 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); }; }
  8418. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8419. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8420. 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; } }
  8421. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8422. var PDFOutlineViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  8423. _inherits(PDFOutlineViewer, _BaseTreeViewer);
  8424. var _super = _createSuper(PDFOutlineViewer);
  8425. function PDFOutlineViewer(options) {
  8426. var _this;
  8427. _classCallCheck(this, PDFOutlineViewer);
  8428. _this = _super.call(this, options);
  8429. _this.linkService = options.linkService;
  8430. _this.eventBus._on("toggleoutlinetree", _this._toggleAllTreeItems.bind(_assertThisInitialized(_this)));
  8431. _this.eventBus._on("currentoutlineitem", _this._currentOutlineItem.bind(_assertThisInitialized(_this)));
  8432. _this.eventBus._on("pagechanging", function (evt) {
  8433. _this._currentPageNumber = evt.pageNumber;
  8434. });
  8435. _this.eventBus._on("pagesloaded", function (evt) {
  8436. _this._isPagesLoaded = !!evt.pagesCount;
  8437. });
  8438. _this.eventBus._on("sidebarviewchanged", function (evt) {
  8439. _this._sidebarView = evt.view;
  8440. });
  8441. return _this;
  8442. }
  8443. _createClass(PDFOutlineViewer, [{
  8444. key: "reset",
  8445. value: function reset() {
  8446. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "reset", this).call(this);
  8447. this._outline = null;
  8448. this._pageNumberToDestHashCapability = null;
  8449. this._currentPageNumber = 1;
  8450. this._isPagesLoaded = false;
  8451. }
  8452. }, {
  8453. key: "_dispatchEvent",
  8454. value: function _dispatchEvent(outlineCount) {
  8455. var _this$_pdfDocument;
  8456. this.eventBus.dispatch("outlineloaded", {
  8457. source: this,
  8458. outlineCount: outlineCount,
  8459. enableCurrentOutlineItemButton: outlineCount > 0 && !((_this$_pdfDocument = this._pdfDocument) !== null && _this$_pdfDocument !== void 0 && _this$_pdfDocument.loadingParams.disableAutoFetch)
  8460. });
  8461. }
  8462. }, {
  8463. key: "_bindLink",
  8464. value: function _bindLink(element, _ref) {
  8465. var _this2 = this;
  8466. var url = _ref.url,
  8467. newWindow = _ref.newWindow,
  8468. dest = _ref.dest;
  8469. var linkService = this.linkService;
  8470. if (url) {
  8471. (0, _pdfjsLib.addLinkAttributes)(element, {
  8472. url: url,
  8473. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
  8474. rel: linkService.externalLinkRel,
  8475. enabled: linkService.externalLinkEnabled
  8476. });
  8477. return;
  8478. }
  8479. element.href = linkService.getDestinationHash(dest);
  8480. element.onclick = function (evt) {
  8481. _this2._updateCurrentTreeItem(evt.target.parentNode);
  8482. if (dest) {
  8483. linkService.goToDestination(dest);
  8484. }
  8485. return false;
  8486. };
  8487. }
  8488. }, {
  8489. key: "_setStyles",
  8490. value: function _setStyles(element, _ref2) {
  8491. var bold = _ref2.bold,
  8492. italic = _ref2.italic;
  8493. if (bold) {
  8494. element.style.fontWeight = "bold";
  8495. }
  8496. if (italic) {
  8497. element.style.fontStyle = "italic";
  8498. }
  8499. }
  8500. }, {
  8501. key: "_addToggleButton",
  8502. value: function _addToggleButton(div, _ref3) {
  8503. var count = _ref3.count,
  8504. items = _ref3.items;
  8505. var hidden = false;
  8506. if (count < 0) {
  8507. var totalCount = items.length;
  8508. if (totalCount > 0) {
  8509. var queue = _toConsumableArray(items);
  8510. while (queue.length > 0) {
  8511. var _queue$shift = queue.shift(),
  8512. nestedCount = _queue$shift.count,
  8513. nestedItems = _queue$shift.items;
  8514. if (nestedCount > 0 && nestedItems.length > 0) {
  8515. totalCount += nestedItems.length;
  8516. queue.push.apply(queue, _toConsumableArray(nestedItems));
  8517. }
  8518. }
  8519. }
  8520. if (Math.abs(count) === totalCount) {
  8521. hidden = true;
  8522. }
  8523. }
  8524. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "_addToggleButton", this).call(this, div, hidden);
  8525. }
  8526. }, {
  8527. key: "_toggleAllTreeItems",
  8528. value: function _toggleAllTreeItems() {
  8529. if (!this._outline) {
  8530. return;
  8531. }
  8532. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "_toggleAllTreeItems", this).call(this);
  8533. }
  8534. }, {
  8535. key: "render",
  8536. value: function render(_ref4) {
  8537. var outline = _ref4.outline,
  8538. pdfDocument = _ref4.pdfDocument;
  8539. if (this._outline) {
  8540. this.reset();
  8541. }
  8542. this._outline = outline || null;
  8543. this._pdfDocument = pdfDocument || null;
  8544. if (!outline) {
  8545. this._dispatchEvent(0);
  8546. return;
  8547. }
  8548. var fragment = document.createDocumentFragment();
  8549. var queue = [{
  8550. parent: fragment,
  8551. items: outline
  8552. }];
  8553. var outlineCount = 0,
  8554. hasAnyNesting = false;
  8555. while (queue.length > 0) {
  8556. var levelData = queue.shift();
  8557. var _iterator = _createForOfIteratorHelper(levelData.items),
  8558. _step;
  8559. try {
  8560. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8561. var item = _step.value;
  8562. var div = document.createElement("div");
  8563. div.className = "treeItem";
  8564. var element = document.createElement("a");
  8565. this._bindLink(element, item);
  8566. this._setStyles(element, item);
  8567. element.textContent = this._normalizeTextContent(item.title);
  8568. div.appendChild(element);
  8569. if (item.items.length > 0) {
  8570. hasAnyNesting = true;
  8571. this._addToggleButton(div, item);
  8572. var itemsDiv = document.createElement("div");
  8573. itemsDiv.className = "treeItems";
  8574. div.appendChild(itemsDiv);
  8575. queue.push({
  8576. parent: itemsDiv,
  8577. items: item.items
  8578. });
  8579. }
  8580. levelData.parent.appendChild(div);
  8581. outlineCount++;
  8582. }
  8583. } catch (err) {
  8584. _iterator.e(err);
  8585. } finally {
  8586. _iterator.f();
  8587. }
  8588. }
  8589. this._finishRendering(fragment, outlineCount, hasAnyNesting);
  8590. }
  8591. }, {
  8592. key: "_currentOutlineItem",
  8593. value: function () {
  8594. var _currentOutlineItem2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  8595. var pageNumberToDestHash, i, destHash, linkElement;
  8596. return _regenerator["default"].wrap(function _callee$(_context) {
  8597. while (1) {
  8598. switch (_context.prev = _context.next) {
  8599. case 0:
  8600. if (this._isPagesLoaded) {
  8601. _context.next = 2;
  8602. break;
  8603. }
  8604. throw new Error("_currentOutlineItem: All pages have not been loaded.");
  8605. case 2:
  8606. if (!(!this._outline || !this._pdfDocument)) {
  8607. _context.next = 4;
  8608. break;
  8609. }
  8610. return _context.abrupt("return");
  8611. case 4:
  8612. _context.next = 6;
  8613. return this._getPageNumberToDestHash(this._pdfDocument);
  8614. case 6:
  8615. pageNumberToDestHash = _context.sent;
  8616. if (pageNumberToDestHash) {
  8617. _context.next = 9;
  8618. break;
  8619. }
  8620. return _context.abrupt("return");
  8621. case 9:
  8622. this._updateCurrentTreeItem(null);
  8623. if (!(this._sidebarView !== _ui_utils.SidebarView.OUTLINE)) {
  8624. _context.next = 12;
  8625. break;
  8626. }
  8627. return _context.abrupt("return");
  8628. case 12:
  8629. i = this._currentPageNumber;
  8630. case 13:
  8631. if (!(i > 0)) {
  8632. _context.next = 25;
  8633. break;
  8634. }
  8635. destHash = pageNumberToDestHash.get(i);
  8636. if (destHash) {
  8637. _context.next = 17;
  8638. break;
  8639. }
  8640. return _context.abrupt("continue", 22);
  8641. case 17:
  8642. linkElement = this.container.querySelector("a[href=\"".concat(destHash, "\"]"));
  8643. if (linkElement) {
  8644. _context.next = 20;
  8645. break;
  8646. }
  8647. return _context.abrupt("continue", 22);
  8648. case 20:
  8649. this._scrollToCurrentTreeItem(linkElement.parentNode);
  8650. return _context.abrupt("break", 25);
  8651. case 22:
  8652. i--;
  8653. _context.next = 13;
  8654. break;
  8655. case 25:
  8656. case "end":
  8657. return _context.stop();
  8658. }
  8659. }
  8660. }, _callee, this);
  8661. }));
  8662. function _currentOutlineItem() {
  8663. return _currentOutlineItem2.apply(this, arguments);
  8664. }
  8665. return _currentOutlineItem;
  8666. }()
  8667. }, {
  8668. key: "_getPageNumberToDestHash",
  8669. value: function () {
  8670. var _getPageNumberToDestHash2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pdfDocument) {
  8671. var pageNumberToDestHash, pageNumberNesting, queue, levelData, currentNesting, _iterator2, _step2, _step2$value, dest, items, explicitDest, pageNumber, _explicitDest, _explicitDest2, destRef, destHash;
  8672. return _regenerator["default"].wrap(function _callee2$(_context2) {
  8673. while (1) {
  8674. switch (_context2.prev = _context2.next) {
  8675. case 0:
  8676. if (!this._pageNumberToDestHashCapability) {
  8677. _context2.next = 2;
  8678. break;
  8679. }
  8680. return _context2.abrupt("return", this._pageNumberToDestHashCapability.promise);
  8681. case 2:
  8682. this._pageNumberToDestHashCapability = (0, _pdfjsLib.createPromiseCapability)();
  8683. pageNumberToDestHash = new Map(), pageNumberNesting = new Map();
  8684. queue = [{
  8685. nesting: 0,
  8686. items: this._outline
  8687. }];
  8688. case 5:
  8689. if (!(queue.length > 0)) {
  8690. _context2.next = 56;
  8691. break;
  8692. }
  8693. levelData = queue.shift(), currentNesting = levelData.nesting;
  8694. _iterator2 = _createForOfIteratorHelper(levelData.items);
  8695. _context2.prev = 8;
  8696. _iterator2.s();
  8697. case 10:
  8698. if ((_step2 = _iterator2.n()).done) {
  8699. _context2.next = 46;
  8700. break;
  8701. }
  8702. _step2$value = _step2.value, dest = _step2$value.dest, items = _step2$value.items;
  8703. explicitDest = void 0, pageNumber = void 0;
  8704. if (!(typeof dest === "string")) {
  8705. _context2.next = 21;
  8706. break;
  8707. }
  8708. _context2.next = 16;
  8709. return pdfDocument.getDestination(dest);
  8710. case 16:
  8711. explicitDest = _context2.sent;
  8712. if (!(pdfDocument !== this._pdfDocument)) {
  8713. _context2.next = 19;
  8714. break;
  8715. }
  8716. return _context2.abrupt("return", null);
  8717. case 19:
  8718. _context2.next = 22;
  8719. break;
  8720. case 21:
  8721. explicitDest = dest;
  8722. case 22:
  8723. if (!Array.isArray(explicitDest)) {
  8724. _context2.next = 43;
  8725. break;
  8726. }
  8727. _explicitDest = explicitDest, _explicitDest2 = _slicedToArray(_explicitDest, 1), destRef = _explicitDest2[0];
  8728. if (!(_typeof(destRef) === "object")) {
  8729. _context2.next = 41;
  8730. break;
  8731. }
  8732. pageNumber = this.linkService._cachedPageNumber(destRef);
  8733. if (pageNumber) {
  8734. _context2.next = 39;
  8735. break;
  8736. }
  8737. _context2.prev = 27;
  8738. _context2.next = 30;
  8739. return pdfDocument.getPageIndex(destRef);
  8740. case 30:
  8741. _context2.t0 = _context2.sent;
  8742. pageNumber = _context2.t0 + 1;
  8743. if (!(pdfDocument !== this._pdfDocument)) {
  8744. _context2.next = 34;
  8745. break;
  8746. }
  8747. return _context2.abrupt("return", null);
  8748. case 34:
  8749. this.linkService.cachePageRef(pageNumber, destRef);
  8750. _context2.next = 39;
  8751. break;
  8752. case 37:
  8753. _context2.prev = 37;
  8754. _context2.t1 = _context2["catch"](27);
  8755. case 39:
  8756. _context2.next = 42;
  8757. break;
  8758. case 41:
  8759. if (Number.isInteger(destRef)) {
  8760. pageNumber = destRef + 1;
  8761. }
  8762. case 42:
  8763. if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) {
  8764. destHash = this.linkService.getDestinationHash(dest);
  8765. pageNumberToDestHash.set(pageNumber, destHash);
  8766. pageNumberNesting.set(pageNumber, currentNesting);
  8767. }
  8768. case 43:
  8769. if (items.length > 0) {
  8770. queue.push({
  8771. nesting: currentNesting + 1,
  8772. items: items
  8773. });
  8774. }
  8775. case 44:
  8776. _context2.next = 10;
  8777. break;
  8778. case 46:
  8779. _context2.next = 51;
  8780. break;
  8781. case 48:
  8782. _context2.prev = 48;
  8783. _context2.t2 = _context2["catch"](8);
  8784. _iterator2.e(_context2.t2);
  8785. case 51:
  8786. _context2.prev = 51;
  8787. _iterator2.f();
  8788. return _context2.finish(51);
  8789. case 54:
  8790. _context2.next = 5;
  8791. break;
  8792. case 56:
  8793. this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null);
  8794. return _context2.abrupt("return", this._pageNumberToDestHashCapability.promise);
  8795. case 58:
  8796. case "end":
  8797. return _context2.stop();
  8798. }
  8799. }
  8800. }, _callee2, this, [[8, 48, 51, 54], [27, 37]]);
  8801. }));
  8802. function _getPageNumberToDestHash(_x) {
  8803. return _getPageNumberToDestHash2.apply(this, arguments);
  8804. }
  8805. return _getPageNumberToDestHash;
  8806. }()
  8807. }]);
  8808. return PDFOutlineViewer;
  8809. }(_base_tree_viewer.BaseTreeViewer);
  8810. exports.PDFOutlineViewer = PDFOutlineViewer;
  8811. /***/ }),
  8812. /* 23 */
  8813. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8814. Object.defineProperty(exports, "__esModule", ({
  8815. value: true
  8816. }));
  8817. exports.PDFPresentationMode = void 0;
  8818. var _ui_utils = __webpack_require__(6);
  8819. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8820. 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); } }
  8821. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8822. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  8823. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  8824. var ACTIVE_SELECTOR = "pdfPresentationMode";
  8825. var CONTROLS_SELECTOR = "pdfPresentationModeControls";
  8826. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  8827. var PAGE_SWITCH_THRESHOLD = 0.1;
  8828. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  8829. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  8830. var PDFPresentationMode = /*#__PURE__*/function () {
  8831. function PDFPresentationMode(_ref) {
  8832. var _this = this;
  8833. var container = _ref.container,
  8834. pdfViewer = _ref.pdfViewer,
  8835. eventBus = _ref.eventBus,
  8836. _ref$contextMenuItems = _ref.contextMenuItems,
  8837. contextMenuItems = _ref$contextMenuItems === void 0 ? null : _ref$contextMenuItems;
  8838. _classCallCheck(this, PDFPresentationMode);
  8839. this.container = container;
  8840. this.pdfViewer = pdfViewer;
  8841. this.eventBus = eventBus;
  8842. this.active = false;
  8843. this.args = null;
  8844. this.contextMenuOpen = false;
  8845. this.mouseScrollTimeStamp = 0;
  8846. this.mouseScrollDelta = 0;
  8847. this.touchSwipeState = null;
  8848. if (contextMenuItems) {
  8849. contextMenuItems.contextFirstPage.addEventListener("click", function () {
  8850. _this.contextMenuOpen = false;
  8851. _this.eventBus.dispatch("firstpage", {
  8852. source: _this
  8853. });
  8854. });
  8855. contextMenuItems.contextLastPage.addEventListener("click", function () {
  8856. _this.contextMenuOpen = false;
  8857. _this.eventBus.dispatch("lastpage", {
  8858. source: _this
  8859. });
  8860. });
  8861. contextMenuItems.contextPageRotateCw.addEventListener("click", function () {
  8862. _this.contextMenuOpen = false;
  8863. _this.eventBus.dispatch("rotatecw", {
  8864. source: _this
  8865. });
  8866. });
  8867. contextMenuItems.contextPageRotateCcw.addEventListener("click", function () {
  8868. _this.contextMenuOpen = false;
  8869. _this.eventBus.dispatch("rotateccw", {
  8870. source: _this
  8871. });
  8872. });
  8873. }
  8874. }
  8875. _createClass(PDFPresentationMode, [{
  8876. key: "request",
  8877. value: function request() {
  8878. if (this.switchInProgress || this.active || !this.pdfViewer.pagesCount) {
  8879. return false;
  8880. }
  8881. this._addFullscreenChangeListeners();
  8882. this._setSwitchInProgress();
  8883. this._notifyStateChange();
  8884. if (this.container.requestFullscreen) {
  8885. this.container.requestFullscreen();
  8886. } else if (this.container.mozRequestFullScreen) {
  8887. this.container.mozRequestFullScreen();
  8888. } else if (this.container.webkitRequestFullscreen) {
  8889. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  8890. } else {
  8891. return false;
  8892. }
  8893. this.args = {
  8894. page: this.pdfViewer.currentPageNumber,
  8895. previousScale: this.pdfViewer.currentScaleValue
  8896. };
  8897. return true;
  8898. }
  8899. }, {
  8900. key: "_mouseWheel",
  8901. value: function _mouseWheel(evt) {
  8902. if (!this.active) {
  8903. return;
  8904. }
  8905. evt.preventDefault();
  8906. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  8907. var currentTime = new Date().getTime();
  8908. var storedTime = this.mouseScrollTimeStamp;
  8909. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  8910. return;
  8911. }
  8912. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  8913. this._resetMouseScrollState();
  8914. }
  8915. this.mouseScrollDelta += delta;
  8916. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  8917. var totalDelta = this.mouseScrollDelta;
  8918. this._resetMouseScrollState();
  8919. var success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage();
  8920. if (success) {
  8921. this.mouseScrollTimeStamp = currentTime;
  8922. }
  8923. }
  8924. }
  8925. }, {
  8926. key: "_notifyStateChange",
  8927. value: function _notifyStateChange() {
  8928. var state = _ui_utils.PresentationModeState.NORMAL;
  8929. if (this.switchInProgress) {
  8930. state = _ui_utils.PresentationModeState.CHANGING;
  8931. } else if (this.active) {
  8932. state = _ui_utils.PresentationModeState.FULLSCREEN;
  8933. }
  8934. this.eventBus.dispatch("presentationmodechanged", {
  8935. source: this,
  8936. state: state,
  8937. get active() {
  8938. throw new Error("Deprecated parameter: `active`, please use `state` instead.");
  8939. },
  8940. get switchInProgress() {
  8941. throw new Error("Deprecated parameter: `switchInProgress`, please use `state` instead.");
  8942. }
  8943. });
  8944. }
  8945. }, {
  8946. key: "_setSwitchInProgress",
  8947. value: function _setSwitchInProgress() {
  8948. var _this2 = this;
  8949. if (this.switchInProgress) {
  8950. clearTimeout(this.switchInProgress);
  8951. }
  8952. this.switchInProgress = setTimeout(function () {
  8953. _this2._removeFullscreenChangeListeners();
  8954. delete _this2.switchInProgress;
  8955. _this2._notifyStateChange();
  8956. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  8957. }
  8958. }, {
  8959. key: "_resetSwitchInProgress",
  8960. value: function _resetSwitchInProgress() {
  8961. if (this.switchInProgress) {
  8962. clearTimeout(this.switchInProgress);
  8963. delete this.switchInProgress;
  8964. }
  8965. }
  8966. }, {
  8967. key: "_enter",
  8968. value: function _enter() {
  8969. var _this3 = this;
  8970. this.active = true;
  8971. this._resetSwitchInProgress();
  8972. this._notifyStateChange();
  8973. this.container.classList.add(ACTIVE_SELECTOR);
  8974. setTimeout(function () {
  8975. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  8976. _this3.pdfViewer.currentScaleValue = "page-fit";
  8977. }, 0);
  8978. this._addWindowListeners();
  8979. this._showControls();
  8980. this.contextMenuOpen = false;
  8981. this.container.setAttribute("contextmenu", "viewerContextMenu");
  8982. window.getSelection().removeAllRanges();
  8983. }
  8984. }, {
  8985. key: "_exit",
  8986. value: function _exit() {
  8987. var _this4 = this;
  8988. var page = this.pdfViewer.currentPageNumber;
  8989. this.container.classList.remove(ACTIVE_SELECTOR);
  8990. setTimeout(function () {
  8991. _this4.active = false;
  8992. _this4._removeFullscreenChangeListeners();
  8993. _this4._notifyStateChange();
  8994. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  8995. _this4.pdfViewer.currentPageNumber = page;
  8996. _this4.args = null;
  8997. }, 0);
  8998. this._removeWindowListeners();
  8999. this._hideControls();
  9000. this._resetMouseScrollState();
  9001. this.container.removeAttribute("contextmenu");
  9002. this.contextMenuOpen = false;
  9003. }
  9004. }, {
  9005. key: "_mouseDown",
  9006. value: function _mouseDown(evt) {
  9007. if (this.contextMenuOpen) {
  9008. this.contextMenuOpen = false;
  9009. evt.preventDefault();
  9010. return;
  9011. }
  9012. if (evt.button === 0) {
  9013. var isInternalLink = evt.target.href && evt.target.classList.contains("internalLink");
  9014. if (!isInternalLink) {
  9015. evt.preventDefault();
  9016. if (evt.shiftKey) {
  9017. this.pdfViewer.previousPage();
  9018. } else {
  9019. this.pdfViewer.nextPage();
  9020. }
  9021. }
  9022. }
  9023. }
  9024. }, {
  9025. key: "_contextMenu",
  9026. value: function _contextMenu() {
  9027. this.contextMenuOpen = true;
  9028. }
  9029. }, {
  9030. key: "_showControls",
  9031. value: function _showControls() {
  9032. var _this5 = this;
  9033. if (this.controlsTimeout) {
  9034. clearTimeout(this.controlsTimeout);
  9035. } else {
  9036. this.container.classList.add(CONTROLS_SELECTOR);
  9037. }
  9038. this.controlsTimeout = setTimeout(function () {
  9039. _this5.container.classList.remove(CONTROLS_SELECTOR);
  9040. delete _this5.controlsTimeout;
  9041. }, DELAY_BEFORE_HIDING_CONTROLS);
  9042. }
  9043. }, {
  9044. key: "_hideControls",
  9045. value: function _hideControls() {
  9046. if (!this.controlsTimeout) {
  9047. return;
  9048. }
  9049. clearTimeout(this.controlsTimeout);
  9050. this.container.classList.remove(CONTROLS_SELECTOR);
  9051. delete this.controlsTimeout;
  9052. }
  9053. }, {
  9054. key: "_resetMouseScrollState",
  9055. value: function _resetMouseScrollState() {
  9056. this.mouseScrollTimeStamp = 0;
  9057. this.mouseScrollDelta = 0;
  9058. }
  9059. }, {
  9060. key: "_touchSwipe",
  9061. value: function _touchSwipe(evt) {
  9062. if (!this.active) {
  9063. return;
  9064. }
  9065. if (evt.touches.length > 1) {
  9066. this.touchSwipeState = null;
  9067. return;
  9068. }
  9069. switch (evt.type) {
  9070. case "touchstart":
  9071. this.touchSwipeState = {
  9072. startX: evt.touches[0].pageX,
  9073. startY: evt.touches[0].pageY,
  9074. endX: evt.touches[0].pageX,
  9075. endY: evt.touches[0].pageY
  9076. };
  9077. break;
  9078. case "touchmove":
  9079. if (this.touchSwipeState === null) {
  9080. return;
  9081. }
  9082. this.touchSwipeState.endX = evt.touches[0].pageX;
  9083. this.touchSwipeState.endY = evt.touches[0].pageY;
  9084. evt.preventDefault();
  9085. break;
  9086. case "touchend":
  9087. if (this.touchSwipeState === null) {
  9088. return;
  9089. }
  9090. var delta = 0;
  9091. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  9092. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  9093. var absAngle = Math.abs(Math.atan2(dy, dx));
  9094. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  9095. delta = dx;
  9096. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  9097. delta = dy;
  9098. }
  9099. if (delta > 0) {
  9100. this.pdfViewer.previousPage();
  9101. } else if (delta < 0) {
  9102. this.pdfViewer.nextPage();
  9103. }
  9104. break;
  9105. }
  9106. }
  9107. }, {
  9108. key: "_addWindowListeners",
  9109. value: function _addWindowListeners() {
  9110. this.showControlsBind = this._showControls.bind(this);
  9111. this.mouseDownBind = this._mouseDown.bind(this);
  9112. this.mouseWheelBind = this._mouseWheel.bind(this);
  9113. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  9114. this.contextMenuBind = this._contextMenu.bind(this);
  9115. this.touchSwipeBind = this._touchSwipe.bind(this);
  9116. window.addEventListener("mousemove", this.showControlsBind);
  9117. window.addEventListener("mousedown", this.mouseDownBind);
  9118. window.addEventListener("wheel", this.mouseWheelBind, {
  9119. passive: false
  9120. });
  9121. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  9122. window.addEventListener("contextmenu", this.contextMenuBind);
  9123. window.addEventListener("touchstart", this.touchSwipeBind);
  9124. window.addEventListener("touchmove", this.touchSwipeBind);
  9125. window.addEventListener("touchend", this.touchSwipeBind);
  9126. }
  9127. }, {
  9128. key: "_removeWindowListeners",
  9129. value: function _removeWindowListeners() {
  9130. window.removeEventListener("mousemove", this.showControlsBind);
  9131. window.removeEventListener("mousedown", this.mouseDownBind);
  9132. window.removeEventListener("wheel", this.mouseWheelBind, {
  9133. passive: false
  9134. });
  9135. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  9136. window.removeEventListener("contextmenu", this.contextMenuBind);
  9137. window.removeEventListener("touchstart", this.touchSwipeBind);
  9138. window.removeEventListener("touchmove", this.touchSwipeBind);
  9139. window.removeEventListener("touchend", this.touchSwipeBind);
  9140. delete this.showControlsBind;
  9141. delete this.mouseDownBind;
  9142. delete this.mouseWheelBind;
  9143. delete this.resetMouseScrollStateBind;
  9144. delete this.contextMenuBind;
  9145. delete this.touchSwipeBind;
  9146. }
  9147. }, {
  9148. key: "_fullscreenChange",
  9149. value: function _fullscreenChange() {
  9150. if (this.isFullscreen) {
  9151. this._enter();
  9152. } else {
  9153. this._exit();
  9154. }
  9155. }
  9156. }, {
  9157. key: "_addFullscreenChangeListeners",
  9158. value: function _addFullscreenChangeListeners() {
  9159. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  9160. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  9161. window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  9162. window.addEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  9163. }
  9164. }, {
  9165. key: "_removeFullscreenChangeListeners",
  9166. value: function _removeFullscreenChangeListeners() {
  9167. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  9168. window.removeEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  9169. window.removeEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  9170. delete this.fullscreenChangeBind;
  9171. }
  9172. }, {
  9173. key: "isFullscreen",
  9174. get: function get() {
  9175. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen);
  9176. }
  9177. }]);
  9178. return PDFPresentationMode;
  9179. }();
  9180. exports.PDFPresentationMode = PDFPresentationMode;
  9181. /***/ }),
  9182. /* 24 */
  9183. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9184. Object.defineProperty(exports, "__esModule", ({
  9185. value: true
  9186. }));
  9187. exports.PDFSidebar = void 0;
  9188. var _ui_utils = __webpack_require__(6);
  9189. var _pdf_rendering_queue = __webpack_require__(10);
  9190. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9191. 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); } }
  9192. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9193. var UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  9194. var PDFSidebar = /*#__PURE__*/function () {
  9195. function PDFSidebar(_ref) {
  9196. var elements = _ref.elements,
  9197. pdfViewer = _ref.pdfViewer,
  9198. pdfThumbnailViewer = _ref.pdfThumbnailViewer,
  9199. eventBus = _ref.eventBus,
  9200. _ref$l10n = _ref.l10n,
  9201. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9202. _classCallCheck(this, PDFSidebar);
  9203. this.isOpen = false;
  9204. this.active = _ui_utils.SidebarView.THUMBS;
  9205. this.isInitialViewSet = false;
  9206. this.onToggled = null;
  9207. this.pdfViewer = pdfViewer;
  9208. this.pdfThumbnailViewer = pdfThumbnailViewer;
  9209. this.outerContainer = elements.outerContainer;
  9210. this.viewerContainer = elements.viewerContainer;
  9211. this.toggleButton = elements.toggleButton;
  9212. this.thumbnailButton = elements.thumbnailButton;
  9213. this.outlineButton = elements.outlineButton;
  9214. this.attachmentsButton = elements.attachmentsButton;
  9215. this.layersButton = elements.layersButton;
  9216. this.thumbnailView = elements.thumbnailView;
  9217. this.outlineView = elements.outlineView;
  9218. this.attachmentsView = elements.attachmentsView;
  9219. this.layersView = elements.layersView;
  9220. this._outlineOptionsContainer = elements.outlineOptionsContainer;
  9221. this._currentOutlineItemButton = elements.currentOutlineItemButton;
  9222. this.eventBus = eventBus;
  9223. this.l10n = l10n;
  9224. this._addEventListeners();
  9225. }
  9226. _createClass(PDFSidebar, [{
  9227. key: "reset",
  9228. value: function reset() {
  9229. this.isInitialViewSet = false;
  9230. this._hideUINotification(true);
  9231. this.switchView(_ui_utils.SidebarView.THUMBS);
  9232. this.outlineButton.disabled = false;
  9233. this.attachmentsButton.disabled = false;
  9234. this.layersButton.disabled = false;
  9235. this._currentOutlineItemButton.disabled = true;
  9236. }
  9237. }, {
  9238. key: "setInitialView",
  9239. value: function setInitialView() {
  9240. var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _ui_utils.SidebarView.NONE;
  9241. if (this.isInitialViewSet) {
  9242. return;
  9243. }
  9244. this.isInitialViewSet = true;
  9245. if (view === _ui_utils.SidebarView.NONE || view === _ui_utils.SidebarView.UNKNOWN) {
  9246. this._dispatchEvent();
  9247. return;
  9248. }
  9249. if (!this._switchView(view, true)) {
  9250. this._dispatchEvent();
  9251. }
  9252. }
  9253. }, {
  9254. key: "switchView",
  9255. value: function switchView(view) {
  9256. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9257. this._switchView(view, forceOpen);
  9258. }
  9259. }, {
  9260. key: "_switchView",
  9261. value: function _switchView(view) {
  9262. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9263. var isViewChanged = view !== this.active;
  9264. var shouldForceRendering = false;
  9265. switch (view) {
  9266. case _ui_utils.SidebarView.NONE:
  9267. if (this.isOpen) {
  9268. this.close();
  9269. return true;
  9270. }
  9271. return false;
  9272. case _ui_utils.SidebarView.THUMBS:
  9273. if (this.isOpen && isViewChanged) {
  9274. shouldForceRendering = true;
  9275. }
  9276. break;
  9277. case _ui_utils.SidebarView.OUTLINE:
  9278. if (this.outlineButton.disabled) {
  9279. return false;
  9280. }
  9281. break;
  9282. case _ui_utils.SidebarView.ATTACHMENTS:
  9283. if (this.attachmentsButton.disabled) {
  9284. return false;
  9285. }
  9286. break;
  9287. case _ui_utils.SidebarView.LAYERS:
  9288. if (this.layersButton.disabled) {
  9289. return false;
  9290. }
  9291. break;
  9292. default:
  9293. console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
  9294. return false;
  9295. }
  9296. this.active = view;
  9297. this.thumbnailButton.classList.toggle("toggled", view === _ui_utils.SidebarView.THUMBS);
  9298. this.outlineButton.classList.toggle("toggled", view === _ui_utils.SidebarView.OUTLINE);
  9299. this.attachmentsButton.classList.toggle("toggled", view === _ui_utils.SidebarView.ATTACHMENTS);
  9300. this.layersButton.classList.toggle("toggled", view === _ui_utils.SidebarView.LAYERS);
  9301. this.thumbnailView.classList.toggle("hidden", view !== _ui_utils.SidebarView.THUMBS);
  9302. this.outlineView.classList.toggle("hidden", view !== _ui_utils.SidebarView.OUTLINE);
  9303. this.attachmentsView.classList.toggle("hidden", view !== _ui_utils.SidebarView.ATTACHMENTS);
  9304. this.layersView.classList.toggle("hidden", view !== _ui_utils.SidebarView.LAYERS);
  9305. this._outlineOptionsContainer.classList.toggle("hidden", view !== _ui_utils.SidebarView.OUTLINE);
  9306. if (forceOpen && !this.isOpen) {
  9307. this.open();
  9308. return true;
  9309. }
  9310. if (shouldForceRendering) {
  9311. this._updateThumbnailViewer();
  9312. this._forceRendering();
  9313. }
  9314. if (isViewChanged) {
  9315. this._dispatchEvent();
  9316. }
  9317. return isViewChanged;
  9318. }
  9319. }, {
  9320. key: "open",
  9321. value: function open() {
  9322. if (this.isOpen) {
  9323. return;
  9324. }
  9325. this.isOpen = true;
  9326. this.toggleButton.classList.add("toggled");
  9327. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  9328. if (this.active === _ui_utils.SidebarView.THUMBS) {
  9329. this._updateThumbnailViewer();
  9330. }
  9331. this._forceRendering();
  9332. this._dispatchEvent();
  9333. this._hideUINotification();
  9334. }
  9335. }, {
  9336. key: "close",
  9337. value: function close() {
  9338. if (!this.isOpen) {
  9339. return;
  9340. }
  9341. this.isOpen = false;
  9342. this.toggleButton.classList.remove("toggled");
  9343. this.outerContainer.classList.add("sidebarMoving");
  9344. this.outerContainer.classList.remove("sidebarOpen");
  9345. this._forceRendering();
  9346. this._dispatchEvent();
  9347. }
  9348. }, {
  9349. key: "toggle",
  9350. value: function toggle() {
  9351. if (this.isOpen) {
  9352. this.close();
  9353. } else {
  9354. this.open();
  9355. }
  9356. }
  9357. }, {
  9358. key: "_dispatchEvent",
  9359. value: function _dispatchEvent() {
  9360. this.eventBus.dispatch("sidebarviewchanged", {
  9361. source: this,
  9362. view: this.visibleView
  9363. });
  9364. }
  9365. }, {
  9366. key: "_forceRendering",
  9367. value: function _forceRendering() {
  9368. if (this.onToggled) {
  9369. this.onToggled();
  9370. } else {
  9371. this.pdfViewer.forceRendering();
  9372. this.pdfThumbnailViewer.forceRendering();
  9373. }
  9374. }
  9375. }, {
  9376. key: "_updateThumbnailViewer",
  9377. value: function _updateThumbnailViewer() {
  9378. var pdfViewer = this.pdfViewer,
  9379. pdfThumbnailViewer = this.pdfThumbnailViewer;
  9380. var pagesCount = pdfViewer.pagesCount;
  9381. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  9382. var pageView = pdfViewer.getPageView(pageIndex);
  9383. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  9384. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  9385. thumbnailView.setImage(pageView);
  9386. }
  9387. }
  9388. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  9389. }
  9390. }, {
  9391. key: "_showUINotification",
  9392. value: function _showUINotification() {
  9393. var _this = this;
  9394. this.l10n.get("toggle_sidebar_notification2.title", null, "Toggle Sidebar (document contains outline/attachments/layers)").then(function (msg) {
  9395. _this.toggleButton.title = msg;
  9396. });
  9397. if (!this.isOpen) {
  9398. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  9399. }
  9400. }
  9401. }, {
  9402. key: "_hideUINotification",
  9403. value: function _hideUINotification() {
  9404. var _this2 = this;
  9405. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9406. if (this.isOpen || reset) {
  9407. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  9408. }
  9409. if (reset) {
  9410. this.l10n.get("toggle_sidebar.title", null, "Toggle Sidebar").then(function (msg) {
  9411. _this2.toggleButton.title = msg;
  9412. });
  9413. }
  9414. }
  9415. }, {
  9416. key: "_addEventListeners",
  9417. value: function _addEventListeners() {
  9418. var _this3 = this;
  9419. this.viewerContainer.addEventListener("transitionend", function (evt) {
  9420. if (evt.target === _this3.viewerContainer) {
  9421. _this3.outerContainer.classList.remove("sidebarMoving");
  9422. }
  9423. });
  9424. this.toggleButton.addEventListener("click", function () {
  9425. _this3.toggle();
  9426. });
  9427. this.thumbnailButton.addEventListener("click", function () {
  9428. _this3.switchView(_ui_utils.SidebarView.THUMBS);
  9429. });
  9430. this.outlineButton.addEventListener("click", function () {
  9431. _this3.switchView(_ui_utils.SidebarView.OUTLINE);
  9432. });
  9433. this.outlineButton.addEventListener("dblclick", function () {
  9434. _this3.eventBus.dispatch("toggleoutlinetree", {
  9435. source: _this3
  9436. });
  9437. });
  9438. this.attachmentsButton.addEventListener("click", function () {
  9439. _this3.switchView(_ui_utils.SidebarView.ATTACHMENTS);
  9440. });
  9441. this.layersButton.addEventListener("click", function () {
  9442. _this3.switchView(_ui_utils.SidebarView.LAYERS);
  9443. });
  9444. this.layersButton.addEventListener("dblclick", function () {
  9445. _this3.eventBus.dispatch("resetlayers", {
  9446. source: _this3
  9447. });
  9448. });
  9449. this._currentOutlineItemButton.addEventListener("click", function () {
  9450. _this3.eventBus.dispatch("currentoutlineitem", {
  9451. source: _this3
  9452. });
  9453. });
  9454. var onTreeLoaded = function onTreeLoaded(count, button, view) {
  9455. button.disabled = !count;
  9456. if (count) {
  9457. _this3._showUINotification();
  9458. } else if (_this3.active === view) {
  9459. _this3.switchView(_ui_utils.SidebarView.THUMBS);
  9460. }
  9461. };
  9462. this.eventBus._on("outlineloaded", function (evt) {
  9463. onTreeLoaded(evt.outlineCount, _this3.outlineButton, _ui_utils.SidebarView.OUTLINE);
  9464. if (evt.enableCurrentOutlineItemButton) {
  9465. _this3.pdfViewer.pagesPromise.then(function () {
  9466. _this3._currentOutlineItemButton.disabled = !_this3.isInitialViewSet;
  9467. });
  9468. }
  9469. });
  9470. this.eventBus._on("attachmentsloaded", function (evt) {
  9471. onTreeLoaded(evt.attachmentsCount, _this3.attachmentsButton, _ui_utils.SidebarView.ATTACHMENTS);
  9472. });
  9473. this.eventBus._on("layersloaded", function (evt) {
  9474. onTreeLoaded(evt.layersCount, _this3.layersButton, _ui_utils.SidebarView.LAYERS);
  9475. });
  9476. this.eventBus._on("presentationmodechanged", function (evt) {
  9477. if (evt.state === _ui_utils.PresentationModeState.NORMAL && _this3.isThumbnailViewVisible) {
  9478. _this3._updateThumbnailViewer();
  9479. }
  9480. });
  9481. }
  9482. }, {
  9483. key: "visibleView",
  9484. get: function get() {
  9485. return this.isOpen ? this.active : _ui_utils.SidebarView.NONE;
  9486. }
  9487. }, {
  9488. key: "isThumbnailViewVisible",
  9489. get: function get() {
  9490. return this.isOpen && this.active === _ui_utils.SidebarView.THUMBS;
  9491. }
  9492. }, {
  9493. key: "isOutlineViewVisible",
  9494. get: function get() {
  9495. return this.isOpen && this.active === _ui_utils.SidebarView.OUTLINE;
  9496. }
  9497. }, {
  9498. key: "isAttachmentsViewVisible",
  9499. get: function get() {
  9500. return this.isOpen && this.active === _ui_utils.SidebarView.ATTACHMENTS;
  9501. }
  9502. }, {
  9503. key: "isLayersViewVisible",
  9504. get: function get() {
  9505. return this.isOpen && this.active === _ui_utils.SidebarView.LAYERS;
  9506. }
  9507. }]);
  9508. return PDFSidebar;
  9509. }();
  9510. exports.PDFSidebar = PDFSidebar;
  9511. /***/ }),
  9512. /* 25 */
  9513. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9514. Object.defineProperty(exports, "__esModule", ({
  9515. value: true
  9516. }));
  9517. exports.PDFSidebarResizer = void 0;
  9518. var _ui_utils = __webpack_require__(6);
  9519. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9520. 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); } }
  9521. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9522. var SIDEBAR_WIDTH_VAR = "--sidebar-width";
  9523. var SIDEBAR_MIN_WIDTH = 200;
  9524. var SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  9525. var PDFSidebarResizer = /*#__PURE__*/function () {
  9526. function PDFSidebarResizer(options, eventBus) {
  9527. var _this = this;
  9528. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  9529. _classCallCheck(this, PDFSidebarResizer);
  9530. this.isRTL = false;
  9531. this.sidebarOpen = false;
  9532. this.doc = document.documentElement;
  9533. this._width = null;
  9534. this._outerContainerWidth = null;
  9535. this._boundEvents = Object.create(null);
  9536. this.outerContainer = options.outerContainer;
  9537. this.resizer = options.resizer;
  9538. this.eventBus = eventBus;
  9539. l10n.getDirection().then(function (dir) {
  9540. _this.isRTL = dir === "rtl";
  9541. });
  9542. this._addEventListeners();
  9543. }
  9544. _createClass(PDFSidebarResizer, [{
  9545. key: "_updateWidth",
  9546. value: function _updateWidth() {
  9547. var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  9548. var maxWidth = Math.floor(this.outerContainerWidth / 2);
  9549. if (width > maxWidth) {
  9550. width = maxWidth;
  9551. }
  9552. if (width < SIDEBAR_MIN_WIDTH) {
  9553. width = SIDEBAR_MIN_WIDTH;
  9554. }
  9555. if (width === this._width) {
  9556. return false;
  9557. }
  9558. this._width = width;
  9559. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(width, "px"));
  9560. return true;
  9561. }
  9562. }, {
  9563. key: "_mouseMove",
  9564. value: function _mouseMove(evt) {
  9565. var width = evt.clientX;
  9566. if (this.isRTL) {
  9567. width = this.outerContainerWidth - width;
  9568. }
  9569. this._updateWidth(width);
  9570. }
  9571. }, {
  9572. key: "_mouseUp",
  9573. value: function _mouseUp(evt) {
  9574. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  9575. this.eventBus.dispatch("resize", {
  9576. source: this
  9577. });
  9578. var _boundEvents = this._boundEvents;
  9579. window.removeEventListener("mousemove", _boundEvents.mouseMove);
  9580. window.removeEventListener("mouseup", _boundEvents.mouseUp);
  9581. }
  9582. }, {
  9583. key: "_addEventListeners",
  9584. value: function _addEventListeners() {
  9585. var _this2 = this;
  9586. var _boundEvents = this._boundEvents;
  9587. _boundEvents.mouseMove = this._mouseMove.bind(this);
  9588. _boundEvents.mouseUp = this._mouseUp.bind(this);
  9589. this.resizer.addEventListener("mousedown", function (evt) {
  9590. if (evt.button !== 0) {
  9591. return;
  9592. }
  9593. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  9594. window.addEventListener("mousemove", _boundEvents.mouseMove);
  9595. window.addEventListener("mouseup", _boundEvents.mouseUp);
  9596. });
  9597. this.eventBus._on("sidebarviewchanged", function (evt) {
  9598. _this2.sidebarOpen = !!(evt && evt.view);
  9599. });
  9600. this.eventBus._on("resize", function (evt) {
  9601. if (!evt || evt.source !== window) {
  9602. return;
  9603. }
  9604. _this2._outerContainerWidth = null;
  9605. if (!_this2._width) {
  9606. return;
  9607. }
  9608. if (!_this2.sidebarOpen) {
  9609. _this2._updateWidth(_this2._width);
  9610. return;
  9611. }
  9612. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  9613. var updated = _this2._updateWidth(_this2._width);
  9614. Promise.resolve().then(function () {
  9615. _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  9616. if (updated) {
  9617. _this2.eventBus.dispatch("resize", {
  9618. source: _this2
  9619. });
  9620. }
  9621. });
  9622. });
  9623. }
  9624. }, {
  9625. key: "outerContainerWidth",
  9626. get: function get() {
  9627. if (!this._outerContainerWidth) {
  9628. this._outerContainerWidth = this.outerContainer.clientWidth;
  9629. }
  9630. return this._outerContainerWidth;
  9631. }
  9632. }]);
  9633. return PDFSidebarResizer;
  9634. }();
  9635. exports.PDFSidebarResizer = PDFSidebarResizer;
  9636. /***/ }),
  9637. /* 26 */
  9638. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9639. Object.defineProperty(exports, "__esModule", ({
  9640. value: true
  9641. }));
  9642. exports.PDFThumbnailViewer = void 0;
  9643. var _ui_utils = __webpack_require__(6);
  9644. var _pdf_thumbnail_view = __webpack_require__(27);
  9645. var _pdf_rendering_queue = __webpack_require__(10);
  9646. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9647. 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); } }
  9648. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9649. var THUMBNAIL_SCROLL_MARGIN = -19;
  9650. var THUMBNAIL_SELECTED_CLASS = "selected";
  9651. var PDFThumbnailViewer = /*#__PURE__*/function () {
  9652. function PDFThumbnailViewer(_ref) {
  9653. var _this = this;
  9654. var container = _ref.container,
  9655. eventBus = _ref.eventBus,
  9656. linkService = _ref.linkService,
  9657. renderingQueue = _ref.renderingQueue,
  9658. _ref$l10n = _ref.l10n,
  9659. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9660. _classCallCheck(this, PDFThumbnailViewer);
  9661. this.container = container;
  9662. this.linkService = linkService;
  9663. this.renderingQueue = renderingQueue;
  9664. this.l10n = l10n;
  9665. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  9666. this._resetView();
  9667. eventBus._on("optionalcontentconfigchanged", function () {
  9668. _this._setImageDisabled = true;
  9669. });
  9670. }
  9671. _createClass(PDFThumbnailViewer, [{
  9672. key: "_scrollUpdated",
  9673. value: function _scrollUpdated() {
  9674. this.renderingQueue.renderHighestPriority();
  9675. }
  9676. }, {
  9677. key: "getThumbnail",
  9678. value: function getThumbnail(index) {
  9679. return this._thumbnails[index];
  9680. }
  9681. }, {
  9682. key: "_getVisibleThumbs",
  9683. value: function _getVisibleThumbs() {
  9684. return (0, _ui_utils.getVisibleElements)({
  9685. scrollEl: this.container,
  9686. views: this._thumbnails
  9687. });
  9688. }
  9689. }, {
  9690. key: "scrollThumbnailIntoView",
  9691. value: function scrollThumbnailIntoView(pageNumber) {
  9692. if (!this.pdfDocument) {
  9693. return;
  9694. }
  9695. var thumbnailView = this._thumbnails[pageNumber - 1];
  9696. if (!thumbnailView) {
  9697. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  9698. return;
  9699. }
  9700. if (pageNumber !== this._currentPageNumber) {
  9701. var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  9702. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  9703. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  9704. }
  9705. var visibleThumbs = this._getVisibleThumbs();
  9706. var numVisibleThumbs = visibleThumbs.views.length;
  9707. if (numVisibleThumbs > 0) {
  9708. var first = visibleThumbs.first.id;
  9709. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  9710. var shouldScroll = false;
  9711. if (pageNumber <= first || pageNumber >= last) {
  9712. shouldScroll = true;
  9713. } else {
  9714. visibleThumbs.views.some(function (view) {
  9715. if (view.id !== pageNumber) {
  9716. return false;
  9717. }
  9718. shouldScroll = view.percent < 100;
  9719. return true;
  9720. });
  9721. }
  9722. if (shouldScroll) {
  9723. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  9724. top: THUMBNAIL_SCROLL_MARGIN
  9725. });
  9726. }
  9727. }
  9728. this._currentPageNumber = pageNumber;
  9729. }
  9730. }, {
  9731. key: "cleanup",
  9732. value: function cleanup() {
  9733. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9734. if (this._thumbnails[i] && this._thumbnails[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9735. this._thumbnails[i].reset();
  9736. }
  9737. }
  9738. _pdf_thumbnail_view.TempImageFactory.destroyCanvas();
  9739. }
  9740. }, {
  9741. key: "_resetView",
  9742. value: function _resetView() {
  9743. this._thumbnails = [];
  9744. this._currentPageNumber = 1;
  9745. this._pageLabels = null;
  9746. this._pagesRotation = 0;
  9747. this._optionalContentConfigPromise = null;
  9748. this._pagesRequests = new WeakMap();
  9749. this._setImageDisabled = false;
  9750. this.container.textContent = "";
  9751. }
  9752. }, {
  9753. key: "setDocument",
  9754. value: function setDocument(pdfDocument) {
  9755. var _this2 = this;
  9756. if (this.pdfDocument) {
  9757. this._cancelRendering();
  9758. this._resetView();
  9759. }
  9760. this.pdfDocument = pdfDocument;
  9761. if (!pdfDocument) {
  9762. return;
  9763. }
  9764. var firstPagePromise = pdfDocument.getPage(1);
  9765. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  9766. firstPagePromise.then(function (firstPdfPage) {
  9767. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  9768. var pagesCount = pdfDocument.numPages;
  9769. var viewport = firstPdfPage.getViewport({
  9770. scale: 1
  9771. });
  9772. var checkSetImageDisabled = function checkSetImageDisabled() {
  9773. return _this2._setImageDisabled;
  9774. };
  9775. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  9776. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  9777. container: _this2.container,
  9778. id: pageNum,
  9779. defaultViewport: viewport.clone(),
  9780. optionalContentConfigPromise: optionalContentConfigPromise,
  9781. linkService: _this2.linkService,
  9782. renderingQueue: _this2.renderingQueue,
  9783. checkSetImageDisabled: checkSetImageDisabled,
  9784. disableCanvasToImageConversion: false,
  9785. l10n: _this2.l10n
  9786. });
  9787. _this2._thumbnails.push(thumbnail);
  9788. }
  9789. var firstThumbnailView = _this2._thumbnails[0];
  9790. if (firstThumbnailView) {
  9791. firstThumbnailView.setPdfPage(firstPdfPage);
  9792. }
  9793. var thumbnailView = _this2._thumbnails[_this2._currentPageNumber - 1];
  9794. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  9795. })["catch"](function (reason) {
  9796. console.error("Unable to initialize thumbnail viewer", reason);
  9797. });
  9798. }
  9799. }, {
  9800. key: "_cancelRendering",
  9801. value: function _cancelRendering() {
  9802. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9803. if (this._thumbnails[i]) {
  9804. this._thumbnails[i].cancelRendering();
  9805. }
  9806. }
  9807. }
  9808. }, {
  9809. key: "setPageLabels",
  9810. value: function setPageLabels(labels) {
  9811. if (!this.pdfDocument) {
  9812. return;
  9813. }
  9814. if (!labels) {
  9815. this._pageLabels = null;
  9816. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  9817. this._pageLabels = null;
  9818. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  9819. } else {
  9820. this._pageLabels = labels;
  9821. }
  9822. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9823. var label = this._pageLabels && this._pageLabels[i];
  9824. this._thumbnails[i].setPageLabel(label);
  9825. }
  9826. }
  9827. }, {
  9828. key: "_ensurePdfPageLoaded",
  9829. value: function _ensurePdfPageLoaded(thumbView) {
  9830. var _this3 = this;
  9831. if (thumbView.pdfPage) {
  9832. return Promise.resolve(thumbView.pdfPage);
  9833. }
  9834. if (this._pagesRequests.has(thumbView)) {
  9835. return this._pagesRequests.get(thumbView);
  9836. }
  9837. var promise = this.pdfDocument.getPage(thumbView.id).then(function (pdfPage) {
  9838. if (!thumbView.pdfPage) {
  9839. thumbView.setPdfPage(pdfPage);
  9840. }
  9841. _this3._pagesRequests["delete"](thumbView);
  9842. return pdfPage;
  9843. })["catch"](function (reason) {
  9844. console.error("Unable to get page for thumb view", reason);
  9845. _this3._pagesRequests["delete"](thumbView);
  9846. });
  9847. this._pagesRequests.set(thumbView, promise);
  9848. return promise;
  9849. }
  9850. }, {
  9851. key: "forceRendering",
  9852. value: function forceRendering() {
  9853. var _this4 = this;
  9854. var visibleThumbs = this._getVisibleThumbs();
  9855. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  9856. if (thumbView) {
  9857. this._ensurePdfPageLoaded(thumbView).then(function () {
  9858. _this4.renderingQueue.renderView(thumbView);
  9859. });
  9860. return true;
  9861. }
  9862. return false;
  9863. }
  9864. }, {
  9865. key: "pagesRotation",
  9866. get: function get() {
  9867. return this._pagesRotation;
  9868. },
  9869. set: function set(rotation) {
  9870. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  9871. throw new Error("Invalid thumbnails rotation angle.");
  9872. }
  9873. if (!this.pdfDocument) {
  9874. return;
  9875. }
  9876. if (this._pagesRotation === rotation) {
  9877. return;
  9878. }
  9879. this._pagesRotation = rotation;
  9880. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9881. this._thumbnails[i].update(rotation);
  9882. }
  9883. }
  9884. }]);
  9885. return PDFThumbnailViewer;
  9886. }();
  9887. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  9888. /***/ }),
  9889. /* 27 */
  9890. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9891. Object.defineProperty(exports, "__esModule", ({
  9892. value: true
  9893. }));
  9894. exports.TempImageFactory = exports.PDFThumbnailView = void 0;
  9895. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  9896. var _ui_utils = __webpack_require__(6);
  9897. var _pdfjsLib = __webpack_require__(7);
  9898. var _pdf_rendering_queue = __webpack_require__(10);
  9899. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9900. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  9901. 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."); }
  9902. 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); }
  9903. 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; }
  9904. 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; }
  9905. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  9906. 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); } }
  9907. 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); }); }; }
  9908. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9909. 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); } }
  9910. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9911. var MAX_NUM_SCALING_STEPS = 3;
  9912. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  9913. var THUMBNAIL_WIDTH = 98;
  9914. var TempImageFactory = function TempImageFactoryClosure() {
  9915. var tempCanvasCache = null;
  9916. return {
  9917. getCanvas: function getCanvas(width, height) {
  9918. var tempCanvas = tempCanvasCache;
  9919. if (!tempCanvas) {
  9920. tempCanvas = document.createElement("canvas");
  9921. tempCanvasCache = tempCanvas;
  9922. }
  9923. tempCanvas.width = width;
  9924. tempCanvas.height = height;
  9925. tempCanvas.mozOpaque = true;
  9926. var ctx = tempCanvas.getContext("2d", {
  9927. alpha: false
  9928. });
  9929. ctx.save();
  9930. ctx.fillStyle = "rgb(255, 255, 255)";
  9931. ctx.fillRect(0, 0, width, height);
  9932. ctx.restore();
  9933. return tempCanvas;
  9934. },
  9935. destroyCanvas: function destroyCanvas() {
  9936. var tempCanvas = tempCanvasCache;
  9937. if (tempCanvas) {
  9938. tempCanvas.width = 0;
  9939. tempCanvas.height = 0;
  9940. }
  9941. tempCanvasCache = null;
  9942. }
  9943. };
  9944. }();
  9945. exports.TempImageFactory = TempImageFactory;
  9946. var PDFThumbnailView = /*#__PURE__*/function () {
  9947. function PDFThumbnailView(_ref) {
  9948. var container = _ref.container,
  9949. id = _ref.id,
  9950. defaultViewport = _ref.defaultViewport,
  9951. optionalContentConfigPromise = _ref.optionalContentConfigPromise,
  9952. linkService = _ref.linkService,
  9953. renderingQueue = _ref.renderingQueue,
  9954. checkSetImageDisabled = _ref.checkSetImageDisabled,
  9955. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  9956. disableCanvasToImageConversion = _ref$disableCanvasToI === void 0 ? false : _ref$disableCanvasToI,
  9957. _ref$l10n = _ref.l10n,
  9958. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9959. _classCallCheck(this, PDFThumbnailView);
  9960. this.id = id;
  9961. this.renderingId = "thumbnail" + id;
  9962. this.pageLabel = null;
  9963. this.pdfPage = null;
  9964. this.rotation = 0;
  9965. this.viewport = defaultViewport;
  9966. this.pdfPageRotate = defaultViewport.rotation;
  9967. this._optionalContentConfigPromise = optionalContentConfigPromise || null;
  9968. this.linkService = linkService;
  9969. this.renderingQueue = renderingQueue;
  9970. this.renderTask = null;
  9971. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9972. this.resume = null;
  9973. this._checkSetImageDisabled = checkSetImageDisabled || function () {
  9974. return false;
  9975. };
  9976. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  9977. this.pageWidth = this.viewport.width;
  9978. this.pageHeight = this.viewport.height;
  9979. this.pageRatio = this.pageWidth / this.pageHeight;
  9980. this.canvasWidth = THUMBNAIL_WIDTH;
  9981. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  9982. this.scale = this.canvasWidth / this.pageWidth;
  9983. this.l10n = l10n;
  9984. var anchor = document.createElement("a");
  9985. anchor.href = linkService.getAnchorUrl("#page=" + id);
  9986. this._thumbPageTitle.then(function (msg) {
  9987. anchor.title = msg;
  9988. });
  9989. anchor.onclick = function () {
  9990. linkService.goToPage(id);
  9991. return false;
  9992. };
  9993. this.anchor = anchor;
  9994. var div = document.createElement("div");
  9995. div.className = "thumbnail";
  9996. div.setAttribute("data-page-number", this.id);
  9997. this.div = div;
  9998. var ring = document.createElement("div");
  9999. ring.className = "thumbnailSelectionRing";
  10000. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  10001. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  10002. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  10003. this.ring = ring;
  10004. div.appendChild(ring);
  10005. anchor.appendChild(div);
  10006. container.appendChild(anchor);
  10007. }
  10008. _createClass(PDFThumbnailView, [{
  10009. key: "setPdfPage",
  10010. value: function setPdfPage(pdfPage) {
  10011. this.pdfPage = pdfPage;
  10012. this.pdfPageRotate = pdfPage.rotate;
  10013. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10014. this.viewport = pdfPage.getViewport({
  10015. scale: 1,
  10016. rotation: totalRotation
  10017. });
  10018. this.reset();
  10019. }
  10020. }, {
  10021. key: "reset",
  10022. value: function reset() {
  10023. this.cancelRendering();
  10024. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  10025. this.pageWidth = this.viewport.width;
  10026. this.pageHeight = this.viewport.height;
  10027. this.pageRatio = this.pageWidth / this.pageHeight;
  10028. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  10029. this.scale = this.canvasWidth / this.pageWidth;
  10030. this.div.removeAttribute("data-loaded");
  10031. var ring = this.ring;
  10032. var childNodes = ring.childNodes;
  10033. for (var i = childNodes.length - 1; i >= 0; i--) {
  10034. ring.removeChild(childNodes[i]);
  10035. }
  10036. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  10037. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  10038. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  10039. if (this.canvas) {
  10040. this.canvas.width = 0;
  10041. this.canvas.height = 0;
  10042. delete this.canvas;
  10043. }
  10044. if (this.image) {
  10045. this.image.removeAttribute("src");
  10046. delete this.image;
  10047. }
  10048. }
  10049. }, {
  10050. key: "update",
  10051. value: function update(rotation) {
  10052. if (typeof rotation !== "undefined") {
  10053. this.rotation = rotation;
  10054. }
  10055. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10056. this.viewport = this.viewport.clone({
  10057. scale: 1,
  10058. rotation: totalRotation
  10059. });
  10060. this.reset();
  10061. }
  10062. }, {
  10063. key: "cancelRendering",
  10064. value: function cancelRendering() {
  10065. if (this.renderTask) {
  10066. this.renderTask.cancel();
  10067. this.renderTask = null;
  10068. }
  10069. this.resume = null;
  10070. }
  10071. }, {
  10072. key: "_getPageDrawContext",
  10073. value: function _getPageDrawContext() {
  10074. var canvas = document.createElement("canvas");
  10075. this.canvas = canvas;
  10076. canvas.mozOpaque = true;
  10077. var ctx = canvas.getContext("2d", {
  10078. alpha: false
  10079. });
  10080. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  10081. canvas.width = this.canvasWidth * outputScale.sx | 0;
  10082. canvas.height = this.canvasHeight * outputScale.sy | 0;
  10083. canvas.style.width = this.canvasWidth + "px";
  10084. canvas.style.height = this.canvasHeight + "px";
  10085. var transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  10086. return [ctx, transform];
  10087. }
  10088. }, {
  10089. key: "_convertCanvasToImage",
  10090. value: function _convertCanvasToImage() {
  10091. var _this = this;
  10092. if (!this.canvas) {
  10093. return;
  10094. }
  10095. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  10096. return;
  10097. }
  10098. var className = "thumbnailImage";
  10099. if (this.disableCanvasToImageConversion) {
  10100. this.canvas.className = className;
  10101. this._thumbPageCanvas.then(function (msg) {
  10102. _this.canvas.setAttribute("aria-label", msg);
  10103. });
  10104. this.div.setAttribute("data-loaded", true);
  10105. this.ring.appendChild(this.canvas);
  10106. return;
  10107. }
  10108. var image = document.createElement("img");
  10109. image.className = className;
  10110. this._thumbPageCanvas.then(function (msg) {
  10111. image.setAttribute("aria-label", msg);
  10112. });
  10113. image.style.width = this.canvasWidth + "px";
  10114. image.style.height = this.canvasHeight + "px";
  10115. image.src = this.canvas.toDataURL();
  10116. this.image = image;
  10117. this.div.setAttribute("data-loaded", true);
  10118. this.ring.appendChild(image);
  10119. this.canvas.width = 0;
  10120. this.canvas.height = 0;
  10121. delete this.canvas;
  10122. }
  10123. }, {
  10124. key: "draw",
  10125. value: function draw() {
  10126. var _this2 = this;
  10127. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  10128. console.error("Must be in new state before drawing");
  10129. return Promise.resolve(undefined);
  10130. }
  10131. var pdfPage = this.pdfPage;
  10132. if (!pdfPage) {
  10133. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10134. return Promise.reject(new Error("pdfPage is not loaded"));
  10135. }
  10136. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10137. var finishRenderTask = /*#__PURE__*/function () {
  10138. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  10139. var error,
  10140. _args = arguments;
  10141. return _regenerator["default"].wrap(function _callee$(_context) {
  10142. while (1) {
  10143. switch (_context.prev = _context.next) {
  10144. case 0:
  10145. error = _args.length > 0 && _args[0] !== undefined ? _args[0] : null;
  10146. if (renderTask === _this2.renderTask) {
  10147. _this2.renderTask = null;
  10148. }
  10149. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  10150. _context.next = 4;
  10151. break;
  10152. }
  10153. return _context.abrupt("return");
  10154. case 4:
  10155. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10156. _this2._convertCanvasToImage();
  10157. if (!error) {
  10158. _context.next = 8;
  10159. break;
  10160. }
  10161. throw error;
  10162. case 8:
  10163. case "end":
  10164. return _context.stop();
  10165. }
  10166. }
  10167. }, _callee);
  10168. }));
  10169. return function finishRenderTask() {
  10170. return _ref2.apply(this, arguments);
  10171. };
  10172. }();
  10173. var _this$_getPageDrawCon = this._getPageDrawContext(),
  10174. _this$_getPageDrawCon2 = _slicedToArray(_this$_getPageDrawCon, 2),
  10175. ctx = _this$_getPageDrawCon2[0],
  10176. transform = _this$_getPageDrawCon2[1];
  10177. var drawViewport = this.viewport.clone({
  10178. scale: this.scale
  10179. });
  10180. var renderContinueCallback = function renderContinueCallback(cont) {
  10181. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  10182. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  10183. _this2.resume = function () {
  10184. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10185. cont();
  10186. };
  10187. return;
  10188. }
  10189. cont();
  10190. };
  10191. var renderContext = {
  10192. canvasContext: ctx,
  10193. transform: transform,
  10194. viewport: drawViewport,
  10195. optionalContentConfigPromise: this._optionalContentConfigPromise
  10196. };
  10197. var renderTask = this.renderTask = pdfPage.render(renderContext);
  10198. renderTask.onContinue = renderContinueCallback;
  10199. var resultPromise = renderTask.promise.then(function () {
  10200. finishRenderTask(null);
  10201. }, function (error) {
  10202. finishRenderTask(error);
  10203. });
  10204. resultPromise["finally"](function () {
  10205. var _this2$pdfPage;
  10206. var pageCached = _this2.linkService.isPageCached(_this2.id);
  10207. if (pageCached) {
  10208. return;
  10209. }
  10210. (_this2$pdfPage = _this2.pdfPage) === null || _this2$pdfPage === void 0 ? void 0 : _this2$pdfPage.cleanup();
  10211. });
  10212. return resultPromise;
  10213. }
  10214. }, {
  10215. key: "setImage",
  10216. value: function setImage(pageView) {
  10217. if (this._checkSetImageDisabled()) {
  10218. return;
  10219. }
  10220. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  10221. return;
  10222. }
  10223. var img = pageView.canvas;
  10224. if (!img) {
  10225. return;
  10226. }
  10227. if (!this.pdfPage) {
  10228. this.setPdfPage(pageView.pdfPage);
  10229. }
  10230. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10231. var _this$_getPageDrawCon3 = this._getPageDrawContext(),
  10232. _this$_getPageDrawCon4 = _slicedToArray(_this$_getPageDrawCon3, 1),
  10233. ctx = _this$_getPageDrawCon4[0];
  10234. var canvas = ctx.canvas;
  10235. if (img.width <= 2 * canvas.width) {
  10236. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  10237. this._convertCanvasToImage();
  10238. return;
  10239. }
  10240. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  10241. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  10242. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  10243. var reducedImageCtx = reducedImage.getContext("2d");
  10244. while (reducedWidth > img.width || reducedHeight > img.height) {
  10245. reducedWidth >>= 1;
  10246. reducedHeight >>= 1;
  10247. }
  10248. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  10249. while (reducedWidth > 2 * canvas.width) {
  10250. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  10251. reducedWidth >>= 1;
  10252. reducedHeight >>= 1;
  10253. }
  10254. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  10255. this._convertCanvasToImage();
  10256. }
  10257. }, {
  10258. key: "setPageLabel",
  10259. value: function setPageLabel(label) {
  10260. var _this3 = this;
  10261. this.pageLabel = typeof label === "string" ? label : null;
  10262. this._thumbPageTitle.then(function (msg) {
  10263. _this3.anchor.title = msg;
  10264. });
  10265. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  10266. return;
  10267. }
  10268. this._thumbPageCanvas.then(function (msg) {
  10269. if (_this3.image) {
  10270. _this3.image.setAttribute("aria-label", msg);
  10271. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  10272. _this3.canvas.setAttribute("aria-label", msg);
  10273. }
  10274. });
  10275. }
  10276. }, {
  10277. key: "_thumbPageTitle",
  10278. get: function get() {
  10279. var _this$pageLabel;
  10280. return this.l10n.get("thumb_page_title", {
  10281. page: (_this$pageLabel = this.pageLabel) !== null && _this$pageLabel !== void 0 ? _this$pageLabel : this.id
  10282. }, "Page {{page}}");
  10283. }
  10284. }, {
  10285. key: "_thumbPageCanvas",
  10286. get: function get() {
  10287. var _this$pageLabel2;
  10288. return this.l10n.get("thumb_page_canvas", {
  10289. page: (_this$pageLabel2 = this.pageLabel) !== null && _this$pageLabel2 !== void 0 ? _this$pageLabel2 : this.id
  10290. }, "Thumbnail of Page {{page}}");
  10291. }
  10292. }]);
  10293. return PDFThumbnailView;
  10294. }();
  10295. exports.PDFThumbnailView = PDFThumbnailView;
  10296. /***/ }),
  10297. /* 28 */
  10298. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10299. 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); }
  10300. Object.defineProperty(exports, "__esModule", ({
  10301. value: true
  10302. }));
  10303. exports.PDFViewer = void 0;
  10304. var _ui_utils = __webpack_require__(6);
  10305. var _base_viewer = __webpack_require__(29);
  10306. var _pdfjsLib = __webpack_require__(7);
  10307. 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; } } }; }
  10308. 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); }
  10309. 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; }
  10310. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10311. 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); } }
  10312. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10313. 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); }
  10314. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  10315. 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); }
  10316. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10317. 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); }; }
  10318. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10319. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10320. 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; } }
  10321. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10322. var PDFViewer = /*#__PURE__*/function (_BaseViewer) {
  10323. _inherits(PDFViewer, _BaseViewer);
  10324. var _super = _createSuper(PDFViewer);
  10325. function PDFViewer() {
  10326. _classCallCheck(this, PDFViewer);
  10327. return _super.apply(this, arguments);
  10328. }
  10329. _createClass(PDFViewer, [{
  10330. key: "_scrollIntoView",
  10331. value: function _scrollIntoView(_ref) {
  10332. var pageDiv = _ref.pageDiv,
  10333. _ref$pageSpot = _ref.pageSpot,
  10334. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  10335. _ref$pageNumber = _ref.pageNumber,
  10336. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  10337. if (!pageSpot && !this.isInPresentationMode) {
  10338. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  10339. var right = left + pageDiv.clientWidth;
  10340. var _this$container = this.container,
  10341. scrollLeft = _this$container.scrollLeft,
  10342. clientWidth = _this$container.clientWidth;
  10343. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  10344. pageSpot = {
  10345. left: 0,
  10346. top: 0
  10347. };
  10348. }
  10349. }
  10350. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  10351. pageDiv: pageDiv,
  10352. pageSpot: pageSpot,
  10353. pageNumber: pageNumber
  10354. });
  10355. }
  10356. }, {
  10357. key: "_getVisiblePages",
  10358. value: function _getVisiblePages() {
  10359. if (this.isInPresentationMode) {
  10360. return this._getCurrentVisiblePage();
  10361. }
  10362. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  10363. }
  10364. }, {
  10365. key: "_updateHelper",
  10366. value: function _updateHelper(visiblePages) {
  10367. if (this.isInPresentationMode) {
  10368. return;
  10369. }
  10370. var currentId = this._currentPageNumber;
  10371. var stillFullyVisible = false;
  10372. var _iterator = _createForOfIteratorHelper(visiblePages),
  10373. _step;
  10374. try {
  10375. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  10376. var page = _step.value;
  10377. if (page.percent < 100) {
  10378. break;
  10379. }
  10380. if (page.id === currentId && this._scrollMode === _ui_utils.ScrollMode.VERTICAL && this._spreadMode === _ui_utils.SpreadMode.NONE) {
  10381. stillFullyVisible = true;
  10382. break;
  10383. }
  10384. }
  10385. } catch (err) {
  10386. _iterator.e(err);
  10387. } finally {
  10388. _iterator.f();
  10389. }
  10390. if (!stillFullyVisible) {
  10391. currentId = visiblePages[0].id;
  10392. }
  10393. this._setCurrentPageNumber(currentId);
  10394. }
  10395. }, {
  10396. key: "_viewerElement",
  10397. get: function get() {
  10398. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this.viewer);
  10399. }
  10400. }]);
  10401. return PDFViewer;
  10402. }(_base_viewer.BaseViewer);
  10403. exports.PDFViewer = PDFViewer;
  10404. /***/ }),
  10405. /* 29 */
  10406. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10407. Object.defineProperty(exports, "__esModule", ({
  10408. value: true
  10409. }));
  10410. exports.BaseViewer = void 0;
  10411. var _pdfjsLib = __webpack_require__(7);
  10412. var _ui_utils = __webpack_require__(6);
  10413. var _pdf_rendering_queue = __webpack_require__(10);
  10414. var _annotation_layer_builder = __webpack_require__(30);
  10415. var _pdf_page_view = __webpack_require__(31);
  10416. var _pdf_link_service = __webpack_require__(21);
  10417. var _text_layer_builder = __webpack_require__(32);
  10418. 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; } } }; }
  10419. 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); }
  10420. 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; }
  10421. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10422. 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); } }
  10423. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10424. var DEFAULT_CACHE_SIZE = 10;
  10425. function PDFPageViewBuffer(size) {
  10426. var data = [];
  10427. this.push = function (view) {
  10428. var i = data.indexOf(view);
  10429. if (i >= 0) {
  10430. data.splice(i, 1);
  10431. }
  10432. data.push(view);
  10433. if (data.length > size) {
  10434. data.shift().destroy();
  10435. }
  10436. };
  10437. this.resize = function (newSize, pagesToKeep) {
  10438. size = newSize;
  10439. if (pagesToKeep) {
  10440. var pageIdsToKeep = new Set();
  10441. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  10442. pageIdsToKeep.add(pagesToKeep[i].id);
  10443. }
  10444. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  10445. return pageIdsToKeep.has(page.id);
  10446. });
  10447. }
  10448. while (data.length > size) {
  10449. data.shift().destroy();
  10450. }
  10451. };
  10452. this.has = function (view) {
  10453. return data.includes(view);
  10454. };
  10455. }
  10456. function isSameScale(oldScale, newScale) {
  10457. if (newScale === oldScale) {
  10458. return true;
  10459. }
  10460. if (Math.abs(newScale - oldScale) < 1e-15) {
  10461. return true;
  10462. }
  10463. return false;
  10464. }
  10465. var BaseViewer = /*#__PURE__*/function () {
  10466. function BaseViewer(options) {
  10467. var _this$container,
  10468. _this$viewer,
  10469. _this = this;
  10470. _classCallCheck(this, BaseViewer);
  10471. if (this.constructor === BaseViewer) {
  10472. throw new Error("Cannot initialize BaseViewer.");
  10473. }
  10474. var viewerVersion = '2.7.570';
  10475. if (_pdfjsLib.version !== viewerVersion) {
  10476. throw new Error("The API version \"".concat(_pdfjsLib.version, "\" does not match the Viewer version \"").concat(viewerVersion, "\"."));
  10477. }
  10478. this._name = this.constructor.name;
  10479. this.container = options.container;
  10480. this.viewer = options.viewer || options.container.firstElementChild;
  10481. if (!(((_this$container = this.container) === null || _this$container === void 0 ? void 0 : _this$container.tagName.toUpperCase()) === "DIV" && ((_this$viewer = this.viewer) === null || _this$viewer === void 0 ? void 0 : _this$viewer.tagName.toUpperCase()) === "DIV")) {
  10482. throw new Error("Invalid `container` and/or `viewer` option.");
  10483. }
  10484. if (getComputedStyle(this.container).position !== "absolute") {
  10485. throw new Error("The `container` must be absolutely positioned.");
  10486. }
  10487. this.eventBus = options.eventBus;
  10488. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  10489. this.downloadManager = options.downloadManager || null;
  10490. this.findController = options.findController || null;
  10491. this.removePageBorders = options.removePageBorders || false;
  10492. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  10493. this.imageResourcesPath = options.imageResourcesPath || "";
  10494. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  10495. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  10496. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  10497. this.enableWebGL = options.enableWebGL || false;
  10498. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  10499. this.maxCanvasPixels = options.maxCanvasPixels;
  10500. this.l10n = options.l10n || _ui_utils.NullL10n;
  10501. this.enableScripting = options.enableScripting || false;
  10502. this._mouseState = options.mouseState || null;
  10503. this.defaultRenderingQueue = !options.renderingQueue;
  10504. if (this.defaultRenderingQueue) {
  10505. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  10506. this.renderingQueue.setViewer(this);
  10507. } else {
  10508. this.renderingQueue = options.renderingQueue;
  10509. }
  10510. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  10511. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  10512. this._onBeforeDraw = this._onAfterDraw = null;
  10513. this._resetView();
  10514. if (this.removePageBorders) {
  10515. this.viewer.classList.add("removePageBorders");
  10516. }
  10517. Promise.resolve().then(function () {
  10518. _this.eventBus.dispatch("baseviewerinit", {
  10519. source: _this
  10520. });
  10521. });
  10522. }
  10523. _createClass(BaseViewer, [{
  10524. key: "getPageView",
  10525. value: function getPageView(index) {
  10526. return this._pages[index];
  10527. }
  10528. }, {
  10529. key: "_setCurrentPageNumber",
  10530. value: function _setCurrentPageNumber(val) {
  10531. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10532. if (this._currentPageNumber === val) {
  10533. if (resetCurrentPageView) {
  10534. this._resetCurrentPageView();
  10535. }
  10536. return true;
  10537. }
  10538. if (!(0 < val && val <= this.pagesCount)) {
  10539. return false;
  10540. }
  10541. var previous = this._currentPageNumber;
  10542. this._currentPageNumber = val;
  10543. this.eventBus.dispatch("pagechanging", {
  10544. source: this,
  10545. pageNumber: val,
  10546. pageLabel: this._pageLabels && this._pageLabels[val - 1],
  10547. previous: previous
  10548. });
  10549. if (resetCurrentPageView) {
  10550. this._resetCurrentPageView();
  10551. }
  10552. return true;
  10553. }
  10554. }, {
  10555. key: "_onePageRenderedOrForceFetch",
  10556. value: function _onePageRenderedOrForceFetch() {
  10557. if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  10558. return Promise.resolve();
  10559. }
  10560. return this._onePageRenderedCapability.promise;
  10561. }
  10562. }, {
  10563. key: "setDocument",
  10564. value: function setDocument(pdfDocument) {
  10565. var _this2 = this;
  10566. if (this.pdfDocument) {
  10567. this.eventBus.dispatch("pagesdestroy", {
  10568. source: this
  10569. });
  10570. this._cancelRendering();
  10571. this._resetView();
  10572. if (this.findController) {
  10573. this.findController.setDocument(null);
  10574. }
  10575. }
  10576. this.pdfDocument = pdfDocument;
  10577. if (!pdfDocument) {
  10578. return;
  10579. }
  10580. var pagesCount = pdfDocument.numPages;
  10581. var firstPagePromise = pdfDocument.getPage(1);
  10582. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  10583. this._pagesCapability.promise.then(function () {
  10584. _this2.eventBus.dispatch("pagesloaded", {
  10585. source: _this2,
  10586. pagesCount: pagesCount
  10587. });
  10588. });
  10589. this._onBeforeDraw = function (evt) {
  10590. var pageView = _this2._pages[evt.pageNumber - 1];
  10591. if (!pageView) {
  10592. return;
  10593. }
  10594. _this2._buffer.push(pageView);
  10595. };
  10596. this.eventBus._on("pagerender", this._onBeforeDraw);
  10597. this._onAfterDraw = function (evt) {
  10598. if (evt.cssTransform || _this2._onePageRenderedCapability.settled) {
  10599. return;
  10600. }
  10601. _this2._onePageRenderedCapability.resolve();
  10602. _this2.eventBus._off("pagerendered", _this2._onAfterDraw);
  10603. _this2._onAfterDraw = null;
  10604. };
  10605. this.eventBus._on("pagerendered", this._onAfterDraw);
  10606. firstPagePromise.then(function (firstPdfPage) {
  10607. _this2._firstPageCapability.resolve(firstPdfPage);
  10608. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  10609. var scale = _this2.currentScale;
  10610. var viewport = firstPdfPage.getViewport({
  10611. scale: scale * _ui_utils.CSS_UNITS
  10612. });
  10613. var textLayerFactory = _this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? _this2 : null;
  10614. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  10615. var pageView = new _pdf_page_view.PDFPageView({
  10616. container: _this2._viewerElement,
  10617. eventBus: _this2.eventBus,
  10618. id: pageNum,
  10619. scale: scale,
  10620. defaultViewport: viewport.clone(),
  10621. optionalContentConfigPromise: optionalContentConfigPromise,
  10622. renderingQueue: _this2.renderingQueue,
  10623. textLayerFactory: textLayerFactory,
  10624. textLayerMode: _this2.textLayerMode,
  10625. annotationLayerFactory: _this2,
  10626. imageResourcesPath: _this2.imageResourcesPath,
  10627. renderInteractiveForms: _this2.renderInteractiveForms,
  10628. renderer: _this2.renderer,
  10629. enableWebGL: _this2.enableWebGL,
  10630. useOnlyCssZoom: _this2.useOnlyCssZoom,
  10631. maxCanvasPixels: _this2.maxCanvasPixels,
  10632. l10n: _this2.l10n,
  10633. enableScripting: _this2.enableScripting
  10634. });
  10635. _this2._pages.push(pageView);
  10636. }
  10637. var firstPageView = _this2._pages[0];
  10638. if (firstPageView) {
  10639. firstPageView.setPdfPage(firstPdfPage);
  10640. _this2.linkService.cachePageRef(1, firstPdfPage.ref);
  10641. }
  10642. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  10643. _this2._updateSpreadMode();
  10644. }
  10645. _this2._onePageRenderedOrForceFetch().then(function () {
  10646. if (_this2.findController) {
  10647. _this2.findController.setDocument(pdfDocument);
  10648. }
  10649. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
  10650. _this2._pagesCapability.resolve();
  10651. return;
  10652. }
  10653. var getPagesLeft = pagesCount - 1;
  10654. if (getPagesLeft <= 0) {
  10655. _this2._pagesCapability.resolve();
  10656. return;
  10657. }
  10658. var _loop = function _loop(_pageNum) {
  10659. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  10660. var pageView = _this2._pages[_pageNum - 1];
  10661. if (!pageView.pdfPage) {
  10662. pageView.setPdfPage(pdfPage);
  10663. }
  10664. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  10665. if (--getPagesLeft === 0) {
  10666. _this2._pagesCapability.resolve();
  10667. }
  10668. }, function (reason) {
  10669. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  10670. if (--getPagesLeft === 0) {
  10671. _this2._pagesCapability.resolve();
  10672. }
  10673. });
  10674. };
  10675. for (var _pageNum = 2; _pageNum <= pagesCount; ++_pageNum) {
  10676. _loop(_pageNum);
  10677. }
  10678. });
  10679. _this2.eventBus.dispatch("pagesinit", {
  10680. source: _this2
  10681. });
  10682. if (_this2.defaultRenderingQueue) {
  10683. _this2.update();
  10684. }
  10685. })["catch"](function (reason) {
  10686. console.error("Unable to initialize viewer", reason);
  10687. });
  10688. }
  10689. }, {
  10690. key: "setPageLabels",
  10691. value: function setPageLabels(labels) {
  10692. if (!this.pdfDocument) {
  10693. return;
  10694. }
  10695. if (!labels) {
  10696. this._pageLabels = null;
  10697. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  10698. this._pageLabels = null;
  10699. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  10700. } else {
  10701. this._pageLabels = labels;
  10702. }
  10703. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10704. var pageView = this._pages[i];
  10705. var label = this._pageLabels && this._pageLabels[i];
  10706. pageView.setPageLabel(label);
  10707. }
  10708. }
  10709. }, {
  10710. key: "_resetView",
  10711. value: function _resetView() {
  10712. this._pages = [];
  10713. this._currentPageNumber = 1;
  10714. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  10715. this._currentScaleValue = null;
  10716. this._pageLabels = null;
  10717. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  10718. this._location = null;
  10719. this._pagesRotation = 0;
  10720. this._optionalContentConfigPromise = null;
  10721. this._pagesRequests = new WeakMap();
  10722. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  10723. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  10724. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  10725. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  10726. this._spreadMode = _ui_utils.SpreadMode.NONE;
  10727. if (this._onBeforeDraw) {
  10728. this.eventBus._off("pagerender", this._onBeforeDraw);
  10729. this._onBeforeDraw = null;
  10730. }
  10731. if (this._onAfterDraw) {
  10732. this.eventBus._off("pagerendered", this._onAfterDraw);
  10733. this._onAfterDraw = null;
  10734. }
  10735. this._resetScriptingEvents();
  10736. this.viewer.textContent = "";
  10737. this._updateScrollMode();
  10738. }
  10739. }, {
  10740. key: "_scrollUpdate",
  10741. value: function _scrollUpdate() {
  10742. if (this.pagesCount === 0) {
  10743. return;
  10744. }
  10745. this.update();
  10746. }
  10747. }, {
  10748. key: "_scrollIntoView",
  10749. value: function _scrollIntoView(_ref) {
  10750. var pageDiv = _ref.pageDiv,
  10751. _ref$pageSpot = _ref.pageSpot,
  10752. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  10753. _ref$pageNumber = _ref.pageNumber,
  10754. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  10755. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  10756. }
  10757. }, {
  10758. key: "_setScaleUpdatePages",
  10759. value: function _setScaleUpdatePages(newScale, newValue) {
  10760. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  10761. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10762. this._currentScaleValue = newValue.toString();
  10763. if (isSameScale(this._currentScale, newScale)) {
  10764. if (preset) {
  10765. this.eventBus.dispatch("scalechanging", {
  10766. source: this,
  10767. scale: newScale,
  10768. presetValue: newValue
  10769. });
  10770. }
  10771. return;
  10772. }
  10773. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10774. this._pages[i].update(newScale);
  10775. }
  10776. this._currentScale = newScale;
  10777. if (!noScroll) {
  10778. var page = this._currentPageNumber,
  10779. dest;
  10780. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  10781. page = this._location.pageNumber;
  10782. dest = [null, {
  10783. name: "XYZ"
  10784. }, this._location.left, this._location.top, null];
  10785. }
  10786. this.scrollPageIntoView({
  10787. pageNumber: page,
  10788. destArray: dest,
  10789. allowNegativeOffset: true
  10790. });
  10791. }
  10792. this.eventBus.dispatch("scalechanging", {
  10793. source: this,
  10794. scale: newScale,
  10795. presetValue: preset ? newValue : undefined
  10796. });
  10797. if (this.defaultRenderingQueue) {
  10798. this.update();
  10799. }
  10800. }
  10801. }, {
  10802. key: "_setScale",
  10803. value: function _setScale(value) {
  10804. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10805. var scale = parseFloat(value);
  10806. if (scale > 0) {
  10807. this._setScaleUpdatePages(scale, value, noScroll, false);
  10808. } else {
  10809. var currentPage = this._pages[this._currentPageNumber - 1];
  10810. if (!currentPage) {
  10811. return;
  10812. }
  10813. var noPadding = this.isInPresentationMode || this.removePageBorders;
  10814. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  10815. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  10816. if (!noPadding && this._isScrollModeHorizontal) {
  10817. var _ref2 = [vPadding, hPadding];
  10818. hPadding = _ref2[0];
  10819. vPadding = _ref2[1];
  10820. }
  10821. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this._pageWidthScaleFactor;
  10822. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  10823. switch (value) {
  10824. case "page-actual":
  10825. scale = 1;
  10826. break;
  10827. case "page-width":
  10828. scale = pageWidthScale;
  10829. break;
  10830. case "page-height":
  10831. scale = pageHeightScale;
  10832. break;
  10833. case "page-fit":
  10834. scale = Math.min(pageWidthScale, pageHeightScale);
  10835. break;
  10836. case "auto":
  10837. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  10838. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  10839. break;
  10840. default:
  10841. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  10842. return;
  10843. }
  10844. this._setScaleUpdatePages(scale, value, noScroll, true);
  10845. }
  10846. }
  10847. }, {
  10848. key: "_resetCurrentPageView",
  10849. value: function _resetCurrentPageView() {
  10850. if (this.isInPresentationMode) {
  10851. this._setScale(this._currentScaleValue, true);
  10852. }
  10853. var pageView = this._pages[this._currentPageNumber - 1];
  10854. this._scrollIntoView({
  10855. pageDiv: pageView.div
  10856. });
  10857. }
  10858. }, {
  10859. key: "pageLabelToPageNumber",
  10860. value: function pageLabelToPageNumber(label) {
  10861. if (!this._pageLabels) {
  10862. return null;
  10863. }
  10864. var i = this._pageLabels.indexOf(label);
  10865. if (i < 0) {
  10866. return null;
  10867. }
  10868. return i + 1;
  10869. }
  10870. }, {
  10871. key: "scrollPageIntoView",
  10872. value: function scrollPageIntoView(_ref3) {
  10873. var pageNumber = _ref3.pageNumber,
  10874. _ref3$destArray = _ref3.destArray,
  10875. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  10876. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  10877. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf,
  10878. _ref3$ignoreDestinati = _ref3.ignoreDestinationZoom,
  10879. ignoreDestinationZoom = _ref3$ignoreDestinati === void 0 ? false : _ref3$ignoreDestinati;
  10880. if (!this.pdfDocument) {
  10881. return;
  10882. }
  10883. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  10884. if (!pageView) {
  10885. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  10886. return;
  10887. }
  10888. if (this.isInPresentationMode || !destArray) {
  10889. this._setCurrentPageNumber(pageNumber, true);
  10890. return;
  10891. }
  10892. var x = 0,
  10893. y = 0;
  10894. var width = 0,
  10895. height = 0,
  10896. widthScale,
  10897. heightScale;
  10898. var changeOrientation = pageView.rotation % 180 !== 0;
  10899. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  10900. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  10901. var scale = 0;
  10902. switch (destArray[1].name) {
  10903. case "XYZ":
  10904. x = destArray[2];
  10905. y = destArray[3];
  10906. scale = destArray[4];
  10907. x = x !== null ? x : 0;
  10908. y = y !== null ? y : pageHeight;
  10909. break;
  10910. case "Fit":
  10911. case "FitB":
  10912. scale = "page-fit";
  10913. break;
  10914. case "FitH":
  10915. case "FitBH":
  10916. y = destArray[2];
  10917. scale = "page-width";
  10918. if (y === null && this._location) {
  10919. x = this._location.left;
  10920. y = this._location.top;
  10921. } else if (typeof y !== "number") {
  10922. y = pageHeight;
  10923. }
  10924. break;
  10925. case "FitV":
  10926. case "FitBV":
  10927. x = destArray[2];
  10928. width = pageWidth;
  10929. height = pageHeight;
  10930. scale = "page-height";
  10931. break;
  10932. case "FitR":
  10933. x = destArray[2];
  10934. y = destArray[3];
  10935. width = destArray[4] - x;
  10936. height = destArray[5] - y;
  10937. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  10938. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  10939. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  10940. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  10941. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  10942. break;
  10943. default:
  10944. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  10945. return;
  10946. }
  10947. if (!ignoreDestinationZoom) {
  10948. if (scale && scale !== this._currentScale) {
  10949. this.currentScaleValue = scale;
  10950. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  10951. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  10952. }
  10953. }
  10954. if (scale === "page-fit" && !destArray[4]) {
  10955. this._scrollIntoView({
  10956. pageDiv: pageView.div,
  10957. pageNumber: pageNumber
  10958. });
  10959. return;
  10960. }
  10961. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  10962. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  10963. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  10964. if (!allowNegativeOffset) {
  10965. left = Math.max(left, 0);
  10966. top = Math.max(top, 0);
  10967. }
  10968. this._scrollIntoView({
  10969. pageDiv: pageView.div,
  10970. pageSpot: {
  10971. left: left,
  10972. top: top
  10973. },
  10974. pageNumber: pageNumber
  10975. });
  10976. }
  10977. }, {
  10978. key: "_updateLocation",
  10979. value: function _updateLocation(firstPage) {
  10980. var currentScale = this._currentScale;
  10981. var currentScaleValue = this._currentScaleValue;
  10982. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  10983. var pageNumber = firstPage.id;
  10984. var pdfOpenParams = "#page=" + pageNumber;
  10985. pdfOpenParams += "&zoom=" + normalizedScaleValue;
  10986. var currentPageView = this._pages[pageNumber - 1];
  10987. var container = this.container;
  10988. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  10989. var intLeft = Math.round(topLeft[0]);
  10990. var intTop = Math.round(topLeft[1]);
  10991. pdfOpenParams += "," + intLeft + "," + intTop;
  10992. this._location = {
  10993. pageNumber: pageNumber,
  10994. scale: normalizedScaleValue,
  10995. top: intTop,
  10996. left: intLeft,
  10997. rotation: this._pagesRotation,
  10998. pdfOpenParams: pdfOpenParams
  10999. };
  11000. }
  11001. }, {
  11002. key: "_updateHelper",
  11003. value: function _updateHelper(visiblePages) {
  11004. throw new Error("Not implemented: _updateHelper");
  11005. }
  11006. }, {
  11007. key: "update",
  11008. value: function update() {
  11009. var visible = this._getVisiblePages();
  11010. var visiblePages = visible.views,
  11011. numVisiblePages = visiblePages.length;
  11012. if (numVisiblePages === 0) {
  11013. return;
  11014. }
  11015. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  11016. this._buffer.resize(newCacheSize, visiblePages);
  11017. this.renderingQueue.renderHighestPriority(visible);
  11018. this._updateHelper(visiblePages);
  11019. this._updateLocation(visible.first);
  11020. this.eventBus.dispatch("updateviewarea", {
  11021. source: this,
  11022. location: this._location
  11023. });
  11024. }
  11025. }, {
  11026. key: "containsElement",
  11027. value: function containsElement(element) {
  11028. return this.container.contains(element);
  11029. }
  11030. }, {
  11031. key: "focus",
  11032. value: function focus() {
  11033. this.container.focus();
  11034. }
  11035. }, {
  11036. key: "_getCurrentVisiblePage",
  11037. value: function _getCurrentVisiblePage() {
  11038. if (!this.pagesCount) {
  11039. return {
  11040. views: []
  11041. };
  11042. }
  11043. var pageView = this._pages[this._currentPageNumber - 1];
  11044. var element = pageView.div;
  11045. var view = {
  11046. id: pageView.id,
  11047. x: element.offsetLeft + element.clientLeft,
  11048. y: element.offsetTop + element.clientTop,
  11049. view: pageView
  11050. };
  11051. return {
  11052. first: view,
  11053. last: view,
  11054. views: [view]
  11055. };
  11056. }
  11057. }, {
  11058. key: "_getVisiblePages",
  11059. value: function _getVisiblePages() {
  11060. return (0, _ui_utils.getVisibleElements)({
  11061. scrollEl: this.container,
  11062. views: this._pages,
  11063. sortByVisibility: true,
  11064. horizontal: this._isScrollModeHorizontal,
  11065. rtl: this._isScrollModeHorizontal && this._isContainerRtl
  11066. });
  11067. }
  11068. }, {
  11069. key: "isPageVisible",
  11070. value: function isPageVisible(pageNumber) {
  11071. if (!this.pdfDocument) {
  11072. return false;
  11073. }
  11074. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  11075. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is not a valid page."));
  11076. return false;
  11077. }
  11078. return this._getVisiblePages().views.some(function (view) {
  11079. return view.id === pageNumber;
  11080. });
  11081. }
  11082. }, {
  11083. key: "isPageCached",
  11084. value: function isPageCached(pageNumber) {
  11085. if (!this.pdfDocument || !this._buffer) {
  11086. return false;
  11087. }
  11088. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  11089. console.error("".concat(this._name, ".isPageCached: \"").concat(pageNumber, "\" is not a valid page."));
  11090. return false;
  11091. }
  11092. var pageView = this._pages[pageNumber - 1];
  11093. if (!pageView) {
  11094. return false;
  11095. }
  11096. return this._buffer.has(pageView);
  11097. }
  11098. }, {
  11099. key: "cleanup",
  11100. value: function cleanup() {
  11101. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  11102. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  11103. this._pages[i].reset();
  11104. }
  11105. }
  11106. }
  11107. }, {
  11108. key: "_cancelRendering",
  11109. value: function _cancelRendering() {
  11110. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  11111. if (this._pages[i]) {
  11112. this._pages[i].cancelRendering();
  11113. }
  11114. }
  11115. }
  11116. }, {
  11117. key: "_ensurePdfPageLoaded",
  11118. value: function _ensurePdfPageLoaded(pageView) {
  11119. var _this3 = this;
  11120. if (pageView.pdfPage) {
  11121. return Promise.resolve(pageView.pdfPage);
  11122. }
  11123. if (this._pagesRequests.has(pageView)) {
  11124. return this._pagesRequests.get(pageView);
  11125. }
  11126. var promise = this.pdfDocument.getPage(pageView.id).then(function (pdfPage) {
  11127. if (!pageView.pdfPage) {
  11128. pageView.setPdfPage(pdfPage);
  11129. }
  11130. _this3._pagesRequests["delete"](pageView);
  11131. return pdfPage;
  11132. })["catch"](function (reason) {
  11133. console.error("Unable to get page for page view", reason);
  11134. _this3._pagesRequests["delete"](pageView);
  11135. });
  11136. this._pagesRequests.set(pageView, promise);
  11137. return promise;
  11138. }
  11139. }, {
  11140. key: "forceRendering",
  11141. value: function forceRendering(currentlyVisiblePages) {
  11142. var _this4 = this;
  11143. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  11144. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  11145. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  11146. if (pageView) {
  11147. this._ensurePdfPageLoaded(pageView).then(function () {
  11148. _this4.renderingQueue.renderView(pageView);
  11149. });
  11150. return true;
  11151. }
  11152. return false;
  11153. }
  11154. }, {
  11155. key: "createTextLayerBuilder",
  11156. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  11157. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  11158. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  11159. return new _text_layer_builder.TextLayerBuilder({
  11160. textLayerDiv: textLayerDiv,
  11161. eventBus: eventBus,
  11162. pageIndex: pageIndex,
  11163. viewport: viewport,
  11164. findController: this.isInPresentationMode ? null : this.findController,
  11165. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  11166. });
  11167. }
  11168. }, {
  11169. key: "createAnnotationLayerBuilder",
  11170. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  11171. var _this$pdfDocument, _this$pdfDocument2;
  11172. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  11173. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  11174. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  11175. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _ui_utils.NullL10n;
  11176. var enableScripting = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
  11177. var hasJSActionsPromise = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  11178. var mouseState = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
  11179. return new _annotation_layer_builder.AnnotationLayerBuilder({
  11180. pageDiv: pageDiv,
  11181. pdfPage: pdfPage,
  11182. annotationStorage: annotationStorage || ((_this$pdfDocument = this.pdfDocument) === null || _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage),
  11183. imageResourcesPath: imageResourcesPath,
  11184. renderInteractiveForms: renderInteractiveForms,
  11185. linkService: this.linkService,
  11186. downloadManager: this.downloadManager,
  11187. l10n: l10n,
  11188. enableScripting: enableScripting,
  11189. hasJSActionsPromise: hasJSActionsPromise || ((_this$pdfDocument2 = this.pdfDocument) === null || _this$pdfDocument2 === void 0 ? void 0 : _this$pdfDocument2.hasJSActions()),
  11190. mouseState: mouseState || this._mouseState
  11191. });
  11192. }
  11193. }, {
  11194. key: "getPagesOverview",
  11195. value: function getPagesOverview() {
  11196. var pagesOverview = this._pages.map(function (pageView) {
  11197. var viewport = pageView.pdfPage.getViewport({
  11198. scale: 1
  11199. });
  11200. return {
  11201. width: viewport.width,
  11202. height: viewport.height,
  11203. rotation: viewport.rotation
  11204. };
  11205. });
  11206. if (!this.enablePrintAutoRotate) {
  11207. return pagesOverview;
  11208. }
  11209. return pagesOverview.map(function (size) {
  11210. if ((0, _ui_utils.isPortraitOrientation)(size)) {
  11211. return size;
  11212. }
  11213. return {
  11214. width: size.height,
  11215. height: size.width,
  11216. rotation: (size.rotation + 90) % 360
  11217. };
  11218. });
  11219. }
  11220. }, {
  11221. key: "_updateScrollMode",
  11222. value: function _updateScrollMode() {
  11223. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11224. var scrollMode = this._scrollMode,
  11225. viewer = this.viewer;
  11226. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  11227. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  11228. if (!this.pdfDocument || !pageNumber) {
  11229. return;
  11230. }
  11231. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  11232. this._setScale(this._currentScaleValue, true);
  11233. }
  11234. this._setCurrentPageNumber(pageNumber, true);
  11235. this.update();
  11236. }
  11237. }, {
  11238. key: "_updateSpreadMode",
  11239. value: function _updateSpreadMode() {
  11240. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11241. if (!this.pdfDocument) {
  11242. return;
  11243. }
  11244. var viewer = this.viewer,
  11245. pages = this._pages;
  11246. viewer.textContent = "";
  11247. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  11248. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  11249. viewer.appendChild(pages[i].div);
  11250. }
  11251. } else {
  11252. var parity = this._spreadMode - 1;
  11253. var spread = null;
  11254. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  11255. if (spread === null) {
  11256. spread = document.createElement("div");
  11257. spread.className = "spread";
  11258. viewer.appendChild(spread);
  11259. } else if (_i % 2 === parity) {
  11260. spread = spread.cloneNode(false);
  11261. viewer.appendChild(spread);
  11262. }
  11263. spread.appendChild(pages[_i].div);
  11264. }
  11265. }
  11266. if (!pageNumber) {
  11267. return;
  11268. }
  11269. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  11270. this._setScale(this._currentScaleValue, true);
  11271. }
  11272. this._setCurrentPageNumber(pageNumber, true);
  11273. this.update();
  11274. }
  11275. }, {
  11276. key: "_getPageAdvance",
  11277. value: function _getPageAdvance(currentPageNumber) {
  11278. var previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  11279. if (this.isInPresentationMode) {
  11280. return 1;
  11281. }
  11282. switch (this._scrollMode) {
  11283. case _ui_utils.ScrollMode.WRAPPED:
  11284. {
  11285. var _this$_getVisiblePage = this._getVisiblePages(),
  11286. views = _this$_getVisiblePage.views,
  11287. pageLayout = new Map();
  11288. var _iterator = _createForOfIteratorHelper(views),
  11289. _step;
  11290. try {
  11291. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11292. var _step$value = _step.value,
  11293. id = _step$value.id,
  11294. y = _step$value.y,
  11295. percent = _step$value.percent,
  11296. widthPercent = _step$value.widthPercent;
  11297. if (percent === 0 || widthPercent < 100) {
  11298. continue;
  11299. }
  11300. var yArray = pageLayout.get(y);
  11301. if (!yArray) {
  11302. pageLayout.set(y, yArray || (yArray = []));
  11303. }
  11304. yArray.push(id);
  11305. }
  11306. } catch (err) {
  11307. _iterator.e(err);
  11308. } finally {
  11309. _iterator.f();
  11310. }
  11311. var _iterator2 = _createForOfIteratorHelper(pageLayout.values()),
  11312. _step2;
  11313. try {
  11314. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  11315. var _yArray = _step2.value;
  11316. var currentIndex = _yArray.indexOf(currentPageNumber);
  11317. if (currentIndex === -1) {
  11318. continue;
  11319. }
  11320. var numPages = _yArray.length;
  11321. if (numPages === 1) {
  11322. break;
  11323. }
  11324. if (previous) {
  11325. for (var i = currentIndex - 1, ii = 0; i >= ii; i--) {
  11326. var currentId = _yArray[i],
  11327. expectedId = _yArray[i + 1] - 1;
  11328. if (currentId < expectedId) {
  11329. return currentPageNumber - expectedId;
  11330. }
  11331. }
  11332. } else {
  11333. for (var _i2 = currentIndex + 1, _ii = numPages; _i2 < _ii; _i2++) {
  11334. var _currentId = _yArray[_i2],
  11335. _expectedId = _yArray[_i2 - 1] + 1;
  11336. if (_currentId > _expectedId) {
  11337. return _expectedId - currentPageNumber;
  11338. }
  11339. }
  11340. }
  11341. if (previous) {
  11342. var firstId = _yArray[0];
  11343. if (firstId < currentPageNumber) {
  11344. return currentPageNumber - firstId + 1;
  11345. }
  11346. } else {
  11347. var lastId = _yArray[numPages - 1];
  11348. if (lastId > currentPageNumber) {
  11349. return lastId - currentPageNumber + 1;
  11350. }
  11351. }
  11352. break;
  11353. }
  11354. } catch (err) {
  11355. _iterator2.e(err);
  11356. } finally {
  11357. _iterator2.f();
  11358. }
  11359. break;
  11360. }
  11361. case _ui_utils.ScrollMode.HORIZONTAL:
  11362. {
  11363. break;
  11364. }
  11365. case _ui_utils.ScrollMode.VERTICAL:
  11366. {
  11367. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  11368. break;
  11369. }
  11370. var parity = this._spreadMode - 1;
  11371. if (previous && currentPageNumber % 2 !== parity) {
  11372. break;
  11373. } else if (!previous && currentPageNumber % 2 === parity) {
  11374. break;
  11375. }
  11376. var _this$_getVisiblePage2 = this._getVisiblePages(),
  11377. _views = _this$_getVisiblePage2.views,
  11378. _expectedId2 = previous ? currentPageNumber - 1 : currentPageNumber + 1;
  11379. var _iterator3 = _createForOfIteratorHelper(_views),
  11380. _step3;
  11381. try {
  11382. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  11383. var _step3$value = _step3.value,
  11384. _id = _step3$value.id,
  11385. _percent = _step3$value.percent,
  11386. _widthPercent = _step3$value.widthPercent;
  11387. if (_id !== _expectedId2) {
  11388. continue;
  11389. }
  11390. if (_percent > 0 && _widthPercent === 100) {
  11391. return 2;
  11392. }
  11393. break;
  11394. }
  11395. } catch (err) {
  11396. _iterator3.e(err);
  11397. } finally {
  11398. _iterator3.f();
  11399. }
  11400. break;
  11401. }
  11402. }
  11403. return 1;
  11404. }
  11405. }, {
  11406. key: "nextPage",
  11407. value: function nextPage() {
  11408. var currentPageNumber = this._currentPageNumber,
  11409. pagesCount = this.pagesCount;
  11410. if (currentPageNumber >= pagesCount) {
  11411. return false;
  11412. }
  11413. var advance = this._getPageAdvance(currentPageNumber, false) || 1;
  11414. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  11415. return true;
  11416. }
  11417. }, {
  11418. key: "previousPage",
  11419. value: function previousPage() {
  11420. var currentPageNumber = this._currentPageNumber;
  11421. if (currentPageNumber <= 1) {
  11422. return false;
  11423. }
  11424. var advance = this._getPageAdvance(currentPageNumber, true) || 1;
  11425. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  11426. return true;
  11427. }
  11428. }, {
  11429. key: "initializeScriptingEvents",
  11430. value: function initializeScriptingEvents() {
  11431. var _this5 = this;
  11432. if (!this.enableScripting || this._pageOpenPendingSet) {
  11433. return;
  11434. }
  11435. var eventBus = this.eventBus,
  11436. pageOpenPendingSet = this._pageOpenPendingSet = new Set(),
  11437. scriptingEvents = this._scriptingEvents || (this._scriptingEvents = Object.create(null));
  11438. var dispatchPageClose = function dispatchPageClose(pageNumber) {
  11439. if (pageOpenPendingSet.has(pageNumber)) {
  11440. return;
  11441. }
  11442. eventBus.dispatch("pageclose", {
  11443. source: _this5,
  11444. pageNumber: pageNumber
  11445. });
  11446. };
  11447. var dispatchPageOpen = function dispatchPageOpen(pageNumber) {
  11448. var pageView = _this5._pages[pageNumber - 1];
  11449. if ((pageView === null || pageView === void 0 ? void 0 : pageView.renderingState) === _pdf_rendering_queue.RenderingStates.FINISHED) {
  11450. var _pageView$pdfPage;
  11451. pageOpenPendingSet["delete"](pageNumber);
  11452. eventBus.dispatch("pageopen", {
  11453. source: _this5,
  11454. pageNumber: pageNumber,
  11455. actionsPromise: (_pageView$pdfPage = pageView.pdfPage) === null || _pageView$pdfPage === void 0 ? void 0 : _pageView$pdfPage.getJSActions()
  11456. });
  11457. } else {
  11458. pageOpenPendingSet.add(pageNumber);
  11459. }
  11460. };
  11461. scriptingEvents.onPageChanging = function (_ref4) {
  11462. var pageNumber = _ref4.pageNumber,
  11463. previous = _ref4.previous;
  11464. if (pageNumber === previous) {
  11465. return;
  11466. }
  11467. dispatchPageClose(previous);
  11468. dispatchPageOpen(pageNumber);
  11469. };
  11470. eventBus._on("pagechanging", scriptingEvents.onPageChanging);
  11471. scriptingEvents.onPageRendered = function (_ref5) {
  11472. var pageNumber = _ref5.pageNumber;
  11473. if (!pageOpenPendingSet.has(pageNumber)) {
  11474. return;
  11475. }
  11476. if (pageNumber !== _this5._currentPageNumber) {
  11477. return;
  11478. }
  11479. dispatchPageOpen(pageNumber);
  11480. };
  11481. eventBus._on("pagerendered", scriptingEvents.onPageRendered);
  11482. scriptingEvents.onPagesDestroy = function () {
  11483. dispatchPageClose(_this5._currentPageNumber);
  11484. };
  11485. eventBus._on("pagesdestroy", scriptingEvents.onPagesDestroy);
  11486. dispatchPageOpen(this._currentPageNumber);
  11487. }
  11488. }, {
  11489. key: "_resetScriptingEvents",
  11490. value: function _resetScriptingEvents() {
  11491. if (!this.enableScripting || !this._pageOpenPendingSet) {
  11492. return;
  11493. }
  11494. var eventBus = this.eventBus,
  11495. scriptingEvents = this._scriptingEvents;
  11496. eventBus._off("pagechanging", scriptingEvents.onPageChanging);
  11497. scriptingEvents.onPageChanging = null;
  11498. eventBus._off("pagerendered", scriptingEvents.onPageRendered);
  11499. scriptingEvents.onPageRendered = null;
  11500. eventBus._off("pagesdestroy", scriptingEvents.onPagesDestroy);
  11501. scriptingEvents.onPagesDestroy = null;
  11502. this._pageOpenPendingSet = null;
  11503. }
  11504. }, {
  11505. key: "pagesCount",
  11506. get: function get() {
  11507. return this._pages.length;
  11508. }
  11509. }, {
  11510. key: "pageViewsReady",
  11511. get: function get() {
  11512. if (!this._pagesCapability.settled) {
  11513. return false;
  11514. }
  11515. return this._pages.every(function (pageView) {
  11516. return pageView && pageView.pdfPage;
  11517. });
  11518. }
  11519. }, {
  11520. key: "currentPageNumber",
  11521. get: function get() {
  11522. return this._currentPageNumber;
  11523. },
  11524. set: function set(val) {
  11525. if (!Number.isInteger(val)) {
  11526. throw new Error("Invalid page number.");
  11527. }
  11528. if (!this.pdfDocument) {
  11529. return;
  11530. }
  11531. if (!this._setCurrentPageNumber(val, true)) {
  11532. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  11533. }
  11534. }
  11535. }, {
  11536. key: "currentPageLabel",
  11537. get: function get() {
  11538. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  11539. },
  11540. set: function set(val) {
  11541. if (!this.pdfDocument) {
  11542. return;
  11543. }
  11544. var page = val | 0;
  11545. if (this._pageLabels) {
  11546. var i = this._pageLabels.indexOf(val);
  11547. if (i >= 0) {
  11548. page = i + 1;
  11549. }
  11550. }
  11551. if (!this._setCurrentPageNumber(page, true)) {
  11552. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  11553. }
  11554. }
  11555. }, {
  11556. key: "currentScale",
  11557. get: function get() {
  11558. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  11559. },
  11560. set: function set(val) {
  11561. if (isNaN(val)) {
  11562. throw new Error("Invalid numeric scale.");
  11563. }
  11564. if (!this.pdfDocument) {
  11565. return;
  11566. }
  11567. this._setScale(val, false);
  11568. }
  11569. }, {
  11570. key: "currentScaleValue",
  11571. get: function get() {
  11572. return this._currentScaleValue;
  11573. },
  11574. set: function set(val) {
  11575. if (!this.pdfDocument) {
  11576. return;
  11577. }
  11578. this._setScale(val, false);
  11579. }
  11580. }, {
  11581. key: "pagesRotation",
  11582. get: function get() {
  11583. return this._pagesRotation;
  11584. },
  11585. set: function set(rotation) {
  11586. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  11587. throw new Error("Invalid pages rotation angle.");
  11588. }
  11589. if (!this.pdfDocument) {
  11590. return;
  11591. }
  11592. if (this._pagesRotation === rotation) {
  11593. return;
  11594. }
  11595. this._pagesRotation = rotation;
  11596. var pageNumber = this._currentPageNumber;
  11597. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  11598. var pageView = this._pages[i];
  11599. pageView.update(pageView.scale, rotation);
  11600. }
  11601. if (this._currentScaleValue) {
  11602. this._setScale(this._currentScaleValue, true);
  11603. }
  11604. this.eventBus.dispatch("rotationchanging", {
  11605. source: this,
  11606. pagesRotation: rotation,
  11607. pageNumber: pageNumber
  11608. });
  11609. if (this.defaultRenderingQueue) {
  11610. this.update();
  11611. }
  11612. }
  11613. }, {
  11614. key: "firstPagePromise",
  11615. get: function get() {
  11616. return this.pdfDocument ? this._firstPageCapability.promise : null;
  11617. }
  11618. }, {
  11619. key: "onePageRendered",
  11620. get: function get() {
  11621. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  11622. }
  11623. }, {
  11624. key: "pagesPromise",
  11625. get: function get() {
  11626. return this.pdfDocument ? this._pagesCapability.promise : null;
  11627. }
  11628. }, {
  11629. key: "_viewerElement",
  11630. get: function get() {
  11631. throw new Error("Not implemented: _viewerElement");
  11632. }
  11633. }, {
  11634. key: "_pageWidthScaleFactor",
  11635. get: function get() {
  11636. if (this.spreadMode !== _ui_utils.SpreadMode.NONE && this.scrollMode !== _ui_utils.ScrollMode.HORIZONTAL && !this.isInPresentationMode) {
  11637. return 2;
  11638. }
  11639. return 1;
  11640. }
  11641. }, {
  11642. key: "_isScrollModeHorizontal",
  11643. get: function get() {
  11644. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  11645. }
  11646. }, {
  11647. key: "_isContainerRtl",
  11648. get: function get() {
  11649. return getComputedStyle(this.container).direction === "rtl";
  11650. }
  11651. }, {
  11652. key: "isInPresentationMode",
  11653. get: function get() {
  11654. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  11655. }
  11656. }, {
  11657. key: "isChangingPresentationMode",
  11658. get: function get() {
  11659. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  11660. }
  11661. }, {
  11662. key: "isHorizontalScrollbarEnabled",
  11663. get: function get() {
  11664. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  11665. }
  11666. }, {
  11667. key: "isVerticalScrollbarEnabled",
  11668. get: function get() {
  11669. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  11670. }
  11671. }, {
  11672. key: "hasEqualPageSizes",
  11673. get: function get() {
  11674. var firstPageView = this._pages[0];
  11675. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  11676. var pageView = this._pages[i];
  11677. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  11678. return false;
  11679. }
  11680. }
  11681. return true;
  11682. }
  11683. }, {
  11684. key: "optionalContentConfigPromise",
  11685. get: function get() {
  11686. if (!this.pdfDocument) {
  11687. return Promise.resolve(null);
  11688. }
  11689. if (!this._optionalContentConfigPromise) {
  11690. return this.pdfDocument.getOptionalContentConfig();
  11691. }
  11692. return this._optionalContentConfigPromise;
  11693. },
  11694. set: function set(promise) {
  11695. if (!(promise instanceof Promise)) {
  11696. throw new Error("Invalid optionalContentConfigPromise: ".concat(promise));
  11697. }
  11698. if (!this.pdfDocument) {
  11699. return;
  11700. }
  11701. if (!this._optionalContentConfigPromise) {
  11702. return;
  11703. }
  11704. this._optionalContentConfigPromise = promise;
  11705. var _iterator4 = _createForOfIteratorHelper(this._pages),
  11706. _step4;
  11707. try {
  11708. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  11709. var pageView = _step4.value;
  11710. pageView.update(pageView.scale, pageView.rotation, promise);
  11711. }
  11712. } catch (err) {
  11713. _iterator4.e(err);
  11714. } finally {
  11715. _iterator4.f();
  11716. }
  11717. this.update();
  11718. this.eventBus.dispatch("optionalcontentconfigchanged", {
  11719. source: this,
  11720. promise: promise
  11721. });
  11722. }
  11723. }, {
  11724. key: "scrollMode",
  11725. get: function get() {
  11726. return this._scrollMode;
  11727. },
  11728. set: function set(mode) {
  11729. if (this._scrollMode === mode) {
  11730. return;
  11731. }
  11732. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  11733. throw new Error("Invalid scroll mode: ".concat(mode));
  11734. }
  11735. this._scrollMode = mode;
  11736. this.eventBus.dispatch("scrollmodechanged", {
  11737. source: this,
  11738. mode: mode
  11739. });
  11740. this._updateScrollMode(this._currentPageNumber);
  11741. }
  11742. }, {
  11743. key: "spreadMode",
  11744. get: function get() {
  11745. return this._spreadMode;
  11746. },
  11747. set: function set(mode) {
  11748. if (this._spreadMode === mode) {
  11749. return;
  11750. }
  11751. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  11752. throw new Error("Invalid spread mode: ".concat(mode));
  11753. }
  11754. this._spreadMode = mode;
  11755. this.eventBus.dispatch("spreadmodechanged", {
  11756. source: this,
  11757. mode: mode
  11758. });
  11759. this._updateSpreadMode(this._currentPageNumber);
  11760. }
  11761. }]);
  11762. return BaseViewer;
  11763. }();
  11764. exports.BaseViewer = BaseViewer;
  11765. /***/ }),
  11766. /* 30 */
  11767. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11768. Object.defineProperty(exports, "__esModule", ({
  11769. value: true
  11770. }));
  11771. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  11772. var _pdfjsLib = __webpack_require__(7);
  11773. var _ui_utils = __webpack_require__(6);
  11774. var _pdf_link_service = __webpack_require__(21);
  11775. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  11776. 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."); }
  11777. 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); }
  11778. 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; }
  11779. 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; }
  11780. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  11781. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11782. 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); } }
  11783. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11784. var AnnotationLayerBuilder = /*#__PURE__*/function () {
  11785. function AnnotationLayerBuilder(_ref) {
  11786. var pageDiv = _ref.pageDiv,
  11787. pdfPage = _ref.pdfPage,
  11788. linkService = _ref.linkService,
  11789. downloadManager = _ref.downloadManager,
  11790. _ref$annotationStorag = _ref.annotationStorage,
  11791. annotationStorage = _ref$annotationStorag === void 0 ? null : _ref$annotationStorag,
  11792. _ref$imageResourcesPa = _ref.imageResourcesPath,
  11793. imageResourcesPath = _ref$imageResourcesPa === void 0 ? "" : _ref$imageResourcesPa,
  11794. _ref$renderInteractiv = _ref.renderInteractiveForms,
  11795. renderInteractiveForms = _ref$renderInteractiv === void 0 ? true : _ref$renderInteractiv,
  11796. _ref$l10n = _ref.l10n,
  11797. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n,
  11798. _ref$enableScripting = _ref.enableScripting,
  11799. enableScripting = _ref$enableScripting === void 0 ? false : _ref$enableScripting,
  11800. _ref$hasJSActionsProm = _ref.hasJSActionsPromise,
  11801. hasJSActionsPromise = _ref$hasJSActionsProm === void 0 ? null : _ref$hasJSActionsProm,
  11802. _ref$mouseState = _ref.mouseState,
  11803. mouseState = _ref$mouseState === void 0 ? null : _ref$mouseState;
  11804. _classCallCheck(this, AnnotationLayerBuilder);
  11805. this.pageDiv = pageDiv;
  11806. this.pdfPage = pdfPage;
  11807. this.linkService = linkService;
  11808. this.downloadManager = downloadManager;
  11809. this.imageResourcesPath = imageResourcesPath;
  11810. this.renderInteractiveForms = renderInteractiveForms;
  11811. this.l10n = l10n;
  11812. this.annotationStorage = annotationStorage;
  11813. this.enableScripting = enableScripting;
  11814. this._hasJSActionsPromise = hasJSActionsPromise;
  11815. this._mouseState = mouseState;
  11816. this.div = null;
  11817. this._cancelled = false;
  11818. }
  11819. _createClass(AnnotationLayerBuilder, [{
  11820. key: "render",
  11821. value: function render(viewport) {
  11822. var _this = this;
  11823. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  11824. return Promise.all([this.pdfPage.getAnnotations({
  11825. intent: intent
  11826. }), this._hasJSActionsPromise]).then(function (_ref2) {
  11827. var _ref3 = _slicedToArray(_ref2, 2),
  11828. annotations = _ref3[0],
  11829. _ref3$ = _ref3[1],
  11830. hasJSActions = _ref3$ === void 0 ? false : _ref3$;
  11831. if (_this._cancelled) {
  11832. return;
  11833. }
  11834. if (annotations.length === 0) {
  11835. return;
  11836. }
  11837. var parameters = {
  11838. viewport: viewport.clone({
  11839. dontFlip: true
  11840. }),
  11841. div: _this.div,
  11842. annotations: annotations,
  11843. page: _this.pdfPage,
  11844. imageResourcesPath: _this.imageResourcesPath,
  11845. renderInteractiveForms: _this.renderInteractiveForms,
  11846. linkService: _this.linkService,
  11847. downloadManager: _this.downloadManager,
  11848. annotationStorage: _this.annotationStorage,
  11849. enableScripting: _this.enableScripting,
  11850. hasJSActions: hasJSActions,
  11851. mouseState: _this._mouseState
  11852. };
  11853. if (_this.div) {
  11854. _pdfjsLib.AnnotationLayer.update(parameters);
  11855. } else {
  11856. _this.div = document.createElement("div");
  11857. _this.div.className = "annotationLayer";
  11858. _this.pageDiv.appendChild(_this.div);
  11859. parameters.div = _this.div;
  11860. _pdfjsLib.AnnotationLayer.render(parameters);
  11861. _this.l10n.translate(_this.div);
  11862. }
  11863. });
  11864. }
  11865. }, {
  11866. key: "cancel",
  11867. value: function cancel() {
  11868. this._cancelled = true;
  11869. }
  11870. }, {
  11871. key: "hide",
  11872. value: function hide() {
  11873. if (!this.div) {
  11874. return;
  11875. }
  11876. this.div.setAttribute("hidden", "true");
  11877. }
  11878. }]);
  11879. return AnnotationLayerBuilder;
  11880. }();
  11881. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  11882. var DefaultAnnotationLayerFactory = /*#__PURE__*/function () {
  11883. function DefaultAnnotationLayerFactory() {
  11884. _classCallCheck(this, DefaultAnnotationLayerFactory);
  11885. }
  11886. _createClass(DefaultAnnotationLayerFactory, [{
  11887. key: "createAnnotationLayerBuilder",
  11888. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  11889. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  11890. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  11891. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  11892. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _ui_utils.NullL10n;
  11893. var enableScripting = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
  11894. var hasJSActionsPromise = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  11895. var mouseState = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
  11896. return new AnnotationLayerBuilder({
  11897. pageDiv: pageDiv,
  11898. pdfPage: pdfPage,
  11899. imageResourcesPath: imageResourcesPath,
  11900. renderInteractiveForms: renderInteractiveForms,
  11901. linkService: new _pdf_link_service.SimpleLinkService(),
  11902. l10n: l10n,
  11903. annotationStorage: annotationStorage,
  11904. enableScripting: enableScripting,
  11905. hasJSActionsPromise: hasJSActionsPromise,
  11906. mouseState: mouseState
  11907. });
  11908. }
  11909. }]);
  11910. return DefaultAnnotationLayerFactory;
  11911. }();
  11912. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  11913. /***/ }),
  11914. /* 31 */
  11915. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11916. Object.defineProperty(exports, "__esModule", ({
  11917. value: true
  11918. }));
  11919. exports.PDFPageView = void 0;
  11920. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  11921. var _ui_utils = __webpack_require__(6);
  11922. var _pdfjsLib = __webpack_require__(7);
  11923. var _pdf_rendering_queue = __webpack_require__(10);
  11924. var _viewer_compatibility = __webpack_require__(2);
  11925. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11926. 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); } }
  11927. 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); }); }; }
  11928. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11929. 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); } }
  11930. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11931. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  11932. var PDFPageView = /*#__PURE__*/function () {
  11933. function PDFPageView(options) {
  11934. _classCallCheck(this, PDFPageView);
  11935. var container = options.container;
  11936. var defaultViewport = options.defaultViewport;
  11937. this.id = options.id;
  11938. this.renderingId = "page" + this.id;
  11939. this.pdfPage = null;
  11940. this.pageLabel = null;
  11941. this.rotation = 0;
  11942. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  11943. this.viewport = defaultViewport;
  11944. this.pdfPageRotate = defaultViewport.rotation;
  11945. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  11946. this.hasRestrictedScaling = false;
  11947. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  11948. this.imageResourcesPath = options.imageResourcesPath || "";
  11949. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  11950. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  11951. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  11952. this.eventBus = options.eventBus;
  11953. this.renderingQueue = options.renderingQueue;
  11954. this.textLayerFactory = options.textLayerFactory;
  11955. this.annotationLayerFactory = options.annotationLayerFactory;
  11956. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  11957. this.enableWebGL = options.enableWebGL || false;
  11958. this.l10n = options.l10n || _ui_utils.NullL10n;
  11959. this.enableScripting = options.enableScripting || false;
  11960. this.paintTask = null;
  11961. this.paintedViewportMap = new WeakMap();
  11962. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  11963. this.resume = null;
  11964. this._renderError = null;
  11965. this.annotationLayer = null;
  11966. this.textLayer = null;
  11967. this.zoomLayer = null;
  11968. var div = document.createElement("div");
  11969. div.className = "page";
  11970. div.style.width = Math.floor(this.viewport.width) + "px";
  11971. div.style.height = Math.floor(this.viewport.height) + "px";
  11972. div.setAttribute("data-page-number", this.id);
  11973. this.div = div;
  11974. container.appendChild(div);
  11975. }
  11976. _createClass(PDFPageView, [{
  11977. key: "setPdfPage",
  11978. value: function setPdfPage(pdfPage) {
  11979. this.pdfPage = pdfPage;
  11980. this.pdfPageRotate = pdfPage.rotate;
  11981. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  11982. this.viewport = pdfPage.getViewport({
  11983. scale: this.scale * _ui_utils.CSS_UNITS,
  11984. rotation: totalRotation
  11985. });
  11986. this.reset();
  11987. }
  11988. }, {
  11989. key: "destroy",
  11990. value: function destroy() {
  11991. this.reset();
  11992. if (this.pdfPage) {
  11993. this.pdfPage.cleanup();
  11994. }
  11995. }
  11996. }, {
  11997. key: "_renderAnnotationLayer",
  11998. value: function () {
  11999. var _renderAnnotationLayer2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  12000. var error;
  12001. return _regenerator["default"].wrap(function _callee$(_context) {
  12002. while (1) {
  12003. switch (_context.prev = _context.next) {
  12004. case 0:
  12005. error = null;
  12006. _context.prev = 1;
  12007. _context.next = 4;
  12008. return this.annotationLayer.render(this.viewport, "display");
  12009. case 4:
  12010. _context.next = 9;
  12011. break;
  12012. case 6:
  12013. _context.prev = 6;
  12014. _context.t0 = _context["catch"](1);
  12015. error = _context.t0;
  12016. case 9:
  12017. _context.prev = 9;
  12018. this.eventBus.dispatch("annotationlayerrendered", {
  12019. source: this,
  12020. pageNumber: this.id,
  12021. error: error
  12022. });
  12023. return _context.finish(9);
  12024. case 12:
  12025. case "end":
  12026. return _context.stop();
  12027. }
  12028. }
  12029. }, _callee, this, [[1, 6, 9, 12]]);
  12030. }));
  12031. function _renderAnnotationLayer() {
  12032. return _renderAnnotationLayer2.apply(this, arguments);
  12033. }
  12034. return _renderAnnotationLayer;
  12035. }()
  12036. }, {
  12037. key: "_resetZoomLayer",
  12038. value: function _resetZoomLayer() {
  12039. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12040. if (!this.zoomLayer) {
  12041. return;
  12042. }
  12043. var zoomLayerCanvas = this.zoomLayer.firstChild;
  12044. this.paintedViewportMap["delete"](zoomLayerCanvas);
  12045. zoomLayerCanvas.width = 0;
  12046. zoomLayerCanvas.height = 0;
  12047. if (removeFromDOM) {
  12048. this.zoomLayer.remove();
  12049. }
  12050. this.zoomLayer = null;
  12051. }
  12052. }, {
  12053. key: "reset",
  12054. value: function reset() {
  12055. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12056. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12057. this.cancelRendering(keepAnnotations);
  12058. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  12059. var div = this.div;
  12060. div.style.width = Math.floor(this.viewport.width) + "px";
  12061. div.style.height = Math.floor(this.viewport.height) + "px";
  12062. var childNodes = div.childNodes;
  12063. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  12064. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  12065. for (var i = childNodes.length - 1; i >= 0; i--) {
  12066. var node = childNodes[i];
  12067. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  12068. continue;
  12069. }
  12070. div.removeChild(node);
  12071. }
  12072. div.removeAttribute("data-loaded");
  12073. if (currentAnnotationNode) {
  12074. this.annotationLayer.hide();
  12075. } else if (this.annotationLayer) {
  12076. this.annotationLayer.cancel();
  12077. this.annotationLayer = null;
  12078. }
  12079. if (!currentZoomLayerNode) {
  12080. if (this.canvas) {
  12081. this.paintedViewportMap["delete"](this.canvas);
  12082. this.canvas.width = 0;
  12083. this.canvas.height = 0;
  12084. delete this.canvas;
  12085. }
  12086. this._resetZoomLayer();
  12087. }
  12088. if (this.svg) {
  12089. this.paintedViewportMap["delete"](this.svg);
  12090. delete this.svg;
  12091. }
  12092. this.loadingIconDiv = document.createElement("div");
  12093. this.loadingIconDiv.className = "loadingIcon";
  12094. div.appendChild(this.loadingIconDiv);
  12095. }
  12096. }, {
  12097. key: "update",
  12098. value: function update(scale, rotation) {
  12099. var optionalContentConfigPromise = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  12100. this.scale = scale || this.scale;
  12101. if (typeof rotation !== "undefined") {
  12102. this.rotation = rotation;
  12103. }
  12104. if (optionalContentConfigPromise instanceof Promise) {
  12105. this._optionalContentConfigPromise = optionalContentConfigPromise;
  12106. }
  12107. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  12108. this.viewport = this.viewport.clone({
  12109. scale: this.scale * _ui_utils.CSS_UNITS,
  12110. rotation: totalRotation
  12111. });
  12112. if (this.svg) {
  12113. this.cssTransform(this.svg, true);
  12114. this.eventBus.dispatch("pagerendered", {
  12115. source: this,
  12116. pageNumber: this.id,
  12117. cssTransform: true,
  12118. timestamp: performance.now(),
  12119. error: this._renderError
  12120. });
  12121. return;
  12122. }
  12123. var isScalingRestricted = false;
  12124. if (this.canvas && this.maxCanvasPixels > 0) {
  12125. var outputScale = this.outputScale;
  12126. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  12127. isScalingRestricted = true;
  12128. }
  12129. }
  12130. if (this.canvas) {
  12131. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  12132. this.cssTransform(this.canvas, true);
  12133. this.eventBus.dispatch("pagerendered", {
  12134. source: this,
  12135. pageNumber: this.id,
  12136. cssTransform: true,
  12137. timestamp: performance.now(),
  12138. error: this._renderError
  12139. });
  12140. return;
  12141. }
  12142. if (!this.zoomLayer && !this.canvas.hasAttribute("hidden")) {
  12143. this.zoomLayer = this.canvas.parentNode;
  12144. this.zoomLayer.style.position = "absolute";
  12145. }
  12146. }
  12147. if (this.zoomLayer) {
  12148. this.cssTransform(this.zoomLayer.firstChild);
  12149. }
  12150. this.reset(true, true);
  12151. }
  12152. }, {
  12153. key: "cancelRendering",
  12154. value: function cancelRendering() {
  12155. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12156. if (this.paintTask) {
  12157. this.paintTask.cancel();
  12158. this.paintTask = null;
  12159. }
  12160. this.resume = null;
  12161. if (this.textLayer) {
  12162. this.textLayer.cancel();
  12163. this.textLayer = null;
  12164. }
  12165. if (!keepAnnotations && this.annotationLayer) {
  12166. this.annotationLayer.cancel();
  12167. this.annotationLayer = null;
  12168. }
  12169. }
  12170. }, {
  12171. key: "cssTransform",
  12172. value: function cssTransform(target) {
  12173. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12174. var width = this.viewport.width;
  12175. var height = this.viewport.height;
  12176. var div = this.div;
  12177. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
  12178. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
  12179. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  12180. var absRotation = Math.abs(relativeRotation);
  12181. var scaleX = 1,
  12182. scaleY = 1;
  12183. if (absRotation === 90 || absRotation === 270) {
  12184. scaleX = height / width;
  12185. scaleY = width / height;
  12186. }
  12187. target.style.transform = "rotate(".concat(relativeRotation, "deg) scale(").concat(scaleX, ", ").concat(scaleY, ")");
  12188. if (this.textLayer) {
  12189. var textLayerViewport = this.textLayer.viewport;
  12190. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  12191. var textAbsRotation = Math.abs(textRelativeRotation);
  12192. var scale = width / textLayerViewport.width;
  12193. if (textAbsRotation === 90 || textAbsRotation === 270) {
  12194. scale = width / textLayerViewport.height;
  12195. }
  12196. var textLayerDiv = this.textLayer.textLayerDiv;
  12197. var transX, transY;
  12198. switch (textAbsRotation) {
  12199. case 0:
  12200. transX = transY = 0;
  12201. break;
  12202. case 90:
  12203. transX = 0;
  12204. transY = "-" + textLayerDiv.style.height;
  12205. break;
  12206. case 180:
  12207. transX = "-" + textLayerDiv.style.width;
  12208. transY = "-" + textLayerDiv.style.height;
  12209. break;
  12210. case 270:
  12211. transX = "-" + textLayerDiv.style.width;
  12212. transY = 0;
  12213. break;
  12214. default:
  12215. console.error("Bad rotation value.");
  12216. break;
  12217. }
  12218. textLayerDiv.style.transform = "rotate(".concat(textAbsRotation, "deg) ") + "scale(".concat(scale, ") ") + "translate(".concat(transX, ", ").concat(transY, ")");
  12219. textLayerDiv.style.transformOrigin = "0% 0%";
  12220. }
  12221. if (redrawAnnotations && this.annotationLayer) {
  12222. this._renderAnnotationLayer();
  12223. }
  12224. }
  12225. }, {
  12226. key: "getPagePoint",
  12227. value: function getPagePoint(x, y) {
  12228. return this.viewport.convertToPdfPoint(x, y);
  12229. }
  12230. }, {
  12231. key: "draw",
  12232. value: function draw() {
  12233. var _this = this;
  12234. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  12235. console.error("Must be in new state before drawing");
  12236. this.reset();
  12237. }
  12238. var div = this.div,
  12239. pdfPage = this.pdfPage;
  12240. if (!pdfPage) {
  12241. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  12242. if (this.loadingIconDiv) {
  12243. div.removeChild(this.loadingIconDiv);
  12244. delete this.loadingIconDiv;
  12245. }
  12246. return Promise.reject(new Error("pdfPage is not loaded"));
  12247. }
  12248. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  12249. var canvasWrapper = document.createElement("div");
  12250. canvasWrapper.style.width = div.style.width;
  12251. canvasWrapper.style.height = div.style.height;
  12252. canvasWrapper.classList.add("canvasWrapper");
  12253. if (this.annotationLayer && this.annotationLayer.div) {
  12254. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  12255. } else {
  12256. div.appendChild(canvasWrapper);
  12257. }
  12258. var textLayer = null;
  12259. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  12260. var textLayerDiv = document.createElement("div");
  12261. textLayerDiv.className = "textLayer";
  12262. textLayerDiv.style.width = canvasWrapper.style.width;
  12263. textLayerDiv.style.height = canvasWrapper.style.height;
  12264. if (this.annotationLayer && this.annotationLayer.div) {
  12265. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  12266. } else {
  12267. div.appendChild(textLayerDiv);
  12268. }
  12269. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, this.eventBus);
  12270. }
  12271. this.textLayer = textLayer;
  12272. var renderContinueCallback = null;
  12273. if (this.renderingQueue) {
  12274. renderContinueCallback = function renderContinueCallback(cont) {
  12275. if (!_this.renderingQueue.isHighestPriority(_this)) {
  12276. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  12277. _this.resume = function () {
  12278. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  12279. cont();
  12280. };
  12281. return;
  12282. }
  12283. cont();
  12284. };
  12285. }
  12286. var finishPaintTask = /*#__PURE__*/function () {
  12287. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  12288. var error,
  12289. _args2 = arguments;
  12290. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12291. while (1) {
  12292. switch (_context2.prev = _context2.next) {
  12293. case 0:
  12294. error = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : null;
  12295. if (paintTask === _this.paintTask) {
  12296. _this.paintTask = null;
  12297. }
  12298. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  12299. _context2.next = 5;
  12300. break;
  12301. }
  12302. _this._renderError = null;
  12303. return _context2.abrupt("return");
  12304. case 5:
  12305. _this._renderError = error;
  12306. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  12307. if (_this.loadingIconDiv) {
  12308. div.removeChild(_this.loadingIconDiv);
  12309. delete _this.loadingIconDiv;
  12310. }
  12311. _this._resetZoomLayer(true);
  12312. _this.eventBus.dispatch("pagerendered", {
  12313. source: _this,
  12314. pageNumber: _this.id,
  12315. cssTransform: false,
  12316. timestamp: performance.now(),
  12317. error: _this._renderError
  12318. });
  12319. if (!error) {
  12320. _context2.next = 12;
  12321. break;
  12322. }
  12323. throw error;
  12324. case 12:
  12325. case "end":
  12326. return _context2.stop();
  12327. }
  12328. }
  12329. }, _callee2);
  12330. }));
  12331. return function finishPaintTask() {
  12332. return _ref.apply(this, arguments);
  12333. };
  12334. }();
  12335. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  12336. paintTask.onRenderContinue = renderContinueCallback;
  12337. this.paintTask = paintTask;
  12338. var resultPromise = paintTask.promise.then(function () {
  12339. return finishPaintTask(null).then(function () {
  12340. if (textLayer) {
  12341. var readableStream = pdfPage.streamTextContent({
  12342. normalizeWhitespace: true
  12343. });
  12344. textLayer.setTextContentStream(readableStream);
  12345. textLayer.render();
  12346. }
  12347. });
  12348. }, function (reason) {
  12349. return finishPaintTask(reason);
  12350. });
  12351. if (this.annotationLayerFactory) {
  12352. if (!this.annotationLayer) {
  12353. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, null, this.imageResourcesPath, this.renderInteractiveForms, this.l10n, this.enableScripting, null, null);
  12354. }
  12355. this._renderAnnotationLayer();
  12356. }
  12357. div.setAttribute("data-loaded", true);
  12358. this.eventBus.dispatch("pagerender", {
  12359. source: this,
  12360. pageNumber: this.id
  12361. });
  12362. return resultPromise;
  12363. }
  12364. }, {
  12365. key: "paintOnCanvas",
  12366. value: function paintOnCanvas(canvasWrapper) {
  12367. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  12368. var result = {
  12369. promise: renderCapability.promise,
  12370. onRenderContinue: function onRenderContinue(cont) {
  12371. cont();
  12372. },
  12373. cancel: function cancel() {
  12374. renderTask.cancel();
  12375. }
  12376. };
  12377. var viewport = this.viewport;
  12378. var canvas = document.createElement("canvas");
  12379. this.l10n.get("page_canvas", {
  12380. page: this.id
  12381. }, "Page {{page}}").then(function (msg) {
  12382. canvas.setAttribute("aria-label", msg);
  12383. });
  12384. canvas.setAttribute("hidden", "hidden");
  12385. var isCanvasHidden = true;
  12386. var showCanvas = function showCanvas() {
  12387. if (isCanvasHidden) {
  12388. canvas.removeAttribute("hidden");
  12389. isCanvasHidden = false;
  12390. }
  12391. };
  12392. canvasWrapper.appendChild(canvas);
  12393. this.canvas = canvas;
  12394. canvas.mozOpaque = true;
  12395. var ctx = canvas.getContext("2d", {
  12396. alpha: false
  12397. });
  12398. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  12399. this.outputScale = outputScale;
  12400. if (this.useOnlyCssZoom) {
  12401. var actualSizeViewport = viewport.clone({
  12402. scale: _ui_utils.CSS_UNITS
  12403. });
  12404. outputScale.sx *= actualSizeViewport.width / viewport.width;
  12405. outputScale.sy *= actualSizeViewport.height / viewport.height;
  12406. outputScale.scaled = true;
  12407. }
  12408. if (this.maxCanvasPixels > 0) {
  12409. var pixelsInViewport = viewport.width * viewport.height;
  12410. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  12411. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  12412. outputScale.sx = maxScale;
  12413. outputScale.sy = maxScale;
  12414. outputScale.scaled = true;
  12415. this.hasRestrictedScaling = true;
  12416. } else {
  12417. this.hasRestrictedScaling = false;
  12418. }
  12419. }
  12420. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  12421. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  12422. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  12423. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  12424. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
  12425. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
  12426. this.paintedViewportMap.set(canvas, viewport);
  12427. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  12428. var renderContext = {
  12429. canvasContext: ctx,
  12430. transform: transform,
  12431. viewport: this.viewport,
  12432. enableWebGL: this.enableWebGL,
  12433. renderInteractiveForms: this.renderInteractiveForms,
  12434. optionalContentConfigPromise: this._optionalContentConfigPromise
  12435. };
  12436. var renderTask = this.pdfPage.render(renderContext);
  12437. renderTask.onContinue = function (cont) {
  12438. showCanvas();
  12439. if (result.onRenderContinue) {
  12440. result.onRenderContinue(cont);
  12441. } else {
  12442. cont();
  12443. }
  12444. };
  12445. renderTask.promise.then(function () {
  12446. showCanvas();
  12447. renderCapability.resolve(undefined);
  12448. }, function (error) {
  12449. showCanvas();
  12450. renderCapability.reject(error);
  12451. });
  12452. return result;
  12453. }
  12454. }, {
  12455. key: "paintOnSvg",
  12456. value: function paintOnSvg(wrapper) {
  12457. var _this2 = this;
  12458. var cancelled = false;
  12459. var ensureNotCancelled = function ensureNotCancelled() {
  12460. if (cancelled) {
  12461. throw new _pdfjsLib.RenderingCancelledException("Rendering cancelled, page ".concat(_this2.id), "svg");
  12462. }
  12463. };
  12464. var pdfPage = this.pdfPage;
  12465. var actualSizeViewport = this.viewport.clone({
  12466. scale: _ui_utils.CSS_UNITS
  12467. });
  12468. var promise = pdfPage.getOperatorList().then(function (opList) {
  12469. ensureNotCancelled();
  12470. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  12471. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  12472. ensureNotCancelled();
  12473. _this2.svg = svg;
  12474. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  12475. svg.style.width = wrapper.style.width;
  12476. svg.style.height = wrapper.style.height;
  12477. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  12478. wrapper.appendChild(svg);
  12479. });
  12480. });
  12481. return {
  12482. promise: promise,
  12483. onRenderContinue: function onRenderContinue(cont) {
  12484. cont();
  12485. },
  12486. cancel: function cancel() {
  12487. cancelled = true;
  12488. }
  12489. };
  12490. }
  12491. }, {
  12492. key: "setPageLabel",
  12493. value: function setPageLabel(label) {
  12494. this.pageLabel = typeof label === "string" ? label : null;
  12495. if (this.pageLabel !== null) {
  12496. this.div.setAttribute("data-page-label", this.pageLabel);
  12497. } else {
  12498. this.div.removeAttribute("data-page-label");
  12499. }
  12500. }
  12501. }, {
  12502. key: "width",
  12503. get: function get() {
  12504. return this.viewport.width;
  12505. }
  12506. }, {
  12507. key: "height",
  12508. get: function get() {
  12509. return this.viewport.height;
  12510. }
  12511. }]);
  12512. return PDFPageView;
  12513. }();
  12514. exports.PDFPageView = PDFPageView;
  12515. /***/ }),
  12516. /* 32 */
  12517. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12518. Object.defineProperty(exports, "__esModule", ({
  12519. value: true
  12520. }));
  12521. exports.TextLayerBuilder = exports.DefaultTextLayerFactory = void 0;
  12522. var _pdfjsLib = __webpack_require__(7);
  12523. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12524. 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); } }
  12525. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12526. var EXPAND_DIVS_TIMEOUT = 300;
  12527. var TextLayerBuilder = /*#__PURE__*/function () {
  12528. function TextLayerBuilder(_ref) {
  12529. var textLayerDiv = _ref.textLayerDiv,
  12530. eventBus = _ref.eventBus,
  12531. pageIndex = _ref.pageIndex,
  12532. viewport = _ref.viewport,
  12533. _ref$findController = _ref.findController,
  12534. findController = _ref$findController === void 0 ? null : _ref$findController,
  12535. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  12536. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  12537. _classCallCheck(this, TextLayerBuilder);
  12538. this.textLayerDiv = textLayerDiv;
  12539. this.eventBus = eventBus;
  12540. this.textContent = null;
  12541. this.textContentItemsStr = [];
  12542. this.textContentStream = null;
  12543. this.renderingDone = false;
  12544. this.pageIdx = pageIndex;
  12545. this.pageNumber = this.pageIdx + 1;
  12546. this.matches = [];
  12547. this.viewport = viewport;
  12548. this.textDivs = [];
  12549. this.findController = findController;
  12550. this.textLayerRenderTask = null;
  12551. this.enhanceTextSelection = enhanceTextSelection;
  12552. this._onUpdateTextLayerMatches = null;
  12553. this._bindMouse();
  12554. }
  12555. _createClass(TextLayerBuilder, [{
  12556. key: "_finishRendering",
  12557. value: function _finishRendering() {
  12558. this.renderingDone = true;
  12559. if (!this.enhanceTextSelection) {
  12560. var endOfContent = document.createElement("div");
  12561. endOfContent.className = "endOfContent";
  12562. this.textLayerDiv.appendChild(endOfContent);
  12563. }
  12564. this.eventBus.dispatch("textlayerrendered", {
  12565. source: this,
  12566. pageNumber: this.pageNumber,
  12567. numTextDivs: this.textDivs.length
  12568. });
  12569. }
  12570. }, {
  12571. key: "render",
  12572. value: function render() {
  12573. var _this = this;
  12574. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  12575. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  12576. return;
  12577. }
  12578. this.cancel();
  12579. this.textDivs = [];
  12580. var textLayerFrag = document.createDocumentFragment();
  12581. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  12582. textContent: this.textContent,
  12583. textContentStream: this.textContentStream,
  12584. container: textLayerFrag,
  12585. viewport: this.viewport,
  12586. textDivs: this.textDivs,
  12587. textContentItemsStr: this.textContentItemsStr,
  12588. timeout: timeout,
  12589. enhanceTextSelection: this.enhanceTextSelection
  12590. });
  12591. this.textLayerRenderTask.promise.then(function () {
  12592. _this.textLayerDiv.appendChild(textLayerFrag);
  12593. _this._finishRendering();
  12594. _this._updateMatches();
  12595. }, function (reason) {});
  12596. if (!this._onUpdateTextLayerMatches) {
  12597. this._onUpdateTextLayerMatches = function (evt) {
  12598. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  12599. _this._updateMatches();
  12600. }
  12601. };
  12602. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  12603. }
  12604. }
  12605. }, {
  12606. key: "cancel",
  12607. value: function cancel() {
  12608. if (this.textLayerRenderTask) {
  12609. this.textLayerRenderTask.cancel();
  12610. this.textLayerRenderTask = null;
  12611. }
  12612. if (this._onUpdateTextLayerMatches) {
  12613. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  12614. this._onUpdateTextLayerMatches = null;
  12615. }
  12616. }
  12617. }, {
  12618. key: "setTextContentStream",
  12619. value: function setTextContentStream(readableStream) {
  12620. this.cancel();
  12621. this.textContentStream = readableStream;
  12622. }
  12623. }, {
  12624. key: "setTextContent",
  12625. value: function setTextContent(textContent) {
  12626. this.cancel();
  12627. this.textContent = textContent;
  12628. }
  12629. }, {
  12630. key: "_convertMatches",
  12631. value: function _convertMatches(matches, matchesLength) {
  12632. if (!matches) {
  12633. return [];
  12634. }
  12635. var textContentItemsStr = this.textContentItemsStr;
  12636. var i = 0,
  12637. iIndex = 0;
  12638. var end = textContentItemsStr.length - 1;
  12639. var result = [];
  12640. for (var m = 0, mm = matches.length; m < mm; m++) {
  12641. var matchIdx = matches[m];
  12642. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  12643. iIndex += textContentItemsStr[i].length;
  12644. i++;
  12645. }
  12646. if (i === textContentItemsStr.length) {
  12647. console.error("Could not find a matching mapping");
  12648. }
  12649. var match = {
  12650. begin: {
  12651. divIdx: i,
  12652. offset: matchIdx - iIndex
  12653. }
  12654. };
  12655. matchIdx += matchesLength[m];
  12656. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  12657. iIndex += textContentItemsStr[i].length;
  12658. i++;
  12659. }
  12660. match.end = {
  12661. divIdx: i,
  12662. offset: matchIdx - iIndex
  12663. };
  12664. result.push(match);
  12665. }
  12666. return result;
  12667. }
  12668. }, {
  12669. key: "_renderMatches",
  12670. value: function _renderMatches(matches) {
  12671. if (matches.length === 0) {
  12672. return;
  12673. }
  12674. var findController = this.findController,
  12675. pageIdx = this.pageIdx,
  12676. textContentItemsStr = this.textContentItemsStr,
  12677. textDivs = this.textDivs;
  12678. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  12679. var selectedMatchIdx = findController.selected.matchIdx;
  12680. var highlightAll = findController.state.highlightAll;
  12681. var prevEnd = null;
  12682. var infinity = {
  12683. divIdx: -1,
  12684. offset: undefined
  12685. };
  12686. function beginText(begin, className) {
  12687. var divIdx = begin.divIdx;
  12688. textDivs[divIdx].textContent = "";
  12689. appendTextToDiv(divIdx, 0, begin.offset, className);
  12690. }
  12691. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  12692. var div = textDivs[divIdx];
  12693. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  12694. var node = document.createTextNode(content);
  12695. if (className) {
  12696. var span = document.createElement("span");
  12697. span.className = className;
  12698. span.appendChild(node);
  12699. div.appendChild(span);
  12700. return;
  12701. }
  12702. div.appendChild(node);
  12703. }
  12704. var i0 = selectedMatchIdx,
  12705. i1 = i0 + 1;
  12706. if (highlightAll) {
  12707. i0 = 0;
  12708. i1 = matches.length;
  12709. } else if (!isSelectedPage) {
  12710. return;
  12711. }
  12712. for (var i = i0; i < i1; i++) {
  12713. var match = matches[i];
  12714. var begin = match.begin;
  12715. var end = match.end;
  12716. var isSelected = isSelectedPage && i === selectedMatchIdx;
  12717. var highlightSuffix = isSelected ? " selected" : "";
  12718. if (isSelected) {
  12719. findController.scrollMatchIntoView({
  12720. element: textDivs[begin.divIdx],
  12721. pageIndex: pageIdx,
  12722. matchIndex: selectedMatchIdx
  12723. });
  12724. }
  12725. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  12726. if (prevEnd !== null) {
  12727. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  12728. }
  12729. beginText(begin);
  12730. } else {
  12731. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  12732. }
  12733. if (begin.divIdx === end.divIdx) {
  12734. appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  12735. } else {
  12736. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  12737. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  12738. textDivs[n0].className = "highlight middle" + highlightSuffix;
  12739. }
  12740. beginText(end, "highlight end" + highlightSuffix);
  12741. }
  12742. prevEnd = end;
  12743. }
  12744. if (prevEnd) {
  12745. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  12746. }
  12747. }
  12748. }, {
  12749. key: "_updateMatches",
  12750. value: function _updateMatches() {
  12751. if (!this.renderingDone) {
  12752. return;
  12753. }
  12754. var findController = this.findController,
  12755. matches = this.matches,
  12756. pageIdx = this.pageIdx,
  12757. textContentItemsStr = this.textContentItemsStr,
  12758. textDivs = this.textDivs;
  12759. var clearedUntilDivIdx = -1;
  12760. for (var i = 0, ii = matches.length; i < ii; i++) {
  12761. var match = matches[i];
  12762. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  12763. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  12764. var div = textDivs[n];
  12765. div.textContent = textContentItemsStr[n];
  12766. div.className = "";
  12767. }
  12768. clearedUntilDivIdx = match.end.divIdx + 1;
  12769. }
  12770. if (!findController || !findController.highlightMatches) {
  12771. return;
  12772. }
  12773. var pageMatches = findController.pageMatches[pageIdx] || null;
  12774. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  12775. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  12776. this._renderMatches(this.matches);
  12777. }
  12778. }, {
  12779. key: "_bindMouse",
  12780. value: function _bindMouse() {
  12781. var _this2 = this;
  12782. var div = this.textLayerDiv;
  12783. var expandDivsTimer = null;
  12784. div.addEventListener("mousedown", function (evt) {
  12785. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  12786. _this2.textLayerRenderTask.expandTextDivs(true);
  12787. if (expandDivsTimer) {
  12788. clearTimeout(expandDivsTimer);
  12789. expandDivsTimer = null;
  12790. }
  12791. return;
  12792. }
  12793. var end = div.querySelector(".endOfContent");
  12794. if (!end) {
  12795. return;
  12796. }
  12797. var adjustTop = evt.target !== div;
  12798. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  12799. if (adjustTop) {
  12800. var divBounds = div.getBoundingClientRect();
  12801. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  12802. end.style.top = (r * 100).toFixed(2) + "%";
  12803. }
  12804. end.classList.add("active");
  12805. });
  12806. div.addEventListener("mouseup", function () {
  12807. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  12808. expandDivsTimer = setTimeout(function () {
  12809. if (_this2.textLayerRenderTask) {
  12810. _this2.textLayerRenderTask.expandTextDivs(false);
  12811. }
  12812. expandDivsTimer = null;
  12813. }, EXPAND_DIVS_TIMEOUT);
  12814. return;
  12815. }
  12816. var end = div.querySelector(".endOfContent");
  12817. if (!end) {
  12818. return;
  12819. }
  12820. end.style.top = "";
  12821. end.classList.remove("active");
  12822. });
  12823. }
  12824. }]);
  12825. return TextLayerBuilder;
  12826. }();
  12827. exports.TextLayerBuilder = TextLayerBuilder;
  12828. var DefaultTextLayerFactory = /*#__PURE__*/function () {
  12829. function DefaultTextLayerFactory() {
  12830. _classCallCheck(this, DefaultTextLayerFactory);
  12831. }
  12832. _createClass(DefaultTextLayerFactory, [{
  12833. key: "createTextLayerBuilder",
  12834. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  12835. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  12836. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  12837. return new TextLayerBuilder({
  12838. textLayerDiv: textLayerDiv,
  12839. pageIndex: pageIndex,
  12840. viewport: viewport,
  12841. enhanceTextSelection: enhanceTextSelection,
  12842. eventBus: eventBus
  12843. });
  12844. }
  12845. }]);
  12846. return DefaultTextLayerFactory;
  12847. }();
  12848. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  12849. /***/ }),
  12850. /* 33 */
  12851. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12852. Object.defineProperty(exports, "__esModule", ({
  12853. value: true
  12854. }));
  12855. exports.SecondaryToolbar = void 0;
  12856. var _ui_utils = __webpack_require__(6);
  12857. var _pdf_cursor_tools = __webpack_require__(8);
  12858. var _pdf_single_page_viewer = __webpack_require__(34);
  12859. 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; } } }; }
  12860. 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); }
  12861. 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; }
  12862. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12863. 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); } }
  12864. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12865. var SecondaryToolbar = /*#__PURE__*/function () {
  12866. function SecondaryToolbar(options, mainContainer, eventBus) {
  12867. var _this = this;
  12868. _classCallCheck(this, SecondaryToolbar);
  12869. this.toolbar = options.toolbar;
  12870. this.toggleButton = options.toggleButton;
  12871. this.toolbarButtonContainer = options.toolbarButtonContainer;
  12872. this.buttons = [{
  12873. element: options.presentationModeButton,
  12874. eventName: "presentationmode",
  12875. close: true
  12876. }, {
  12877. element: options.openFileButton,
  12878. eventName: "openfile",
  12879. close: true
  12880. }, {
  12881. element: options.printButton,
  12882. eventName: "print",
  12883. close: true
  12884. }, {
  12885. element: options.downloadButton,
  12886. eventName: "download",
  12887. close: true
  12888. }, {
  12889. element: options.viewBookmarkButton,
  12890. eventName: null,
  12891. close: true
  12892. }, {
  12893. element: options.firstPageButton,
  12894. eventName: "firstpage",
  12895. close: true
  12896. }, {
  12897. element: options.lastPageButton,
  12898. eventName: "lastpage",
  12899. close: true
  12900. }, {
  12901. element: options.pageRotateCwButton,
  12902. eventName: "rotatecw",
  12903. close: false
  12904. }, {
  12905. element: options.pageRotateCcwButton,
  12906. eventName: "rotateccw",
  12907. close: false
  12908. }, {
  12909. element: options.cursorSelectToolButton,
  12910. eventName: "switchcursortool",
  12911. eventDetails: {
  12912. tool: _pdf_cursor_tools.CursorTool.SELECT
  12913. },
  12914. close: true
  12915. }, {
  12916. element: options.cursorHandToolButton,
  12917. eventName: "switchcursortool",
  12918. eventDetails: {
  12919. tool: _pdf_cursor_tools.CursorTool.HAND
  12920. },
  12921. close: true
  12922. }, {
  12923. element: options.scrollVerticalButton,
  12924. eventName: "switchscrollmode",
  12925. eventDetails: {
  12926. mode: _ui_utils.ScrollMode.VERTICAL
  12927. },
  12928. close: true
  12929. }, {
  12930. element: options.scrollHorizontalButton,
  12931. eventName: "switchscrollmode",
  12932. eventDetails: {
  12933. mode: _ui_utils.ScrollMode.HORIZONTAL
  12934. },
  12935. close: true
  12936. }, {
  12937. element: options.scrollWrappedButton,
  12938. eventName: "switchscrollmode",
  12939. eventDetails: {
  12940. mode: _ui_utils.ScrollMode.WRAPPED
  12941. },
  12942. close: true
  12943. }, {
  12944. element: options.spreadNoneButton,
  12945. eventName: "switchspreadmode",
  12946. eventDetails: {
  12947. mode: _ui_utils.SpreadMode.NONE
  12948. },
  12949. close: true
  12950. }, {
  12951. element: options.spreadOddButton,
  12952. eventName: "switchspreadmode",
  12953. eventDetails: {
  12954. mode: _ui_utils.SpreadMode.ODD
  12955. },
  12956. close: true
  12957. }, {
  12958. element: options.spreadEvenButton,
  12959. eventName: "switchspreadmode",
  12960. eventDetails: {
  12961. mode: _ui_utils.SpreadMode.EVEN
  12962. },
  12963. close: true
  12964. }, {
  12965. element: options.documentPropertiesButton,
  12966. eventName: "documentproperties",
  12967. close: true
  12968. }];
  12969. this.items = {
  12970. firstPage: options.firstPageButton,
  12971. lastPage: options.lastPageButton,
  12972. pageRotateCw: options.pageRotateCwButton,
  12973. pageRotateCcw: options.pageRotateCcwButton
  12974. };
  12975. this.mainContainer = mainContainer;
  12976. this.eventBus = eventBus;
  12977. this.opened = false;
  12978. this.containerHeight = null;
  12979. this.previousContainerHeight = null;
  12980. this.reset();
  12981. this._bindClickListeners();
  12982. this._bindCursorToolsListener(options);
  12983. this._bindScrollModeListener(options);
  12984. this._bindSpreadModeListener(options);
  12985. this.eventBus._on("resize", this._setMaxHeight.bind(this));
  12986. this.eventBus._on("baseviewerinit", function (evt) {
  12987. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  12988. _this.toolbarButtonContainer.classList.add("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  12989. } else {
  12990. _this.toolbarButtonContainer.classList.remove("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  12991. }
  12992. });
  12993. }
  12994. _createClass(SecondaryToolbar, [{
  12995. key: "setPageNumber",
  12996. value: function setPageNumber(pageNumber) {
  12997. this.pageNumber = pageNumber;
  12998. this._updateUIState();
  12999. }
  13000. }, {
  13001. key: "setPagesCount",
  13002. value: function setPagesCount(pagesCount) {
  13003. this.pagesCount = pagesCount;
  13004. this._updateUIState();
  13005. }
  13006. }, {
  13007. key: "reset",
  13008. value: function reset() {
  13009. this.pageNumber = 0;
  13010. this.pagesCount = 0;
  13011. this._updateUIState();
  13012. this.eventBus.dispatch("secondarytoolbarreset", {
  13013. source: this
  13014. });
  13015. }
  13016. }, {
  13017. key: "_updateUIState",
  13018. value: function _updateUIState() {
  13019. this.items.firstPage.disabled = this.pageNumber <= 1;
  13020. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  13021. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  13022. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  13023. }
  13024. }, {
  13025. key: "_bindClickListeners",
  13026. value: function _bindClickListeners() {
  13027. var _this2 = this;
  13028. this.toggleButton.addEventListener("click", this.toggle.bind(this));
  13029. var _iterator = _createForOfIteratorHelper(this.buttons),
  13030. _step;
  13031. try {
  13032. var _loop = function _loop() {
  13033. var _step$value = _step.value,
  13034. element = _step$value.element,
  13035. eventName = _step$value.eventName,
  13036. close = _step$value.close,
  13037. eventDetails = _step$value.eventDetails;
  13038. element.addEventListener("click", function (evt) {
  13039. if (eventName !== null) {
  13040. var details = {
  13041. source: _this2
  13042. };
  13043. for (var property in eventDetails) {
  13044. details[property] = eventDetails[property];
  13045. }
  13046. _this2.eventBus.dispatch(eventName, details);
  13047. }
  13048. if (close) {
  13049. _this2.close();
  13050. }
  13051. });
  13052. };
  13053. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  13054. _loop();
  13055. }
  13056. } catch (err) {
  13057. _iterator.e(err);
  13058. } finally {
  13059. _iterator.f();
  13060. }
  13061. }
  13062. }, {
  13063. key: "_bindCursorToolsListener",
  13064. value: function _bindCursorToolsListener(buttons) {
  13065. this.eventBus._on("cursortoolchanged", function (_ref) {
  13066. var tool = _ref.tool;
  13067. buttons.cursorSelectToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.SELECT);
  13068. buttons.cursorHandToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.HAND);
  13069. });
  13070. }
  13071. }, {
  13072. key: "_bindScrollModeListener",
  13073. value: function _bindScrollModeListener(buttons) {
  13074. var _this3 = this;
  13075. function scrollModeChanged(_ref2) {
  13076. var mode = _ref2.mode;
  13077. buttons.scrollVerticalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.VERTICAL);
  13078. buttons.scrollHorizontalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.HORIZONTAL);
  13079. buttons.scrollWrappedButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.WRAPPED);
  13080. var isScrollModeHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
  13081. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  13082. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  13083. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  13084. }
  13085. this.eventBus._on("scrollmodechanged", scrollModeChanged);
  13086. this.eventBus._on("secondarytoolbarreset", function (evt) {
  13087. if (evt.source === _this3) {
  13088. scrollModeChanged({
  13089. mode: _ui_utils.ScrollMode.VERTICAL
  13090. });
  13091. }
  13092. });
  13093. }
  13094. }, {
  13095. key: "_bindSpreadModeListener",
  13096. value: function _bindSpreadModeListener(buttons) {
  13097. var _this4 = this;
  13098. function spreadModeChanged(_ref3) {
  13099. var mode = _ref3.mode;
  13100. buttons.spreadNoneButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.NONE);
  13101. buttons.spreadOddButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.ODD);
  13102. buttons.spreadEvenButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.EVEN);
  13103. }
  13104. this.eventBus._on("spreadmodechanged", spreadModeChanged);
  13105. this.eventBus._on("secondarytoolbarreset", function (evt) {
  13106. if (evt.source === _this4) {
  13107. spreadModeChanged({
  13108. mode: _ui_utils.SpreadMode.NONE
  13109. });
  13110. }
  13111. });
  13112. }
  13113. }, {
  13114. key: "open",
  13115. value: function open() {
  13116. if (this.opened) {
  13117. return;
  13118. }
  13119. this.opened = true;
  13120. this._setMaxHeight();
  13121. this.toggleButton.classList.add("toggled");
  13122. this.toolbar.classList.remove("hidden");
  13123. }
  13124. }, {
  13125. key: "close",
  13126. value: function close() {
  13127. if (!this.opened) {
  13128. return;
  13129. }
  13130. this.opened = false;
  13131. this.toolbar.classList.add("hidden");
  13132. this.toggleButton.classList.remove("toggled");
  13133. }
  13134. }, {
  13135. key: "toggle",
  13136. value: function toggle() {
  13137. if (this.opened) {
  13138. this.close();
  13139. } else {
  13140. this.open();
  13141. }
  13142. }
  13143. }, {
  13144. key: "_setMaxHeight",
  13145. value: function _setMaxHeight() {
  13146. if (!this.opened) {
  13147. return;
  13148. }
  13149. this.containerHeight = this.mainContainer.clientHeight;
  13150. if (this.containerHeight === this.previousContainerHeight) {
  13151. return;
  13152. }
  13153. this.toolbarButtonContainer.style.maxHeight = "".concat(this.containerHeight - _ui_utils.SCROLLBAR_PADDING, "px");
  13154. this.previousContainerHeight = this.containerHeight;
  13155. }
  13156. }, {
  13157. key: "isOpen",
  13158. get: function get() {
  13159. return this.opened;
  13160. }
  13161. }]);
  13162. return SecondaryToolbar;
  13163. }();
  13164. exports.SecondaryToolbar = SecondaryToolbar;
  13165. /***/ }),
  13166. /* 34 */
  13167. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13168. 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); }
  13169. Object.defineProperty(exports, "__esModule", ({
  13170. value: true
  13171. }));
  13172. exports.PDFSinglePageViewer = void 0;
  13173. var _base_viewer = __webpack_require__(29);
  13174. var _pdfjsLib = __webpack_require__(7);
  13175. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13176. 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); } }
  13177. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13178. 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); }
  13179. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  13180. 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); }
  13181. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13182. 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); }; }
  13183. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13184. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13185. 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; } }
  13186. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13187. var PDFSinglePageViewer = /*#__PURE__*/function (_BaseViewer) {
  13188. _inherits(PDFSinglePageViewer, _BaseViewer);
  13189. var _super = _createSuper(PDFSinglePageViewer);
  13190. function PDFSinglePageViewer(options) {
  13191. var _this;
  13192. _classCallCheck(this, PDFSinglePageViewer);
  13193. _this = _super.call(this, options);
  13194. _this.eventBus._on("pagesinit", function (evt) {
  13195. _this._ensurePageViewVisible();
  13196. });
  13197. return _this;
  13198. }
  13199. _createClass(PDFSinglePageViewer, [{
  13200. key: "_resetView",
  13201. value: function _resetView() {
  13202. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  13203. this._previousPageNumber = 1;
  13204. this._shadowViewer = document.createDocumentFragment();
  13205. this._updateScrollDown = null;
  13206. }
  13207. }, {
  13208. key: "_ensurePageViewVisible",
  13209. value: function _ensurePageViewVisible() {
  13210. var pageView = this._pages[this._currentPageNumber - 1];
  13211. var previousPageView = this._pages[this._previousPageNumber - 1];
  13212. var viewerNodes = this.viewer.childNodes;
  13213. switch (viewerNodes.length) {
  13214. case 0:
  13215. this.viewer.appendChild(pageView.div);
  13216. break;
  13217. case 1:
  13218. if (viewerNodes[0] !== previousPageView.div) {
  13219. throw new Error("_ensurePageViewVisible: Unexpected previously visible page.");
  13220. }
  13221. if (pageView === previousPageView) {
  13222. break;
  13223. }
  13224. this._shadowViewer.appendChild(previousPageView.div);
  13225. this.viewer.appendChild(pageView.div);
  13226. this.container.scrollTop = 0;
  13227. break;
  13228. default:
  13229. throw new Error("_ensurePageViewVisible: Only one page should be visible at a time.");
  13230. }
  13231. this._previousPageNumber = this._currentPageNumber;
  13232. }
  13233. }, {
  13234. key: "_scrollUpdate",
  13235. value: function _scrollUpdate() {
  13236. if (this._updateScrollDown) {
  13237. this._updateScrollDown();
  13238. }
  13239. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  13240. }
  13241. }, {
  13242. key: "_scrollIntoView",
  13243. value: function _scrollIntoView(_ref) {
  13244. var _this2 = this;
  13245. var pageDiv = _ref.pageDiv,
  13246. _ref$pageSpot = _ref.pageSpot,
  13247. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  13248. _ref$pageNumber = _ref.pageNumber,
  13249. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  13250. if (pageNumber) {
  13251. this._setCurrentPageNumber(pageNumber);
  13252. }
  13253. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  13254. this._ensurePageViewVisible();
  13255. this.update();
  13256. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  13257. pageDiv: pageDiv,
  13258. pageSpot: pageSpot,
  13259. pageNumber: pageNumber
  13260. });
  13261. this._updateScrollDown = function () {
  13262. _this2.scroll.down = scrolledDown;
  13263. _this2._updateScrollDown = null;
  13264. };
  13265. }
  13266. }, {
  13267. key: "_getVisiblePages",
  13268. value: function _getVisiblePages() {
  13269. return this._getCurrentVisiblePage();
  13270. }
  13271. }, {
  13272. key: "_updateHelper",
  13273. value: function _updateHelper(visiblePages) {}
  13274. }, {
  13275. key: "_updateScrollMode",
  13276. value: function _updateScrollMode() {}
  13277. }, {
  13278. key: "_updateSpreadMode",
  13279. value: function _updateSpreadMode() {}
  13280. }, {
  13281. key: "_getPageAdvance",
  13282. value: function _getPageAdvance() {
  13283. return 1;
  13284. }
  13285. }, {
  13286. key: "_viewerElement",
  13287. get: function get() {
  13288. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this._shadowViewer);
  13289. }
  13290. }, {
  13291. key: "_pageWidthScaleFactor",
  13292. get: function get() {
  13293. return 1;
  13294. }
  13295. }, {
  13296. key: "_isScrollModeHorizontal",
  13297. get: function get() {
  13298. return (0, _pdfjsLib.shadow)(this, "_isScrollModeHorizontal", false);
  13299. }
  13300. }]);
  13301. return PDFSinglePageViewer;
  13302. }(_base_viewer.BaseViewer);
  13303. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  13304. /***/ }),
  13305. /* 35 */
  13306. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13307. Object.defineProperty(exports, "__esModule", ({
  13308. value: true
  13309. }));
  13310. exports.Toolbar = void 0;
  13311. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  13312. var _ui_utils = __webpack_require__(6);
  13313. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13314. 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); } }
  13315. 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); }); }; }
  13316. 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; } } }; }
  13317. 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); }
  13318. 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; }
  13319. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13320. 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); } }
  13321. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13322. var PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
  13323. var SCALE_SELECT_CONTAINER_WIDTH = 140;
  13324. var SCALE_SELECT_WIDTH = 162;
  13325. var Toolbar = /*#__PURE__*/function () {
  13326. function Toolbar(options, eventBus) {
  13327. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  13328. _classCallCheck(this, Toolbar);
  13329. this.toolbar = options.container;
  13330. this.eventBus = eventBus;
  13331. this.l10n = l10n;
  13332. this.buttons = [{
  13333. element: options.previous,
  13334. eventName: "previouspage"
  13335. }, {
  13336. element: options.next,
  13337. eventName: "nextpage"
  13338. }, {
  13339. element: options.zoomIn,
  13340. eventName: "zoomin"
  13341. }, {
  13342. element: options.zoomOut,
  13343. eventName: "zoomout"
  13344. }, {
  13345. element: options.openFile,
  13346. eventName: "openfile"
  13347. }, {
  13348. element: options.print,
  13349. eventName: "print"
  13350. }, {
  13351. element: options.presentationModeButton,
  13352. eventName: "presentationmode"
  13353. }, {
  13354. element: options.download,
  13355. eventName: "download"
  13356. }, {
  13357. element: options.viewBookmark,
  13358. eventName: null
  13359. }];
  13360. this.items = {
  13361. numPages: options.numPages,
  13362. pageNumber: options.pageNumber,
  13363. scaleSelectContainer: options.scaleSelectContainer,
  13364. scaleSelect: options.scaleSelect,
  13365. customScaleOption: options.customScaleOption,
  13366. previous: options.previous,
  13367. next: options.next,
  13368. zoomIn: options.zoomIn,
  13369. zoomOut: options.zoomOut
  13370. };
  13371. this._wasLocalized = false;
  13372. this.reset();
  13373. this._bindListeners();
  13374. }
  13375. _createClass(Toolbar, [{
  13376. key: "setPageNumber",
  13377. value: function setPageNumber(pageNumber, pageLabel) {
  13378. this.pageNumber = pageNumber;
  13379. this.pageLabel = pageLabel;
  13380. this._updateUIState(false);
  13381. }
  13382. }, {
  13383. key: "setPagesCount",
  13384. value: function setPagesCount(pagesCount, hasPageLabels) {
  13385. this.pagesCount = pagesCount;
  13386. this.hasPageLabels = hasPageLabels;
  13387. this._updateUIState(true);
  13388. }
  13389. }, {
  13390. key: "setPageScale",
  13391. value: function setPageScale(pageScaleValue, pageScale) {
  13392. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  13393. this.pageScale = pageScale;
  13394. this._updateUIState(false);
  13395. }
  13396. }, {
  13397. key: "reset",
  13398. value: function reset() {
  13399. this.pageNumber = 0;
  13400. this.pageLabel = null;
  13401. this.hasPageLabels = false;
  13402. this.pagesCount = 0;
  13403. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  13404. this.pageScale = _ui_utils.DEFAULT_SCALE;
  13405. this._updateUIState(true);
  13406. this.updateLoadingIndicatorState();
  13407. }
  13408. }, {
  13409. key: "_bindListeners",
  13410. value: function _bindListeners() {
  13411. var _this = this;
  13412. var _this$items = this.items,
  13413. pageNumber = _this$items.pageNumber,
  13414. scaleSelect = _this$items.scaleSelect;
  13415. var self = this;
  13416. var _iterator = _createForOfIteratorHelper(this.buttons),
  13417. _step;
  13418. try {
  13419. var _loop = function _loop() {
  13420. var _step$value = _step.value,
  13421. element = _step$value.element,
  13422. eventName = _step$value.eventName;
  13423. element.addEventListener("click", function (evt) {
  13424. if (eventName !== null) {
  13425. _this.eventBus.dispatch(eventName, {
  13426. source: _this
  13427. });
  13428. }
  13429. });
  13430. };
  13431. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  13432. _loop();
  13433. }
  13434. } catch (err) {
  13435. _iterator.e(err);
  13436. } finally {
  13437. _iterator.f();
  13438. }
  13439. pageNumber.addEventListener("click", function () {
  13440. this.select();
  13441. });
  13442. pageNumber.addEventListener("change", function () {
  13443. self.eventBus.dispatch("pagenumberchanged", {
  13444. source: self,
  13445. value: this.value
  13446. });
  13447. });
  13448. scaleSelect.addEventListener("change", function () {
  13449. if (this.value === "custom") {
  13450. return;
  13451. }
  13452. self.eventBus.dispatch("scalechanged", {
  13453. source: self,
  13454. value: this.value
  13455. });
  13456. });
  13457. scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  13458. this.eventBus._on("localized", function () {
  13459. _this._wasLocalized = true;
  13460. _this._adjustScaleWidth();
  13461. _this._updateUIState(true);
  13462. });
  13463. }
  13464. }, {
  13465. key: "_updateUIState",
  13466. value: function _updateUIState() {
  13467. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  13468. if (!this._wasLocalized) {
  13469. return;
  13470. }
  13471. var pageNumber = this.pageNumber,
  13472. pagesCount = this.pagesCount,
  13473. pageScaleValue = this.pageScaleValue,
  13474. pageScale = this.pageScale,
  13475. items = this.items;
  13476. if (resetNumPages) {
  13477. if (this.hasPageLabels) {
  13478. items.pageNumber.type = "text";
  13479. } else {
  13480. items.pageNumber.type = "number";
  13481. this.l10n.get("of_pages", {
  13482. pagesCount: pagesCount
  13483. }, "of {{pagesCount}}").then(function (msg) {
  13484. items.numPages.textContent = msg;
  13485. });
  13486. }
  13487. items.pageNumber.max = pagesCount;
  13488. }
  13489. if (this.hasPageLabels) {
  13490. items.pageNumber.value = this.pageLabel;
  13491. this.l10n.get("page_of_pages", {
  13492. pageNumber: pageNumber,
  13493. pagesCount: pagesCount
  13494. }, "({{pageNumber}} of {{pagesCount}})").then(function (msg) {
  13495. items.numPages.textContent = msg;
  13496. });
  13497. } else {
  13498. items.pageNumber.value = pageNumber;
  13499. }
  13500. items.previous.disabled = pageNumber <= 1;
  13501. items.next.disabled = pageNumber >= pagesCount;
  13502. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  13503. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  13504. var customScale = Math.round(pageScale * 10000) / 100;
  13505. this.l10n.get("page_scale_percent", {
  13506. scale: customScale
  13507. }, "{{scale}}%").then(function (msg) {
  13508. var predefinedValueFound = false;
  13509. var _iterator2 = _createForOfIteratorHelper(items.scaleSelect.options),
  13510. _step2;
  13511. try {
  13512. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  13513. var option = _step2.value;
  13514. if (option.value !== pageScaleValue) {
  13515. option.selected = false;
  13516. continue;
  13517. }
  13518. option.selected = true;
  13519. predefinedValueFound = true;
  13520. }
  13521. } catch (err) {
  13522. _iterator2.e(err);
  13523. } finally {
  13524. _iterator2.f();
  13525. }
  13526. if (!predefinedValueFound) {
  13527. items.customScaleOption.textContent = msg;
  13528. items.customScaleOption.selected = true;
  13529. }
  13530. });
  13531. }
  13532. }, {
  13533. key: "updateLoadingIndicatorState",
  13534. value: function updateLoadingIndicatorState() {
  13535. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  13536. var pageNumberInput = this.items.pageNumber;
  13537. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  13538. }
  13539. }, {
  13540. key: "_adjustScaleWidth",
  13541. value: function () {
  13542. var _adjustScaleWidth2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  13543. var items, l10n, predefinedValuesPromise, canvas, ctx, _getComputedStyle, fontSize, fontFamily, maxWidth, _iterator3, _step3, predefinedValue, _ctx$measureText, width, overflow;
  13544. return _regenerator["default"].wrap(function _callee$(_context) {
  13545. while (1) {
  13546. switch (_context.prev = _context.next) {
  13547. case 0:
  13548. items = this.items, l10n = this.l10n;
  13549. 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")]);
  13550. canvas = document.createElement("canvas");
  13551. canvas.mozOpaque = true;
  13552. ctx = canvas.getContext("2d", {
  13553. alpha: false
  13554. });
  13555. _context.next = 7;
  13556. return _ui_utils.animationStarted;
  13557. case 7:
  13558. _getComputedStyle = getComputedStyle(items.scaleSelect), fontSize = _getComputedStyle.fontSize, fontFamily = _getComputedStyle.fontFamily;
  13559. ctx.font = "".concat(fontSize, " ").concat(fontFamily);
  13560. maxWidth = 0;
  13561. _context.t0 = _createForOfIteratorHelper;
  13562. _context.next = 13;
  13563. return predefinedValuesPromise;
  13564. case 13:
  13565. _context.t1 = _context.sent;
  13566. _iterator3 = (0, _context.t0)(_context.t1);
  13567. try {
  13568. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  13569. predefinedValue = _step3.value;
  13570. _ctx$measureText = ctx.measureText(predefinedValue), width = _ctx$measureText.width;
  13571. if (width > maxWidth) {
  13572. maxWidth = width;
  13573. }
  13574. }
  13575. } catch (err) {
  13576. _iterator3.e(err);
  13577. } finally {
  13578. _iterator3.f();
  13579. }
  13580. overflow = SCALE_SELECT_WIDTH - SCALE_SELECT_CONTAINER_WIDTH;
  13581. maxWidth += 2 * overflow;
  13582. if (maxWidth > SCALE_SELECT_CONTAINER_WIDTH) {
  13583. items.scaleSelect.style.width = "".concat(maxWidth + overflow, "px");
  13584. items.scaleSelectContainer.style.width = "".concat(maxWidth, "px");
  13585. }
  13586. canvas.width = 0;
  13587. canvas.height = 0;
  13588. canvas = ctx = null;
  13589. case 22:
  13590. case "end":
  13591. return _context.stop();
  13592. }
  13593. }
  13594. }, _callee, this);
  13595. }));
  13596. function _adjustScaleWidth() {
  13597. return _adjustScaleWidth2.apply(this, arguments);
  13598. }
  13599. return _adjustScaleWidth;
  13600. }()
  13601. }]);
  13602. return Toolbar;
  13603. }();
  13604. exports.Toolbar = Toolbar;
  13605. /***/ }),
  13606. /* 36 */
  13607. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13608. Object.defineProperty(exports, "__esModule", ({
  13609. value: true
  13610. }));
  13611. exports.ViewHistory = void 0;
  13612. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  13613. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13614. 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); } }
  13615. 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); }); }; }
  13616. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13617. 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); } }
  13618. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13619. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  13620. var ViewHistory = /*#__PURE__*/function () {
  13621. function ViewHistory(fingerprint) {
  13622. var _this = this;
  13623. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  13624. _classCallCheck(this, ViewHistory);
  13625. this.fingerprint = fingerprint;
  13626. this.cacheSize = cacheSize;
  13627. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  13628. var database = JSON.parse(databaseStr || "{}");
  13629. var index = -1;
  13630. if (!Array.isArray(database.files)) {
  13631. database.files = [];
  13632. } else {
  13633. while (database.files.length >= _this.cacheSize) {
  13634. database.files.shift();
  13635. }
  13636. for (var i = 0, ii = database.files.length; i < ii; i++) {
  13637. var branch = database.files[i];
  13638. if (branch.fingerprint === _this.fingerprint) {
  13639. index = i;
  13640. break;
  13641. }
  13642. }
  13643. }
  13644. if (index === -1) {
  13645. index = database.files.push({
  13646. fingerprint: _this.fingerprint
  13647. }) - 1;
  13648. }
  13649. _this.file = database.files[index];
  13650. _this.database = database;
  13651. });
  13652. }
  13653. _createClass(ViewHistory, [{
  13654. key: "_writeToStorage",
  13655. value: function () {
  13656. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  13657. var databaseStr;
  13658. return _regenerator["default"].wrap(function _callee$(_context) {
  13659. while (1) {
  13660. switch (_context.prev = _context.next) {
  13661. case 0:
  13662. databaseStr = JSON.stringify(this.database);
  13663. localStorage.setItem("pdfjs.history", databaseStr);
  13664. case 2:
  13665. case "end":
  13666. return _context.stop();
  13667. }
  13668. }
  13669. }, _callee, this);
  13670. }));
  13671. function _writeToStorage() {
  13672. return _writeToStorage2.apply(this, arguments);
  13673. }
  13674. return _writeToStorage;
  13675. }()
  13676. }, {
  13677. key: "_readFromStorage",
  13678. value: function () {
  13679. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  13680. return _regenerator["default"].wrap(function _callee2$(_context2) {
  13681. while (1) {
  13682. switch (_context2.prev = _context2.next) {
  13683. case 0:
  13684. return _context2.abrupt("return", localStorage.getItem("pdfjs.history"));
  13685. case 1:
  13686. case "end":
  13687. return _context2.stop();
  13688. }
  13689. }
  13690. }, _callee2);
  13691. }));
  13692. function _readFromStorage() {
  13693. return _readFromStorage2.apply(this, arguments);
  13694. }
  13695. return _readFromStorage;
  13696. }()
  13697. }, {
  13698. key: "set",
  13699. value: function () {
  13700. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name, val) {
  13701. return _regenerator["default"].wrap(function _callee3$(_context3) {
  13702. while (1) {
  13703. switch (_context3.prev = _context3.next) {
  13704. case 0:
  13705. _context3.next = 2;
  13706. return this._initializedPromise;
  13707. case 2:
  13708. this.file[name] = val;
  13709. return _context3.abrupt("return", this._writeToStorage());
  13710. case 4:
  13711. case "end":
  13712. return _context3.stop();
  13713. }
  13714. }
  13715. }, _callee3, this);
  13716. }));
  13717. function set(_x, _x2) {
  13718. return _set.apply(this, arguments);
  13719. }
  13720. return set;
  13721. }()
  13722. }, {
  13723. key: "setMultiple",
  13724. value: function () {
  13725. var _setMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(properties) {
  13726. var name;
  13727. return _regenerator["default"].wrap(function _callee4$(_context4) {
  13728. while (1) {
  13729. switch (_context4.prev = _context4.next) {
  13730. case 0:
  13731. _context4.next = 2;
  13732. return this._initializedPromise;
  13733. case 2:
  13734. for (name in properties) {
  13735. this.file[name] = properties[name];
  13736. }
  13737. return _context4.abrupt("return", this._writeToStorage());
  13738. case 4:
  13739. case "end":
  13740. return _context4.stop();
  13741. }
  13742. }
  13743. }, _callee4, this);
  13744. }));
  13745. function setMultiple(_x3) {
  13746. return _setMultiple.apply(this, arguments);
  13747. }
  13748. return setMultiple;
  13749. }()
  13750. }, {
  13751. key: "get",
  13752. value: function () {
  13753. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name, defaultValue) {
  13754. var val;
  13755. return _regenerator["default"].wrap(function _callee5$(_context5) {
  13756. while (1) {
  13757. switch (_context5.prev = _context5.next) {
  13758. case 0:
  13759. _context5.next = 2;
  13760. return this._initializedPromise;
  13761. case 2:
  13762. val = this.file[name];
  13763. return _context5.abrupt("return", val !== undefined ? val : defaultValue);
  13764. case 4:
  13765. case "end":
  13766. return _context5.stop();
  13767. }
  13768. }
  13769. }, _callee5, this);
  13770. }));
  13771. function get(_x4, _x5) {
  13772. return _get.apply(this, arguments);
  13773. }
  13774. return get;
  13775. }()
  13776. }, {
  13777. key: "getMultiple",
  13778. value: function () {
  13779. var _getMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6(properties) {
  13780. var values, name, val;
  13781. return _regenerator["default"].wrap(function _callee6$(_context6) {
  13782. while (1) {
  13783. switch (_context6.prev = _context6.next) {
  13784. case 0:
  13785. _context6.next = 2;
  13786. return this._initializedPromise;
  13787. case 2:
  13788. values = Object.create(null);
  13789. for (name in properties) {
  13790. val = this.file[name];
  13791. values[name] = val !== undefined ? val : properties[name];
  13792. }
  13793. return _context6.abrupt("return", values);
  13794. case 5:
  13795. case "end":
  13796. return _context6.stop();
  13797. }
  13798. }
  13799. }, _callee6, this);
  13800. }));
  13801. function getMultiple(_x6) {
  13802. return _getMultiple.apply(this, arguments);
  13803. }
  13804. return getMultiple;
  13805. }()
  13806. }]);
  13807. return ViewHistory;
  13808. }();
  13809. exports.ViewHistory = ViewHistory;
  13810. /***/ }),
  13811. /* 37 */
  13812. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13813. 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); }
  13814. Object.defineProperty(exports, "__esModule", ({
  13815. value: true
  13816. }));
  13817. exports.GenericCom = void 0;
  13818. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  13819. var _app = __webpack_require__(3);
  13820. var _preferences = __webpack_require__(38);
  13821. var _download_manager = __webpack_require__(39);
  13822. var _genericl10n = __webpack_require__(40);
  13823. var _generic_scripting = __webpack_require__(42);
  13824. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13825. 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); } }
  13826. 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); }); }; }
  13827. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13828. 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); } }
  13829. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13830. 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); }
  13831. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13832. 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); }; }
  13833. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13834. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13835. 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; } }
  13836. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13837. ;
  13838. var GenericCom = {};
  13839. exports.GenericCom = GenericCom;
  13840. var GenericPreferences = /*#__PURE__*/function (_BasePreferences) {
  13841. _inherits(GenericPreferences, _BasePreferences);
  13842. var _super = _createSuper(GenericPreferences);
  13843. function GenericPreferences() {
  13844. _classCallCheck(this, GenericPreferences);
  13845. return _super.apply(this, arguments);
  13846. }
  13847. _createClass(GenericPreferences, [{
  13848. key: "_writeToStorage",
  13849. value: function () {
  13850. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  13851. return _regenerator["default"].wrap(function _callee$(_context) {
  13852. while (1) {
  13853. switch (_context.prev = _context.next) {
  13854. case 0:
  13855. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  13856. case 1:
  13857. case "end":
  13858. return _context.stop();
  13859. }
  13860. }
  13861. }, _callee);
  13862. }));
  13863. function _writeToStorage(_x) {
  13864. return _writeToStorage2.apply(this, arguments);
  13865. }
  13866. return _writeToStorage;
  13867. }()
  13868. }, {
  13869. key: "_readFromStorage",
  13870. value: function () {
  13871. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  13872. return _regenerator["default"].wrap(function _callee2$(_context2) {
  13873. while (1) {
  13874. switch (_context2.prev = _context2.next) {
  13875. case 0:
  13876. return _context2.abrupt("return", JSON.parse(localStorage.getItem("pdfjs.preferences")));
  13877. case 1:
  13878. case "end":
  13879. return _context2.stop();
  13880. }
  13881. }
  13882. }, _callee2);
  13883. }));
  13884. function _readFromStorage(_x2) {
  13885. return _readFromStorage2.apply(this, arguments);
  13886. }
  13887. return _readFromStorage;
  13888. }()
  13889. }]);
  13890. return GenericPreferences;
  13891. }(_preferences.BasePreferences);
  13892. var GenericExternalServices = /*#__PURE__*/function (_DefaultExternalServi) {
  13893. _inherits(GenericExternalServices, _DefaultExternalServi);
  13894. var _super2 = _createSuper(GenericExternalServices);
  13895. function GenericExternalServices() {
  13896. _classCallCheck(this, GenericExternalServices);
  13897. return _super2.apply(this, arguments);
  13898. }
  13899. _createClass(GenericExternalServices, null, [{
  13900. key: "createDownloadManager",
  13901. value: function createDownloadManager(options) {
  13902. return new _download_manager.DownloadManager();
  13903. }
  13904. }, {
  13905. key: "createPreferences",
  13906. value: function createPreferences() {
  13907. return new GenericPreferences();
  13908. }
  13909. }, {
  13910. key: "createL10n",
  13911. value: function createL10n(_ref) {
  13912. var _ref$locale = _ref.locale,
  13913. locale = _ref$locale === void 0 ? "en-US" : _ref$locale;
  13914. return new _genericl10n.GenericL10n(locale);
  13915. }
  13916. }, {
  13917. key: "createScripting",
  13918. value: function createScripting(_ref2) {
  13919. var sandboxBundleSrc = _ref2.sandboxBundleSrc;
  13920. return new _generic_scripting.GenericScripting(sandboxBundleSrc);
  13921. }
  13922. }]);
  13923. return GenericExternalServices;
  13924. }(_app.DefaultExternalServices);
  13925. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  13926. /***/ }),
  13927. /* 38 */
  13928. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13929. Object.defineProperty(exports, "__esModule", ({
  13930. value: true
  13931. }));
  13932. exports.BasePreferences = void 0;
  13933. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  13934. var _app_options = __webpack_require__(1);
  13935. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13936. 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); } }
  13937. 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); }); }; }
  13938. 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); }
  13939. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13940. 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); } }
  13941. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13942. var BasePreferences = /*#__PURE__*/function () {
  13943. function BasePreferences() {
  13944. var _this = this;
  13945. _classCallCheck(this, BasePreferences);
  13946. if (this.constructor === BasePreferences) {
  13947. throw new Error("Cannot initialize BasePreferences.");
  13948. }
  13949. Object.defineProperty(this, "defaults", {
  13950. value: Object.freeze({
  13951. "cursorToolOnLoad": 0,
  13952. "defaultZoomValue": "",
  13953. "disablePageLabels": false,
  13954. "enablePermissions": false,
  13955. "enablePrintAutoRotate": false,
  13956. "enableScripting": false,
  13957. "enableWebGL": false,
  13958. "externalLinkTarget": 0,
  13959. "historyUpdateUrl": false,
  13960. "ignoreDestinationZoom": false,
  13961. "pdfBugEnabled": false,
  13962. "renderer": "canvas",
  13963. "renderInteractiveForms": true,
  13964. "sidebarViewOnLoad": -1,
  13965. "scrollModeOnLoad": -1,
  13966. "spreadModeOnLoad": -1,
  13967. "textLayerMode": 1,
  13968. "useOnlyCssZoom": false,
  13969. "viewerCssTheme": 0,
  13970. "viewOnLoad": 0,
  13971. "disableAutoFetch": false,
  13972. "disableFontFace": false,
  13973. "disableRange": false,
  13974. "disableStream": false
  13975. }),
  13976. writable: false,
  13977. enumerable: true,
  13978. configurable: false
  13979. });
  13980. this.prefs = Object.assign(Object.create(null), this.defaults);
  13981. this._initializedPromise = this._readFromStorage(this.defaults).then(function (prefs) {
  13982. if (!prefs) {
  13983. return;
  13984. }
  13985. for (var name in prefs) {
  13986. var defaultValue = _this.defaults[name],
  13987. prefValue = prefs[name];
  13988. if (defaultValue === undefined || _typeof(prefValue) !== _typeof(defaultValue)) {
  13989. continue;
  13990. }
  13991. _this.prefs[name] = prefValue;
  13992. }
  13993. });
  13994. }
  13995. _createClass(BasePreferences, [{
  13996. key: "_writeToStorage",
  13997. value: function () {
  13998. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  13999. return _regenerator["default"].wrap(function _callee$(_context) {
  14000. while (1) {
  14001. switch (_context.prev = _context.next) {
  14002. case 0:
  14003. throw new Error("Not implemented: _writeToStorage");
  14004. case 1:
  14005. case "end":
  14006. return _context.stop();
  14007. }
  14008. }
  14009. }, _callee);
  14010. }));
  14011. function _writeToStorage(_x) {
  14012. return _writeToStorage2.apply(this, arguments);
  14013. }
  14014. return _writeToStorage;
  14015. }()
  14016. }, {
  14017. key: "_readFromStorage",
  14018. value: function () {
  14019. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  14020. return _regenerator["default"].wrap(function _callee2$(_context2) {
  14021. while (1) {
  14022. switch (_context2.prev = _context2.next) {
  14023. case 0:
  14024. throw new Error("Not implemented: _readFromStorage");
  14025. case 1:
  14026. case "end":
  14027. return _context2.stop();
  14028. }
  14029. }
  14030. }, _callee2);
  14031. }));
  14032. function _readFromStorage(_x2) {
  14033. return _readFromStorage2.apply(this, arguments);
  14034. }
  14035. return _readFromStorage;
  14036. }()
  14037. }, {
  14038. key: "reset",
  14039. value: function () {
  14040. var _reset = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  14041. return _regenerator["default"].wrap(function _callee3$(_context3) {
  14042. while (1) {
  14043. switch (_context3.prev = _context3.next) {
  14044. case 0:
  14045. _context3.next = 2;
  14046. return this._initializedPromise;
  14047. case 2:
  14048. this.prefs = Object.assign(Object.create(null), this.defaults);
  14049. return _context3.abrupt("return", this._writeToStorage(this.defaults));
  14050. case 4:
  14051. case "end":
  14052. return _context3.stop();
  14053. }
  14054. }
  14055. }, _callee3, this);
  14056. }));
  14057. function reset() {
  14058. return _reset.apply(this, arguments);
  14059. }
  14060. return reset;
  14061. }()
  14062. }, {
  14063. key: "set",
  14064. value: function () {
  14065. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name, value) {
  14066. var defaultValue, valueType, defaultType;
  14067. return _regenerator["default"].wrap(function _callee4$(_context4) {
  14068. while (1) {
  14069. switch (_context4.prev = _context4.next) {
  14070. case 0:
  14071. _context4.next = 2;
  14072. return this._initializedPromise;
  14073. case 2:
  14074. defaultValue = this.defaults[name];
  14075. if (!(defaultValue === undefined)) {
  14076. _context4.next = 7;
  14077. break;
  14078. }
  14079. throw new Error("Set preference: \"".concat(name, "\" is undefined."));
  14080. case 7:
  14081. if (!(value === undefined)) {
  14082. _context4.next = 9;
  14083. break;
  14084. }
  14085. throw new Error("Set preference: no value is specified.");
  14086. case 9:
  14087. valueType = _typeof(value);
  14088. defaultType = _typeof(defaultValue);
  14089. if (!(valueType !== defaultType)) {
  14090. _context4.next = 19;
  14091. break;
  14092. }
  14093. if (!(valueType === "number" && defaultType === "string")) {
  14094. _context4.next = 16;
  14095. break;
  14096. }
  14097. value = value.toString();
  14098. _context4.next = 17;
  14099. break;
  14100. case 16:
  14101. throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", ") + "expected a ".concat(defaultType, "."));
  14102. case 17:
  14103. _context4.next = 21;
  14104. break;
  14105. case 19:
  14106. if (!(valueType === "number" && !Number.isInteger(value))) {
  14107. _context4.next = 21;
  14108. break;
  14109. }
  14110. throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
  14111. case 21:
  14112. this.prefs[name] = value;
  14113. return _context4.abrupt("return", this._writeToStorage(this.prefs));
  14114. case 23:
  14115. case "end":
  14116. return _context4.stop();
  14117. }
  14118. }
  14119. }, _callee4, this);
  14120. }));
  14121. function set(_x3, _x4) {
  14122. return _set.apply(this, arguments);
  14123. }
  14124. return set;
  14125. }()
  14126. }, {
  14127. key: "get",
  14128. value: function () {
  14129. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name) {
  14130. var defaultValue, prefValue;
  14131. return _regenerator["default"].wrap(function _callee5$(_context5) {
  14132. while (1) {
  14133. switch (_context5.prev = _context5.next) {
  14134. case 0:
  14135. _context5.next = 2;
  14136. return this._initializedPromise;
  14137. case 2:
  14138. defaultValue = this.defaults[name];
  14139. if (!(defaultValue === undefined)) {
  14140. _context5.next = 7;
  14141. break;
  14142. }
  14143. throw new Error("Get preference: \"".concat(name, "\" is undefined."));
  14144. case 7:
  14145. prefValue = this.prefs[name];
  14146. if (!(prefValue !== undefined)) {
  14147. _context5.next = 10;
  14148. break;
  14149. }
  14150. return _context5.abrupt("return", prefValue);
  14151. case 10:
  14152. return _context5.abrupt("return", defaultValue);
  14153. case 11:
  14154. case "end":
  14155. return _context5.stop();
  14156. }
  14157. }
  14158. }, _callee5, this);
  14159. }));
  14160. function get(_x5) {
  14161. return _get.apply(this, arguments);
  14162. }
  14163. return get;
  14164. }()
  14165. }, {
  14166. key: "getAll",
  14167. value: function () {
  14168. var _getAll = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  14169. return _regenerator["default"].wrap(function _callee6$(_context6) {
  14170. while (1) {
  14171. switch (_context6.prev = _context6.next) {
  14172. case 0:
  14173. _context6.next = 2;
  14174. return this._initializedPromise;
  14175. case 2:
  14176. return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs));
  14177. case 3:
  14178. case "end":
  14179. return _context6.stop();
  14180. }
  14181. }
  14182. }, _callee6, this);
  14183. }));
  14184. function getAll() {
  14185. return _getAll.apply(this, arguments);
  14186. }
  14187. return getAll;
  14188. }()
  14189. }]);
  14190. return BasePreferences;
  14191. }();
  14192. exports.BasePreferences = BasePreferences;
  14193. /***/ }),
  14194. /* 39 */
  14195. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14196. Object.defineProperty(exports, "__esModule", ({
  14197. value: true
  14198. }));
  14199. exports.DownloadManager = void 0;
  14200. var _pdfjsLib = __webpack_require__(7);
  14201. var _viewer_compatibility = __webpack_require__(2);
  14202. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14203. 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); } }
  14204. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14205. ;
  14206. function _download(blobUrl, filename) {
  14207. var a = document.createElement("a");
  14208. if (!a.click) {
  14209. throw new Error('DownloadManager: "a.click()" is not supported.');
  14210. }
  14211. a.href = blobUrl;
  14212. a.target = "_parent";
  14213. if ("download" in a) {
  14214. a.download = filename;
  14215. }
  14216. (document.body || document.documentElement).appendChild(a);
  14217. a.click();
  14218. a.remove();
  14219. }
  14220. var DownloadManager = /*#__PURE__*/function () {
  14221. function DownloadManager() {
  14222. _classCallCheck(this, DownloadManager);
  14223. }
  14224. _createClass(DownloadManager, [{
  14225. key: "downloadUrl",
  14226. value: function downloadUrl(url, filename) {
  14227. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  14228. return;
  14229. }
  14230. _download(url + "#pdfjs.action=download", filename);
  14231. }
  14232. }, {
  14233. key: "downloadData",
  14234. value: function downloadData(data, filename, contentType) {
  14235. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
  14236. _download(blobUrl, filename);
  14237. }
  14238. }, {
  14239. key: "download",
  14240. value: function download(blob, url, filename) {
  14241. var sourceEventType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "download";
  14242. if (_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  14243. this.downloadUrl(url, filename);
  14244. return;
  14245. }
  14246. var blobUrl = URL.createObjectURL(blob);
  14247. _download(blobUrl, filename);
  14248. }
  14249. }]);
  14250. return DownloadManager;
  14251. }();
  14252. exports.DownloadManager = DownloadManager;
  14253. /***/ }),
  14254. /* 40 */
  14255. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14256. Object.defineProperty(exports, "__esModule", ({
  14257. value: true
  14258. }));
  14259. exports.GenericL10n = void 0;
  14260. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  14261. __webpack_require__(41);
  14262. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14263. 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); } }
  14264. 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); }); }; }
  14265. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14266. 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); } }
  14267. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14268. var webL10n = document.webL10n;
  14269. var GenericL10n = /*#__PURE__*/function () {
  14270. function GenericL10n(lang) {
  14271. _classCallCheck(this, GenericL10n);
  14272. this._lang = lang;
  14273. this._ready = new Promise(function (resolve, reject) {
  14274. webL10n.setLanguage(lang, function () {
  14275. resolve(webL10n);
  14276. });
  14277. });
  14278. }
  14279. _createClass(GenericL10n, [{
  14280. key: "getLanguage",
  14281. value: function () {
  14282. var _getLanguage = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  14283. var l10n;
  14284. return _regenerator["default"].wrap(function _callee$(_context) {
  14285. while (1) {
  14286. switch (_context.prev = _context.next) {
  14287. case 0:
  14288. _context.next = 2;
  14289. return this._ready;
  14290. case 2:
  14291. l10n = _context.sent;
  14292. return _context.abrupt("return", l10n.getLanguage());
  14293. case 4:
  14294. case "end":
  14295. return _context.stop();
  14296. }
  14297. }
  14298. }, _callee, this);
  14299. }));
  14300. function getLanguage() {
  14301. return _getLanguage.apply(this, arguments);
  14302. }
  14303. return getLanguage;
  14304. }()
  14305. }, {
  14306. key: "getDirection",
  14307. value: function () {
  14308. var _getDirection = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  14309. var l10n;
  14310. return _regenerator["default"].wrap(function _callee2$(_context2) {
  14311. while (1) {
  14312. switch (_context2.prev = _context2.next) {
  14313. case 0:
  14314. _context2.next = 2;
  14315. return this._ready;
  14316. case 2:
  14317. l10n = _context2.sent;
  14318. return _context2.abrupt("return", l10n.getDirection());
  14319. case 4:
  14320. case "end":
  14321. return _context2.stop();
  14322. }
  14323. }
  14324. }, _callee2, this);
  14325. }));
  14326. function getDirection() {
  14327. return _getDirection.apply(this, arguments);
  14328. }
  14329. return getDirection;
  14330. }()
  14331. }, {
  14332. key: "get",
  14333. value: function () {
  14334. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(property, args, fallback) {
  14335. var l10n;
  14336. return _regenerator["default"].wrap(function _callee3$(_context3) {
  14337. while (1) {
  14338. switch (_context3.prev = _context3.next) {
  14339. case 0:
  14340. _context3.next = 2;
  14341. return this._ready;
  14342. case 2:
  14343. l10n = _context3.sent;
  14344. return _context3.abrupt("return", l10n.get(property, args, fallback));
  14345. case 4:
  14346. case "end":
  14347. return _context3.stop();
  14348. }
  14349. }
  14350. }, _callee3, this);
  14351. }));
  14352. function get(_x, _x2, _x3) {
  14353. return _get.apply(this, arguments);
  14354. }
  14355. return get;
  14356. }()
  14357. }, {
  14358. key: "translate",
  14359. value: function () {
  14360. var _translate = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(element) {
  14361. var l10n;
  14362. return _regenerator["default"].wrap(function _callee4$(_context4) {
  14363. while (1) {
  14364. switch (_context4.prev = _context4.next) {
  14365. case 0:
  14366. _context4.next = 2;
  14367. return this._ready;
  14368. case 2:
  14369. l10n = _context4.sent;
  14370. return _context4.abrupt("return", l10n.translate(element));
  14371. case 4:
  14372. case "end":
  14373. return _context4.stop();
  14374. }
  14375. }
  14376. }, _callee4, this);
  14377. }));
  14378. function translate(_x4) {
  14379. return _translate.apply(this, arguments);
  14380. }
  14381. return translate;
  14382. }()
  14383. }]);
  14384. return GenericL10n;
  14385. }();
  14386. exports.GenericL10n = GenericL10n;
  14387. /***/ }),
  14388. /* 41 */
  14389. /***/ (() => {
  14390. document.webL10n = function (window, document, undefined) {
  14391. var gL10nData = {};
  14392. var gTextData = '';
  14393. var gTextProp = 'textContent';
  14394. var gLanguage = '';
  14395. var gMacros = {};
  14396. var gReadyState = 'loading';
  14397. var gAsyncResourceLoading = true;
  14398. function getL10nResourceLinks() {
  14399. return document.querySelectorAll('link[type="application/l10n"]');
  14400. }
  14401. function getL10nDictionary() {
  14402. var script = document.querySelector('script[type="application/l10n"]');
  14403. return script ? JSON.parse(script.innerHTML) : null;
  14404. }
  14405. function getTranslatableChildren(element) {
  14406. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  14407. }
  14408. function getL10nAttributes(element) {
  14409. if (!element) return {};
  14410. var l10nId = element.getAttribute('data-l10n-id');
  14411. var l10nArgs = element.getAttribute('data-l10n-args');
  14412. var args = {};
  14413. if (l10nArgs) {
  14414. try {
  14415. args = JSON.parse(l10nArgs);
  14416. } catch (e) {
  14417. console.warn('could not parse arguments for #' + l10nId);
  14418. }
  14419. }
  14420. return {
  14421. id: l10nId,
  14422. args: args
  14423. };
  14424. }
  14425. function xhrLoadText(url, onSuccess, onFailure) {
  14426. onSuccess = onSuccess || function _onSuccess(data) {};
  14427. onFailure = onFailure || function _onFailure() {};
  14428. var xhr = new XMLHttpRequest();
  14429. xhr.open('GET', url, gAsyncResourceLoading);
  14430. if (xhr.overrideMimeType) {
  14431. xhr.overrideMimeType('text/plain; charset=utf-8');
  14432. }
  14433. xhr.onreadystatechange = function () {
  14434. if (xhr.readyState == 4) {
  14435. if (xhr.status == 200 || xhr.status === 0) {
  14436. onSuccess(xhr.responseText);
  14437. } else {
  14438. onFailure();
  14439. }
  14440. }
  14441. };
  14442. xhr.onerror = onFailure;
  14443. xhr.ontimeout = onFailure;
  14444. try {
  14445. xhr.send(null);
  14446. } catch (e) {
  14447. onFailure();
  14448. }
  14449. }
  14450. function parseResource(href, lang, successCallback, failureCallback) {
  14451. var baseURL = href.replace(/[^\/]*$/, '') || './';
  14452. function evalString(text) {
  14453. if (text.lastIndexOf('\\') < 0) return text;
  14454. 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, "'");
  14455. }
  14456. function parseProperties(text, parsedPropertiesCallback) {
  14457. var dictionary = {};
  14458. var reBlank = /^\s*|\s*$/;
  14459. var reComment = /^\s*#|^\s*$/;
  14460. var reSection = /^\s*\[(.*)\]\s*$/;
  14461. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  14462. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  14463. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  14464. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  14465. var currentLang = '*';
  14466. var genericLang = lang.split('-', 1)[0];
  14467. var skipLang = false;
  14468. var match = '';
  14469. function nextEntry() {
  14470. while (true) {
  14471. if (!entries.length) {
  14472. parsedRawLinesCallback();
  14473. return;
  14474. }
  14475. var line = entries.shift();
  14476. if (reComment.test(line)) continue;
  14477. if (extendedSyntax) {
  14478. match = reSection.exec(line);
  14479. if (match) {
  14480. currentLang = match[1].toLowerCase();
  14481. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  14482. continue;
  14483. } else if (skipLang) {
  14484. continue;
  14485. }
  14486. match = reImport.exec(line);
  14487. if (match) {
  14488. loadImport(baseURL + match[1], nextEntry);
  14489. return;
  14490. }
  14491. }
  14492. var tmp = line.match(reSplit);
  14493. if (tmp && tmp.length == 3) {
  14494. dictionary[tmp[1]] = evalString(tmp[2]);
  14495. }
  14496. }
  14497. }
  14498. nextEntry();
  14499. }
  14500. function loadImport(url, callback) {
  14501. xhrLoadText(url, function (content) {
  14502. parseRawLines(content, false, callback);
  14503. }, function () {
  14504. console.warn(url + ' not found.');
  14505. callback();
  14506. });
  14507. }
  14508. parseRawLines(text, true, function () {
  14509. parsedPropertiesCallback(dictionary);
  14510. });
  14511. }
  14512. xhrLoadText(href, function (response) {
  14513. gTextData += response;
  14514. parseProperties(response, function (data) {
  14515. for (var key in data) {
  14516. var id,
  14517. prop,
  14518. index = key.lastIndexOf('.');
  14519. if (index > 0) {
  14520. id = key.substring(0, index);
  14521. prop = key.substring(index + 1);
  14522. } else {
  14523. id = key;
  14524. prop = gTextProp;
  14525. }
  14526. if (!gL10nData[id]) {
  14527. gL10nData[id] = {};
  14528. }
  14529. gL10nData[id][prop] = data[key];
  14530. }
  14531. if (successCallback) {
  14532. successCallback();
  14533. }
  14534. });
  14535. }, failureCallback);
  14536. }
  14537. function loadLocale(lang, callback) {
  14538. if (lang) {
  14539. lang = lang.toLowerCase();
  14540. }
  14541. callback = callback || function _callback() {};
  14542. clear();
  14543. gLanguage = lang;
  14544. var langLinks = getL10nResourceLinks();
  14545. var langCount = langLinks.length;
  14546. if (langCount === 0) {
  14547. var dict = getL10nDictionary();
  14548. if (dict && dict.locales && dict.default_locale) {
  14549. console.log('using the embedded JSON directory, early way out');
  14550. gL10nData = dict.locales[lang];
  14551. if (!gL10nData) {
  14552. var defaultLocale = dict.default_locale.toLowerCase();
  14553. for (var anyCaseLang in dict.locales) {
  14554. anyCaseLang = anyCaseLang.toLowerCase();
  14555. if (anyCaseLang === lang) {
  14556. gL10nData = dict.locales[lang];
  14557. break;
  14558. } else if (anyCaseLang === defaultLocale) {
  14559. gL10nData = dict.locales[defaultLocale];
  14560. }
  14561. }
  14562. }
  14563. callback();
  14564. } else {
  14565. console.log('no resource to load, early way out');
  14566. }
  14567. gReadyState = 'complete';
  14568. return;
  14569. }
  14570. var onResourceLoaded = null;
  14571. var gResourceCount = 0;
  14572. onResourceLoaded = function onResourceLoaded() {
  14573. gResourceCount++;
  14574. if (gResourceCount >= langCount) {
  14575. callback();
  14576. gReadyState = 'complete';
  14577. }
  14578. };
  14579. function L10nResourceLink(link) {
  14580. var href = link.href;
  14581. this.load = function (lang, callback) {
  14582. parseResource(href, lang, callback, function () {
  14583. console.warn(href + ' not found.');
  14584. console.warn('"' + lang + '" resource not found');
  14585. gLanguage = '';
  14586. callback();
  14587. });
  14588. };
  14589. }
  14590. for (var i = 0; i < langCount; i++) {
  14591. var resource = new L10nResourceLink(langLinks[i]);
  14592. resource.load(lang, onResourceLoaded);
  14593. }
  14594. }
  14595. function clear() {
  14596. gL10nData = {};
  14597. gTextData = '';
  14598. gLanguage = '';
  14599. }
  14600. function getPluralRules(lang) {
  14601. var locales2rules = {
  14602. 'af': 3,
  14603. 'ak': 4,
  14604. 'am': 4,
  14605. 'ar': 1,
  14606. 'asa': 3,
  14607. 'az': 0,
  14608. 'be': 11,
  14609. 'bem': 3,
  14610. 'bez': 3,
  14611. 'bg': 3,
  14612. 'bh': 4,
  14613. 'bm': 0,
  14614. 'bn': 3,
  14615. 'bo': 0,
  14616. 'br': 20,
  14617. 'brx': 3,
  14618. 'bs': 11,
  14619. 'ca': 3,
  14620. 'cgg': 3,
  14621. 'chr': 3,
  14622. 'cs': 12,
  14623. 'cy': 17,
  14624. 'da': 3,
  14625. 'de': 3,
  14626. 'dv': 3,
  14627. 'dz': 0,
  14628. 'ee': 3,
  14629. 'el': 3,
  14630. 'en': 3,
  14631. 'eo': 3,
  14632. 'es': 3,
  14633. 'et': 3,
  14634. 'eu': 3,
  14635. 'fa': 0,
  14636. 'ff': 5,
  14637. 'fi': 3,
  14638. 'fil': 4,
  14639. 'fo': 3,
  14640. 'fr': 5,
  14641. 'fur': 3,
  14642. 'fy': 3,
  14643. 'ga': 8,
  14644. 'gd': 24,
  14645. 'gl': 3,
  14646. 'gsw': 3,
  14647. 'gu': 3,
  14648. 'guw': 4,
  14649. 'gv': 23,
  14650. 'ha': 3,
  14651. 'haw': 3,
  14652. 'he': 2,
  14653. 'hi': 4,
  14654. 'hr': 11,
  14655. 'hu': 0,
  14656. 'id': 0,
  14657. 'ig': 0,
  14658. 'ii': 0,
  14659. 'is': 3,
  14660. 'it': 3,
  14661. 'iu': 7,
  14662. 'ja': 0,
  14663. 'jmc': 3,
  14664. 'jv': 0,
  14665. 'ka': 0,
  14666. 'kab': 5,
  14667. 'kaj': 3,
  14668. 'kcg': 3,
  14669. 'kde': 0,
  14670. 'kea': 0,
  14671. 'kk': 3,
  14672. 'kl': 3,
  14673. 'km': 0,
  14674. 'kn': 0,
  14675. 'ko': 0,
  14676. 'ksb': 3,
  14677. 'ksh': 21,
  14678. 'ku': 3,
  14679. 'kw': 7,
  14680. 'lag': 18,
  14681. 'lb': 3,
  14682. 'lg': 3,
  14683. 'ln': 4,
  14684. 'lo': 0,
  14685. 'lt': 10,
  14686. 'lv': 6,
  14687. 'mas': 3,
  14688. 'mg': 4,
  14689. 'mk': 16,
  14690. 'ml': 3,
  14691. 'mn': 3,
  14692. 'mo': 9,
  14693. 'mr': 3,
  14694. 'ms': 0,
  14695. 'mt': 15,
  14696. 'my': 0,
  14697. 'nah': 3,
  14698. 'naq': 7,
  14699. 'nb': 3,
  14700. 'nd': 3,
  14701. 'ne': 3,
  14702. 'nl': 3,
  14703. 'nn': 3,
  14704. 'no': 3,
  14705. 'nr': 3,
  14706. 'nso': 4,
  14707. 'ny': 3,
  14708. 'nyn': 3,
  14709. 'om': 3,
  14710. 'or': 3,
  14711. 'pa': 3,
  14712. 'pap': 3,
  14713. 'pl': 13,
  14714. 'ps': 3,
  14715. 'pt': 3,
  14716. 'rm': 3,
  14717. 'ro': 9,
  14718. 'rof': 3,
  14719. 'ru': 11,
  14720. 'rwk': 3,
  14721. 'sah': 0,
  14722. 'saq': 3,
  14723. 'se': 7,
  14724. 'seh': 3,
  14725. 'ses': 0,
  14726. 'sg': 0,
  14727. 'sh': 11,
  14728. 'shi': 19,
  14729. 'sk': 12,
  14730. 'sl': 14,
  14731. 'sma': 7,
  14732. 'smi': 7,
  14733. 'smj': 7,
  14734. 'smn': 7,
  14735. 'sms': 7,
  14736. 'sn': 3,
  14737. 'so': 3,
  14738. 'sq': 3,
  14739. 'sr': 11,
  14740. 'ss': 3,
  14741. 'ssy': 3,
  14742. 'st': 3,
  14743. 'sv': 3,
  14744. 'sw': 3,
  14745. 'syr': 3,
  14746. 'ta': 3,
  14747. 'te': 3,
  14748. 'teo': 3,
  14749. 'th': 0,
  14750. 'ti': 4,
  14751. 'tig': 3,
  14752. 'tk': 3,
  14753. 'tl': 4,
  14754. 'tn': 3,
  14755. 'to': 0,
  14756. 'tr': 0,
  14757. 'ts': 3,
  14758. 'tzm': 22,
  14759. 'uk': 11,
  14760. 'ur': 3,
  14761. 've': 3,
  14762. 'vi': 0,
  14763. 'vun': 3,
  14764. 'wa': 4,
  14765. 'wae': 3,
  14766. 'wo': 0,
  14767. 'xh': 3,
  14768. 'xog': 3,
  14769. 'yo': 0,
  14770. 'zh': 0,
  14771. 'zu': 3
  14772. };
  14773. function isIn(n, list) {
  14774. return list.indexOf(n) !== -1;
  14775. }
  14776. function isBetween(n, start, end) {
  14777. return start <= n && n <= end;
  14778. }
  14779. var pluralRules = {
  14780. '0': function _(n) {
  14781. return 'other';
  14782. },
  14783. '1': function _(n) {
  14784. if (isBetween(n % 100, 3, 10)) return 'few';
  14785. if (n === 0) return 'zero';
  14786. if (isBetween(n % 100, 11, 99)) return 'many';
  14787. if (n == 2) return 'two';
  14788. if (n == 1) return 'one';
  14789. return 'other';
  14790. },
  14791. '2': function _(n) {
  14792. if (n !== 0 && n % 10 === 0) return 'many';
  14793. if (n == 2) return 'two';
  14794. if (n == 1) return 'one';
  14795. return 'other';
  14796. },
  14797. '3': function _(n) {
  14798. if (n == 1) return 'one';
  14799. return 'other';
  14800. },
  14801. '4': function _(n) {
  14802. if (isBetween(n, 0, 1)) return 'one';
  14803. return 'other';
  14804. },
  14805. '5': function _(n) {
  14806. if (isBetween(n, 0, 2) && n != 2) return 'one';
  14807. return 'other';
  14808. },
  14809. '6': function _(n) {
  14810. if (n === 0) return 'zero';
  14811. if (n % 10 == 1 && n % 100 != 11) return 'one';
  14812. return 'other';
  14813. },
  14814. '7': function _(n) {
  14815. if (n == 2) return 'two';
  14816. if (n == 1) return 'one';
  14817. return 'other';
  14818. },
  14819. '8': function _(n) {
  14820. if (isBetween(n, 3, 6)) return 'few';
  14821. if (isBetween(n, 7, 10)) return 'many';
  14822. if (n == 2) return 'two';
  14823. if (n == 1) return 'one';
  14824. return 'other';
  14825. },
  14826. '9': function _(n) {
  14827. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  14828. if (n == 1) return 'one';
  14829. return 'other';
  14830. },
  14831. '10': function _(n) {
  14832. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  14833. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  14834. return 'other';
  14835. },
  14836. '11': function _(n) {
  14837. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  14838. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  14839. if (n % 10 == 1 && n % 100 != 11) return 'one';
  14840. return 'other';
  14841. },
  14842. '12': function _(n) {
  14843. if (isBetween(n, 2, 4)) return 'few';
  14844. if (n == 1) return 'one';
  14845. return 'other';
  14846. },
  14847. '13': function _(n) {
  14848. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  14849. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  14850. if (n == 1) return 'one';
  14851. return 'other';
  14852. },
  14853. '14': function _(n) {
  14854. if (isBetween(n % 100, 3, 4)) return 'few';
  14855. if (n % 100 == 2) return 'two';
  14856. if (n % 100 == 1) return 'one';
  14857. return 'other';
  14858. },
  14859. '15': function _(n) {
  14860. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  14861. if (isBetween(n % 100, 11, 19)) return 'many';
  14862. if (n == 1) return 'one';
  14863. return 'other';
  14864. },
  14865. '16': function _(n) {
  14866. if (n % 10 == 1 && n != 11) return 'one';
  14867. return 'other';
  14868. },
  14869. '17': function _(n) {
  14870. if (n == 3) return 'few';
  14871. if (n === 0) return 'zero';
  14872. if (n == 6) return 'many';
  14873. if (n == 2) return 'two';
  14874. if (n == 1) return 'one';
  14875. return 'other';
  14876. },
  14877. '18': function _(n) {
  14878. if (n === 0) return 'zero';
  14879. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  14880. return 'other';
  14881. },
  14882. '19': function _(n) {
  14883. if (isBetween(n, 2, 10)) return 'few';
  14884. if (isBetween(n, 0, 1)) return 'one';
  14885. return 'other';
  14886. },
  14887. '20': function _(n) {
  14888. 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';
  14889. if (n % 1000000 === 0 && n !== 0) return 'many';
  14890. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  14891. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  14892. return 'other';
  14893. },
  14894. '21': function _(n) {
  14895. if (n === 0) return 'zero';
  14896. if (n == 1) return 'one';
  14897. return 'other';
  14898. },
  14899. '22': function _(n) {
  14900. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  14901. return 'other';
  14902. },
  14903. '23': function _(n) {
  14904. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  14905. return 'other';
  14906. },
  14907. '24': function _(n) {
  14908. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  14909. if (isIn(n, [2, 12])) return 'two';
  14910. if (isIn(n, [1, 11])) return 'one';
  14911. return 'other';
  14912. }
  14913. };
  14914. var index = locales2rules[lang.replace(/-.*$/, '')];
  14915. if (!(index in pluralRules)) {
  14916. console.warn('plural form unknown for [' + lang + ']');
  14917. return function () {
  14918. return 'other';
  14919. };
  14920. }
  14921. return pluralRules[index];
  14922. }
  14923. gMacros.plural = function (str, param, key, prop) {
  14924. var n = parseFloat(param);
  14925. if (isNaN(n)) return str;
  14926. if (prop != gTextProp) return str;
  14927. if (!gMacros._pluralRules) {
  14928. gMacros._pluralRules = getPluralRules(gLanguage);
  14929. }
  14930. var index = '[' + gMacros._pluralRules(n) + ']';
  14931. if (n === 0 && key + '[zero]' in gL10nData) {
  14932. str = gL10nData[key + '[zero]'][prop];
  14933. } else if (n == 1 && key + '[one]' in gL10nData) {
  14934. str = gL10nData[key + '[one]'][prop];
  14935. } else if (n == 2 && key + '[two]' in gL10nData) {
  14936. str = gL10nData[key + '[two]'][prop];
  14937. } else if (key + index in gL10nData) {
  14938. str = gL10nData[key + index][prop];
  14939. } else if (key + '[other]' in gL10nData) {
  14940. str = gL10nData[key + '[other]'][prop];
  14941. }
  14942. return str;
  14943. };
  14944. function getL10nData(key, args, fallback) {
  14945. var data = gL10nData[key];
  14946. if (!data) {
  14947. console.warn('#' + key + ' is undefined.');
  14948. if (!fallback) {
  14949. return null;
  14950. }
  14951. data = fallback;
  14952. }
  14953. var rv = {};
  14954. for (var prop in data) {
  14955. var str = data[prop];
  14956. str = substIndexes(str, args, key, prop);
  14957. str = substArguments(str, args, key);
  14958. rv[prop] = str;
  14959. }
  14960. return rv;
  14961. }
  14962. function substIndexes(str, args, key, prop) {
  14963. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  14964. var reMatch = reIndex.exec(str);
  14965. if (!reMatch || !reMatch.length) return str;
  14966. var macroName = reMatch[1];
  14967. var paramName = reMatch[2];
  14968. var param;
  14969. if (args && paramName in args) {
  14970. param = args[paramName];
  14971. } else if (paramName in gL10nData) {
  14972. param = gL10nData[paramName];
  14973. }
  14974. if (macroName in gMacros) {
  14975. var macro = gMacros[macroName];
  14976. str = macro(str, param, key, prop);
  14977. }
  14978. return str;
  14979. }
  14980. function substArguments(str, args, key) {
  14981. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  14982. return str.replace(reArgs, function (matched_text, arg) {
  14983. if (args && arg in args) {
  14984. return args[arg];
  14985. }
  14986. if (arg in gL10nData) {
  14987. return gL10nData[arg];
  14988. }
  14989. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  14990. return matched_text;
  14991. });
  14992. }
  14993. function translateElement(element) {
  14994. var l10n = getL10nAttributes(element);
  14995. if (!l10n.id) return;
  14996. var data = getL10nData(l10n.id, l10n.args);
  14997. if (!data) {
  14998. console.warn('#' + l10n.id + ' is undefined.');
  14999. return;
  15000. }
  15001. if (data[gTextProp]) {
  15002. if (getChildElementCount(element) === 0) {
  15003. element[gTextProp] = data[gTextProp];
  15004. } else {
  15005. var children = element.childNodes;
  15006. var found = false;
  15007. for (var i = 0, l = children.length; i < l; i++) {
  15008. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  15009. if (found) {
  15010. children[i].nodeValue = '';
  15011. } else {
  15012. children[i].nodeValue = data[gTextProp];
  15013. found = true;
  15014. }
  15015. }
  15016. }
  15017. if (!found) {
  15018. var textNode = document.createTextNode(data[gTextProp]);
  15019. element.insertBefore(textNode, element.firstChild);
  15020. }
  15021. }
  15022. delete data[gTextProp];
  15023. }
  15024. for (var k in data) {
  15025. element[k] = data[k];
  15026. }
  15027. }
  15028. function getChildElementCount(element) {
  15029. if (element.children) {
  15030. return element.children.length;
  15031. }
  15032. if (typeof element.childElementCount !== 'undefined') {
  15033. return element.childElementCount;
  15034. }
  15035. var count = 0;
  15036. for (var i = 0; i < element.childNodes.length; i++) {
  15037. count += element.nodeType === 1 ? 1 : 0;
  15038. }
  15039. return count;
  15040. }
  15041. function translateFragment(element) {
  15042. element = element || document.documentElement;
  15043. var children = getTranslatableChildren(element);
  15044. var elementCount = children.length;
  15045. for (var i = 0; i < elementCount; i++) {
  15046. translateElement(children[i]);
  15047. }
  15048. translateElement(element);
  15049. }
  15050. return {
  15051. get: function get(key, args, fallbackString) {
  15052. var index = key.lastIndexOf('.');
  15053. var prop = gTextProp;
  15054. if (index > 0) {
  15055. prop = key.substring(index + 1);
  15056. key = key.substring(0, index);
  15057. }
  15058. var fallback;
  15059. if (fallbackString) {
  15060. fallback = {};
  15061. fallback[prop] = fallbackString;
  15062. }
  15063. var data = getL10nData(key, args, fallback);
  15064. if (data && prop in data) {
  15065. return data[prop];
  15066. }
  15067. return '{{' + key + '}}';
  15068. },
  15069. getData: function getData() {
  15070. return gL10nData;
  15071. },
  15072. getText: function getText() {
  15073. return gTextData;
  15074. },
  15075. getLanguage: function getLanguage() {
  15076. return gLanguage;
  15077. },
  15078. setLanguage: function setLanguage(lang, callback) {
  15079. loadLocale(lang, function () {
  15080. if (callback) callback();
  15081. });
  15082. },
  15083. getDirection: function getDirection() {
  15084. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  15085. var shortCode = gLanguage.split('-', 1)[0];
  15086. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  15087. },
  15088. translate: translateFragment,
  15089. getReadyState: function getReadyState() {
  15090. return gReadyState;
  15091. },
  15092. ready: function ready(callback) {
  15093. if (!callback) {
  15094. return;
  15095. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  15096. window.setTimeout(function () {
  15097. callback();
  15098. });
  15099. } else if (document.addEventListener) {
  15100. document.addEventListener('localized', function once() {
  15101. document.removeEventListener('localized', once);
  15102. callback();
  15103. });
  15104. }
  15105. }
  15106. };
  15107. }(window, document);
  15108. /***/ }),
  15109. /* 42 */
  15110. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15111. Object.defineProperty(exports, "__esModule", ({
  15112. value: true
  15113. }));
  15114. exports.GenericScripting = void 0;
  15115. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  15116. var _pdfjsLib = __webpack_require__(7);
  15117. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15118. 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); } }
  15119. 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); }); }; }
  15120. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15121. 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); } }
  15122. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15123. var GenericScripting = /*#__PURE__*/function () {
  15124. function GenericScripting(sandboxBundleSrc) {
  15125. _classCallCheck(this, GenericScripting);
  15126. this._ready = (0, _pdfjsLib.loadScript)(sandboxBundleSrc, true).then(function () {
  15127. return window.pdfjsSandbox.QuickJSSandbox();
  15128. });
  15129. }
  15130. _createClass(GenericScripting, [{
  15131. key: "createSandbox",
  15132. value: function () {
  15133. var _createSandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(data) {
  15134. var sandbox;
  15135. return _regenerator["default"].wrap(function _callee$(_context) {
  15136. while (1) {
  15137. switch (_context.prev = _context.next) {
  15138. case 0:
  15139. _context.next = 2;
  15140. return this._ready;
  15141. case 2:
  15142. sandbox = _context.sent;
  15143. sandbox.create(data);
  15144. case 4:
  15145. case "end":
  15146. return _context.stop();
  15147. }
  15148. }
  15149. }, _callee, this);
  15150. }));
  15151. function createSandbox(_x) {
  15152. return _createSandbox.apply(this, arguments);
  15153. }
  15154. return createSandbox;
  15155. }()
  15156. }, {
  15157. key: "dispatchEventInSandbox",
  15158. value: function () {
  15159. var _dispatchEventInSandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(event) {
  15160. var sandbox;
  15161. return _regenerator["default"].wrap(function _callee2$(_context2) {
  15162. while (1) {
  15163. switch (_context2.prev = _context2.next) {
  15164. case 0:
  15165. _context2.next = 2;
  15166. return this._ready;
  15167. case 2:
  15168. sandbox = _context2.sent;
  15169. sandbox.dispatchEvent(event);
  15170. case 4:
  15171. case "end":
  15172. return _context2.stop();
  15173. }
  15174. }
  15175. }, _callee2, this);
  15176. }));
  15177. function dispatchEventInSandbox(_x2) {
  15178. return _dispatchEventInSandbox.apply(this, arguments);
  15179. }
  15180. return dispatchEventInSandbox;
  15181. }()
  15182. }, {
  15183. key: "destroySandbox",
  15184. value: function () {
  15185. var _destroySandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  15186. var sandbox;
  15187. return _regenerator["default"].wrap(function _callee3$(_context3) {
  15188. while (1) {
  15189. switch (_context3.prev = _context3.next) {
  15190. case 0:
  15191. _context3.next = 2;
  15192. return this._ready;
  15193. case 2:
  15194. sandbox = _context3.sent;
  15195. sandbox.nukeSandbox();
  15196. case 4:
  15197. case "end":
  15198. return _context3.stop();
  15199. }
  15200. }
  15201. }, _callee3, this);
  15202. }));
  15203. function destroySandbox() {
  15204. return _destroySandbox.apply(this, arguments);
  15205. }
  15206. return destroySandbox;
  15207. }()
  15208. }]);
  15209. return GenericScripting;
  15210. }();
  15211. exports.GenericScripting = GenericScripting;
  15212. /***/ }),
  15213. /* 43 */
  15214. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15215. Object.defineProperty(exports, "__esModule", ({
  15216. value: true
  15217. }));
  15218. exports.PDFPrintService = PDFPrintService;
  15219. var _ui_utils = __webpack_require__(6);
  15220. var _app = __webpack_require__(3);
  15221. var _viewer_compatibility = __webpack_require__(2);
  15222. var activeService = null;
  15223. var overlayManager = null;
  15224. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise) {
  15225. var scratchCanvas = activeService.scratchCanvas;
  15226. var PRINT_UNITS = printResolution / 72.0;
  15227. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  15228. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  15229. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + "px";
  15230. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + "px";
  15231. var ctx = scratchCanvas.getContext("2d");
  15232. ctx.save();
  15233. ctx.fillStyle = "rgb(255, 255, 255)";
  15234. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  15235. ctx.restore();
  15236. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  15237. var renderContext = {
  15238. canvasContext: ctx,
  15239. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  15240. viewport: pdfPage.getViewport({
  15241. scale: 1,
  15242. rotation: size.rotation
  15243. }),
  15244. intent: "print",
  15245. annotationStorage: pdfDocument.annotationStorage,
  15246. optionalContentConfigPromise: optionalContentConfigPromise
  15247. };
  15248. return pdfPage.render(renderContext).promise;
  15249. }).then(function () {
  15250. return {
  15251. width: width,
  15252. height: height
  15253. };
  15254. });
  15255. }
  15256. function PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution) {
  15257. var optionalContentConfigPromise = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  15258. var l10n = arguments.length > 5 ? arguments[5] : undefined;
  15259. this.pdfDocument = pdfDocument;
  15260. this.pagesOverview = pagesOverview;
  15261. this.printContainer = printContainer;
  15262. this._printResolution = printResolution || 150;
  15263. this._optionalContentConfigPromise = optionalContentConfigPromise || pdfDocument.getOptionalContentConfig();
  15264. this.l10n = l10n || _ui_utils.NullL10n;
  15265. this.currentPage = -1;
  15266. this.scratchCanvas = document.createElement("canvas");
  15267. }
  15268. PDFPrintService.prototype = {
  15269. layout: function layout() {
  15270. this.throwIfInactive();
  15271. var body = document.querySelector("body");
  15272. body.setAttribute("data-pdfjsprinting", true);
  15273. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  15274. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  15275. }, this);
  15276. if (!hasEqualPageSizes) {
  15277. console.warn("Not all pages have the same size. The printed " + "result may be incorrect!");
  15278. }
  15279. this.pageStyleSheet = document.createElement("style");
  15280. var pageSize = this.pagesOverview[0];
  15281. this.pageStyleSheet.textContent = "@supports ((size:A4) and (size:1pt 1pt)) {" + "@page { size: " + pageSize.width + "pt " + pageSize.height + "pt;}" + "}";
  15282. body.appendChild(this.pageStyleSheet);
  15283. },
  15284. destroy: function destroy() {
  15285. if (activeService !== this) {
  15286. return;
  15287. }
  15288. this.printContainer.textContent = "";
  15289. var body = document.querySelector("body");
  15290. body.removeAttribute("data-pdfjsprinting");
  15291. if (this.pageStyleSheet) {
  15292. this.pageStyleSheet.remove();
  15293. this.pageStyleSheet = null;
  15294. }
  15295. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  15296. this.scratchCanvas = null;
  15297. activeService = null;
  15298. ensureOverlay().then(function () {
  15299. if (overlayManager.active !== "printServiceOverlay") {
  15300. return;
  15301. }
  15302. overlayManager.close("printServiceOverlay");
  15303. });
  15304. },
  15305. renderPages: function renderPages() {
  15306. var _this = this;
  15307. var pageCount = this.pagesOverview.length;
  15308. var renderNextPage = function renderNextPage(resolve, reject) {
  15309. _this.throwIfInactive();
  15310. if (++_this.currentPage >= pageCount) {
  15311. renderProgress(pageCount, pageCount, _this.l10n);
  15312. resolve();
  15313. return;
  15314. }
  15315. var index = _this.currentPage;
  15316. renderProgress(index, pageCount, _this.l10n);
  15317. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index], _this._printResolution, _this._optionalContentConfigPromise).then(_this.useRenderedPage.bind(_this)).then(function () {
  15318. renderNextPage(resolve, reject);
  15319. }, reject);
  15320. };
  15321. return new Promise(renderNextPage);
  15322. },
  15323. useRenderedPage: function useRenderedPage(printItem) {
  15324. this.throwIfInactive();
  15325. var img = document.createElement("img");
  15326. img.style.width = printItem.width;
  15327. img.style.height = printItem.height;
  15328. var scratchCanvas = this.scratchCanvas;
  15329. if ("toBlob" in scratchCanvas && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  15330. scratchCanvas.toBlob(function (blob) {
  15331. img.src = URL.createObjectURL(blob);
  15332. });
  15333. } else {
  15334. img.src = scratchCanvas.toDataURL();
  15335. }
  15336. var wrapper = document.createElement("div");
  15337. wrapper.appendChild(img);
  15338. this.printContainer.appendChild(wrapper);
  15339. return new Promise(function (resolve, reject) {
  15340. img.onload = resolve;
  15341. img.onerror = reject;
  15342. });
  15343. },
  15344. performPrint: function performPrint() {
  15345. var _this2 = this;
  15346. this.throwIfInactive();
  15347. return new Promise(function (resolve) {
  15348. setTimeout(function () {
  15349. if (!_this2.active) {
  15350. resolve();
  15351. return;
  15352. }
  15353. print.call(window);
  15354. setTimeout(resolve, 20);
  15355. }, 0);
  15356. });
  15357. },
  15358. get active() {
  15359. return this === activeService;
  15360. },
  15361. throwIfInactive: function throwIfInactive() {
  15362. if (!this.active) {
  15363. throw new Error("This print request was cancelled or completed.");
  15364. }
  15365. }
  15366. };
  15367. var print = window.print;
  15368. window.print = function () {
  15369. if (activeService) {
  15370. console.warn("Ignored window.print() because of a pending print job.");
  15371. return;
  15372. }
  15373. ensureOverlay().then(function () {
  15374. if (activeService) {
  15375. overlayManager.open("printServiceOverlay");
  15376. }
  15377. });
  15378. try {
  15379. dispatchEvent("beforeprint");
  15380. } finally {
  15381. if (!activeService) {
  15382. console.error("Expected print service to be initialized.");
  15383. ensureOverlay().then(function () {
  15384. if (overlayManager.active === "printServiceOverlay") {
  15385. overlayManager.close("printServiceOverlay");
  15386. }
  15387. });
  15388. return;
  15389. }
  15390. var activeServiceOnEntry = activeService;
  15391. activeService.renderPages().then(function () {
  15392. return activeServiceOnEntry.performPrint();
  15393. })["catch"](function () {}).then(function () {
  15394. if (activeServiceOnEntry.active) {
  15395. abort();
  15396. }
  15397. });
  15398. }
  15399. };
  15400. function dispatchEvent(eventType) {
  15401. var event = document.createEvent("CustomEvent");
  15402. event.initCustomEvent(eventType, false, false, "custom");
  15403. window.dispatchEvent(event);
  15404. }
  15405. function abort() {
  15406. if (activeService) {
  15407. activeService.destroy();
  15408. dispatchEvent("afterprint");
  15409. }
  15410. }
  15411. function renderProgress(index, total, l10n) {
  15412. var progressContainer = document.getElementById("printServiceOverlay");
  15413. var progress = Math.round(100 * index / total);
  15414. var progressBar = progressContainer.querySelector("progress");
  15415. var progressPerc = progressContainer.querySelector(".relative-progress");
  15416. progressBar.value = progress;
  15417. l10n.get("print_progress_percent", {
  15418. progress: progress
  15419. }, progress + "%").then(function (msg) {
  15420. progressPerc.textContent = msg;
  15421. });
  15422. }
  15423. window.addEventListener("keydown", function (event) {
  15424. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  15425. window.print();
  15426. event.preventDefault();
  15427. if (event.stopImmediatePropagation) {
  15428. event.stopImmediatePropagation();
  15429. } else {
  15430. event.stopPropagation();
  15431. }
  15432. }
  15433. }, true);
  15434. if ("onbeforeprint" in window) {
  15435. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  15436. if (event.detail !== "custom" && event.stopImmediatePropagation) {
  15437. event.stopImmediatePropagation();
  15438. }
  15439. };
  15440. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  15441. window.addEventListener("afterprint", stopPropagationIfNeeded);
  15442. }
  15443. var overlayPromise;
  15444. function ensureOverlay() {
  15445. if (!overlayPromise) {
  15446. overlayManager = _app.PDFViewerApplication.overlayManager;
  15447. if (!overlayManager) {
  15448. throw new Error("The overlay manager has not yet been initialized.");
  15449. }
  15450. overlayPromise = overlayManager.register("printServiceOverlay", document.getElementById("printServiceOverlay"), abort, true);
  15451. document.getElementById("printCancel").onclick = abort;
  15452. }
  15453. return overlayPromise;
  15454. }
  15455. _app.PDFPrintServiceFactory.instance = {
  15456. supportsPrinting: true,
  15457. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, l10n) {
  15458. if (activeService) {
  15459. throw new Error("The print service is created and active.");
  15460. }
  15461. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, l10n);
  15462. return activeService;
  15463. }
  15464. };
  15465. /***/ })
  15466. /******/ ]);
  15467. /************************************************************************/
  15468. /******/ // The module cache
  15469. /******/ var __webpack_module_cache__ = {};
  15470. /******/
  15471. /******/ // The require function
  15472. /******/ function __webpack_require__(moduleId) {
  15473. /******/ // Check if module is in cache
  15474. /******/ if(__webpack_module_cache__[moduleId]) {
  15475. /******/ return __webpack_module_cache__[moduleId].exports;
  15476. /******/ }
  15477. /******/ // Create a new module (and put it into the cache)
  15478. /******/ var module = __webpack_module_cache__[moduleId] = {
  15479. /******/ id: moduleId,
  15480. /******/ loaded: false,
  15481. /******/ exports: {}
  15482. /******/ };
  15483. /******/
  15484. /******/ // Execute the module function
  15485. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  15486. /******/
  15487. /******/ // Flag the module as loaded
  15488. /******/ module.loaded = true;
  15489. /******/
  15490. /******/ // Return the exports of the module
  15491. /******/ return module.exports;
  15492. /******/ }
  15493. /******/
  15494. /************************************************************************/
  15495. /******/ /* webpack/runtime/node module decorator */
  15496. /******/ (() => {
  15497. /******/ __webpack_require__.nmd = (module) => {
  15498. /******/ module.paths = [];
  15499. /******/ if (!module.children) module.children = [];
  15500. /******/ return module;
  15501. /******/ };
  15502. /******/ })();
  15503. /******/
  15504. /************************************************************************/
  15505. /******/ // startup
  15506. /******/ // Load entry module
  15507. /******/ __webpack_require__(0);
  15508. /******/ // This entry module used 'exports' so it can't be inlined
  15509. /******/ })()
  15510. ;
  15511. //# sourceMappingURL=viewer.js.map