viewer.js 637 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2021 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. /* 1 */
  27. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  28. Object.defineProperty(exports, "__esModule", ({
  29. value: true
  30. }));
  31. exports.OptionKind = exports.AppOptions = void 0;
  32. var _viewer_compatibility = __webpack_require__(2);
  33. 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); }
  34. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  35. 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); } }
  36. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  37. var OptionKind = {
  38. VIEWER: 0x02,
  39. API: 0x04,
  40. WORKER: 0x08,
  41. PREFERENCE: 0x80
  42. };
  43. exports.OptionKind = OptionKind;
  44. var defaultOptions = {
  45. cursorToolOnLoad: {
  46. value: 0,
  47. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  48. },
  49. defaultUrl: {
  50. value: "compressed.tracemonkey-pldi-09.pdf",
  51. kind: OptionKind.VIEWER
  52. },
  53. defaultZoomValue: {
  54. value: "",
  55. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  56. },
  57. disableHistory: {
  58. value: false,
  59. kind: OptionKind.VIEWER
  60. },
  61. disablePageLabels: {
  62. value: false,
  63. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  64. },
  65. enablePermissions: {
  66. value: false,
  67. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  68. },
  69. enablePrintAutoRotate: {
  70. value: true,
  71. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  72. },
  73. enableScripting: {
  74. value: true,
  75. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  76. },
  77. enableWebGL: {
  78. value: false,
  79. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  80. },
  81. externalLinkRel: {
  82. value: "noopener noreferrer nofollow",
  83. kind: OptionKind.VIEWER
  84. },
  85. externalLinkTarget: {
  86. value: 0,
  87. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  88. },
  89. historyUpdateUrl: {
  90. value: false,
  91. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  92. },
  93. ignoreDestinationZoom: {
  94. value: false,
  95. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  96. },
  97. imageResourcesPath: {
  98. value: "./images/",
  99. kind: OptionKind.VIEWER
  100. },
  101. maxCanvasPixels: {
  102. value: 16777216,
  103. compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
  104. kind: OptionKind.VIEWER
  105. },
  106. pdfBugEnabled: {
  107. value: false,
  108. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  109. },
  110. printResolution: {
  111. value: 150,
  112. kind: OptionKind.VIEWER
  113. },
  114. renderer: {
  115. value: "canvas",
  116. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  117. },
  118. renderInteractiveForms: {
  119. value: true,
  120. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  121. },
  122. sidebarViewOnLoad: {
  123. value: -1,
  124. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  125. },
  126. scrollModeOnLoad: {
  127. value: -1,
  128. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  129. },
  130. spreadModeOnLoad: {
  131. value: -1,
  132. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  133. },
  134. textLayerMode: {
  135. value: 1,
  136. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  137. },
  138. useOnlyCssZoom: {
  139. value: false,
  140. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  141. },
  142. viewerCssTheme: {
  143. value: 0,
  144. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  145. },
  146. viewOnLoad: {
  147. value: 0,
  148. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  149. },
  150. cMapPacked: {
  151. value: true,
  152. kind: OptionKind.API
  153. },
  154. cMapUrl: {
  155. value: "../web/cmaps/",
  156. kind: OptionKind.API
  157. },
  158. disableAutoFetch: {
  159. value: false,
  160. kind: OptionKind.API + OptionKind.PREFERENCE
  161. },
  162. disableFontFace: {
  163. value: false,
  164. kind: OptionKind.API + OptionKind.PREFERENCE
  165. },
  166. disableRange: {
  167. value: false,
  168. kind: OptionKind.API + OptionKind.PREFERENCE
  169. },
  170. disableStream: {
  171. value: false,
  172. kind: OptionKind.API + OptionKind.PREFERENCE
  173. },
  174. docBaseUrl: {
  175. value: "",
  176. kind: OptionKind.API
  177. },
  178. enableXfa: {
  179. value: false,
  180. kind: OptionKind.API
  181. },
  182. fontExtraProperties: {
  183. value: false,
  184. kind: OptionKind.API
  185. },
  186. isEvalSupported: {
  187. value: true,
  188. kind: OptionKind.API
  189. },
  190. maxImageSize: {
  191. value: -1,
  192. kind: OptionKind.API
  193. },
  194. pdfBug: {
  195. value: false,
  196. kind: OptionKind.API
  197. },
  198. verbosity: {
  199. value: 1,
  200. kind: OptionKind.API
  201. },
  202. workerPort: {
  203. value: null,
  204. kind: OptionKind.WORKER
  205. },
  206. workerSrc: {
  207. value: "../build/pdf.worker.js",
  208. kind: OptionKind.WORKER
  209. }
  210. };
  211. {
  212. defaultOptions.disablePreferences = {
  213. value: false,
  214. kind: OptionKind.VIEWER
  215. };
  216. defaultOptions.locale = {
  217. value: typeof navigator !== "undefined" ? navigator.language : "en-US",
  218. kind: OptionKind.VIEWER
  219. };
  220. defaultOptions.sandboxBundleSrc = {
  221. value: "../build/pdf.sandbox.js",
  222. kind: OptionKind.VIEWER
  223. };
  224. }
  225. var userOptions = Object.create(null);
  226. var AppOptions = /*#__PURE__*/function () {
  227. function AppOptions() {
  228. _classCallCheck(this, AppOptions);
  229. throw new Error("Cannot initialize AppOptions.");
  230. }
  231. _createClass(AppOptions, null, [{
  232. key: "get",
  233. value: function get(name) {
  234. var userOption = userOptions[name];
  235. if (userOption !== undefined) {
  236. return userOption;
  237. }
  238. var defaultOption = defaultOptions[name];
  239. if (defaultOption !== undefined) {
  240. var _defaultOption$compat;
  241. return (_defaultOption$compat = defaultOption.compatibility) !== null && _defaultOption$compat !== void 0 ? _defaultOption$compat : defaultOption.value;
  242. }
  243. return undefined;
  244. }
  245. }, {
  246. key: "getAll",
  247. value: function getAll() {
  248. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  249. var options = Object.create(null);
  250. for (var name in defaultOptions) {
  251. var _defaultOption$compat2;
  252. var defaultOption = defaultOptions[name];
  253. if (kind) {
  254. if ((kind & defaultOption.kind) === 0) {
  255. continue;
  256. }
  257. if (kind === OptionKind.PREFERENCE) {
  258. var value = defaultOption.value,
  259. valueType = _typeof(value);
  260. if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
  261. options[name] = value;
  262. continue;
  263. }
  264. throw new Error("Invalid type for preference: ".concat(name));
  265. }
  266. }
  267. var userOption = userOptions[name];
  268. options[name] = userOption !== undefined ? userOption : (_defaultOption$compat2 = defaultOption.compatibility) !== null && _defaultOption$compat2 !== void 0 ? _defaultOption$compat2 : defaultOption.value;
  269. }
  270. return options;
  271. }
  272. }, {
  273. key: "set",
  274. value: function set(name, value) {
  275. userOptions[name] = value;
  276. }
  277. }, {
  278. key: "setAll",
  279. value: function setAll(options) {
  280. for (var name in options) {
  281. userOptions[name] = options[name];
  282. }
  283. }
  284. }, {
  285. key: "remove",
  286. value: function remove(name) {
  287. delete userOptions[name];
  288. }
  289. }]);
  290. return AppOptions;
  291. }();
  292. exports.AppOptions = AppOptions;
  293. /***/ }),
  294. /* 2 */
  295. /***/ ((__unused_webpack_module, exports) => {
  296. Object.defineProperty(exports, "__esModule", ({
  297. value: true
  298. }));
  299. exports.viewerCompatibilityParams = void 0;
  300. var compatibilityParams = Object.create(null);
  301. {
  302. var userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
  303. var platform = typeof navigator !== "undefined" && navigator.platform || "";
  304. var maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
  305. var isAndroid = /Android/.test(userAgent);
  306. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  307. var isIOSChrome = /CriOS/.test(userAgent);
  308. (function checkOnBlobSupport() {
  309. if (isIOSChrome) {
  310. compatibilityParams.disableCreateObjectURL = true;
  311. }
  312. })();
  313. (function checkCanvasSizeLimitation() {
  314. if (isIOS || isAndroid) {
  315. compatibilityParams.maxCanvasPixels = 5242880;
  316. }
  317. })();
  318. }
  319. var viewerCompatibilityParams = Object.freeze(compatibilityParams);
  320. exports.viewerCompatibilityParams = viewerCompatibilityParams;
  321. /***/ }),
  322. /* 3 */
  323. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  324. Object.defineProperty(exports, "__esModule", ({
  325. value: true
  326. }));
  327. exports.PDFViewerApplication = exports.PDFPrintServiceFactory = exports.DefaultExternalServices = void 0;
  328. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  329. var _ui_utils = __webpack_require__(6);
  330. var _app_options = __webpack_require__(1);
  331. var _pdfjsLib = __webpack_require__(7);
  332. var _pdf_cursor_tools = __webpack_require__(8);
  333. var _pdf_rendering_queue = __webpack_require__(10);
  334. var _overlay_manager = __webpack_require__(11);
  335. var _password_prompt = __webpack_require__(12);
  336. var _pdf_attachment_viewer = __webpack_require__(13);
  337. var _pdf_document_properties = __webpack_require__(15);
  338. var _pdf_find_bar = __webpack_require__(16);
  339. var _pdf_find_controller = __webpack_require__(17);
  340. var _pdf_history = __webpack_require__(19);
  341. var _pdf_layer_viewer = __webpack_require__(20);
  342. var _pdf_link_service = __webpack_require__(21);
  343. var _pdf_outline_viewer = __webpack_require__(22);
  344. var _pdf_presentation_mode = __webpack_require__(23);
  345. var _pdf_scripting_manager = __webpack_require__(24);
  346. var _pdf_sidebar = __webpack_require__(25);
  347. var _pdf_sidebar_resizer = __webpack_require__(26);
  348. var _pdf_thumbnail_viewer = __webpack_require__(27);
  349. var _pdf_viewer = __webpack_require__(29);
  350. var _secondary_toolbar = __webpack_require__(36);
  351. var _toolbar = __webpack_require__(38);
  352. var _viewer_compatibility = __webpack_require__(2);
  353. var _view_history = __webpack_require__(39);
  354. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  355. 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; }
  356. 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; }
  357. 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; }
  358. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  359. 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."); }
  360. 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; }
  361. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  362. 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; } } }; }
  363. 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); }
  364. 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; }
  365. 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); } }
  366. 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); }); }; }
  367. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  368. 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); } }
  369. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  370. var DEFAULT_SCALE_DELTA = 1.1;
  371. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  372. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  373. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  374. var ENABLE_PERMISSIONS_CLASS = "enablePermissions";
  375. var ViewOnLoad = {
  376. UNKNOWN: -1,
  377. PREVIOUS: 0,
  378. INITIAL: 1
  379. };
  380. var ViewerCssTheme = {
  381. AUTOMATIC: 0,
  382. LIGHT: 1,
  383. DARK: 2
  384. };
  385. 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"];
  386. 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"];
  387. var DefaultExternalServices = /*#__PURE__*/function () {
  388. function DefaultExternalServices() {
  389. _classCallCheck(this, DefaultExternalServices);
  390. throw new Error("Cannot initialize DefaultExternalServices.");
  391. }
  392. _createClass(DefaultExternalServices, null, [{
  393. key: "updateFindControlState",
  394. value: function updateFindControlState(data) {}
  395. }, {
  396. key: "updateFindMatchesCount",
  397. value: function updateFindMatchesCount(data) {}
  398. }, {
  399. key: "initPassiveLoading",
  400. value: function initPassiveLoading(callbacks) {}
  401. }, {
  402. key: "fallback",
  403. value: function () {
  404. var _fallback = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(data) {
  405. return _regenerator["default"].wrap(function _callee$(_context) {
  406. while (1) {
  407. switch (_context.prev = _context.next) {
  408. case 0:
  409. case "end":
  410. return _context.stop();
  411. }
  412. }
  413. }, _callee);
  414. }));
  415. function fallback(_x) {
  416. return _fallback.apply(this, arguments);
  417. }
  418. return fallback;
  419. }()
  420. }, {
  421. key: "reportTelemetry",
  422. value: function reportTelemetry(data) {}
  423. }, {
  424. key: "createDownloadManager",
  425. value: function createDownloadManager(options) {
  426. throw new Error("Not implemented: createDownloadManager");
  427. }
  428. }, {
  429. key: "createPreferences",
  430. value: function createPreferences() {
  431. throw new Error("Not implemented: createPreferences");
  432. }
  433. }, {
  434. key: "createL10n",
  435. value: function createL10n(options) {
  436. throw new Error("Not implemented: createL10n");
  437. }
  438. }, {
  439. key: "createScripting",
  440. value: function createScripting(options) {
  441. throw new Error("Not implemented: createScripting");
  442. }
  443. }, {
  444. key: "supportsIntegratedFind",
  445. get: function get() {
  446. return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false);
  447. }
  448. }, {
  449. key: "supportsDocumentFonts",
  450. get: function get() {
  451. return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts", true);
  452. }
  453. }, {
  454. key: "supportedMouseWheelZoomModifierKeys",
  455. get: function get() {
  456. return (0, _pdfjsLib.shadow)(this, "supportedMouseWheelZoomModifierKeys", {
  457. ctrlKey: true,
  458. metaKey: true
  459. });
  460. }
  461. }, {
  462. key: "isInAutomation",
  463. get: function get() {
  464. return (0, _pdfjsLib.shadow)(this, "isInAutomation", false);
  465. }
  466. }]);
  467. return DefaultExternalServices;
  468. }();
  469. exports.DefaultExternalServices = DefaultExternalServices;
  470. var PDFViewerApplication = {
  471. initialBookmark: document.location.hash.substring(1),
  472. _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(),
  473. fellback: false,
  474. appConfig: null,
  475. pdfDocument: null,
  476. pdfLoadingTask: null,
  477. printService: null,
  478. pdfViewer: null,
  479. pdfThumbnailViewer: null,
  480. pdfRenderingQueue: null,
  481. pdfPresentationMode: null,
  482. pdfDocumentProperties: null,
  483. pdfLinkService: null,
  484. pdfHistory: null,
  485. pdfSidebar: null,
  486. pdfSidebarResizer: null,
  487. pdfOutlineViewer: null,
  488. pdfAttachmentViewer: null,
  489. pdfLayerViewer: null,
  490. pdfCursorTools: null,
  491. pdfScriptingManager: null,
  492. store: null,
  493. downloadManager: null,
  494. overlayManager: null,
  495. preferences: null,
  496. toolbar: null,
  497. secondaryToolbar: null,
  498. eventBus: null,
  499. l10n: null,
  500. isInitialViewSet: false,
  501. downloadComplete: false,
  502. isViewerEmbedded: window.parent !== window,
  503. url: "",
  504. baseUrl: "",
  505. externalServices: DefaultExternalServices,
  506. _boundEvents: Object.create(null),
  507. documentInfo: null,
  508. metadata: null,
  509. _contentDispositionFilename: null,
  510. _contentLength: null,
  511. triggerDelayedFallback: null,
  512. _saveInProgress: false,
  513. _wheelUnusedTicks: 0,
  514. _idleCallbacks: new Set(),
  515. initialize: function initialize(appConfig) {
  516. var _this = this;
  517. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  518. var appContainer;
  519. return _regenerator["default"].wrap(function _callee2$(_context2) {
  520. while (1) {
  521. switch (_context2.prev = _context2.next) {
  522. case 0:
  523. _this.preferences = _this.externalServices.createPreferences();
  524. _this.appConfig = appConfig;
  525. _context2.next = 4;
  526. return _this._readPreferences();
  527. case 4:
  528. _context2.next = 6;
  529. return _this._parseHashParameters();
  530. case 6:
  531. _this._forceCssTheme();
  532. _context2.next = 9;
  533. return _this._initializeL10n();
  534. case 9:
  535. if (_this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdfjsLib.LinkTarget.NONE) {
  536. _app_options.AppOptions.set("externalLinkTarget", _pdfjsLib.LinkTarget.TOP);
  537. }
  538. _context2.next = 12;
  539. return _this._initializeViewerComponents();
  540. case 12:
  541. _this.bindEvents();
  542. _this.bindWindowEvents();
  543. appContainer = appConfig.appContainer || document.documentElement;
  544. _this.l10n.translate(appContainer).then(function () {
  545. _this.eventBus.dispatch("localized", {
  546. source: _this
  547. });
  548. });
  549. _this._initializedCapability.resolve();
  550. case 17:
  551. case "end":
  552. return _context2.stop();
  553. }
  554. }
  555. }, _callee2);
  556. }))();
  557. },
  558. _readPreferences: function _readPreferences() {
  559. var _this2 = this;
  560. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  561. return _regenerator["default"].wrap(function _callee3$(_context3) {
  562. while (1) {
  563. switch (_context3.prev = _context3.next) {
  564. case 0:
  565. if (!_app_options.AppOptions.get("disablePreferences")) {
  566. _context3.next = 2;
  567. break;
  568. }
  569. return _context3.abrupt("return");
  570. case 2:
  571. _context3.prev = 2;
  572. _context3.t0 = _app_options.AppOptions;
  573. _context3.next = 6;
  574. return _this2.preferences.getAll();
  575. case 6:
  576. _context3.t1 = _context3.sent;
  577. _context3.t0.setAll.call(_context3.t0, _context3.t1);
  578. _context3.next = 13;
  579. break;
  580. case 10:
  581. _context3.prev = 10;
  582. _context3.t2 = _context3["catch"](2);
  583. console.error("_readPreferences: \"".concat(_context3.t2 === null || _context3.t2 === void 0 ? void 0 : _context3.t2.message, "\"."));
  584. case 13:
  585. case "end":
  586. return _context3.stop();
  587. }
  588. }
  589. }, _callee3, null, [[2, 10]]);
  590. }))();
  591. },
  592. _parseHashParameters: function _parseHashParameters() {
  593. var _this3 = this;
  594. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  595. var hash, hashParams, waitOn, viewer, enabled;
  596. return _regenerator["default"].wrap(function _callee4$(_context4) {
  597. while (1) {
  598. switch (_context4.prev = _context4.next) {
  599. case 0:
  600. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  601. _context4.next = 2;
  602. break;
  603. }
  604. return _context4.abrupt("return", undefined);
  605. case 2:
  606. hash = document.location.hash.substring(1);
  607. if (hash) {
  608. _context4.next = 5;
  609. break;
  610. }
  611. return _context4.abrupt("return", undefined);
  612. case 5:
  613. hashParams = (0, _ui_utils.parseQueryString)(hash), waitOn = [];
  614. if ("disableworker" in hashParams && hashParams.disableworker === "true") {
  615. waitOn.push(loadFakeWorker());
  616. }
  617. if ("disablerange" in hashParams) {
  618. _app_options.AppOptions.set("disableRange", hashParams.disablerange === "true");
  619. }
  620. if ("disablestream" in hashParams) {
  621. _app_options.AppOptions.set("disableStream", hashParams.disablestream === "true");
  622. }
  623. if ("disableautofetch" in hashParams) {
  624. _app_options.AppOptions.set("disableAutoFetch", hashParams.disableautofetch === "true");
  625. }
  626. if ("disablefontface" in hashParams) {
  627. _app_options.AppOptions.set("disableFontFace", hashParams.disablefontface === "true");
  628. }
  629. if ("disablehistory" in hashParams) {
  630. _app_options.AppOptions.set("disableHistory", hashParams.disablehistory === "true");
  631. }
  632. if ("webgl" in hashParams) {
  633. _app_options.AppOptions.set("enableWebGL", hashParams.webgl === "true");
  634. }
  635. if ("verbosity" in hashParams) {
  636. _app_options.AppOptions.set("verbosity", hashParams.verbosity | 0);
  637. }
  638. if (!("textlayer" in hashParams)) {
  639. _context4.next = 23;
  640. break;
  641. }
  642. _context4.t0 = hashParams.textlayer;
  643. _context4.next = _context4.t0 === "off" ? 18 : _context4.t0 === "visible" ? 20 : _context4.t0 === "shadow" ? 20 : _context4.t0 === "hover" ? 20 : 23;
  644. break;
  645. case 18:
  646. _app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
  647. return _context4.abrupt("break", 23);
  648. case 20:
  649. viewer = _this3.appConfig.viewerContainer;
  650. viewer.classList.add("textLayer-" + hashParams.textlayer);
  651. return _context4.abrupt("break", 23);
  652. case 23:
  653. if ("pdfbug" in hashParams) {
  654. _app_options.AppOptions.set("pdfBug", true);
  655. _app_options.AppOptions.set("fontExtraProperties", true);
  656. enabled = hashParams.pdfbug.split(",");
  657. waitOn.push(loadAndEnablePDFBug(enabled));
  658. }
  659. if ("locale" in hashParams) {
  660. _app_options.AppOptions.set("locale", hashParams.locale);
  661. }
  662. if (!(waitOn.length === 0)) {
  663. _context4.next = 27;
  664. break;
  665. }
  666. return _context4.abrupt("return", undefined);
  667. case 27:
  668. return _context4.abrupt("return", Promise.all(waitOn)["catch"](function (reason) {
  669. console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
  670. }));
  671. case 28:
  672. case "end":
  673. return _context4.stop();
  674. }
  675. }
  676. }, _callee4);
  677. }))();
  678. },
  679. _initializeL10n: function _initializeL10n() {
  680. var _this4 = this;
  681. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
  682. var dir;
  683. return _regenerator["default"].wrap(function _callee5$(_context5) {
  684. while (1) {
  685. switch (_context5.prev = _context5.next) {
  686. case 0:
  687. _this4.l10n = _this4.externalServices.createL10n({
  688. locale: _app_options.AppOptions.get("locale")
  689. });
  690. _context5.next = 3;
  691. return _this4.l10n.getDirection();
  692. case 3:
  693. dir = _context5.sent;
  694. document.getElementsByTagName("html")[0].dir = dir;
  695. case 5:
  696. case "end":
  697. return _context5.stop();
  698. }
  699. }
  700. }, _callee5);
  701. }))();
  702. },
  703. _forceCssTheme: function _forceCssTheme() {
  704. var cssTheme = _app_options.AppOptions.get("viewerCssTheme");
  705. if (cssTheme === ViewerCssTheme.AUTOMATIC || !Object.values(ViewerCssTheme).includes(cssTheme)) {
  706. return;
  707. }
  708. try {
  709. var styleSheet = document.styleSheets[0];
  710. var cssRules = (styleSheet === null || styleSheet === void 0 ? void 0 : styleSheet.cssRules) || [];
  711. for (var i = 0, ii = cssRules.length; i < ii; i++) {
  712. var _rule$media;
  713. var rule = cssRules[i];
  714. if (rule instanceof CSSMediaRule && ((_rule$media = rule.media) === null || _rule$media === void 0 ? void 0 : _rule$media[0]) === "(prefers-color-scheme: dark)") {
  715. if (cssTheme === ViewerCssTheme.LIGHT) {
  716. styleSheet.deleteRule(i);
  717. return;
  718. }
  719. var darkRules = /^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/.exec(rule.cssText);
  720. if (darkRules !== null && darkRules !== void 0 && darkRules[1]) {
  721. styleSheet.deleteRule(i);
  722. styleSheet.insertRule(darkRules[1], i);
  723. }
  724. return;
  725. }
  726. }
  727. } catch (reason) {
  728. console.error("_forceCssTheme: \"".concat(reason === null || reason === void 0 ? void 0 : reason.message, "\"."));
  729. }
  730. },
  731. _initializeViewerComponents: function _initializeViewerComponents() {
  732. var _this5 = this;
  733. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  734. var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, pdfScriptingManager, container, viewer;
  735. return _regenerator["default"].wrap(function _callee6$(_context6) {
  736. while (1) {
  737. switch (_context6.prev = _context6.next) {
  738. case 0:
  739. appConfig = _this5.appConfig;
  740. eventBus = appConfig.eventBus || new _ui_utils.EventBus({
  741. isInAutomation: _this5.externalServices.isInAutomation
  742. });
  743. _this5.eventBus = eventBus;
  744. _this5.overlayManager = new _overlay_manager.OverlayManager();
  745. pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  746. pdfRenderingQueue.onIdle = _this5._cleanup.bind(_this5);
  747. _this5.pdfRenderingQueue = pdfRenderingQueue;
  748. pdfLinkService = new _pdf_link_service.PDFLinkService({
  749. eventBus: eventBus,
  750. externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"),
  751. externalLinkRel: _app_options.AppOptions.get("externalLinkRel"),
  752. ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom")
  753. });
  754. _this5.pdfLinkService = pdfLinkService;
  755. downloadManager = _this5.externalServices.createDownloadManager();
  756. _this5.downloadManager = downloadManager;
  757. findController = new _pdf_find_controller.PDFFindController({
  758. linkService: pdfLinkService,
  759. eventBus: eventBus
  760. });
  761. _this5.findController = findController;
  762. pdfScriptingManager = new _pdf_scripting_manager.PDFScriptingManager({
  763. eventBus: eventBus,
  764. sandboxBundleSrc: _app_options.AppOptions.get("sandboxBundleSrc"),
  765. scriptingFactory: _this5.externalServices,
  766. docPropertiesLookup: _this5._scriptingDocProperties.bind(_this5)
  767. });
  768. _this5.pdfScriptingManager = pdfScriptingManager;
  769. container = appConfig.mainContainer;
  770. viewer = appConfig.viewerContainer;
  771. _this5.pdfViewer = new _pdf_viewer.PDFViewer({
  772. container: container,
  773. viewer: viewer,
  774. eventBus: eventBus,
  775. renderingQueue: pdfRenderingQueue,
  776. linkService: pdfLinkService,
  777. downloadManager: downloadManager,
  778. findController: findController,
  779. scriptingManager: pdfScriptingManager,
  780. renderer: _app_options.AppOptions.get("renderer"),
  781. enableWebGL: _app_options.AppOptions.get("enableWebGL"),
  782. l10n: _this5.l10n,
  783. textLayerMode: _app_options.AppOptions.get("textLayerMode"),
  784. imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"),
  785. renderInteractiveForms: _app_options.AppOptions.get("renderInteractiveForms"),
  786. enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"),
  787. useOnlyCssZoom: _app_options.AppOptions.get("useOnlyCssZoom"),
  788. maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels"),
  789. enableScripting: _app_options.AppOptions.get("enableScripting")
  790. });
  791. pdfRenderingQueue.setViewer(_this5.pdfViewer);
  792. pdfLinkService.setViewer(_this5.pdfViewer);
  793. pdfScriptingManager.setViewer(_this5.pdfViewer);
  794. _this5.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  795. container: appConfig.sidebar.thumbnailView,
  796. eventBus: eventBus,
  797. renderingQueue: pdfRenderingQueue,
  798. linkService: pdfLinkService,
  799. l10n: _this5.l10n
  800. });
  801. pdfRenderingQueue.setThumbnailViewer(_this5.pdfThumbnailViewer);
  802. _this5.pdfHistory = new _pdf_history.PDFHistory({
  803. linkService: pdfLinkService,
  804. eventBus: eventBus
  805. });
  806. pdfLinkService.setHistory(_this5.pdfHistory);
  807. if (!_this5.supportsIntegratedFind) {
  808. _this5.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, _this5.l10n);
  809. }
  810. _this5.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this5.overlayManager, eventBus, _this5.l10n);
  811. _this5.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  812. container: container,
  813. eventBus: eventBus,
  814. cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad")
  815. });
  816. _this5.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, _this5.l10n);
  817. _this5.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  818. if (_this5.supportsFullscreen) {
  819. _this5.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  820. container: container,
  821. pdfViewer: _this5.pdfViewer,
  822. eventBus: eventBus
  823. });
  824. }
  825. _this5.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this5.overlayManager, _this5.l10n, _this5.isViewerEmbedded);
  826. _this5.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  827. container: appConfig.sidebar.outlineView,
  828. eventBus: eventBus,
  829. linkService: pdfLinkService
  830. });
  831. _this5.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  832. container: appConfig.sidebar.attachmentsView,
  833. eventBus: eventBus,
  834. downloadManager: downloadManager
  835. });
  836. _this5.pdfLayerViewer = new _pdf_layer_viewer.PDFLayerViewer({
  837. container: appConfig.sidebar.layersView,
  838. eventBus: eventBus,
  839. l10n: _this5.l10n
  840. });
  841. _this5.pdfSidebar = new _pdf_sidebar.PDFSidebar({
  842. elements: appConfig.sidebar,
  843. pdfViewer: _this5.pdfViewer,
  844. pdfThumbnailViewer: _this5.pdfThumbnailViewer,
  845. eventBus: eventBus,
  846. l10n: _this5.l10n
  847. });
  848. _this5.pdfSidebar.onToggled = _this5.forceRendering.bind(_this5);
  849. _this5.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, _this5.l10n);
  850. case 38:
  851. case "end":
  852. return _context6.stop();
  853. }
  854. }
  855. }, _callee6);
  856. }))();
  857. },
  858. run: function run(config) {
  859. this.initialize(config).then(webViewerInitialized);
  860. },
  861. get initialized() {
  862. return this._initializedCapability.settled;
  863. },
  864. get initializedPromise() {
  865. return this._initializedCapability.promise;
  866. },
  867. zoomIn: function zoomIn(ticks) {
  868. if (this.pdfViewer.isInPresentationMode) {
  869. return;
  870. }
  871. var newScale = this.pdfViewer.currentScale;
  872. do {
  873. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  874. newScale = Math.ceil(newScale * 10) / 10;
  875. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  876. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  877. this.pdfViewer.currentScaleValue = newScale;
  878. },
  879. zoomOut: function zoomOut(ticks) {
  880. if (this.pdfViewer.isInPresentationMode) {
  881. return;
  882. }
  883. var newScale = this.pdfViewer.currentScale;
  884. do {
  885. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  886. newScale = Math.floor(newScale * 10) / 10;
  887. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  888. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  889. this.pdfViewer.currentScaleValue = newScale;
  890. },
  891. zoomReset: function zoomReset() {
  892. if (this.pdfViewer.isInPresentationMode) {
  893. return;
  894. }
  895. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  896. },
  897. get pagesCount() {
  898. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  899. },
  900. get page() {
  901. return this.pdfViewer.currentPageNumber;
  902. },
  903. set page(val) {
  904. this.pdfViewer.currentPageNumber = val;
  905. },
  906. get supportsPrinting() {
  907. return PDFPrintServiceFactory.instance.supportsPrinting;
  908. },
  909. get supportsFullscreen() {
  910. var doc = document.documentElement;
  911. var support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen);
  912. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false) {
  913. support = false;
  914. }
  915. return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", support);
  916. },
  917. get supportsIntegratedFind() {
  918. return this.externalServices.supportsIntegratedFind;
  919. },
  920. get supportsDocumentFonts() {
  921. return this.externalServices.supportsDocumentFonts;
  922. },
  923. get loadingBar() {
  924. var bar = new _ui_utils.ProgressBar("#loadingBar");
  925. return (0, _pdfjsLib.shadow)(this, "loadingBar", bar);
  926. },
  927. get supportedMouseWheelZoomModifierKeys() {
  928. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  929. },
  930. initPassiveLoading: function initPassiveLoading() {
  931. throw new Error("Not implemented: initPassiveLoading");
  932. },
  933. setTitleUsingUrl: function setTitleUsingUrl() {
  934. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  935. this.url = url;
  936. this.baseUrl = url.split("#")[0];
  937. var title = (0, _pdfjsLib.getPdfFilenameFromUrl)(url, "");
  938. if (!title) {
  939. try {
  940. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  941. } catch (ex) {
  942. title = url;
  943. }
  944. }
  945. this.setTitle(title);
  946. },
  947. setTitle: function setTitle(title) {
  948. if (this.isViewerEmbedded) {
  949. return;
  950. }
  951. document.title = title;
  952. },
  953. get _docFilename() {
  954. return this._contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(this.url);
  955. },
  956. _cancelIdleCallbacks: function _cancelIdleCallbacks() {
  957. if (!this._idleCallbacks.size) {
  958. return;
  959. }
  960. var _iterator = _createForOfIteratorHelper(this._idleCallbacks),
  961. _step;
  962. try {
  963. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  964. var callback = _step.value;
  965. window.cancelIdleCallback(callback);
  966. }
  967. } catch (err) {
  968. _iterator.e(err);
  969. } finally {
  970. _iterator.f();
  971. }
  972. this._idleCallbacks.clear();
  973. },
  974. close: function close() {
  975. var _this6 = this;
  976. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
  977. var _this6$pdfDocument;
  978. var container, promises;
  979. return _regenerator["default"].wrap(function _callee7$(_context7) {
  980. while (1) {
  981. switch (_context7.prev = _context7.next) {
  982. case 0:
  983. _this6._unblockDocumentLoadEvent();
  984. container = _this6.appConfig.errorWrapper.container;
  985. container.hidden = true;
  986. if (_this6.pdfLoadingTask) {
  987. _context7.next = 5;
  988. break;
  989. }
  990. return _context7.abrupt("return");
  991. case 5:
  992. if (!(((_this6$pdfDocument = _this6.pdfDocument) === null || _this6$pdfDocument === void 0 ? void 0 : _this6$pdfDocument.annotationStorage.size) > 0 && _this6._annotationStorageModified)) {
  993. _context7.next = 13;
  994. break;
  995. }
  996. _context7.prev = 6;
  997. _context7.next = 9;
  998. return _this6.save({
  999. sourceEventType: "save"
  1000. });
  1001. case 9:
  1002. _context7.next = 13;
  1003. break;
  1004. case 11:
  1005. _context7.prev = 11;
  1006. _context7.t0 = _context7["catch"](6);
  1007. case 13:
  1008. promises = [];
  1009. promises.push(_this6.pdfLoadingTask.destroy());
  1010. _this6.pdfLoadingTask = null;
  1011. if (_this6.pdfDocument) {
  1012. _this6.pdfDocument = null;
  1013. _this6.pdfThumbnailViewer.setDocument(null);
  1014. _this6.pdfViewer.setDocument(null);
  1015. _this6.pdfLinkService.setDocument(null);
  1016. _this6.pdfDocumentProperties.setDocument(null);
  1017. }
  1018. webViewerResetPermissions();
  1019. _this6.store = null;
  1020. _this6.isInitialViewSet = false;
  1021. _this6.downloadComplete = false;
  1022. _this6.url = "";
  1023. _this6.baseUrl = "";
  1024. _this6.documentInfo = null;
  1025. _this6.metadata = null;
  1026. _this6._contentDispositionFilename = null;
  1027. _this6._contentLength = null;
  1028. _this6.triggerDelayedFallback = null;
  1029. _this6._saveInProgress = false;
  1030. _this6._cancelIdleCallbacks();
  1031. promises.push(_this6.pdfScriptingManager.destroyPromise);
  1032. _this6.pdfSidebar.reset();
  1033. _this6.pdfOutlineViewer.reset();
  1034. _this6.pdfAttachmentViewer.reset();
  1035. _this6.pdfLayerViewer.reset();
  1036. if (_this6.pdfHistory) {
  1037. _this6.pdfHistory.reset();
  1038. }
  1039. if (_this6.findBar) {
  1040. _this6.findBar.reset();
  1041. }
  1042. _this6.toolbar.reset();
  1043. _this6.secondaryToolbar.reset();
  1044. if (typeof PDFBug !== "undefined") {
  1045. PDFBug.cleanup();
  1046. }
  1047. _context7.next = 42;
  1048. return Promise.all(promises);
  1049. case 42:
  1050. case "end":
  1051. return _context7.stop();
  1052. }
  1053. }
  1054. }, _callee7, null, [[6, 11]]);
  1055. }))();
  1056. },
  1057. open: function open(file, args) {
  1058. var _this7 = this;
  1059. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
  1060. var workerParameters, key, parameters, apiParameters, _key, value, _key2, loadingTask;
  1061. return _regenerator["default"].wrap(function _callee8$(_context8) {
  1062. while (1) {
  1063. switch (_context8.prev = _context8.next) {
  1064. case 0:
  1065. if (!_this7.pdfLoadingTask) {
  1066. _context8.next = 3;
  1067. break;
  1068. }
  1069. _context8.next = 3;
  1070. return _this7.close();
  1071. case 3:
  1072. workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
  1073. for (key in workerParameters) {
  1074. _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key];
  1075. }
  1076. parameters = Object.create(null);
  1077. if (typeof file === "string") {
  1078. _this7.setTitleUsingUrl(file);
  1079. parameters.url = file;
  1080. } else if (file && "byteLength" in file) {
  1081. parameters.data = file;
  1082. } else if (file.url && file.originalUrl) {
  1083. _this7.setTitleUsingUrl(file.originalUrl);
  1084. parameters.url = file.url;
  1085. }
  1086. apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
  1087. for (_key in apiParameters) {
  1088. value = apiParameters[_key];
  1089. if (_key === "docBaseUrl" && !value) {}
  1090. parameters[_key] = value;
  1091. }
  1092. if (args) {
  1093. for (_key2 in args) {
  1094. parameters[_key2] = args[_key2];
  1095. }
  1096. }
  1097. loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  1098. _this7.pdfLoadingTask = loadingTask;
  1099. loadingTask.onPassword = function (updateCallback, reason) {
  1100. _this7.pdfLinkService.externalLinkEnabled = false;
  1101. _this7.passwordPrompt.setUpdateCallback(updateCallback, reason);
  1102. _this7.passwordPrompt.open();
  1103. };
  1104. loadingTask.onProgress = function (_ref) {
  1105. var loaded = _ref.loaded,
  1106. total = _ref.total;
  1107. _this7.progress(loaded / total);
  1108. };
  1109. loadingTask.onUnsupportedFeature = _this7.fallback.bind(_this7);
  1110. return _context8.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
  1111. _this7.load(pdfDocument);
  1112. }, function (exception) {
  1113. if (loadingTask !== _this7.pdfLoadingTask) {
  1114. return undefined;
  1115. }
  1116. var key = "loading_error";
  1117. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  1118. key = "invalid_file_error";
  1119. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  1120. key = "missing_file_error";
  1121. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  1122. key = "unexpected_response_error";
  1123. }
  1124. return _this7.l10n.get(key).then(function (msg) {
  1125. _this7._documentError(msg, {
  1126. message: exception === null || exception === void 0 ? void 0 : exception.message
  1127. });
  1128. throw exception;
  1129. });
  1130. }));
  1131. case 16:
  1132. case "end":
  1133. return _context8.stop();
  1134. }
  1135. }
  1136. }, _callee8);
  1137. }))();
  1138. },
  1139. _ensureDownloadComplete: function _ensureDownloadComplete() {
  1140. if (this.pdfDocument && this.downloadComplete) {
  1141. return;
  1142. }
  1143. throw new Error("PDF document not downloaded.");
  1144. },
  1145. download: function download() {
  1146. var _arguments = arguments,
  1147. _this8 = this;
  1148. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
  1149. var _ref2, _ref2$sourceEventType, sourceEventType, url, filename, data, blob;
  1150. return _regenerator["default"].wrap(function _callee9$(_context9) {
  1151. while (1) {
  1152. switch (_context9.prev = _context9.next) {
  1153. case 0:
  1154. _ref2 = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {}, _ref2$sourceEventType = _ref2.sourceEventType, sourceEventType = _ref2$sourceEventType === void 0 ? "download" : _ref2$sourceEventType;
  1155. url = _this8.baseUrl, filename = _this8._docFilename;
  1156. _context9.prev = 2;
  1157. _this8._ensureDownloadComplete();
  1158. _context9.next = 6;
  1159. return _this8.pdfDocument.getData();
  1160. case 6:
  1161. data = _context9.sent;
  1162. blob = new Blob([data], {
  1163. type: "application/pdf"
  1164. });
  1165. _context9.next = 10;
  1166. return _this8.downloadManager.download(blob, url, filename, sourceEventType);
  1167. case 10:
  1168. _context9.next = 16;
  1169. break;
  1170. case 12:
  1171. _context9.prev = 12;
  1172. _context9.t0 = _context9["catch"](2);
  1173. _context9.next = 16;
  1174. return _this8.downloadManager.downloadUrl(url, filename);
  1175. case 16:
  1176. case "end":
  1177. return _context9.stop();
  1178. }
  1179. }
  1180. }, _callee9, null, [[2, 12]]);
  1181. }))();
  1182. },
  1183. save: function save() {
  1184. var _arguments2 = arguments,
  1185. _this9 = this;
  1186. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee10() {
  1187. var _ref3, _ref3$sourceEventType, sourceEventType, url, filename, data, blob;
  1188. return _regenerator["default"].wrap(function _callee10$(_context10) {
  1189. while (1) {
  1190. switch (_context10.prev = _context10.next) {
  1191. case 0:
  1192. _ref3 = _arguments2.length > 0 && _arguments2[0] !== undefined ? _arguments2[0] : {}, _ref3$sourceEventType = _ref3.sourceEventType, sourceEventType = _ref3$sourceEventType === void 0 ? "download" : _ref3$sourceEventType;
  1193. if (!_this9._saveInProgress) {
  1194. _context10.next = 3;
  1195. break;
  1196. }
  1197. return _context10.abrupt("return");
  1198. case 3:
  1199. _this9._saveInProgress = true;
  1200. _context10.next = 6;
  1201. return _this9.pdfScriptingManager.dispatchWillSave();
  1202. case 6:
  1203. url = _this9.baseUrl, filename = _this9._docFilename;
  1204. _context10.prev = 7;
  1205. _this9._ensureDownloadComplete();
  1206. _context10.next = 11;
  1207. return _this9.pdfDocument.saveDocument(_this9.pdfDocument.annotationStorage);
  1208. case 11:
  1209. data = _context10.sent;
  1210. blob = new Blob([data], {
  1211. type: "application/pdf"
  1212. });
  1213. _context10.next = 15;
  1214. return _this9.downloadManager.download(blob, url, filename, sourceEventType);
  1215. case 15:
  1216. _context10.next = 21;
  1217. break;
  1218. case 17:
  1219. _context10.prev = 17;
  1220. _context10.t0 = _context10["catch"](7);
  1221. _context10.next = 21;
  1222. return _this9.download({
  1223. sourceEventType: sourceEventType
  1224. });
  1225. case 21:
  1226. _context10.prev = 21;
  1227. _context10.next = 24;
  1228. return _this9.pdfScriptingManager.dispatchDidSave();
  1229. case 24:
  1230. _this9._saveInProgress = false;
  1231. return _context10.finish(21);
  1232. case 26:
  1233. case "end":
  1234. return _context10.stop();
  1235. }
  1236. }
  1237. }, _callee10, null, [[7, 17, 21, 26]]);
  1238. }))();
  1239. },
  1240. downloadOrSave: function downloadOrSave(options) {
  1241. var _this$pdfDocument;
  1242. if (((_this$pdfDocument = this.pdfDocument) === null || _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage.size) > 0) {
  1243. this.save(options);
  1244. } else {
  1245. this.download(options);
  1246. }
  1247. },
  1248. _delayedFallback: function _delayedFallback(featureId) {
  1249. var _this10 = this;
  1250. this.externalServices.reportTelemetry({
  1251. type: "unsupportedFeature",
  1252. featureId: featureId
  1253. });
  1254. if (!this.triggerDelayedFallback) {
  1255. this.triggerDelayedFallback = function () {
  1256. _this10.fallback(featureId);
  1257. _this10.triggerDelayedFallback = null;
  1258. };
  1259. }
  1260. },
  1261. fallback: function fallback(featureId) {
  1262. var _this11 = this;
  1263. this.externalServices.reportTelemetry({
  1264. type: "unsupportedFeature",
  1265. featureId: featureId
  1266. });
  1267. switch (featureId) {
  1268. case _pdfjsLib.UNSUPPORTED_FEATURES.errorFontLoadNative:
  1269. case _pdfjsLib.UNSUPPORTED_FEATURES.errorFontMissing:
  1270. return;
  1271. }
  1272. if (this.fellback) {
  1273. return;
  1274. }
  1275. this.fellback = true;
  1276. this.externalServices.fallback({
  1277. featureId: featureId,
  1278. url: this.baseUrl
  1279. }).then(function (download) {
  1280. if (!download) {
  1281. return;
  1282. }
  1283. _this11.download({
  1284. sourceEventType: "download"
  1285. });
  1286. });
  1287. },
  1288. _documentError: function _documentError(message) {
  1289. var moreInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1290. this._unblockDocumentLoadEvent();
  1291. this._otherError(message, moreInfo);
  1292. },
  1293. _otherError: function _otherError(message) {
  1294. var moreInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1295. var moreInfoText = [this.l10n.get("error_version_info", {
  1296. version: _pdfjsLib.version || "?",
  1297. build: _pdfjsLib.build || "?"
  1298. })];
  1299. if (moreInfo) {
  1300. moreInfoText.push(this.l10n.get("error_message", {
  1301. message: moreInfo.message
  1302. }));
  1303. if (moreInfo.stack) {
  1304. moreInfoText.push(this.l10n.get("error_stack", {
  1305. stack: moreInfo.stack
  1306. }));
  1307. } else {
  1308. if (moreInfo.filename) {
  1309. moreInfoText.push(this.l10n.get("error_file", {
  1310. file: moreInfo.filename
  1311. }));
  1312. }
  1313. if (moreInfo.lineNumber) {
  1314. moreInfoText.push(this.l10n.get("error_line", {
  1315. line: moreInfo.lineNumber
  1316. }));
  1317. }
  1318. }
  1319. }
  1320. var errorWrapperConfig = this.appConfig.errorWrapper;
  1321. var errorWrapper = errorWrapperConfig.container;
  1322. errorWrapper.hidden = false;
  1323. var errorMessage = errorWrapperConfig.errorMessage;
  1324. errorMessage.textContent = message;
  1325. var closeButton = errorWrapperConfig.closeButton;
  1326. closeButton.onclick = function () {
  1327. errorWrapper.hidden = true;
  1328. };
  1329. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  1330. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  1331. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  1332. moreInfoButton.onclick = function () {
  1333. errorMoreInfo.hidden = false;
  1334. moreInfoButton.hidden = true;
  1335. lessInfoButton.hidden = false;
  1336. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + "px";
  1337. };
  1338. lessInfoButton.onclick = function () {
  1339. errorMoreInfo.hidden = true;
  1340. moreInfoButton.hidden = false;
  1341. lessInfoButton.hidden = true;
  1342. };
  1343. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1344. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1345. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1346. moreInfoButton.hidden = false;
  1347. lessInfoButton.hidden = true;
  1348. Promise.all(moreInfoText).then(function (parts) {
  1349. errorMoreInfo.value = parts.join("\n");
  1350. });
  1351. },
  1352. progress: function progress(level) {
  1353. var _this12 = this;
  1354. if (this.downloadComplete) {
  1355. return;
  1356. }
  1357. var percent = Math.round(level * 100);
  1358. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1359. this.loadingBar.percent = percent;
  1360. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams.disableAutoFetch : _app_options.AppOptions.get("disableAutoFetch");
  1361. if (disableAutoFetch && percent) {
  1362. if (this.disableAutoFetchLoadingBarTimeout) {
  1363. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1364. this.disableAutoFetchLoadingBarTimeout = null;
  1365. }
  1366. this.loadingBar.show();
  1367. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  1368. _this12.loadingBar.hide();
  1369. _this12.disableAutoFetchLoadingBarTimeout = null;
  1370. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1371. }
  1372. }
  1373. },
  1374. load: function load(pdfDocument) {
  1375. var _this13 = this;
  1376. this.pdfDocument = pdfDocument;
  1377. pdfDocument.getDownloadInfo().then(function (_ref4) {
  1378. var length = _ref4.length;
  1379. _this13._contentLength = length;
  1380. _this13.downloadComplete = true;
  1381. _this13.loadingBar.hide();
  1382. firstPagePromise.then(function () {
  1383. _this13.eventBus.dispatch("documentloaded", {
  1384. source: _this13
  1385. });
  1386. });
  1387. });
  1388. var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function () {});
  1389. var pageModePromise = pdfDocument.getPageMode()["catch"](function () {});
  1390. var openActionPromise = pdfDocument.getOpenAction()["catch"](function () {});
  1391. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1392. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1393. var baseDocumentUrl;
  1394. baseDocumentUrl = null;
  1395. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1396. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1397. var pdfViewer = this.pdfViewer;
  1398. pdfViewer.setDocument(pdfDocument);
  1399. var firstPagePromise = pdfViewer.firstPagePromise,
  1400. onePageRendered = pdfViewer.onePageRendered,
  1401. pagesPromise = pdfViewer.pagesPromise;
  1402. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1403. pdfThumbnailViewer.setDocument(pdfDocument);
  1404. var storedPromise = (this.store = new _view_history.ViewHistory(pdfDocument.fingerprint)).getMultiple({
  1405. page: null,
  1406. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1407. scrollLeft: "0",
  1408. scrollTop: "0",
  1409. rotation: null,
  1410. sidebarView: _ui_utils.SidebarView.UNKNOWN,
  1411. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  1412. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  1413. })["catch"](function () {
  1414. return Object.create(null);
  1415. });
  1416. firstPagePromise.then(function (pdfPage) {
  1417. _this13.loadingBar.setWidth(_this13.appConfig.viewerContainer);
  1418. _this13._initializeAnnotationStorageCallbacks(pdfDocument);
  1419. Promise.all([_ui_utils.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then( /*#__PURE__*/function () {
  1420. var _ref6 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee11(_ref5) {
  1421. var _ref7, timeStamp, stored, pageLayout, pageMode, openAction, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
  1422. return _regenerator["default"].wrap(function _callee11$(_context11) {
  1423. while (1) {
  1424. switch (_context11.prev = _context11.next) {
  1425. case 0:
  1426. _ref7 = _slicedToArray(_ref5, 5), timeStamp = _ref7[0], stored = _ref7[1], pageLayout = _ref7[2], pageMode = _ref7[3], openAction = _ref7[4];
  1427. viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
  1428. _this13._initializePdfHistory({
  1429. fingerprint: pdfDocument.fingerprint,
  1430. viewOnLoad: viewOnLoad,
  1431. initialDest: openAction === null || openAction === void 0 ? void 0 : openAction.dest
  1432. });
  1433. initialBookmark = _this13.initialBookmark;
  1434. zoom = _app_options.AppOptions.get("defaultZoomValue");
  1435. hash = zoom ? "zoom=".concat(zoom) : null;
  1436. rotation = null;
  1437. sidebarView = _app_options.AppOptions.get("sidebarViewOnLoad");
  1438. scrollMode = _app_options.AppOptions.get("scrollModeOnLoad");
  1439. spreadMode = _app_options.AppOptions.get("spreadModeOnLoad");
  1440. if (stored.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  1441. hash = "page=".concat(stored.page, "&zoom=").concat(zoom || stored.zoom, ",") + "".concat(stored.scrollLeft, ",").concat(stored.scrollTop);
  1442. rotation = parseInt(stored.rotation, 10);
  1443. if (sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  1444. sidebarView = stored.sidebarView | 0;
  1445. }
  1446. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  1447. scrollMode = stored.scrollMode | 0;
  1448. }
  1449. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1450. spreadMode = stored.spreadMode | 0;
  1451. }
  1452. }
  1453. if (pageMode && sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  1454. sidebarView = (0, _ui_utils.apiPageModeToSidebarView)(pageMode);
  1455. }
  1456. if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1457. spreadMode = (0, _ui_utils.apiPageLayoutToSpreadMode)(pageLayout);
  1458. }
  1459. _this13.setInitialView(hash, {
  1460. rotation: rotation,
  1461. sidebarView: sidebarView,
  1462. scrollMode: scrollMode,
  1463. spreadMode: spreadMode
  1464. });
  1465. _this13.eventBus.dispatch("documentinit", {
  1466. source: _this13
  1467. });
  1468. if (!_this13.isViewerEmbedded) {
  1469. pdfViewer.focus();
  1470. }
  1471. _this13._initializePermissions(pdfDocument);
  1472. _context11.next = 19;
  1473. return Promise.race([pagesPromise, new Promise(function (resolve) {
  1474. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  1475. })]);
  1476. case 19:
  1477. if (!(!initialBookmark && !hash)) {
  1478. _context11.next = 21;
  1479. break;
  1480. }
  1481. return _context11.abrupt("return");
  1482. case 21:
  1483. if (!pdfViewer.hasEqualPageSizes) {
  1484. _context11.next = 23;
  1485. break;
  1486. }
  1487. return _context11.abrupt("return");
  1488. case 23:
  1489. _this13.initialBookmark = initialBookmark;
  1490. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  1491. _this13.setInitialView(hash);
  1492. case 26:
  1493. case "end":
  1494. return _context11.stop();
  1495. }
  1496. }
  1497. }, _callee11);
  1498. }));
  1499. return function (_x2) {
  1500. return _ref6.apply(this, arguments);
  1501. };
  1502. }())["catch"](function () {
  1503. _this13.setInitialView();
  1504. }).then(function () {
  1505. pdfViewer.update();
  1506. });
  1507. });
  1508. pagesPromise.then(function () {
  1509. _this13._unblockDocumentLoadEvent();
  1510. _this13._initializeAutoPrint(pdfDocument, openActionPromise);
  1511. });
  1512. onePageRendered.then(function () {
  1513. pdfDocument.getOutline().then(function (outline) {
  1514. _this13.pdfOutlineViewer.render({
  1515. outline: outline,
  1516. pdfDocument: pdfDocument
  1517. });
  1518. });
  1519. pdfDocument.getAttachments().then(function (attachments) {
  1520. _this13.pdfAttachmentViewer.render({
  1521. attachments: attachments
  1522. });
  1523. });
  1524. pdfViewer.optionalContentConfigPromise.then(function (optionalContentConfig) {
  1525. _this13.pdfLayerViewer.render({
  1526. optionalContentConfig: optionalContentConfig,
  1527. pdfDocument: pdfDocument
  1528. });
  1529. });
  1530. if ("requestIdleCallback" in window) {
  1531. var callback = window.requestIdleCallback(function () {
  1532. _this13._collectTelemetry(pdfDocument);
  1533. _this13._idleCallbacks["delete"](callback);
  1534. }, {
  1535. timeout: 1000
  1536. });
  1537. _this13._idleCallbacks.add(callback);
  1538. }
  1539. });
  1540. this._initializePageLabels(pdfDocument);
  1541. this._initializeMetadata(pdfDocument);
  1542. },
  1543. _scriptingDocProperties: function _scriptingDocProperties(pdfDocument) {
  1544. var _this14 = this;
  1545. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
  1546. var _this14$metadata, _this14$metadata2;
  1547. return _regenerator["default"].wrap(function _callee12$(_context12) {
  1548. while (1) {
  1549. switch (_context12.prev = _context12.next) {
  1550. case 0:
  1551. if (_this14.documentInfo) {
  1552. _context12.next = 5;
  1553. break;
  1554. }
  1555. _context12.next = 3;
  1556. return new Promise(function (resolve) {
  1557. _this14.eventBus._on("metadataloaded", resolve, {
  1558. once: true
  1559. });
  1560. });
  1561. case 3:
  1562. if (!(pdfDocument !== _this14.pdfDocument)) {
  1563. _context12.next = 5;
  1564. break;
  1565. }
  1566. return _context12.abrupt("return", null);
  1567. case 5:
  1568. if (_this14._contentLength) {
  1569. _context12.next = 10;
  1570. break;
  1571. }
  1572. _context12.next = 8;
  1573. return new Promise(function (resolve) {
  1574. _this14.eventBus._on("documentloaded", resolve, {
  1575. once: true
  1576. });
  1577. });
  1578. case 8:
  1579. if (!(pdfDocument !== _this14.pdfDocument)) {
  1580. _context12.next = 10;
  1581. break;
  1582. }
  1583. return _context12.abrupt("return", null);
  1584. case 10:
  1585. return _context12.abrupt("return", _objectSpread(_objectSpread({}, _this14.documentInfo), {}, {
  1586. baseURL: _this14.baseUrl,
  1587. filesize: _this14._contentLength,
  1588. filename: _this14._docFilename,
  1589. metadata: (_this14$metadata = _this14.metadata) === null || _this14$metadata === void 0 ? void 0 : _this14$metadata.getRaw(),
  1590. authors: (_this14$metadata2 = _this14.metadata) === null || _this14$metadata2 === void 0 ? void 0 : _this14$metadata2.get("dc:creator"),
  1591. numPages: _this14.pagesCount,
  1592. URL: _this14.url
  1593. }));
  1594. case 11:
  1595. case "end":
  1596. return _context12.stop();
  1597. }
  1598. }
  1599. }, _callee12);
  1600. }))();
  1601. },
  1602. _collectTelemetry: function _collectTelemetry(pdfDocument) {
  1603. var _this15 = this;
  1604. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
  1605. var markInfo, tagged;
  1606. return _regenerator["default"].wrap(function _callee13$(_context13) {
  1607. while (1) {
  1608. switch (_context13.prev = _context13.next) {
  1609. case 0:
  1610. _context13.next = 2;
  1611. return _this15.pdfDocument.getMarkInfo();
  1612. case 2:
  1613. markInfo = _context13.sent;
  1614. if (!(pdfDocument !== _this15.pdfDocument)) {
  1615. _context13.next = 5;
  1616. break;
  1617. }
  1618. return _context13.abrupt("return");
  1619. case 5:
  1620. tagged = (markInfo === null || markInfo === void 0 ? void 0 : markInfo.Marked) || false;
  1621. _this15.externalServices.reportTelemetry({
  1622. type: "tagged",
  1623. tagged: tagged
  1624. });
  1625. case 7:
  1626. case "end":
  1627. return _context13.stop();
  1628. }
  1629. }
  1630. }, _callee13);
  1631. }))();
  1632. },
  1633. _initializeAutoPrint: function _initializeAutoPrint(pdfDocument, openActionPromise) {
  1634. var _this16 = this;
  1635. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee14() {
  1636. var _yield$Promise$all, _yield$Promise$all2, openAction, javaScript, triggerAutoPrint, _iterator2, _step2, js;
  1637. return _regenerator["default"].wrap(function _callee14$(_context14) {
  1638. while (1) {
  1639. switch (_context14.prev = _context14.next) {
  1640. case 0:
  1641. _context14.next = 2;
  1642. return Promise.all([openActionPromise, !_this16.pdfViewer.enableScripting ? pdfDocument.getJavaScript() : null]);
  1643. case 2:
  1644. _yield$Promise$all = _context14.sent;
  1645. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
  1646. openAction = _yield$Promise$all2[0];
  1647. javaScript = _yield$Promise$all2[1];
  1648. if (!(pdfDocument !== _this16.pdfDocument)) {
  1649. _context14.next = 8;
  1650. break;
  1651. }
  1652. return _context14.abrupt("return");
  1653. case 8:
  1654. triggerAutoPrint = false;
  1655. if ((openAction === null || openAction === void 0 ? void 0 : openAction.action) === "Print") {
  1656. triggerAutoPrint = true;
  1657. }
  1658. if (!javaScript) {
  1659. _context14.next = 31;
  1660. break;
  1661. }
  1662. javaScript.some(function (js) {
  1663. if (!js) {
  1664. return false;
  1665. }
  1666. console.warn("Warning: JavaScript is not supported");
  1667. _this16._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  1668. return true;
  1669. });
  1670. if (triggerAutoPrint) {
  1671. _context14.next = 31;
  1672. break;
  1673. }
  1674. _iterator2 = _createForOfIteratorHelper(javaScript);
  1675. _context14.prev = 14;
  1676. _iterator2.s();
  1677. case 16:
  1678. if ((_step2 = _iterator2.n()).done) {
  1679. _context14.next = 23;
  1680. break;
  1681. }
  1682. js = _step2.value;
  1683. if (!(js && _ui_utils.AutoPrintRegExp.test(js))) {
  1684. _context14.next = 21;
  1685. break;
  1686. }
  1687. triggerAutoPrint = true;
  1688. return _context14.abrupt("break", 23);
  1689. case 21:
  1690. _context14.next = 16;
  1691. break;
  1692. case 23:
  1693. _context14.next = 28;
  1694. break;
  1695. case 25:
  1696. _context14.prev = 25;
  1697. _context14.t0 = _context14["catch"](14);
  1698. _iterator2.e(_context14.t0);
  1699. case 28:
  1700. _context14.prev = 28;
  1701. _iterator2.f();
  1702. return _context14.finish(28);
  1703. case 31:
  1704. if (triggerAutoPrint) {
  1705. _this16.triggerPrinting();
  1706. }
  1707. case 32:
  1708. case "end":
  1709. return _context14.stop();
  1710. }
  1711. }
  1712. }, _callee14, null, [[14, 25, 28, 31]]);
  1713. }))();
  1714. },
  1715. _initializeMetadata: function _initializeMetadata(pdfDocument) {
  1716. var _this17 = this;
  1717. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee15() {
  1718. var _this17$_contentDispo, _this17$_contentLengt;
  1719. var _yield$pdfDocument$ge, info, metadata, contentDispositionFilename, contentLength, pdfTitle, metadataTitle, versionId, generatorId, producer, formType;
  1720. return _regenerator["default"].wrap(function _callee15$(_context15) {
  1721. while (1) {
  1722. switch (_context15.prev = _context15.next) {
  1723. case 0:
  1724. _context15.next = 2;
  1725. return pdfDocument.getMetadata();
  1726. case 2:
  1727. _yield$pdfDocument$ge = _context15.sent;
  1728. info = _yield$pdfDocument$ge.info;
  1729. metadata = _yield$pdfDocument$ge.metadata;
  1730. contentDispositionFilename = _yield$pdfDocument$ge.contentDispositionFilename;
  1731. contentLength = _yield$pdfDocument$ge.contentLength;
  1732. if (!(pdfDocument !== _this17.pdfDocument)) {
  1733. _context15.next = 9;
  1734. break;
  1735. }
  1736. return _context15.abrupt("return");
  1737. case 9:
  1738. _this17.documentInfo = info;
  1739. _this17.metadata = metadata;
  1740. (_this17$_contentDispo = _this17._contentDispositionFilename) !== null && _this17$_contentDispo !== void 0 ? _this17$_contentDispo : _this17._contentDispositionFilename = contentDispositionFilename;
  1741. (_this17$_contentLengt = _this17._contentLength) !== null && _this17$_contentLengt !== void 0 ? _this17$_contentLengt : _this17._contentLength = contentLength;
  1742. 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]" : "", ")"));
  1743. pdfTitle = info === null || info === void 0 ? void 0 : info.Title;
  1744. metadataTitle = metadata === null || metadata === void 0 ? void 0 : metadata.get("dc:title");
  1745. if (metadataTitle) {
  1746. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
  1747. pdfTitle = metadataTitle;
  1748. }
  1749. }
  1750. if (pdfTitle) {
  1751. _this17.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
  1752. } else if (contentDispositionFilename) {
  1753. _this17.setTitle(contentDispositionFilename);
  1754. }
  1755. if (info.IsXFAPresent && !info.IsAcroFormPresent && !pdfDocument.isPureXfa) {
  1756. console.warn("Warning: XFA is not supported");
  1757. _this17._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1758. } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !_this17.pdfViewer.renderInteractiveForms) {
  1759. console.warn("Warning: Interactive form support is not enabled");
  1760. _this17._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1761. }
  1762. versionId = "other";
  1763. if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
  1764. versionId = "v".concat(info.PDFFormatVersion.replace(".", "_"));
  1765. }
  1766. generatorId = "other";
  1767. if (info.Producer) {
  1768. producer = info.Producer.toLowerCase();
  1769. KNOWN_GENERATORS.some(function (generator) {
  1770. if (!producer.includes(generator)) {
  1771. return false;
  1772. }
  1773. generatorId = generator.replace(/[ .-]/g, "_");
  1774. return true;
  1775. });
  1776. }
  1777. formType = null;
  1778. if (info.IsXFAPresent) {
  1779. formType = "xfa";
  1780. } else if (info.IsAcroFormPresent) {
  1781. formType = "acroform";
  1782. }
  1783. _this17.externalServices.reportTelemetry({
  1784. type: "documentInfo",
  1785. version: versionId,
  1786. generator: generatorId,
  1787. formType: formType
  1788. });
  1789. _this17.eventBus.dispatch("metadataloaded", {
  1790. source: _this17
  1791. });
  1792. case 27:
  1793. case "end":
  1794. return _context15.stop();
  1795. }
  1796. }
  1797. }, _callee15);
  1798. }))();
  1799. },
  1800. _initializePageLabels: function _initializePageLabels(pdfDocument) {
  1801. var _this18 = this;
  1802. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee16() {
  1803. var labels, numLabels, i, pdfViewer, pdfThumbnailViewer, toolbar;
  1804. return _regenerator["default"].wrap(function _callee16$(_context16) {
  1805. while (1) {
  1806. switch (_context16.prev = _context16.next) {
  1807. case 0:
  1808. _context16.next = 2;
  1809. return pdfDocument.getPageLabels();
  1810. case 2:
  1811. labels = _context16.sent;
  1812. if (!(pdfDocument !== _this18.pdfDocument)) {
  1813. _context16.next = 5;
  1814. break;
  1815. }
  1816. return _context16.abrupt("return");
  1817. case 5:
  1818. if (!(!labels || _app_options.AppOptions.get("disablePageLabels"))) {
  1819. _context16.next = 7;
  1820. break;
  1821. }
  1822. return _context16.abrupt("return");
  1823. case 7:
  1824. numLabels = labels.length;
  1825. if (!(numLabels !== _this18.pagesCount)) {
  1826. _context16.next = 11;
  1827. break;
  1828. }
  1829. console.error("The number of Page Labels does not match the number of pages in the document.");
  1830. return _context16.abrupt("return");
  1831. case 11:
  1832. i = 0;
  1833. while (i < numLabels && labels[i] === (i + 1).toString()) {
  1834. i++;
  1835. }
  1836. if (!(i === numLabels)) {
  1837. _context16.next = 15;
  1838. break;
  1839. }
  1840. return _context16.abrupt("return");
  1841. case 15:
  1842. pdfViewer = _this18.pdfViewer, pdfThumbnailViewer = _this18.pdfThumbnailViewer, toolbar = _this18.toolbar;
  1843. pdfViewer.setPageLabels(labels);
  1844. pdfThumbnailViewer.setPageLabels(labels);
  1845. toolbar.setPagesCount(numLabels, true);
  1846. toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1847. case 20:
  1848. case "end":
  1849. return _context16.stop();
  1850. }
  1851. }
  1852. }, _callee16);
  1853. }))();
  1854. },
  1855. _initializePdfHistory: function _initializePdfHistory(_ref8) {
  1856. var fingerprint = _ref8.fingerprint,
  1857. viewOnLoad = _ref8.viewOnLoad,
  1858. _ref8$initialDest = _ref8.initialDest,
  1859. initialDest = _ref8$initialDest === void 0 ? null : _ref8$initialDest;
  1860. if (this.isViewerEmbedded || _app_options.AppOptions.get("disableHistory")) {
  1861. return;
  1862. }
  1863. this.pdfHistory.initialize({
  1864. fingerprint: fingerprint,
  1865. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  1866. updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
  1867. });
  1868. if (this.pdfHistory.initialBookmark) {
  1869. this.initialBookmark = this.pdfHistory.initialBookmark;
  1870. this.initialRotation = this.pdfHistory.initialRotation;
  1871. }
  1872. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  1873. this.initialBookmark = JSON.stringify(initialDest);
  1874. this.pdfHistory.push({
  1875. explicitDest: initialDest,
  1876. pageNumber: null
  1877. });
  1878. }
  1879. },
  1880. _initializePermissions: function _initializePermissions(pdfDocument) {
  1881. var _this19 = this;
  1882. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee17() {
  1883. var permissions;
  1884. return _regenerator["default"].wrap(function _callee17$(_context17) {
  1885. while (1) {
  1886. switch (_context17.prev = _context17.next) {
  1887. case 0:
  1888. _context17.next = 2;
  1889. return pdfDocument.getPermissions();
  1890. case 2:
  1891. permissions = _context17.sent;
  1892. if (!(pdfDocument !== _this19.pdfDocument)) {
  1893. _context17.next = 5;
  1894. break;
  1895. }
  1896. return _context17.abrupt("return");
  1897. case 5:
  1898. if (!(!permissions || !_app_options.AppOptions.get("enablePermissions"))) {
  1899. _context17.next = 7;
  1900. break;
  1901. }
  1902. return _context17.abrupt("return");
  1903. case 7:
  1904. if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY)) {
  1905. _this19.appConfig.viewerContainer.classList.add(ENABLE_PERMISSIONS_CLASS);
  1906. }
  1907. case 8:
  1908. case "end":
  1909. return _context17.stop();
  1910. }
  1911. }
  1912. }, _callee17);
  1913. }))();
  1914. },
  1915. _initializeAnnotationStorageCallbacks: function _initializeAnnotationStorageCallbacks(pdfDocument) {
  1916. var _this20 = this;
  1917. if (pdfDocument !== this.pdfDocument) {
  1918. return;
  1919. }
  1920. var annotationStorage = pdfDocument.annotationStorage;
  1921. annotationStorage.onSetModified = function () {
  1922. window.addEventListener("beforeunload", beforeUnload);
  1923. _this20._annotationStorageModified = true;
  1924. };
  1925. annotationStorage.onResetModified = function () {
  1926. window.removeEventListener("beforeunload", beforeUnload);
  1927. delete _this20._annotationStorageModified;
  1928. };
  1929. },
  1930. setInitialView: function setInitialView(storedHash) {
  1931. var _this21 = this;
  1932. var _ref9 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1933. rotation = _ref9.rotation,
  1934. sidebarView = _ref9.sidebarView,
  1935. scrollMode = _ref9.scrollMode,
  1936. spreadMode = _ref9.spreadMode;
  1937. var setRotation = function setRotation(angle) {
  1938. if ((0, _ui_utils.isValidRotation)(angle)) {
  1939. _this21.pdfViewer.pagesRotation = angle;
  1940. }
  1941. };
  1942. var setViewerModes = function setViewerModes(scroll, spread) {
  1943. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  1944. _this21.pdfViewer.scrollMode = scroll;
  1945. }
  1946. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  1947. _this21.pdfViewer.spreadMode = spread;
  1948. }
  1949. };
  1950. this.isInitialViewSet = true;
  1951. this.pdfSidebar.setInitialView(sidebarView);
  1952. setViewerModes(scrollMode, spreadMode);
  1953. if (this.initialBookmark) {
  1954. setRotation(this.initialRotation);
  1955. delete this.initialRotation;
  1956. this.pdfLinkService.setHash(this.initialBookmark);
  1957. this.initialBookmark = null;
  1958. } else if (storedHash) {
  1959. setRotation(rotation);
  1960. this.pdfLinkService.setHash(storedHash);
  1961. }
  1962. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  1963. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  1964. if (!this.pdfViewer.currentScaleValue) {
  1965. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1966. }
  1967. },
  1968. _cleanup: function _cleanup() {
  1969. if (!this.pdfDocument) {
  1970. return;
  1971. }
  1972. this.pdfViewer.cleanup();
  1973. this.pdfThumbnailViewer.cleanup();
  1974. this.pdfDocument.cleanup(this.pdfViewer.renderer === _ui_utils.RendererType.SVG);
  1975. },
  1976. forceRendering: function forceRendering() {
  1977. this.pdfRenderingQueue.printing = !!this.printService;
  1978. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  1979. this.pdfRenderingQueue.renderHighestPriority();
  1980. },
  1981. beforePrint: function beforePrint() {
  1982. var _this22 = this;
  1983. this.pdfScriptingManager.dispatchWillPrint();
  1984. if (this.printService) {
  1985. return;
  1986. }
  1987. if (!this.supportsPrinting) {
  1988. this.l10n.get("printing_not_supported").then(function (msg) {
  1989. _this22._otherError(msg);
  1990. });
  1991. return;
  1992. }
  1993. if (!this.pdfViewer.pageViewsReady) {
  1994. this.l10n.get("printing_not_ready").then(function (msg) {
  1995. window.alert(msg);
  1996. });
  1997. return;
  1998. }
  1999. var pagesOverview = this.pdfViewer.getPagesOverview();
  2000. var printContainer = this.appConfig.printContainer;
  2001. var printResolution = _app_options.AppOptions.get("printResolution");
  2002. var optionalContentConfigPromise = this.pdfViewer.optionalContentConfigPromise;
  2003. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, this.l10n);
  2004. this.printService = printService;
  2005. this.forceRendering();
  2006. printService.layout();
  2007. this.externalServices.reportTelemetry({
  2008. type: "print"
  2009. });
  2010. },
  2011. afterPrint: function afterPrint() {
  2012. this.pdfScriptingManager.dispatchDidPrint();
  2013. if (this.printService) {
  2014. this.printService.destroy();
  2015. this.printService = null;
  2016. if (this.pdfDocument) {
  2017. this.pdfDocument.annotationStorage.resetModified();
  2018. }
  2019. }
  2020. this.forceRendering();
  2021. },
  2022. rotatePages: function rotatePages(delta) {
  2023. this.pdfViewer.pagesRotation += delta;
  2024. },
  2025. requestPresentationMode: function requestPresentationMode() {
  2026. if (!this.pdfPresentationMode) {
  2027. return;
  2028. }
  2029. this.pdfPresentationMode.request();
  2030. },
  2031. triggerPrinting: function triggerPrinting() {
  2032. if (!this.supportsPrinting) {
  2033. return;
  2034. }
  2035. window.print();
  2036. },
  2037. bindEvents: function bindEvents() {
  2038. var eventBus = this.eventBus,
  2039. _boundEvents = this._boundEvents;
  2040. _boundEvents.beforePrint = this.beforePrint.bind(this);
  2041. _boundEvents.afterPrint = this.afterPrint.bind(this);
  2042. eventBus._on("resize", webViewerResize);
  2043. eventBus._on("hashchange", webViewerHashchange);
  2044. eventBus._on("beforeprint", _boundEvents.beforePrint);
  2045. eventBus._on("afterprint", _boundEvents.afterPrint);
  2046. eventBus._on("pagerendered", webViewerPageRendered);
  2047. eventBus._on("updateviewarea", webViewerUpdateViewarea);
  2048. eventBus._on("pagechanging", webViewerPageChanging);
  2049. eventBus._on("scalechanging", webViewerScaleChanging);
  2050. eventBus._on("rotationchanging", webViewerRotationChanging);
  2051. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
  2052. eventBus._on("pagemode", webViewerPageMode);
  2053. eventBus._on("namedaction", webViewerNamedAction);
  2054. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
  2055. eventBus._on("presentationmode", webViewerPresentationMode);
  2056. eventBus._on("print", webViewerPrint);
  2057. eventBus._on("download", webViewerDownload);
  2058. eventBus._on("save", webViewerSave);
  2059. eventBus._on("firstpage", webViewerFirstPage);
  2060. eventBus._on("lastpage", webViewerLastPage);
  2061. eventBus._on("nextpage", webViewerNextPage);
  2062. eventBus._on("previouspage", webViewerPreviousPage);
  2063. eventBus._on("zoomin", webViewerZoomIn);
  2064. eventBus._on("zoomout", webViewerZoomOut);
  2065. eventBus._on("zoomreset", webViewerZoomReset);
  2066. eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
  2067. eventBus._on("scalechanged", webViewerScaleChanged);
  2068. eventBus._on("rotatecw", webViewerRotateCw);
  2069. eventBus._on("rotateccw", webViewerRotateCcw);
  2070. eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig);
  2071. eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
  2072. eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
  2073. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
  2074. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
  2075. eventBus._on("documentproperties", webViewerDocumentProperties);
  2076. eventBus._on("find", webViewerFind);
  2077. eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
  2078. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2079. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
  2080. if (_app_options.AppOptions.get("pdfBug")) {
  2081. _boundEvents.reportPageStatsPDFBug = reportPageStatsPDFBug;
  2082. eventBus._on("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2083. eventBus._on("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2084. }
  2085. eventBus._on("fileinputchange", webViewerFileInputChange);
  2086. eventBus._on("openfile", webViewerOpenFile);
  2087. },
  2088. bindWindowEvents: function bindWindowEvents() {
  2089. var eventBus = this.eventBus,
  2090. _boundEvents = this._boundEvents;
  2091. _boundEvents.windowResize = function () {
  2092. eventBus.dispatch("resize", {
  2093. source: window
  2094. });
  2095. };
  2096. _boundEvents.windowHashChange = function () {
  2097. eventBus.dispatch("hashchange", {
  2098. source: window,
  2099. hash: document.location.hash.substring(1)
  2100. });
  2101. };
  2102. _boundEvents.windowBeforePrint = function () {
  2103. eventBus.dispatch("beforeprint", {
  2104. source: window
  2105. });
  2106. };
  2107. _boundEvents.windowAfterPrint = function () {
  2108. eventBus.dispatch("afterprint", {
  2109. source: window
  2110. });
  2111. };
  2112. _boundEvents.windowUpdateFromSandbox = function (event) {
  2113. eventBus.dispatch("updatefromsandbox", {
  2114. source: window,
  2115. detail: event.detail
  2116. });
  2117. };
  2118. window.addEventListener("visibilitychange", webViewerVisibilityChange);
  2119. window.addEventListener("wheel", webViewerWheel, {
  2120. passive: false
  2121. });
  2122. window.addEventListener("touchstart", webViewerTouchStart, {
  2123. passive: false
  2124. });
  2125. window.addEventListener("click", webViewerClick);
  2126. window.addEventListener("keydown", webViewerKeyDown);
  2127. window.addEventListener("keyup", webViewerKeyUp);
  2128. window.addEventListener("resize", _boundEvents.windowResize);
  2129. window.addEventListener("hashchange", _boundEvents.windowHashChange);
  2130. window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2131. window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
  2132. window.addEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  2133. },
  2134. unbindEvents: function unbindEvents() {
  2135. var eventBus = this.eventBus,
  2136. _boundEvents = this._boundEvents;
  2137. eventBus._off("resize", webViewerResize);
  2138. eventBus._off("hashchange", webViewerHashchange);
  2139. eventBus._off("beforeprint", _boundEvents.beforePrint);
  2140. eventBus._off("afterprint", _boundEvents.afterPrint);
  2141. eventBus._off("pagerendered", webViewerPageRendered);
  2142. eventBus._off("updateviewarea", webViewerUpdateViewarea);
  2143. eventBus._off("pagechanging", webViewerPageChanging);
  2144. eventBus._off("scalechanging", webViewerScaleChanging);
  2145. eventBus._off("rotationchanging", webViewerRotationChanging);
  2146. eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
  2147. eventBus._off("pagemode", webViewerPageMode);
  2148. eventBus._off("namedaction", webViewerNamedAction);
  2149. eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
  2150. eventBus._off("presentationmode", webViewerPresentationMode);
  2151. eventBus._off("print", webViewerPrint);
  2152. eventBus._off("download", webViewerDownload);
  2153. eventBus._off("save", webViewerSave);
  2154. eventBus._off("firstpage", webViewerFirstPage);
  2155. eventBus._off("lastpage", webViewerLastPage);
  2156. eventBus._off("nextpage", webViewerNextPage);
  2157. eventBus._off("previouspage", webViewerPreviousPage);
  2158. eventBus._off("zoomin", webViewerZoomIn);
  2159. eventBus._off("zoomout", webViewerZoomOut);
  2160. eventBus._off("zoomreset", webViewerZoomReset);
  2161. eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
  2162. eventBus._off("scalechanged", webViewerScaleChanged);
  2163. eventBus._off("rotatecw", webViewerRotateCw);
  2164. eventBus._off("rotateccw", webViewerRotateCcw);
  2165. eventBus._off("optionalcontentconfig", webViewerOptionalContentConfig);
  2166. eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
  2167. eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
  2168. eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
  2169. eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
  2170. eventBus._off("documentproperties", webViewerDocumentProperties);
  2171. eventBus._off("find", webViewerFind);
  2172. eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
  2173. eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2174. eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
  2175. if (_boundEvents.reportPageStatsPDFBug) {
  2176. eventBus._off("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2177. eventBus._off("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2178. _boundEvents.reportPageStatsPDFBug = null;
  2179. }
  2180. eventBus._off("fileinputchange", webViewerFileInputChange);
  2181. eventBus._off("openfile", webViewerOpenFile);
  2182. _boundEvents.beforePrint = null;
  2183. _boundEvents.afterPrint = null;
  2184. },
  2185. unbindWindowEvents: function unbindWindowEvents() {
  2186. var _boundEvents = this._boundEvents;
  2187. window.removeEventListener("visibilitychange", webViewerVisibilityChange);
  2188. window.removeEventListener("wheel", webViewerWheel, {
  2189. passive: false
  2190. });
  2191. window.removeEventListener("touchstart", webViewerTouchStart, {
  2192. passive: false
  2193. });
  2194. window.removeEventListener("click", webViewerClick);
  2195. window.removeEventListener("keydown", webViewerKeyDown);
  2196. window.removeEventListener("keyup", webViewerKeyUp);
  2197. window.removeEventListener("resize", _boundEvents.windowResize);
  2198. window.removeEventListener("hashchange", _boundEvents.windowHashChange);
  2199. window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2200. window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
  2201. window.removeEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  2202. _boundEvents.windowResize = null;
  2203. _boundEvents.windowHashChange = null;
  2204. _boundEvents.windowBeforePrint = null;
  2205. _boundEvents.windowAfterPrint = null;
  2206. _boundEvents.windowUpdateFromSandbox = null;
  2207. },
  2208. accumulateWheelTicks: function accumulateWheelTicks(ticks) {
  2209. if (this._wheelUnusedTicks > 0 && ticks < 0 || this._wheelUnusedTicks < 0 && ticks > 0) {
  2210. this._wheelUnusedTicks = 0;
  2211. }
  2212. this._wheelUnusedTicks += ticks;
  2213. var wholeTicks = Math.sign(this._wheelUnusedTicks) * Math.floor(Math.abs(this._wheelUnusedTicks));
  2214. this._wheelUnusedTicks -= wholeTicks;
  2215. return wholeTicks;
  2216. },
  2217. _unblockDocumentLoadEvent: function _unblockDocumentLoadEvent() {
  2218. if (document.blockUnblockOnload) {
  2219. document.blockUnblockOnload(false);
  2220. }
  2221. this._unblockDocumentLoadEvent = function () {};
  2222. },
  2223. get scriptingReady() {
  2224. return this.pdfScriptingManager.ready;
  2225. }
  2226. };
  2227. exports.PDFViewerApplication = PDFViewerApplication;
  2228. var validateFileURL;
  2229. {
  2230. var HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
  2231. validateFileURL = function validateFileURL(file) {
  2232. if (file === undefined) {
  2233. return;
  2234. }
  2235. try {
  2236. var viewerOrigin = new URL(window.location.href).origin || "null";
  2237. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  2238. return;
  2239. }
  2240. var _URL = new URL(file, window.location.href),
  2241. origin = _URL.origin,
  2242. protocol = _URL.protocol;
  2243. if (origin !== viewerOrigin && protocol !== "blob:") {
  2244. throw new Error("file origin does not match viewer's");
  2245. }
  2246. } catch (ex) {
  2247. PDFViewerApplication.l10n.get("loading_error").then(function (msg) {
  2248. PDFViewerApplication._documentError(msg, {
  2249. message: ex === null || ex === void 0 ? void 0 : ex.message
  2250. });
  2251. });
  2252. throw ex;
  2253. }
  2254. };
  2255. }
  2256. function loadFakeWorker() {
  2257. return _loadFakeWorker.apply(this, arguments);
  2258. }
  2259. function _loadFakeWorker() {
  2260. _loadFakeWorker = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee18() {
  2261. return _regenerator["default"].wrap(function _callee18$(_context18) {
  2262. while (1) {
  2263. switch (_context18.prev = _context18.next) {
  2264. case 0:
  2265. if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
  2266. _pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get("workerSrc");
  2267. }
  2268. return _context18.abrupt("return", (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc()));
  2269. case 2:
  2270. case "end":
  2271. return _context18.stop();
  2272. }
  2273. }
  2274. }, _callee18);
  2275. }));
  2276. return _loadFakeWorker.apply(this, arguments);
  2277. }
  2278. function loadAndEnablePDFBug(enabledTabs) {
  2279. var appConfig = PDFViewerApplication.appConfig;
  2280. return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function () {
  2281. PDFBug.enable(enabledTabs);
  2282. PDFBug.init({
  2283. OPS: _pdfjsLib.OPS
  2284. }, appConfig.mainContainer);
  2285. });
  2286. }
  2287. function reportPageStatsPDFBug(_ref10) {
  2288. var _pageView$pdfPage;
  2289. var pageNumber = _ref10.pageNumber;
  2290. if (typeof Stats === "undefined" || !Stats.enabled) {
  2291. return;
  2292. }
  2293. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  2294. var pageStats = pageView === null || pageView === void 0 ? void 0 : (_pageView$pdfPage = pageView.pdfPage) === null || _pageView$pdfPage === void 0 ? void 0 : _pageView$pdfPage.stats;
  2295. if (!pageStats) {
  2296. return;
  2297. }
  2298. Stats.add(pageNumber, pageStats);
  2299. }
  2300. function webViewerInitialized() {
  2301. var appConfig = PDFViewerApplication.appConfig;
  2302. var file;
  2303. var queryString = document.location.search.substring(1);
  2304. var params = (0, _ui_utils.parseQueryString)(queryString);
  2305. file = "file" in params ? params.file : _app_options.AppOptions.get("defaultUrl");
  2306. validateFileURL(file);
  2307. var fileInput = document.createElement("input");
  2308. fileInput.id = appConfig.openFileInputName;
  2309. fileInput.className = "fileInput";
  2310. fileInput.setAttribute("type", "file");
  2311. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  2312. document.body.appendChild(fileInput);
  2313. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  2314. appConfig.toolbar.openFile.hidden = true;
  2315. appConfig.secondaryToolbar.openFileButton.hidden = true;
  2316. } else {
  2317. fileInput.value = null;
  2318. }
  2319. fileInput.addEventListener("change", function (evt) {
  2320. var files = evt.target.files;
  2321. if (!files || files.length === 0) {
  2322. return;
  2323. }
  2324. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  2325. source: this,
  2326. fileInput: evt.target
  2327. });
  2328. });
  2329. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  2330. evt.preventDefault();
  2331. evt.dataTransfer.dropEffect = "move";
  2332. });
  2333. appConfig.mainContainer.addEventListener("drop", function (evt) {
  2334. evt.preventDefault();
  2335. var files = evt.dataTransfer.files;
  2336. if (!files || files.length === 0) {
  2337. return;
  2338. }
  2339. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  2340. source: this,
  2341. fileInput: evt.dataTransfer
  2342. });
  2343. });
  2344. if (!PDFViewerApplication.supportsDocumentFonts) {
  2345. _app_options.AppOptions.set("disableFontFace", true);
  2346. PDFViewerApplication.l10n.get("web_fonts_disabled").then(function (msg) {
  2347. console.warn(msg);
  2348. });
  2349. }
  2350. if (!PDFViewerApplication.supportsPrinting) {
  2351. appConfig.toolbar.print.classList.add("hidden");
  2352. appConfig.secondaryToolbar.printButton.classList.add("hidden");
  2353. }
  2354. if (!PDFViewerApplication.supportsFullscreen) {
  2355. appConfig.toolbar.presentationModeButton.classList.add("hidden");
  2356. appConfig.secondaryToolbar.presentationModeButton.classList.add("hidden");
  2357. }
  2358. if (PDFViewerApplication.supportsIntegratedFind) {
  2359. appConfig.toolbar.viewFind.classList.add("hidden");
  2360. }
  2361. appConfig.mainContainer.addEventListener("transitionend", function (evt) {
  2362. if (evt.target === this) {
  2363. PDFViewerApplication.eventBus.dispatch("resize", {
  2364. source: this
  2365. });
  2366. }
  2367. }, true);
  2368. try {
  2369. webViewerOpenFileViaURL(file);
  2370. } catch (reason) {
  2371. PDFViewerApplication.l10n.get("loading_error").then(function (msg) {
  2372. PDFViewerApplication._documentError(msg, reason);
  2373. });
  2374. }
  2375. }
  2376. function webViewerOpenFileViaURL(file) {
  2377. if (file) {
  2378. PDFViewerApplication.open(file);
  2379. }
  2380. }
  2381. function webViewerResetPermissions() {
  2382. var appConfig = PDFViewerApplication.appConfig;
  2383. if (!appConfig) {
  2384. return;
  2385. }
  2386. appConfig.viewerContainer.classList.remove(ENABLE_PERMISSIONS_CLASS);
  2387. }
  2388. function webViewerPageRendered(_ref11) {
  2389. var pageNumber = _ref11.pageNumber,
  2390. timestamp = _ref11.timestamp,
  2391. error = _ref11.error;
  2392. if (pageNumber === PDFViewerApplication.page) {
  2393. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  2394. }
  2395. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2396. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  2397. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageNumber - 1);
  2398. if (pageView && thumbnailView) {
  2399. thumbnailView.setImage(pageView);
  2400. }
  2401. }
  2402. if (error) {
  2403. PDFViewerApplication.l10n.get("rendering_error").then(function (msg) {
  2404. PDFViewerApplication._otherError(msg, error);
  2405. });
  2406. }
  2407. PDFViewerApplication.externalServices.reportTelemetry({
  2408. type: "pageInfo",
  2409. timestamp: timestamp
  2410. });
  2411. PDFViewerApplication.pdfDocument.getStats().then(function (stats) {
  2412. PDFViewerApplication.externalServices.reportTelemetry({
  2413. type: "documentStats",
  2414. stats: stats
  2415. });
  2416. });
  2417. }
  2418. function webViewerPageMode(_ref12) {
  2419. var mode = _ref12.mode;
  2420. var view;
  2421. switch (mode) {
  2422. case "thumbs":
  2423. view = _ui_utils.SidebarView.THUMBS;
  2424. break;
  2425. case "bookmarks":
  2426. case "outline":
  2427. view = _ui_utils.SidebarView.OUTLINE;
  2428. break;
  2429. case "attachments":
  2430. view = _ui_utils.SidebarView.ATTACHMENTS;
  2431. break;
  2432. case "layers":
  2433. view = _ui_utils.SidebarView.LAYERS;
  2434. break;
  2435. case "none":
  2436. view = _ui_utils.SidebarView.NONE;
  2437. break;
  2438. default:
  2439. console.error('Invalid "pagemode" hash parameter: ' + mode);
  2440. return;
  2441. }
  2442. PDFViewerApplication.pdfSidebar.switchView(view, true);
  2443. }
  2444. function webViewerNamedAction(evt) {
  2445. switch (evt.action) {
  2446. case "GoToPage":
  2447. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2448. break;
  2449. case "Find":
  2450. if (!PDFViewerApplication.supportsIntegratedFind) {
  2451. PDFViewerApplication.findBar.toggle();
  2452. }
  2453. break;
  2454. case "Print":
  2455. PDFViewerApplication.triggerPrinting();
  2456. break;
  2457. case "SaveAs":
  2458. webViewerSave();
  2459. break;
  2460. }
  2461. }
  2462. function webViewerPresentationModeChanged(evt) {
  2463. PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
  2464. }
  2465. function webViewerSidebarViewChanged(evt) {
  2466. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  2467. var store = PDFViewerApplication.store;
  2468. if (store && PDFViewerApplication.isInitialViewSet) {
  2469. store.set("sidebarView", evt.view)["catch"](function () {});
  2470. }
  2471. }
  2472. function webViewerUpdateViewarea(evt) {
  2473. var location = evt.location,
  2474. store = PDFViewerApplication.store;
  2475. if (store && PDFViewerApplication.isInitialViewSet) {
  2476. store.setMultiple({
  2477. page: location.pageNumber,
  2478. zoom: location.scale,
  2479. scrollLeft: location.left,
  2480. scrollTop: location.top,
  2481. rotation: location.rotation
  2482. })["catch"](function () {});
  2483. }
  2484. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  2485. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  2486. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  2487. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  2488. var loading = (currentPage === null || currentPage === void 0 ? void 0 : currentPage.renderingState) !== _pdf_rendering_queue.RenderingStates.FINISHED;
  2489. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  2490. }
  2491. function webViewerScrollModeChanged(evt) {
  2492. var store = PDFViewerApplication.store;
  2493. if (store && PDFViewerApplication.isInitialViewSet) {
  2494. store.set("scrollMode", evt.mode)["catch"](function () {});
  2495. }
  2496. }
  2497. function webViewerSpreadModeChanged(evt) {
  2498. var store = PDFViewerApplication.store;
  2499. if (store && PDFViewerApplication.isInitialViewSet) {
  2500. store.set("spreadMode", evt.mode)["catch"](function () {});
  2501. }
  2502. }
  2503. function webViewerResize() {
  2504. var pdfDocument = PDFViewerApplication.pdfDocument,
  2505. pdfViewer = PDFViewerApplication.pdfViewer;
  2506. if (!pdfDocument) {
  2507. return;
  2508. }
  2509. var currentScaleValue = pdfViewer.currentScaleValue;
  2510. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  2511. pdfViewer.currentScaleValue = currentScaleValue;
  2512. }
  2513. pdfViewer.update();
  2514. }
  2515. function webViewerHashchange(evt) {
  2516. var hash = evt.hash;
  2517. if (!hash) {
  2518. return;
  2519. }
  2520. if (!PDFViewerApplication.isInitialViewSet) {
  2521. PDFViewerApplication.initialBookmark = hash;
  2522. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  2523. PDFViewerApplication.pdfLinkService.setHash(hash);
  2524. }
  2525. }
  2526. var webViewerFileInputChange, webViewerOpenFile;
  2527. {
  2528. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  2529. var _PDFViewerApplication;
  2530. if ((_PDFViewerApplication = PDFViewerApplication.pdfViewer) !== null && _PDFViewerApplication !== void 0 && _PDFViewerApplication.isInPresentationMode) {
  2531. return;
  2532. }
  2533. var file = evt.fileInput.files[0];
  2534. if (!_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  2535. var url = URL.createObjectURL(file);
  2536. if (file.name) {
  2537. url = {
  2538. url: url,
  2539. originalUrl: file.name
  2540. };
  2541. }
  2542. PDFViewerApplication.open(url);
  2543. } else {
  2544. PDFViewerApplication.setTitleUsingUrl(file.name);
  2545. var fileReader = new FileReader();
  2546. fileReader.onload = function webViewerChangeFileReaderOnload(event) {
  2547. var buffer = event.target.result;
  2548. PDFViewerApplication.open(new Uint8Array(buffer));
  2549. };
  2550. fileReader.readAsArrayBuffer(file);
  2551. }
  2552. var appConfig = PDFViewerApplication.appConfig;
  2553. appConfig.toolbar.viewBookmark.hidden = true;
  2554. appConfig.secondaryToolbar.viewBookmarkButton.hidden = true;
  2555. appConfig.toolbar.download.hidden = true;
  2556. appConfig.secondaryToolbar.downloadButton.hidden = true;
  2557. };
  2558. webViewerOpenFile = function webViewerOpenFile(evt) {
  2559. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  2560. document.getElementById(openFileInputName).click();
  2561. };
  2562. }
  2563. function webViewerPresentationMode() {
  2564. PDFViewerApplication.requestPresentationMode();
  2565. }
  2566. function webViewerPrint() {
  2567. PDFViewerApplication.triggerPrinting();
  2568. }
  2569. function webViewerDownload() {
  2570. PDFViewerApplication.downloadOrSave({
  2571. sourceEventType: "download"
  2572. });
  2573. }
  2574. function webViewerSave() {
  2575. PDFViewerApplication.downloadOrSave({
  2576. sourceEventType: "save"
  2577. });
  2578. }
  2579. function webViewerFirstPage() {
  2580. if (PDFViewerApplication.pdfDocument) {
  2581. PDFViewerApplication.page = 1;
  2582. }
  2583. }
  2584. function webViewerLastPage() {
  2585. if (PDFViewerApplication.pdfDocument) {
  2586. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2587. }
  2588. }
  2589. function webViewerNextPage() {
  2590. PDFViewerApplication.pdfViewer.nextPage();
  2591. }
  2592. function webViewerPreviousPage() {
  2593. PDFViewerApplication.pdfViewer.previousPage();
  2594. }
  2595. function webViewerZoomIn() {
  2596. PDFViewerApplication.zoomIn();
  2597. }
  2598. function webViewerZoomOut() {
  2599. PDFViewerApplication.zoomOut();
  2600. }
  2601. function webViewerZoomReset() {
  2602. PDFViewerApplication.zoomReset();
  2603. }
  2604. function webViewerPageNumberChanged(evt) {
  2605. var pdfViewer = PDFViewerApplication.pdfViewer;
  2606. if (evt.value !== "") {
  2607. PDFViewerApplication.pdfLinkService.goToPage(evt.value);
  2608. }
  2609. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  2610. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  2611. }
  2612. }
  2613. function webViewerScaleChanged(evt) {
  2614. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  2615. }
  2616. function webViewerRotateCw() {
  2617. PDFViewerApplication.rotatePages(90);
  2618. }
  2619. function webViewerRotateCcw() {
  2620. PDFViewerApplication.rotatePages(-90);
  2621. }
  2622. function webViewerOptionalContentConfig(evt) {
  2623. PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
  2624. }
  2625. function webViewerSwitchScrollMode(evt) {
  2626. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  2627. }
  2628. function webViewerSwitchSpreadMode(evt) {
  2629. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  2630. }
  2631. function webViewerDocumentProperties() {
  2632. PDFViewerApplication.pdfDocumentProperties.open();
  2633. }
  2634. function webViewerFind(evt) {
  2635. PDFViewerApplication.findController.executeCommand("find" + evt.type, {
  2636. query: evt.query,
  2637. phraseSearch: evt.phraseSearch,
  2638. caseSensitive: evt.caseSensitive,
  2639. entireWord: evt.entireWord,
  2640. highlightAll: evt.highlightAll,
  2641. findPrevious: evt.findPrevious
  2642. });
  2643. }
  2644. function webViewerFindFromUrlHash(evt) {
  2645. PDFViewerApplication.findController.executeCommand("find", {
  2646. query: evt.query,
  2647. phraseSearch: evt.phraseSearch,
  2648. caseSensitive: false,
  2649. entireWord: false,
  2650. highlightAll: true,
  2651. findPrevious: false
  2652. });
  2653. }
  2654. function webViewerUpdateFindMatchesCount(_ref13) {
  2655. var matchesCount = _ref13.matchesCount;
  2656. if (PDFViewerApplication.supportsIntegratedFind) {
  2657. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  2658. } else {
  2659. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  2660. }
  2661. }
  2662. function webViewerUpdateFindControlState(_ref14) {
  2663. var state = _ref14.state,
  2664. previous = _ref14.previous,
  2665. matchesCount = _ref14.matchesCount,
  2666. rawQuery = _ref14.rawQuery;
  2667. if (PDFViewerApplication.supportsIntegratedFind) {
  2668. PDFViewerApplication.externalServices.updateFindControlState({
  2669. result: state,
  2670. findPrevious: previous,
  2671. matchesCount: matchesCount,
  2672. rawQuery: rawQuery
  2673. });
  2674. } else {
  2675. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  2676. }
  2677. }
  2678. function webViewerScaleChanging(evt) {
  2679. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  2680. PDFViewerApplication.pdfViewer.update();
  2681. }
  2682. function webViewerRotationChanging(evt) {
  2683. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  2684. PDFViewerApplication.forceRendering();
  2685. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  2686. }
  2687. function webViewerPageChanging(_ref15) {
  2688. var pageNumber = _ref15.pageNumber,
  2689. pageLabel = _ref15.pageLabel;
  2690. PDFViewerApplication.toolbar.setPageNumber(pageNumber, pageLabel);
  2691. PDFViewerApplication.secondaryToolbar.setPageNumber(pageNumber);
  2692. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2693. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(pageNumber);
  2694. }
  2695. }
  2696. function webViewerVisibilityChange(evt) {
  2697. if (document.visibilityState === "visible") {
  2698. setZoomDisabledTimeout();
  2699. }
  2700. }
  2701. var zoomDisabledTimeout = null;
  2702. function setZoomDisabledTimeout() {
  2703. if (zoomDisabledTimeout) {
  2704. clearTimeout(zoomDisabledTimeout);
  2705. }
  2706. zoomDisabledTimeout = setTimeout(function () {
  2707. zoomDisabledTimeout = null;
  2708. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  2709. }
  2710. function webViewerWheel(evt) {
  2711. var pdfViewer = PDFViewerApplication.pdfViewer,
  2712. supportedMouseWheelZoomModifierKeys = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  2713. if (pdfViewer.isInPresentationMode) {
  2714. return;
  2715. }
  2716. if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
  2717. evt.preventDefault();
  2718. if (zoomDisabledTimeout || document.visibilityState === "hidden") {
  2719. return;
  2720. }
  2721. var previousScale = pdfViewer.currentScale;
  2722. var delta = (0, _ui_utils.normalizeWheelEventDirection)(evt);
  2723. var ticks = 0;
  2724. if (evt.deltaMode === WheelEvent.DOM_DELTA_LINE || evt.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
  2725. if (Math.abs(delta) >= 1) {
  2726. ticks = Math.sign(delta);
  2727. } else {
  2728. ticks = PDFViewerApplication.accumulateWheelTicks(delta);
  2729. }
  2730. } else {
  2731. var PIXELS_PER_LINE_SCALE = 30;
  2732. ticks = PDFViewerApplication.accumulateWheelTicks(delta / PIXELS_PER_LINE_SCALE);
  2733. }
  2734. if (ticks < 0) {
  2735. PDFViewerApplication.zoomOut(-ticks);
  2736. } else if (ticks > 0) {
  2737. PDFViewerApplication.zoomIn(ticks);
  2738. }
  2739. var currentScale = pdfViewer.currentScale;
  2740. if (previousScale !== currentScale) {
  2741. var scaleCorrectionFactor = currentScale / previousScale - 1;
  2742. var rect = pdfViewer.container.getBoundingClientRect();
  2743. var dx = evt.clientX - rect.left;
  2744. var dy = evt.clientY - rect.top;
  2745. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  2746. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  2747. }
  2748. } else {
  2749. setZoomDisabledTimeout();
  2750. }
  2751. }
  2752. function webViewerTouchStart(evt) {
  2753. if (evt.touches.length > 1) {
  2754. evt.preventDefault();
  2755. }
  2756. }
  2757. function webViewerClick(evt) {
  2758. if (PDFViewerApplication.triggerDelayedFallback && PDFViewerApplication.pdfViewer.containsElement(evt.target)) {
  2759. PDFViewerApplication.triggerDelayedFallback();
  2760. }
  2761. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  2762. return;
  2763. }
  2764. var appConfig = PDFViewerApplication.appConfig;
  2765. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  2766. PDFViewerApplication.secondaryToolbar.close();
  2767. }
  2768. }
  2769. function webViewerKeyUp(evt) {
  2770. if (evt.keyCode === 9) {
  2771. if (PDFViewerApplication.triggerDelayedFallback) {
  2772. PDFViewerApplication.triggerDelayedFallback();
  2773. }
  2774. }
  2775. }
  2776. function webViewerKeyDown(evt) {
  2777. if (PDFViewerApplication.overlayManager.active) {
  2778. return;
  2779. }
  2780. var handled = false,
  2781. ensureViewerFocused = false;
  2782. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  2783. var pdfViewer = PDFViewerApplication.pdfViewer;
  2784. var isViewerInPresentationMode = pdfViewer === null || pdfViewer === void 0 ? void 0 : pdfViewer.isInPresentationMode;
  2785. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  2786. switch (evt.keyCode) {
  2787. case 70:
  2788. if (!PDFViewerApplication.supportsIntegratedFind && !evt.shiftKey) {
  2789. PDFViewerApplication.findBar.open();
  2790. handled = true;
  2791. }
  2792. break;
  2793. case 71:
  2794. if (!PDFViewerApplication.supportsIntegratedFind) {
  2795. var findState = PDFViewerApplication.findController.state;
  2796. if (findState) {
  2797. PDFViewerApplication.findController.executeCommand("findagain", {
  2798. query: findState.query,
  2799. phraseSearch: findState.phraseSearch,
  2800. caseSensitive: findState.caseSensitive,
  2801. entireWord: findState.entireWord,
  2802. highlightAll: findState.highlightAll,
  2803. findPrevious: cmd === 5 || cmd === 12
  2804. });
  2805. }
  2806. handled = true;
  2807. }
  2808. break;
  2809. case 61:
  2810. case 107:
  2811. case 187:
  2812. case 171:
  2813. if (!isViewerInPresentationMode) {
  2814. PDFViewerApplication.zoomIn();
  2815. }
  2816. handled = true;
  2817. break;
  2818. case 173:
  2819. case 109:
  2820. case 189:
  2821. if (!isViewerInPresentationMode) {
  2822. PDFViewerApplication.zoomOut();
  2823. }
  2824. handled = true;
  2825. break;
  2826. case 48:
  2827. case 96:
  2828. if (!isViewerInPresentationMode) {
  2829. setTimeout(function () {
  2830. PDFViewerApplication.zoomReset();
  2831. });
  2832. handled = false;
  2833. }
  2834. break;
  2835. case 38:
  2836. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2837. PDFViewerApplication.page = 1;
  2838. handled = true;
  2839. ensureViewerFocused = true;
  2840. }
  2841. break;
  2842. case 40:
  2843. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2844. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2845. handled = true;
  2846. ensureViewerFocused = true;
  2847. }
  2848. break;
  2849. }
  2850. }
  2851. var eventBus = PDFViewerApplication.eventBus;
  2852. if (cmd === 1 || cmd === 8) {
  2853. switch (evt.keyCode) {
  2854. case 83:
  2855. eventBus.dispatch("download", {
  2856. source: window
  2857. });
  2858. handled = true;
  2859. break;
  2860. case 79:
  2861. {
  2862. eventBus.dispatch("openfile", {
  2863. source: window
  2864. });
  2865. handled = true;
  2866. }
  2867. break;
  2868. }
  2869. }
  2870. if (cmd === 3 || cmd === 10) {
  2871. switch (evt.keyCode) {
  2872. case 80:
  2873. PDFViewerApplication.requestPresentationMode();
  2874. handled = true;
  2875. break;
  2876. case 71:
  2877. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2878. handled = true;
  2879. break;
  2880. }
  2881. }
  2882. if (handled) {
  2883. if (ensureViewerFocused && !isViewerInPresentationMode) {
  2884. pdfViewer.focus();
  2885. }
  2886. evt.preventDefault();
  2887. return;
  2888. }
  2889. var curElement = (0, _ui_utils.getActiveOrFocusedElement)();
  2890. var curElementTagName = curElement === null || curElement === void 0 ? void 0 : curElement.tagName.toUpperCase();
  2891. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement !== null && curElement !== void 0 && curElement.isContentEditable) {
  2892. if (evt.keyCode !== 27) {
  2893. return;
  2894. }
  2895. }
  2896. if (cmd === 0) {
  2897. var turnPage = 0,
  2898. turnOnlyIfPageFit = false;
  2899. switch (evt.keyCode) {
  2900. case 38:
  2901. case 33:
  2902. if (pdfViewer.isVerticalScrollbarEnabled) {
  2903. turnOnlyIfPageFit = true;
  2904. }
  2905. turnPage = -1;
  2906. break;
  2907. case 8:
  2908. if (!isViewerInPresentationMode) {
  2909. turnOnlyIfPageFit = true;
  2910. }
  2911. turnPage = -1;
  2912. break;
  2913. case 37:
  2914. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2915. turnOnlyIfPageFit = true;
  2916. }
  2917. case 75:
  2918. case 80:
  2919. turnPage = -1;
  2920. break;
  2921. case 27:
  2922. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  2923. PDFViewerApplication.secondaryToolbar.close();
  2924. handled = true;
  2925. }
  2926. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  2927. PDFViewerApplication.findBar.close();
  2928. handled = true;
  2929. }
  2930. break;
  2931. case 40:
  2932. case 34:
  2933. if (pdfViewer.isVerticalScrollbarEnabled) {
  2934. turnOnlyIfPageFit = true;
  2935. }
  2936. turnPage = 1;
  2937. break;
  2938. case 13:
  2939. case 32:
  2940. if (!isViewerInPresentationMode) {
  2941. turnOnlyIfPageFit = true;
  2942. }
  2943. turnPage = 1;
  2944. break;
  2945. case 39:
  2946. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2947. turnOnlyIfPageFit = true;
  2948. }
  2949. case 74:
  2950. case 78:
  2951. turnPage = 1;
  2952. break;
  2953. case 36:
  2954. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2955. PDFViewerApplication.page = 1;
  2956. handled = true;
  2957. ensureViewerFocused = true;
  2958. }
  2959. break;
  2960. case 35:
  2961. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2962. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2963. handled = true;
  2964. ensureViewerFocused = true;
  2965. }
  2966. break;
  2967. case 83:
  2968. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  2969. break;
  2970. case 72:
  2971. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  2972. break;
  2973. case 82:
  2974. PDFViewerApplication.rotatePages(90);
  2975. break;
  2976. case 115:
  2977. PDFViewerApplication.pdfSidebar.toggle();
  2978. break;
  2979. }
  2980. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  2981. if (turnPage > 0) {
  2982. pdfViewer.nextPage();
  2983. } else {
  2984. pdfViewer.previousPage();
  2985. }
  2986. handled = true;
  2987. }
  2988. }
  2989. if (cmd === 4) {
  2990. switch (evt.keyCode) {
  2991. case 13:
  2992. case 32:
  2993. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  2994. break;
  2995. }
  2996. if (PDFViewerApplication.page > 1) {
  2997. PDFViewerApplication.page--;
  2998. }
  2999. handled = true;
  3000. break;
  3001. case 82:
  3002. PDFViewerApplication.rotatePages(-90);
  3003. break;
  3004. }
  3005. }
  3006. if (!handled && !isViewerInPresentationMode) {
  3007. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  3008. ensureViewerFocused = true;
  3009. }
  3010. }
  3011. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  3012. pdfViewer.focus();
  3013. }
  3014. if (handled) {
  3015. evt.preventDefault();
  3016. }
  3017. }
  3018. function beforeUnload(evt) {
  3019. evt.preventDefault();
  3020. evt.returnValue = "";
  3021. return false;
  3022. }
  3023. var PDFPrintServiceFactory = {
  3024. instance: {
  3025. supportsPrinting: false,
  3026. createPrintService: function createPrintService() {
  3027. throw new Error("Not implemented: createPrintService");
  3028. }
  3029. }
  3030. };
  3031. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  3032. /***/ }),
  3033. /* 4 */
  3034. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3035. module.exports = __webpack_require__(5);
  3036. /***/ }),
  3037. /* 5 */
  3038. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3039. /* module decorator */ module = __webpack_require__.nmd(module);
  3040. 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); }
  3041. var runtime = function (exports) {
  3042. "use strict";
  3043. var Op = Object.prototype;
  3044. var hasOwn = Op.hasOwnProperty;
  3045. var undefined;
  3046. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  3047. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  3048. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  3049. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  3050. function define(obj, key, value) {
  3051. Object.defineProperty(obj, key, {
  3052. value: value,
  3053. enumerable: true,
  3054. configurable: true,
  3055. writable: true
  3056. });
  3057. return obj[key];
  3058. }
  3059. try {
  3060. define({}, "");
  3061. } catch (err) {
  3062. define = function define(obj, key, value) {
  3063. return obj[key] = value;
  3064. };
  3065. }
  3066. function wrap(innerFn, outerFn, self, tryLocsList) {
  3067. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  3068. var generator = Object.create(protoGenerator.prototype);
  3069. var context = new Context(tryLocsList || []);
  3070. generator._invoke = makeInvokeMethod(innerFn, self, context);
  3071. return generator;
  3072. }
  3073. exports.wrap = wrap;
  3074. function tryCatch(fn, obj, arg) {
  3075. try {
  3076. return {
  3077. type: "normal",
  3078. arg: fn.call(obj, arg)
  3079. };
  3080. } catch (err) {
  3081. return {
  3082. type: "throw",
  3083. arg: err
  3084. };
  3085. }
  3086. }
  3087. var GenStateSuspendedStart = "suspendedStart";
  3088. var GenStateSuspendedYield = "suspendedYield";
  3089. var GenStateExecuting = "executing";
  3090. var GenStateCompleted = "completed";
  3091. var ContinueSentinel = {};
  3092. function Generator() {}
  3093. function GeneratorFunction() {}
  3094. function GeneratorFunctionPrototype() {}
  3095. var IteratorPrototype = {};
  3096. IteratorPrototype[iteratorSymbol] = function () {
  3097. return this;
  3098. };
  3099. var getProto = Object.getPrototypeOf;
  3100. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  3101. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  3102. IteratorPrototype = NativeIteratorPrototype;
  3103. }
  3104. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  3105. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  3106. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  3107. GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
  3108. function defineIteratorMethods(prototype) {
  3109. ["next", "throw", "return"].forEach(function (method) {
  3110. define(prototype, method, function (arg) {
  3111. return this._invoke(method, arg);
  3112. });
  3113. });
  3114. }
  3115. exports.isGeneratorFunction = function (genFun) {
  3116. var ctor = typeof genFun === "function" && genFun.constructor;
  3117. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  3118. };
  3119. exports.mark = function (genFun) {
  3120. if (Object.setPrototypeOf) {
  3121. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  3122. } else {
  3123. genFun.__proto__ = GeneratorFunctionPrototype;
  3124. define(genFun, toStringTagSymbol, "GeneratorFunction");
  3125. }
  3126. genFun.prototype = Object.create(Gp);
  3127. return genFun;
  3128. };
  3129. exports.awrap = function (arg) {
  3130. return {
  3131. __await: arg
  3132. };
  3133. };
  3134. function AsyncIterator(generator, PromiseImpl) {
  3135. function invoke(method, arg, resolve, reject) {
  3136. var record = tryCatch(generator[method], generator, arg);
  3137. if (record.type === "throw") {
  3138. reject(record.arg);
  3139. } else {
  3140. var result = record.arg;
  3141. var value = result.value;
  3142. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  3143. return PromiseImpl.resolve(value.__await).then(function (value) {
  3144. invoke("next", value, resolve, reject);
  3145. }, function (err) {
  3146. invoke("throw", err, resolve, reject);
  3147. });
  3148. }
  3149. return PromiseImpl.resolve(value).then(function (unwrapped) {
  3150. result.value = unwrapped;
  3151. resolve(result);
  3152. }, function (error) {
  3153. return invoke("throw", error, resolve, reject);
  3154. });
  3155. }
  3156. }
  3157. var previousPromise;
  3158. function enqueue(method, arg) {
  3159. function callInvokeWithMethodAndArg() {
  3160. return new PromiseImpl(function (resolve, reject) {
  3161. invoke(method, arg, resolve, reject);
  3162. });
  3163. }
  3164. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  3165. }
  3166. this._invoke = enqueue;
  3167. }
  3168. defineIteratorMethods(AsyncIterator.prototype);
  3169. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  3170. return this;
  3171. };
  3172. exports.AsyncIterator = AsyncIterator;
  3173. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  3174. if (PromiseImpl === void 0) PromiseImpl = Promise;
  3175. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  3176. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  3177. return result.done ? result.value : iter.next();
  3178. });
  3179. };
  3180. function makeInvokeMethod(innerFn, self, context) {
  3181. var state = GenStateSuspendedStart;
  3182. return function invoke(method, arg) {
  3183. if (state === GenStateExecuting) {
  3184. throw new Error("Generator is already running");
  3185. }
  3186. if (state === GenStateCompleted) {
  3187. if (method === "throw") {
  3188. throw arg;
  3189. }
  3190. return doneResult();
  3191. }
  3192. context.method = method;
  3193. context.arg = arg;
  3194. while (true) {
  3195. var delegate = context.delegate;
  3196. if (delegate) {
  3197. var delegateResult = maybeInvokeDelegate(delegate, context);
  3198. if (delegateResult) {
  3199. if (delegateResult === ContinueSentinel) continue;
  3200. return delegateResult;
  3201. }
  3202. }
  3203. if (context.method === "next") {
  3204. context.sent = context._sent = context.arg;
  3205. } else if (context.method === "throw") {
  3206. if (state === GenStateSuspendedStart) {
  3207. state = GenStateCompleted;
  3208. throw context.arg;
  3209. }
  3210. context.dispatchException(context.arg);
  3211. } else if (context.method === "return") {
  3212. context.abrupt("return", context.arg);
  3213. }
  3214. state = GenStateExecuting;
  3215. var record = tryCatch(innerFn, self, context);
  3216. if (record.type === "normal") {
  3217. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  3218. if (record.arg === ContinueSentinel) {
  3219. continue;
  3220. }
  3221. return {
  3222. value: record.arg,
  3223. done: context.done
  3224. };
  3225. } else if (record.type === "throw") {
  3226. state = GenStateCompleted;
  3227. context.method = "throw";
  3228. context.arg = record.arg;
  3229. }
  3230. }
  3231. };
  3232. }
  3233. function maybeInvokeDelegate(delegate, context) {
  3234. var method = delegate.iterator[context.method];
  3235. if (method === undefined) {
  3236. context.delegate = null;
  3237. if (context.method === "throw") {
  3238. if (delegate.iterator["return"]) {
  3239. context.method = "return";
  3240. context.arg = undefined;
  3241. maybeInvokeDelegate(delegate, context);
  3242. if (context.method === "throw") {
  3243. return ContinueSentinel;
  3244. }
  3245. }
  3246. context.method = "throw";
  3247. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  3248. }
  3249. return ContinueSentinel;
  3250. }
  3251. var record = tryCatch(method, delegate.iterator, context.arg);
  3252. if (record.type === "throw") {
  3253. context.method = "throw";
  3254. context.arg = record.arg;
  3255. context.delegate = null;
  3256. return ContinueSentinel;
  3257. }
  3258. var info = record.arg;
  3259. if (!info) {
  3260. context.method = "throw";
  3261. context.arg = new TypeError("iterator result is not an object");
  3262. context.delegate = null;
  3263. return ContinueSentinel;
  3264. }
  3265. if (info.done) {
  3266. context[delegate.resultName] = info.value;
  3267. context.next = delegate.nextLoc;
  3268. if (context.method !== "return") {
  3269. context.method = "next";
  3270. context.arg = undefined;
  3271. }
  3272. } else {
  3273. return info;
  3274. }
  3275. context.delegate = null;
  3276. return ContinueSentinel;
  3277. }
  3278. defineIteratorMethods(Gp);
  3279. define(Gp, toStringTagSymbol, "Generator");
  3280. Gp[iteratorSymbol] = function () {
  3281. return this;
  3282. };
  3283. Gp.toString = function () {
  3284. return "[object Generator]";
  3285. };
  3286. function pushTryEntry(locs) {
  3287. var entry = {
  3288. tryLoc: locs[0]
  3289. };
  3290. if (1 in locs) {
  3291. entry.catchLoc = locs[1];
  3292. }
  3293. if (2 in locs) {
  3294. entry.finallyLoc = locs[2];
  3295. entry.afterLoc = locs[3];
  3296. }
  3297. this.tryEntries.push(entry);
  3298. }
  3299. function resetTryEntry(entry) {
  3300. var record = entry.completion || {};
  3301. record.type = "normal";
  3302. delete record.arg;
  3303. entry.completion = record;
  3304. }
  3305. function Context(tryLocsList) {
  3306. this.tryEntries = [{
  3307. tryLoc: "root"
  3308. }];
  3309. tryLocsList.forEach(pushTryEntry, this);
  3310. this.reset(true);
  3311. }
  3312. exports.keys = function (object) {
  3313. var keys = [];
  3314. for (var key in object) {
  3315. keys.push(key);
  3316. }
  3317. keys.reverse();
  3318. return function next() {
  3319. while (keys.length) {
  3320. var key = keys.pop();
  3321. if (key in object) {
  3322. next.value = key;
  3323. next.done = false;
  3324. return next;
  3325. }
  3326. }
  3327. next.done = true;
  3328. return next;
  3329. };
  3330. };
  3331. function values(iterable) {
  3332. if (iterable) {
  3333. var iteratorMethod = iterable[iteratorSymbol];
  3334. if (iteratorMethod) {
  3335. return iteratorMethod.call(iterable);
  3336. }
  3337. if (typeof iterable.next === "function") {
  3338. return iterable;
  3339. }
  3340. if (!isNaN(iterable.length)) {
  3341. var i = -1,
  3342. next = function next() {
  3343. while (++i < iterable.length) {
  3344. if (hasOwn.call(iterable, i)) {
  3345. next.value = iterable[i];
  3346. next.done = false;
  3347. return next;
  3348. }
  3349. }
  3350. next.value = undefined;
  3351. next.done = true;
  3352. return next;
  3353. };
  3354. return next.next = next;
  3355. }
  3356. }
  3357. return {
  3358. next: doneResult
  3359. };
  3360. }
  3361. exports.values = values;
  3362. function doneResult() {
  3363. return {
  3364. value: undefined,
  3365. done: true
  3366. };
  3367. }
  3368. Context.prototype = {
  3369. constructor: Context,
  3370. reset: function reset(skipTempReset) {
  3371. this.prev = 0;
  3372. this.next = 0;
  3373. this.sent = this._sent = undefined;
  3374. this.done = false;
  3375. this.delegate = null;
  3376. this.method = "next";
  3377. this.arg = undefined;
  3378. this.tryEntries.forEach(resetTryEntry);
  3379. if (!skipTempReset) {
  3380. for (var name in this) {
  3381. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  3382. this[name] = undefined;
  3383. }
  3384. }
  3385. }
  3386. },
  3387. stop: function stop() {
  3388. this.done = true;
  3389. var rootEntry = this.tryEntries[0];
  3390. var rootRecord = rootEntry.completion;
  3391. if (rootRecord.type === "throw") {
  3392. throw rootRecord.arg;
  3393. }
  3394. return this.rval;
  3395. },
  3396. dispatchException: function dispatchException(exception) {
  3397. if (this.done) {
  3398. throw exception;
  3399. }
  3400. var context = this;
  3401. function handle(loc, caught) {
  3402. record.type = "throw";
  3403. record.arg = exception;
  3404. context.next = loc;
  3405. if (caught) {
  3406. context.method = "next";
  3407. context.arg = undefined;
  3408. }
  3409. return !!caught;
  3410. }
  3411. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3412. var entry = this.tryEntries[i];
  3413. var record = entry.completion;
  3414. if (entry.tryLoc === "root") {
  3415. return handle("end");
  3416. }
  3417. if (entry.tryLoc <= this.prev) {
  3418. var hasCatch = hasOwn.call(entry, "catchLoc");
  3419. var hasFinally = hasOwn.call(entry, "finallyLoc");
  3420. if (hasCatch && hasFinally) {
  3421. if (this.prev < entry.catchLoc) {
  3422. return handle(entry.catchLoc, true);
  3423. } else if (this.prev < entry.finallyLoc) {
  3424. return handle(entry.finallyLoc);
  3425. }
  3426. } else if (hasCatch) {
  3427. if (this.prev < entry.catchLoc) {
  3428. return handle(entry.catchLoc, true);
  3429. }
  3430. } else if (hasFinally) {
  3431. if (this.prev < entry.finallyLoc) {
  3432. return handle(entry.finallyLoc);
  3433. }
  3434. } else {
  3435. throw new Error("try statement without catch or finally");
  3436. }
  3437. }
  3438. }
  3439. },
  3440. abrupt: function abrupt(type, arg) {
  3441. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3442. var entry = this.tryEntries[i];
  3443. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  3444. var finallyEntry = entry;
  3445. break;
  3446. }
  3447. }
  3448. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  3449. finallyEntry = null;
  3450. }
  3451. var record = finallyEntry ? finallyEntry.completion : {};
  3452. record.type = type;
  3453. record.arg = arg;
  3454. if (finallyEntry) {
  3455. this.method = "next";
  3456. this.next = finallyEntry.finallyLoc;
  3457. return ContinueSentinel;
  3458. }
  3459. return this.complete(record);
  3460. },
  3461. complete: function complete(record, afterLoc) {
  3462. if (record.type === "throw") {
  3463. throw record.arg;
  3464. }
  3465. if (record.type === "break" || record.type === "continue") {
  3466. this.next = record.arg;
  3467. } else if (record.type === "return") {
  3468. this.rval = this.arg = record.arg;
  3469. this.method = "return";
  3470. this.next = "end";
  3471. } else if (record.type === "normal" && afterLoc) {
  3472. this.next = afterLoc;
  3473. }
  3474. return ContinueSentinel;
  3475. },
  3476. finish: function finish(finallyLoc) {
  3477. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3478. var entry = this.tryEntries[i];
  3479. if (entry.finallyLoc === finallyLoc) {
  3480. this.complete(entry.completion, entry.afterLoc);
  3481. resetTryEntry(entry);
  3482. return ContinueSentinel;
  3483. }
  3484. }
  3485. },
  3486. "catch": function _catch(tryLoc) {
  3487. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3488. var entry = this.tryEntries[i];
  3489. if (entry.tryLoc === tryLoc) {
  3490. var record = entry.completion;
  3491. if (record.type === "throw") {
  3492. var thrown = record.arg;
  3493. resetTryEntry(entry);
  3494. }
  3495. return thrown;
  3496. }
  3497. }
  3498. throw new Error("illegal catch attempt");
  3499. },
  3500. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  3501. this.delegate = {
  3502. iterator: values(iterable),
  3503. resultName: resultName,
  3504. nextLoc: nextLoc
  3505. };
  3506. if (this.method === "next") {
  3507. this.arg = undefined;
  3508. }
  3509. return ContinueSentinel;
  3510. }
  3511. };
  3512. return exports;
  3513. }(( false ? 0 : _typeof(module)) === "object" ? module.exports : {});
  3514. try {
  3515. regeneratorRuntime = runtime;
  3516. } catch (accidentalStrictMode) {
  3517. Function("r", "regeneratorRuntime = r")(runtime);
  3518. }
  3519. /***/ }),
  3520. /* 6 */
  3521. /***/ ((__unused_webpack_module, exports) => {
  3522. Object.defineProperty(exports, "__esModule", ({
  3523. value: true
  3524. }));
  3525. exports.apiPageLayoutToSpreadMode = apiPageLayoutToSpreadMode;
  3526. exports.apiPageModeToSidebarView = apiPageModeToSidebarView;
  3527. exports.approximateFraction = approximateFraction;
  3528. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  3529. exports.binarySearchFirstItem = binarySearchFirstItem;
  3530. exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
  3531. exports.getOutputScale = getOutputScale;
  3532. exports.getPageSizeInches = getPageSizeInches;
  3533. exports.getVisibleElements = getVisibleElements;
  3534. exports.isPortraitOrientation = isPortraitOrientation;
  3535. exports.isValidRotation = isValidRotation;
  3536. exports.isValidScrollMode = isValidScrollMode;
  3537. exports.isValidSpreadMode = isValidSpreadMode;
  3538. exports.moveToEndOfArray = moveToEndOfArray;
  3539. exports.noContextMenuHandler = noContextMenuHandler;
  3540. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  3541. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  3542. exports.parseQueryString = parseQueryString;
  3543. exports.roundToDivide = roundToDivide;
  3544. exports.scrollIntoView = scrollIntoView;
  3545. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  3546. exports.watchScroll = watchScroll;
  3547. 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.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;
  3548. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3549. 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); } }
  3550. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3551. 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); }
  3552. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  3553. 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."); }
  3554. 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); }
  3555. 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; }
  3556. 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; }
  3557. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  3558. var CSS_UNITS = 96.0 / 72.0;
  3559. exports.CSS_UNITS = CSS_UNITS;
  3560. var DEFAULT_SCALE_VALUE = "auto";
  3561. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  3562. var DEFAULT_SCALE = 1.0;
  3563. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  3564. var MIN_SCALE = 0.1;
  3565. exports.MIN_SCALE = MIN_SCALE;
  3566. var MAX_SCALE = 10.0;
  3567. exports.MAX_SCALE = MAX_SCALE;
  3568. var UNKNOWN_SCALE = 0;
  3569. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  3570. var MAX_AUTO_SCALE = 1.25;
  3571. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  3572. var SCROLLBAR_PADDING = 40;
  3573. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  3574. var VERTICAL_PADDING = 5;
  3575. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  3576. var LOADINGBAR_END_OFFSET_VAR = "--loadingBar-end-offset";
  3577. var PresentationModeState = {
  3578. UNKNOWN: 0,
  3579. NORMAL: 1,
  3580. CHANGING: 2,
  3581. FULLSCREEN: 3
  3582. };
  3583. exports.PresentationModeState = PresentationModeState;
  3584. var SidebarView = {
  3585. UNKNOWN: -1,
  3586. NONE: 0,
  3587. THUMBS: 1,
  3588. OUTLINE: 2,
  3589. ATTACHMENTS: 3,
  3590. LAYERS: 4
  3591. };
  3592. exports.SidebarView = SidebarView;
  3593. var RendererType = {
  3594. CANVAS: "canvas",
  3595. SVG: "svg"
  3596. };
  3597. exports.RendererType = RendererType;
  3598. var TextLayerMode = {
  3599. DISABLE: 0,
  3600. ENABLE: 1,
  3601. ENABLE_ENHANCE: 2
  3602. };
  3603. exports.TextLayerMode = TextLayerMode;
  3604. var ScrollMode = {
  3605. UNKNOWN: -1,
  3606. VERTICAL: 0,
  3607. HORIZONTAL: 1,
  3608. WRAPPED: 2
  3609. };
  3610. exports.ScrollMode = ScrollMode;
  3611. var SpreadMode = {
  3612. UNKNOWN: -1,
  3613. NONE: 0,
  3614. ODD: 1,
  3615. EVEN: 2
  3616. };
  3617. exports.SpreadMode = SpreadMode;
  3618. var AutoPrintRegExp = /\bprint\s*\(/;
  3619. exports.AutoPrintRegExp = AutoPrintRegExp;
  3620. function getOutputScale(ctx) {
  3621. var devicePixelRatio = window.devicePixelRatio || 1;
  3622. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  3623. var pixelRatio = devicePixelRatio / backingStoreRatio;
  3624. return {
  3625. sx: pixelRatio,
  3626. sy: pixelRatio,
  3627. scaled: pixelRatio !== 1
  3628. };
  3629. }
  3630. function scrollIntoView(element, spot) {
  3631. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3632. var parent = element.offsetParent;
  3633. if (!parent) {
  3634. console.error("offsetParent is not set -- cannot scroll");
  3635. return;
  3636. }
  3637. var offsetY = element.offsetTop + element.clientTop;
  3638. var offsetX = element.offsetLeft + element.clientLeft;
  3639. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === "hidden") {
  3640. if (parent.dataset._scaleY) {
  3641. offsetY /= parent.dataset._scaleY;
  3642. offsetX /= parent.dataset._scaleX;
  3643. }
  3644. offsetY += parent.offsetTop;
  3645. offsetX += parent.offsetLeft;
  3646. parent = parent.offsetParent;
  3647. if (!parent) {
  3648. return;
  3649. }
  3650. }
  3651. if (spot) {
  3652. if (spot.top !== undefined) {
  3653. offsetY += spot.top;
  3654. }
  3655. if (spot.left !== undefined) {
  3656. offsetX += spot.left;
  3657. parent.scrollLeft = offsetX;
  3658. }
  3659. }
  3660. parent.scrollTop = offsetY;
  3661. }
  3662. function watchScroll(viewAreaElement, callback) {
  3663. var debounceScroll = function debounceScroll(evt) {
  3664. if (rAF) {
  3665. return;
  3666. }
  3667. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  3668. rAF = null;
  3669. var currentX = viewAreaElement.scrollLeft;
  3670. var lastX = state.lastX;
  3671. if (currentX !== lastX) {
  3672. state.right = currentX > lastX;
  3673. }
  3674. state.lastX = currentX;
  3675. var currentY = viewAreaElement.scrollTop;
  3676. var lastY = state.lastY;
  3677. if (currentY !== lastY) {
  3678. state.down = currentY > lastY;
  3679. }
  3680. state.lastY = currentY;
  3681. callback(state);
  3682. });
  3683. };
  3684. var state = {
  3685. right: true,
  3686. down: true,
  3687. lastX: viewAreaElement.scrollLeft,
  3688. lastY: viewAreaElement.scrollTop,
  3689. _eventHandler: debounceScroll
  3690. };
  3691. var rAF = null;
  3692. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  3693. return state;
  3694. }
  3695. function parseQueryString(query) {
  3696. var parts = query.split("&");
  3697. var params = Object.create(null);
  3698. for (var i = 0, ii = parts.length; i < ii; ++i) {
  3699. var param = parts[i].split("=");
  3700. var key = param[0].toLowerCase();
  3701. var value = param.length > 1 ? param[1] : null;
  3702. params[decodeURIComponent(key)] = decodeURIComponent(value);
  3703. }
  3704. return params;
  3705. }
  3706. function binarySearchFirstItem(items, condition) {
  3707. var minIndex = 0;
  3708. var maxIndex = items.length - 1;
  3709. if (maxIndex < 0 || !condition(items[maxIndex])) {
  3710. return items.length;
  3711. }
  3712. if (condition(items[minIndex])) {
  3713. return minIndex;
  3714. }
  3715. while (minIndex < maxIndex) {
  3716. var currentIndex = minIndex + maxIndex >> 1;
  3717. var currentItem = items[currentIndex];
  3718. if (condition(currentItem)) {
  3719. maxIndex = currentIndex;
  3720. } else {
  3721. minIndex = currentIndex + 1;
  3722. }
  3723. }
  3724. return minIndex;
  3725. }
  3726. function approximateFraction(x) {
  3727. if (Math.floor(x) === x) {
  3728. return [x, 1];
  3729. }
  3730. var xinv = 1 / x;
  3731. var limit = 8;
  3732. if (xinv > limit) {
  3733. return [1, limit];
  3734. } else if (Math.floor(xinv) === xinv) {
  3735. return [1, xinv];
  3736. }
  3737. var x_ = x > 1 ? xinv : x;
  3738. var a = 0,
  3739. b = 1,
  3740. c = 1,
  3741. d = 1;
  3742. while (true) {
  3743. var p = a + c,
  3744. q = b + d;
  3745. if (q > limit) {
  3746. break;
  3747. }
  3748. if (x_ <= p / q) {
  3749. c = p;
  3750. d = q;
  3751. } else {
  3752. a = p;
  3753. b = q;
  3754. }
  3755. }
  3756. var result;
  3757. if (x_ - a / b < c / d - x_) {
  3758. result = x_ === x ? [a, b] : [b, a];
  3759. } else {
  3760. result = x_ === x ? [c, d] : [d, c];
  3761. }
  3762. return result;
  3763. }
  3764. function roundToDivide(x, div) {
  3765. var r = x % div;
  3766. return r === 0 ? x : Math.round(x - r + div);
  3767. }
  3768. function getPageSizeInches(_ref) {
  3769. var view = _ref.view,
  3770. userUnit = _ref.userUnit,
  3771. rotate = _ref.rotate;
  3772. var _view = _slicedToArray(view, 4),
  3773. x1 = _view[0],
  3774. y1 = _view[1],
  3775. x2 = _view[2],
  3776. y2 = _view[3];
  3777. var changeOrientation = rotate % 180 !== 0;
  3778. var width = (x2 - x1) / 72 * userUnit;
  3779. var height = (y2 - y1) / 72 * userUnit;
  3780. return {
  3781. width: changeOrientation ? height : width,
  3782. height: changeOrientation ? width : height
  3783. };
  3784. }
  3785. function backtrackBeforeAllVisibleElements(index, views, top) {
  3786. if (index < 2) {
  3787. return index;
  3788. }
  3789. var elt = views[index].div;
  3790. var pageTop = elt.offsetTop + elt.clientTop;
  3791. if (pageTop >= top) {
  3792. elt = views[index - 1].div;
  3793. pageTop = elt.offsetTop + elt.clientTop;
  3794. }
  3795. for (var i = index - 2; i >= 0; --i) {
  3796. elt = views[i].div;
  3797. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  3798. break;
  3799. }
  3800. index = i;
  3801. }
  3802. return index;
  3803. }
  3804. function getVisibleElements(_ref2) {
  3805. var scrollEl = _ref2.scrollEl,
  3806. views = _ref2.views,
  3807. _ref2$sortByVisibilit = _ref2.sortByVisibility,
  3808. sortByVisibility = _ref2$sortByVisibilit === void 0 ? false : _ref2$sortByVisibilit,
  3809. _ref2$horizontal = _ref2.horizontal,
  3810. horizontal = _ref2$horizontal === void 0 ? false : _ref2$horizontal,
  3811. _ref2$rtl = _ref2.rtl,
  3812. rtl = _ref2$rtl === void 0 ? false : _ref2$rtl;
  3813. var top = scrollEl.scrollTop,
  3814. bottom = top + scrollEl.clientHeight;
  3815. var left = scrollEl.scrollLeft,
  3816. right = left + scrollEl.clientWidth;
  3817. function isElementBottomAfterViewTop(view) {
  3818. var element = view.div;
  3819. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  3820. return elementBottom > top;
  3821. }
  3822. function isElementNextAfterViewHorizontally(view) {
  3823. var element = view.div;
  3824. var elementLeft = element.offsetLeft + element.clientLeft;
  3825. var elementRight = elementLeft + element.clientWidth;
  3826. return rtl ? elementLeft < right : elementRight > left;
  3827. }
  3828. var visible = [],
  3829. numViews = views.length;
  3830. var firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  3831. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  3832. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  3833. }
  3834. var lastEdge = horizontal ? right : -1;
  3835. for (var i = firstVisibleElementInd; i < numViews; i++) {
  3836. var view = views[i],
  3837. element = view.div;
  3838. var currentWidth = element.offsetLeft + element.clientLeft;
  3839. var currentHeight = element.offsetTop + element.clientTop;
  3840. var viewWidth = element.clientWidth,
  3841. viewHeight = element.clientHeight;
  3842. var viewRight = currentWidth + viewWidth;
  3843. var viewBottom = currentHeight + viewHeight;
  3844. if (lastEdge === -1) {
  3845. if (viewBottom >= bottom) {
  3846. lastEdge = viewBottom;
  3847. }
  3848. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  3849. break;
  3850. }
  3851. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  3852. continue;
  3853. }
  3854. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  3855. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  3856. var fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  3857. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  3858. var percent = fractionHeight * fractionWidth * 100 | 0;
  3859. visible.push({
  3860. id: view.id,
  3861. x: currentWidth,
  3862. y: currentHeight,
  3863. view: view,
  3864. percent: percent,
  3865. widthPercent: fractionWidth * 100 | 0
  3866. });
  3867. }
  3868. var first = visible[0],
  3869. last = visible[visible.length - 1];
  3870. if (sortByVisibility) {
  3871. visible.sort(function (a, b) {
  3872. var pc = a.percent - b.percent;
  3873. if (Math.abs(pc) > 0.001) {
  3874. return -pc;
  3875. }
  3876. return a.id - b.id;
  3877. });
  3878. }
  3879. return {
  3880. first: first,
  3881. last: last,
  3882. views: visible
  3883. };
  3884. }
  3885. function noContextMenuHandler(evt) {
  3886. evt.preventDefault();
  3887. }
  3888. function normalizeWheelEventDirection(evt) {
  3889. var delta = Math.hypot(evt.deltaX, evt.deltaY);
  3890. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  3891. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  3892. delta = -delta;
  3893. }
  3894. return delta;
  3895. }
  3896. function normalizeWheelEventDelta(evt) {
  3897. var delta = normalizeWheelEventDirection(evt);
  3898. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  3899. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  3900. var MOUSE_PIXELS_PER_LINE = 30;
  3901. var MOUSE_LINES_PER_PAGE = 30;
  3902. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  3903. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  3904. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  3905. delta /= MOUSE_LINES_PER_PAGE;
  3906. }
  3907. return delta;
  3908. }
  3909. function isValidRotation(angle) {
  3910. return Number.isInteger(angle) && angle % 90 === 0;
  3911. }
  3912. function isValidScrollMode(mode) {
  3913. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  3914. }
  3915. function isValidSpreadMode(mode) {
  3916. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  3917. }
  3918. function isPortraitOrientation(size) {
  3919. return size.width <= size.height;
  3920. }
  3921. var WaitOnType = {
  3922. EVENT: "event",
  3923. TIMEOUT: "timeout"
  3924. };
  3925. exports.WaitOnType = WaitOnType;
  3926. function waitOnEventOrTimeout(_ref3) {
  3927. var target = _ref3.target,
  3928. name = _ref3.name,
  3929. _ref3$delay = _ref3.delay,
  3930. delay = _ref3$delay === void 0 ? 0 : _ref3$delay;
  3931. return new Promise(function (resolve, reject) {
  3932. if (_typeof(target) !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  3933. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  3934. }
  3935. function handler(type) {
  3936. if (target instanceof EventBus) {
  3937. target._off(name, eventHandler);
  3938. } else {
  3939. target.removeEventListener(name, eventHandler);
  3940. }
  3941. if (timeout) {
  3942. clearTimeout(timeout);
  3943. }
  3944. resolve(type);
  3945. }
  3946. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  3947. if (target instanceof EventBus) {
  3948. target._on(name, eventHandler);
  3949. } else {
  3950. target.addEventListener(name, eventHandler);
  3951. }
  3952. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  3953. var timeout = setTimeout(timeoutHandler, delay);
  3954. });
  3955. }
  3956. var animationStarted = new Promise(function (resolve) {
  3957. window.requestAnimationFrame(resolve);
  3958. });
  3959. exports.animationStarted = animationStarted;
  3960. function dispatchDOMEvent(eventName) {
  3961. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3962. throw new Error("Not implemented: dispatchDOMEvent");
  3963. }
  3964. var EventBus = /*#__PURE__*/function () {
  3965. function EventBus(options) {
  3966. _classCallCheck(this, EventBus);
  3967. this._listeners = Object.create(null);
  3968. }
  3969. _createClass(EventBus, [{
  3970. key: "on",
  3971. value: function on(eventName, listener) {
  3972. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3973. this._on(eventName, listener, {
  3974. external: true,
  3975. once: options === null || options === void 0 ? void 0 : options.once
  3976. });
  3977. }
  3978. }, {
  3979. key: "off",
  3980. value: function off(eventName, listener) {
  3981. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3982. this._off(eventName, listener, {
  3983. external: true,
  3984. once: options === null || options === void 0 ? void 0 : options.once
  3985. });
  3986. }
  3987. }, {
  3988. key: "dispatch",
  3989. value: function dispatch(eventName) {
  3990. var _this = this;
  3991. var eventListeners = this._listeners[eventName];
  3992. if (!eventListeners || eventListeners.length === 0) {
  3993. return;
  3994. }
  3995. var args = Array.prototype.slice.call(arguments, 1);
  3996. var externalListeners;
  3997. eventListeners.slice(0).forEach(function (_ref4) {
  3998. var listener = _ref4.listener,
  3999. external = _ref4.external,
  4000. once = _ref4.once;
  4001. if (once) {
  4002. _this._off(eventName, listener);
  4003. }
  4004. if (external) {
  4005. (externalListeners || (externalListeners = [])).push(listener);
  4006. return;
  4007. }
  4008. listener.apply(null, args);
  4009. });
  4010. if (externalListeners) {
  4011. externalListeners.forEach(function (listener) {
  4012. listener.apply(null, args);
  4013. });
  4014. externalListeners = null;
  4015. }
  4016. }
  4017. }, {
  4018. key: "_on",
  4019. value: function _on(eventName, listener) {
  4020. var _this$_listeners;
  4021. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4022. var eventListeners = (_this$_listeners = this._listeners)[eventName] || (_this$_listeners[eventName] = []);
  4023. eventListeners.push({
  4024. listener: listener,
  4025. external: (options === null || options === void 0 ? void 0 : options.external) === true,
  4026. once: (options === null || options === void 0 ? void 0 : options.once) === true
  4027. });
  4028. }
  4029. }, {
  4030. key: "_off",
  4031. value: function _off(eventName, listener) {
  4032. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4033. var eventListeners = this._listeners[eventName];
  4034. if (!eventListeners) {
  4035. return;
  4036. }
  4037. for (var i = 0, ii = eventListeners.length; i < ii; i++) {
  4038. if (eventListeners[i].listener === listener) {
  4039. eventListeners.splice(i, 1);
  4040. return;
  4041. }
  4042. }
  4043. }
  4044. }]);
  4045. return EventBus;
  4046. }();
  4047. exports.EventBus = EventBus;
  4048. function clamp(v, min, max) {
  4049. return Math.min(Math.max(v, min), max);
  4050. }
  4051. var ProgressBar = /*#__PURE__*/function () {
  4052. function ProgressBar(id) {
  4053. var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  4054. height = _ref5.height,
  4055. width = _ref5.width,
  4056. units = _ref5.units;
  4057. _classCallCheck(this, ProgressBar);
  4058. this.visible = true;
  4059. this.div = document.querySelector(id + " .progress");
  4060. this.bar = this.div.parentNode;
  4061. this.height = height || 100;
  4062. this.width = width || 100;
  4063. this.units = units || "%";
  4064. this.div.style.height = this.height + this.units;
  4065. this.percent = 0;
  4066. }
  4067. _createClass(ProgressBar, [{
  4068. key: "_updateBar",
  4069. value: function _updateBar() {
  4070. if (this._indeterminate) {
  4071. this.div.classList.add("indeterminate");
  4072. this.div.style.width = this.width + this.units;
  4073. return;
  4074. }
  4075. this.div.classList.remove("indeterminate");
  4076. var progressSize = this.width * this._percent / 100;
  4077. this.div.style.width = progressSize + this.units;
  4078. }
  4079. }, {
  4080. key: "percent",
  4081. get: function get() {
  4082. return this._percent;
  4083. },
  4084. set: function set(val) {
  4085. this._indeterminate = isNaN(val);
  4086. this._percent = clamp(val, 0, 100);
  4087. this._updateBar();
  4088. }
  4089. }, {
  4090. key: "setWidth",
  4091. value: function setWidth(viewer) {
  4092. if (!viewer) {
  4093. return;
  4094. }
  4095. var container = viewer.parentNode;
  4096. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  4097. if (scrollbarWidth > 0) {
  4098. var doc = document.documentElement;
  4099. doc.style.setProperty(LOADINGBAR_END_OFFSET_VAR, "".concat(scrollbarWidth, "px"));
  4100. }
  4101. }
  4102. }, {
  4103. key: "hide",
  4104. value: function hide() {
  4105. if (!this.visible) {
  4106. return;
  4107. }
  4108. this.visible = false;
  4109. this.bar.classList.add("hidden");
  4110. }
  4111. }, {
  4112. key: "show",
  4113. value: function show() {
  4114. if (this.visible) {
  4115. return;
  4116. }
  4117. this.visible = true;
  4118. this.bar.classList.remove("hidden");
  4119. }
  4120. }]);
  4121. return ProgressBar;
  4122. }();
  4123. exports.ProgressBar = ProgressBar;
  4124. function moveToEndOfArray(arr, condition) {
  4125. var moved = [],
  4126. len = arr.length;
  4127. var write = 0;
  4128. for (var read = 0; read < len; ++read) {
  4129. if (condition(arr[read])) {
  4130. moved.push(arr[read]);
  4131. } else {
  4132. arr[write] = arr[read];
  4133. ++write;
  4134. }
  4135. }
  4136. for (var _read = 0; write < len; ++_read, ++write) {
  4137. arr[write] = moved[_read];
  4138. }
  4139. }
  4140. function getActiveOrFocusedElement() {
  4141. var curRoot = document;
  4142. var curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  4143. while ((_curActiveOrFocused = curActiveOrFocused) !== null && _curActiveOrFocused !== void 0 && _curActiveOrFocused.shadowRoot) {
  4144. var _curActiveOrFocused;
  4145. curRoot = curActiveOrFocused.shadowRoot;
  4146. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  4147. }
  4148. return curActiveOrFocused;
  4149. }
  4150. function apiPageLayoutToSpreadMode(layout) {
  4151. switch (layout) {
  4152. case "SinglePage":
  4153. case "OneColumn":
  4154. return SpreadMode.NONE;
  4155. case "TwoColumnLeft":
  4156. case "TwoPageLeft":
  4157. return SpreadMode.ODD;
  4158. case "TwoColumnRight":
  4159. case "TwoPageRight":
  4160. return SpreadMode.EVEN;
  4161. }
  4162. return SpreadMode.NONE;
  4163. }
  4164. function apiPageModeToSidebarView(mode) {
  4165. switch (mode) {
  4166. case "UseNone":
  4167. return SidebarView.NONE;
  4168. case "UseThumbs":
  4169. return SidebarView.THUMBS;
  4170. case "UseOutlines":
  4171. return SidebarView.OUTLINE;
  4172. case "UseAttachments":
  4173. return SidebarView.ATTACHMENTS;
  4174. case "UseOC":
  4175. return SidebarView.LAYERS;
  4176. }
  4177. return SidebarView.NONE;
  4178. }
  4179. /***/ }),
  4180. /* 7 */
  4181. /***/ ((module) => {
  4182. var pdfjsLib;
  4183. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  4184. pdfjsLib = window["pdfjs-dist/build/pdf"];
  4185. } else {
  4186. pdfjsLib = require("../build/pdf.js");
  4187. }
  4188. module.exports = pdfjsLib;
  4189. /***/ }),
  4190. /* 8 */
  4191. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4192. Object.defineProperty(exports, "__esModule", ({
  4193. value: true
  4194. }));
  4195. exports.PDFCursorTools = exports.CursorTool = void 0;
  4196. var _grab_to_pan = __webpack_require__(9);
  4197. var _ui_utils = __webpack_require__(6);
  4198. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4199. 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); } }
  4200. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4201. var CursorTool = {
  4202. SELECT: 0,
  4203. HAND: 1,
  4204. ZOOM: 2
  4205. };
  4206. exports.CursorTool = CursorTool;
  4207. var PDFCursorTools = /*#__PURE__*/function () {
  4208. function PDFCursorTools(_ref) {
  4209. var _this = this;
  4210. var container = _ref.container,
  4211. eventBus = _ref.eventBus,
  4212. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  4213. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT : _ref$cursorToolOnLoad;
  4214. _classCallCheck(this, PDFCursorTools);
  4215. this.container = container;
  4216. this.eventBus = eventBus;
  4217. this.active = CursorTool.SELECT;
  4218. this.activeBeforePresentationMode = null;
  4219. this.handTool = new _grab_to_pan.GrabToPan({
  4220. element: this.container
  4221. });
  4222. this._addEventListeners();
  4223. Promise.resolve().then(function () {
  4224. _this.switchTool(cursorToolOnLoad);
  4225. });
  4226. }
  4227. _createClass(PDFCursorTools, [{
  4228. key: "activeTool",
  4229. get: function get() {
  4230. return this.active;
  4231. }
  4232. }, {
  4233. key: "switchTool",
  4234. value: function switchTool(tool) {
  4235. var _this2 = this;
  4236. if (this.activeBeforePresentationMode !== null) {
  4237. return;
  4238. }
  4239. if (tool === this.active) {
  4240. return;
  4241. }
  4242. var disableActiveTool = function disableActiveTool() {
  4243. switch (_this2.active) {
  4244. case CursorTool.SELECT:
  4245. break;
  4246. case CursorTool.HAND:
  4247. _this2.handTool.deactivate();
  4248. break;
  4249. case CursorTool.ZOOM:
  4250. }
  4251. };
  4252. switch (tool) {
  4253. case CursorTool.SELECT:
  4254. disableActiveTool();
  4255. break;
  4256. case CursorTool.HAND:
  4257. disableActiveTool();
  4258. this.handTool.activate();
  4259. break;
  4260. case CursorTool.ZOOM:
  4261. default:
  4262. console.error("switchTool: \"".concat(tool, "\" is an unsupported value."));
  4263. return;
  4264. }
  4265. this.active = tool;
  4266. this._dispatchEvent();
  4267. }
  4268. }, {
  4269. key: "_dispatchEvent",
  4270. value: function _dispatchEvent() {
  4271. this.eventBus.dispatch("cursortoolchanged", {
  4272. source: this,
  4273. tool: this.active
  4274. });
  4275. }
  4276. }, {
  4277. key: "_addEventListeners",
  4278. value: function _addEventListeners() {
  4279. var _this3 = this;
  4280. this.eventBus._on("switchcursortool", function (evt) {
  4281. _this3.switchTool(evt.tool);
  4282. });
  4283. this.eventBus._on("presentationmodechanged", function (evt) {
  4284. switch (evt.state) {
  4285. case _ui_utils.PresentationModeState.FULLSCREEN:
  4286. {
  4287. var previouslyActive = _this3.active;
  4288. _this3.switchTool(CursorTool.SELECT);
  4289. _this3.activeBeforePresentationMode = previouslyActive;
  4290. break;
  4291. }
  4292. case _ui_utils.PresentationModeState.NORMAL:
  4293. {
  4294. var _previouslyActive = _this3.activeBeforePresentationMode;
  4295. _this3.activeBeforePresentationMode = null;
  4296. _this3.switchTool(_previouslyActive);
  4297. break;
  4298. }
  4299. }
  4300. });
  4301. }
  4302. }]);
  4303. return PDFCursorTools;
  4304. }();
  4305. exports.PDFCursorTools = PDFCursorTools;
  4306. /***/ }),
  4307. /* 9 */
  4308. /***/ ((__unused_webpack_module, exports) => {
  4309. Object.defineProperty(exports, "__esModule", ({
  4310. value: true
  4311. }));
  4312. exports.GrabToPan = GrabToPan;
  4313. function GrabToPan(options) {
  4314. this.element = options.element;
  4315. this.document = options.element.ownerDocument;
  4316. if (typeof options.ignoreTarget === "function") {
  4317. this.ignoreTarget = options.ignoreTarget;
  4318. }
  4319. this.onActiveChanged = options.onActiveChanged;
  4320. this.activate = this.activate.bind(this);
  4321. this.deactivate = this.deactivate.bind(this);
  4322. this.toggle = this.toggle.bind(this);
  4323. this._onmousedown = this._onmousedown.bind(this);
  4324. this._onmousemove = this._onmousemove.bind(this);
  4325. this._endPan = this._endPan.bind(this);
  4326. var overlay = this.overlay = document.createElement("div");
  4327. overlay.className = "grab-to-pan-grabbing";
  4328. }
  4329. GrabToPan.prototype = {
  4330. CSS_CLASS_GRAB: "grab-to-pan-grab",
  4331. activate: function GrabToPan_activate() {
  4332. if (!this.active) {
  4333. this.active = true;
  4334. this.element.addEventListener("mousedown", this._onmousedown, true);
  4335. this.element.classList.add(this.CSS_CLASS_GRAB);
  4336. if (this.onActiveChanged) {
  4337. this.onActiveChanged(true);
  4338. }
  4339. }
  4340. },
  4341. deactivate: function GrabToPan_deactivate() {
  4342. if (this.active) {
  4343. this.active = false;
  4344. this.element.removeEventListener("mousedown", this._onmousedown, true);
  4345. this._endPan();
  4346. this.element.classList.remove(this.CSS_CLASS_GRAB);
  4347. if (this.onActiveChanged) {
  4348. this.onActiveChanged(false);
  4349. }
  4350. }
  4351. },
  4352. toggle: function GrabToPan_toggle() {
  4353. if (this.active) {
  4354. this.deactivate();
  4355. } else {
  4356. this.activate();
  4357. }
  4358. },
  4359. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  4360. return node.matches("a[href], a[href] *, input, textarea, button, button *, select, option");
  4361. },
  4362. _onmousedown: function GrabToPan__onmousedown(event) {
  4363. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  4364. return;
  4365. }
  4366. if (event.originalTarget) {
  4367. try {
  4368. event.originalTarget.tagName;
  4369. } catch (e) {
  4370. return;
  4371. }
  4372. }
  4373. this.scrollLeftStart = this.element.scrollLeft;
  4374. this.scrollTopStart = this.element.scrollTop;
  4375. this.clientXStart = event.clientX;
  4376. this.clientYStart = event.clientY;
  4377. this.document.addEventListener("mousemove", this._onmousemove, true);
  4378. this.document.addEventListener("mouseup", this._endPan, true);
  4379. this.element.addEventListener("scroll", this._endPan, true);
  4380. event.preventDefault();
  4381. event.stopPropagation();
  4382. var focusedElement = document.activeElement;
  4383. if (focusedElement && !focusedElement.contains(event.target)) {
  4384. focusedElement.blur();
  4385. }
  4386. },
  4387. _onmousemove: function GrabToPan__onmousemove(event) {
  4388. this.element.removeEventListener("scroll", this._endPan, true);
  4389. if (isLeftMouseReleased(event)) {
  4390. this._endPan();
  4391. return;
  4392. }
  4393. var xDiff = event.clientX - this.clientXStart;
  4394. var yDiff = event.clientY - this.clientYStart;
  4395. var scrollTop = this.scrollTopStart - yDiff;
  4396. var scrollLeft = this.scrollLeftStart - xDiff;
  4397. if (this.element.scrollTo) {
  4398. this.element.scrollTo({
  4399. top: scrollTop,
  4400. left: scrollLeft,
  4401. behavior: "instant"
  4402. });
  4403. } else {
  4404. this.element.scrollTop = scrollTop;
  4405. this.element.scrollLeft = scrollLeft;
  4406. }
  4407. if (!this.overlay.parentNode) {
  4408. document.body.appendChild(this.overlay);
  4409. }
  4410. },
  4411. _endPan: function GrabToPan__endPan() {
  4412. this.element.removeEventListener("scroll", this._endPan, true);
  4413. this.document.removeEventListener("mousemove", this._onmousemove, true);
  4414. this.document.removeEventListener("mouseup", this._endPan, true);
  4415. this.overlay.remove();
  4416. }
  4417. };
  4418. function isLeftMouseReleased(event) {
  4419. if ("buttons" in event) {
  4420. return !(event.buttons & 1);
  4421. }
  4422. var chrome = window.chrome;
  4423. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  4424. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  4425. if (isChrome15OrOpera15plus || isSafari6plus) {
  4426. return event.which === 0;
  4427. }
  4428. return false;
  4429. }
  4430. /***/ }),
  4431. /* 10 */
  4432. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4433. Object.defineProperty(exports, "__esModule", ({
  4434. value: true
  4435. }));
  4436. exports.RenderingStates = exports.PDFRenderingQueue = void 0;
  4437. var _pdfjsLib = __webpack_require__(7);
  4438. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4439. 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); } }
  4440. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4441. var CLEANUP_TIMEOUT = 30000;
  4442. var RenderingStates = {
  4443. INITIAL: 0,
  4444. RUNNING: 1,
  4445. PAUSED: 2,
  4446. FINISHED: 3
  4447. };
  4448. exports.RenderingStates = RenderingStates;
  4449. var PDFRenderingQueue = /*#__PURE__*/function () {
  4450. function PDFRenderingQueue() {
  4451. _classCallCheck(this, PDFRenderingQueue);
  4452. this.pdfViewer = null;
  4453. this.pdfThumbnailViewer = null;
  4454. this.onIdle = null;
  4455. this.highestPriorityPage = null;
  4456. this.idleTimeout = null;
  4457. this.printing = false;
  4458. this.isThumbnailViewEnabled = false;
  4459. }
  4460. _createClass(PDFRenderingQueue, [{
  4461. key: "setViewer",
  4462. value: function setViewer(pdfViewer) {
  4463. this.pdfViewer = pdfViewer;
  4464. }
  4465. }, {
  4466. key: "setThumbnailViewer",
  4467. value: function setThumbnailViewer(pdfThumbnailViewer) {
  4468. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4469. }
  4470. }, {
  4471. key: "isHighestPriority",
  4472. value: function isHighestPriority(view) {
  4473. return this.highestPriorityPage === view.renderingId;
  4474. }
  4475. }, {
  4476. key: "renderHighestPriority",
  4477. value: function renderHighestPriority(currentlyVisiblePages) {
  4478. if (this.idleTimeout) {
  4479. clearTimeout(this.idleTimeout);
  4480. this.idleTimeout = null;
  4481. }
  4482. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  4483. return;
  4484. }
  4485. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  4486. if (this.pdfThumbnailViewer.forceRendering()) {
  4487. return;
  4488. }
  4489. }
  4490. if (this.printing) {
  4491. return;
  4492. }
  4493. if (this.onIdle) {
  4494. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  4495. }
  4496. }
  4497. }, {
  4498. key: "getHighestPriority",
  4499. value: function getHighestPriority(visible, views, scrolledDown) {
  4500. var visibleViews = visible.views;
  4501. var numVisible = visibleViews.length;
  4502. if (numVisible === 0) {
  4503. return null;
  4504. }
  4505. for (var i = 0; i < numVisible; ++i) {
  4506. var view = visibleViews[i].view;
  4507. if (!this.isViewFinished(view)) {
  4508. return view;
  4509. }
  4510. }
  4511. if (scrolledDown) {
  4512. var nextPageIndex = visible.last.id;
  4513. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  4514. return views[nextPageIndex];
  4515. }
  4516. } else {
  4517. var previousPageIndex = visible.first.id - 2;
  4518. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  4519. return views[previousPageIndex];
  4520. }
  4521. }
  4522. return null;
  4523. }
  4524. }, {
  4525. key: "isViewFinished",
  4526. value: function isViewFinished(view) {
  4527. return view.renderingState === RenderingStates.FINISHED;
  4528. }
  4529. }, {
  4530. key: "renderView",
  4531. value: function renderView(view) {
  4532. var _this = this;
  4533. switch (view.renderingState) {
  4534. case RenderingStates.FINISHED:
  4535. return false;
  4536. case RenderingStates.PAUSED:
  4537. this.highestPriorityPage = view.renderingId;
  4538. view.resume();
  4539. break;
  4540. case RenderingStates.RUNNING:
  4541. this.highestPriorityPage = view.renderingId;
  4542. break;
  4543. case RenderingStates.INITIAL:
  4544. this.highestPriorityPage = view.renderingId;
  4545. view.draw()["finally"](function () {
  4546. _this.renderHighestPriority();
  4547. })["catch"](function (reason) {
  4548. if (reason instanceof _pdfjsLib.RenderingCancelledException) {
  4549. return;
  4550. }
  4551. console.error("renderView: \"".concat(reason, "\""));
  4552. });
  4553. break;
  4554. }
  4555. return true;
  4556. }
  4557. }]);
  4558. return PDFRenderingQueue;
  4559. }();
  4560. exports.PDFRenderingQueue = PDFRenderingQueue;
  4561. /***/ }),
  4562. /* 11 */
  4563. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4564. Object.defineProperty(exports, "__esModule", ({
  4565. value: true
  4566. }));
  4567. exports.OverlayManager = void 0;
  4568. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  4569. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4570. 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); } }
  4571. 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); }); }; }
  4572. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4573. 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); } }
  4574. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4575. var OverlayManager = /*#__PURE__*/function () {
  4576. function OverlayManager() {
  4577. _classCallCheck(this, OverlayManager);
  4578. this._overlays = {};
  4579. this._active = null;
  4580. this._keyDownBound = this._keyDown.bind(this);
  4581. }
  4582. _createClass(OverlayManager, [{
  4583. key: "active",
  4584. get: function get() {
  4585. return this._active;
  4586. }
  4587. }, {
  4588. key: "register",
  4589. value: function () {
  4590. var _register = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, element) {
  4591. var callerCloseMethod,
  4592. canForceClose,
  4593. container,
  4594. _args = arguments;
  4595. return _regenerator["default"].wrap(function _callee$(_context) {
  4596. while (1) {
  4597. switch (_context.prev = _context.next) {
  4598. case 0:
  4599. callerCloseMethod = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
  4600. canForceClose = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
  4601. if (!(!name || !element || !(container = element.parentNode))) {
  4602. _context.next = 6;
  4603. break;
  4604. }
  4605. throw new Error("Not enough parameters.");
  4606. case 6:
  4607. if (!this._overlays[name]) {
  4608. _context.next = 8;
  4609. break;
  4610. }
  4611. throw new Error("The overlay is already registered.");
  4612. case 8:
  4613. this._overlays[name] = {
  4614. element: element,
  4615. container: container,
  4616. callerCloseMethod: callerCloseMethod,
  4617. canForceClose: canForceClose
  4618. };
  4619. case 9:
  4620. case "end":
  4621. return _context.stop();
  4622. }
  4623. }
  4624. }, _callee, this);
  4625. }));
  4626. function register(_x, _x2) {
  4627. return _register.apply(this, arguments);
  4628. }
  4629. return register;
  4630. }()
  4631. }, {
  4632. key: "unregister",
  4633. value: function () {
  4634. var _unregister = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(name) {
  4635. return _regenerator["default"].wrap(function _callee2$(_context2) {
  4636. while (1) {
  4637. switch (_context2.prev = _context2.next) {
  4638. case 0:
  4639. if (this._overlays[name]) {
  4640. _context2.next = 4;
  4641. break;
  4642. }
  4643. throw new Error("The overlay does not exist.");
  4644. case 4:
  4645. if (!(this._active === name)) {
  4646. _context2.next = 6;
  4647. break;
  4648. }
  4649. throw new Error("The overlay cannot be removed while it is active.");
  4650. case 6:
  4651. delete this._overlays[name];
  4652. case 7:
  4653. case "end":
  4654. return _context2.stop();
  4655. }
  4656. }
  4657. }, _callee2, this);
  4658. }));
  4659. function unregister(_x3) {
  4660. return _unregister.apply(this, arguments);
  4661. }
  4662. return unregister;
  4663. }()
  4664. }, {
  4665. key: "open",
  4666. value: function () {
  4667. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name) {
  4668. return _regenerator["default"].wrap(function _callee3$(_context3) {
  4669. while (1) {
  4670. switch (_context3.prev = _context3.next) {
  4671. case 0:
  4672. if (this._overlays[name]) {
  4673. _context3.next = 4;
  4674. break;
  4675. }
  4676. throw new Error("The overlay does not exist.");
  4677. case 4:
  4678. if (!this._active) {
  4679. _context3.next = 14;
  4680. break;
  4681. }
  4682. if (!this._overlays[name].canForceClose) {
  4683. _context3.next = 9;
  4684. break;
  4685. }
  4686. this._closeThroughCaller();
  4687. _context3.next = 14;
  4688. break;
  4689. case 9:
  4690. if (!(this._active === name)) {
  4691. _context3.next = 13;
  4692. break;
  4693. }
  4694. throw new Error("The overlay is already active.");
  4695. case 13:
  4696. throw new Error("Another overlay is currently active.");
  4697. case 14:
  4698. this._active = name;
  4699. this._overlays[this._active].element.classList.remove("hidden");
  4700. this._overlays[this._active].container.classList.remove("hidden");
  4701. window.addEventListener("keydown", this._keyDownBound);
  4702. case 18:
  4703. case "end":
  4704. return _context3.stop();
  4705. }
  4706. }
  4707. }, _callee3, this);
  4708. }));
  4709. function open(_x4) {
  4710. return _open.apply(this, arguments);
  4711. }
  4712. return open;
  4713. }()
  4714. }, {
  4715. key: "close",
  4716. value: function () {
  4717. var _close = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name) {
  4718. return _regenerator["default"].wrap(function _callee4$(_context4) {
  4719. while (1) {
  4720. switch (_context4.prev = _context4.next) {
  4721. case 0:
  4722. if (this._overlays[name]) {
  4723. _context4.next = 4;
  4724. break;
  4725. }
  4726. throw new Error("The overlay does not exist.");
  4727. case 4:
  4728. if (this._active) {
  4729. _context4.next = 8;
  4730. break;
  4731. }
  4732. throw new Error("The overlay is currently not active.");
  4733. case 8:
  4734. if (!(this._active !== name)) {
  4735. _context4.next = 10;
  4736. break;
  4737. }
  4738. throw new Error("Another overlay is currently active.");
  4739. case 10:
  4740. this._overlays[this._active].container.classList.add("hidden");
  4741. this._overlays[this._active].element.classList.add("hidden");
  4742. this._active = null;
  4743. window.removeEventListener("keydown", this._keyDownBound);
  4744. case 14:
  4745. case "end":
  4746. return _context4.stop();
  4747. }
  4748. }
  4749. }, _callee4, this);
  4750. }));
  4751. function close(_x5) {
  4752. return _close.apply(this, arguments);
  4753. }
  4754. return close;
  4755. }()
  4756. }, {
  4757. key: "_keyDown",
  4758. value: function _keyDown(evt) {
  4759. if (this._active && evt.keyCode === 27) {
  4760. this._closeThroughCaller();
  4761. evt.preventDefault();
  4762. }
  4763. }
  4764. }, {
  4765. key: "_closeThroughCaller",
  4766. value: function _closeThroughCaller() {
  4767. if (this._overlays[this._active].callerCloseMethod) {
  4768. this._overlays[this._active].callerCloseMethod();
  4769. }
  4770. if (this._active) {
  4771. this.close(this._active);
  4772. }
  4773. }
  4774. }]);
  4775. return OverlayManager;
  4776. }();
  4777. exports.OverlayManager = OverlayManager;
  4778. /***/ }),
  4779. /* 12 */
  4780. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4781. Object.defineProperty(exports, "__esModule", ({
  4782. value: true
  4783. }));
  4784. exports.PasswordPrompt = void 0;
  4785. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  4786. var _pdfjsLib = __webpack_require__(7);
  4787. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4788. 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); } }
  4789. 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); }); }; }
  4790. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4791. 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); } }
  4792. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4793. var PasswordPrompt = /*#__PURE__*/function () {
  4794. function PasswordPrompt(options, overlayManager, l10n) {
  4795. var _this = this;
  4796. var isViewerEmbedded = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  4797. _classCallCheck(this, PasswordPrompt);
  4798. this.overlayName = options.overlayName;
  4799. this.container = options.container;
  4800. this.label = options.label;
  4801. this.input = options.input;
  4802. this.submitButton = options.submitButton;
  4803. this.cancelButton = options.cancelButton;
  4804. this.overlayManager = overlayManager;
  4805. this.l10n = l10n;
  4806. this._isViewerEmbedded = isViewerEmbedded;
  4807. this.updateCallback = null;
  4808. this.reason = null;
  4809. this.submitButton.addEventListener("click", this.verify.bind(this));
  4810. this.cancelButton.addEventListener("click", this.close.bind(this));
  4811. this.input.addEventListener("keydown", function (e) {
  4812. if (e.keyCode === 13) {
  4813. _this.verify();
  4814. }
  4815. });
  4816. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  4817. }
  4818. _createClass(PasswordPrompt, [{
  4819. key: "open",
  4820. value: function () {
  4821. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  4822. var passwordIncorrect;
  4823. return _regenerator["default"].wrap(function _callee$(_context) {
  4824. while (1) {
  4825. switch (_context.prev = _context.next) {
  4826. case 0:
  4827. _context.next = 2;
  4828. return this.overlayManager.open(this.overlayName);
  4829. case 2:
  4830. passwordIncorrect = this.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD;
  4831. if (!this._isViewerEmbedded || passwordIncorrect) {
  4832. this.input.focus();
  4833. }
  4834. _context.next = 6;
  4835. return this.l10n.get("password_".concat(passwordIncorrect ? "invalid" : "label"));
  4836. case 6:
  4837. this.label.textContent = _context.sent;
  4838. case 7:
  4839. case "end":
  4840. return _context.stop();
  4841. }
  4842. }
  4843. }, _callee, this);
  4844. }));
  4845. function open() {
  4846. return _open.apply(this, arguments);
  4847. }
  4848. return open;
  4849. }()
  4850. }, {
  4851. key: "close",
  4852. value: function close() {
  4853. var _this2 = this;
  4854. this.overlayManager.close(this.overlayName).then(function () {
  4855. _this2.input.value = "";
  4856. });
  4857. }
  4858. }, {
  4859. key: "verify",
  4860. value: function verify() {
  4861. var password = this.input.value;
  4862. if ((password === null || password === void 0 ? void 0 : password.length) > 0) {
  4863. this.close();
  4864. this.updateCallback(password);
  4865. }
  4866. }
  4867. }, {
  4868. key: "setUpdateCallback",
  4869. value: function setUpdateCallback(updateCallback, reason) {
  4870. this.updateCallback = updateCallback;
  4871. this.reason = reason;
  4872. }
  4873. }]);
  4874. return PasswordPrompt;
  4875. }();
  4876. exports.PasswordPrompt = PasswordPrompt;
  4877. /***/ }),
  4878. /* 13 */
  4879. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4880. 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); }
  4881. Object.defineProperty(exports, "__esModule", ({
  4882. value: true
  4883. }));
  4884. exports.PDFAttachmentViewer = void 0;
  4885. var _pdfjsLib = __webpack_require__(7);
  4886. var _base_tree_viewer = __webpack_require__(14);
  4887. 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; } } }; }
  4888. 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); }
  4889. 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; }
  4890. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4891. 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); } }
  4892. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4893. 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); }
  4894. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  4895. 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); }
  4896. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  4897. 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); }; }
  4898. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  4899. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  4900. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  4901. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  4902. var PDFAttachmentViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  4903. _inherits(PDFAttachmentViewer, _BaseTreeViewer);
  4904. var _super = _createSuper(PDFAttachmentViewer);
  4905. function PDFAttachmentViewer(options) {
  4906. var _this;
  4907. _classCallCheck(this, PDFAttachmentViewer);
  4908. _this = _super.call(this, options);
  4909. _this.downloadManager = options.downloadManager;
  4910. _this.eventBus._on("fileattachmentannotation", _this._appendAttachment.bind(_assertThisInitialized(_this)));
  4911. return _this;
  4912. }
  4913. _createClass(PDFAttachmentViewer, [{
  4914. key: "reset",
  4915. value: function reset() {
  4916. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4917. _get(_getPrototypeOf(PDFAttachmentViewer.prototype), "reset", this).call(this);
  4918. this._attachments = null;
  4919. if (!keepRenderedCapability) {
  4920. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  4921. }
  4922. if (this._pendingDispatchEvent) {
  4923. clearTimeout(this._pendingDispatchEvent);
  4924. }
  4925. this._pendingDispatchEvent = null;
  4926. }
  4927. }, {
  4928. key: "_dispatchEvent",
  4929. value: function _dispatchEvent(attachmentsCount) {
  4930. var _this2 = this;
  4931. this._renderedCapability.resolve();
  4932. if (this._pendingDispatchEvent) {
  4933. clearTimeout(this._pendingDispatchEvent);
  4934. this._pendingDispatchEvent = null;
  4935. }
  4936. if (attachmentsCount === 0) {
  4937. this._pendingDispatchEvent = setTimeout(function () {
  4938. _this2.eventBus.dispatch("attachmentsloaded", {
  4939. source: _this2,
  4940. attachmentsCount: 0
  4941. });
  4942. _this2._pendingDispatchEvent = null;
  4943. });
  4944. return;
  4945. }
  4946. this.eventBus.dispatch("attachmentsloaded", {
  4947. source: this,
  4948. attachmentsCount: attachmentsCount
  4949. });
  4950. }
  4951. }, {
  4952. key: "_bindLink",
  4953. value: function _bindLink(element, _ref) {
  4954. var _this3 = this;
  4955. var content = _ref.content,
  4956. filename = _ref.filename;
  4957. element.onclick = function () {
  4958. _this3.downloadManager.openOrDownloadData(element, content, filename);
  4959. return false;
  4960. };
  4961. }
  4962. }, {
  4963. key: "render",
  4964. value: function render(_ref2) {
  4965. var attachments = _ref2.attachments,
  4966. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  4967. keepRenderedCapability = _ref2$keepRenderedCap === void 0 ? false : _ref2$keepRenderedCap;
  4968. if (this._attachments) {
  4969. this.reset(keepRenderedCapability);
  4970. }
  4971. this._attachments = attachments || null;
  4972. if (!attachments) {
  4973. this._dispatchEvent(0);
  4974. return;
  4975. }
  4976. var names = Object.keys(attachments).sort(function (a, b) {
  4977. return a.toLowerCase().localeCompare(b.toLowerCase());
  4978. });
  4979. var fragment = document.createDocumentFragment();
  4980. var attachmentsCount = 0;
  4981. var _iterator = _createForOfIteratorHelper(names),
  4982. _step;
  4983. try {
  4984. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  4985. var name = _step.value;
  4986. var item = attachments[name];
  4987. var content = item.content,
  4988. filename = (0, _pdfjsLib.getFilenameFromUrl)(item.filename);
  4989. var div = document.createElement("div");
  4990. div.className = "treeItem";
  4991. var element = document.createElement("a");
  4992. this._bindLink(element, {
  4993. content: content,
  4994. filename: filename
  4995. });
  4996. element.textContent = this._normalizeTextContent(filename);
  4997. div.appendChild(element);
  4998. fragment.appendChild(div);
  4999. attachmentsCount++;
  5000. }
  5001. } catch (err) {
  5002. _iterator.e(err);
  5003. } finally {
  5004. _iterator.f();
  5005. }
  5006. this._finishRendering(fragment, attachmentsCount);
  5007. }
  5008. }, {
  5009. key: "_appendAttachment",
  5010. value: function _appendAttachment(_ref3) {
  5011. var _this4 = this;
  5012. var id = _ref3.id,
  5013. filename = _ref3.filename,
  5014. content = _ref3.content;
  5015. var renderedPromise = this._renderedCapability.promise;
  5016. renderedPromise.then(function () {
  5017. if (renderedPromise !== _this4._renderedCapability.promise) {
  5018. return;
  5019. }
  5020. var attachments = _this4._attachments;
  5021. if (!attachments) {
  5022. attachments = Object.create(null);
  5023. } else {
  5024. for (var name in attachments) {
  5025. if (id === name) {
  5026. return;
  5027. }
  5028. }
  5029. }
  5030. attachments[id] = {
  5031. filename: filename,
  5032. content: content
  5033. };
  5034. _this4.render({
  5035. attachments: attachments,
  5036. keepRenderedCapability: true
  5037. });
  5038. });
  5039. }
  5040. }]);
  5041. return PDFAttachmentViewer;
  5042. }(_base_tree_viewer.BaseTreeViewer);
  5043. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  5044. /***/ }),
  5045. /* 14 */
  5046. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5047. Object.defineProperty(exports, "__esModule", ({
  5048. value: true
  5049. }));
  5050. exports.BaseTreeViewer = void 0;
  5051. var _pdfjsLib = __webpack_require__(7);
  5052. 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; } } }; }
  5053. 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); }
  5054. 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; }
  5055. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5056. 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); } }
  5057. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5058. var TREEITEM_OFFSET_TOP = -100;
  5059. var TREEITEM_SELECTED_CLASS = "selected";
  5060. var BaseTreeViewer = /*#__PURE__*/function () {
  5061. function BaseTreeViewer(options) {
  5062. _classCallCheck(this, BaseTreeViewer);
  5063. if (this.constructor === BaseTreeViewer) {
  5064. throw new Error("Cannot initialize BaseTreeViewer.");
  5065. }
  5066. this.container = options.container;
  5067. this.eventBus = options.eventBus;
  5068. this.reset();
  5069. }
  5070. _createClass(BaseTreeViewer, [{
  5071. key: "reset",
  5072. value: function reset() {
  5073. this._pdfDocument = null;
  5074. this._lastToggleIsShow = true;
  5075. this._currentTreeItem = null;
  5076. this.container.textContent = "";
  5077. this.container.classList.remove("treeWithDeepNesting");
  5078. }
  5079. }, {
  5080. key: "_dispatchEvent",
  5081. value: function _dispatchEvent(count) {
  5082. throw new Error("Not implemented: _dispatchEvent");
  5083. }
  5084. }, {
  5085. key: "_bindLink",
  5086. value: function _bindLink(element, params) {
  5087. throw new Error("Not implemented: _bindLink");
  5088. }
  5089. }, {
  5090. key: "_normalizeTextContent",
  5091. value: function _normalizeTextContent(str) {
  5092. return (0, _pdfjsLib.removeNullCharacters)(str) || "\u2013";
  5093. }
  5094. }, {
  5095. key: "_addToggleButton",
  5096. value: function _addToggleButton(div) {
  5097. var _this = this;
  5098. var hidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5099. var toggler = document.createElement("div");
  5100. toggler.className = "treeItemToggler";
  5101. if (hidden) {
  5102. toggler.classList.add("treeItemsHidden");
  5103. }
  5104. toggler.onclick = function (evt) {
  5105. evt.stopPropagation();
  5106. toggler.classList.toggle("treeItemsHidden");
  5107. if (evt.shiftKey) {
  5108. var shouldShowAll = !toggler.classList.contains("treeItemsHidden");
  5109. _this._toggleTreeItem(div, shouldShowAll);
  5110. }
  5111. };
  5112. div.insertBefore(toggler, div.firstChild);
  5113. }
  5114. }, {
  5115. key: "_toggleTreeItem",
  5116. value: function _toggleTreeItem(root) {
  5117. var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5118. this._lastToggleIsShow = show;
  5119. var _iterator = _createForOfIteratorHelper(root.querySelectorAll(".treeItemToggler")),
  5120. _step;
  5121. try {
  5122. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5123. var toggler = _step.value;
  5124. toggler.classList.toggle("treeItemsHidden", !show);
  5125. }
  5126. } catch (err) {
  5127. _iterator.e(err);
  5128. } finally {
  5129. _iterator.f();
  5130. }
  5131. }
  5132. }, {
  5133. key: "_toggleAllTreeItems",
  5134. value: function _toggleAllTreeItems() {
  5135. this._toggleTreeItem(this.container, !this._lastToggleIsShow);
  5136. }
  5137. }, {
  5138. key: "_finishRendering",
  5139. value: function _finishRendering(fragment, count) {
  5140. var hasAnyNesting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5141. if (hasAnyNesting) {
  5142. this.container.classList.add("treeWithDeepNesting");
  5143. this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
  5144. }
  5145. this.container.appendChild(fragment);
  5146. this._dispatchEvent(count);
  5147. }
  5148. }, {
  5149. key: "render",
  5150. value: function render(params) {
  5151. throw new Error("Not implemented: render");
  5152. }
  5153. }, {
  5154. key: "_updateCurrentTreeItem",
  5155. value: function _updateCurrentTreeItem() {
  5156. var treeItem = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  5157. if (this._currentTreeItem) {
  5158. this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS);
  5159. this._currentTreeItem = null;
  5160. }
  5161. if (treeItem) {
  5162. treeItem.classList.add(TREEITEM_SELECTED_CLASS);
  5163. this._currentTreeItem = treeItem;
  5164. }
  5165. }
  5166. }, {
  5167. key: "_scrollToCurrentTreeItem",
  5168. value: function _scrollToCurrentTreeItem(treeItem) {
  5169. if (!treeItem) {
  5170. return;
  5171. }
  5172. var currentNode = treeItem.parentNode;
  5173. while (currentNode && currentNode !== this.container) {
  5174. if (currentNode.classList.contains("treeItem")) {
  5175. var toggler = currentNode.firstElementChild;
  5176. toggler === null || toggler === void 0 ? void 0 : toggler.classList.remove("treeItemsHidden");
  5177. }
  5178. currentNode = currentNode.parentNode;
  5179. }
  5180. this._updateCurrentTreeItem(treeItem);
  5181. this.container.scrollTo(treeItem.offsetLeft, treeItem.offsetTop + TREEITEM_OFFSET_TOP);
  5182. }
  5183. }]);
  5184. return BaseTreeViewer;
  5185. }();
  5186. exports.BaseTreeViewer = BaseTreeViewer;
  5187. /***/ }),
  5188. /* 15 */
  5189. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5190. Object.defineProperty(exports, "__esModule", ({
  5191. value: true
  5192. }));
  5193. exports.PDFDocumentProperties = void 0;
  5194. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  5195. var _pdfjsLib = __webpack_require__(7);
  5196. var _ui_utils = __webpack_require__(6);
  5197. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5198. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  5199. 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."); }
  5200. 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); }
  5201. 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; }
  5202. 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; }
  5203. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  5204. 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); } }
  5205. 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); }); }; }
  5206. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5207. 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); } }
  5208. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5209. var DEFAULT_FIELD_CONTENT = "-";
  5210. var NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  5211. var US_PAGE_NAMES = {
  5212. "8.5x11": "Letter",
  5213. "8.5x14": "Legal"
  5214. };
  5215. var METRIC_PAGE_NAMES = {
  5216. "297x420": "A3",
  5217. "210x297": "A4"
  5218. };
  5219. function getPageName(size, isPortrait, pageNames) {
  5220. var width = isPortrait ? size.width : size.height;
  5221. var height = isPortrait ? size.height : size.width;
  5222. return pageNames["".concat(width, "x").concat(height)];
  5223. }
  5224. var PDFDocumentProperties = /*#__PURE__*/function () {
  5225. function PDFDocumentProperties(_ref, overlayManager, eventBus, l10n) {
  5226. var _this = this;
  5227. var overlayName = _ref.overlayName,
  5228. fields = _ref.fields,
  5229. container = _ref.container,
  5230. closeButton = _ref.closeButton;
  5231. _classCallCheck(this, PDFDocumentProperties);
  5232. this.overlayName = overlayName;
  5233. this.fields = fields;
  5234. this.container = container;
  5235. this.overlayManager = overlayManager;
  5236. this.l10n = l10n;
  5237. this._reset();
  5238. closeButton.addEventListener("click", this.close.bind(this));
  5239. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  5240. eventBus._on("pagechanging", function (evt) {
  5241. _this._currentPageNumber = evt.pageNumber;
  5242. });
  5243. eventBus._on("rotationchanging", function (evt) {
  5244. _this._pagesRotation = evt.pagesRotation;
  5245. });
  5246. this._isNonMetricLocale = true;
  5247. l10n.getLanguage().then(function (locale) {
  5248. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  5249. });
  5250. }
  5251. _createClass(PDFDocumentProperties, [{
  5252. key: "open",
  5253. value: function () {
  5254. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  5255. var _this2 = this;
  5256. 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;
  5257. return _regenerator["default"].wrap(function _callee$(_context) {
  5258. while (1) {
  5259. switch (_context.prev = _context.next) {
  5260. case 0:
  5261. freezeFieldData = function freezeFieldData(data) {
  5262. Object.defineProperty(_this2, "fieldData", {
  5263. value: Object.freeze(data),
  5264. writable: false,
  5265. enumerable: true,
  5266. configurable: true
  5267. });
  5268. };
  5269. _context.next = 3;
  5270. return Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]);
  5271. case 3:
  5272. currentPageNumber = this._currentPageNumber;
  5273. pagesRotation = this._pagesRotation;
  5274. if (!(this.fieldData && currentPageNumber === this.fieldData._currentPageNumber && pagesRotation === this.fieldData._pagesRotation)) {
  5275. _context.next = 8;
  5276. break;
  5277. }
  5278. this._updateUI();
  5279. return _context.abrupt("return");
  5280. case 8:
  5281. _context.next = 10;
  5282. return this.pdfDocument.getMetadata();
  5283. case 10:
  5284. _yield$this$pdfDocume = _context.sent;
  5285. info = _yield$this$pdfDocume.info;
  5286. contentDispositionFilename = _yield$this$pdfDocume.contentDispositionFilename;
  5287. contentLength = _yield$this$pdfDocume.contentLength;
  5288. _context.next = 16;
  5289. return Promise.all([contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(this.url), this._parseFileSize(contentLength), this._parseDate(info.CreationDate), this._parseDate(info.ModDate), this.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
  5290. return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  5291. }), this._parseLinearization(info.IsLinearized)]);
  5292. case 16:
  5293. _yield$Promise$all = _context.sent;
  5294. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 6);
  5295. fileName = _yield$Promise$all2[0];
  5296. fileSize = _yield$Promise$all2[1];
  5297. creationDate = _yield$Promise$all2[2];
  5298. modificationDate = _yield$Promise$all2[3];
  5299. pageSize = _yield$Promise$all2[4];
  5300. isLinearized = _yield$Promise$all2[5];
  5301. freezeFieldData({
  5302. fileName: fileName,
  5303. fileSize: fileSize,
  5304. title: info.Title,
  5305. author: info.Author,
  5306. subject: info.Subject,
  5307. keywords: info.Keywords,
  5308. creationDate: creationDate,
  5309. modificationDate: modificationDate,
  5310. creator: info.Creator,
  5311. producer: info.Producer,
  5312. version: info.PDFFormatVersion,
  5313. pageCount: this.pdfDocument.numPages,
  5314. pageSize: pageSize,
  5315. linearized: isLinearized,
  5316. _currentPageNumber: currentPageNumber,
  5317. _pagesRotation: pagesRotation
  5318. });
  5319. this._updateUI();
  5320. _context.next = 28;
  5321. return this.pdfDocument.getDownloadInfo();
  5322. case 28:
  5323. _yield$this$pdfDocume2 = _context.sent;
  5324. length = _yield$this$pdfDocume2.length;
  5325. if (!(contentLength === length)) {
  5326. _context.next = 32;
  5327. break;
  5328. }
  5329. return _context.abrupt("return");
  5330. case 32:
  5331. data = Object.assign(Object.create(null), this.fieldData);
  5332. _context.next = 35;
  5333. return this._parseFileSize(length);
  5334. case 35:
  5335. data.fileSize = _context.sent;
  5336. freezeFieldData(data);
  5337. this._updateUI();
  5338. case 38:
  5339. case "end":
  5340. return _context.stop();
  5341. }
  5342. }
  5343. }, _callee, this);
  5344. }));
  5345. function open() {
  5346. return _open.apply(this, arguments);
  5347. }
  5348. return open;
  5349. }()
  5350. }, {
  5351. key: "close",
  5352. value: function close() {
  5353. this.overlayManager.close(this.overlayName);
  5354. }
  5355. }, {
  5356. key: "setDocument",
  5357. value: function setDocument(pdfDocument) {
  5358. var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5359. if (this.pdfDocument) {
  5360. this._reset();
  5361. this._updateUI(true);
  5362. }
  5363. if (!pdfDocument) {
  5364. return;
  5365. }
  5366. this.pdfDocument = pdfDocument;
  5367. this.url = url;
  5368. this._dataAvailableCapability.resolve();
  5369. }
  5370. }, {
  5371. key: "_reset",
  5372. value: function _reset() {
  5373. this.pdfDocument = null;
  5374. this.url = null;
  5375. delete this.fieldData;
  5376. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5377. this._currentPageNumber = 1;
  5378. this._pagesRotation = 0;
  5379. }
  5380. }, {
  5381. key: "_updateUI",
  5382. value: function _updateUI() {
  5383. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5384. if (reset || !this.fieldData) {
  5385. for (var id in this.fields) {
  5386. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5387. }
  5388. return;
  5389. }
  5390. if (this.overlayManager.active !== this.overlayName) {
  5391. return;
  5392. }
  5393. for (var _id in this.fields) {
  5394. var content = this.fieldData[_id];
  5395. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5396. }
  5397. }
  5398. }, {
  5399. key: "_parseFileSize",
  5400. value: function () {
  5401. var _parseFileSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  5402. var fileSize,
  5403. kb,
  5404. mb,
  5405. _args2 = arguments;
  5406. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5407. while (1) {
  5408. switch (_context2.prev = _context2.next) {
  5409. case 0:
  5410. fileSize = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : 0;
  5411. kb = fileSize / 1024, mb = kb / 1024;
  5412. if (kb) {
  5413. _context2.next = 4;
  5414. break;
  5415. }
  5416. return _context2.abrupt("return", undefined);
  5417. case 4:
  5418. return _context2.abrupt("return", this.l10n.get("document_properties_".concat(mb >= 1 ? "mb" : "kb"), {
  5419. size_mb: mb >= 1 && (+mb.toPrecision(3)).toLocaleString(),
  5420. size_kb: mb < 1 && (+kb.toPrecision(3)).toLocaleString(),
  5421. size_b: fileSize.toLocaleString()
  5422. }));
  5423. case 5:
  5424. case "end":
  5425. return _context2.stop();
  5426. }
  5427. }
  5428. }, _callee2, this);
  5429. }));
  5430. function _parseFileSize() {
  5431. return _parseFileSize2.apply(this, arguments);
  5432. }
  5433. return _parseFileSize;
  5434. }()
  5435. }, {
  5436. key: "_parsePageSize",
  5437. value: function () {
  5438. var _parsePageSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(pageSizeInches, pagesRotation) {
  5439. var isPortrait, sizeInches, sizeMillimeters, rawName, exactMillimeters, intMillimeters, _yield$Promise$all3, _yield$Promise$all4, _yield$Promise$all4$, width, height, unit, name, orientation;
  5440. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5441. while (1) {
  5442. switch (_context3.prev = _context3.next) {
  5443. case 0:
  5444. if (pageSizeInches) {
  5445. _context3.next = 2;
  5446. break;
  5447. }
  5448. return _context3.abrupt("return", undefined);
  5449. case 2:
  5450. if (pagesRotation % 180 !== 0) {
  5451. pageSizeInches = {
  5452. width: pageSizeInches.height,
  5453. height: pageSizeInches.width
  5454. };
  5455. }
  5456. isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  5457. sizeInches = {
  5458. width: Math.round(pageSizeInches.width * 100) / 100,
  5459. height: Math.round(pageSizeInches.height * 100) / 100
  5460. };
  5461. sizeMillimeters = {
  5462. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  5463. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  5464. };
  5465. rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5466. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  5467. exactMillimeters = {
  5468. width: pageSizeInches.width * 25.4,
  5469. height: pageSizeInches.height * 25.4
  5470. };
  5471. intMillimeters = {
  5472. width: Math.round(sizeMillimeters.width),
  5473. height: Math.round(sizeMillimeters.height)
  5474. };
  5475. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  5476. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5477. if (rawName) {
  5478. sizeInches = {
  5479. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  5480. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  5481. };
  5482. sizeMillimeters = intMillimeters;
  5483. }
  5484. }
  5485. }
  5486. _context3.next = 10;
  5487. return Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get("document_properties_page_size_unit_".concat(this._isNonMetricLocale ? "inches" : "millimeters")), rawName && this.l10n.get("document_properties_page_size_name_".concat(rawName.toLowerCase())), this.l10n.get("document_properties_page_size_orientation_".concat(isPortrait ? "portrait" : "landscape"))]);
  5488. case 10:
  5489. _yield$Promise$all3 = _context3.sent;
  5490. _yield$Promise$all4 = _slicedToArray(_yield$Promise$all3, 4);
  5491. _yield$Promise$all4$ = _yield$Promise$all4[0];
  5492. width = _yield$Promise$all4$.width;
  5493. height = _yield$Promise$all4$.height;
  5494. unit = _yield$Promise$all4[1];
  5495. name = _yield$Promise$all4[2];
  5496. orientation = _yield$Promise$all4[3];
  5497. return _context3.abrupt("return", this.l10n.get("document_properties_page_size_dimension_".concat(name ? "name_" : "", "string"), {
  5498. width: width.toLocaleString(),
  5499. height: height.toLocaleString(),
  5500. unit: unit,
  5501. name: name,
  5502. orientation: orientation
  5503. }));
  5504. case 19:
  5505. case "end":
  5506. return _context3.stop();
  5507. }
  5508. }
  5509. }, _callee3, this);
  5510. }));
  5511. function _parsePageSize(_x, _x2) {
  5512. return _parsePageSize2.apply(this, arguments);
  5513. }
  5514. return _parsePageSize;
  5515. }()
  5516. }, {
  5517. key: "_parseDate",
  5518. value: function () {
  5519. var _parseDate2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(inputDate) {
  5520. var dateObject;
  5521. return _regenerator["default"].wrap(function _callee4$(_context4) {
  5522. while (1) {
  5523. switch (_context4.prev = _context4.next) {
  5524. case 0:
  5525. dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  5526. if (dateObject) {
  5527. _context4.next = 3;
  5528. break;
  5529. }
  5530. return _context4.abrupt("return", undefined);
  5531. case 3:
  5532. return _context4.abrupt("return", this.l10n.get("document_properties_date_string", {
  5533. date: dateObject.toLocaleDateString(),
  5534. time: dateObject.toLocaleTimeString()
  5535. }));
  5536. case 4:
  5537. case "end":
  5538. return _context4.stop();
  5539. }
  5540. }
  5541. }, _callee4, this);
  5542. }));
  5543. function _parseDate(_x3) {
  5544. return _parseDate2.apply(this, arguments);
  5545. }
  5546. return _parseDate;
  5547. }()
  5548. }, {
  5549. key: "_parseLinearization",
  5550. value: function _parseLinearization(isLinearized) {
  5551. return this.l10n.get("document_properties_linearized_".concat(isLinearized ? "yes" : "no"));
  5552. }
  5553. }]);
  5554. return PDFDocumentProperties;
  5555. }();
  5556. exports.PDFDocumentProperties = PDFDocumentProperties;
  5557. /***/ }),
  5558. /* 16 */
  5559. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5560. Object.defineProperty(exports, "__esModule", ({
  5561. value: true
  5562. }));
  5563. exports.PDFFindBar = void 0;
  5564. var _pdf_find_controller = __webpack_require__(17);
  5565. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5566. 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); } }
  5567. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5568. var MATCHES_COUNT_LIMIT = 1000;
  5569. var PDFFindBar = /*#__PURE__*/function () {
  5570. function PDFFindBar(options, eventBus, l10n) {
  5571. var _this = this;
  5572. _classCallCheck(this, PDFFindBar);
  5573. this.opened = false;
  5574. this.bar = options.bar;
  5575. this.toggleButton = options.toggleButton;
  5576. this.findField = options.findField;
  5577. this.highlightAll = options.highlightAllCheckbox;
  5578. this.caseSensitive = options.caseSensitiveCheckbox;
  5579. this.entireWord = options.entireWordCheckbox;
  5580. this.findMsg = options.findMsg;
  5581. this.findResultsCount = options.findResultsCount;
  5582. this.findPreviousButton = options.findPreviousButton;
  5583. this.findNextButton = options.findNextButton;
  5584. this.eventBus = eventBus;
  5585. this.l10n = l10n;
  5586. this.toggleButton.addEventListener("click", function () {
  5587. _this.toggle();
  5588. });
  5589. this.findField.addEventListener("input", function () {
  5590. _this.dispatchEvent("");
  5591. });
  5592. this.bar.addEventListener("keydown", function (e) {
  5593. switch (e.keyCode) {
  5594. case 13:
  5595. if (e.target === _this.findField) {
  5596. _this.dispatchEvent("again", e.shiftKey);
  5597. }
  5598. break;
  5599. case 27:
  5600. _this.close();
  5601. break;
  5602. }
  5603. });
  5604. this.findPreviousButton.addEventListener("click", function () {
  5605. _this.dispatchEvent("again", true);
  5606. });
  5607. this.findNextButton.addEventListener("click", function () {
  5608. _this.dispatchEvent("again", false);
  5609. });
  5610. this.highlightAll.addEventListener("click", function () {
  5611. _this.dispatchEvent("highlightallchange");
  5612. });
  5613. this.caseSensitive.addEventListener("click", function () {
  5614. _this.dispatchEvent("casesensitivitychange");
  5615. });
  5616. this.entireWord.addEventListener("click", function () {
  5617. _this.dispatchEvent("entirewordchange");
  5618. });
  5619. this.eventBus._on("resize", this._adjustWidth.bind(this));
  5620. }
  5621. _createClass(PDFFindBar, [{
  5622. key: "reset",
  5623. value: function reset() {
  5624. this.updateUIState();
  5625. }
  5626. }, {
  5627. key: "dispatchEvent",
  5628. value: function dispatchEvent(type, findPrev) {
  5629. this.eventBus.dispatch("find", {
  5630. source: this,
  5631. type: type,
  5632. query: this.findField.value,
  5633. phraseSearch: true,
  5634. caseSensitive: this.caseSensitive.checked,
  5635. entireWord: this.entireWord.checked,
  5636. highlightAll: this.highlightAll.checked,
  5637. findPrevious: findPrev
  5638. });
  5639. }
  5640. }, {
  5641. key: "updateUIState",
  5642. value: function updateUIState(state, previous, matchesCount) {
  5643. var _this2 = this;
  5644. var findMsg = Promise.resolve("");
  5645. var status = "";
  5646. switch (state) {
  5647. case _pdf_find_controller.FindState.FOUND:
  5648. break;
  5649. case _pdf_find_controller.FindState.PENDING:
  5650. status = "pending";
  5651. break;
  5652. case _pdf_find_controller.FindState.NOT_FOUND:
  5653. findMsg = this.l10n.get("find_not_found");
  5654. status = "notFound";
  5655. break;
  5656. case _pdf_find_controller.FindState.WRAPPED:
  5657. findMsg = this.l10n.get("find_reached_".concat(previous ? "top" : "bottom"));
  5658. break;
  5659. }
  5660. this.findField.setAttribute("data-status", status);
  5661. findMsg.then(function (msg) {
  5662. _this2.findMsg.textContent = msg;
  5663. _this2._adjustWidth();
  5664. });
  5665. this.updateResultsCount(matchesCount);
  5666. }
  5667. }, {
  5668. key: "updateResultsCount",
  5669. value: function updateResultsCount() {
  5670. var _this3 = this;
  5671. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  5672. _ref$current = _ref.current,
  5673. current = _ref$current === void 0 ? 0 : _ref$current,
  5674. _ref$total = _ref.total,
  5675. total = _ref$total === void 0 ? 0 : _ref$total;
  5676. var limit = MATCHES_COUNT_LIMIT;
  5677. var matchCountMsg = Promise.resolve("");
  5678. if (total > 0) {
  5679. if (total > limit) {
  5680. var key = "find_match_count_limit";
  5681. matchCountMsg = this.l10n.get(key, {
  5682. limit: limit
  5683. });
  5684. } else {
  5685. var _key = "find_match_count";
  5686. matchCountMsg = this.l10n.get(_key, {
  5687. current: current,
  5688. total: total
  5689. });
  5690. }
  5691. }
  5692. matchCountMsg.then(function (msg) {
  5693. _this3.findResultsCount.textContent = msg;
  5694. _this3.findResultsCount.classList.toggle("hidden", !total);
  5695. _this3._adjustWidth();
  5696. });
  5697. }
  5698. }, {
  5699. key: "open",
  5700. value: function open() {
  5701. if (!this.opened) {
  5702. this.opened = true;
  5703. this.toggleButton.classList.add("toggled");
  5704. this.toggleButton.setAttribute("aria-expanded", "true");
  5705. this.bar.classList.remove("hidden");
  5706. }
  5707. this.findField.select();
  5708. this.findField.focus();
  5709. this._adjustWidth();
  5710. }
  5711. }, {
  5712. key: "close",
  5713. value: function close() {
  5714. if (!this.opened) {
  5715. return;
  5716. }
  5717. this.opened = false;
  5718. this.toggleButton.classList.remove("toggled");
  5719. this.toggleButton.setAttribute("aria-expanded", "false");
  5720. this.bar.classList.add("hidden");
  5721. this.eventBus.dispatch("findbarclose", {
  5722. source: this
  5723. });
  5724. }
  5725. }, {
  5726. key: "toggle",
  5727. value: function toggle() {
  5728. if (this.opened) {
  5729. this.close();
  5730. } else {
  5731. this.open();
  5732. }
  5733. }
  5734. }, {
  5735. key: "_adjustWidth",
  5736. value: function _adjustWidth() {
  5737. if (!this.opened) {
  5738. return;
  5739. }
  5740. this.bar.classList.remove("wrapContainers");
  5741. var findbarHeight = this.bar.clientHeight;
  5742. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  5743. if (findbarHeight > inputContainerHeight) {
  5744. this.bar.classList.add("wrapContainers");
  5745. }
  5746. }
  5747. }]);
  5748. return PDFFindBar;
  5749. }();
  5750. exports.PDFFindBar = PDFFindBar;
  5751. /***/ }),
  5752. /* 17 */
  5753. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5754. Object.defineProperty(exports, "__esModule", ({
  5755. value: true
  5756. }));
  5757. exports.PDFFindController = exports.FindState = void 0;
  5758. var _pdfjsLib = __webpack_require__(7);
  5759. var _pdf_find_utils = __webpack_require__(18);
  5760. var _ui_utils = __webpack_require__(6);
  5761. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5762. 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); } }
  5763. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5764. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  5765. 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."); }
  5766. 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; }
  5767. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  5768. 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; } } }; }
  5769. 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); }
  5770. 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; }
  5771. var FindState = {
  5772. FOUND: 0,
  5773. NOT_FOUND: 1,
  5774. WRAPPED: 2,
  5775. PENDING: 3
  5776. };
  5777. exports.FindState = FindState;
  5778. var FIND_TIMEOUT = 250;
  5779. var MATCH_SCROLL_OFFSET_TOP = -50;
  5780. var MATCH_SCROLL_OFFSET_LEFT = -400;
  5781. var CHARACTERS_TO_NORMALIZE = {
  5782. "\u2018": "'",
  5783. "\u2019": "'",
  5784. "\u201A": "'",
  5785. "\u201B": "'",
  5786. "\u201C": '"',
  5787. "\u201D": '"',
  5788. "\u201E": '"',
  5789. "\u201F": '"',
  5790. "\xBC": "1/4",
  5791. "\xBD": "1/2",
  5792. "\xBE": "3/4"
  5793. };
  5794. var normalizationRegex = null;
  5795. function normalize(text) {
  5796. if (!normalizationRegex) {
  5797. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  5798. normalizationRegex = new RegExp("[".concat(replace, "]"), "g");
  5799. }
  5800. var diffs = null;
  5801. var normalizedText = text.replace(normalizationRegex, function (ch, index) {
  5802. var normalizedCh = CHARACTERS_TO_NORMALIZE[ch],
  5803. diff = normalizedCh.length - ch.length;
  5804. if (diff !== 0) {
  5805. (diffs || (diffs = [])).push([index, diff]);
  5806. }
  5807. return normalizedCh;
  5808. });
  5809. return [normalizedText, diffs];
  5810. }
  5811. function getOriginalIndex(matchIndex) {
  5812. var diffs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5813. if (!diffs) {
  5814. return matchIndex;
  5815. }
  5816. var totalDiff = 0;
  5817. var _iterator = _createForOfIteratorHelper(diffs),
  5818. _step;
  5819. try {
  5820. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5821. var _step$value = _slicedToArray(_step.value, 2),
  5822. index = _step$value[0],
  5823. diff = _step$value[1];
  5824. var currentIndex = index + totalDiff;
  5825. if (currentIndex >= matchIndex) {
  5826. break;
  5827. }
  5828. if (currentIndex + diff > matchIndex) {
  5829. totalDiff += matchIndex - currentIndex;
  5830. break;
  5831. }
  5832. totalDiff += diff;
  5833. }
  5834. } catch (err) {
  5835. _iterator.e(err);
  5836. } finally {
  5837. _iterator.f();
  5838. }
  5839. return matchIndex - totalDiff;
  5840. }
  5841. var PDFFindController = /*#__PURE__*/function () {
  5842. function PDFFindController(_ref) {
  5843. var linkService = _ref.linkService,
  5844. eventBus = _ref.eventBus;
  5845. _classCallCheck(this, PDFFindController);
  5846. this._linkService = linkService;
  5847. this._eventBus = eventBus;
  5848. this._reset();
  5849. eventBus._on("findbarclose", this._onFindBarClose.bind(this));
  5850. }
  5851. _createClass(PDFFindController, [{
  5852. key: "highlightMatches",
  5853. get: function get() {
  5854. return this._highlightMatches;
  5855. }
  5856. }, {
  5857. key: "pageMatches",
  5858. get: function get() {
  5859. return this._pageMatches;
  5860. }
  5861. }, {
  5862. key: "pageMatchesLength",
  5863. get: function get() {
  5864. return this._pageMatchesLength;
  5865. }
  5866. }, {
  5867. key: "selected",
  5868. get: function get() {
  5869. return this._selected;
  5870. }
  5871. }, {
  5872. key: "state",
  5873. get: function get() {
  5874. return this._state;
  5875. }
  5876. }, {
  5877. key: "setDocument",
  5878. value: function setDocument(pdfDocument) {
  5879. if (this._pdfDocument) {
  5880. this._reset();
  5881. }
  5882. if (!pdfDocument) {
  5883. return;
  5884. }
  5885. this._pdfDocument = pdfDocument;
  5886. this._firstPageCapability.resolve();
  5887. }
  5888. }, {
  5889. key: "executeCommand",
  5890. value: function executeCommand(cmd, state) {
  5891. var _this = this;
  5892. if (!state) {
  5893. return;
  5894. }
  5895. var pdfDocument = this._pdfDocument;
  5896. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  5897. this._dirtyMatch = true;
  5898. }
  5899. this._state = state;
  5900. if (cmd !== "findhighlightallchange") {
  5901. this._updateUIState(FindState.PENDING);
  5902. }
  5903. this._firstPageCapability.promise.then(function () {
  5904. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  5905. return;
  5906. }
  5907. _this._extractText();
  5908. var findbarClosed = !_this._highlightMatches;
  5909. var pendingTimeout = !!_this._findTimeout;
  5910. if (_this._findTimeout) {
  5911. clearTimeout(_this._findTimeout);
  5912. _this._findTimeout = null;
  5913. }
  5914. if (cmd === "find") {
  5915. _this._findTimeout = setTimeout(function () {
  5916. _this._nextMatch();
  5917. _this._findTimeout = null;
  5918. }, FIND_TIMEOUT);
  5919. } else if (_this._dirtyMatch) {
  5920. _this._nextMatch();
  5921. } else if (cmd === "findagain") {
  5922. _this._nextMatch();
  5923. if (findbarClosed && _this._state.highlightAll) {
  5924. _this._updateAllPages();
  5925. }
  5926. } else if (cmd === "findhighlightallchange") {
  5927. if (pendingTimeout) {
  5928. _this._nextMatch();
  5929. } else {
  5930. _this._highlightMatches = true;
  5931. }
  5932. _this._updateAllPages();
  5933. } else {
  5934. _this._nextMatch();
  5935. }
  5936. });
  5937. }
  5938. }, {
  5939. key: "scrollMatchIntoView",
  5940. value: function scrollMatchIntoView(_ref2) {
  5941. var _ref2$element = _ref2.element,
  5942. element = _ref2$element === void 0 ? null : _ref2$element,
  5943. _ref2$pageIndex = _ref2.pageIndex,
  5944. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  5945. _ref2$matchIndex = _ref2.matchIndex,
  5946. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  5947. if (!this._scrollMatches || !element) {
  5948. return;
  5949. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  5950. return;
  5951. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  5952. return;
  5953. }
  5954. this._scrollMatches = false;
  5955. var spot = {
  5956. top: MATCH_SCROLL_OFFSET_TOP,
  5957. left: MATCH_SCROLL_OFFSET_LEFT
  5958. };
  5959. (0, _ui_utils.scrollIntoView)(element, spot, true);
  5960. }
  5961. }, {
  5962. key: "_reset",
  5963. value: function _reset() {
  5964. this._highlightMatches = false;
  5965. this._scrollMatches = false;
  5966. this._pdfDocument = null;
  5967. this._pageMatches = [];
  5968. this._pageMatchesLength = [];
  5969. this._state = null;
  5970. this._selected = {
  5971. pageIdx: -1,
  5972. matchIdx: -1
  5973. };
  5974. this._offset = {
  5975. pageIdx: null,
  5976. matchIdx: null,
  5977. wrapped: false
  5978. };
  5979. this._extractTextPromises = [];
  5980. this._pageContents = [];
  5981. this._pageDiffs = [];
  5982. this._matchesCountTotal = 0;
  5983. this._pagesToSearch = null;
  5984. this._pendingFindMatches = Object.create(null);
  5985. this._resumePageIdx = null;
  5986. this._dirtyMatch = false;
  5987. clearTimeout(this._findTimeout);
  5988. this._findTimeout = null;
  5989. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  5990. }
  5991. }, {
  5992. key: "_query",
  5993. get: function get() {
  5994. if (this._state.query !== this._rawQuery) {
  5995. this._rawQuery = this._state.query;
  5996. var _normalize = normalize(this._state.query);
  5997. var _normalize2 = _slicedToArray(_normalize, 1);
  5998. this._normalizedQuery = _normalize2[0];
  5999. }
  6000. return this._normalizedQuery;
  6001. }
  6002. }, {
  6003. key: "_shouldDirtyMatch",
  6004. value: function _shouldDirtyMatch(cmd, state) {
  6005. if (state.query !== this._state.query) {
  6006. return true;
  6007. }
  6008. switch (cmd) {
  6009. case "findagain":
  6010. var pageNumber = this._selected.pageIdx + 1;
  6011. var linkService = this._linkService;
  6012. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  6013. return true;
  6014. }
  6015. return false;
  6016. case "findhighlightallchange":
  6017. return false;
  6018. }
  6019. return true;
  6020. }
  6021. }, {
  6022. key: "_prepareMatches",
  6023. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  6024. function isSubTerm(currentIndex) {
  6025. var currentElem = matchesWithLength[currentIndex];
  6026. var nextElem = matchesWithLength[currentIndex + 1];
  6027. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  6028. currentElem.skipped = true;
  6029. return true;
  6030. }
  6031. for (var i = currentIndex - 1; i >= 0; i--) {
  6032. var prevElem = matchesWithLength[i];
  6033. if (prevElem.skipped) {
  6034. continue;
  6035. }
  6036. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  6037. break;
  6038. }
  6039. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  6040. currentElem.skipped = true;
  6041. return true;
  6042. }
  6043. }
  6044. return false;
  6045. }
  6046. matchesWithLength.sort(function (a, b) {
  6047. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  6048. });
  6049. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  6050. if (isSubTerm(i)) {
  6051. continue;
  6052. }
  6053. matches.push(matchesWithLength[i].match);
  6054. matchesLength.push(matchesWithLength[i].matchLength);
  6055. }
  6056. }
  6057. }, {
  6058. key: "_isEntireWord",
  6059. value: function _isEntireWord(content, startIdx, length) {
  6060. if (startIdx > 0) {
  6061. var first = content.charCodeAt(startIdx);
  6062. var limit = content.charCodeAt(startIdx - 1);
  6063. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  6064. return false;
  6065. }
  6066. }
  6067. var endIdx = startIdx + length - 1;
  6068. if (endIdx < content.length - 1) {
  6069. var last = content.charCodeAt(endIdx);
  6070. var _limit = content.charCodeAt(endIdx + 1);
  6071. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  6072. return false;
  6073. }
  6074. }
  6075. return true;
  6076. }
  6077. }, {
  6078. key: "_calculatePhraseMatch",
  6079. value: function _calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord) {
  6080. var matches = [],
  6081. matchesLength = [];
  6082. var queryLen = query.length;
  6083. var matchIdx = -queryLen;
  6084. while (true) {
  6085. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  6086. if (matchIdx === -1) {
  6087. break;
  6088. }
  6089. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  6090. continue;
  6091. }
  6092. var originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs),
  6093. matchEnd = matchIdx + queryLen - 1,
  6094. originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1;
  6095. matches.push(originalMatchIdx);
  6096. matchesLength.push(originalQueryLen);
  6097. }
  6098. this._pageMatches[pageIndex] = matches;
  6099. this._pageMatchesLength[pageIndex] = matchesLength;
  6100. }
  6101. }, {
  6102. key: "_calculateWordMatch",
  6103. value: function _calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord) {
  6104. var matchesWithLength = [];
  6105. var queryArray = query.match(/\S+/g);
  6106. for (var i = 0, len = queryArray.length; i < len; i++) {
  6107. var subquery = queryArray[i];
  6108. var subqueryLen = subquery.length;
  6109. var matchIdx = -subqueryLen;
  6110. while (true) {
  6111. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  6112. if (matchIdx === -1) {
  6113. break;
  6114. }
  6115. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  6116. continue;
  6117. }
  6118. var originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs),
  6119. matchEnd = matchIdx + subqueryLen - 1,
  6120. originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1;
  6121. matchesWithLength.push({
  6122. match: originalMatchIdx,
  6123. matchLength: originalQueryLen,
  6124. skipped: false
  6125. });
  6126. }
  6127. }
  6128. this._pageMatchesLength[pageIndex] = [];
  6129. this._pageMatches[pageIndex] = [];
  6130. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  6131. }
  6132. }, {
  6133. key: "_calculateMatch",
  6134. value: function _calculateMatch(pageIndex) {
  6135. var pageContent = this._pageContents[pageIndex];
  6136. var pageDiffs = this._pageDiffs[pageIndex];
  6137. var query = this._query;
  6138. var _this$_state = this._state,
  6139. caseSensitive = _this$_state.caseSensitive,
  6140. entireWord = _this$_state.entireWord,
  6141. phraseSearch = _this$_state.phraseSearch;
  6142. if (query.length === 0) {
  6143. return;
  6144. }
  6145. if (!caseSensitive) {
  6146. pageContent = pageContent.toLowerCase();
  6147. query = query.toLowerCase();
  6148. }
  6149. if (phraseSearch) {
  6150. this._calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord);
  6151. } else {
  6152. this._calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord);
  6153. }
  6154. if (this._state.highlightAll) {
  6155. this._updatePage(pageIndex);
  6156. }
  6157. if (this._resumePageIdx === pageIndex) {
  6158. this._resumePageIdx = null;
  6159. this._nextPageMatch();
  6160. }
  6161. var pageMatchesCount = this._pageMatches[pageIndex].length;
  6162. if (pageMatchesCount > 0) {
  6163. this._matchesCountTotal += pageMatchesCount;
  6164. this._updateUIResultsCount();
  6165. }
  6166. }
  6167. }, {
  6168. key: "_extractText",
  6169. value: function _extractText() {
  6170. var _this2 = this;
  6171. if (this._extractTextPromises.length > 0) {
  6172. return;
  6173. }
  6174. var promise = Promise.resolve();
  6175. var _loop = function _loop(i, ii) {
  6176. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  6177. _this2._extractTextPromises[i] = extractTextCapability.promise;
  6178. promise = promise.then(function () {
  6179. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  6180. return pdfPage.getTextContent({
  6181. normalizeWhitespace: true
  6182. });
  6183. }).then(function (textContent) {
  6184. var textItems = textContent.items;
  6185. var strBuf = [];
  6186. for (var j = 0, jj = textItems.length; j < jj; j++) {
  6187. strBuf.push(textItems[j].str);
  6188. }
  6189. var _normalize3 = normalize(strBuf.join(""));
  6190. var _normalize4 = _slicedToArray(_normalize3, 2);
  6191. _this2._pageContents[i] = _normalize4[0];
  6192. _this2._pageDiffs[i] = _normalize4[1];
  6193. extractTextCapability.resolve(i);
  6194. }, function (reason) {
  6195. console.error("Unable to get text content for page ".concat(i + 1), reason);
  6196. _this2._pageContents[i] = "";
  6197. _this2._pageDiffs[i] = null;
  6198. extractTextCapability.resolve(i);
  6199. });
  6200. });
  6201. };
  6202. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  6203. _loop(i, ii);
  6204. }
  6205. }
  6206. }, {
  6207. key: "_updatePage",
  6208. value: function _updatePage(index) {
  6209. if (this._scrollMatches && this._selected.pageIdx === index) {
  6210. this._linkService.page = index + 1;
  6211. }
  6212. this._eventBus.dispatch("updatetextlayermatches", {
  6213. source: this,
  6214. pageIndex: index
  6215. });
  6216. }
  6217. }, {
  6218. key: "_updateAllPages",
  6219. value: function _updateAllPages() {
  6220. this._eventBus.dispatch("updatetextlayermatches", {
  6221. source: this,
  6222. pageIndex: -1
  6223. });
  6224. }
  6225. }, {
  6226. key: "_nextMatch",
  6227. value: function _nextMatch() {
  6228. var _this3 = this;
  6229. var previous = this._state.findPrevious;
  6230. var currentPageIndex = this._linkService.page - 1;
  6231. var numPages = this._linkService.pagesCount;
  6232. this._highlightMatches = true;
  6233. if (this._dirtyMatch) {
  6234. this._dirtyMatch = false;
  6235. this._selected.pageIdx = this._selected.matchIdx = -1;
  6236. this._offset.pageIdx = currentPageIndex;
  6237. this._offset.matchIdx = null;
  6238. this._offset.wrapped = false;
  6239. this._resumePageIdx = null;
  6240. this._pageMatches.length = 0;
  6241. this._pageMatchesLength.length = 0;
  6242. this._matchesCountTotal = 0;
  6243. this._updateAllPages();
  6244. for (var i = 0; i < numPages; i++) {
  6245. if (this._pendingFindMatches[i] === true) {
  6246. continue;
  6247. }
  6248. this._pendingFindMatches[i] = true;
  6249. this._extractTextPromises[i].then(function (pageIdx) {
  6250. delete _this3._pendingFindMatches[pageIdx];
  6251. _this3._calculateMatch(pageIdx);
  6252. });
  6253. }
  6254. }
  6255. if (this._query === "") {
  6256. this._updateUIState(FindState.FOUND);
  6257. return;
  6258. }
  6259. if (this._resumePageIdx) {
  6260. return;
  6261. }
  6262. var offset = this._offset;
  6263. this._pagesToSearch = numPages;
  6264. if (offset.matchIdx !== null) {
  6265. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  6266. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  6267. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  6268. this._updateMatch(true);
  6269. return;
  6270. }
  6271. this._advanceOffsetPage(previous);
  6272. }
  6273. this._nextPageMatch();
  6274. }
  6275. }, {
  6276. key: "_matchesReady",
  6277. value: function _matchesReady(matches) {
  6278. var offset = this._offset;
  6279. var numMatches = matches.length;
  6280. var previous = this._state.findPrevious;
  6281. if (numMatches) {
  6282. offset.matchIdx = previous ? numMatches - 1 : 0;
  6283. this._updateMatch(true);
  6284. return true;
  6285. }
  6286. this._advanceOffsetPage(previous);
  6287. if (offset.wrapped) {
  6288. offset.matchIdx = null;
  6289. if (this._pagesToSearch < 0) {
  6290. this._updateMatch(false);
  6291. return true;
  6292. }
  6293. }
  6294. return false;
  6295. }
  6296. }, {
  6297. key: "_nextPageMatch",
  6298. value: function _nextPageMatch() {
  6299. if (this._resumePageIdx !== null) {
  6300. console.error("There can only be one pending page.");
  6301. }
  6302. var matches = null;
  6303. do {
  6304. var pageIdx = this._offset.pageIdx;
  6305. matches = this._pageMatches[pageIdx];
  6306. if (!matches) {
  6307. this._resumePageIdx = pageIdx;
  6308. break;
  6309. }
  6310. } while (!this._matchesReady(matches));
  6311. }
  6312. }, {
  6313. key: "_advanceOffsetPage",
  6314. value: function _advanceOffsetPage(previous) {
  6315. var offset = this._offset;
  6316. var numPages = this._linkService.pagesCount;
  6317. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  6318. offset.matchIdx = null;
  6319. this._pagesToSearch--;
  6320. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  6321. offset.pageIdx = previous ? numPages - 1 : 0;
  6322. offset.wrapped = true;
  6323. }
  6324. }
  6325. }, {
  6326. key: "_updateMatch",
  6327. value: function _updateMatch() {
  6328. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6329. var state = FindState.NOT_FOUND;
  6330. var wrapped = this._offset.wrapped;
  6331. this._offset.wrapped = false;
  6332. if (found) {
  6333. var previousPage = this._selected.pageIdx;
  6334. this._selected.pageIdx = this._offset.pageIdx;
  6335. this._selected.matchIdx = this._offset.matchIdx;
  6336. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  6337. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  6338. this._updatePage(previousPage);
  6339. }
  6340. }
  6341. this._updateUIState(state, this._state.findPrevious);
  6342. if (this._selected.pageIdx !== -1) {
  6343. this._scrollMatches = true;
  6344. this._updatePage(this._selected.pageIdx);
  6345. }
  6346. }
  6347. }, {
  6348. key: "_onFindBarClose",
  6349. value: function _onFindBarClose(evt) {
  6350. var _this4 = this;
  6351. var pdfDocument = this._pdfDocument;
  6352. this._firstPageCapability.promise.then(function () {
  6353. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  6354. return;
  6355. }
  6356. if (_this4._findTimeout) {
  6357. clearTimeout(_this4._findTimeout);
  6358. _this4._findTimeout = null;
  6359. }
  6360. if (_this4._resumePageIdx) {
  6361. _this4._resumePageIdx = null;
  6362. _this4._dirtyMatch = true;
  6363. }
  6364. _this4._updateUIState(FindState.FOUND);
  6365. _this4._highlightMatches = false;
  6366. _this4._updateAllPages();
  6367. });
  6368. }
  6369. }, {
  6370. key: "_requestMatchesCount",
  6371. value: function _requestMatchesCount() {
  6372. var _this$_selected = this._selected,
  6373. pageIdx = _this$_selected.pageIdx,
  6374. matchIdx = _this$_selected.matchIdx;
  6375. var current = 0,
  6376. total = this._matchesCountTotal;
  6377. if (matchIdx !== -1) {
  6378. for (var i = 0; i < pageIdx; i++) {
  6379. var _this$_pageMatches$i;
  6380. current += ((_this$_pageMatches$i = this._pageMatches[i]) === null || _this$_pageMatches$i === void 0 ? void 0 : _this$_pageMatches$i.length) || 0;
  6381. }
  6382. current += matchIdx + 1;
  6383. }
  6384. if (current < 1 || current > total) {
  6385. current = total = 0;
  6386. }
  6387. return {
  6388. current: current,
  6389. total: total
  6390. };
  6391. }
  6392. }, {
  6393. key: "_updateUIResultsCount",
  6394. value: function _updateUIResultsCount() {
  6395. this._eventBus.dispatch("updatefindmatchescount", {
  6396. source: this,
  6397. matchesCount: this._requestMatchesCount()
  6398. });
  6399. }
  6400. }, {
  6401. key: "_updateUIState",
  6402. value: function _updateUIState(state, previous) {
  6403. var _this$_state$query, _this$_state2;
  6404. this._eventBus.dispatch("updatefindcontrolstate", {
  6405. source: this,
  6406. state: state,
  6407. previous: previous,
  6408. matchesCount: this._requestMatchesCount(),
  6409. rawQuery: (_this$_state$query = (_this$_state2 = this._state) === null || _this$_state2 === void 0 ? void 0 : _this$_state2.query) !== null && _this$_state$query !== void 0 ? _this$_state$query : null
  6410. });
  6411. }
  6412. }]);
  6413. return PDFFindController;
  6414. }();
  6415. exports.PDFFindController = PDFFindController;
  6416. /***/ }),
  6417. /* 18 */
  6418. /***/ ((__unused_webpack_module, exports) => {
  6419. Object.defineProperty(exports, "__esModule", ({
  6420. value: true
  6421. }));
  6422. exports.getCharacterType = getCharacterType;
  6423. exports.CharacterType = void 0;
  6424. var CharacterType = {
  6425. SPACE: 0,
  6426. ALPHA_LETTER: 1,
  6427. PUNCT: 2,
  6428. HAN_LETTER: 3,
  6429. KATAKANA_LETTER: 4,
  6430. HIRAGANA_LETTER: 5,
  6431. HALFWIDTH_KATAKANA_LETTER: 6,
  6432. THAI_LETTER: 7
  6433. };
  6434. exports.CharacterType = CharacterType;
  6435. function isAlphabeticalScript(charCode) {
  6436. return charCode < 0x2e80;
  6437. }
  6438. function isAscii(charCode) {
  6439. return (charCode & 0xff80) === 0;
  6440. }
  6441. function isAsciiAlpha(charCode) {
  6442. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  6443. }
  6444. function isAsciiDigit(charCode) {
  6445. return charCode >= 0x30 && charCode <= 0x39;
  6446. }
  6447. function isAsciiSpace(charCode) {
  6448. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  6449. }
  6450. function isHan(charCode) {
  6451. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  6452. }
  6453. function isKatakana(charCode) {
  6454. return charCode >= 0x30a0 && charCode <= 0x30ff;
  6455. }
  6456. function isHiragana(charCode) {
  6457. return charCode >= 0x3040 && charCode <= 0x309f;
  6458. }
  6459. function isHalfwidthKatakana(charCode) {
  6460. return charCode >= 0xff60 && charCode <= 0xff9f;
  6461. }
  6462. function isThai(charCode) {
  6463. return (charCode & 0xff80) === 0x0e00;
  6464. }
  6465. function getCharacterType(charCode) {
  6466. if (isAlphabeticalScript(charCode)) {
  6467. if (isAscii(charCode)) {
  6468. if (isAsciiSpace(charCode)) {
  6469. return CharacterType.SPACE;
  6470. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  6471. return CharacterType.ALPHA_LETTER;
  6472. }
  6473. return CharacterType.PUNCT;
  6474. } else if (isThai(charCode)) {
  6475. return CharacterType.THAI_LETTER;
  6476. } else if (charCode === 0xa0) {
  6477. return CharacterType.SPACE;
  6478. }
  6479. return CharacterType.ALPHA_LETTER;
  6480. }
  6481. if (isHan(charCode)) {
  6482. return CharacterType.HAN_LETTER;
  6483. } else if (isKatakana(charCode)) {
  6484. return CharacterType.KATAKANA_LETTER;
  6485. } else if (isHiragana(charCode)) {
  6486. return CharacterType.HIRAGANA_LETTER;
  6487. } else if (isHalfwidthKatakana(charCode)) {
  6488. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  6489. }
  6490. return CharacterType.ALPHA_LETTER;
  6491. }
  6492. /***/ }),
  6493. /* 19 */
  6494. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6495. Object.defineProperty(exports, "__esModule", ({
  6496. value: true
  6497. }));
  6498. exports.isDestArraysEqual = isDestArraysEqual;
  6499. exports.isDestHashesEqual = isDestHashesEqual;
  6500. exports.PDFHistory = void 0;
  6501. var _ui_utils = __webpack_require__(6);
  6502. 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); }
  6503. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  6504. 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."); }
  6505. 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); }
  6506. 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; }
  6507. 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; }
  6508. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  6509. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6510. 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); } }
  6511. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6512. var HASH_CHANGE_TIMEOUT = 1000;
  6513. var POSITION_UPDATED_THRESHOLD = 50;
  6514. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  6515. function getCurrentHash() {
  6516. return document.location.hash;
  6517. }
  6518. var PDFHistory = /*#__PURE__*/function () {
  6519. function PDFHistory(_ref) {
  6520. var _this = this;
  6521. var linkService = _ref.linkService,
  6522. eventBus = _ref.eventBus;
  6523. _classCallCheck(this, PDFHistory);
  6524. this.linkService = linkService;
  6525. this.eventBus = eventBus;
  6526. this._initialized = false;
  6527. this._fingerprint = "";
  6528. this.reset();
  6529. this._boundEvents = null;
  6530. this._isViewerInPresentationMode = false;
  6531. this.eventBus._on("presentationmodechanged", function (evt) {
  6532. _this._isViewerInPresentationMode = evt.state !== _ui_utils.PresentationModeState.NORMAL;
  6533. });
  6534. this.eventBus._on("pagesinit", function () {
  6535. _this._isPagesLoaded = false;
  6536. _this.eventBus._on("pagesloaded", function (evt) {
  6537. _this._isPagesLoaded = !!evt.pagesCount;
  6538. }, {
  6539. once: true
  6540. });
  6541. });
  6542. }
  6543. _createClass(PDFHistory, [{
  6544. key: "initialize",
  6545. value: function initialize(_ref2) {
  6546. var fingerprint = _ref2.fingerprint,
  6547. _ref2$resetHistory = _ref2.resetHistory,
  6548. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  6549. _ref2$updateUrl = _ref2.updateUrl,
  6550. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  6551. if (!fingerprint || typeof fingerprint !== "string") {
  6552. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  6553. return;
  6554. }
  6555. if (this._initialized) {
  6556. this.reset();
  6557. }
  6558. var reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  6559. this._fingerprint = fingerprint;
  6560. this._updateUrl = updateUrl === true;
  6561. this._initialized = true;
  6562. this._bindEvents();
  6563. var state = window.history.state;
  6564. this._popStateInProgress = false;
  6565. this._blockHashChange = 0;
  6566. this._currentHash = getCurrentHash();
  6567. this._numPositionUpdates = 0;
  6568. this._uid = this._maxUid = 0;
  6569. this._destination = null;
  6570. this._position = null;
  6571. if (!this._isValidState(state, true) || resetHistory) {
  6572. var _this$_parseCurrentHa = this._parseCurrentHash(true),
  6573. hash = _this$_parseCurrentHa.hash,
  6574. page = _this$_parseCurrentHa.page,
  6575. rotation = _this$_parseCurrentHa.rotation;
  6576. if (!hash || reInitialized || resetHistory) {
  6577. this._pushOrReplaceState(null, true);
  6578. return;
  6579. }
  6580. this._pushOrReplaceState({
  6581. hash: hash,
  6582. page: page,
  6583. rotation: rotation
  6584. }, true);
  6585. return;
  6586. }
  6587. var destination = state.destination;
  6588. this._updateInternalState(destination, state.uid, true);
  6589. if (destination.rotation !== undefined) {
  6590. this._initialRotation = destination.rotation;
  6591. }
  6592. if (destination.dest) {
  6593. this._initialBookmark = JSON.stringify(destination.dest);
  6594. this._destination.page = null;
  6595. } else if (destination.hash) {
  6596. this._initialBookmark = destination.hash;
  6597. } else if (destination.page) {
  6598. this._initialBookmark = "page=".concat(destination.page);
  6599. }
  6600. }
  6601. }, {
  6602. key: "reset",
  6603. value: function reset() {
  6604. if (this._initialized) {
  6605. this._pageHide();
  6606. this._initialized = false;
  6607. this._unbindEvents();
  6608. }
  6609. if (this._updateViewareaTimeout) {
  6610. clearTimeout(this._updateViewareaTimeout);
  6611. this._updateViewareaTimeout = null;
  6612. }
  6613. this._initialBookmark = null;
  6614. this._initialRotation = null;
  6615. }
  6616. }, {
  6617. key: "push",
  6618. value: function push(_ref3) {
  6619. var _this2 = this;
  6620. var _ref3$namedDest = _ref3.namedDest,
  6621. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  6622. explicitDest = _ref3.explicitDest,
  6623. pageNumber = _ref3.pageNumber;
  6624. if (!this._initialized) {
  6625. return;
  6626. }
  6627. if (namedDest && typeof namedDest !== "string") {
  6628. console.error("PDFHistory.push: " + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  6629. return;
  6630. } else if (!Array.isArray(explicitDest)) {
  6631. console.error("PDFHistory.push: " + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  6632. return;
  6633. } else if (!this._isValidPage(pageNumber)) {
  6634. if (pageNumber !== null || this._destination) {
  6635. console.error("PDFHistory.push: " + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  6636. return;
  6637. }
  6638. }
  6639. var hash = namedDest || JSON.stringify(explicitDest);
  6640. if (!hash) {
  6641. return;
  6642. }
  6643. var forceReplace = false;
  6644. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  6645. if (this._destination.page) {
  6646. return;
  6647. }
  6648. forceReplace = true;
  6649. }
  6650. if (this._popStateInProgress && !forceReplace) {
  6651. return;
  6652. }
  6653. this._pushOrReplaceState({
  6654. dest: explicitDest,
  6655. hash: hash,
  6656. page: pageNumber,
  6657. rotation: this.linkService.rotation
  6658. }, forceReplace);
  6659. if (!this._popStateInProgress) {
  6660. this._popStateInProgress = true;
  6661. Promise.resolve().then(function () {
  6662. _this2._popStateInProgress = false;
  6663. });
  6664. }
  6665. }
  6666. }, {
  6667. key: "pushPage",
  6668. value: function pushPage(pageNumber) {
  6669. var _this$_destination,
  6670. _this3 = this;
  6671. if (!this._initialized) {
  6672. return;
  6673. }
  6674. if (!this._isValidPage(pageNumber)) {
  6675. console.error("PDFHistory.pushPage: \"".concat(pageNumber, "\" is not a valid page number."));
  6676. return;
  6677. }
  6678. if (((_this$_destination = this._destination) === null || _this$_destination === void 0 ? void 0 : _this$_destination.page) === pageNumber) {
  6679. return;
  6680. }
  6681. if (this._popStateInProgress) {
  6682. return;
  6683. }
  6684. this._pushOrReplaceState({
  6685. dest: null,
  6686. hash: "page=".concat(pageNumber),
  6687. page: pageNumber,
  6688. rotation: this.linkService.rotation
  6689. });
  6690. if (!this._popStateInProgress) {
  6691. this._popStateInProgress = true;
  6692. Promise.resolve().then(function () {
  6693. _this3._popStateInProgress = false;
  6694. });
  6695. }
  6696. }
  6697. }, {
  6698. key: "pushCurrentPosition",
  6699. value: function pushCurrentPosition() {
  6700. if (!this._initialized || this._popStateInProgress) {
  6701. return;
  6702. }
  6703. this._tryPushCurrentPosition();
  6704. }
  6705. }, {
  6706. key: "back",
  6707. value: function back() {
  6708. if (!this._initialized || this._popStateInProgress) {
  6709. return;
  6710. }
  6711. var state = window.history.state;
  6712. if (this._isValidState(state) && state.uid > 0) {
  6713. window.history.back();
  6714. }
  6715. }
  6716. }, {
  6717. key: "forward",
  6718. value: function forward() {
  6719. if (!this._initialized || this._popStateInProgress) {
  6720. return;
  6721. }
  6722. var state = window.history.state;
  6723. if (this._isValidState(state) && state.uid < this._maxUid) {
  6724. window.history.forward();
  6725. }
  6726. }
  6727. }, {
  6728. key: "popStateInProgress",
  6729. get: function get() {
  6730. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  6731. }
  6732. }, {
  6733. key: "initialBookmark",
  6734. get: function get() {
  6735. return this._initialized ? this._initialBookmark : null;
  6736. }
  6737. }, {
  6738. key: "initialRotation",
  6739. get: function get() {
  6740. return this._initialized ? this._initialRotation : null;
  6741. }
  6742. }, {
  6743. key: "_pushOrReplaceState",
  6744. value: function _pushOrReplaceState(destination) {
  6745. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6746. var shouldReplace = forceReplace || !this._destination;
  6747. var newState = {
  6748. fingerprint: this._fingerprint,
  6749. uid: shouldReplace ? this._uid : this._uid + 1,
  6750. destination: destination
  6751. };
  6752. this._updateInternalState(destination, newState.uid);
  6753. var newUrl;
  6754. if (this._updateUrl && destination !== null && destination !== void 0 && destination.hash) {
  6755. var baseUrl = document.location.href.split("#")[0];
  6756. if (!baseUrl.startsWith("file://")) {
  6757. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  6758. }
  6759. }
  6760. if (shouldReplace) {
  6761. window.history.replaceState(newState, "", newUrl);
  6762. } else {
  6763. window.history.pushState(newState, "", newUrl);
  6764. }
  6765. }
  6766. }, {
  6767. key: "_tryPushCurrentPosition",
  6768. value: function _tryPushCurrentPosition() {
  6769. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6770. if (!this._position) {
  6771. return;
  6772. }
  6773. var position = this._position;
  6774. if (temporary) {
  6775. position = Object.assign(Object.create(null), this._position);
  6776. position.temporary = true;
  6777. }
  6778. if (!this._destination) {
  6779. this._pushOrReplaceState(position);
  6780. return;
  6781. }
  6782. if (this._destination.temporary) {
  6783. this._pushOrReplaceState(position, true);
  6784. return;
  6785. }
  6786. if (this._destination.hash === position.hash) {
  6787. return;
  6788. }
  6789. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  6790. return;
  6791. }
  6792. var forceReplace = false;
  6793. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  6794. if (this._destination.dest !== undefined || !this._destination.first) {
  6795. return;
  6796. }
  6797. forceReplace = true;
  6798. }
  6799. this._pushOrReplaceState(position, forceReplace);
  6800. }
  6801. }, {
  6802. key: "_isValidPage",
  6803. value: function _isValidPage(val) {
  6804. return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount;
  6805. }
  6806. }, {
  6807. key: "_isValidState",
  6808. value: function _isValidState(state) {
  6809. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6810. if (!state) {
  6811. return false;
  6812. }
  6813. if (state.fingerprint !== this._fingerprint) {
  6814. if (checkReload) {
  6815. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  6816. return false;
  6817. }
  6818. var _performance$getEntri = performance.getEntriesByType("navigation"),
  6819. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  6820. perfEntry = _performance$getEntri2[0];
  6821. if ((perfEntry === null || perfEntry === void 0 ? void 0 : perfEntry.type) !== "reload") {
  6822. return false;
  6823. }
  6824. } else {
  6825. return false;
  6826. }
  6827. }
  6828. if (!Number.isInteger(state.uid) || state.uid < 0) {
  6829. return false;
  6830. }
  6831. if (state.destination === null || _typeof(state.destination) !== "object") {
  6832. return false;
  6833. }
  6834. return true;
  6835. }
  6836. }, {
  6837. key: "_updateInternalState",
  6838. value: function _updateInternalState(destination, uid) {
  6839. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6840. if (this._updateViewareaTimeout) {
  6841. clearTimeout(this._updateViewareaTimeout);
  6842. this._updateViewareaTimeout = null;
  6843. }
  6844. if (removeTemporary && destination !== null && destination !== void 0 && destination.temporary) {
  6845. delete destination.temporary;
  6846. }
  6847. this._destination = destination;
  6848. this._uid = uid;
  6849. this._maxUid = Math.max(this._maxUid, uid);
  6850. this._numPositionUpdates = 0;
  6851. }
  6852. }, {
  6853. key: "_parseCurrentHash",
  6854. value: function _parseCurrentHash() {
  6855. var checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6856. var hash = unescape(getCurrentHash()).substring(1);
  6857. var params = (0, _ui_utils.parseQueryString)(hash);
  6858. var nameddest = params.nameddest || "";
  6859. var page = params.page | 0;
  6860. if (!this._isValidPage(page) || checkNameddest && nameddest.length > 0) {
  6861. page = null;
  6862. }
  6863. return {
  6864. hash: hash,
  6865. page: page,
  6866. rotation: this.linkService.rotation
  6867. };
  6868. }
  6869. }, {
  6870. key: "_updateViewarea",
  6871. value: function _updateViewarea(_ref4) {
  6872. var _this4 = this;
  6873. var location = _ref4.location;
  6874. if (this._updateViewareaTimeout) {
  6875. clearTimeout(this._updateViewareaTimeout);
  6876. this._updateViewareaTimeout = null;
  6877. }
  6878. this._position = {
  6879. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  6880. page: this.linkService.page,
  6881. first: location.pageNumber,
  6882. rotation: location.rotation
  6883. };
  6884. if (this._popStateInProgress) {
  6885. return;
  6886. }
  6887. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  6888. this._numPositionUpdates++;
  6889. }
  6890. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  6891. this._updateViewareaTimeout = setTimeout(function () {
  6892. if (!_this4._popStateInProgress) {
  6893. _this4._tryPushCurrentPosition(true);
  6894. }
  6895. _this4._updateViewareaTimeout = null;
  6896. }, UPDATE_VIEWAREA_TIMEOUT);
  6897. }
  6898. }
  6899. }, {
  6900. key: "_popState",
  6901. value: function _popState(_ref5) {
  6902. var _this5 = this;
  6903. var state = _ref5.state;
  6904. var newHash = getCurrentHash(),
  6905. hashChanged = this._currentHash !== newHash;
  6906. this._currentHash = newHash;
  6907. if (!state) {
  6908. this._uid++;
  6909. var _this$_parseCurrentHa2 = this._parseCurrentHash(),
  6910. hash = _this$_parseCurrentHa2.hash,
  6911. page = _this$_parseCurrentHa2.page,
  6912. rotation = _this$_parseCurrentHa2.rotation;
  6913. this._pushOrReplaceState({
  6914. hash: hash,
  6915. page: page,
  6916. rotation: rotation
  6917. }, true);
  6918. return;
  6919. }
  6920. if (!this._isValidState(state)) {
  6921. return;
  6922. }
  6923. this._popStateInProgress = true;
  6924. if (hashChanged) {
  6925. this._blockHashChange++;
  6926. (0, _ui_utils.waitOnEventOrTimeout)({
  6927. target: window,
  6928. name: "hashchange",
  6929. delay: HASH_CHANGE_TIMEOUT
  6930. }).then(function () {
  6931. _this5._blockHashChange--;
  6932. });
  6933. }
  6934. var destination = state.destination;
  6935. this._updateInternalState(destination, state.uid, true);
  6936. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  6937. this.linkService.rotation = destination.rotation;
  6938. }
  6939. if (destination.dest) {
  6940. this.linkService.goToDestination(destination.dest);
  6941. } else if (destination.hash) {
  6942. this.linkService.setHash(destination.hash);
  6943. } else if (destination.page) {
  6944. this.linkService.page = destination.page;
  6945. }
  6946. Promise.resolve().then(function () {
  6947. _this5._popStateInProgress = false;
  6948. });
  6949. }
  6950. }, {
  6951. key: "_pageHide",
  6952. value: function _pageHide() {
  6953. if (!this._destination || this._destination.temporary) {
  6954. this._tryPushCurrentPosition();
  6955. }
  6956. }
  6957. }, {
  6958. key: "_bindEvents",
  6959. value: function _bindEvents() {
  6960. if (this._boundEvents) {
  6961. return;
  6962. }
  6963. this._boundEvents = {
  6964. updateViewarea: this._updateViewarea.bind(this),
  6965. popState: this._popState.bind(this),
  6966. pageHide: this._pageHide.bind(this)
  6967. };
  6968. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  6969. window.addEventListener("popstate", this._boundEvents.popState);
  6970. window.addEventListener("pagehide", this._boundEvents.pageHide);
  6971. }
  6972. }, {
  6973. key: "_unbindEvents",
  6974. value: function _unbindEvents() {
  6975. if (!this._boundEvents) {
  6976. return;
  6977. }
  6978. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  6979. window.removeEventListener("popstate", this._boundEvents.popState);
  6980. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  6981. this._boundEvents = null;
  6982. }
  6983. }]);
  6984. return PDFHistory;
  6985. }();
  6986. exports.PDFHistory = PDFHistory;
  6987. function isDestHashesEqual(destHash, pushHash) {
  6988. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  6989. return false;
  6990. }
  6991. if (destHash === pushHash) {
  6992. return true;
  6993. }
  6994. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  6995. nameddest = _parseQueryString.nameddest;
  6996. if (nameddest === pushHash) {
  6997. return true;
  6998. }
  6999. return false;
  7000. }
  7001. function isDestArraysEqual(firstDest, secondDest) {
  7002. function isEntryEqual(first, second) {
  7003. if (_typeof(first) !== _typeof(second)) {
  7004. return false;
  7005. }
  7006. if (Array.isArray(first) || Array.isArray(second)) {
  7007. return false;
  7008. }
  7009. if (first !== null && _typeof(first) === "object" && second !== null) {
  7010. if (Object.keys(first).length !== Object.keys(second).length) {
  7011. return false;
  7012. }
  7013. for (var key in first) {
  7014. if (!isEntryEqual(first[key], second[key])) {
  7015. return false;
  7016. }
  7017. }
  7018. return true;
  7019. }
  7020. return first === second || Number.isNaN(first) && Number.isNaN(second);
  7021. }
  7022. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  7023. return false;
  7024. }
  7025. if (firstDest.length !== secondDest.length) {
  7026. return false;
  7027. }
  7028. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  7029. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  7030. return false;
  7031. }
  7032. }
  7033. return true;
  7034. }
  7035. /***/ }),
  7036. /* 20 */
  7037. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7038. Object.defineProperty(exports, "__esModule", ({
  7039. value: true
  7040. }));
  7041. exports.PDFLayerViewer = void 0;
  7042. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  7043. var _base_tree_viewer = __webpack_require__(14);
  7044. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7045. 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); }
  7046. 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; } } }; }
  7047. 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); }
  7048. 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; }
  7049. 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); } }
  7050. 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); }); }; }
  7051. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7052. 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); } }
  7053. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7054. 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); }
  7055. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  7056. 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); }
  7057. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7058. 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); }; }
  7059. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7060. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7061. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  7062. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7063. var PDFLayerViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  7064. _inherits(PDFLayerViewer, _BaseTreeViewer);
  7065. var _super = _createSuper(PDFLayerViewer);
  7066. function PDFLayerViewer(options) {
  7067. var _this;
  7068. _classCallCheck(this, PDFLayerViewer);
  7069. _this = _super.call(this, options);
  7070. _this.l10n = options.l10n;
  7071. _this.eventBus._on("resetlayers", _this._resetLayers.bind(_assertThisInitialized(_this)));
  7072. _this.eventBus._on("togglelayerstree", _this._toggleAllTreeItems.bind(_assertThisInitialized(_this)));
  7073. return _this;
  7074. }
  7075. _createClass(PDFLayerViewer, [{
  7076. key: "reset",
  7077. value: function reset() {
  7078. _get(_getPrototypeOf(PDFLayerViewer.prototype), "reset", this).call(this);
  7079. this._optionalContentConfig = null;
  7080. }
  7081. }, {
  7082. key: "_dispatchEvent",
  7083. value: function _dispatchEvent(layersCount) {
  7084. this.eventBus.dispatch("layersloaded", {
  7085. source: this,
  7086. layersCount: layersCount
  7087. });
  7088. }
  7089. }, {
  7090. key: "_bindLink",
  7091. value: function _bindLink(element, _ref) {
  7092. var _this2 = this;
  7093. var groupId = _ref.groupId,
  7094. input = _ref.input;
  7095. var setVisibility = function setVisibility() {
  7096. _this2._optionalContentConfig.setVisibility(groupId, input.checked);
  7097. _this2.eventBus.dispatch("optionalcontentconfig", {
  7098. source: _this2,
  7099. promise: Promise.resolve(_this2._optionalContentConfig)
  7100. });
  7101. };
  7102. element.onclick = function (evt) {
  7103. if (evt.target === input) {
  7104. setVisibility();
  7105. return true;
  7106. } else if (evt.target !== element) {
  7107. return true;
  7108. }
  7109. input.checked = !input.checked;
  7110. setVisibility();
  7111. return false;
  7112. };
  7113. }
  7114. }, {
  7115. key: "_setNestedName",
  7116. value: function () {
  7117. var _setNestedName2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(element, _ref2) {
  7118. var _ref2$name, name;
  7119. return _regenerator["default"].wrap(function _callee$(_context) {
  7120. while (1) {
  7121. switch (_context.prev = _context.next) {
  7122. case 0:
  7123. _ref2$name = _ref2.name, name = _ref2$name === void 0 ? null : _ref2$name;
  7124. if (!(typeof name === "string")) {
  7125. _context.next = 4;
  7126. break;
  7127. }
  7128. element.textContent = this._normalizeTextContent(name);
  7129. return _context.abrupt("return");
  7130. case 4:
  7131. _context.next = 6;
  7132. return this.l10n.get("additional_layers");
  7133. case 6:
  7134. element.textContent = _context.sent;
  7135. element.style.fontStyle = "italic";
  7136. case 8:
  7137. case "end":
  7138. return _context.stop();
  7139. }
  7140. }
  7141. }, _callee, this);
  7142. }));
  7143. function _setNestedName(_x, _x2) {
  7144. return _setNestedName2.apply(this, arguments);
  7145. }
  7146. return _setNestedName;
  7147. }()
  7148. }, {
  7149. key: "_addToggleButton",
  7150. value: function _addToggleButton(div, _ref3) {
  7151. var _ref3$name = _ref3.name,
  7152. name = _ref3$name === void 0 ? null : _ref3$name;
  7153. _get(_getPrototypeOf(PDFLayerViewer.prototype), "_addToggleButton", this).call(this, div, name === null);
  7154. }
  7155. }, {
  7156. key: "_toggleAllTreeItems",
  7157. value: function _toggleAllTreeItems() {
  7158. if (!this._optionalContentConfig) {
  7159. return;
  7160. }
  7161. _get(_getPrototypeOf(PDFLayerViewer.prototype), "_toggleAllTreeItems", this).call(this);
  7162. }
  7163. }, {
  7164. key: "render",
  7165. value: function render(_ref4) {
  7166. var optionalContentConfig = _ref4.optionalContentConfig,
  7167. pdfDocument = _ref4.pdfDocument;
  7168. if (this._optionalContentConfig) {
  7169. this.reset();
  7170. }
  7171. this._optionalContentConfig = optionalContentConfig || null;
  7172. this._pdfDocument = pdfDocument || null;
  7173. var groups = optionalContentConfig === null || optionalContentConfig === void 0 ? void 0 : optionalContentConfig.getOrder();
  7174. if (!groups) {
  7175. this._dispatchEvent(0);
  7176. return;
  7177. }
  7178. var fragment = document.createDocumentFragment(),
  7179. queue = [{
  7180. parent: fragment,
  7181. groups: groups
  7182. }];
  7183. var layersCount = 0,
  7184. hasAnyNesting = false;
  7185. while (queue.length > 0) {
  7186. var levelData = queue.shift();
  7187. var _iterator = _createForOfIteratorHelper(levelData.groups),
  7188. _step;
  7189. try {
  7190. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7191. var groupId = _step.value;
  7192. var div = document.createElement("div");
  7193. div.className = "treeItem";
  7194. var element = document.createElement("a");
  7195. div.appendChild(element);
  7196. if (_typeof(groupId) === "object") {
  7197. hasAnyNesting = true;
  7198. this._addToggleButton(div, groupId);
  7199. this._setNestedName(element, groupId);
  7200. var itemsDiv = document.createElement("div");
  7201. itemsDiv.className = "treeItems";
  7202. div.appendChild(itemsDiv);
  7203. queue.push({
  7204. parent: itemsDiv,
  7205. groups: groupId.order
  7206. });
  7207. } else {
  7208. var group = optionalContentConfig.getGroup(groupId);
  7209. var input = document.createElement("input");
  7210. this._bindLink(element, {
  7211. groupId: groupId,
  7212. input: input
  7213. });
  7214. input.type = "checkbox";
  7215. input.id = groupId;
  7216. input.checked = group.visible;
  7217. var label = document.createElement("label");
  7218. label.setAttribute("for", groupId);
  7219. label.textContent = this._normalizeTextContent(group.name);
  7220. element.appendChild(input);
  7221. element.appendChild(label);
  7222. layersCount++;
  7223. }
  7224. levelData.parent.appendChild(div);
  7225. }
  7226. } catch (err) {
  7227. _iterator.e(err);
  7228. } finally {
  7229. _iterator.f();
  7230. }
  7231. }
  7232. this._finishRendering(fragment, layersCount, hasAnyNesting);
  7233. }
  7234. }, {
  7235. key: "_resetLayers",
  7236. value: function () {
  7237. var _resetLayers2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  7238. var optionalContentConfig;
  7239. return _regenerator["default"].wrap(function _callee2$(_context2) {
  7240. while (1) {
  7241. switch (_context2.prev = _context2.next) {
  7242. case 0:
  7243. if (this._optionalContentConfig) {
  7244. _context2.next = 2;
  7245. break;
  7246. }
  7247. return _context2.abrupt("return");
  7248. case 2:
  7249. _context2.next = 4;
  7250. return this._pdfDocument.getOptionalContentConfig();
  7251. case 4:
  7252. optionalContentConfig = _context2.sent;
  7253. this.eventBus.dispatch("optionalcontentconfig", {
  7254. source: this,
  7255. promise: Promise.resolve(optionalContentConfig)
  7256. });
  7257. this.render({
  7258. optionalContentConfig: optionalContentConfig,
  7259. pdfDocument: this._pdfDocument
  7260. });
  7261. case 7:
  7262. case "end":
  7263. return _context2.stop();
  7264. }
  7265. }
  7266. }, _callee2, this);
  7267. }));
  7268. function _resetLayers() {
  7269. return _resetLayers2.apply(this, arguments);
  7270. }
  7271. return _resetLayers;
  7272. }()
  7273. }]);
  7274. return PDFLayerViewer;
  7275. }(_base_tree_viewer.BaseTreeViewer);
  7276. exports.PDFLayerViewer = PDFLayerViewer;
  7277. /***/ }),
  7278. /* 21 */
  7279. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7280. Object.defineProperty(exports, "__esModule", ({
  7281. value: true
  7282. }));
  7283. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  7284. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  7285. var _ui_utils = __webpack_require__(6);
  7286. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7287. 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); }
  7288. 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); } }
  7289. 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); }); }; }
  7290. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7291. 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); } }
  7292. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7293. var PDFLinkService = /*#__PURE__*/function () {
  7294. function PDFLinkService() {
  7295. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  7296. eventBus = _ref.eventBus,
  7297. _ref$externalLinkTarg = _ref.externalLinkTarget,
  7298. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  7299. _ref$externalLinkRel = _ref.externalLinkRel,
  7300. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel,
  7301. _ref$externalLinkEnab = _ref.externalLinkEnabled,
  7302. externalLinkEnabled = _ref$externalLinkEnab === void 0 ? true : _ref$externalLinkEnab,
  7303. _ref$ignoreDestinatio = _ref.ignoreDestinationZoom,
  7304. ignoreDestinationZoom = _ref$ignoreDestinatio === void 0 ? false : _ref$ignoreDestinatio;
  7305. _classCallCheck(this, PDFLinkService);
  7306. this.eventBus = eventBus;
  7307. this.externalLinkTarget = externalLinkTarget;
  7308. this.externalLinkRel = externalLinkRel;
  7309. this.externalLinkEnabled = externalLinkEnabled;
  7310. this._ignoreDestinationZoom = ignoreDestinationZoom;
  7311. this.baseUrl = null;
  7312. this.pdfDocument = null;
  7313. this.pdfViewer = null;
  7314. this.pdfHistory = null;
  7315. this._pagesRefCache = null;
  7316. }
  7317. _createClass(PDFLinkService, [{
  7318. key: "setDocument",
  7319. value: function setDocument(pdfDocument) {
  7320. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  7321. this.baseUrl = baseUrl;
  7322. this.pdfDocument = pdfDocument;
  7323. this._pagesRefCache = Object.create(null);
  7324. }
  7325. }, {
  7326. key: "setViewer",
  7327. value: function setViewer(pdfViewer) {
  7328. this.pdfViewer = pdfViewer;
  7329. }
  7330. }, {
  7331. key: "setHistory",
  7332. value: function setHistory(pdfHistory) {
  7333. this.pdfHistory = pdfHistory;
  7334. }
  7335. }, {
  7336. key: "pagesCount",
  7337. get: function get() {
  7338. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  7339. }
  7340. }, {
  7341. key: "page",
  7342. get: function get() {
  7343. return this.pdfViewer.currentPageNumber;
  7344. },
  7345. set: function set(value) {
  7346. this.pdfViewer.currentPageNumber = value;
  7347. }
  7348. }, {
  7349. key: "rotation",
  7350. get: function get() {
  7351. return this.pdfViewer.pagesRotation;
  7352. },
  7353. set: function set(value) {
  7354. this.pdfViewer.pagesRotation = value;
  7355. }
  7356. }, {
  7357. key: "navigateTo",
  7358. value: function navigateTo(dest) {
  7359. console.error("Deprecated method: `navigateTo`, use `goToDestination` instead.");
  7360. this.goToDestination(dest);
  7361. }
  7362. }, {
  7363. key: "_goToDestinationHelper",
  7364. value: function _goToDestinationHelper(rawDest) {
  7365. var _this = this;
  7366. var namedDest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  7367. var explicitDest = arguments.length > 2 ? arguments[2] : undefined;
  7368. var destRef = explicitDest[0];
  7369. var pageNumber;
  7370. if (destRef instanceof Object) {
  7371. pageNumber = this._cachedPageNumber(destRef);
  7372. if (pageNumber === null) {
  7373. this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  7374. _this.cachePageRef(pageIndex + 1, destRef);
  7375. _this._goToDestinationHelper(rawDest, namedDest, explicitDest);
  7376. })["catch"](function () {
  7377. console.error("PDFLinkService._goToDestinationHelper: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(rawDest, "\"."));
  7378. });
  7379. return;
  7380. }
  7381. } else if (Number.isInteger(destRef)) {
  7382. pageNumber = destRef + 1;
  7383. } else {
  7384. console.error("PDFLinkService._goToDestinationHelper: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(rawDest, "\"."));
  7385. return;
  7386. }
  7387. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  7388. console.error("PDFLinkService._goToDestinationHelper: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(rawDest, "\"."));
  7389. return;
  7390. }
  7391. if (this.pdfHistory) {
  7392. this.pdfHistory.pushCurrentPosition();
  7393. this.pdfHistory.push({
  7394. namedDest: namedDest,
  7395. explicitDest: explicitDest,
  7396. pageNumber: pageNumber
  7397. });
  7398. }
  7399. this.pdfViewer.scrollPageIntoView({
  7400. pageNumber: pageNumber,
  7401. destArray: explicitDest,
  7402. ignoreDestinationZoom: this._ignoreDestinationZoom
  7403. });
  7404. }
  7405. }, {
  7406. key: "goToDestination",
  7407. value: function () {
  7408. var _goToDestination = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(dest) {
  7409. var namedDest, explicitDest;
  7410. return _regenerator["default"].wrap(function _callee$(_context) {
  7411. while (1) {
  7412. switch (_context.prev = _context.next) {
  7413. case 0:
  7414. if (this.pdfDocument) {
  7415. _context.next = 2;
  7416. break;
  7417. }
  7418. return _context.abrupt("return");
  7419. case 2:
  7420. if (!(typeof dest === "string")) {
  7421. _context.next = 9;
  7422. break;
  7423. }
  7424. namedDest = dest;
  7425. _context.next = 6;
  7426. return this.pdfDocument.getDestination(dest);
  7427. case 6:
  7428. explicitDest = _context.sent;
  7429. _context.next = 13;
  7430. break;
  7431. case 9:
  7432. namedDest = null;
  7433. _context.next = 12;
  7434. return dest;
  7435. case 12:
  7436. explicitDest = _context.sent;
  7437. case 13:
  7438. if (Array.isArray(explicitDest)) {
  7439. _context.next = 16;
  7440. break;
  7441. }
  7442. console.error("PDFLinkService.goToDestination: \"".concat(explicitDest, "\" is not ") + "a valid destination array, for dest=\"".concat(dest, "\"."));
  7443. return _context.abrupt("return");
  7444. case 16:
  7445. this._goToDestinationHelper(dest, namedDest, explicitDest);
  7446. case 17:
  7447. case "end":
  7448. return _context.stop();
  7449. }
  7450. }
  7451. }, _callee, this);
  7452. }));
  7453. function goToDestination(_x) {
  7454. return _goToDestination.apply(this, arguments);
  7455. }
  7456. return goToDestination;
  7457. }()
  7458. }, {
  7459. key: "goToPage",
  7460. value: function goToPage(val) {
  7461. if (!this.pdfDocument) {
  7462. return;
  7463. }
  7464. var pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
  7465. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  7466. console.error("PDFLinkService.goToPage: \"".concat(val, "\" is not a valid page."));
  7467. return;
  7468. }
  7469. if (this.pdfHistory) {
  7470. this.pdfHistory.pushCurrentPosition();
  7471. this.pdfHistory.pushPage(pageNumber);
  7472. }
  7473. this.pdfViewer.scrollPageIntoView({
  7474. pageNumber: pageNumber
  7475. });
  7476. }
  7477. }, {
  7478. key: "getDestinationHash",
  7479. value: function getDestinationHash(dest) {
  7480. if (typeof dest === "string") {
  7481. if (dest.length > 0) {
  7482. return this.getAnchorUrl("#" + escape(dest));
  7483. }
  7484. } else if (Array.isArray(dest)) {
  7485. var str = JSON.stringify(dest);
  7486. if (str.length > 0) {
  7487. return this.getAnchorUrl("#" + escape(str));
  7488. }
  7489. }
  7490. return this.getAnchorUrl("");
  7491. }
  7492. }, {
  7493. key: "getAnchorUrl",
  7494. value: function getAnchorUrl(anchor) {
  7495. return (this.baseUrl || "") + anchor;
  7496. }
  7497. }, {
  7498. key: "setHash",
  7499. value: function setHash(hash) {
  7500. if (!this.pdfDocument) {
  7501. return;
  7502. }
  7503. var pageNumber, dest;
  7504. if (hash.includes("=")) {
  7505. var params = (0, _ui_utils.parseQueryString)(hash);
  7506. if ("search" in params) {
  7507. this.eventBus.dispatch("findfromurlhash", {
  7508. source: this,
  7509. query: params.search.replace(/"/g, ""),
  7510. phraseSearch: params.phrase === "true"
  7511. });
  7512. }
  7513. if ("page" in params) {
  7514. pageNumber = params.page | 0 || 1;
  7515. }
  7516. if ("zoom" in params) {
  7517. var zoomArgs = params.zoom.split(",");
  7518. var zoomArg = zoomArgs[0];
  7519. var zoomArgNumber = parseFloat(zoomArg);
  7520. if (!zoomArg.includes("Fit")) {
  7521. dest = [null, {
  7522. name: "XYZ"
  7523. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  7524. } else {
  7525. if (zoomArg === "Fit" || zoomArg === "FitB") {
  7526. dest = [null, {
  7527. name: zoomArg
  7528. }];
  7529. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  7530. dest = [null, {
  7531. name: zoomArg
  7532. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  7533. } else if (zoomArg === "FitR") {
  7534. if (zoomArgs.length !== 5) {
  7535. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  7536. } else {
  7537. dest = [null, {
  7538. name: zoomArg
  7539. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  7540. }
  7541. } else {
  7542. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + "a valid zoom value.");
  7543. }
  7544. }
  7545. }
  7546. if (dest) {
  7547. this.pdfViewer.scrollPageIntoView({
  7548. pageNumber: pageNumber || this.page,
  7549. destArray: dest,
  7550. allowNegativeOffset: true
  7551. });
  7552. } else if (pageNumber) {
  7553. this.page = pageNumber;
  7554. }
  7555. if ("pagemode" in params) {
  7556. this.eventBus.dispatch("pagemode", {
  7557. source: this,
  7558. mode: params.pagemode
  7559. });
  7560. }
  7561. if ("nameddest" in params) {
  7562. this.goToDestination(params.nameddest);
  7563. }
  7564. } else {
  7565. dest = unescape(hash);
  7566. try {
  7567. dest = JSON.parse(dest);
  7568. if (!Array.isArray(dest)) {
  7569. dest = dest.toString();
  7570. }
  7571. } catch (ex) {}
  7572. if (typeof dest === "string" || isValidExplicitDestination(dest)) {
  7573. this.goToDestination(dest);
  7574. return;
  7575. }
  7576. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + "a valid destination.");
  7577. }
  7578. }
  7579. }, {
  7580. key: "executeNamedAction",
  7581. value: function executeNamedAction(action) {
  7582. switch (action) {
  7583. case "GoBack":
  7584. if (this.pdfHistory) {
  7585. this.pdfHistory.back();
  7586. }
  7587. break;
  7588. case "GoForward":
  7589. if (this.pdfHistory) {
  7590. this.pdfHistory.forward();
  7591. }
  7592. break;
  7593. case "NextPage":
  7594. this.pdfViewer.nextPage();
  7595. break;
  7596. case "PrevPage":
  7597. this.pdfViewer.previousPage();
  7598. break;
  7599. case "LastPage":
  7600. this.page = this.pagesCount;
  7601. break;
  7602. case "FirstPage":
  7603. this.page = 1;
  7604. break;
  7605. default:
  7606. break;
  7607. }
  7608. this.eventBus.dispatch("namedaction", {
  7609. source: this,
  7610. action: action
  7611. });
  7612. }
  7613. }, {
  7614. key: "cachePageRef",
  7615. value: function cachePageRef(pageNum, pageRef) {
  7616. if (!pageRef) {
  7617. return;
  7618. }
  7619. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  7620. this._pagesRefCache[refStr] = pageNum;
  7621. }
  7622. }, {
  7623. key: "_cachedPageNumber",
  7624. value: function _cachedPageNumber(pageRef) {
  7625. var _this$_pagesRefCache;
  7626. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  7627. return ((_this$_pagesRefCache = this._pagesRefCache) === null || _this$_pagesRefCache === void 0 ? void 0 : _this$_pagesRefCache[refStr]) || null;
  7628. }
  7629. }, {
  7630. key: "isPageVisible",
  7631. value: function isPageVisible(pageNumber) {
  7632. return this.pdfViewer.isPageVisible(pageNumber);
  7633. }
  7634. }, {
  7635. key: "isPageCached",
  7636. value: function isPageCached(pageNumber) {
  7637. return this.pdfViewer.isPageCached(pageNumber);
  7638. }
  7639. }]);
  7640. return PDFLinkService;
  7641. }();
  7642. exports.PDFLinkService = PDFLinkService;
  7643. function isValidExplicitDestination(dest) {
  7644. if (!Array.isArray(dest)) {
  7645. return false;
  7646. }
  7647. var destLength = dest.length;
  7648. if (destLength < 2) {
  7649. return false;
  7650. }
  7651. var page = dest[0];
  7652. if (!(_typeof(page) === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  7653. return false;
  7654. }
  7655. var zoom = dest[1];
  7656. if (!(_typeof(zoom) === "object" && typeof zoom.name === "string")) {
  7657. return false;
  7658. }
  7659. var allowNull = true;
  7660. switch (zoom.name) {
  7661. case "XYZ":
  7662. if (destLength !== 5) {
  7663. return false;
  7664. }
  7665. break;
  7666. case "Fit":
  7667. case "FitB":
  7668. return destLength === 2;
  7669. case "FitH":
  7670. case "FitBH":
  7671. case "FitV":
  7672. case "FitBV":
  7673. if (destLength !== 3) {
  7674. return false;
  7675. }
  7676. break;
  7677. case "FitR":
  7678. if (destLength !== 6) {
  7679. return false;
  7680. }
  7681. allowNull = false;
  7682. break;
  7683. default:
  7684. return false;
  7685. }
  7686. for (var i = 2; i < destLength; i++) {
  7687. var param = dest[i];
  7688. if (!(typeof param === "number" || allowNull && param === null)) {
  7689. return false;
  7690. }
  7691. }
  7692. return true;
  7693. }
  7694. var SimpleLinkService = /*#__PURE__*/function () {
  7695. function SimpleLinkService() {
  7696. _classCallCheck(this, SimpleLinkService);
  7697. this.externalLinkTarget = null;
  7698. this.externalLinkRel = null;
  7699. this.externalLinkEnabled = true;
  7700. this._ignoreDestinationZoom = false;
  7701. }
  7702. _createClass(SimpleLinkService, [{
  7703. key: "pagesCount",
  7704. get: function get() {
  7705. return 0;
  7706. }
  7707. }, {
  7708. key: "page",
  7709. get: function get() {
  7710. return 0;
  7711. },
  7712. set: function set(value) {}
  7713. }, {
  7714. key: "rotation",
  7715. get: function get() {
  7716. return 0;
  7717. },
  7718. set: function set(value) {}
  7719. }, {
  7720. key: "goToDestination",
  7721. value: function () {
  7722. var _goToDestination2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(dest) {
  7723. return _regenerator["default"].wrap(function _callee2$(_context2) {
  7724. while (1) {
  7725. switch (_context2.prev = _context2.next) {
  7726. case 0:
  7727. case "end":
  7728. return _context2.stop();
  7729. }
  7730. }
  7731. }, _callee2);
  7732. }));
  7733. function goToDestination(_x2) {
  7734. return _goToDestination2.apply(this, arguments);
  7735. }
  7736. return goToDestination;
  7737. }()
  7738. }, {
  7739. key: "goToPage",
  7740. value: function goToPage(val) {}
  7741. }, {
  7742. key: "getDestinationHash",
  7743. value: function getDestinationHash(dest) {
  7744. return "#";
  7745. }
  7746. }, {
  7747. key: "getAnchorUrl",
  7748. value: function getAnchorUrl(hash) {
  7749. return "#";
  7750. }
  7751. }, {
  7752. key: "setHash",
  7753. value: function setHash(hash) {}
  7754. }, {
  7755. key: "executeNamedAction",
  7756. value: function executeNamedAction(action) {}
  7757. }, {
  7758. key: "cachePageRef",
  7759. value: function cachePageRef(pageNum, pageRef) {}
  7760. }, {
  7761. key: "isPageVisible",
  7762. value: function isPageVisible(pageNumber) {
  7763. return true;
  7764. }
  7765. }, {
  7766. key: "isPageCached",
  7767. value: function isPageCached(pageNumber) {
  7768. return true;
  7769. }
  7770. }]);
  7771. return SimpleLinkService;
  7772. }();
  7773. exports.SimpleLinkService = SimpleLinkService;
  7774. /***/ }),
  7775. /* 22 */
  7776. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7777. 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); }
  7778. Object.defineProperty(exports, "__esModule", ({
  7779. value: true
  7780. }));
  7781. exports.PDFOutlineViewer = void 0;
  7782. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  7783. var _pdfjsLib = __webpack_require__(7);
  7784. var _base_tree_viewer = __webpack_require__(14);
  7785. var _ui_utils = __webpack_require__(6);
  7786. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7787. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  7788. 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."); }
  7789. 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; }
  7790. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  7791. 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); } }
  7792. 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); }); }; }
  7793. 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; } } }; }
  7794. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  7795. 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."); }
  7796. 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); }
  7797. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
  7798. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  7799. 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; }
  7800. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7801. 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); } }
  7802. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7803. 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); }
  7804. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  7805. 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); }
  7806. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7807. 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); }; }
  7808. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7809. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7810. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  7811. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7812. var PDFOutlineViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  7813. _inherits(PDFOutlineViewer, _BaseTreeViewer);
  7814. var _super = _createSuper(PDFOutlineViewer);
  7815. function PDFOutlineViewer(options) {
  7816. var _this;
  7817. _classCallCheck(this, PDFOutlineViewer);
  7818. _this = _super.call(this, options);
  7819. _this.linkService = options.linkService;
  7820. _this.eventBus._on("toggleoutlinetree", _this._toggleAllTreeItems.bind(_assertThisInitialized(_this)));
  7821. _this.eventBus._on("currentoutlineitem", _this._currentOutlineItem.bind(_assertThisInitialized(_this)));
  7822. _this.eventBus._on("pagechanging", function (evt) {
  7823. _this._currentPageNumber = evt.pageNumber;
  7824. });
  7825. _this.eventBus._on("pagesloaded", function (evt) {
  7826. _this._isPagesLoaded = !!evt.pagesCount;
  7827. });
  7828. _this.eventBus._on("sidebarviewchanged", function (evt) {
  7829. _this._sidebarView = evt.view;
  7830. });
  7831. return _this;
  7832. }
  7833. _createClass(PDFOutlineViewer, [{
  7834. key: "reset",
  7835. value: function reset() {
  7836. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "reset", this).call(this);
  7837. this._outline = null;
  7838. this._pageNumberToDestHashCapability = null;
  7839. this._currentPageNumber = 1;
  7840. this._isPagesLoaded = false;
  7841. }
  7842. }, {
  7843. key: "_dispatchEvent",
  7844. value: function _dispatchEvent(outlineCount) {
  7845. var _this$_pdfDocument;
  7846. this.eventBus.dispatch("outlineloaded", {
  7847. source: this,
  7848. outlineCount: outlineCount,
  7849. enableCurrentOutlineItemButton: outlineCount > 0 && !((_this$_pdfDocument = this._pdfDocument) !== null && _this$_pdfDocument !== void 0 && _this$_pdfDocument.loadingParams.disableAutoFetch)
  7850. });
  7851. }
  7852. }, {
  7853. key: "_bindLink",
  7854. value: function _bindLink(element, _ref) {
  7855. var _this2 = this;
  7856. var url = _ref.url,
  7857. newWindow = _ref.newWindow,
  7858. dest = _ref.dest;
  7859. var linkService = this.linkService;
  7860. if (url) {
  7861. (0, _pdfjsLib.addLinkAttributes)(element, {
  7862. url: url,
  7863. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
  7864. rel: linkService.externalLinkRel,
  7865. enabled: linkService.externalLinkEnabled
  7866. });
  7867. return;
  7868. }
  7869. element.href = linkService.getDestinationHash(dest);
  7870. element.onclick = function (evt) {
  7871. _this2._updateCurrentTreeItem(evt.target.parentNode);
  7872. if (dest) {
  7873. linkService.goToDestination(dest);
  7874. }
  7875. return false;
  7876. };
  7877. }
  7878. }, {
  7879. key: "_setStyles",
  7880. value: function _setStyles(element, _ref2) {
  7881. var bold = _ref2.bold,
  7882. italic = _ref2.italic;
  7883. if (bold) {
  7884. element.style.fontWeight = "bold";
  7885. }
  7886. if (italic) {
  7887. element.style.fontStyle = "italic";
  7888. }
  7889. }
  7890. }, {
  7891. key: "_addToggleButton",
  7892. value: function _addToggleButton(div, _ref3) {
  7893. var count = _ref3.count,
  7894. items = _ref3.items;
  7895. var hidden = false;
  7896. if (count < 0) {
  7897. var totalCount = items.length;
  7898. if (totalCount > 0) {
  7899. var queue = _toConsumableArray(items);
  7900. while (queue.length > 0) {
  7901. var _queue$shift = queue.shift(),
  7902. nestedCount = _queue$shift.count,
  7903. nestedItems = _queue$shift.items;
  7904. if (nestedCount > 0 && nestedItems.length > 0) {
  7905. totalCount += nestedItems.length;
  7906. queue.push.apply(queue, _toConsumableArray(nestedItems));
  7907. }
  7908. }
  7909. }
  7910. if (Math.abs(count) === totalCount) {
  7911. hidden = true;
  7912. }
  7913. }
  7914. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "_addToggleButton", this).call(this, div, hidden);
  7915. }
  7916. }, {
  7917. key: "_toggleAllTreeItems",
  7918. value: function _toggleAllTreeItems() {
  7919. if (!this._outline) {
  7920. return;
  7921. }
  7922. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "_toggleAllTreeItems", this).call(this);
  7923. }
  7924. }, {
  7925. key: "render",
  7926. value: function render(_ref4) {
  7927. var outline = _ref4.outline,
  7928. pdfDocument = _ref4.pdfDocument;
  7929. if (this._outline) {
  7930. this.reset();
  7931. }
  7932. this._outline = outline || null;
  7933. this._pdfDocument = pdfDocument || null;
  7934. if (!outline) {
  7935. this._dispatchEvent(0);
  7936. return;
  7937. }
  7938. var fragment = document.createDocumentFragment();
  7939. var queue = [{
  7940. parent: fragment,
  7941. items: outline
  7942. }];
  7943. var outlineCount = 0,
  7944. hasAnyNesting = false;
  7945. while (queue.length > 0) {
  7946. var levelData = queue.shift();
  7947. var _iterator = _createForOfIteratorHelper(levelData.items),
  7948. _step;
  7949. try {
  7950. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7951. var item = _step.value;
  7952. var div = document.createElement("div");
  7953. div.className = "treeItem";
  7954. var element = document.createElement("a");
  7955. this._bindLink(element, item);
  7956. this._setStyles(element, item);
  7957. element.textContent = this._normalizeTextContent(item.title);
  7958. div.appendChild(element);
  7959. if (item.items.length > 0) {
  7960. hasAnyNesting = true;
  7961. this._addToggleButton(div, item);
  7962. var itemsDiv = document.createElement("div");
  7963. itemsDiv.className = "treeItems";
  7964. div.appendChild(itemsDiv);
  7965. queue.push({
  7966. parent: itemsDiv,
  7967. items: item.items
  7968. });
  7969. }
  7970. levelData.parent.appendChild(div);
  7971. outlineCount++;
  7972. }
  7973. } catch (err) {
  7974. _iterator.e(err);
  7975. } finally {
  7976. _iterator.f();
  7977. }
  7978. }
  7979. this._finishRendering(fragment, outlineCount, hasAnyNesting);
  7980. }
  7981. }, {
  7982. key: "_currentOutlineItem",
  7983. value: function () {
  7984. var _currentOutlineItem2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  7985. var pageNumberToDestHash, i, destHash, linkElement;
  7986. return _regenerator["default"].wrap(function _callee$(_context) {
  7987. while (1) {
  7988. switch (_context.prev = _context.next) {
  7989. case 0:
  7990. if (this._isPagesLoaded) {
  7991. _context.next = 2;
  7992. break;
  7993. }
  7994. throw new Error("_currentOutlineItem: All pages have not been loaded.");
  7995. case 2:
  7996. if (!(!this._outline || !this._pdfDocument)) {
  7997. _context.next = 4;
  7998. break;
  7999. }
  8000. return _context.abrupt("return");
  8001. case 4:
  8002. _context.next = 6;
  8003. return this._getPageNumberToDestHash(this._pdfDocument);
  8004. case 6:
  8005. pageNumberToDestHash = _context.sent;
  8006. if (pageNumberToDestHash) {
  8007. _context.next = 9;
  8008. break;
  8009. }
  8010. return _context.abrupt("return");
  8011. case 9:
  8012. this._updateCurrentTreeItem(null);
  8013. if (!(this._sidebarView !== _ui_utils.SidebarView.OUTLINE)) {
  8014. _context.next = 12;
  8015. break;
  8016. }
  8017. return _context.abrupt("return");
  8018. case 12:
  8019. i = this._currentPageNumber;
  8020. case 13:
  8021. if (!(i > 0)) {
  8022. _context.next = 25;
  8023. break;
  8024. }
  8025. destHash = pageNumberToDestHash.get(i);
  8026. if (destHash) {
  8027. _context.next = 17;
  8028. break;
  8029. }
  8030. return _context.abrupt("continue", 22);
  8031. case 17:
  8032. linkElement = this.container.querySelector("a[href=\"".concat(destHash, "\"]"));
  8033. if (linkElement) {
  8034. _context.next = 20;
  8035. break;
  8036. }
  8037. return _context.abrupt("continue", 22);
  8038. case 20:
  8039. this._scrollToCurrentTreeItem(linkElement.parentNode);
  8040. return _context.abrupt("break", 25);
  8041. case 22:
  8042. i--;
  8043. _context.next = 13;
  8044. break;
  8045. case 25:
  8046. case "end":
  8047. return _context.stop();
  8048. }
  8049. }
  8050. }, _callee, this);
  8051. }));
  8052. function _currentOutlineItem() {
  8053. return _currentOutlineItem2.apply(this, arguments);
  8054. }
  8055. return _currentOutlineItem;
  8056. }()
  8057. }, {
  8058. key: "_getPageNumberToDestHash",
  8059. value: function () {
  8060. var _getPageNumberToDestHash2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pdfDocument) {
  8061. var pageNumberToDestHash, pageNumberNesting, queue, levelData, currentNesting, _iterator2, _step2, _step2$value, dest, items, explicitDest, pageNumber, _explicitDest, _explicitDest2, destRef, destHash;
  8062. return _regenerator["default"].wrap(function _callee2$(_context2) {
  8063. while (1) {
  8064. switch (_context2.prev = _context2.next) {
  8065. case 0:
  8066. if (!this._pageNumberToDestHashCapability) {
  8067. _context2.next = 2;
  8068. break;
  8069. }
  8070. return _context2.abrupt("return", this._pageNumberToDestHashCapability.promise);
  8071. case 2:
  8072. this._pageNumberToDestHashCapability = (0, _pdfjsLib.createPromiseCapability)();
  8073. pageNumberToDestHash = new Map(), pageNumberNesting = new Map();
  8074. queue = [{
  8075. nesting: 0,
  8076. items: this._outline
  8077. }];
  8078. case 5:
  8079. if (!(queue.length > 0)) {
  8080. _context2.next = 56;
  8081. break;
  8082. }
  8083. levelData = queue.shift(), currentNesting = levelData.nesting;
  8084. _iterator2 = _createForOfIteratorHelper(levelData.items);
  8085. _context2.prev = 8;
  8086. _iterator2.s();
  8087. case 10:
  8088. if ((_step2 = _iterator2.n()).done) {
  8089. _context2.next = 46;
  8090. break;
  8091. }
  8092. _step2$value = _step2.value, dest = _step2$value.dest, items = _step2$value.items;
  8093. explicitDest = void 0, pageNumber = void 0;
  8094. if (!(typeof dest === "string")) {
  8095. _context2.next = 21;
  8096. break;
  8097. }
  8098. _context2.next = 16;
  8099. return pdfDocument.getDestination(dest);
  8100. case 16:
  8101. explicitDest = _context2.sent;
  8102. if (!(pdfDocument !== this._pdfDocument)) {
  8103. _context2.next = 19;
  8104. break;
  8105. }
  8106. return _context2.abrupt("return", null);
  8107. case 19:
  8108. _context2.next = 22;
  8109. break;
  8110. case 21:
  8111. explicitDest = dest;
  8112. case 22:
  8113. if (!Array.isArray(explicitDest)) {
  8114. _context2.next = 43;
  8115. break;
  8116. }
  8117. _explicitDest = explicitDest, _explicitDest2 = _slicedToArray(_explicitDest, 1), destRef = _explicitDest2[0];
  8118. if (!(destRef instanceof Object)) {
  8119. _context2.next = 41;
  8120. break;
  8121. }
  8122. pageNumber = this.linkService._cachedPageNumber(destRef);
  8123. if (pageNumber) {
  8124. _context2.next = 39;
  8125. break;
  8126. }
  8127. _context2.prev = 27;
  8128. _context2.next = 30;
  8129. return pdfDocument.getPageIndex(destRef);
  8130. case 30:
  8131. _context2.t0 = _context2.sent;
  8132. pageNumber = _context2.t0 + 1;
  8133. if (!(pdfDocument !== this._pdfDocument)) {
  8134. _context2.next = 34;
  8135. break;
  8136. }
  8137. return _context2.abrupt("return", null);
  8138. case 34:
  8139. this.linkService.cachePageRef(pageNumber, destRef);
  8140. _context2.next = 39;
  8141. break;
  8142. case 37:
  8143. _context2.prev = 37;
  8144. _context2.t1 = _context2["catch"](27);
  8145. case 39:
  8146. _context2.next = 42;
  8147. break;
  8148. case 41:
  8149. if (Number.isInteger(destRef)) {
  8150. pageNumber = destRef + 1;
  8151. }
  8152. case 42:
  8153. if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) {
  8154. destHash = this.linkService.getDestinationHash(dest);
  8155. pageNumberToDestHash.set(pageNumber, destHash);
  8156. pageNumberNesting.set(pageNumber, currentNesting);
  8157. }
  8158. case 43:
  8159. if (items.length > 0) {
  8160. queue.push({
  8161. nesting: currentNesting + 1,
  8162. items: items
  8163. });
  8164. }
  8165. case 44:
  8166. _context2.next = 10;
  8167. break;
  8168. case 46:
  8169. _context2.next = 51;
  8170. break;
  8171. case 48:
  8172. _context2.prev = 48;
  8173. _context2.t2 = _context2["catch"](8);
  8174. _iterator2.e(_context2.t2);
  8175. case 51:
  8176. _context2.prev = 51;
  8177. _iterator2.f();
  8178. return _context2.finish(51);
  8179. case 54:
  8180. _context2.next = 5;
  8181. break;
  8182. case 56:
  8183. this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null);
  8184. return _context2.abrupt("return", this._pageNumberToDestHashCapability.promise);
  8185. case 58:
  8186. case "end":
  8187. return _context2.stop();
  8188. }
  8189. }
  8190. }, _callee2, this, [[8, 48, 51, 54], [27, 37]]);
  8191. }));
  8192. function _getPageNumberToDestHash(_x) {
  8193. return _getPageNumberToDestHash2.apply(this, arguments);
  8194. }
  8195. return _getPageNumberToDestHash;
  8196. }()
  8197. }]);
  8198. return PDFOutlineViewer;
  8199. }(_base_tree_viewer.BaseTreeViewer);
  8200. exports.PDFOutlineViewer = PDFOutlineViewer;
  8201. /***/ }),
  8202. /* 23 */
  8203. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8204. Object.defineProperty(exports, "__esModule", ({
  8205. value: true
  8206. }));
  8207. exports.PDFPresentationMode = void 0;
  8208. var _ui_utils = __webpack_require__(6);
  8209. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8210. 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); } }
  8211. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8212. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  8213. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  8214. var ACTIVE_SELECTOR = "pdfPresentationMode";
  8215. var CONTROLS_SELECTOR = "pdfPresentationModeControls";
  8216. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  8217. var PAGE_SWITCH_THRESHOLD = 0.1;
  8218. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  8219. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  8220. var PDFPresentationMode = /*#__PURE__*/function () {
  8221. function PDFPresentationMode(_ref) {
  8222. var container = _ref.container,
  8223. pdfViewer = _ref.pdfViewer,
  8224. eventBus = _ref.eventBus;
  8225. _classCallCheck(this, PDFPresentationMode);
  8226. this.container = container;
  8227. this.pdfViewer = pdfViewer;
  8228. this.eventBus = eventBus;
  8229. this.active = false;
  8230. this.args = null;
  8231. this.contextMenuOpen = false;
  8232. this.mouseScrollTimeStamp = 0;
  8233. this.mouseScrollDelta = 0;
  8234. this.touchSwipeState = null;
  8235. }
  8236. _createClass(PDFPresentationMode, [{
  8237. key: "request",
  8238. value: function request() {
  8239. if (this.switchInProgress || this.active || !this.pdfViewer.pagesCount) {
  8240. return false;
  8241. }
  8242. this._addFullscreenChangeListeners();
  8243. this._setSwitchInProgress();
  8244. this._notifyStateChange();
  8245. if (this.container.requestFullscreen) {
  8246. this.container.requestFullscreen();
  8247. } else if (this.container.mozRequestFullScreen) {
  8248. this.container.mozRequestFullScreen();
  8249. } else if (this.container.webkitRequestFullscreen) {
  8250. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  8251. } else {
  8252. return false;
  8253. }
  8254. this.args = {
  8255. page: this.pdfViewer.currentPageNumber,
  8256. previousScale: this.pdfViewer.currentScaleValue
  8257. };
  8258. return true;
  8259. }
  8260. }, {
  8261. key: "_mouseWheel",
  8262. value: function _mouseWheel(evt) {
  8263. if (!this.active) {
  8264. return;
  8265. }
  8266. evt.preventDefault();
  8267. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  8268. var currentTime = Date.now();
  8269. var storedTime = this.mouseScrollTimeStamp;
  8270. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  8271. return;
  8272. }
  8273. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  8274. this._resetMouseScrollState();
  8275. }
  8276. this.mouseScrollDelta += delta;
  8277. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  8278. var totalDelta = this.mouseScrollDelta;
  8279. this._resetMouseScrollState();
  8280. var success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage();
  8281. if (success) {
  8282. this.mouseScrollTimeStamp = currentTime;
  8283. }
  8284. }
  8285. }
  8286. }, {
  8287. key: "isFullscreen",
  8288. get: function get() {
  8289. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen);
  8290. }
  8291. }, {
  8292. key: "_notifyStateChange",
  8293. value: function _notifyStateChange() {
  8294. var state = _ui_utils.PresentationModeState.NORMAL;
  8295. if (this.switchInProgress) {
  8296. state = _ui_utils.PresentationModeState.CHANGING;
  8297. } else if (this.active) {
  8298. state = _ui_utils.PresentationModeState.FULLSCREEN;
  8299. }
  8300. this.eventBus.dispatch("presentationmodechanged", {
  8301. source: this,
  8302. state: state,
  8303. get active() {
  8304. throw new Error("Deprecated parameter: `active`, please use `state` instead.");
  8305. },
  8306. get switchInProgress() {
  8307. throw new Error("Deprecated parameter: `switchInProgress`, please use `state` instead.");
  8308. }
  8309. });
  8310. }
  8311. }, {
  8312. key: "_setSwitchInProgress",
  8313. value: function _setSwitchInProgress() {
  8314. var _this = this;
  8315. if (this.switchInProgress) {
  8316. clearTimeout(this.switchInProgress);
  8317. }
  8318. this.switchInProgress = setTimeout(function () {
  8319. _this._removeFullscreenChangeListeners();
  8320. delete _this.switchInProgress;
  8321. _this._notifyStateChange();
  8322. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  8323. }
  8324. }, {
  8325. key: "_resetSwitchInProgress",
  8326. value: function _resetSwitchInProgress() {
  8327. if (this.switchInProgress) {
  8328. clearTimeout(this.switchInProgress);
  8329. delete this.switchInProgress;
  8330. }
  8331. }
  8332. }, {
  8333. key: "_enter",
  8334. value: function _enter() {
  8335. var _this2 = this;
  8336. this.active = true;
  8337. this._resetSwitchInProgress();
  8338. this._notifyStateChange();
  8339. this.container.classList.add(ACTIVE_SELECTOR);
  8340. setTimeout(function () {
  8341. _this2.pdfViewer.currentPageNumber = _this2.args.page;
  8342. _this2.pdfViewer.currentScaleValue = "page-fit";
  8343. }, 0);
  8344. this._addWindowListeners();
  8345. this._showControls();
  8346. this.contextMenuOpen = false;
  8347. window.getSelection().removeAllRanges();
  8348. }
  8349. }, {
  8350. key: "_exit",
  8351. value: function _exit() {
  8352. var _this3 = this;
  8353. var page = this.pdfViewer.currentPageNumber;
  8354. this.container.classList.remove(ACTIVE_SELECTOR);
  8355. setTimeout(function () {
  8356. _this3.active = false;
  8357. _this3._removeFullscreenChangeListeners();
  8358. _this3._notifyStateChange();
  8359. _this3.pdfViewer.currentScaleValue = _this3.args.previousScale;
  8360. _this3.pdfViewer.currentPageNumber = page;
  8361. _this3.args = null;
  8362. }, 0);
  8363. this._removeWindowListeners();
  8364. this._hideControls();
  8365. this._resetMouseScrollState();
  8366. this.contextMenuOpen = false;
  8367. }
  8368. }, {
  8369. key: "_mouseDown",
  8370. value: function _mouseDown(evt) {
  8371. if (this.contextMenuOpen) {
  8372. this.contextMenuOpen = false;
  8373. evt.preventDefault();
  8374. return;
  8375. }
  8376. if (evt.button === 0) {
  8377. var isInternalLink = evt.target.href && evt.target.classList.contains("internalLink");
  8378. if (!isInternalLink) {
  8379. evt.preventDefault();
  8380. if (evt.shiftKey) {
  8381. this.pdfViewer.previousPage();
  8382. } else {
  8383. this.pdfViewer.nextPage();
  8384. }
  8385. }
  8386. }
  8387. }
  8388. }, {
  8389. key: "_contextMenu",
  8390. value: function _contextMenu() {
  8391. this.contextMenuOpen = true;
  8392. }
  8393. }, {
  8394. key: "_showControls",
  8395. value: function _showControls() {
  8396. var _this4 = this;
  8397. if (this.controlsTimeout) {
  8398. clearTimeout(this.controlsTimeout);
  8399. } else {
  8400. this.container.classList.add(CONTROLS_SELECTOR);
  8401. }
  8402. this.controlsTimeout = setTimeout(function () {
  8403. _this4.container.classList.remove(CONTROLS_SELECTOR);
  8404. delete _this4.controlsTimeout;
  8405. }, DELAY_BEFORE_HIDING_CONTROLS);
  8406. }
  8407. }, {
  8408. key: "_hideControls",
  8409. value: function _hideControls() {
  8410. if (!this.controlsTimeout) {
  8411. return;
  8412. }
  8413. clearTimeout(this.controlsTimeout);
  8414. this.container.classList.remove(CONTROLS_SELECTOR);
  8415. delete this.controlsTimeout;
  8416. }
  8417. }, {
  8418. key: "_resetMouseScrollState",
  8419. value: function _resetMouseScrollState() {
  8420. this.mouseScrollTimeStamp = 0;
  8421. this.mouseScrollDelta = 0;
  8422. }
  8423. }, {
  8424. key: "_touchSwipe",
  8425. value: function _touchSwipe(evt) {
  8426. if (!this.active) {
  8427. return;
  8428. }
  8429. if (evt.touches.length > 1) {
  8430. this.touchSwipeState = null;
  8431. return;
  8432. }
  8433. switch (evt.type) {
  8434. case "touchstart":
  8435. this.touchSwipeState = {
  8436. startX: evt.touches[0].pageX,
  8437. startY: evt.touches[0].pageY,
  8438. endX: evt.touches[0].pageX,
  8439. endY: evt.touches[0].pageY
  8440. };
  8441. break;
  8442. case "touchmove":
  8443. if (this.touchSwipeState === null) {
  8444. return;
  8445. }
  8446. this.touchSwipeState.endX = evt.touches[0].pageX;
  8447. this.touchSwipeState.endY = evt.touches[0].pageY;
  8448. evt.preventDefault();
  8449. break;
  8450. case "touchend":
  8451. if (this.touchSwipeState === null) {
  8452. return;
  8453. }
  8454. var delta = 0;
  8455. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  8456. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  8457. var absAngle = Math.abs(Math.atan2(dy, dx));
  8458. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  8459. delta = dx;
  8460. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  8461. delta = dy;
  8462. }
  8463. if (delta > 0) {
  8464. this.pdfViewer.previousPage();
  8465. } else if (delta < 0) {
  8466. this.pdfViewer.nextPage();
  8467. }
  8468. break;
  8469. }
  8470. }
  8471. }, {
  8472. key: "_addWindowListeners",
  8473. value: function _addWindowListeners() {
  8474. this.showControlsBind = this._showControls.bind(this);
  8475. this.mouseDownBind = this._mouseDown.bind(this);
  8476. this.mouseWheelBind = this._mouseWheel.bind(this);
  8477. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  8478. this.contextMenuBind = this._contextMenu.bind(this);
  8479. this.touchSwipeBind = this._touchSwipe.bind(this);
  8480. window.addEventListener("mousemove", this.showControlsBind);
  8481. window.addEventListener("mousedown", this.mouseDownBind);
  8482. window.addEventListener("wheel", this.mouseWheelBind, {
  8483. passive: false
  8484. });
  8485. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  8486. window.addEventListener("contextmenu", this.contextMenuBind);
  8487. window.addEventListener("touchstart", this.touchSwipeBind);
  8488. window.addEventListener("touchmove", this.touchSwipeBind);
  8489. window.addEventListener("touchend", this.touchSwipeBind);
  8490. }
  8491. }, {
  8492. key: "_removeWindowListeners",
  8493. value: function _removeWindowListeners() {
  8494. window.removeEventListener("mousemove", this.showControlsBind);
  8495. window.removeEventListener("mousedown", this.mouseDownBind);
  8496. window.removeEventListener("wheel", this.mouseWheelBind, {
  8497. passive: false
  8498. });
  8499. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  8500. window.removeEventListener("contextmenu", this.contextMenuBind);
  8501. window.removeEventListener("touchstart", this.touchSwipeBind);
  8502. window.removeEventListener("touchmove", this.touchSwipeBind);
  8503. window.removeEventListener("touchend", this.touchSwipeBind);
  8504. delete this.showControlsBind;
  8505. delete this.mouseDownBind;
  8506. delete this.mouseWheelBind;
  8507. delete this.resetMouseScrollStateBind;
  8508. delete this.contextMenuBind;
  8509. delete this.touchSwipeBind;
  8510. }
  8511. }, {
  8512. key: "_fullscreenChange",
  8513. value: function _fullscreenChange() {
  8514. if (this.isFullscreen) {
  8515. this._enter();
  8516. } else {
  8517. this._exit();
  8518. }
  8519. }
  8520. }, {
  8521. key: "_addFullscreenChangeListeners",
  8522. value: function _addFullscreenChangeListeners() {
  8523. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  8524. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  8525. window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  8526. window.addEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  8527. }
  8528. }, {
  8529. key: "_removeFullscreenChangeListeners",
  8530. value: function _removeFullscreenChangeListeners() {
  8531. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  8532. window.removeEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  8533. window.removeEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  8534. delete this.fullscreenChangeBind;
  8535. }
  8536. }]);
  8537. return PDFPresentationMode;
  8538. }();
  8539. exports.PDFPresentationMode = PDFPresentationMode;
  8540. /***/ }),
  8541. /* 24 */
  8542. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8543. Object.defineProperty(exports, "__esModule", ({
  8544. value: true
  8545. }));
  8546. exports.PDFScriptingManager = void 0;
  8547. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  8548. var _pdfjsLib = __webpack_require__(7);
  8549. var _ui_utils = __webpack_require__(6);
  8550. var _pdf_rendering_queue = __webpack_require__(10);
  8551. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8552. 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; }
  8553. 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; }
  8554. 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; }
  8555. 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; } } }; }
  8556. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  8557. 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."); }
  8558. 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); }
  8559. 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; }
  8560. 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; }
  8561. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  8562. 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); } }
  8563. 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); }); }; }
  8564. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8565. 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); } }
  8566. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8567. var PDFScriptingManager = /*#__PURE__*/function () {
  8568. function PDFScriptingManager(_ref) {
  8569. var eventBus = _ref.eventBus,
  8570. _ref$sandboxBundleSrc = _ref.sandboxBundleSrc,
  8571. sandboxBundleSrc = _ref$sandboxBundleSrc === void 0 ? null : _ref$sandboxBundleSrc,
  8572. _ref$scriptingFactory = _ref.scriptingFactory,
  8573. scriptingFactory = _ref$scriptingFactory === void 0 ? null : _ref$scriptingFactory,
  8574. _ref$docPropertiesLoo = _ref.docPropertiesLookup,
  8575. docPropertiesLookup = _ref$docPropertiesLoo === void 0 ? null : _ref$docPropertiesLoo;
  8576. _classCallCheck(this, PDFScriptingManager);
  8577. this._pdfDocument = null;
  8578. this._pdfViewer = null;
  8579. this._closeCapability = null;
  8580. this._destroyCapability = null;
  8581. this._scripting = null;
  8582. this._mouseState = Object.create(null);
  8583. this._pageEventsReady = false;
  8584. this._ready = false;
  8585. this._eventBus = eventBus;
  8586. this._sandboxBundleSrc = sandboxBundleSrc;
  8587. this._scriptingFactory = scriptingFactory;
  8588. this._docPropertiesLookup = docPropertiesLookup;
  8589. }
  8590. _createClass(PDFScriptingManager, [{
  8591. key: "setViewer",
  8592. value: function setViewer(pdfViewer) {
  8593. this._pdfViewer = pdfViewer;
  8594. }
  8595. }, {
  8596. key: "setDocument",
  8597. value: function () {
  8598. var _setDocument = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pdfDocument) {
  8599. var _this = this,
  8600. _this$_scripting3;
  8601. var _yield$Promise$all, _yield$Promise$all2, objects, calculationOrder, docActions, _iterator, _step, _step$value, name, listener, _iterator2, _step2, _step2$value, _name, _listener, docProperties;
  8602. return _regenerator["default"].wrap(function _callee2$(_context2) {
  8603. while (1) {
  8604. switch (_context2.prev = _context2.next) {
  8605. case 0:
  8606. if (!this._pdfDocument) {
  8607. _context2.next = 3;
  8608. break;
  8609. }
  8610. _context2.next = 3;
  8611. return this._destroyScripting();
  8612. case 3:
  8613. this._pdfDocument = pdfDocument;
  8614. if (pdfDocument) {
  8615. _context2.next = 6;
  8616. break;
  8617. }
  8618. return _context2.abrupt("return");
  8619. case 6:
  8620. _context2.next = 8;
  8621. return Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
  8622. case 8:
  8623. _yield$Promise$all = _context2.sent;
  8624. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
  8625. objects = _yield$Promise$all2[0];
  8626. calculationOrder = _yield$Promise$all2[1];
  8627. docActions = _yield$Promise$all2[2];
  8628. if (!(!objects && !docActions)) {
  8629. _context2.next = 17;
  8630. break;
  8631. }
  8632. _context2.next = 16;
  8633. return this._destroyScripting();
  8634. case 16:
  8635. return _context2.abrupt("return");
  8636. case 17:
  8637. if (!(pdfDocument !== this._pdfDocument)) {
  8638. _context2.next = 19;
  8639. break;
  8640. }
  8641. return _context2.abrupt("return");
  8642. case 19:
  8643. this._scripting = this._createScripting();
  8644. this._internalEvents.set("updatefromsandbox", function (event) {
  8645. if ((event === null || event === void 0 ? void 0 : event.source) !== window) {
  8646. return;
  8647. }
  8648. _this._updateFromSandbox(event.detail);
  8649. });
  8650. this._internalEvents.set("dispatcheventinsandbox", function (event) {
  8651. var _this$_scripting;
  8652. (_this$_scripting = _this._scripting) === null || _this$_scripting === void 0 ? void 0 : _this$_scripting.dispatchEventInSandbox(event.detail);
  8653. });
  8654. this._internalEvents.set("pagechanging", function (_ref2) {
  8655. var pageNumber = _ref2.pageNumber,
  8656. previous = _ref2.previous;
  8657. if (pageNumber === previous) {
  8658. return;
  8659. }
  8660. _this._dispatchPageClose(previous);
  8661. _this._dispatchPageOpen(pageNumber);
  8662. });
  8663. this._internalEvents.set("pagerendered", function (_ref3) {
  8664. var pageNumber = _ref3.pageNumber;
  8665. if (!_this._pageOpenPending.has(pageNumber)) {
  8666. return;
  8667. }
  8668. if (pageNumber !== _this._pdfViewer.currentPageNumber) {
  8669. return;
  8670. }
  8671. _this._dispatchPageOpen(pageNumber);
  8672. });
  8673. this._internalEvents.set("pagesdestroy", /*#__PURE__*/function () {
  8674. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(event) {
  8675. var _this$_scripting2, _this$_closeCapabilit;
  8676. return _regenerator["default"].wrap(function _callee$(_context) {
  8677. while (1) {
  8678. switch (_context.prev = _context.next) {
  8679. case 0:
  8680. _context.next = 2;
  8681. return _this._dispatchPageClose(_this._pdfViewer.currentPageNumber);
  8682. case 2:
  8683. _context.next = 4;
  8684. return (_this$_scripting2 = _this._scripting) === null || _this$_scripting2 === void 0 ? void 0 : _this$_scripting2.dispatchEventInSandbox({
  8685. id: "doc",
  8686. name: "WillClose"
  8687. });
  8688. case 4:
  8689. (_this$_closeCapabilit = _this._closeCapability) === null || _this$_closeCapabilit === void 0 ? void 0 : _this$_closeCapabilit.resolve();
  8690. case 5:
  8691. case "end":
  8692. return _context.stop();
  8693. }
  8694. }
  8695. }, _callee);
  8696. }));
  8697. return function (_x2) {
  8698. return _ref4.apply(this, arguments);
  8699. };
  8700. }());
  8701. this._domEvents.set("mousedown", function (event) {
  8702. _this._mouseState.isDown = true;
  8703. });
  8704. this._domEvents.set("mouseup", function (event) {
  8705. _this._mouseState.isDown = false;
  8706. });
  8707. _iterator = _createForOfIteratorHelper(this._internalEvents);
  8708. try {
  8709. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8710. _step$value = _slicedToArray(_step.value, 2), name = _step$value[0], listener = _step$value[1];
  8711. this._eventBus._on(name, listener);
  8712. }
  8713. } catch (err) {
  8714. _iterator.e(err);
  8715. } finally {
  8716. _iterator.f();
  8717. }
  8718. _iterator2 = _createForOfIteratorHelper(this._domEvents);
  8719. try {
  8720. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  8721. _step2$value = _slicedToArray(_step2.value, 2), _name = _step2$value[0], _listener = _step2$value[1];
  8722. window.addEventListener(_name, _listener);
  8723. }
  8724. } catch (err) {
  8725. _iterator2.e(err);
  8726. } finally {
  8727. _iterator2.f();
  8728. }
  8729. _context2.prev = 31;
  8730. _context2.next = 34;
  8731. return this._getDocProperties();
  8732. case 34:
  8733. docProperties = _context2.sent;
  8734. if (!(pdfDocument !== this._pdfDocument)) {
  8735. _context2.next = 37;
  8736. break;
  8737. }
  8738. return _context2.abrupt("return");
  8739. case 37:
  8740. _context2.next = 39;
  8741. return this._scripting.createSandbox({
  8742. objects: objects,
  8743. calculationOrder: calculationOrder,
  8744. appInfo: {
  8745. platform: navigator.platform,
  8746. language: navigator.language
  8747. },
  8748. docInfo: _objectSpread(_objectSpread({}, docProperties), {}, {
  8749. actions: docActions
  8750. })
  8751. });
  8752. case 39:
  8753. this._eventBus.dispatch("sandboxcreated", {
  8754. source: this
  8755. });
  8756. _context2.next = 48;
  8757. break;
  8758. case 42:
  8759. _context2.prev = 42;
  8760. _context2.t0 = _context2["catch"](31);
  8761. console.error("PDFScriptingManager.setDocument: \"".concat(_context2.t0 === null || _context2.t0 === void 0 ? void 0 : _context2.t0.message, "\"."));
  8762. _context2.next = 47;
  8763. return this._destroyScripting();
  8764. case 47:
  8765. return _context2.abrupt("return");
  8766. case 48:
  8767. _context2.next = 50;
  8768. return (_this$_scripting3 = this._scripting) === null || _this$_scripting3 === void 0 ? void 0 : _this$_scripting3.dispatchEventInSandbox({
  8769. id: "doc",
  8770. name: "Open"
  8771. });
  8772. case 50:
  8773. _context2.next = 52;
  8774. return this._dispatchPageOpen(this._pdfViewer.currentPageNumber, true);
  8775. case 52:
  8776. Promise.resolve().then(function () {
  8777. if (pdfDocument === _this._pdfDocument) {
  8778. _this._ready = true;
  8779. }
  8780. });
  8781. case 53:
  8782. case "end":
  8783. return _context2.stop();
  8784. }
  8785. }
  8786. }, _callee2, this, [[31, 42]]);
  8787. }));
  8788. function setDocument(_x) {
  8789. return _setDocument.apply(this, arguments);
  8790. }
  8791. return setDocument;
  8792. }()
  8793. }, {
  8794. key: "dispatchWillSave",
  8795. value: function () {
  8796. var _dispatchWillSave = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(detail) {
  8797. var _this$_scripting4;
  8798. return _regenerator["default"].wrap(function _callee3$(_context3) {
  8799. while (1) {
  8800. switch (_context3.prev = _context3.next) {
  8801. case 0:
  8802. return _context3.abrupt("return", (_this$_scripting4 = this._scripting) === null || _this$_scripting4 === void 0 ? void 0 : _this$_scripting4.dispatchEventInSandbox({
  8803. id: "doc",
  8804. name: "WillSave"
  8805. }));
  8806. case 1:
  8807. case "end":
  8808. return _context3.stop();
  8809. }
  8810. }
  8811. }, _callee3, this);
  8812. }));
  8813. function dispatchWillSave(_x3) {
  8814. return _dispatchWillSave.apply(this, arguments);
  8815. }
  8816. return dispatchWillSave;
  8817. }()
  8818. }, {
  8819. key: "dispatchDidSave",
  8820. value: function () {
  8821. var _dispatchDidSave = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(detail) {
  8822. var _this$_scripting5;
  8823. return _regenerator["default"].wrap(function _callee4$(_context4) {
  8824. while (1) {
  8825. switch (_context4.prev = _context4.next) {
  8826. case 0:
  8827. return _context4.abrupt("return", (_this$_scripting5 = this._scripting) === null || _this$_scripting5 === void 0 ? void 0 : _this$_scripting5.dispatchEventInSandbox({
  8828. id: "doc",
  8829. name: "DidSave"
  8830. }));
  8831. case 1:
  8832. case "end":
  8833. return _context4.stop();
  8834. }
  8835. }
  8836. }, _callee4, this);
  8837. }));
  8838. function dispatchDidSave(_x4) {
  8839. return _dispatchDidSave.apply(this, arguments);
  8840. }
  8841. return dispatchDidSave;
  8842. }()
  8843. }, {
  8844. key: "dispatchWillPrint",
  8845. value: function () {
  8846. var _dispatchWillPrint = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(detail) {
  8847. var _this$_scripting6;
  8848. return _regenerator["default"].wrap(function _callee5$(_context5) {
  8849. while (1) {
  8850. switch (_context5.prev = _context5.next) {
  8851. case 0:
  8852. return _context5.abrupt("return", (_this$_scripting6 = this._scripting) === null || _this$_scripting6 === void 0 ? void 0 : _this$_scripting6.dispatchEventInSandbox({
  8853. id: "doc",
  8854. name: "WillPrint"
  8855. }));
  8856. case 1:
  8857. case "end":
  8858. return _context5.stop();
  8859. }
  8860. }
  8861. }, _callee5, this);
  8862. }));
  8863. function dispatchWillPrint(_x5) {
  8864. return _dispatchWillPrint.apply(this, arguments);
  8865. }
  8866. return dispatchWillPrint;
  8867. }()
  8868. }, {
  8869. key: "dispatchDidPrint",
  8870. value: function () {
  8871. var _dispatchDidPrint = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6(detail) {
  8872. var _this$_scripting7;
  8873. return _regenerator["default"].wrap(function _callee6$(_context6) {
  8874. while (1) {
  8875. switch (_context6.prev = _context6.next) {
  8876. case 0:
  8877. return _context6.abrupt("return", (_this$_scripting7 = this._scripting) === null || _this$_scripting7 === void 0 ? void 0 : _this$_scripting7.dispatchEventInSandbox({
  8878. id: "doc",
  8879. name: "DidPrint"
  8880. }));
  8881. case 1:
  8882. case "end":
  8883. return _context6.stop();
  8884. }
  8885. }
  8886. }, _callee6, this);
  8887. }));
  8888. function dispatchDidPrint(_x6) {
  8889. return _dispatchDidPrint.apply(this, arguments);
  8890. }
  8891. return dispatchDidPrint;
  8892. }()
  8893. }, {
  8894. key: "mouseState",
  8895. get: function get() {
  8896. return this._mouseState;
  8897. }
  8898. }, {
  8899. key: "destroyPromise",
  8900. get: function get() {
  8901. var _this$_destroyCapabil;
  8902. return ((_this$_destroyCapabil = this._destroyCapability) === null || _this$_destroyCapabil === void 0 ? void 0 : _this$_destroyCapabil.promise) || null;
  8903. }
  8904. }, {
  8905. key: "ready",
  8906. get: function get() {
  8907. return this._ready;
  8908. }
  8909. }, {
  8910. key: "_internalEvents",
  8911. get: function get() {
  8912. return (0, _pdfjsLib.shadow)(this, "_internalEvents", new Map());
  8913. }
  8914. }, {
  8915. key: "_domEvents",
  8916. get: function get() {
  8917. return (0, _pdfjsLib.shadow)(this, "_domEvents", new Map());
  8918. }
  8919. }, {
  8920. key: "_pageOpenPending",
  8921. get: function get() {
  8922. return (0, _pdfjsLib.shadow)(this, "_pageOpenPending", new Set());
  8923. }
  8924. }, {
  8925. key: "_visitedPages",
  8926. get: function get() {
  8927. return (0, _pdfjsLib.shadow)(this, "_visitedPages", new Map());
  8928. }
  8929. }, {
  8930. key: "_updateFromSandbox",
  8931. value: function () {
  8932. var _updateFromSandbox2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7(detail) {
  8933. var isInPresentationMode, id, command, value, element, _this$_pdfDocument;
  8934. return _regenerator["default"].wrap(function _callee7$(_context7) {
  8935. while (1) {
  8936. switch (_context7.prev = _context7.next) {
  8937. case 0:
  8938. isInPresentationMode = this._pdfViewer.isInPresentationMode || this._pdfViewer.isChangingPresentationMode;
  8939. id = detail.id, command = detail.command, value = detail.value;
  8940. if (id) {
  8941. _context7.next = 25;
  8942. break;
  8943. }
  8944. _context7.t0 = command;
  8945. _context7.next = _context7.t0 === "clear" ? 6 : _context7.t0 === "error" ? 8 : _context7.t0 === "layout" ? 10 : _context7.t0 === "page-num" ? 12 : _context7.t0 === "print" ? 14 : _context7.t0 === "println" ? 18 : _context7.t0 === "zoom" ? 20 : 24;
  8946. break;
  8947. case 6:
  8948. console.clear();
  8949. return _context7.abrupt("break", 24);
  8950. case 8:
  8951. console.error(value);
  8952. return _context7.abrupt("break", 24);
  8953. case 10:
  8954. this._pdfViewer.spreadMode = (0, _ui_utils.apiPageLayoutToSpreadMode)(value);
  8955. return _context7.abrupt("break", 24);
  8956. case 12:
  8957. this._pdfViewer.currentPageNumber = value + 1;
  8958. return _context7.abrupt("break", 24);
  8959. case 14:
  8960. _context7.next = 16;
  8961. return this._pdfViewer.pagesPromise;
  8962. case 16:
  8963. this._eventBus.dispatch("print", {
  8964. source: this
  8965. });
  8966. return _context7.abrupt("break", 24);
  8967. case 18:
  8968. console.log(value);
  8969. return _context7.abrupt("break", 24);
  8970. case 20:
  8971. if (!isInPresentationMode) {
  8972. _context7.next = 22;
  8973. break;
  8974. }
  8975. return _context7.abrupt("return");
  8976. case 22:
  8977. this._pdfViewer.currentScaleValue = value;
  8978. return _context7.abrupt("break", 24);
  8979. case 24:
  8980. return _context7.abrupt("return");
  8981. case 25:
  8982. if (!isInPresentationMode) {
  8983. _context7.next = 28;
  8984. break;
  8985. }
  8986. if (!detail.focus) {
  8987. _context7.next = 28;
  8988. break;
  8989. }
  8990. return _context7.abrupt("return");
  8991. case 28:
  8992. element = document.getElementById(id);
  8993. if (element) {
  8994. element.dispatchEvent(new CustomEvent("updatefromsandbox", {
  8995. detail: detail
  8996. }));
  8997. } else {
  8998. delete detail.id;
  8999. (_this$_pdfDocument = this._pdfDocument) === null || _this$_pdfDocument === void 0 ? void 0 : _this$_pdfDocument.annotationStorage.setValue(id, detail);
  9000. }
  9001. case 30:
  9002. case "end":
  9003. return _context7.stop();
  9004. }
  9005. }
  9006. }, _callee7, this);
  9007. }));
  9008. function _updateFromSandbox(_x7) {
  9009. return _updateFromSandbox2.apply(this, arguments);
  9010. }
  9011. return _updateFromSandbox;
  9012. }()
  9013. }, {
  9014. key: "_dispatchPageOpen",
  9015. value: function () {
  9016. var _dispatchPageOpen2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee9(pageNumber) {
  9017. var _this2 = this;
  9018. var initialize,
  9019. pdfDocument,
  9020. visitedPages,
  9021. pageView,
  9022. actionsPromise,
  9023. _args9 = arguments;
  9024. return _regenerator["default"].wrap(function _callee9$(_context9) {
  9025. while (1) {
  9026. switch (_context9.prev = _context9.next) {
  9027. case 0:
  9028. initialize = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : false;
  9029. pdfDocument = this._pdfDocument, visitedPages = this._visitedPages;
  9030. if (initialize) {
  9031. this._closeCapability = (0, _pdfjsLib.createPromiseCapability)();
  9032. this._pageEventsReady = true;
  9033. }
  9034. if (this._pageEventsReady) {
  9035. _context9.next = 5;
  9036. break;
  9037. }
  9038. return _context9.abrupt("return");
  9039. case 5:
  9040. pageView = this._pdfViewer.getPageView(pageNumber - 1);
  9041. if (!((pageView === null || pageView === void 0 ? void 0 : pageView.renderingState) !== _pdf_rendering_queue.RenderingStates.FINISHED)) {
  9042. _context9.next = 9;
  9043. break;
  9044. }
  9045. this._pageOpenPending.add(pageNumber);
  9046. return _context9.abrupt("return");
  9047. case 9:
  9048. this._pageOpenPending["delete"](pageNumber);
  9049. actionsPromise = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
  9050. var _pageView$pdfPage, _this2$_scripting;
  9051. var actions;
  9052. return _regenerator["default"].wrap(function _callee8$(_context8) {
  9053. while (1) {
  9054. switch (_context8.prev = _context8.next) {
  9055. case 0:
  9056. _context8.next = 2;
  9057. return !visitedPages.has(pageNumber) ? (_pageView$pdfPage = pageView.pdfPage) === null || _pageView$pdfPage === void 0 ? void 0 : _pageView$pdfPage.getJSActions() : null;
  9058. case 2:
  9059. actions = _context8.sent;
  9060. if (!(pdfDocument !== _this2._pdfDocument)) {
  9061. _context8.next = 5;
  9062. break;
  9063. }
  9064. return _context8.abrupt("return");
  9065. case 5:
  9066. _context8.next = 7;
  9067. return (_this2$_scripting = _this2._scripting) === null || _this2$_scripting === void 0 ? void 0 : _this2$_scripting.dispatchEventInSandbox({
  9068. id: "page",
  9069. name: "PageOpen",
  9070. pageNumber: pageNumber,
  9071. actions: actions
  9072. });
  9073. case 7:
  9074. case "end":
  9075. return _context8.stop();
  9076. }
  9077. }
  9078. }, _callee8);
  9079. }))();
  9080. visitedPages.set(pageNumber, actionsPromise);
  9081. case 12:
  9082. case "end":
  9083. return _context9.stop();
  9084. }
  9085. }
  9086. }, _callee9, this);
  9087. }));
  9088. function _dispatchPageOpen(_x8) {
  9089. return _dispatchPageOpen2.apply(this, arguments);
  9090. }
  9091. return _dispatchPageOpen;
  9092. }()
  9093. }, {
  9094. key: "_dispatchPageClose",
  9095. value: function () {
  9096. var _dispatchPageClose2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee10(pageNumber) {
  9097. var _this$_scripting8;
  9098. var pdfDocument, visitedPages, actionsPromise;
  9099. return _regenerator["default"].wrap(function _callee10$(_context10) {
  9100. while (1) {
  9101. switch (_context10.prev = _context10.next) {
  9102. case 0:
  9103. pdfDocument = this._pdfDocument, visitedPages = this._visitedPages;
  9104. if (this._pageEventsReady) {
  9105. _context10.next = 3;
  9106. break;
  9107. }
  9108. return _context10.abrupt("return");
  9109. case 3:
  9110. if (!this._pageOpenPending.has(pageNumber)) {
  9111. _context10.next = 5;
  9112. break;
  9113. }
  9114. return _context10.abrupt("return");
  9115. case 5:
  9116. actionsPromise = visitedPages.get(pageNumber);
  9117. if (actionsPromise) {
  9118. _context10.next = 8;
  9119. break;
  9120. }
  9121. return _context10.abrupt("return");
  9122. case 8:
  9123. visitedPages.set(pageNumber, null);
  9124. _context10.next = 11;
  9125. return actionsPromise;
  9126. case 11:
  9127. if (!(pdfDocument !== this._pdfDocument)) {
  9128. _context10.next = 13;
  9129. break;
  9130. }
  9131. return _context10.abrupt("return");
  9132. case 13:
  9133. _context10.next = 15;
  9134. return (_this$_scripting8 = this._scripting) === null || _this$_scripting8 === void 0 ? void 0 : _this$_scripting8.dispatchEventInSandbox({
  9135. id: "page",
  9136. name: "PageClose",
  9137. pageNumber: pageNumber
  9138. });
  9139. case 15:
  9140. case "end":
  9141. return _context10.stop();
  9142. }
  9143. }
  9144. }, _callee10, this);
  9145. }));
  9146. function _dispatchPageClose(_x9) {
  9147. return _dispatchPageClose2.apply(this, arguments);
  9148. }
  9149. return _dispatchPageClose;
  9150. }()
  9151. }, {
  9152. key: "_getDocProperties",
  9153. value: function () {
  9154. var _getDocProperties2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
  9155. return _regenerator["default"].wrap(function _callee11$(_context11) {
  9156. while (1) {
  9157. switch (_context11.prev = _context11.next) {
  9158. case 0:
  9159. if (!this._docPropertiesLookup) {
  9160. _context11.next = 2;
  9161. break;
  9162. }
  9163. return _context11.abrupt("return", this._docPropertiesLookup(this._pdfDocument));
  9164. case 2:
  9165. throw new Error("_getDocProperties: Unable to lookup properties.");
  9166. case 3:
  9167. case "end":
  9168. return _context11.stop();
  9169. }
  9170. }
  9171. }, _callee11, this);
  9172. }));
  9173. function _getDocProperties() {
  9174. return _getDocProperties2.apply(this, arguments);
  9175. }
  9176. return _getDocProperties;
  9177. }()
  9178. }, {
  9179. key: "_createScripting",
  9180. value: function _createScripting() {
  9181. this._destroyCapability = (0, _pdfjsLib.createPromiseCapability)();
  9182. if (this._scripting) {
  9183. throw new Error("_createScripting: Scripting already exists.");
  9184. }
  9185. if (this._scriptingFactory) {
  9186. return this._scriptingFactory.createScripting({
  9187. sandboxBundleSrc: this._sandboxBundleSrc
  9188. });
  9189. }
  9190. throw new Error("_createScripting: Cannot create scripting.");
  9191. }
  9192. }, {
  9193. key: "_destroyScripting",
  9194. value: function () {
  9195. var _destroyScripting2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
  9196. var _this$_destroyCapabil3;
  9197. var _this$_destroyCapabil2, _iterator3, _step3, _step3$value, name, listener, _iterator4, _step4, _step4$value, _name2, _listener2;
  9198. return _regenerator["default"].wrap(function _callee12$(_context12) {
  9199. while (1) {
  9200. switch (_context12.prev = _context12.next) {
  9201. case 0:
  9202. if (this._scripting) {
  9203. _context12.next = 4;
  9204. break;
  9205. }
  9206. this._pdfDocument = null;
  9207. (_this$_destroyCapabil2 = this._destroyCapability) === null || _this$_destroyCapabil2 === void 0 ? void 0 : _this$_destroyCapabil2.resolve();
  9208. return _context12.abrupt("return");
  9209. case 4:
  9210. if (!this._closeCapability) {
  9211. _context12.next = 8;
  9212. break;
  9213. }
  9214. _context12.next = 7;
  9215. return Promise.race([this._closeCapability.promise, new Promise(function (resolve) {
  9216. setTimeout(resolve, 1000);
  9217. })])["catch"](function (reason) {});
  9218. case 7:
  9219. this._closeCapability = null;
  9220. case 8:
  9221. this._pdfDocument = null;
  9222. _context12.prev = 9;
  9223. _context12.next = 12;
  9224. return this._scripting.destroySandbox();
  9225. case 12:
  9226. _context12.next = 16;
  9227. break;
  9228. case 14:
  9229. _context12.prev = 14;
  9230. _context12.t0 = _context12["catch"](9);
  9231. case 16:
  9232. _iterator3 = _createForOfIteratorHelper(this._internalEvents);
  9233. try {
  9234. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  9235. _step3$value = _slicedToArray(_step3.value, 2), name = _step3$value[0], listener = _step3$value[1];
  9236. this._eventBus._off(name, listener);
  9237. }
  9238. } catch (err) {
  9239. _iterator3.e(err);
  9240. } finally {
  9241. _iterator3.f();
  9242. }
  9243. this._internalEvents.clear();
  9244. _iterator4 = _createForOfIteratorHelper(this._domEvents);
  9245. try {
  9246. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  9247. _step4$value = _slicedToArray(_step4.value, 2), _name2 = _step4$value[0], _listener2 = _step4$value[1];
  9248. window.removeEventListener(_name2, _listener2);
  9249. }
  9250. } catch (err) {
  9251. _iterator4.e(err);
  9252. } finally {
  9253. _iterator4.f();
  9254. }
  9255. this._domEvents.clear();
  9256. this._pageOpenPending.clear();
  9257. this._visitedPages.clear();
  9258. this._scripting = null;
  9259. delete this._mouseState.isDown;
  9260. this._pageEventsReady = false;
  9261. this._ready = false;
  9262. (_this$_destroyCapabil3 = this._destroyCapability) === null || _this$_destroyCapabil3 === void 0 ? void 0 : _this$_destroyCapabil3.resolve();
  9263. case 29:
  9264. case "end":
  9265. return _context12.stop();
  9266. }
  9267. }
  9268. }, _callee12, this, [[9, 14]]);
  9269. }));
  9270. function _destroyScripting() {
  9271. return _destroyScripting2.apply(this, arguments);
  9272. }
  9273. return _destroyScripting;
  9274. }()
  9275. }]);
  9276. return PDFScriptingManager;
  9277. }();
  9278. exports.PDFScriptingManager = PDFScriptingManager;
  9279. /***/ }),
  9280. /* 25 */
  9281. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9282. Object.defineProperty(exports, "__esModule", ({
  9283. value: true
  9284. }));
  9285. exports.PDFSidebar = void 0;
  9286. var _ui_utils = __webpack_require__(6);
  9287. var _pdf_rendering_queue = __webpack_require__(10);
  9288. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9289. 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); } }
  9290. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9291. var UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  9292. var PDFSidebar = /*#__PURE__*/function () {
  9293. function PDFSidebar(_ref) {
  9294. var elements = _ref.elements,
  9295. pdfViewer = _ref.pdfViewer,
  9296. pdfThumbnailViewer = _ref.pdfThumbnailViewer,
  9297. eventBus = _ref.eventBus,
  9298. l10n = _ref.l10n;
  9299. _classCallCheck(this, PDFSidebar);
  9300. this.isOpen = false;
  9301. this.active = _ui_utils.SidebarView.THUMBS;
  9302. this.isInitialViewSet = false;
  9303. this.onToggled = null;
  9304. this.pdfViewer = pdfViewer;
  9305. this.pdfThumbnailViewer = pdfThumbnailViewer;
  9306. this.outerContainer = elements.outerContainer;
  9307. this.viewerContainer = elements.viewerContainer;
  9308. this.toggleButton = elements.toggleButton;
  9309. this.thumbnailButton = elements.thumbnailButton;
  9310. this.outlineButton = elements.outlineButton;
  9311. this.attachmentsButton = elements.attachmentsButton;
  9312. this.layersButton = elements.layersButton;
  9313. this.thumbnailView = elements.thumbnailView;
  9314. this.outlineView = elements.outlineView;
  9315. this.attachmentsView = elements.attachmentsView;
  9316. this.layersView = elements.layersView;
  9317. this._outlineOptionsContainer = elements.outlineOptionsContainer;
  9318. this._currentOutlineItemButton = elements.currentOutlineItemButton;
  9319. this.eventBus = eventBus;
  9320. this.l10n = l10n;
  9321. this._addEventListeners();
  9322. }
  9323. _createClass(PDFSidebar, [{
  9324. key: "reset",
  9325. value: function reset() {
  9326. this.isInitialViewSet = false;
  9327. this._hideUINotification(true);
  9328. this.switchView(_ui_utils.SidebarView.THUMBS);
  9329. this.outlineButton.disabled = false;
  9330. this.attachmentsButton.disabled = false;
  9331. this.layersButton.disabled = false;
  9332. this._currentOutlineItemButton.disabled = true;
  9333. }
  9334. }, {
  9335. key: "visibleView",
  9336. get: function get() {
  9337. return this.isOpen ? this.active : _ui_utils.SidebarView.NONE;
  9338. }
  9339. }, {
  9340. key: "isThumbnailViewVisible",
  9341. get: function get() {
  9342. return this.isOpen && this.active === _ui_utils.SidebarView.THUMBS;
  9343. }
  9344. }, {
  9345. key: "isOutlineViewVisible",
  9346. get: function get() {
  9347. return this.isOpen && this.active === _ui_utils.SidebarView.OUTLINE;
  9348. }
  9349. }, {
  9350. key: "isAttachmentsViewVisible",
  9351. get: function get() {
  9352. return this.isOpen && this.active === _ui_utils.SidebarView.ATTACHMENTS;
  9353. }
  9354. }, {
  9355. key: "isLayersViewVisible",
  9356. get: function get() {
  9357. return this.isOpen && this.active === _ui_utils.SidebarView.LAYERS;
  9358. }
  9359. }, {
  9360. key: "setInitialView",
  9361. value: function setInitialView() {
  9362. var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _ui_utils.SidebarView.NONE;
  9363. if (this.isInitialViewSet) {
  9364. return;
  9365. }
  9366. this.isInitialViewSet = true;
  9367. if (view === _ui_utils.SidebarView.NONE || view === _ui_utils.SidebarView.UNKNOWN) {
  9368. this._dispatchEvent();
  9369. return;
  9370. }
  9371. if (!this._switchView(view, true)) {
  9372. this._dispatchEvent();
  9373. }
  9374. }
  9375. }, {
  9376. key: "switchView",
  9377. value: function switchView(view) {
  9378. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9379. this._switchView(view, forceOpen);
  9380. }
  9381. }, {
  9382. key: "_switchView",
  9383. value: function _switchView(view) {
  9384. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9385. var isViewChanged = view !== this.active;
  9386. var shouldForceRendering = false;
  9387. switch (view) {
  9388. case _ui_utils.SidebarView.NONE:
  9389. if (this.isOpen) {
  9390. this.close();
  9391. return true;
  9392. }
  9393. return false;
  9394. case _ui_utils.SidebarView.THUMBS:
  9395. if (this.isOpen && isViewChanged) {
  9396. shouldForceRendering = true;
  9397. }
  9398. break;
  9399. case _ui_utils.SidebarView.OUTLINE:
  9400. if (this.outlineButton.disabled) {
  9401. return false;
  9402. }
  9403. break;
  9404. case _ui_utils.SidebarView.ATTACHMENTS:
  9405. if (this.attachmentsButton.disabled) {
  9406. return false;
  9407. }
  9408. break;
  9409. case _ui_utils.SidebarView.LAYERS:
  9410. if (this.layersButton.disabled) {
  9411. return false;
  9412. }
  9413. break;
  9414. default:
  9415. console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
  9416. return false;
  9417. }
  9418. this.active = view;
  9419. this.thumbnailButton.classList.toggle("toggled", view === _ui_utils.SidebarView.THUMBS);
  9420. this.outlineButton.classList.toggle("toggled", view === _ui_utils.SidebarView.OUTLINE);
  9421. this.attachmentsButton.classList.toggle("toggled", view === _ui_utils.SidebarView.ATTACHMENTS);
  9422. this.layersButton.classList.toggle("toggled", view === _ui_utils.SidebarView.LAYERS);
  9423. this.thumbnailView.classList.toggle("hidden", view !== _ui_utils.SidebarView.THUMBS);
  9424. this.outlineView.classList.toggle("hidden", view !== _ui_utils.SidebarView.OUTLINE);
  9425. this.attachmentsView.classList.toggle("hidden", view !== _ui_utils.SidebarView.ATTACHMENTS);
  9426. this.layersView.classList.toggle("hidden", view !== _ui_utils.SidebarView.LAYERS);
  9427. this._outlineOptionsContainer.classList.toggle("hidden", view !== _ui_utils.SidebarView.OUTLINE);
  9428. if (forceOpen && !this.isOpen) {
  9429. this.open();
  9430. return true;
  9431. }
  9432. if (shouldForceRendering) {
  9433. this._updateThumbnailViewer();
  9434. this._forceRendering();
  9435. }
  9436. if (isViewChanged) {
  9437. this._dispatchEvent();
  9438. }
  9439. return isViewChanged;
  9440. }
  9441. }, {
  9442. key: "open",
  9443. value: function open() {
  9444. if (this.isOpen) {
  9445. return;
  9446. }
  9447. this.isOpen = true;
  9448. this.toggleButton.classList.add("toggled");
  9449. this.toggleButton.setAttribute("aria-expanded", "true");
  9450. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  9451. if (this.active === _ui_utils.SidebarView.THUMBS) {
  9452. this._updateThumbnailViewer();
  9453. }
  9454. this._forceRendering();
  9455. this._dispatchEvent();
  9456. this._hideUINotification();
  9457. }
  9458. }, {
  9459. key: "close",
  9460. value: function close() {
  9461. if (!this.isOpen) {
  9462. return;
  9463. }
  9464. this.isOpen = false;
  9465. this.toggleButton.classList.remove("toggled");
  9466. this.toggleButton.setAttribute("aria-expanded", "false");
  9467. this.outerContainer.classList.add("sidebarMoving");
  9468. this.outerContainer.classList.remove("sidebarOpen");
  9469. this._forceRendering();
  9470. this._dispatchEvent();
  9471. }
  9472. }, {
  9473. key: "toggle",
  9474. value: function toggle() {
  9475. if (this.isOpen) {
  9476. this.close();
  9477. } else {
  9478. this.open();
  9479. }
  9480. }
  9481. }, {
  9482. key: "_dispatchEvent",
  9483. value: function _dispatchEvent() {
  9484. this.eventBus.dispatch("sidebarviewchanged", {
  9485. source: this,
  9486. view: this.visibleView
  9487. });
  9488. }
  9489. }, {
  9490. key: "_forceRendering",
  9491. value: function _forceRendering() {
  9492. if (this.onToggled) {
  9493. this.onToggled();
  9494. } else {
  9495. this.pdfViewer.forceRendering();
  9496. this.pdfThumbnailViewer.forceRendering();
  9497. }
  9498. }
  9499. }, {
  9500. key: "_updateThumbnailViewer",
  9501. value: function _updateThumbnailViewer() {
  9502. var pdfViewer = this.pdfViewer,
  9503. pdfThumbnailViewer = this.pdfThumbnailViewer;
  9504. var pagesCount = pdfViewer.pagesCount;
  9505. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  9506. var pageView = pdfViewer.getPageView(pageIndex);
  9507. if ((pageView === null || pageView === void 0 ? void 0 : pageView.renderingState) === _pdf_rendering_queue.RenderingStates.FINISHED) {
  9508. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  9509. thumbnailView.setImage(pageView);
  9510. }
  9511. }
  9512. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  9513. }
  9514. }, {
  9515. key: "_showUINotification",
  9516. value: function _showUINotification() {
  9517. var _this = this;
  9518. this.l10n.get("toggle_sidebar_notification2.title").then(function (msg) {
  9519. _this.toggleButton.title = msg;
  9520. });
  9521. if (!this.isOpen) {
  9522. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  9523. }
  9524. }
  9525. }, {
  9526. key: "_hideUINotification",
  9527. value: function _hideUINotification() {
  9528. var _this2 = this;
  9529. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9530. if (this.isOpen || reset) {
  9531. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  9532. }
  9533. if (reset) {
  9534. this.l10n.get("toggle_sidebar.title").then(function (msg) {
  9535. _this2.toggleButton.title = msg;
  9536. });
  9537. }
  9538. }
  9539. }, {
  9540. key: "_addEventListeners",
  9541. value: function _addEventListeners() {
  9542. var _this3 = this;
  9543. this.viewerContainer.addEventListener("transitionend", function (evt) {
  9544. if (evt.target === _this3.viewerContainer) {
  9545. _this3.outerContainer.classList.remove("sidebarMoving");
  9546. }
  9547. });
  9548. this.toggleButton.addEventListener("click", function () {
  9549. _this3.toggle();
  9550. });
  9551. this.thumbnailButton.addEventListener("click", function () {
  9552. _this3.switchView(_ui_utils.SidebarView.THUMBS);
  9553. });
  9554. this.outlineButton.addEventListener("click", function () {
  9555. _this3.switchView(_ui_utils.SidebarView.OUTLINE);
  9556. });
  9557. this.outlineButton.addEventListener("dblclick", function () {
  9558. _this3.eventBus.dispatch("toggleoutlinetree", {
  9559. source: _this3
  9560. });
  9561. });
  9562. this.attachmentsButton.addEventListener("click", function () {
  9563. _this3.switchView(_ui_utils.SidebarView.ATTACHMENTS);
  9564. });
  9565. this.layersButton.addEventListener("click", function () {
  9566. _this3.switchView(_ui_utils.SidebarView.LAYERS);
  9567. });
  9568. this.layersButton.addEventListener("dblclick", function () {
  9569. _this3.eventBus.dispatch("resetlayers", {
  9570. source: _this3
  9571. });
  9572. });
  9573. this._currentOutlineItemButton.addEventListener("click", function () {
  9574. _this3.eventBus.dispatch("currentoutlineitem", {
  9575. source: _this3
  9576. });
  9577. });
  9578. var onTreeLoaded = function onTreeLoaded(count, button, view) {
  9579. button.disabled = !count;
  9580. if (count) {
  9581. _this3._showUINotification();
  9582. } else if (_this3.active === view) {
  9583. _this3.switchView(_ui_utils.SidebarView.THUMBS);
  9584. }
  9585. };
  9586. this.eventBus._on("outlineloaded", function (evt) {
  9587. onTreeLoaded(evt.outlineCount, _this3.outlineButton, _ui_utils.SidebarView.OUTLINE);
  9588. if (evt.enableCurrentOutlineItemButton) {
  9589. _this3.pdfViewer.pagesPromise.then(function () {
  9590. _this3._currentOutlineItemButton.disabled = !_this3.isInitialViewSet;
  9591. });
  9592. }
  9593. });
  9594. this.eventBus._on("attachmentsloaded", function (evt) {
  9595. onTreeLoaded(evt.attachmentsCount, _this3.attachmentsButton, _ui_utils.SidebarView.ATTACHMENTS);
  9596. });
  9597. this.eventBus._on("layersloaded", function (evt) {
  9598. onTreeLoaded(evt.layersCount, _this3.layersButton, _ui_utils.SidebarView.LAYERS);
  9599. });
  9600. this.eventBus._on("presentationmodechanged", function (evt) {
  9601. if (evt.state === _ui_utils.PresentationModeState.NORMAL && _this3.isThumbnailViewVisible) {
  9602. _this3._updateThumbnailViewer();
  9603. }
  9604. });
  9605. }
  9606. }]);
  9607. return PDFSidebar;
  9608. }();
  9609. exports.PDFSidebar = PDFSidebar;
  9610. /***/ }),
  9611. /* 26 */
  9612. /***/ ((__unused_webpack_module, exports) => {
  9613. Object.defineProperty(exports, "__esModule", ({
  9614. value: true
  9615. }));
  9616. exports.PDFSidebarResizer = void 0;
  9617. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9618. 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); } }
  9619. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9620. var SIDEBAR_WIDTH_VAR = "--sidebar-width";
  9621. var SIDEBAR_MIN_WIDTH = 200;
  9622. var SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  9623. var PDFSidebarResizer = /*#__PURE__*/function () {
  9624. function PDFSidebarResizer(options, eventBus, l10n) {
  9625. var _this = this;
  9626. _classCallCheck(this, PDFSidebarResizer);
  9627. this.isRTL = false;
  9628. this.sidebarOpen = false;
  9629. this.doc = document.documentElement;
  9630. this._width = null;
  9631. this._outerContainerWidth = null;
  9632. this._boundEvents = Object.create(null);
  9633. this.outerContainer = options.outerContainer;
  9634. this.resizer = options.resizer;
  9635. this.eventBus = eventBus;
  9636. l10n.getDirection().then(function (dir) {
  9637. _this.isRTL = dir === "rtl";
  9638. });
  9639. this._addEventListeners();
  9640. }
  9641. _createClass(PDFSidebarResizer, [{
  9642. key: "outerContainerWidth",
  9643. get: function get() {
  9644. return this._outerContainerWidth || (this._outerContainerWidth = this.outerContainer.clientWidth);
  9645. }
  9646. }, {
  9647. key: "_updateWidth",
  9648. value: function _updateWidth() {
  9649. var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  9650. var maxWidth = Math.floor(this.outerContainerWidth / 2);
  9651. if (width > maxWidth) {
  9652. width = maxWidth;
  9653. }
  9654. if (width < SIDEBAR_MIN_WIDTH) {
  9655. width = SIDEBAR_MIN_WIDTH;
  9656. }
  9657. if (width === this._width) {
  9658. return false;
  9659. }
  9660. this._width = width;
  9661. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(width, "px"));
  9662. return true;
  9663. }
  9664. }, {
  9665. key: "_mouseMove",
  9666. value: function _mouseMove(evt) {
  9667. var width = evt.clientX;
  9668. if (this.isRTL) {
  9669. width = this.outerContainerWidth - width;
  9670. }
  9671. this._updateWidth(width);
  9672. }
  9673. }, {
  9674. key: "_mouseUp",
  9675. value: function _mouseUp(evt) {
  9676. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  9677. this.eventBus.dispatch("resize", {
  9678. source: this
  9679. });
  9680. var _boundEvents = this._boundEvents;
  9681. window.removeEventListener("mousemove", _boundEvents.mouseMove);
  9682. window.removeEventListener("mouseup", _boundEvents.mouseUp);
  9683. }
  9684. }, {
  9685. key: "_addEventListeners",
  9686. value: function _addEventListeners() {
  9687. var _this2 = this;
  9688. var _boundEvents = this._boundEvents;
  9689. _boundEvents.mouseMove = this._mouseMove.bind(this);
  9690. _boundEvents.mouseUp = this._mouseUp.bind(this);
  9691. this.resizer.addEventListener("mousedown", function (evt) {
  9692. if (evt.button !== 0) {
  9693. return;
  9694. }
  9695. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  9696. window.addEventListener("mousemove", _boundEvents.mouseMove);
  9697. window.addEventListener("mouseup", _boundEvents.mouseUp);
  9698. });
  9699. this.eventBus._on("sidebarviewchanged", function (evt) {
  9700. _this2.sidebarOpen = !!(evt !== null && evt !== void 0 && evt.view);
  9701. });
  9702. this.eventBus._on("resize", function (evt) {
  9703. if ((evt === null || evt === void 0 ? void 0 : evt.source) !== window) {
  9704. return;
  9705. }
  9706. _this2._outerContainerWidth = null;
  9707. if (!_this2._width) {
  9708. return;
  9709. }
  9710. if (!_this2.sidebarOpen) {
  9711. _this2._updateWidth(_this2._width);
  9712. return;
  9713. }
  9714. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  9715. var updated = _this2._updateWidth(_this2._width);
  9716. Promise.resolve().then(function () {
  9717. _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  9718. if (updated) {
  9719. _this2.eventBus.dispatch("resize", {
  9720. source: _this2
  9721. });
  9722. }
  9723. });
  9724. });
  9725. }
  9726. }]);
  9727. return PDFSidebarResizer;
  9728. }();
  9729. exports.PDFSidebarResizer = PDFSidebarResizer;
  9730. /***/ }),
  9731. /* 27 */
  9732. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9733. Object.defineProperty(exports, "__esModule", ({
  9734. value: true
  9735. }));
  9736. exports.PDFThumbnailViewer = void 0;
  9737. var _ui_utils = __webpack_require__(6);
  9738. var _pdf_thumbnail_view = __webpack_require__(28);
  9739. var _pdf_rendering_queue = __webpack_require__(10);
  9740. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9741. 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); } }
  9742. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9743. var THUMBNAIL_SCROLL_MARGIN = -19;
  9744. var THUMBNAIL_SELECTED_CLASS = "selected";
  9745. var PDFThumbnailViewer = /*#__PURE__*/function () {
  9746. function PDFThumbnailViewer(_ref) {
  9747. var _this = this;
  9748. var container = _ref.container,
  9749. eventBus = _ref.eventBus,
  9750. linkService = _ref.linkService,
  9751. renderingQueue = _ref.renderingQueue,
  9752. l10n = _ref.l10n;
  9753. _classCallCheck(this, PDFThumbnailViewer);
  9754. this.container = container;
  9755. this.linkService = linkService;
  9756. this.renderingQueue = renderingQueue;
  9757. this.l10n = l10n;
  9758. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  9759. this._resetView();
  9760. eventBus._on("optionalcontentconfigchanged", function () {
  9761. _this._setImageDisabled = true;
  9762. });
  9763. }
  9764. _createClass(PDFThumbnailViewer, [{
  9765. key: "_scrollUpdated",
  9766. value: function _scrollUpdated() {
  9767. this.renderingQueue.renderHighestPriority();
  9768. }
  9769. }, {
  9770. key: "getThumbnail",
  9771. value: function getThumbnail(index) {
  9772. return this._thumbnails[index];
  9773. }
  9774. }, {
  9775. key: "_getVisibleThumbs",
  9776. value: function _getVisibleThumbs() {
  9777. return (0, _ui_utils.getVisibleElements)({
  9778. scrollEl: this.container,
  9779. views: this._thumbnails
  9780. });
  9781. }
  9782. }, {
  9783. key: "scrollThumbnailIntoView",
  9784. value: function scrollThumbnailIntoView(pageNumber) {
  9785. if (!this.pdfDocument) {
  9786. return;
  9787. }
  9788. var thumbnailView = this._thumbnails[pageNumber - 1];
  9789. if (!thumbnailView) {
  9790. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  9791. return;
  9792. }
  9793. if (pageNumber !== this._currentPageNumber) {
  9794. var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  9795. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  9796. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  9797. }
  9798. var visibleThumbs = this._getVisibleThumbs();
  9799. var numVisibleThumbs = visibleThumbs.views.length;
  9800. if (numVisibleThumbs > 0) {
  9801. var first = visibleThumbs.first.id;
  9802. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  9803. var shouldScroll = false;
  9804. if (pageNumber <= first || pageNumber >= last) {
  9805. shouldScroll = true;
  9806. } else {
  9807. visibleThumbs.views.some(function (view) {
  9808. if (view.id !== pageNumber) {
  9809. return false;
  9810. }
  9811. shouldScroll = view.percent < 100;
  9812. return true;
  9813. });
  9814. }
  9815. if (shouldScroll) {
  9816. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  9817. top: THUMBNAIL_SCROLL_MARGIN
  9818. });
  9819. }
  9820. }
  9821. this._currentPageNumber = pageNumber;
  9822. }
  9823. }, {
  9824. key: "pagesRotation",
  9825. get: function get() {
  9826. return this._pagesRotation;
  9827. },
  9828. set: function set(rotation) {
  9829. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  9830. throw new Error("Invalid thumbnails rotation angle.");
  9831. }
  9832. if (!this.pdfDocument) {
  9833. return;
  9834. }
  9835. if (this._pagesRotation === rotation) {
  9836. return;
  9837. }
  9838. this._pagesRotation = rotation;
  9839. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9840. this._thumbnails[i].update(rotation);
  9841. }
  9842. }
  9843. }, {
  9844. key: "cleanup",
  9845. value: function cleanup() {
  9846. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9847. if (this._thumbnails[i] && this._thumbnails[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9848. this._thumbnails[i].reset();
  9849. }
  9850. }
  9851. _pdf_thumbnail_view.TempImageFactory.destroyCanvas();
  9852. }
  9853. }, {
  9854. key: "_resetView",
  9855. value: function _resetView() {
  9856. this._thumbnails = [];
  9857. this._currentPageNumber = 1;
  9858. this._pageLabels = null;
  9859. this._pagesRotation = 0;
  9860. this._optionalContentConfigPromise = null;
  9861. this._pagesRequests = new WeakMap();
  9862. this._setImageDisabled = false;
  9863. this.container.textContent = "";
  9864. }
  9865. }, {
  9866. key: "setDocument",
  9867. value: function setDocument(pdfDocument) {
  9868. var _this2 = this;
  9869. if (this.pdfDocument) {
  9870. this._cancelRendering();
  9871. this._resetView();
  9872. }
  9873. this.pdfDocument = pdfDocument;
  9874. if (!pdfDocument) {
  9875. return;
  9876. }
  9877. var firstPagePromise = pdfDocument.getPage(1);
  9878. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  9879. firstPagePromise.then(function (firstPdfPage) {
  9880. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  9881. var pagesCount = pdfDocument.numPages;
  9882. var viewport = firstPdfPage.getViewport({
  9883. scale: 1
  9884. });
  9885. var checkSetImageDisabled = function checkSetImageDisabled() {
  9886. return _this2._setImageDisabled;
  9887. };
  9888. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  9889. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  9890. container: _this2.container,
  9891. id: pageNum,
  9892. defaultViewport: viewport.clone(),
  9893. optionalContentConfigPromise: optionalContentConfigPromise,
  9894. linkService: _this2.linkService,
  9895. renderingQueue: _this2.renderingQueue,
  9896. checkSetImageDisabled: checkSetImageDisabled,
  9897. disableCanvasToImageConversion: false,
  9898. l10n: _this2.l10n
  9899. });
  9900. _this2._thumbnails.push(thumbnail);
  9901. }
  9902. var firstThumbnailView = _this2._thumbnails[0];
  9903. if (firstThumbnailView) {
  9904. firstThumbnailView.setPdfPage(firstPdfPage);
  9905. }
  9906. var thumbnailView = _this2._thumbnails[_this2._currentPageNumber - 1];
  9907. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  9908. })["catch"](function (reason) {
  9909. console.error("Unable to initialize thumbnail viewer", reason);
  9910. });
  9911. }
  9912. }, {
  9913. key: "_cancelRendering",
  9914. value: function _cancelRendering() {
  9915. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9916. if (this._thumbnails[i]) {
  9917. this._thumbnails[i].cancelRendering();
  9918. }
  9919. }
  9920. }
  9921. }, {
  9922. key: "setPageLabels",
  9923. value: function setPageLabels(labels) {
  9924. if (!this.pdfDocument) {
  9925. return;
  9926. }
  9927. if (!labels) {
  9928. this._pageLabels = null;
  9929. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  9930. this._pageLabels = null;
  9931. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  9932. } else {
  9933. this._pageLabels = labels;
  9934. }
  9935. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9936. var _this$_pageLabels$i, _this$_pageLabels;
  9937. this._thumbnails[i].setPageLabel((_this$_pageLabels$i = (_this$_pageLabels = this._pageLabels) === null || _this$_pageLabels === void 0 ? void 0 : _this$_pageLabels[i]) !== null && _this$_pageLabels$i !== void 0 ? _this$_pageLabels$i : null);
  9938. }
  9939. }
  9940. }, {
  9941. key: "_ensurePdfPageLoaded",
  9942. value: function _ensurePdfPageLoaded(thumbView) {
  9943. var _this3 = this;
  9944. if (thumbView.pdfPage) {
  9945. return Promise.resolve(thumbView.pdfPage);
  9946. }
  9947. if (this._pagesRequests.has(thumbView)) {
  9948. return this._pagesRequests.get(thumbView);
  9949. }
  9950. var promise = this.pdfDocument.getPage(thumbView.id).then(function (pdfPage) {
  9951. if (!thumbView.pdfPage) {
  9952. thumbView.setPdfPage(pdfPage);
  9953. }
  9954. _this3._pagesRequests["delete"](thumbView);
  9955. return pdfPage;
  9956. })["catch"](function (reason) {
  9957. console.error("Unable to get page for thumb view", reason);
  9958. _this3._pagesRequests["delete"](thumbView);
  9959. });
  9960. this._pagesRequests.set(thumbView, promise);
  9961. return promise;
  9962. }
  9963. }, {
  9964. key: "forceRendering",
  9965. value: function forceRendering() {
  9966. var _this4 = this;
  9967. var visibleThumbs = this._getVisibleThumbs();
  9968. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  9969. if (thumbView) {
  9970. this._ensurePdfPageLoaded(thumbView).then(function () {
  9971. _this4.renderingQueue.renderView(thumbView);
  9972. });
  9973. return true;
  9974. }
  9975. return false;
  9976. }
  9977. }]);
  9978. return PDFThumbnailViewer;
  9979. }();
  9980. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  9981. /***/ }),
  9982. /* 28 */
  9983. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9984. Object.defineProperty(exports, "__esModule", ({
  9985. value: true
  9986. }));
  9987. exports.TempImageFactory = exports.PDFThumbnailView = void 0;
  9988. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  9989. var _ui_utils = __webpack_require__(6);
  9990. var _pdfjsLib = __webpack_require__(7);
  9991. var _pdf_rendering_queue = __webpack_require__(10);
  9992. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9993. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  9994. 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."); }
  9995. 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); }
  9996. 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; }
  9997. 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; }
  9998. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  9999. 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); } }
  10000. 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); }); }; }
  10001. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10002. 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); } }
  10003. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10004. var MAX_NUM_SCALING_STEPS = 3;
  10005. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  10006. var THUMBNAIL_WIDTH = 98;
  10007. var TempImageFactory = function TempImageFactoryClosure() {
  10008. var tempCanvasCache = null;
  10009. return {
  10010. getCanvas: function getCanvas(width, height) {
  10011. var tempCanvas = tempCanvasCache;
  10012. if (!tempCanvas) {
  10013. tempCanvas = document.createElement("canvas");
  10014. tempCanvasCache = tempCanvas;
  10015. }
  10016. tempCanvas.width = width;
  10017. tempCanvas.height = height;
  10018. tempCanvas.mozOpaque = true;
  10019. var ctx = tempCanvas.getContext("2d", {
  10020. alpha: false
  10021. });
  10022. ctx.save();
  10023. ctx.fillStyle = "rgb(255, 255, 255)";
  10024. ctx.fillRect(0, 0, width, height);
  10025. ctx.restore();
  10026. return tempCanvas;
  10027. },
  10028. destroyCanvas: function destroyCanvas() {
  10029. var tempCanvas = tempCanvasCache;
  10030. if (tempCanvas) {
  10031. tempCanvas.width = 0;
  10032. tempCanvas.height = 0;
  10033. }
  10034. tempCanvasCache = null;
  10035. }
  10036. };
  10037. }();
  10038. exports.TempImageFactory = TempImageFactory;
  10039. var PDFThumbnailView = /*#__PURE__*/function () {
  10040. function PDFThumbnailView(_ref) {
  10041. var container = _ref.container,
  10042. id = _ref.id,
  10043. defaultViewport = _ref.defaultViewport,
  10044. optionalContentConfigPromise = _ref.optionalContentConfigPromise,
  10045. linkService = _ref.linkService,
  10046. renderingQueue = _ref.renderingQueue,
  10047. checkSetImageDisabled = _ref.checkSetImageDisabled,
  10048. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  10049. disableCanvasToImageConversion = _ref$disableCanvasToI === void 0 ? false : _ref$disableCanvasToI,
  10050. l10n = _ref.l10n;
  10051. _classCallCheck(this, PDFThumbnailView);
  10052. this.id = id;
  10053. this.renderingId = "thumbnail" + id;
  10054. this.pageLabel = null;
  10055. this.pdfPage = null;
  10056. this.rotation = 0;
  10057. this.viewport = defaultViewport;
  10058. this.pdfPageRotate = defaultViewport.rotation;
  10059. this._optionalContentConfigPromise = optionalContentConfigPromise || null;
  10060. this.linkService = linkService;
  10061. this.renderingQueue = renderingQueue;
  10062. this.renderTask = null;
  10063. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  10064. this.resume = null;
  10065. this._checkSetImageDisabled = checkSetImageDisabled || function () {
  10066. return false;
  10067. };
  10068. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  10069. this.pageWidth = this.viewport.width;
  10070. this.pageHeight = this.viewport.height;
  10071. this.pageRatio = this.pageWidth / this.pageHeight;
  10072. this.canvasWidth = THUMBNAIL_WIDTH;
  10073. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  10074. this.scale = this.canvasWidth / this.pageWidth;
  10075. this.l10n = l10n;
  10076. var anchor = document.createElement("a");
  10077. anchor.href = linkService.getAnchorUrl("#page=" + id);
  10078. this._thumbPageTitle.then(function (msg) {
  10079. anchor.title = msg;
  10080. });
  10081. anchor.onclick = function () {
  10082. linkService.goToPage(id);
  10083. return false;
  10084. };
  10085. this.anchor = anchor;
  10086. var div = document.createElement("div");
  10087. div.className = "thumbnail";
  10088. div.setAttribute("data-page-number", this.id);
  10089. this.div = div;
  10090. var ring = document.createElement("div");
  10091. ring.className = "thumbnailSelectionRing";
  10092. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  10093. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  10094. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  10095. this.ring = ring;
  10096. div.appendChild(ring);
  10097. anchor.appendChild(div);
  10098. container.appendChild(anchor);
  10099. }
  10100. _createClass(PDFThumbnailView, [{
  10101. key: "setPdfPage",
  10102. value: function setPdfPage(pdfPage) {
  10103. this.pdfPage = pdfPage;
  10104. this.pdfPageRotate = pdfPage.rotate;
  10105. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10106. this.viewport = pdfPage.getViewport({
  10107. scale: 1,
  10108. rotation: totalRotation
  10109. });
  10110. this.reset();
  10111. }
  10112. }, {
  10113. key: "reset",
  10114. value: function reset() {
  10115. this.cancelRendering();
  10116. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  10117. this.pageWidth = this.viewport.width;
  10118. this.pageHeight = this.viewport.height;
  10119. this.pageRatio = this.pageWidth / this.pageHeight;
  10120. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  10121. this.scale = this.canvasWidth / this.pageWidth;
  10122. this.div.removeAttribute("data-loaded");
  10123. var ring = this.ring;
  10124. var childNodes = ring.childNodes;
  10125. for (var i = childNodes.length - 1; i >= 0; i--) {
  10126. ring.removeChild(childNodes[i]);
  10127. }
  10128. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  10129. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  10130. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  10131. if (this.canvas) {
  10132. this.canvas.width = 0;
  10133. this.canvas.height = 0;
  10134. delete this.canvas;
  10135. }
  10136. if (this.image) {
  10137. this.image.removeAttribute("src");
  10138. delete this.image;
  10139. }
  10140. }
  10141. }, {
  10142. key: "update",
  10143. value: function update(rotation) {
  10144. if (typeof rotation !== "undefined") {
  10145. this.rotation = rotation;
  10146. }
  10147. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10148. this.viewport = this.viewport.clone({
  10149. scale: 1,
  10150. rotation: totalRotation
  10151. });
  10152. this.reset();
  10153. }
  10154. }, {
  10155. key: "cancelRendering",
  10156. value: function cancelRendering() {
  10157. if (this.renderTask) {
  10158. this.renderTask.cancel();
  10159. this.renderTask = null;
  10160. }
  10161. this.resume = null;
  10162. }
  10163. }, {
  10164. key: "_getPageDrawContext",
  10165. value: function _getPageDrawContext() {
  10166. var canvas = document.createElement("canvas");
  10167. this.canvas = canvas;
  10168. canvas.mozOpaque = true;
  10169. var ctx = canvas.getContext("2d", {
  10170. alpha: false
  10171. });
  10172. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  10173. canvas.width = this.canvasWidth * outputScale.sx | 0;
  10174. canvas.height = this.canvasHeight * outputScale.sy | 0;
  10175. canvas.style.width = this.canvasWidth + "px";
  10176. canvas.style.height = this.canvasHeight + "px";
  10177. var transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  10178. return [ctx, transform];
  10179. }
  10180. }, {
  10181. key: "_convertCanvasToImage",
  10182. value: function _convertCanvasToImage() {
  10183. var _this = this;
  10184. if (!this.canvas) {
  10185. return;
  10186. }
  10187. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  10188. return;
  10189. }
  10190. var className = "thumbnailImage";
  10191. if (this.disableCanvasToImageConversion) {
  10192. this.canvas.className = className;
  10193. this._thumbPageCanvas.then(function (msg) {
  10194. _this.canvas.setAttribute("aria-label", msg);
  10195. });
  10196. this.div.setAttribute("data-loaded", true);
  10197. this.ring.appendChild(this.canvas);
  10198. return;
  10199. }
  10200. var image = document.createElement("img");
  10201. image.className = className;
  10202. this._thumbPageCanvas.then(function (msg) {
  10203. image.setAttribute("aria-label", msg);
  10204. });
  10205. image.style.width = this.canvasWidth + "px";
  10206. image.style.height = this.canvasHeight + "px";
  10207. image.src = this.canvas.toDataURL();
  10208. this.image = image;
  10209. this.div.setAttribute("data-loaded", true);
  10210. this.ring.appendChild(image);
  10211. this.canvas.width = 0;
  10212. this.canvas.height = 0;
  10213. delete this.canvas;
  10214. }
  10215. }, {
  10216. key: "draw",
  10217. value: function draw() {
  10218. var _this2 = this;
  10219. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  10220. console.error("Must be in new state before drawing");
  10221. return Promise.resolve(undefined);
  10222. }
  10223. var pdfPage = this.pdfPage;
  10224. if (!pdfPage) {
  10225. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10226. return Promise.reject(new Error("pdfPage is not loaded"));
  10227. }
  10228. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10229. var finishRenderTask = /*#__PURE__*/function () {
  10230. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  10231. var error,
  10232. _args = arguments;
  10233. return _regenerator["default"].wrap(function _callee$(_context) {
  10234. while (1) {
  10235. switch (_context.prev = _context.next) {
  10236. case 0:
  10237. error = _args.length > 0 && _args[0] !== undefined ? _args[0] : null;
  10238. if (renderTask === _this2.renderTask) {
  10239. _this2.renderTask = null;
  10240. }
  10241. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  10242. _context.next = 4;
  10243. break;
  10244. }
  10245. return _context.abrupt("return");
  10246. case 4:
  10247. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10248. _this2._convertCanvasToImage();
  10249. if (!error) {
  10250. _context.next = 8;
  10251. break;
  10252. }
  10253. throw error;
  10254. case 8:
  10255. case "end":
  10256. return _context.stop();
  10257. }
  10258. }
  10259. }, _callee);
  10260. }));
  10261. return function finishRenderTask() {
  10262. return _ref2.apply(this, arguments);
  10263. };
  10264. }();
  10265. var _this$_getPageDrawCon = this._getPageDrawContext(),
  10266. _this$_getPageDrawCon2 = _slicedToArray(_this$_getPageDrawCon, 2),
  10267. ctx = _this$_getPageDrawCon2[0],
  10268. transform = _this$_getPageDrawCon2[1];
  10269. var drawViewport = this.viewport.clone({
  10270. scale: this.scale
  10271. });
  10272. var renderContinueCallback = function renderContinueCallback(cont) {
  10273. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  10274. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  10275. _this2.resume = function () {
  10276. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10277. cont();
  10278. };
  10279. return;
  10280. }
  10281. cont();
  10282. };
  10283. var renderContext = {
  10284. canvasContext: ctx,
  10285. transform: transform,
  10286. viewport: drawViewport,
  10287. optionalContentConfigPromise: this._optionalContentConfigPromise
  10288. };
  10289. var renderTask = this.renderTask = pdfPage.render(renderContext);
  10290. renderTask.onContinue = renderContinueCallback;
  10291. var resultPromise = renderTask.promise.then(function () {
  10292. finishRenderTask(null);
  10293. }, function (error) {
  10294. finishRenderTask(error);
  10295. });
  10296. resultPromise["finally"](function () {
  10297. var _this2$pdfPage;
  10298. var pageCached = _this2.linkService.isPageCached(_this2.id);
  10299. if (pageCached) {
  10300. return;
  10301. }
  10302. (_this2$pdfPage = _this2.pdfPage) === null || _this2$pdfPage === void 0 ? void 0 : _this2$pdfPage.cleanup();
  10303. });
  10304. return resultPromise;
  10305. }
  10306. }, {
  10307. key: "setImage",
  10308. value: function setImage(pageView) {
  10309. if (this._checkSetImageDisabled()) {
  10310. return;
  10311. }
  10312. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  10313. return;
  10314. }
  10315. var img = pageView.canvas;
  10316. if (!img) {
  10317. return;
  10318. }
  10319. if (!this.pdfPage) {
  10320. this.setPdfPage(pageView.pdfPage);
  10321. }
  10322. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10323. var _this$_getPageDrawCon3 = this._getPageDrawContext(),
  10324. _this$_getPageDrawCon4 = _slicedToArray(_this$_getPageDrawCon3, 1),
  10325. ctx = _this$_getPageDrawCon4[0];
  10326. var canvas = ctx.canvas;
  10327. if (img.width <= 2 * canvas.width) {
  10328. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  10329. this._convertCanvasToImage();
  10330. return;
  10331. }
  10332. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  10333. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  10334. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  10335. var reducedImageCtx = reducedImage.getContext("2d");
  10336. while (reducedWidth > img.width || reducedHeight > img.height) {
  10337. reducedWidth >>= 1;
  10338. reducedHeight >>= 1;
  10339. }
  10340. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  10341. while (reducedWidth > 2 * canvas.width) {
  10342. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  10343. reducedWidth >>= 1;
  10344. reducedHeight >>= 1;
  10345. }
  10346. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  10347. this._convertCanvasToImage();
  10348. }
  10349. }, {
  10350. key: "_thumbPageTitle",
  10351. get: function get() {
  10352. var _this$pageLabel;
  10353. return this.l10n.get("thumb_page_title", {
  10354. page: (_this$pageLabel = this.pageLabel) !== null && _this$pageLabel !== void 0 ? _this$pageLabel : this.id
  10355. });
  10356. }
  10357. }, {
  10358. key: "_thumbPageCanvas",
  10359. get: function get() {
  10360. var _this$pageLabel2;
  10361. return this.l10n.get("thumb_page_canvas", {
  10362. page: (_this$pageLabel2 = this.pageLabel) !== null && _this$pageLabel2 !== void 0 ? _this$pageLabel2 : this.id
  10363. });
  10364. }
  10365. }, {
  10366. key: "setPageLabel",
  10367. value: function setPageLabel(label) {
  10368. var _this3 = this;
  10369. this.pageLabel = typeof label === "string" ? label : null;
  10370. this._thumbPageTitle.then(function (msg) {
  10371. _this3.anchor.title = msg;
  10372. });
  10373. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  10374. return;
  10375. }
  10376. this._thumbPageCanvas.then(function (msg) {
  10377. if (_this3.image) {
  10378. _this3.image.setAttribute("aria-label", msg);
  10379. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  10380. _this3.canvas.setAttribute("aria-label", msg);
  10381. }
  10382. });
  10383. }
  10384. }]);
  10385. return PDFThumbnailView;
  10386. }();
  10387. exports.PDFThumbnailView = PDFThumbnailView;
  10388. /***/ }),
  10389. /* 29 */
  10390. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10391. 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); }
  10392. Object.defineProperty(exports, "__esModule", ({
  10393. value: true
  10394. }));
  10395. exports.PDFViewer = void 0;
  10396. var _ui_utils = __webpack_require__(6);
  10397. var _base_viewer = __webpack_require__(30);
  10398. var _pdfjsLib = __webpack_require__(7);
  10399. 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; } } }; }
  10400. 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); }
  10401. 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; }
  10402. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10403. 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); } }
  10404. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10405. 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); }
  10406. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  10407. 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); }
  10408. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10409. 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); }; }
  10410. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10411. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10412. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  10413. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10414. var PDFViewer = /*#__PURE__*/function (_BaseViewer) {
  10415. _inherits(PDFViewer, _BaseViewer);
  10416. var _super = _createSuper(PDFViewer);
  10417. function PDFViewer() {
  10418. _classCallCheck(this, PDFViewer);
  10419. return _super.apply(this, arguments);
  10420. }
  10421. _createClass(PDFViewer, [{
  10422. key: "_viewerElement",
  10423. get: function get() {
  10424. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this.viewer);
  10425. }
  10426. }, {
  10427. key: "_scrollIntoView",
  10428. value: function _scrollIntoView(_ref) {
  10429. var pageDiv = _ref.pageDiv,
  10430. _ref$pageSpot = _ref.pageSpot,
  10431. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  10432. _ref$pageNumber = _ref.pageNumber,
  10433. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  10434. if (!pageSpot && !this.isInPresentationMode) {
  10435. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  10436. var right = left + pageDiv.clientWidth;
  10437. var _this$container = this.container,
  10438. scrollLeft = _this$container.scrollLeft,
  10439. clientWidth = _this$container.clientWidth;
  10440. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  10441. pageSpot = {
  10442. left: 0,
  10443. top: 0
  10444. };
  10445. }
  10446. }
  10447. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  10448. pageDiv: pageDiv,
  10449. pageSpot: pageSpot,
  10450. pageNumber: pageNumber
  10451. });
  10452. }
  10453. }, {
  10454. key: "_getVisiblePages",
  10455. value: function _getVisiblePages() {
  10456. if (this.isInPresentationMode) {
  10457. return this._getCurrentVisiblePage();
  10458. }
  10459. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  10460. }
  10461. }, {
  10462. key: "_updateHelper",
  10463. value: function _updateHelper(visiblePages) {
  10464. if (this.isInPresentationMode) {
  10465. return;
  10466. }
  10467. var currentId = this._currentPageNumber;
  10468. var stillFullyVisible = false;
  10469. var _iterator = _createForOfIteratorHelper(visiblePages),
  10470. _step;
  10471. try {
  10472. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  10473. var page = _step.value;
  10474. if (page.percent < 100) {
  10475. break;
  10476. }
  10477. if (page.id === currentId && this._scrollMode === _ui_utils.ScrollMode.VERTICAL && this._spreadMode === _ui_utils.SpreadMode.NONE) {
  10478. stillFullyVisible = true;
  10479. break;
  10480. }
  10481. }
  10482. } catch (err) {
  10483. _iterator.e(err);
  10484. } finally {
  10485. _iterator.f();
  10486. }
  10487. if (!stillFullyVisible) {
  10488. currentId = visiblePages[0].id;
  10489. }
  10490. this._setCurrentPageNumber(currentId);
  10491. }
  10492. }]);
  10493. return PDFViewer;
  10494. }(_base_viewer.BaseViewer);
  10495. exports.PDFViewer = PDFViewer;
  10496. /***/ }),
  10497. /* 30 */
  10498. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10499. Object.defineProperty(exports, "__esModule", ({
  10500. value: true
  10501. }));
  10502. exports.BaseViewer = void 0;
  10503. var _pdfjsLib = __webpack_require__(7);
  10504. var _ui_utils = __webpack_require__(6);
  10505. var _pdf_rendering_queue = __webpack_require__(10);
  10506. var _annotation_layer_builder = __webpack_require__(31);
  10507. var _l10n_utils = __webpack_require__(32);
  10508. var _pdf_page_view = __webpack_require__(33);
  10509. var _pdf_link_service = __webpack_require__(21);
  10510. var _text_layer_builder = __webpack_require__(34);
  10511. var _xfa_layer_builder = __webpack_require__(35);
  10512. 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; } } }; }
  10513. 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); }
  10514. 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; }
  10515. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10516. 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); } }
  10517. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10518. var DEFAULT_CACHE_SIZE = 10;
  10519. function PDFPageViewBuffer(size) {
  10520. var data = [];
  10521. this.push = function (view) {
  10522. var i = data.indexOf(view);
  10523. if (i >= 0) {
  10524. data.splice(i, 1);
  10525. }
  10526. data.push(view);
  10527. if (data.length > size) {
  10528. data.shift().destroy();
  10529. }
  10530. };
  10531. this.resize = function (newSize, pagesToKeep) {
  10532. size = newSize;
  10533. if (pagesToKeep) {
  10534. var pageIdsToKeep = new Set();
  10535. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  10536. pageIdsToKeep.add(pagesToKeep[i].id);
  10537. }
  10538. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  10539. return pageIdsToKeep.has(page.id);
  10540. });
  10541. }
  10542. while (data.length > size) {
  10543. data.shift().destroy();
  10544. }
  10545. };
  10546. this.has = function (view) {
  10547. return data.includes(view);
  10548. };
  10549. }
  10550. function isSameScale(oldScale, newScale) {
  10551. if (newScale === oldScale) {
  10552. return true;
  10553. }
  10554. if (Math.abs(newScale - oldScale) < 1e-15) {
  10555. return true;
  10556. }
  10557. return false;
  10558. }
  10559. var BaseViewer = /*#__PURE__*/function () {
  10560. function BaseViewer(options) {
  10561. var _this$container,
  10562. _this$viewer,
  10563. _this = this;
  10564. _classCallCheck(this, BaseViewer);
  10565. if (this.constructor === BaseViewer) {
  10566. throw new Error("Cannot initialize BaseViewer.");
  10567. }
  10568. var viewerVersion = '2.8.335';
  10569. if (_pdfjsLib.version !== viewerVersion) {
  10570. throw new Error("The API version \"".concat(_pdfjsLib.version, "\" does not match the Viewer version \"").concat(viewerVersion, "\"."));
  10571. }
  10572. this._name = this.constructor.name;
  10573. this.container = options.container;
  10574. this.viewer = options.viewer || options.container.firstElementChild;
  10575. 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")) {
  10576. throw new Error("Invalid `container` and/or `viewer` option.");
  10577. }
  10578. if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") {
  10579. throw new Error("The `container` must be absolutely positioned.");
  10580. }
  10581. this.eventBus = options.eventBus;
  10582. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  10583. this.downloadManager = options.downloadManager || null;
  10584. this.findController = options.findController || null;
  10585. this._scriptingManager = options.scriptingManager || null;
  10586. this.removePageBorders = options.removePageBorders || false;
  10587. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  10588. this.imageResourcesPath = options.imageResourcesPath || "";
  10589. this.renderInteractiveForms = options.renderInteractiveForms !== false;
  10590. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  10591. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  10592. this.enableWebGL = options.enableWebGL || false;
  10593. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  10594. this.maxCanvasPixels = options.maxCanvasPixels;
  10595. this.l10n = options.l10n || _l10n_utils.NullL10n;
  10596. this.enableScripting = options.enableScripting === true && !!this._scriptingManager;
  10597. this.defaultRenderingQueue = !options.renderingQueue;
  10598. if (this.defaultRenderingQueue) {
  10599. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  10600. this.renderingQueue.setViewer(this);
  10601. } else {
  10602. this.renderingQueue = options.renderingQueue;
  10603. }
  10604. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  10605. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  10606. this._onBeforeDraw = this._onAfterDraw = null;
  10607. this._resetView();
  10608. if (this.removePageBorders) {
  10609. this.viewer.classList.add("removePageBorders");
  10610. }
  10611. Promise.resolve().then(function () {
  10612. _this.eventBus.dispatch("baseviewerinit", {
  10613. source: _this
  10614. });
  10615. });
  10616. }
  10617. _createClass(BaseViewer, [{
  10618. key: "pagesCount",
  10619. get: function get() {
  10620. return this._pages.length;
  10621. }
  10622. }, {
  10623. key: "getPageView",
  10624. value: function getPageView(index) {
  10625. return this._pages[index];
  10626. }
  10627. }, {
  10628. key: "pageViewsReady",
  10629. get: function get() {
  10630. if (!this._pagesCapability.settled) {
  10631. return false;
  10632. }
  10633. return this._pages.every(function (pageView) {
  10634. return pageView === null || pageView === void 0 ? void 0 : pageView.pdfPage;
  10635. });
  10636. }
  10637. }, {
  10638. key: "currentPageNumber",
  10639. get: function get() {
  10640. return this._currentPageNumber;
  10641. },
  10642. set: function set(val) {
  10643. if (!Number.isInteger(val)) {
  10644. throw new Error("Invalid page number.");
  10645. }
  10646. if (!this.pdfDocument) {
  10647. return;
  10648. }
  10649. if (!this._setCurrentPageNumber(val, true)) {
  10650. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  10651. }
  10652. }
  10653. }, {
  10654. key: "_setCurrentPageNumber",
  10655. value: function _setCurrentPageNumber(val) {
  10656. var _this$_pageLabels, _this$_pageLabels2;
  10657. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10658. if (this._currentPageNumber === val) {
  10659. if (resetCurrentPageView) {
  10660. this._resetCurrentPageView();
  10661. }
  10662. return true;
  10663. }
  10664. if (!(0 < val && val <= this.pagesCount)) {
  10665. return false;
  10666. }
  10667. var previous = this._currentPageNumber;
  10668. this._currentPageNumber = val;
  10669. this.eventBus.dispatch("pagechanging", {
  10670. source: this,
  10671. pageNumber: val,
  10672. pageLabel: (_this$_pageLabels = (_this$_pageLabels2 = this._pageLabels) === null || _this$_pageLabels2 === void 0 ? void 0 : _this$_pageLabels2[val - 1]) !== null && _this$_pageLabels !== void 0 ? _this$_pageLabels : null,
  10673. previous: previous
  10674. });
  10675. if (resetCurrentPageView) {
  10676. this._resetCurrentPageView();
  10677. }
  10678. return true;
  10679. }
  10680. }, {
  10681. key: "currentPageLabel",
  10682. get: function get() {
  10683. var _this$_pageLabels3, _this$_pageLabels4;
  10684. return (_this$_pageLabels3 = (_this$_pageLabels4 = this._pageLabels) === null || _this$_pageLabels4 === void 0 ? void 0 : _this$_pageLabels4[this._currentPageNumber - 1]) !== null && _this$_pageLabels3 !== void 0 ? _this$_pageLabels3 : null;
  10685. },
  10686. set: function set(val) {
  10687. if (!this.pdfDocument) {
  10688. return;
  10689. }
  10690. var page = val | 0;
  10691. if (this._pageLabels) {
  10692. var i = this._pageLabels.indexOf(val);
  10693. if (i >= 0) {
  10694. page = i + 1;
  10695. }
  10696. }
  10697. if (!this._setCurrentPageNumber(page, true)) {
  10698. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  10699. }
  10700. }
  10701. }, {
  10702. key: "currentScale",
  10703. get: function get() {
  10704. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  10705. },
  10706. set: function set(val) {
  10707. if (isNaN(val)) {
  10708. throw new Error("Invalid numeric scale.");
  10709. }
  10710. if (!this.pdfDocument) {
  10711. return;
  10712. }
  10713. this._setScale(val, false);
  10714. }
  10715. }, {
  10716. key: "currentScaleValue",
  10717. get: function get() {
  10718. return this._currentScaleValue;
  10719. },
  10720. set: function set(val) {
  10721. if (!this.pdfDocument) {
  10722. return;
  10723. }
  10724. this._setScale(val, false);
  10725. }
  10726. }, {
  10727. key: "pagesRotation",
  10728. get: function get() {
  10729. return this._pagesRotation;
  10730. },
  10731. set: function set(rotation) {
  10732. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  10733. throw new Error("Invalid pages rotation angle.");
  10734. }
  10735. if (!this.pdfDocument) {
  10736. return;
  10737. }
  10738. rotation %= 360;
  10739. if (rotation < 0) {
  10740. rotation += 360;
  10741. }
  10742. if (this._pagesRotation === rotation) {
  10743. return;
  10744. }
  10745. this._pagesRotation = rotation;
  10746. var pageNumber = this._currentPageNumber;
  10747. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10748. var pageView = this._pages[i];
  10749. pageView.update(pageView.scale, rotation);
  10750. }
  10751. if (this._currentScaleValue) {
  10752. this._setScale(this._currentScaleValue, true);
  10753. }
  10754. this.eventBus.dispatch("rotationchanging", {
  10755. source: this,
  10756. pagesRotation: rotation,
  10757. pageNumber: pageNumber
  10758. });
  10759. if (this.defaultRenderingQueue) {
  10760. this.update();
  10761. }
  10762. }
  10763. }, {
  10764. key: "firstPagePromise",
  10765. get: function get() {
  10766. return this.pdfDocument ? this._firstPageCapability.promise : null;
  10767. }
  10768. }, {
  10769. key: "onePageRendered",
  10770. get: function get() {
  10771. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  10772. }
  10773. }, {
  10774. key: "pagesPromise",
  10775. get: function get() {
  10776. return this.pdfDocument ? this._pagesCapability.promise : null;
  10777. }
  10778. }, {
  10779. key: "_viewerElement",
  10780. get: function get() {
  10781. throw new Error("Not implemented: _viewerElement");
  10782. }
  10783. }, {
  10784. key: "_onePageRenderedOrForceFetch",
  10785. value: function _onePageRenderedOrForceFetch() {
  10786. if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  10787. return Promise.resolve();
  10788. }
  10789. return this._onePageRenderedCapability.promise;
  10790. }
  10791. }, {
  10792. key: "setDocument",
  10793. value: function setDocument(pdfDocument) {
  10794. var _this2 = this;
  10795. if (this.pdfDocument) {
  10796. this.eventBus.dispatch("pagesdestroy", {
  10797. source: this
  10798. });
  10799. this._cancelRendering();
  10800. this._resetView();
  10801. if (this.findController) {
  10802. this.findController.setDocument(null);
  10803. }
  10804. if (this._scriptingManager) {
  10805. this._scriptingManager.setDocument(null);
  10806. }
  10807. }
  10808. this.pdfDocument = pdfDocument;
  10809. if (!pdfDocument) {
  10810. return;
  10811. }
  10812. var isPureXfa = pdfDocument.isPureXfa;
  10813. var pagesCount = pdfDocument.numPages;
  10814. var firstPagePromise = pdfDocument.getPage(1);
  10815. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  10816. this._pagesCapability.promise.then(function () {
  10817. _this2.eventBus.dispatch("pagesloaded", {
  10818. source: _this2,
  10819. pagesCount: pagesCount
  10820. });
  10821. });
  10822. this._onBeforeDraw = function (evt) {
  10823. var pageView = _this2._pages[evt.pageNumber - 1];
  10824. if (!pageView) {
  10825. return;
  10826. }
  10827. _this2._buffer.push(pageView);
  10828. };
  10829. this.eventBus._on("pagerender", this._onBeforeDraw);
  10830. this._onAfterDraw = function (evt) {
  10831. if (evt.cssTransform || _this2._onePageRenderedCapability.settled) {
  10832. return;
  10833. }
  10834. _this2._onePageRenderedCapability.resolve();
  10835. _this2.eventBus._off("pagerendered", _this2._onAfterDraw);
  10836. _this2._onAfterDraw = null;
  10837. };
  10838. this.eventBus._on("pagerendered", this._onAfterDraw);
  10839. firstPagePromise.then(function (firstPdfPage) {
  10840. _this2._firstPageCapability.resolve(firstPdfPage);
  10841. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  10842. var scale = _this2.currentScale;
  10843. var viewport = firstPdfPage.getViewport({
  10844. scale: scale * _ui_utils.CSS_UNITS
  10845. });
  10846. var textLayerFactory = _this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? _this2 : null;
  10847. var xfaLayerFactory = isPureXfa ? _this2 : null;
  10848. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  10849. var pageView = new _pdf_page_view.PDFPageView({
  10850. container: _this2._viewerElement,
  10851. eventBus: _this2.eventBus,
  10852. id: pageNum,
  10853. scale: scale,
  10854. defaultViewport: viewport.clone(),
  10855. optionalContentConfigPromise: optionalContentConfigPromise,
  10856. renderingQueue: _this2.renderingQueue,
  10857. textLayerFactory: textLayerFactory,
  10858. textLayerMode: _this2.textLayerMode,
  10859. annotationLayerFactory: _this2,
  10860. xfaLayerFactory: xfaLayerFactory,
  10861. imageResourcesPath: _this2.imageResourcesPath,
  10862. renderInteractiveForms: _this2.renderInteractiveForms,
  10863. renderer: _this2.renderer,
  10864. enableWebGL: _this2.enableWebGL,
  10865. useOnlyCssZoom: _this2.useOnlyCssZoom,
  10866. maxCanvasPixels: _this2.maxCanvasPixels,
  10867. l10n: _this2.l10n,
  10868. enableScripting: _this2.enableScripting
  10869. });
  10870. _this2._pages.push(pageView);
  10871. }
  10872. var firstPageView = _this2._pages[0];
  10873. if (firstPageView) {
  10874. firstPageView.setPdfPage(firstPdfPage);
  10875. _this2.linkService.cachePageRef(1, firstPdfPage.ref);
  10876. }
  10877. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  10878. _this2._updateSpreadMode();
  10879. }
  10880. _this2._onePageRenderedOrForceFetch().then(function () {
  10881. if (_this2.findController) {
  10882. _this2.findController.setDocument(pdfDocument);
  10883. }
  10884. if (_this2.enableScripting) {
  10885. _this2._scriptingManager.setDocument(pdfDocument);
  10886. }
  10887. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
  10888. _this2._pagesCapability.resolve();
  10889. return;
  10890. }
  10891. var getPagesLeft = pagesCount - 1;
  10892. if (getPagesLeft <= 0) {
  10893. _this2._pagesCapability.resolve();
  10894. return;
  10895. }
  10896. var _loop = function _loop(_pageNum) {
  10897. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  10898. var pageView = _this2._pages[_pageNum - 1];
  10899. if (!pageView.pdfPage) {
  10900. pageView.setPdfPage(pdfPage);
  10901. }
  10902. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  10903. if (--getPagesLeft === 0) {
  10904. _this2._pagesCapability.resolve();
  10905. }
  10906. }, function (reason) {
  10907. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  10908. if (--getPagesLeft === 0) {
  10909. _this2._pagesCapability.resolve();
  10910. }
  10911. });
  10912. };
  10913. for (var _pageNum = 2; _pageNum <= pagesCount; ++_pageNum) {
  10914. _loop(_pageNum);
  10915. }
  10916. });
  10917. _this2.eventBus.dispatch("pagesinit", {
  10918. source: _this2
  10919. });
  10920. if (_this2.defaultRenderingQueue) {
  10921. _this2.update();
  10922. }
  10923. })["catch"](function (reason) {
  10924. console.error("Unable to initialize viewer", reason);
  10925. });
  10926. }
  10927. }, {
  10928. key: "setPageLabels",
  10929. value: function setPageLabels(labels) {
  10930. if (!this.pdfDocument) {
  10931. return;
  10932. }
  10933. if (!labels) {
  10934. this._pageLabels = null;
  10935. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  10936. this._pageLabels = null;
  10937. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  10938. } else {
  10939. this._pageLabels = labels;
  10940. }
  10941. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10942. var _this$_pageLabels$i, _this$_pageLabels5;
  10943. this._pages[i].setPageLabel((_this$_pageLabels$i = (_this$_pageLabels5 = this._pageLabels) === null || _this$_pageLabels5 === void 0 ? void 0 : _this$_pageLabels5[i]) !== null && _this$_pageLabels$i !== void 0 ? _this$_pageLabels$i : null);
  10944. }
  10945. }
  10946. }, {
  10947. key: "_resetView",
  10948. value: function _resetView() {
  10949. this._pages = [];
  10950. this._currentPageNumber = 1;
  10951. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  10952. this._currentScaleValue = null;
  10953. this._pageLabels = null;
  10954. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  10955. this._location = null;
  10956. this._pagesRotation = 0;
  10957. this._optionalContentConfigPromise = null;
  10958. this._pagesRequests = new WeakMap();
  10959. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  10960. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  10961. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  10962. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  10963. this._spreadMode = _ui_utils.SpreadMode.NONE;
  10964. if (this._onBeforeDraw) {
  10965. this.eventBus._off("pagerender", this._onBeforeDraw);
  10966. this._onBeforeDraw = null;
  10967. }
  10968. if (this._onAfterDraw) {
  10969. this.eventBus._off("pagerendered", this._onAfterDraw);
  10970. this._onAfterDraw = null;
  10971. }
  10972. this.viewer.textContent = "";
  10973. this._updateScrollMode();
  10974. }
  10975. }, {
  10976. key: "_scrollUpdate",
  10977. value: function _scrollUpdate() {
  10978. if (this.pagesCount === 0) {
  10979. return;
  10980. }
  10981. this.update();
  10982. }
  10983. }, {
  10984. key: "_scrollIntoView",
  10985. value: function _scrollIntoView(_ref) {
  10986. var pageDiv = _ref.pageDiv,
  10987. _ref$pageSpot = _ref.pageSpot,
  10988. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  10989. _ref$pageNumber = _ref.pageNumber,
  10990. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  10991. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  10992. }
  10993. }, {
  10994. key: "_setScaleUpdatePages",
  10995. value: function _setScaleUpdatePages(newScale, newValue) {
  10996. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  10997. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10998. this._currentScaleValue = newValue.toString();
  10999. if (isSameScale(this._currentScale, newScale)) {
  11000. if (preset) {
  11001. this.eventBus.dispatch("scalechanging", {
  11002. source: this,
  11003. scale: newScale,
  11004. presetValue: newValue
  11005. });
  11006. }
  11007. return;
  11008. }
  11009. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  11010. this._pages[i].update(newScale);
  11011. }
  11012. this._currentScale = newScale;
  11013. if (!noScroll) {
  11014. var page = this._currentPageNumber,
  11015. dest;
  11016. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  11017. page = this._location.pageNumber;
  11018. dest = [null, {
  11019. name: "XYZ"
  11020. }, this._location.left, this._location.top, null];
  11021. }
  11022. this.scrollPageIntoView({
  11023. pageNumber: page,
  11024. destArray: dest,
  11025. allowNegativeOffset: true
  11026. });
  11027. }
  11028. this.eventBus.dispatch("scalechanging", {
  11029. source: this,
  11030. scale: newScale,
  11031. presetValue: preset ? newValue : undefined
  11032. });
  11033. if (this.defaultRenderingQueue) {
  11034. this.update();
  11035. }
  11036. }
  11037. }, {
  11038. key: "_pageWidthScaleFactor",
  11039. get: function get() {
  11040. if (this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL && !this.isInPresentationMode) {
  11041. return 2;
  11042. }
  11043. return 1;
  11044. }
  11045. }, {
  11046. key: "_setScale",
  11047. value: function _setScale(value) {
  11048. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  11049. var scale = parseFloat(value);
  11050. if (scale > 0) {
  11051. this._setScaleUpdatePages(scale, value, noScroll, false);
  11052. } else {
  11053. var currentPage = this._pages[this._currentPageNumber - 1];
  11054. if (!currentPage) {
  11055. return;
  11056. }
  11057. var noPadding = this.isInPresentationMode || this.removePageBorders;
  11058. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  11059. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  11060. if (!noPadding && this._isScrollModeHorizontal) {
  11061. var _ref2 = [vPadding, hPadding];
  11062. hPadding = _ref2[0];
  11063. vPadding = _ref2[1];
  11064. }
  11065. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this._pageWidthScaleFactor;
  11066. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  11067. switch (value) {
  11068. case "page-actual":
  11069. scale = 1;
  11070. break;
  11071. case "page-width":
  11072. scale = pageWidthScale;
  11073. break;
  11074. case "page-height":
  11075. scale = pageHeightScale;
  11076. break;
  11077. case "page-fit":
  11078. scale = Math.min(pageWidthScale, pageHeightScale);
  11079. break;
  11080. case "auto":
  11081. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  11082. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  11083. break;
  11084. default:
  11085. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  11086. return;
  11087. }
  11088. this._setScaleUpdatePages(scale, value, noScroll, true);
  11089. }
  11090. }
  11091. }, {
  11092. key: "_resetCurrentPageView",
  11093. value: function _resetCurrentPageView() {
  11094. if (this.isInPresentationMode) {
  11095. this._setScale(this._currentScaleValue, true);
  11096. }
  11097. var pageView = this._pages[this._currentPageNumber - 1];
  11098. this._scrollIntoView({
  11099. pageDiv: pageView.div
  11100. });
  11101. }
  11102. }, {
  11103. key: "pageLabelToPageNumber",
  11104. value: function pageLabelToPageNumber(label) {
  11105. if (!this._pageLabels) {
  11106. return null;
  11107. }
  11108. var i = this._pageLabels.indexOf(label);
  11109. if (i < 0) {
  11110. return null;
  11111. }
  11112. return i + 1;
  11113. }
  11114. }, {
  11115. key: "scrollPageIntoView",
  11116. value: function scrollPageIntoView(_ref3) {
  11117. var pageNumber = _ref3.pageNumber,
  11118. _ref3$destArray = _ref3.destArray,
  11119. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  11120. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  11121. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf,
  11122. _ref3$ignoreDestinati = _ref3.ignoreDestinationZoom,
  11123. ignoreDestinationZoom = _ref3$ignoreDestinati === void 0 ? false : _ref3$ignoreDestinati;
  11124. if (!this.pdfDocument) {
  11125. return;
  11126. }
  11127. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  11128. if (!pageView) {
  11129. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  11130. return;
  11131. }
  11132. if (this.isInPresentationMode || !destArray) {
  11133. this._setCurrentPageNumber(pageNumber, true);
  11134. return;
  11135. }
  11136. var x = 0,
  11137. y = 0;
  11138. var width = 0,
  11139. height = 0,
  11140. widthScale,
  11141. heightScale;
  11142. var changeOrientation = pageView.rotation % 180 !== 0;
  11143. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  11144. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  11145. var scale = 0;
  11146. switch (destArray[1].name) {
  11147. case "XYZ":
  11148. x = destArray[2];
  11149. y = destArray[3];
  11150. scale = destArray[4];
  11151. x = x !== null ? x : 0;
  11152. y = y !== null ? y : pageHeight;
  11153. break;
  11154. case "Fit":
  11155. case "FitB":
  11156. scale = "page-fit";
  11157. break;
  11158. case "FitH":
  11159. case "FitBH":
  11160. y = destArray[2];
  11161. scale = "page-width";
  11162. if (y === null && this._location) {
  11163. x = this._location.left;
  11164. y = this._location.top;
  11165. } else if (typeof y !== "number") {
  11166. y = pageHeight;
  11167. }
  11168. break;
  11169. case "FitV":
  11170. case "FitBV":
  11171. x = destArray[2];
  11172. width = pageWidth;
  11173. height = pageHeight;
  11174. scale = "page-height";
  11175. break;
  11176. case "FitR":
  11177. x = destArray[2];
  11178. y = destArray[3];
  11179. width = destArray[4] - x;
  11180. height = destArray[5] - y;
  11181. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  11182. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  11183. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  11184. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  11185. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  11186. break;
  11187. default:
  11188. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  11189. return;
  11190. }
  11191. if (!ignoreDestinationZoom) {
  11192. if (scale && scale !== this._currentScale) {
  11193. this.currentScaleValue = scale;
  11194. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  11195. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  11196. }
  11197. }
  11198. if (scale === "page-fit" && !destArray[4]) {
  11199. this._scrollIntoView({
  11200. pageDiv: pageView.div,
  11201. pageNumber: pageNumber
  11202. });
  11203. return;
  11204. }
  11205. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  11206. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  11207. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  11208. if (!allowNegativeOffset) {
  11209. left = Math.max(left, 0);
  11210. top = Math.max(top, 0);
  11211. }
  11212. this._scrollIntoView({
  11213. pageDiv: pageView.div,
  11214. pageSpot: {
  11215. left: left,
  11216. top: top
  11217. },
  11218. pageNumber: pageNumber
  11219. });
  11220. }
  11221. }, {
  11222. key: "_updateLocation",
  11223. value: function _updateLocation(firstPage) {
  11224. var currentScale = this._currentScale;
  11225. var currentScaleValue = this._currentScaleValue;
  11226. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  11227. var pageNumber = firstPage.id;
  11228. var pdfOpenParams = "#page=" + pageNumber;
  11229. pdfOpenParams += "&zoom=" + normalizedScaleValue;
  11230. var currentPageView = this._pages[pageNumber - 1];
  11231. var container = this.container;
  11232. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  11233. var intLeft = Math.round(topLeft[0]);
  11234. var intTop = Math.round(topLeft[1]);
  11235. pdfOpenParams += "," + intLeft + "," + intTop;
  11236. this._location = {
  11237. pageNumber: pageNumber,
  11238. scale: normalizedScaleValue,
  11239. top: intTop,
  11240. left: intLeft,
  11241. rotation: this._pagesRotation,
  11242. pdfOpenParams: pdfOpenParams
  11243. };
  11244. }
  11245. }, {
  11246. key: "_updateHelper",
  11247. value: function _updateHelper(visiblePages) {
  11248. throw new Error("Not implemented: _updateHelper");
  11249. }
  11250. }, {
  11251. key: "update",
  11252. value: function update() {
  11253. var visible = this._getVisiblePages();
  11254. var visiblePages = visible.views,
  11255. numVisiblePages = visiblePages.length;
  11256. if (numVisiblePages === 0) {
  11257. return;
  11258. }
  11259. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  11260. this._buffer.resize(newCacheSize, visiblePages);
  11261. this.renderingQueue.renderHighestPriority(visible);
  11262. this._updateHelper(visiblePages);
  11263. this._updateLocation(visible.first);
  11264. this.eventBus.dispatch("updateviewarea", {
  11265. source: this,
  11266. location: this._location
  11267. });
  11268. }
  11269. }, {
  11270. key: "containsElement",
  11271. value: function containsElement(element) {
  11272. return this.container.contains(element);
  11273. }
  11274. }, {
  11275. key: "focus",
  11276. value: function focus() {
  11277. this.container.focus();
  11278. }
  11279. }, {
  11280. key: "_isScrollModeHorizontal",
  11281. get: function get() {
  11282. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  11283. }
  11284. }, {
  11285. key: "_isContainerRtl",
  11286. get: function get() {
  11287. return getComputedStyle(this.container).direction === "rtl";
  11288. }
  11289. }, {
  11290. key: "isInPresentationMode",
  11291. get: function get() {
  11292. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  11293. }
  11294. }, {
  11295. key: "isChangingPresentationMode",
  11296. get: function get() {
  11297. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  11298. }
  11299. }, {
  11300. key: "isHorizontalScrollbarEnabled",
  11301. get: function get() {
  11302. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  11303. }
  11304. }, {
  11305. key: "isVerticalScrollbarEnabled",
  11306. get: function get() {
  11307. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  11308. }
  11309. }, {
  11310. key: "_getCurrentVisiblePage",
  11311. value: function _getCurrentVisiblePage() {
  11312. if (!this.pagesCount) {
  11313. return {
  11314. views: []
  11315. };
  11316. }
  11317. var pageView = this._pages[this._currentPageNumber - 1];
  11318. var element = pageView.div;
  11319. var view = {
  11320. id: pageView.id,
  11321. x: element.offsetLeft + element.clientLeft,
  11322. y: element.offsetTop + element.clientTop,
  11323. view: pageView
  11324. };
  11325. return {
  11326. first: view,
  11327. last: view,
  11328. views: [view]
  11329. };
  11330. }
  11331. }, {
  11332. key: "_getVisiblePages",
  11333. value: function _getVisiblePages() {
  11334. return (0, _ui_utils.getVisibleElements)({
  11335. scrollEl: this.container,
  11336. views: this._pages,
  11337. sortByVisibility: true,
  11338. horizontal: this._isScrollModeHorizontal,
  11339. rtl: this._isScrollModeHorizontal && this._isContainerRtl
  11340. });
  11341. }
  11342. }, {
  11343. key: "isPageVisible",
  11344. value: function isPageVisible(pageNumber) {
  11345. if (!this.pdfDocument) {
  11346. return false;
  11347. }
  11348. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  11349. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is not a valid page."));
  11350. return false;
  11351. }
  11352. return this._getVisiblePages().views.some(function (view) {
  11353. return view.id === pageNumber;
  11354. });
  11355. }
  11356. }, {
  11357. key: "isPageCached",
  11358. value: function isPageCached(pageNumber) {
  11359. if (!this.pdfDocument || !this._buffer) {
  11360. return false;
  11361. }
  11362. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  11363. console.error("".concat(this._name, ".isPageCached: \"").concat(pageNumber, "\" is not a valid page."));
  11364. return false;
  11365. }
  11366. var pageView = this._pages[pageNumber - 1];
  11367. if (!pageView) {
  11368. return false;
  11369. }
  11370. return this._buffer.has(pageView);
  11371. }
  11372. }, {
  11373. key: "cleanup",
  11374. value: function cleanup() {
  11375. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  11376. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  11377. this._pages[i].reset();
  11378. }
  11379. }
  11380. }
  11381. }, {
  11382. key: "_cancelRendering",
  11383. value: function _cancelRendering() {
  11384. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  11385. if (this._pages[i]) {
  11386. this._pages[i].cancelRendering();
  11387. }
  11388. }
  11389. }
  11390. }, {
  11391. key: "_ensurePdfPageLoaded",
  11392. value: function _ensurePdfPageLoaded(pageView) {
  11393. var _this3 = this;
  11394. if (pageView.pdfPage) {
  11395. return Promise.resolve(pageView.pdfPage);
  11396. }
  11397. if (this._pagesRequests.has(pageView)) {
  11398. return this._pagesRequests.get(pageView);
  11399. }
  11400. var promise = this.pdfDocument.getPage(pageView.id).then(function (pdfPage) {
  11401. if (!pageView.pdfPage) {
  11402. pageView.setPdfPage(pdfPage);
  11403. }
  11404. _this3._pagesRequests["delete"](pageView);
  11405. return pdfPage;
  11406. })["catch"](function (reason) {
  11407. console.error("Unable to get page for page view", reason);
  11408. _this3._pagesRequests["delete"](pageView);
  11409. });
  11410. this._pagesRequests.set(pageView, promise);
  11411. return promise;
  11412. }
  11413. }, {
  11414. key: "forceRendering",
  11415. value: function forceRendering(currentlyVisiblePages) {
  11416. var _this4 = this;
  11417. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  11418. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  11419. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  11420. if (pageView) {
  11421. this._ensurePdfPageLoaded(pageView).then(function () {
  11422. _this4.renderingQueue.renderView(pageView);
  11423. });
  11424. return true;
  11425. }
  11426. return false;
  11427. }
  11428. }, {
  11429. key: "createTextLayerBuilder",
  11430. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  11431. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  11432. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  11433. return new _text_layer_builder.TextLayerBuilder({
  11434. textLayerDiv: textLayerDiv,
  11435. eventBus: eventBus,
  11436. pageIndex: pageIndex,
  11437. viewport: viewport,
  11438. findController: this.isInPresentationMode ? null : this.findController,
  11439. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  11440. });
  11441. }
  11442. }, {
  11443. key: "createAnnotationLayerBuilder",
  11444. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  11445. var _this$pdfDocument, _this$pdfDocument2, _this$_scriptingManag;
  11446. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  11447. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  11448. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  11449. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _l10n_utils.NullL10n;
  11450. var enableScripting = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
  11451. var hasJSActionsPromise = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  11452. var mouseState = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
  11453. return new _annotation_layer_builder.AnnotationLayerBuilder({
  11454. pageDiv: pageDiv,
  11455. pdfPage: pdfPage,
  11456. annotationStorage: annotationStorage || ((_this$pdfDocument = this.pdfDocument) === null || _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage),
  11457. imageResourcesPath: imageResourcesPath,
  11458. renderInteractiveForms: renderInteractiveForms,
  11459. linkService: this.linkService,
  11460. downloadManager: this.downloadManager,
  11461. l10n: l10n,
  11462. enableScripting: enableScripting,
  11463. hasJSActionsPromise: hasJSActionsPromise || ((_this$pdfDocument2 = this.pdfDocument) === null || _this$pdfDocument2 === void 0 ? void 0 : _this$pdfDocument2.hasJSActions()),
  11464. mouseState: mouseState || ((_this$_scriptingManag = this._scriptingManager) === null || _this$_scriptingManag === void 0 ? void 0 : _this$_scriptingManag.mouseState)
  11465. });
  11466. }
  11467. }, {
  11468. key: "createXfaLayerBuilder",
  11469. value: function createXfaLayerBuilder(pageDiv, pdfPage) {
  11470. return new _xfa_layer_builder.XfaLayerBuilder({
  11471. pageDiv: pageDiv,
  11472. pdfPage: pdfPage
  11473. });
  11474. }
  11475. }, {
  11476. key: "hasEqualPageSizes",
  11477. get: function get() {
  11478. var firstPageView = this._pages[0];
  11479. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  11480. var pageView = this._pages[i];
  11481. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  11482. return false;
  11483. }
  11484. }
  11485. return true;
  11486. }
  11487. }, {
  11488. key: "getPagesOverview",
  11489. value: function getPagesOverview() {
  11490. var _this5 = this;
  11491. return this._pages.map(function (pageView) {
  11492. var viewport = pageView.pdfPage.getViewport({
  11493. scale: 1
  11494. });
  11495. if (!_this5.enablePrintAutoRotate || (0, _ui_utils.isPortraitOrientation)(viewport)) {
  11496. return {
  11497. width: viewport.width,
  11498. height: viewport.height,
  11499. rotation: viewport.rotation
  11500. };
  11501. }
  11502. return {
  11503. width: viewport.height,
  11504. height: viewport.width,
  11505. rotation: (viewport.rotation - 90) % 360
  11506. };
  11507. });
  11508. }
  11509. }, {
  11510. key: "optionalContentConfigPromise",
  11511. get: function get() {
  11512. if (!this.pdfDocument) {
  11513. return Promise.resolve(null);
  11514. }
  11515. if (!this._optionalContentConfigPromise) {
  11516. return this.pdfDocument.getOptionalContentConfig();
  11517. }
  11518. return this._optionalContentConfigPromise;
  11519. },
  11520. set: function set(promise) {
  11521. if (!(promise instanceof Promise)) {
  11522. throw new Error("Invalid optionalContentConfigPromise: ".concat(promise));
  11523. }
  11524. if (!this.pdfDocument) {
  11525. return;
  11526. }
  11527. if (!this._optionalContentConfigPromise) {
  11528. return;
  11529. }
  11530. this._optionalContentConfigPromise = promise;
  11531. var _iterator = _createForOfIteratorHelper(this._pages),
  11532. _step;
  11533. try {
  11534. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11535. var pageView = _step.value;
  11536. pageView.update(pageView.scale, pageView.rotation, promise);
  11537. }
  11538. } catch (err) {
  11539. _iterator.e(err);
  11540. } finally {
  11541. _iterator.f();
  11542. }
  11543. this.update();
  11544. this.eventBus.dispatch("optionalcontentconfigchanged", {
  11545. source: this,
  11546. promise: promise
  11547. });
  11548. }
  11549. }, {
  11550. key: "scrollMode",
  11551. get: function get() {
  11552. return this._scrollMode;
  11553. },
  11554. set: function set(mode) {
  11555. if (this._scrollMode === mode) {
  11556. return;
  11557. }
  11558. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  11559. throw new Error("Invalid scroll mode: ".concat(mode));
  11560. }
  11561. this._scrollMode = mode;
  11562. this.eventBus.dispatch("scrollmodechanged", {
  11563. source: this,
  11564. mode: mode
  11565. });
  11566. this._updateScrollMode(this._currentPageNumber);
  11567. }
  11568. }, {
  11569. key: "_updateScrollMode",
  11570. value: function _updateScrollMode() {
  11571. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11572. var scrollMode = this._scrollMode,
  11573. viewer = this.viewer;
  11574. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  11575. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  11576. if (!this.pdfDocument || !pageNumber) {
  11577. return;
  11578. }
  11579. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  11580. this._setScale(this._currentScaleValue, true);
  11581. }
  11582. this._setCurrentPageNumber(pageNumber, true);
  11583. this.update();
  11584. }
  11585. }, {
  11586. key: "spreadMode",
  11587. get: function get() {
  11588. return this._spreadMode;
  11589. },
  11590. set: function set(mode) {
  11591. if (this._spreadMode === mode) {
  11592. return;
  11593. }
  11594. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  11595. throw new Error("Invalid spread mode: ".concat(mode));
  11596. }
  11597. this._spreadMode = mode;
  11598. this.eventBus.dispatch("spreadmodechanged", {
  11599. source: this,
  11600. mode: mode
  11601. });
  11602. this._updateSpreadMode(this._currentPageNumber);
  11603. }
  11604. }, {
  11605. key: "_updateSpreadMode",
  11606. value: function _updateSpreadMode() {
  11607. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11608. if (!this.pdfDocument) {
  11609. return;
  11610. }
  11611. var viewer = this.viewer,
  11612. pages = this._pages;
  11613. viewer.textContent = "";
  11614. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  11615. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  11616. viewer.appendChild(pages[i].div);
  11617. }
  11618. } else {
  11619. var parity = this._spreadMode - 1;
  11620. var spread = null;
  11621. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  11622. if (spread === null) {
  11623. spread = document.createElement("div");
  11624. spread.className = "spread";
  11625. viewer.appendChild(spread);
  11626. } else if (_i % 2 === parity) {
  11627. spread = spread.cloneNode(false);
  11628. viewer.appendChild(spread);
  11629. }
  11630. spread.appendChild(pages[_i].div);
  11631. }
  11632. }
  11633. if (!pageNumber) {
  11634. return;
  11635. }
  11636. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  11637. this._setScale(this._currentScaleValue, true);
  11638. }
  11639. this._setCurrentPageNumber(pageNumber, true);
  11640. this.update();
  11641. }
  11642. }, {
  11643. key: "_getPageAdvance",
  11644. value: function _getPageAdvance(currentPageNumber) {
  11645. var previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  11646. if (this.isInPresentationMode) {
  11647. return 1;
  11648. }
  11649. switch (this._scrollMode) {
  11650. case _ui_utils.ScrollMode.WRAPPED:
  11651. {
  11652. var _this$_getVisiblePage = this._getVisiblePages(),
  11653. views = _this$_getVisiblePage.views,
  11654. pageLayout = new Map();
  11655. var _iterator2 = _createForOfIteratorHelper(views),
  11656. _step2;
  11657. try {
  11658. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  11659. var _step2$value = _step2.value,
  11660. id = _step2$value.id,
  11661. y = _step2$value.y,
  11662. percent = _step2$value.percent,
  11663. widthPercent = _step2$value.widthPercent;
  11664. if (percent === 0 || widthPercent < 100) {
  11665. continue;
  11666. }
  11667. var yArray = pageLayout.get(y);
  11668. if (!yArray) {
  11669. pageLayout.set(y, yArray || (yArray = []));
  11670. }
  11671. yArray.push(id);
  11672. }
  11673. } catch (err) {
  11674. _iterator2.e(err);
  11675. } finally {
  11676. _iterator2.f();
  11677. }
  11678. var _iterator3 = _createForOfIteratorHelper(pageLayout.values()),
  11679. _step3;
  11680. try {
  11681. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  11682. var _yArray = _step3.value;
  11683. var currentIndex = _yArray.indexOf(currentPageNumber);
  11684. if (currentIndex === -1) {
  11685. continue;
  11686. }
  11687. var numPages = _yArray.length;
  11688. if (numPages === 1) {
  11689. break;
  11690. }
  11691. if (previous) {
  11692. for (var i = currentIndex - 1, ii = 0; i >= ii; i--) {
  11693. var currentId = _yArray[i],
  11694. expectedId = _yArray[i + 1] - 1;
  11695. if (currentId < expectedId) {
  11696. return currentPageNumber - expectedId;
  11697. }
  11698. }
  11699. } else {
  11700. for (var _i2 = currentIndex + 1, _ii = numPages; _i2 < _ii; _i2++) {
  11701. var _currentId = _yArray[_i2],
  11702. _expectedId = _yArray[_i2 - 1] + 1;
  11703. if (_currentId > _expectedId) {
  11704. return _expectedId - currentPageNumber;
  11705. }
  11706. }
  11707. }
  11708. if (previous) {
  11709. var firstId = _yArray[0];
  11710. if (firstId < currentPageNumber) {
  11711. return currentPageNumber - firstId + 1;
  11712. }
  11713. } else {
  11714. var lastId = _yArray[numPages - 1];
  11715. if (lastId > currentPageNumber) {
  11716. return lastId - currentPageNumber + 1;
  11717. }
  11718. }
  11719. break;
  11720. }
  11721. } catch (err) {
  11722. _iterator3.e(err);
  11723. } finally {
  11724. _iterator3.f();
  11725. }
  11726. break;
  11727. }
  11728. case _ui_utils.ScrollMode.HORIZONTAL:
  11729. {
  11730. break;
  11731. }
  11732. case _ui_utils.ScrollMode.VERTICAL:
  11733. {
  11734. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  11735. break;
  11736. }
  11737. var parity = this._spreadMode - 1;
  11738. if (previous && currentPageNumber % 2 !== parity) {
  11739. break;
  11740. } else if (!previous && currentPageNumber % 2 === parity) {
  11741. break;
  11742. }
  11743. var _this$_getVisiblePage2 = this._getVisiblePages(),
  11744. _views = _this$_getVisiblePage2.views,
  11745. _expectedId2 = previous ? currentPageNumber - 1 : currentPageNumber + 1;
  11746. var _iterator4 = _createForOfIteratorHelper(_views),
  11747. _step4;
  11748. try {
  11749. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  11750. var _step4$value = _step4.value,
  11751. _id = _step4$value.id,
  11752. _percent = _step4$value.percent,
  11753. _widthPercent = _step4$value.widthPercent;
  11754. if (_id !== _expectedId2) {
  11755. continue;
  11756. }
  11757. if (_percent > 0 && _widthPercent === 100) {
  11758. return 2;
  11759. }
  11760. break;
  11761. }
  11762. } catch (err) {
  11763. _iterator4.e(err);
  11764. } finally {
  11765. _iterator4.f();
  11766. }
  11767. break;
  11768. }
  11769. }
  11770. return 1;
  11771. }
  11772. }, {
  11773. key: "nextPage",
  11774. value: function nextPage() {
  11775. var currentPageNumber = this._currentPageNumber,
  11776. pagesCount = this.pagesCount;
  11777. if (currentPageNumber >= pagesCount) {
  11778. return false;
  11779. }
  11780. var advance = this._getPageAdvance(currentPageNumber, false) || 1;
  11781. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  11782. return true;
  11783. }
  11784. }, {
  11785. key: "previousPage",
  11786. value: function previousPage() {
  11787. var currentPageNumber = this._currentPageNumber;
  11788. if (currentPageNumber <= 1) {
  11789. return false;
  11790. }
  11791. var advance = this._getPageAdvance(currentPageNumber, true) || 1;
  11792. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  11793. return true;
  11794. }
  11795. }]);
  11796. return BaseViewer;
  11797. }();
  11798. exports.BaseViewer = BaseViewer;
  11799. /***/ }),
  11800. /* 31 */
  11801. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11802. Object.defineProperty(exports, "__esModule", ({
  11803. value: true
  11804. }));
  11805. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  11806. var _pdfjsLib = __webpack_require__(7);
  11807. var _l10n_utils = __webpack_require__(32);
  11808. var _pdf_link_service = __webpack_require__(21);
  11809. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  11810. 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."); }
  11811. 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); }
  11812. 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; }
  11813. 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; }
  11814. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  11815. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11816. 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); } }
  11817. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11818. var AnnotationLayerBuilder = /*#__PURE__*/function () {
  11819. function AnnotationLayerBuilder(_ref) {
  11820. var pageDiv = _ref.pageDiv,
  11821. pdfPage = _ref.pdfPage,
  11822. linkService = _ref.linkService,
  11823. downloadManager = _ref.downloadManager,
  11824. _ref$annotationStorag = _ref.annotationStorage,
  11825. annotationStorage = _ref$annotationStorag === void 0 ? null : _ref$annotationStorag,
  11826. _ref$imageResourcesPa = _ref.imageResourcesPath,
  11827. imageResourcesPath = _ref$imageResourcesPa === void 0 ? "" : _ref$imageResourcesPa,
  11828. _ref$renderInteractiv = _ref.renderInteractiveForms,
  11829. renderInteractiveForms = _ref$renderInteractiv === void 0 ? true : _ref$renderInteractiv,
  11830. _ref$l10n = _ref.l10n,
  11831. l10n = _ref$l10n === void 0 ? _l10n_utils.NullL10n : _ref$l10n,
  11832. _ref$enableScripting = _ref.enableScripting,
  11833. enableScripting = _ref$enableScripting === void 0 ? false : _ref$enableScripting,
  11834. _ref$hasJSActionsProm = _ref.hasJSActionsPromise,
  11835. hasJSActionsPromise = _ref$hasJSActionsProm === void 0 ? null : _ref$hasJSActionsProm,
  11836. _ref$mouseState = _ref.mouseState,
  11837. mouseState = _ref$mouseState === void 0 ? null : _ref$mouseState;
  11838. _classCallCheck(this, AnnotationLayerBuilder);
  11839. this.pageDiv = pageDiv;
  11840. this.pdfPage = pdfPage;
  11841. this.linkService = linkService;
  11842. this.downloadManager = downloadManager;
  11843. this.imageResourcesPath = imageResourcesPath;
  11844. this.renderInteractiveForms = renderInteractiveForms;
  11845. this.l10n = l10n;
  11846. this.annotationStorage = annotationStorage;
  11847. this.enableScripting = enableScripting;
  11848. this._hasJSActionsPromise = hasJSActionsPromise;
  11849. this._mouseState = mouseState;
  11850. this.div = null;
  11851. this._cancelled = false;
  11852. }
  11853. _createClass(AnnotationLayerBuilder, [{
  11854. key: "render",
  11855. value: function render(viewport) {
  11856. var _this = this;
  11857. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  11858. return Promise.all([this.pdfPage.getAnnotations({
  11859. intent: intent
  11860. }), this._hasJSActionsPromise]).then(function (_ref2) {
  11861. var _ref3 = _slicedToArray(_ref2, 2),
  11862. annotations = _ref3[0],
  11863. _ref3$ = _ref3[1],
  11864. hasJSActions = _ref3$ === void 0 ? false : _ref3$;
  11865. if (_this._cancelled) {
  11866. return;
  11867. }
  11868. if (annotations.length === 0) {
  11869. return;
  11870. }
  11871. var parameters = {
  11872. viewport: viewport.clone({
  11873. dontFlip: true
  11874. }),
  11875. div: _this.div,
  11876. annotations: annotations,
  11877. page: _this.pdfPage,
  11878. imageResourcesPath: _this.imageResourcesPath,
  11879. renderInteractiveForms: _this.renderInteractiveForms,
  11880. linkService: _this.linkService,
  11881. downloadManager: _this.downloadManager,
  11882. annotationStorage: _this.annotationStorage,
  11883. enableScripting: _this.enableScripting,
  11884. hasJSActions: hasJSActions,
  11885. mouseState: _this._mouseState
  11886. };
  11887. if (_this.div) {
  11888. _pdfjsLib.AnnotationLayer.update(parameters);
  11889. } else {
  11890. _this.div = document.createElement("div");
  11891. _this.div.className = "annotationLayer";
  11892. _this.pageDiv.appendChild(_this.div);
  11893. parameters.div = _this.div;
  11894. _pdfjsLib.AnnotationLayer.render(parameters);
  11895. _this.l10n.translate(_this.div);
  11896. }
  11897. });
  11898. }
  11899. }, {
  11900. key: "cancel",
  11901. value: function cancel() {
  11902. this._cancelled = true;
  11903. }
  11904. }, {
  11905. key: "hide",
  11906. value: function hide() {
  11907. if (!this.div) {
  11908. return;
  11909. }
  11910. this.div.hidden = true;
  11911. }
  11912. }]);
  11913. return AnnotationLayerBuilder;
  11914. }();
  11915. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  11916. var DefaultAnnotationLayerFactory = /*#__PURE__*/function () {
  11917. function DefaultAnnotationLayerFactory() {
  11918. _classCallCheck(this, DefaultAnnotationLayerFactory);
  11919. }
  11920. _createClass(DefaultAnnotationLayerFactory, [{
  11921. key: "createAnnotationLayerBuilder",
  11922. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  11923. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  11924. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  11925. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  11926. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _l10n_utils.NullL10n;
  11927. var enableScripting = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
  11928. var hasJSActionsPromise = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  11929. var mouseState = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
  11930. return new AnnotationLayerBuilder({
  11931. pageDiv: pageDiv,
  11932. pdfPage: pdfPage,
  11933. imageResourcesPath: imageResourcesPath,
  11934. renderInteractiveForms: renderInteractiveForms,
  11935. linkService: new _pdf_link_service.SimpleLinkService(),
  11936. l10n: l10n,
  11937. annotationStorage: annotationStorage,
  11938. enableScripting: enableScripting,
  11939. hasJSActionsPromise: hasJSActionsPromise,
  11940. mouseState: mouseState
  11941. });
  11942. }
  11943. }]);
  11944. return DefaultAnnotationLayerFactory;
  11945. }();
  11946. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  11947. /***/ }),
  11948. /* 32 */
  11949. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11950. Object.defineProperty(exports, "__esModule", ({
  11951. value: true
  11952. }));
  11953. exports.getL10nFallback = getL10nFallback;
  11954. exports.NullL10n = void 0;
  11955. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  11956. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11957. 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); } }
  11958. 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); }); }; }
  11959. var DEFAULT_L10N_STRINGS = {
  11960. of_pages: "of {{pagesCount}}",
  11961. page_of_pages: "({{pageNumber}} of {{pagesCount}})",
  11962. document_properties_kb: "{{size_kb}} KB ({{size_b}} bytes)",
  11963. document_properties_mb: "{{size_mb}} MB ({{size_b}} bytes)",
  11964. document_properties_date_string: "{{date}}, {{time}}",
  11965. document_properties_page_size_unit_inches: "in",
  11966. document_properties_page_size_unit_millimeters: "mm",
  11967. document_properties_page_size_orientation_portrait: "portrait",
  11968. document_properties_page_size_orientation_landscape: "landscape",
  11969. document_properties_page_size_name_a3: "A3",
  11970. document_properties_page_size_name_a4: "A4",
  11971. document_properties_page_size_name_letter: "Letter",
  11972. document_properties_page_size_name_legal: "Legal",
  11973. document_properties_page_size_dimension_string: "{{width}} × {{height}} {{unit}} ({{orientation}})",
  11974. document_properties_page_size_dimension_name_string: "{{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})",
  11975. document_properties_linearized_yes: "Yes",
  11976. document_properties_linearized_no: "No",
  11977. print_progress_percent: "{{progress}}%",
  11978. "toggle_sidebar.title": "Toggle Sidebar",
  11979. "toggle_sidebar_notification2.title": "Toggle Sidebar (document contains outline/attachments/layers)",
  11980. additional_layers: "Additional Layers",
  11981. page_landmark: "Page {{page}}",
  11982. thumb_page_title: "Page {{page}}",
  11983. thumb_page_canvas: "Thumbnail of Page {{page}}",
  11984. find_reached_top: "Reached top of document, continued from bottom",
  11985. find_reached_bottom: "Reached end of document, continued from top",
  11986. "find_match_count[one]": "{{current}} of {{total}} match",
  11987. "find_match_count[other]": "{{current}} of {{total}} matches",
  11988. "find_match_count_limit[one]": "More than {{limit}} match",
  11989. "find_match_count_limit[other]": "More than {{limit}} matches",
  11990. find_not_found: "Phrase not found",
  11991. error_version_info: "PDF.js v{{version}} (build: {{build}})",
  11992. error_message: "Message: {{message}}",
  11993. error_stack: "Stack: {{stack}}",
  11994. error_file: "File: {{file}}",
  11995. error_line: "Line: {{line}}",
  11996. rendering_error: "An error occurred while rendering the page.",
  11997. page_scale_width: "Page Width",
  11998. page_scale_fit: "Page Fit",
  11999. page_scale_auto: "Automatic Zoom",
  12000. page_scale_actual: "Actual Size",
  12001. page_scale_percent: "{{scale}}%",
  12002. loading: "Loading…",
  12003. loading_error: "An error occurred while loading the PDF.",
  12004. invalid_file_error: "Invalid or corrupted PDF file.",
  12005. missing_file_error: "Missing PDF file.",
  12006. unexpected_response_error: "Unexpected server response.",
  12007. printing_not_supported: "Warning: Printing is not fully supported by this browser.",
  12008. printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
  12009. web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts."
  12010. };
  12011. function getL10nFallback(key, args) {
  12012. switch (key) {
  12013. case "find_match_count":
  12014. key = "find_match_count[".concat(args.total === 1 ? "one" : "other", "]");
  12015. break;
  12016. case "find_match_count_limit":
  12017. key = "find_match_count_limit[".concat(args.limit === 1 ? "one" : "other", "]");
  12018. break;
  12019. }
  12020. return DEFAULT_L10N_STRINGS[key] || "";
  12021. }
  12022. function formatL10nValue(text, args) {
  12023. if (!args) {
  12024. return text;
  12025. }
  12026. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  12027. return name in args ? args[name] : "{{" + name + "}}";
  12028. });
  12029. }
  12030. var NullL10n = {
  12031. getLanguage: function getLanguage() {
  12032. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  12033. return _regenerator["default"].wrap(function _callee$(_context) {
  12034. while (1) {
  12035. switch (_context.prev = _context.next) {
  12036. case 0:
  12037. return _context.abrupt("return", "en-us");
  12038. case 1:
  12039. case "end":
  12040. return _context.stop();
  12041. }
  12042. }
  12043. }, _callee);
  12044. }))();
  12045. },
  12046. getDirection: function getDirection() {
  12047. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  12048. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12049. while (1) {
  12050. switch (_context2.prev = _context2.next) {
  12051. case 0:
  12052. return _context2.abrupt("return", "ltr");
  12053. case 1:
  12054. case "end":
  12055. return _context2.stop();
  12056. }
  12057. }
  12058. }, _callee2);
  12059. }))();
  12060. },
  12061. get: function get(key) {
  12062. var _arguments = arguments;
  12063. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  12064. var args, fallback;
  12065. return _regenerator["default"].wrap(function _callee3$(_context3) {
  12066. while (1) {
  12067. switch (_context3.prev = _context3.next) {
  12068. case 0:
  12069. args = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : null;
  12070. fallback = _arguments.length > 2 && _arguments[2] !== undefined ? _arguments[2] : getL10nFallback(key, args);
  12071. return _context3.abrupt("return", formatL10nValue(fallback, args));
  12072. case 3:
  12073. case "end":
  12074. return _context3.stop();
  12075. }
  12076. }
  12077. }, _callee3);
  12078. }))();
  12079. },
  12080. translate: function translate(element) {
  12081. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  12082. return _regenerator["default"].wrap(function _callee4$(_context4) {
  12083. while (1) {
  12084. switch (_context4.prev = _context4.next) {
  12085. case 0:
  12086. case "end":
  12087. return _context4.stop();
  12088. }
  12089. }
  12090. }, _callee4);
  12091. }))();
  12092. }
  12093. };
  12094. exports.NullL10n = NullL10n;
  12095. /***/ }),
  12096. /* 33 */
  12097. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12098. Object.defineProperty(exports, "__esModule", ({
  12099. value: true
  12100. }));
  12101. exports.PDFPageView = void 0;
  12102. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  12103. var _ui_utils = __webpack_require__(6);
  12104. var _pdfjsLib = __webpack_require__(7);
  12105. var _l10n_utils = __webpack_require__(32);
  12106. var _pdf_rendering_queue = __webpack_require__(10);
  12107. var _viewer_compatibility = __webpack_require__(2);
  12108. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12109. 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); } }
  12110. 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); }); }; }
  12111. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12112. 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); } }
  12113. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12114. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  12115. var PDFPageView = /*#__PURE__*/function () {
  12116. function PDFPageView(options) {
  12117. _classCallCheck(this, PDFPageView);
  12118. var container = options.container;
  12119. var defaultViewport = options.defaultViewport;
  12120. this.id = options.id;
  12121. this.renderingId = "page" + this.id;
  12122. this.pdfPage = null;
  12123. this.pageLabel = null;
  12124. this.rotation = 0;
  12125. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  12126. this.viewport = defaultViewport;
  12127. this.pdfPageRotate = defaultViewport.rotation;
  12128. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  12129. this.hasRestrictedScaling = false;
  12130. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  12131. this.imageResourcesPath = options.imageResourcesPath || "";
  12132. this.renderInteractiveForms = options.renderInteractiveForms !== false;
  12133. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  12134. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  12135. this.eventBus = options.eventBus;
  12136. this.renderingQueue = options.renderingQueue;
  12137. this.textLayerFactory = options.textLayerFactory;
  12138. this.annotationLayerFactory = options.annotationLayerFactory;
  12139. this.xfaLayerFactory = options.xfaLayerFactory;
  12140. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  12141. this.enableWebGL = options.enableWebGL || false;
  12142. this.l10n = options.l10n || _l10n_utils.NullL10n;
  12143. this.enableScripting = options.enableScripting === true;
  12144. this.paintTask = null;
  12145. this.paintedViewportMap = new WeakMap();
  12146. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  12147. this.resume = null;
  12148. this._renderError = null;
  12149. this.annotationLayer = null;
  12150. this.textLayer = null;
  12151. this.zoomLayer = null;
  12152. this.xfaLayer = null;
  12153. var div = document.createElement("div");
  12154. div.className = "page";
  12155. div.style.width = Math.floor(this.viewport.width) + "px";
  12156. div.style.height = Math.floor(this.viewport.height) + "px";
  12157. div.setAttribute("data-page-number", this.id);
  12158. div.setAttribute("role", "region");
  12159. this.l10n.get("page_landmark", {
  12160. page: this.id
  12161. }).then(function (msg) {
  12162. div.setAttribute("aria-label", msg);
  12163. });
  12164. this.div = div;
  12165. container.appendChild(div);
  12166. }
  12167. _createClass(PDFPageView, [{
  12168. key: "setPdfPage",
  12169. value: function setPdfPage(pdfPage) {
  12170. this.pdfPage = pdfPage;
  12171. this.pdfPageRotate = pdfPage.rotate;
  12172. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  12173. this.viewport = pdfPage.getViewport({
  12174. scale: this.scale * _ui_utils.CSS_UNITS,
  12175. rotation: totalRotation
  12176. });
  12177. this.reset();
  12178. }
  12179. }, {
  12180. key: "destroy",
  12181. value: function destroy() {
  12182. this.reset();
  12183. if (this.pdfPage) {
  12184. this.pdfPage.cleanup();
  12185. }
  12186. }
  12187. }, {
  12188. key: "_renderAnnotationLayer",
  12189. value: function () {
  12190. var _renderAnnotationLayer2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  12191. var error;
  12192. return _regenerator["default"].wrap(function _callee$(_context) {
  12193. while (1) {
  12194. switch (_context.prev = _context.next) {
  12195. case 0:
  12196. error = null;
  12197. _context.prev = 1;
  12198. _context.next = 4;
  12199. return this.annotationLayer.render(this.viewport, "display");
  12200. case 4:
  12201. _context.next = 9;
  12202. break;
  12203. case 6:
  12204. _context.prev = 6;
  12205. _context.t0 = _context["catch"](1);
  12206. error = _context.t0;
  12207. case 9:
  12208. _context.prev = 9;
  12209. this.eventBus.dispatch("annotationlayerrendered", {
  12210. source: this,
  12211. pageNumber: this.id,
  12212. error: error
  12213. });
  12214. return _context.finish(9);
  12215. case 12:
  12216. case "end":
  12217. return _context.stop();
  12218. }
  12219. }
  12220. }, _callee, this, [[1, 6, 9, 12]]);
  12221. }));
  12222. function _renderAnnotationLayer() {
  12223. return _renderAnnotationLayer2.apply(this, arguments);
  12224. }
  12225. return _renderAnnotationLayer;
  12226. }()
  12227. }, {
  12228. key: "_renderXfaLayer",
  12229. value: function () {
  12230. var _renderXfaLayer2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  12231. var error;
  12232. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12233. while (1) {
  12234. switch (_context2.prev = _context2.next) {
  12235. case 0:
  12236. error = null;
  12237. _context2.prev = 1;
  12238. _context2.next = 4;
  12239. return this.xfaLayer.render(this.viewport, "display");
  12240. case 4:
  12241. _context2.next = 9;
  12242. break;
  12243. case 6:
  12244. _context2.prev = 6;
  12245. _context2.t0 = _context2["catch"](1);
  12246. error = _context2.t0;
  12247. case 9:
  12248. _context2.prev = 9;
  12249. this.eventBus.dispatch("xfalayerrendered", {
  12250. source: this,
  12251. pageNumber: this.id,
  12252. error: error
  12253. });
  12254. return _context2.finish(9);
  12255. case 12:
  12256. case "end":
  12257. return _context2.stop();
  12258. }
  12259. }
  12260. }, _callee2, this, [[1, 6, 9, 12]]);
  12261. }));
  12262. function _renderXfaLayer() {
  12263. return _renderXfaLayer2.apply(this, arguments);
  12264. }
  12265. return _renderXfaLayer;
  12266. }()
  12267. }, {
  12268. key: "_resetZoomLayer",
  12269. value: function _resetZoomLayer() {
  12270. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12271. if (!this.zoomLayer) {
  12272. return;
  12273. }
  12274. var zoomLayerCanvas = this.zoomLayer.firstChild;
  12275. this.paintedViewportMap["delete"](zoomLayerCanvas);
  12276. zoomLayerCanvas.width = 0;
  12277. zoomLayerCanvas.height = 0;
  12278. if (removeFromDOM) {
  12279. this.zoomLayer.remove();
  12280. }
  12281. this.zoomLayer = null;
  12282. }
  12283. }, {
  12284. key: "reset",
  12285. value: function reset() {
  12286. var _this$annotationLayer,
  12287. _this$xfaLayer,
  12288. _this = this;
  12289. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12290. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12291. this.cancelRendering(keepAnnotations);
  12292. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  12293. var div = this.div;
  12294. div.style.width = Math.floor(this.viewport.width) + "px";
  12295. div.style.height = Math.floor(this.viewport.height) + "px";
  12296. var childNodes = div.childNodes;
  12297. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  12298. var currentAnnotationNode = keepAnnotations && ((_this$annotationLayer = this.annotationLayer) === null || _this$annotationLayer === void 0 ? void 0 : _this$annotationLayer.div) || null;
  12299. var currentXfaLayerNode = ((_this$xfaLayer = this.xfaLayer) === null || _this$xfaLayer === void 0 ? void 0 : _this$xfaLayer.div) || null;
  12300. for (var i = childNodes.length - 1; i >= 0; i--) {
  12301. var node = childNodes[i];
  12302. if (currentZoomLayerNode === node || currentAnnotationNode === node || currentXfaLayerNode === node) {
  12303. continue;
  12304. }
  12305. div.removeChild(node);
  12306. }
  12307. div.removeAttribute("data-loaded");
  12308. if (currentAnnotationNode) {
  12309. this.annotationLayer.hide();
  12310. } else if (this.annotationLayer) {
  12311. this.annotationLayer.cancel();
  12312. this.annotationLayer = null;
  12313. }
  12314. if (!currentZoomLayerNode) {
  12315. if (this.canvas) {
  12316. this.paintedViewportMap["delete"](this.canvas);
  12317. this.canvas.width = 0;
  12318. this.canvas.height = 0;
  12319. delete this.canvas;
  12320. }
  12321. this._resetZoomLayer();
  12322. }
  12323. if (this.svg) {
  12324. this.paintedViewportMap["delete"](this.svg);
  12325. delete this.svg;
  12326. }
  12327. this.loadingIconDiv = document.createElement("div");
  12328. this.loadingIconDiv.className = "loadingIcon";
  12329. this.loadingIconDiv.setAttribute("role", "img");
  12330. this.l10n.get("loading").then(function (msg) {
  12331. var _this$loadingIconDiv;
  12332. (_this$loadingIconDiv = _this.loadingIconDiv) === null || _this$loadingIconDiv === void 0 ? void 0 : _this$loadingIconDiv.setAttribute("aria-label", msg);
  12333. });
  12334. div.appendChild(this.loadingIconDiv);
  12335. }
  12336. }, {
  12337. key: "update",
  12338. value: function update(scale, rotation) {
  12339. var optionalContentConfigPromise = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  12340. this.scale = scale || this.scale;
  12341. if (typeof rotation !== "undefined") {
  12342. this.rotation = rotation;
  12343. }
  12344. if (optionalContentConfigPromise instanceof Promise) {
  12345. this._optionalContentConfigPromise = optionalContentConfigPromise;
  12346. }
  12347. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  12348. this.viewport = this.viewport.clone({
  12349. scale: this.scale * _ui_utils.CSS_UNITS,
  12350. rotation: totalRotation
  12351. });
  12352. if (this.svg) {
  12353. this.cssTransform(this.svg, true);
  12354. this.eventBus.dispatch("pagerendered", {
  12355. source: this,
  12356. pageNumber: this.id,
  12357. cssTransform: true,
  12358. timestamp: performance.now(),
  12359. error: this._renderError
  12360. });
  12361. return;
  12362. }
  12363. var isScalingRestricted = false;
  12364. if (this.canvas && this.maxCanvasPixels > 0) {
  12365. var outputScale = this.outputScale;
  12366. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  12367. isScalingRestricted = true;
  12368. }
  12369. }
  12370. if (this.canvas) {
  12371. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  12372. this.cssTransform(this.canvas, true);
  12373. this.eventBus.dispatch("pagerendered", {
  12374. source: this,
  12375. pageNumber: this.id,
  12376. cssTransform: true,
  12377. timestamp: performance.now(),
  12378. error: this._renderError
  12379. });
  12380. return;
  12381. }
  12382. if (!this.zoomLayer && !this.canvas.hidden) {
  12383. this.zoomLayer = this.canvas.parentNode;
  12384. this.zoomLayer.style.position = "absolute";
  12385. }
  12386. }
  12387. if (this.zoomLayer) {
  12388. this.cssTransform(this.zoomLayer.firstChild);
  12389. }
  12390. this.reset(true, true);
  12391. }
  12392. }, {
  12393. key: "cancelRendering",
  12394. value: function cancelRendering() {
  12395. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12396. if (this.paintTask) {
  12397. this.paintTask.cancel();
  12398. this.paintTask = null;
  12399. }
  12400. this.resume = null;
  12401. if (this.textLayer) {
  12402. this.textLayer.cancel();
  12403. this.textLayer = null;
  12404. }
  12405. if (!keepAnnotations && this.annotationLayer) {
  12406. this.annotationLayer.cancel();
  12407. this.annotationLayer = null;
  12408. }
  12409. }
  12410. }, {
  12411. key: "cssTransform",
  12412. value: function cssTransform(target) {
  12413. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12414. var width = this.viewport.width;
  12415. var height = this.viewport.height;
  12416. var div = this.div;
  12417. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
  12418. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
  12419. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  12420. var absRotation = Math.abs(relativeRotation);
  12421. var scaleX = 1,
  12422. scaleY = 1;
  12423. if (absRotation === 90 || absRotation === 270) {
  12424. scaleX = height / width;
  12425. scaleY = width / height;
  12426. }
  12427. target.style.transform = "rotate(".concat(relativeRotation, "deg) scale(").concat(scaleX, ", ").concat(scaleY, ")");
  12428. if (this.textLayer) {
  12429. var textLayerViewport = this.textLayer.viewport;
  12430. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  12431. var textAbsRotation = Math.abs(textRelativeRotation);
  12432. var scale = width / textLayerViewport.width;
  12433. if (textAbsRotation === 90 || textAbsRotation === 270) {
  12434. scale = width / textLayerViewport.height;
  12435. }
  12436. var textLayerDiv = this.textLayer.textLayerDiv;
  12437. var transX, transY;
  12438. switch (textAbsRotation) {
  12439. case 0:
  12440. transX = transY = 0;
  12441. break;
  12442. case 90:
  12443. transX = 0;
  12444. transY = "-" + textLayerDiv.style.height;
  12445. break;
  12446. case 180:
  12447. transX = "-" + textLayerDiv.style.width;
  12448. transY = "-" + textLayerDiv.style.height;
  12449. break;
  12450. case 270:
  12451. transX = "-" + textLayerDiv.style.width;
  12452. transY = 0;
  12453. break;
  12454. default:
  12455. console.error("Bad rotation value.");
  12456. break;
  12457. }
  12458. textLayerDiv.style.transform = "rotate(".concat(textAbsRotation, "deg) ") + "scale(".concat(scale, ") ") + "translate(".concat(transX, ", ").concat(transY, ")");
  12459. textLayerDiv.style.transformOrigin = "0% 0%";
  12460. }
  12461. if (redrawAnnotations && this.annotationLayer) {
  12462. this._renderAnnotationLayer();
  12463. }
  12464. if (this.xfaLayer) {
  12465. this._renderXfaLayer();
  12466. }
  12467. }
  12468. }, {
  12469. key: "width",
  12470. get: function get() {
  12471. return this.viewport.width;
  12472. }
  12473. }, {
  12474. key: "height",
  12475. get: function get() {
  12476. return this.viewport.height;
  12477. }
  12478. }, {
  12479. key: "getPagePoint",
  12480. value: function getPagePoint(x, y) {
  12481. return this.viewport.convertToPdfPoint(x, y);
  12482. }
  12483. }, {
  12484. key: "draw",
  12485. value: function draw() {
  12486. var _this$annotationLayer2,
  12487. _this2 = this;
  12488. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  12489. console.error("Must be in new state before drawing");
  12490. this.reset();
  12491. }
  12492. var div = this.div,
  12493. pdfPage = this.pdfPage;
  12494. if (!pdfPage) {
  12495. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  12496. if (this.loadingIconDiv) {
  12497. div.removeChild(this.loadingIconDiv);
  12498. delete this.loadingIconDiv;
  12499. }
  12500. return Promise.reject(new Error("pdfPage is not loaded"));
  12501. }
  12502. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  12503. var canvasWrapper = document.createElement("div");
  12504. canvasWrapper.style.width = div.style.width;
  12505. canvasWrapper.style.height = div.style.height;
  12506. canvasWrapper.classList.add("canvasWrapper");
  12507. if ((_this$annotationLayer2 = this.annotationLayer) !== null && _this$annotationLayer2 !== void 0 && _this$annotationLayer2.div) {
  12508. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  12509. } else {
  12510. div.appendChild(canvasWrapper);
  12511. }
  12512. var textLayer = null;
  12513. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  12514. var _this$annotationLayer3;
  12515. var textLayerDiv = document.createElement("div");
  12516. textLayerDiv.className = "textLayer";
  12517. textLayerDiv.style.width = canvasWrapper.style.width;
  12518. textLayerDiv.style.height = canvasWrapper.style.height;
  12519. if ((_this$annotationLayer3 = this.annotationLayer) !== null && _this$annotationLayer3 !== void 0 && _this$annotationLayer3.div) {
  12520. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  12521. } else {
  12522. div.appendChild(textLayerDiv);
  12523. }
  12524. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, this.eventBus);
  12525. }
  12526. this.textLayer = textLayer;
  12527. var renderContinueCallback = null;
  12528. if (this.renderingQueue) {
  12529. renderContinueCallback = function renderContinueCallback(cont) {
  12530. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  12531. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  12532. _this2.resume = function () {
  12533. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  12534. cont();
  12535. };
  12536. return;
  12537. }
  12538. cont();
  12539. };
  12540. }
  12541. var finishPaintTask = /*#__PURE__*/function () {
  12542. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  12543. var error,
  12544. _args3 = arguments;
  12545. return _regenerator["default"].wrap(function _callee3$(_context3) {
  12546. while (1) {
  12547. switch (_context3.prev = _context3.next) {
  12548. case 0:
  12549. error = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : null;
  12550. if (paintTask === _this2.paintTask) {
  12551. _this2.paintTask = null;
  12552. }
  12553. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  12554. _context3.next = 5;
  12555. break;
  12556. }
  12557. _this2._renderError = null;
  12558. return _context3.abrupt("return");
  12559. case 5:
  12560. _this2._renderError = error;
  12561. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  12562. if (_this2.loadingIconDiv) {
  12563. div.removeChild(_this2.loadingIconDiv);
  12564. delete _this2.loadingIconDiv;
  12565. }
  12566. _this2._resetZoomLayer(true);
  12567. _this2.eventBus.dispatch("pagerendered", {
  12568. source: _this2,
  12569. pageNumber: _this2.id,
  12570. cssTransform: false,
  12571. timestamp: performance.now(),
  12572. error: _this2._renderError
  12573. });
  12574. if (!error) {
  12575. _context3.next = 12;
  12576. break;
  12577. }
  12578. throw error;
  12579. case 12:
  12580. case "end":
  12581. return _context3.stop();
  12582. }
  12583. }
  12584. }, _callee3);
  12585. }));
  12586. return function finishPaintTask() {
  12587. return _ref.apply(this, arguments);
  12588. };
  12589. }();
  12590. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  12591. paintTask.onRenderContinue = renderContinueCallback;
  12592. this.paintTask = paintTask;
  12593. var resultPromise = paintTask.promise.then(function () {
  12594. return finishPaintTask(null).then(function () {
  12595. if (textLayer) {
  12596. var readableStream = pdfPage.streamTextContent({
  12597. normalizeWhitespace: true
  12598. });
  12599. textLayer.setTextContentStream(readableStream);
  12600. textLayer.render();
  12601. }
  12602. });
  12603. }, function (reason) {
  12604. return finishPaintTask(reason);
  12605. });
  12606. if (this.annotationLayerFactory) {
  12607. if (!this.annotationLayer) {
  12608. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, null, this.imageResourcesPath, this.renderInteractiveForms, this.l10n, this.enableScripting, null, null);
  12609. }
  12610. this._renderAnnotationLayer();
  12611. }
  12612. if (this.xfaLayerFactory) {
  12613. if (!this.xfaLayer) {
  12614. this.xfaLayer = this.xfaLayerFactory.createXfaLayerBuilder(div, pdfPage);
  12615. }
  12616. this._renderXfaLayer();
  12617. }
  12618. div.setAttribute("data-loaded", true);
  12619. this.eventBus.dispatch("pagerender", {
  12620. source: this,
  12621. pageNumber: this.id
  12622. });
  12623. return resultPromise;
  12624. }
  12625. }, {
  12626. key: "paintOnCanvas",
  12627. value: function paintOnCanvas(canvasWrapper) {
  12628. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  12629. var result = {
  12630. promise: renderCapability.promise,
  12631. onRenderContinue: function onRenderContinue(cont) {
  12632. cont();
  12633. },
  12634. cancel: function cancel() {
  12635. renderTask.cancel();
  12636. }
  12637. };
  12638. var viewport = this.viewport;
  12639. var canvas = document.createElement("canvas");
  12640. canvas.hidden = true;
  12641. var isCanvasHidden = true;
  12642. var showCanvas = function showCanvas() {
  12643. if (isCanvasHidden) {
  12644. canvas.hidden = false;
  12645. isCanvasHidden = false;
  12646. }
  12647. };
  12648. canvasWrapper.appendChild(canvas);
  12649. this.canvas = canvas;
  12650. canvas.mozOpaque = true;
  12651. var ctx = canvas.getContext("2d", {
  12652. alpha: false
  12653. });
  12654. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  12655. this.outputScale = outputScale;
  12656. if (this.useOnlyCssZoom) {
  12657. var actualSizeViewport = viewport.clone({
  12658. scale: _ui_utils.CSS_UNITS
  12659. });
  12660. outputScale.sx *= actualSizeViewport.width / viewport.width;
  12661. outputScale.sy *= actualSizeViewport.height / viewport.height;
  12662. outputScale.scaled = true;
  12663. }
  12664. if (this.maxCanvasPixels > 0) {
  12665. var pixelsInViewport = viewport.width * viewport.height;
  12666. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  12667. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  12668. outputScale.sx = maxScale;
  12669. outputScale.sy = maxScale;
  12670. outputScale.scaled = true;
  12671. this.hasRestrictedScaling = true;
  12672. } else {
  12673. this.hasRestrictedScaling = false;
  12674. }
  12675. }
  12676. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  12677. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  12678. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  12679. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  12680. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
  12681. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
  12682. this.paintedViewportMap.set(canvas, viewport);
  12683. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  12684. var renderContext = {
  12685. canvasContext: ctx,
  12686. transform: transform,
  12687. viewport: this.viewport,
  12688. enableWebGL: this.enableWebGL,
  12689. renderInteractiveForms: this.renderInteractiveForms,
  12690. optionalContentConfigPromise: this._optionalContentConfigPromise
  12691. };
  12692. var renderTask = this.pdfPage.render(renderContext);
  12693. renderTask.onContinue = function (cont) {
  12694. showCanvas();
  12695. if (result.onRenderContinue) {
  12696. result.onRenderContinue(cont);
  12697. } else {
  12698. cont();
  12699. }
  12700. };
  12701. renderTask.promise.then(function () {
  12702. showCanvas();
  12703. renderCapability.resolve(undefined);
  12704. }, function (error) {
  12705. showCanvas();
  12706. renderCapability.reject(error);
  12707. });
  12708. return result;
  12709. }
  12710. }, {
  12711. key: "paintOnSvg",
  12712. value: function paintOnSvg(wrapper) {
  12713. var _this3 = this;
  12714. var cancelled = false;
  12715. var ensureNotCancelled = function ensureNotCancelled() {
  12716. if (cancelled) {
  12717. throw new _pdfjsLib.RenderingCancelledException("Rendering cancelled, page ".concat(_this3.id), "svg");
  12718. }
  12719. };
  12720. var pdfPage = this.pdfPage;
  12721. var actualSizeViewport = this.viewport.clone({
  12722. scale: _ui_utils.CSS_UNITS
  12723. });
  12724. var promise = pdfPage.getOperatorList().then(function (opList) {
  12725. ensureNotCancelled();
  12726. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
  12727. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  12728. ensureNotCancelled();
  12729. _this3.svg = svg;
  12730. _this3.paintedViewportMap.set(svg, actualSizeViewport);
  12731. svg.style.width = wrapper.style.width;
  12732. svg.style.height = wrapper.style.height;
  12733. _this3.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  12734. wrapper.appendChild(svg);
  12735. });
  12736. });
  12737. return {
  12738. promise: promise,
  12739. onRenderContinue: function onRenderContinue(cont) {
  12740. cont();
  12741. },
  12742. cancel: function cancel() {
  12743. cancelled = true;
  12744. }
  12745. };
  12746. }
  12747. }, {
  12748. key: "setPageLabel",
  12749. value: function setPageLabel(label) {
  12750. this.pageLabel = typeof label === "string" ? label : null;
  12751. if (this.pageLabel !== null) {
  12752. this.div.setAttribute("data-page-label", this.pageLabel);
  12753. } else {
  12754. this.div.removeAttribute("data-page-label");
  12755. }
  12756. }
  12757. }]);
  12758. return PDFPageView;
  12759. }();
  12760. exports.PDFPageView = PDFPageView;
  12761. /***/ }),
  12762. /* 34 */
  12763. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12764. Object.defineProperty(exports, "__esModule", ({
  12765. value: true
  12766. }));
  12767. exports.TextLayerBuilder = exports.DefaultTextLayerFactory = void 0;
  12768. var _pdfjsLib = __webpack_require__(7);
  12769. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12770. 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); } }
  12771. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12772. var EXPAND_DIVS_TIMEOUT = 300;
  12773. var TextLayerBuilder = /*#__PURE__*/function () {
  12774. function TextLayerBuilder(_ref) {
  12775. var textLayerDiv = _ref.textLayerDiv,
  12776. eventBus = _ref.eventBus,
  12777. pageIndex = _ref.pageIndex,
  12778. viewport = _ref.viewport,
  12779. _ref$findController = _ref.findController,
  12780. findController = _ref$findController === void 0 ? null : _ref$findController,
  12781. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  12782. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  12783. _classCallCheck(this, TextLayerBuilder);
  12784. this.textLayerDiv = textLayerDiv;
  12785. this.eventBus = eventBus;
  12786. this.textContent = null;
  12787. this.textContentItemsStr = [];
  12788. this.textContentStream = null;
  12789. this.renderingDone = false;
  12790. this.pageIdx = pageIndex;
  12791. this.pageNumber = this.pageIdx + 1;
  12792. this.matches = [];
  12793. this.viewport = viewport;
  12794. this.textDivs = [];
  12795. this.findController = findController;
  12796. this.textLayerRenderTask = null;
  12797. this.enhanceTextSelection = enhanceTextSelection;
  12798. this._onUpdateTextLayerMatches = null;
  12799. this._bindMouse();
  12800. }
  12801. _createClass(TextLayerBuilder, [{
  12802. key: "_finishRendering",
  12803. value: function _finishRendering() {
  12804. this.renderingDone = true;
  12805. if (!this.enhanceTextSelection) {
  12806. var endOfContent = document.createElement("div");
  12807. endOfContent.className = "endOfContent";
  12808. this.textLayerDiv.appendChild(endOfContent);
  12809. }
  12810. this.eventBus.dispatch("textlayerrendered", {
  12811. source: this,
  12812. pageNumber: this.pageNumber,
  12813. numTextDivs: this.textDivs.length
  12814. });
  12815. }
  12816. }, {
  12817. key: "render",
  12818. value: function render() {
  12819. var _this = this;
  12820. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  12821. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  12822. return;
  12823. }
  12824. this.cancel();
  12825. this.textDivs = [];
  12826. var textLayerFrag = document.createDocumentFragment();
  12827. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  12828. textContent: this.textContent,
  12829. textContentStream: this.textContentStream,
  12830. container: textLayerFrag,
  12831. viewport: this.viewport,
  12832. textDivs: this.textDivs,
  12833. textContentItemsStr: this.textContentItemsStr,
  12834. timeout: timeout,
  12835. enhanceTextSelection: this.enhanceTextSelection
  12836. });
  12837. this.textLayerRenderTask.promise.then(function () {
  12838. _this.textLayerDiv.appendChild(textLayerFrag);
  12839. _this._finishRendering();
  12840. _this._updateMatches();
  12841. }, function (reason) {});
  12842. if (!this._onUpdateTextLayerMatches) {
  12843. this._onUpdateTextLayerMatches = function (evt) {
  12844. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  12845. _this._updateMatches();
  12846. }
  12847. };
  12848. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  12849. }
  12850. }
  12851. }, {
  12852. key: "cancel",
  12853. value: function cancel() {
  12854. if (this.textLayerRenderTask) {
  12855. this.textLayerRenderTask.cancel();
  12856. this.textLayerRenderTask = null;
  12857. }
  12858. if (this._onUpdateTextLayerMatches) {
  12859. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  12860. this._onUpdateTextLayerMatches = null;
  12861. }
  12862. }
  12863. }, {
  12864. key: "setTextContentStream",
  12865. value: function setTextContentStream(readableStream) {
  12866. this.cancel();
  12867. this.textContentStream = readableStream;
  12868. }
  12869. }, {
  12870. key: "setTextContent",
  12871. value: function setTextContent(textContent) {
  12872. this.cancel();
  12873. this.textContent = textContent;
  12874. }
  12875. }, {
  12876. key: "_convertMatches",
  12877. value: function _convertMatches(matches, matchesLength) {
  12878. if (!matches) {
  12879. return [];
  12880. }
  12881. var textContentItemsStr = this.textContentItemsStr;
  12882. var i = 0,
  12883. iIndex = 0;
  12884. var end = textContentItemsStr.length - 1;
  12885. var result = [];
  12886. for (var m = 0, mm = matches.length; m < mm; m++) {
  12887. var matchIdx = matches[m];
  12888. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  12889. iIndex += textContentItemsStr[i].length;
  12890. i++;
  12891. }
  12892. if (i === textContentItemsStr.length) {
  12893. console.error("Could not find a matching mapping");
  12894. }
  12895. var match = {
  12896. begin: {
  12897. divIdx: i,
  12898. offset: matchIdx - iIndex
  12899. }
  12900. };
  12901. matchIdx += matchesLength[m];
  12902. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  12903. iIndex += textContentItemsStr[i].length;
  12904. i++;
  12905. }
  12906. match.end = {
  12907. divIdx: i,
  12908. offset: matchIdx - iIndex
  12909. };
  12910. result.push(match);
  12911. }
  12912. return result;
  12913. }
  12914. }, {
  12915. key: "_renderMatches",
  12916. value: function _renderMatches(matches) {
  12917. if (matches.length === 0) {
  12918. return;
  12919. }
  12920. var findController = this.findController,
  12921. pageIdx = this.pageIdx,
  12922. textContentItemsStr = this.textContentItemsStr,
  12923. textDivs = this.textDivs;
  12924. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  12925. var selectedMatchIdx = findController.selected.matchIdx;
  12926. var highlightAll = findController.state.highlightAll;
  12927. var prevEnd = null;
  12928. var infinity = {
  12929. divIdx: -1,
  12930. offset: undefined
  12931. };
  12932. function beginText(begin, className) {
  12933. var divIdx = begin.divIdx;
  12934. textDivs[divIdx].textContent = "";
  12935. appendTextToDiv(divIdx, 0, begin.offset, className);
  12936. }
  12937. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  12938. var div = textDivs[divIdx];
  12939. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  12940. var node = document.createTextNode(content);
  12941. if (className) {
  12942. var span = document.createElement("span");
  12943. span.className = className;
  12944. span.appendChild(node);
  12945. div.appendChild(span);
  12946. return;
  12947. }
  12948. div.appendChild(node);
  12949. }
  12950. var i0 = selectedMatchIdx,
  12951. i1 = i0 + 1;
  12952. if (highlightAll) {
  12953. i0 = 0;
  12954. i1 = matches.length;
  12955. } else if (!isSelectedPage) {
  12956. return;
  12957. }
  12958. for (var i = i0; i < i1; i++) {
  12959. var match = matches[i];
  12960. var begin = match.begin;
  12961. var end = match.end;
  12962. var isSelected = isSelectedPage && i === selectedMatchIdx;
  12963. var highlightSuffix = isSelected ? " selected" : "";
  12964. if (isSelected) {
  12965. findController.scrollMatchIntoView({
  12966. element: textDivs[begin.divIdx],
  12967. pageIndex: pageIdx,
  12968. matchIndex: selectedMatchIdx
  12969. });
  12970. }
  12971. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  12972. if (prevEnd !== null) {
  12973. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  12974. }
  12975. beginText(begin);
  12976. } else {
  12977. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  12978. }
  12979. if (begin.divIdx === end.divIdx) {
  12980. appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  12981. } else {
  12982. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  12983. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  12984. textDivs[n0].className = "highlight middle" + highlightSuffix;
  12985. }
  12986. beginText(end, "highlight end" + highlightSuffix);
  12987. }
  12988. prevEnd = end;
  12989. }
  12990. if (prevEnd) {
  12991. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  12992. }
  12993. }
  12994. }, {
  12995. key: "_updateMatches",
  12996. value: function _updateMatches() {
  12997. if (!this.renderingDone) {
  12998. return;
  12999. }
  13000. var findController = this.findController,
  13001. matches = this.matches,
  13002. pageIdx = this.pageIdx,
  13003. textContentItemsStr = this.textContentItemsStr,
  13004. textDivs = this.textDivs;
  13005. var clearedUntilDivIdx = -1;
  13006. for (var i = 0, ii = matches.length; i < ii; i++) {
  13007. var match = matches[i];
  13008. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  13009. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  13010. var div = textDivs[n];
  13011. div.textContent = textContentItemsStr[n];
  13012. div.className = "";
  13013. }
  13014. clearedUntilDivIdx = match.end.divIdx + 1;
  13015. }
  13016. if (!(findController !== null && findController !== void 0 && findController.highlightMatches)) {
  13017. return;
  13018. }
  13019. var pageMatches = findController.pageMatches[pageIdx] || null;
  13020. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  13021. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  13022. this._renderMatches(this.matches);
  13023. }
  13024. }, {
  13025. key: "_bindMouse",
  13026. value: function _bindMouse() {
  13027. var _this2 = this;
  13028. var div = this.textLayerDiv;
  13029. var expandDivsTimer = null;
  13030. div.addEventListener("mousedown", function (evt) {
  13031. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  13032. _this2.textLayerRenderTask.expandTextDivs(true);
  13033. if (expandDivsTimer) {
  13034. clearTimeout(expandDivsTimer);
  13035. expandDivsTimer = null;
  13036. }
  13037. return;
  13038. }
  13039. var end = div.querySelector(".endOfContent");
  13040. if (!end) {
  13041. return;
  13042. }
  13043. var adjustTop = evt.target !== div;
  13044. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  13045. if (adjustTop) {
  13046. var divBounds = div.getBoundingClientRect();
  13047. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  13048. end.style.top = (r * 100).toFixed(2) + "%";
  13049. }
  13050. end.classList.add("active");
  13051. });
  13052. div.addEventListener("mouseup", function () {
  13053. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  13054. expandDivsTimer = setTimeout(function () {
  13055. if (_this2.textLayerRenderTask) {
  13056. _this2.textLayerRenderTask.expandTextDivs(false);
  13057. }
  13058. expandDivsTimer = null;
  13059. }, EXPAND_DIVS_TIMEOUT);
  13060. return;
  13061. }
  13062. var end = div.querySelector(".endOfContent");
  13063. if (!end) {
  13064. return;
  13065. }
  13066. end.style.top = "";
  13067. end.classList.remove("active");
  13068. });
  13069. }
  13070. }]);
  13071. return TextLayerBuilder;
  13072. }();
  13073. exports.TextLayerBuilder = TextLayerBuilder;
  13074. var DefaultTextLayerFactory = /*#__PURE__*/function () {
  13075. function DefaultTextLayerFactory() {
  13076. _classCallCheck(this, DefaultTextLayerFactory);
  13077. }
  13078. _createClass(DefaultTextLayerFactory, [{
  13079. key: "createTextLayerBuilder",
  13080. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  13081. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  13082. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  13083. return new TextLayerBuilder({
  13084. textLayerDiv: textLayerDiv,
  13085. pageIndex: pageIndex,
  13086. viewport: viewport,
  13087. enhanceTextSelection: enhanceTextSelection,
  13088. eventBus: eventBus
  13089. });
  13090. }
  13091. }]);
  13092. return DefaultTextLayerFactory;
  13093. }();
  13094. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  13095. /***/ }),
  13096. /* 35 */
  13097. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13098. Object.defineProperty(exports, "__esModule", ({
  13099. value: true
  13100. }));
  13101. exports.XfaLayerBuilder = exports.DefaultXfaLayerFactory = void 0;
  13102. var _pdfjsLib = __webpack_require__(7);
  13103. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13104. 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); } }
  13105. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13106. var XfaLayerBuilder = /*#__PURE__*/function () {
  13107. function XfaLayerBuilder(_ref) {
  13108. var pageDiv = _ref.pageDiv,
  13109. pdfPage = _ref.pdfPage;
  13110. _classCallCheck(this, XfaLayerBuilder);
  13111. this.pageDiv = pageDiv;
  13112. this.pdfPage = pdfPage;
  13113. this.div = null;
  13114. this._cancelled = false;
  13115. }
  13116. _createClass(XfaLayerBuilder, [{
  13117. key: "render",
  13118. value: function render(viewport) {
  13119. var _this = this;
  13120. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  13121. return this.pdfPage.getXfa().then(function (xfa) {
  13122. if (_this._cancelled) {
  13123. return;
  13124. }
  13125. var parameters = {
  13126. viewport: viewport.clone({
  13127. dontFlip: true
  13128. }),
  13129. div: _this.div,
  13130. xfa: xfa,
  13131. page: _this.pdfPage
  13132. };
  13133. if (_this.div) {
  13134. _pdfjsLib.XfaLayer.update(parameters);
  13135. } else {
  13136. _this.div = document.createElement("div");
  13137. _this.pageDiv.appendChild(_this.div);
  13138. parameters.div = _this.div;
  13139. _pdfjsLib.XfaLayer.render(parameters);
  13140. }
  13141. });
  13142. }
  13143. }, {
  13144. key: "cancel",
  13145. value: function cancel() {
  13146. this._cancelled = true;
  13147. }
  13148. }, {
  13149. key: "hide",
  13150. value: function hide() {
  13151. if (!this.div) {
  13152. return;
  13153. }
  13154. this.div.hidden = true;
  13155. }
  13156. }]);
  13157. return XfaLayerBuilder;
  13158. }();
  13159. exports.XfaLayerBuilder = XfaLayerBuilder;
  13160. var DefaultXfaLayerFactory = /*#__PURE__*/function () {
  13161. function DefaultXfaLayerFactory() {
  13162. _classCallCheck(this, DefaultXfaLayerFactory);
  13163. }
  13164. _createClass(DefaultXfaLayerFactory, [{
  13165. key: "createXfaLayerBuilder",
  13166. value: function createXfaLayerBuilder(pageDiv, pdfPage) {
  13167. return new XfaLayerBuilder({
  13168. pageDiv: pageDiv,
  13169. pdfPage: pdfPage
  13170. });
  13171. }
  13172. }]);
  13173. return DefaultXfaLayerFactory;
  13174. }();
  13175. exports.DefaultXfaLayerFactory = DefaultXfaLayerFactory;
  13176. /***/ }),
  13177. /* 36 */
  13178. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13179. Object.defineProperty(exports, "__esModule", ({
  13180. value: true
  13181. }));
  13182. exports.SecondaryToolbar = void 0;
  13183. var _ui_utils = __webpack_require__(6);
  13184. var _pdf_cursor_tools = __webpack_require__(8);
  13185. var _pdf_single_page_viewer = __webpack_require__(37);
  13186. 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; } } }; }
  13187. 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); }
  13188. 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; }
  13189. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13190. 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); } }
  13191. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13192. var SecondaryToolbar = /*#__PURE__*/function () {
  13193. function SecondaryToolbar(options, mainContainer, eventBus) {
  13194. var _this = this;
  13195. _classCallCheck(this, SecondaryToolbar);
  13196. this.toolbar = options.toolbar;
  13197. this.toggleButton = options.toggleButton;
  13198. this.toolbarButtonContainer = options.toolbarButtonContainer;
  13199. this.buttons = [{
  13200. element: options.presentationModeButton,
  13201. eventName: "presentationmode",
  13202. close: true
  13203. }, {
  13204. element: options.openFileButton,
  13205. eventName: "openfile",
  13206. close: true
  13207. }, {
  13208. element: options.printButton,
  13209. eventName: "print",
  13210. close: true
  13211. }, {
  13212. element: options.downloadButton,
  13213. eventName: "download",
  13214. close: true
  13215. }, {
  13216. element: options.viewBookmarkButton,
  13217. eventName: null,
  13218. close: true
  13219. }, {
  13220. element: options.firstPageButton,
  13221. eventName: "firstpage",
  13222. close: true
  13223. }, {
  13224. element: options.lastPageButton,
  13225. eventName: "lastpage",
  13226. close: true
  13227. }, {
  13228. element: options.pageRotateCwButton,
  13229. eventName: "rotatecw",
  13230. close: false
  13231. }, {
  13232. element: options.pageRotateCcwButton,
  13233. eventName: "rotateccw",
  13234. close: false
  13235. }, {
  13236. element: options.cursorSelectToolButton,
  13237. eventName: "switchcursortool",
  13238. eventDetails: {
  13239. tool: _pdf_cursor_tools.CursorTool.SELECT
  13240. },
  13241. close: true
  13242. }, {
  13243. element: options.cursorHandToolButton,
  13244. eventName: "switchcursortool",
  13245. eventDetails: {
  13246. tool: _pdf_cursor_tools.CursorTool.HAND
  13247. },
  13248. close: true
  13249. }, {
  13250. element: options.scrollVerticalButton,
  13251. eventName: "switchscrollmode",
  13252. eventDetails: {
  13253. mode: _ui_utils.ScrollMode.VERTICAL
  13254. },
  13255. close: true
  13256. }, {
  13257. element: options.scrollHorizontalButton,
  13258. eventName: "switchscrollmode",
  13259. eventDetails: {
  13260. mode: _ui_utils.ScrollMode.HORIZONTAL
  13261. },
  13262. close: true
  13263. }, {
  13264. element: options.scrollWrappedButton,
  13265. eventName: "switchscrollmode",
  13266. eventDetails: {
  13267. mode: _ui_utils.ScrollMode.WRAPPED
  13268. },
  13269. close: true
  13270. }, {
  13271. element: options.spreadNoneButton,
  13272. eventName: "switchspreadmode",
  13273. eventDetails: {
  13274. mode: _ui_utils.SpreadMode.NONE
  13275. },
  13276. close: true
  13277. }, {
  13278. element: options.spreadOddButton,
  13279. eventName: "switchspreadmode",
  13280. eventDetails: {
  13281. mode: _ui_utils.SpreadMode.ODD
  13282. },
  13283. close: true
  13284. }, {
  13285. element: options.spreadEvenButton,
  13286. eventName: "switchspreadmode",
  13287. eventDetails: {
  13288. mode: _ui_utils.SpreadMode.EVEN
  13289. },
  13290. close: true
  13291. }, {
  13292. element: options.documentPropertiesButton,
  13293. eventName: "documentproperties",
  13294. close: true
  13295. }];
  13296. this.items = {
  13297. firstPage: options.firstPageButton,
  13298. lastPage: options.lastPageButton,
  13299. pageRotateCw: options.pageRotateCwButton,
  13300. pageRotateCcw: options.pageRotateCcwButton
  13301. };
  13302. this.mainContainer = mainContainer;
  13303. this.eventBus = eventBus;
  13304. this.opened = false;
  13305. this.containerHeight = null;
  13306. this.previousContainerHeight = null;
  13307. this.reset();
  13308. this._bindClickListeners();
  13309. this._bindCursorToolsListener(options);
  13310. this._bindScrollModeListener(options);
  13311. this._bindSpreadModeListener(options);
  13312. this.eventBus._on("resize", this._setMaxHeight.bind(this));
  13313. this.eventBus._on("baseviewerinit", function (evt) {
  13314. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  13315. _this.toolbarButtonContainer.classList.add("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  13316. } else {
  13317. _this.toolbarButtonContainer.classList.remove("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  13318. }
  13319. });
  13320. }
  13321. _createClass(SecondaryToolbar, [{
  13322. key: "isOpen",
  13323. get: function get() {
  13324. return this.opened;
  13325. }
  13326. }, {
  13327. key: "setPageNumber",
  13328. value: function setPageNumber(pageNumber) {
  13329. this.pageNumber = pageNumber;
  13330. this._updateUIState();
  13331. }
  13332. }, {
  13333. key: "setPagesCount",
  13334. value: function setPagesCount(pagesCount) {
  13335. this.pagesCount = pagesCount;
  13336. this._updateUIState();
  13337. }
  13338. }, {
  13339. key: "reset",
  13340. value: function reset() {
  13341. this.pageNumber = 0;
  13342. this.pagesCount = 0;
  13343. this._updateUIState();
  13344. this.eventBus.dispatch("secondarytoolbarreset", {
  13345. source: this
  13346. });
  13347. }
  13348. }, {
  13349. key: "_updateUIState",
  13350. value: function _updateUIState() {
  13351. this.items.firstPage.disabled = this.pageNumber <= 1;
  13352. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  13353. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  13354. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  13355. }
  13356. }, {
  13357. key: "_bindClickListeners",
  13358. value: function _bindClickListeners() {
  13359. var _this2 = this;
  13360. this.toggleButton.addEventListener("click", this.toggle.bind(this));
  13361. var _iterator = _createForOfIteratorHelper(this.buttons),
  13362. _step;
  13363. try {
  13364. var _loop = function _loop() {
  13365. var _step$value = _step.value,
  13366. element = _step$value.element,
  13367. eventName = _step$value.eventName,
  13368. close = _step$value.close,
  13369. eventDetails = _step$value.eventDetails;
  13370. element.addEventListener("click", function (evt) {
  13371. if (eventName !== null) {
  13372. var details = {
  13373. source: _this2
  13374. };
  13375. for (var property in eventDetails) {
  13376. details[property] = eventDetails[property];
  13377. }
  13378. _this2.eventBus.dispatch(eventName, details);
  13379. }
  13380. if (close) {
  13381. _this2.close();
  13382. }
  13383. });
  13384. };
  13385. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  13386. _loop();
  13387. }
  13388. } catch (err) {
  13389. _iterator.e(err);
  13390. } finally {
  13391. _iterator.f();
  13392. }
  13393. }
  13394. }, {
  13395. key: "_bindCursorToolsListener",
  13396. value: function _bindCursorToolsListener(buttons) {
  13397. this.eventBus._on("cursortoolchanged", function (_ref) {
  13398. var tool = _ref.tool;
  13399. buttons.cursorSelectToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.SELECT);
  13400. buttons.cursorHandToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.HAND);
  13401. });
  13402. }
  13403. }, {
  13404. key: "_bindScrollModeListener",
  13405. value: function _bindScrollModeListener(buttons) {
  13406. var _this3 = this;
  13407. function scrollModeChanged(_ref2) {
  13408. var mode = _ref2.mode;
  13409. buttons.scrollVerticalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.VERTICAL);
  13410. buttons.scrollHorizontalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.HORIZONTAL);
  13411. buttons.scrollWrappedButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.WRAPPED);
  13412. var isScrollModeHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
  13413. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  13414. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  13415. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  13416. }
  13417. this.eventBus._on("scrollmodechanged", scrollModeChanged);
  13418. this.eventBus._on("secondarytoolbarreset", function (evt) {
  13419. if (evt.source === _this3) {
  13420. scrollModeChanged({
  13421. mode: _ui_utils.ScrollMode.VERTICAL
  13422. });
  13423. }
  13424. });
  13425. }
  13426. }, {
  13427. key: "_bindSpreadModeListener",
  13428. value: function _bindSpreadModeListener(buttons) {
  13429. var _this4 = this;
  13430. function spreadModeChanged(_ref3) {
  13431. var mode = _ref3.mode;
  13432. buttons.spreadNoneButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.NONE);
  13433. buttons.spreadOddButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.ODD);
  13434. buttons.spreadEvenButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.EVEN);
  13435. }
  13436. this.eventBus._on("spreadmodechanged", spreadModeChanged);
  13437. this.eventBus._on("secondarytoolbarreset", function (evt) {
  13438. if (evt.source === _this4) {
  13439. spreadModeChanged({
  13440. mode: _ui_utils.SpreadMode.NONE
  13441. });
  13442. }
  13443. });
  13444. }
  13445. }, {
  13446. key: "open",
  13447. value: function open() {
  13448. if (this.opened) {
  13449. return;
  13450. }
  13451. this.opened = true;
  13452. this._setMaxHeight();
  13453. this.toggleButton.classList.add("toggled");
  13454. this.toggleButton.setAttribute("aria-expanded", "true");
  13455. this.toolbar.classList.remove("hidden");
  13456. }
  13457. }, {
  13458. key: "close",
  13459. value: function close() {
  13460. if (!this.opened) {
  13461. return;
  13462. }
  13463. this.opened = false;
  13464. this.toolbar.classList.add("hidden");
  13465. this.toggleButton.classList.remove("toggled");
  13466. this.toggleButton.setAttribute("aria-expanded", "false");
  13467. }
  13468. }, {
  13469. key: "toggle",
  13470. value: function toggle() {
  13471. if (this.opened) {
  13472. this.close();
  13473. } else {
  13474. this.open();
  13475. }
  13476. }
  13477. }, {
  13478. key: "_setMaxHeight",
  13479. value: function _setMaxHeight() {
  13480. if (!this.opened) {
  13481. return;
  13482. }
  13483. this.containerHeight = this.mainContainer.clientHeight;
  13484. if (this.containerHeight === this.previousContainerHeight) {
  13485. return;
  13486. }
  13487. this.toolbarButtonContainer.style.maxHeight = "".concat(this.containerHeight - _ui_utils.SCROLLBAR_PADDING, "px");
  13488. this.previousContainerHeight = this.containerHeight;
  13489. }
  13490. }]);
  13491. return SecondaryToolbar;
  13492. }();
  13493. exports.SecondaryToolbar = SecondaryToolbar;
  13494. /***/ }),
  13495. /* 37 */
  13496. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13497. 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); }
  13498. Object.defineProperty(exports, "__esModule", ({
  13499. value: true
  13500. }));
  13501. exports.PDFSinglePageViewer = void 0;
  13502. var _base_viewer = __webpack_require__(30);
  13503. var _pdfjsLib = __webpack_require__(7);
  13504. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13505. 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); } }
  13506. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13507. 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); }
  13508. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  13509. 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); }
  13510. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13511. 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); }; }
  13512. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13513. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13514. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  13515. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13516. var PDFSinglePageViewer = /*#__PURE__*/function (_BaseViewer) {
  13517. _inherits(PDFSinglePageViewer, _BaseViewer);
  13518. var _super = _createSuper(PDFSinglePageViewer);
  13519. function PDFSinglePageViewer(options) {
  13520. var _this;
  13521. _classCallCheck(this, PDFSinglePageViewer);
  13522. _this = _super.call(this, options);
  13523. _this.eventBus._on("pagesinit", function (evt) {
  13524. _this._ensurePageViewVisible();
  13525. });
  13526. return _this;
  13527. }
  13528. _createClass(PDFSinglePageViewer, [{
  13529. key: "_viewerElement",
  13530. get: function get() {
  13531. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this._shadowViewer);
  13532. }
  13533. }, {
  13534. key: "_pageWidthScaleFactor",
  13535. get: function get() {
  13536. return 1;
  13537. }
  13538. }, {
  13539. key: "_resetView",
  13540. value: function _resetView() {
  13541. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  13542. this._previousPageNumber = 1;
  13543. this._shadowViewer = document.createDocumentFragment();
  13544. this._updateScrollDown = null;
  13545. }
  13546. }, {
  13547. key: "_ensurePageViewVisible",
  13548. value: function _ensurePageViewVisible() {
  13549. var pageView = this._pages[this._currentPageNumber - 1];
  13550. var previousPageView = this._pages[this._previousPageNumber - 1];
  13551. var viewerNodes = this.viewer.childNodes;
  13552. switch (viewerNodes.length) {
  13553. case 0:
  13554. this.viewer.appendChild(pageView.div);
  13555. break;
  13556. case 1:
  13557. if (viewerNodes[0] !== previousPageView.div) {
  13558. throw new Error("_ensurePageViewVisible: Unexpected previously visible page.");
  13559. }
  13560. if (pageView === previousPageView) {
  13561. break;
  13562. }
  13563. this._shadowViewer.appendChild(previousPageView.div);
  13564. this.viewer.appendChild(pageView.div);
  13565. this.container.scrollTop = 0;
  13566. break;
  13567. default:
  13568. throw new Error("_ensurePageViewVisible: Only one page should be visible at a time.");
  13569. }
  13570. this._previousPageNumber = this._currentPageNumber;
  13571. }
  13572. }, {
  13573. key: "_scrollUpdate",
  13574. value: function _scrollUpdate() {
  13575. if (this._updateScrollDown) {
  13576. this._updateScrollDown();
  13577. }
  13578. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  13579. }
  13580. }, {
  13581. key: "_scrollIntoView",
  13582. value: function _scrollIntoView(_ref) {
  13583. var _this2 = this;
  13584. var pageDiv = _ref.pageDiv,
  13585. _ref$pageSpot = _ref.pageSpot,
  13586. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  13587. _ref$pageNumber = _ref.pageNumber,
  13588. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  13589. if (pageNumber) {
  13590. this._setCurrentPageNumber(pageNumber);
  13591. }
  13592. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  13593. this._ensurePageViewVisible();
  13594. this.update();
  13595. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  13596. pageDiv: pageDiv,
  13597. pageSpot: pageSpot,
  13598. pageNumber: pageNumber
  13599. });
  13600. this._updateScrollDown = function () {
  13601. _this2.scroll.down = scrolledDown;
  13602. _this2._updateScrollDown = null;
  13603. };
  13604. }
  13605. }, {
  13606. key: "_getVisiblePages",
  13607. value: function _getVisiblePages() {
  13608. return this._getCurrentVisiblePage();
  13609. }
  13610. }, {
  13611. key: "_updateHelper",
  13612. value: function _updateHelper(visiblePages) {}
  13613. }, {
  13614. key: "_isScrollModeHorizontal",
  13615. get: function get() {
  13616. return (0, _pdfjsLib.shadow)(this, "_isScrollModeHorizontal", false);
  13617. }
  13618. }, {
  13619. key: "_updateScrollMode",
  13620. value: function _updateScrollMode() {}
  13621. }, {
  13622. key: "_updateSpreadMode",
  13623. value: function _updateSpreadMode() {}
  13624. }, {
  13625. key: "_getPageAdvance",
  13626. value: function _getPageAdvance() {
  13627. return 1;
  13628. }
  13629. }]);
  13630. return PDFSinglePageViewer;
  13631. }(_base_viewer.BaseViewer);
  13632. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  13633. /***/ }),
  13634. /* 38 */
  13635. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13636. Object.defineProperty(exports, "__esModule", ({
  13637. value: true
  13638. }));
  13639. exports.Toolbar = void 0;
  13640. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  13641. var _ui_utils = __webpack_require__(6);
  13642. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13643. 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); } }
  13644. 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); }); }; }
  13645. 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; } } }; }
  13646. 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); }
  13647. 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; }
  13648. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13649. 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); } }
  13650. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13651. var PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
  13652. var SCALE_SELECT_CONTAINER_WIDTH = 140;
  13653. var SCALE_SELECT_WIDTH = 162;
  13654. var Toolbar = /*#__PURE__*/function () {
  13655. function Toolbar(options, eventBus, l10n) {
  13656. _classCallCheck(this, Toolbar);
  13657. this.toolbar = options.container;
  13658. this.eventBus = eventBus;
  13659. this.l10n = l10n;
  13660. this.buttons = [{
  13661. element: options.previous,
  13662. eventName: "previouspage"
  13663. }, {
  13664. element: options.next,
  13665. eventName: "nextpage"
  13666. }, {
  13667. element: options.zoomIn,
  13668. eventName: "zoomin"
  13669. }, {
  13670. element: options.zoomOut,
  13671. eventName: "zoomout"
  13672. }, {
  13673. element: options.openFile,
  13674. eventName: "openfile"
  13675. }, {
  13676. element: options.print,
  13677. eventName: "print"
  13678. }, {
  13679. element: options.presentationModeButton,
  13680. eventName: "presentationmode"
  13681. }, {
  13682. element: options.download,
  13683. eventName: "download"
  13684. }, {
  13685. element: options.viewBookmark,
  13686. eventName: null
  13687. }];
  13688. this.items = {
  13689. numPages: options.numPages,
  13690. pageNumber: options.pageNumber,
  13691. scaleSelectContainer: options.scaleSelectContainer,
  13692. scaleSelect: options.scaleSelect,
  13693. customScaleOption: options.customScaleOption,
  13694. previous: options.previous,
  13695. next: options.next,
  13696. zoomIn: options.zoomIn,
  13697. zoomOut: options.zoomOut
  13698. };
  13699. this._wasLocalized = false;
  13700. this.reset();
  13701. this._bindListeners();
  13702. }
  13703. _createClass(Toolbar, [{
  13704. key: "setPageNumber",
  13705. value: function setPageNumber(pageNumber, pageLabel) {
  13706. this.pageNumber = pageNumber;
  13707. this.pageLabel = pageLabel;
  13708. this._updateUIState(false);
  13709. }
  13710. }, {
  13711. key: "setPagesCount",
  13712. value: function setPagesCount(pagesCount, hasPageLabels) {
  13713. this.pagesCount = pagesCount;
  13714. this.hasPageLabels = hasPageLabels;
  13715. this._updateUIState(true);
  13716. }
  13717. }, {
  13718. key: "setPageScale",
  13719. value: function setPageScale(pageScaleValue, pageScale) {
  13720. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  13721. this.pageScale = pageScale;
  13722. this._updateUIState(false);
  13723. }
  13724. }, {
  13725. key: "reset",
  13726. value: function reset() {
  13727. this.pageNumber = 0;
  13728. this.pageLabel = null;
  13729. this.hasPageLabels = false;
  13730. this.pagesCount = 0;
  13731. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  13732. this.pageScale = _ui_utils.DEFAULT_SCALE;
  13733. this._updateUIState(true);
  13734. this.updateLoadingIndicatorState();
  13735. }
  13736. }, {
  13737. key: "_bindListeners",
  13738. value: function _bindListeners() {
  13739. var _this = this;
  13740. var _this$items = this.items,
  13741. pageNumber = _this$items.pageNumber,
  13742. scaleSelect = _this$items.scaleSelect;
  13743. var self = this;
  13744. var _iterator = _createForOfIteratorHelper(this.buttons),
  13745. _step;
  13746. try {
  13747. var _loop = function _loop() {
  13748. var _step$value = _step.value,
  13749. element = _step$value.element,
  13750. eventName = _step$value.eventName;
  13751. element.addEventListener("click", function (evt) {
  13752. if (eventName !== null) {
  13753. _this.eventBus.dispatch(eventName, {
  13754. source: _this
  13755. });
  13756. }
  13757. });
  13758. };
  13759. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  13760. _loop();
  13761. }
  13762. } catch (err) {
  13763. _iterator.e(err);
  13764. } finally {
  13765. _iterator.f();
  13766. }
  13767. pageNumber.addEventListener("click", function () {
  13768. this.select();
  13769. });
  13770. pageNumber.addEventListener("change", function () {
  13771. self.eventBus.dispatch("pagenumberchanged", {
  13772. source: self,
  13773. value: this.value
  13774. });
  13775. });
  13776. scaleSelect.addEventListener("change", function () {
  13777. if (this.value === "custom") {
  13778. return;
  13779. }
  13780. self.eventBus.dispatch("scalechanged", {
  13781. source: self,
  13782. value: this.value
  13783. });
  13784. });
  13785. scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  13786. this.eventBus._on("localized", function () {
  13787. _this._wasLocalized = true;
  13788. _this._adjustScaleWidth();
  13789. _this._updateUIState(true);
  13790. });
  13791. }
  13792. }, {
  13793. key: "_updateUIState",
  13794. value: function _updateUIState() {
  13795. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  13796. if (!this._wasLocalized) {
  13797. return;
  13798. }
  13799. var pageNumber = this.pageNumber,
  13800. pagesCount = this.pagesCount,
  13801. pageScaleValue = this.pageScaleValue,
  13802. pageScale = this.pageScale,
  13803. items = this.items;
  13804. if (resetNumPages) {
  13805. if (this.hasPageLabels) {
  13806. items.pageNumber.type = "text";
  13807. } else {
  13808. items.pageNumber.type = "number";
  13809. this.l10n.get("of_pages", {
  13810. pagesCount: pagesCount
  13811. }).then(function (msg) {
  13812. items.numPages.textContent = msg;
  13813. });
  13814. }
  13815. items.pageNumber.max = pagesCount;
  13816. }
  13817. if (this.hasPageLabels) {
  13818. items.pageNumber.value = this.pageLabel;
  13819. this.l10n.get("page_of_pages", {
  13820. pageNumber: pageNumber,
  13821. pagesCount: pagesCount
  13822. }).then(function (msg) {
  13823. items.numPages.textContent = msg;
  13824. });
  13825. } else {
  13826. items.pageNumber.value = pageNumber;
  13827. }
  13828. items.previous.disabled = pageNumber <= 1;
  13829. items.next.disabled = pageNumber >= pagesCount;
  13830. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  13831. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  13832. this.l10n.get("page_scale_percent", {
  13833. scale: Math.round(pageScale * 10000) / 100
  13834. }).then(function (msg) {
  13835. var predefinedValueFound = false;
  13836. var _iterator2 = _createForOfIteratorHelper(items.scaleSelect.options),
  13837. _step2;
  13838. try {
  13839. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  13840. var option = _step2.value;
  13841. if (option.value !== pageScaleValue) {
  13842. option.selected = false;
  13843. continue;
  13844. }
  13845. option.selected = true;
  13846. predefinedValueFound = true;
  13847. }
  13848. } catch (err) {
  13849. _iterator2.e(err);
  13850. } finally {
  13851. _iterator2.f();
  13852. }
  13853. if (!predefinedValueFound) {
  13854. items.customScaleOption.textContent = msg;
  13855. items.customScaleOption.selected = true;
  13856. }
  13857. });
  13858. }
  13859. }, {
  13860. key: "updateLoadingIndicatorState",
  13861. value: function updateLoadingIndicatorState() {
  13862. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  13863. var pageNumberInput = this.items.pageNumber;
  13864. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  13865. }
  13866. }, {
  13867. key: "_adjustScaleWidth",
  13868. value: function () {
  13869. var _adjustScaleWidth2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  13870. var items, l10n, predefinedValuesPromise, canvas, ctx, _getComputedStyle, fontSize, fontFamily, maxWidth, _iterator3, _step3, predefinedValue, _ctx$measureText, width, overflow;
  13871. return _regenerator["default"].wrap(function _callee$(_context) {
  13872. while (1) {
  13873. switch (_context.prev = _context.next) {
  13874. case 0:
  13875. items = this.items, l10n = this.l10n;
  13876. predefinedValuesPromise = Promise.all([l10n.get("page_scale_auto"), l10n.get("page_scale_actual"), l10n.get("page_scale_fit"), l10n.get("page_scale_width")]);
  13877. canvas = document.createElement("canvas");
  13878. canvas.mozOpaque = true;
  13879. ctx = canvas.getContext("2d", {
  13880. alpha: false
  13881. });
  13882. _context.next = 7;
  13883. return _ui_utils.animationStarted;
  13884. case 7:
  13885. _getComputedStyle = getComputedStyle(items.scaleSelect), fontSize = _getComputedStyle.fontSize, fontFamily = _getComputedStyle.fontFamily;
  13886. ctx.font = "".concat(fontSize, " ").concat(fontFamily);
  13887. maxWidth = 0;
  13888. _context.t0 = _createForOfIteratorHelper;
  13889. _context.next = 13;
  13890. return predefinedValuesPromise;
  13891. case 13:
  13892. _context.t1 = _context.sent;
  13893. _iterator3 = (0, _context.t0)(_context.t1);
  13894. try {
  13895. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  13896. predefinedValue = _step3.value;
  13897. _ctx$measureText = ctx.measureText(predefinedValue), width = _ctx$measureText.width;
  13898. if (width > maxWidth) {
  13899. maxWidth = width;
  13900. }
  13901. }
  13902. } catch (err) {
  13903. _iterator3.e(err);
  13904. } finally {
  13905. _iterator3.f();
  13906. }
  13907. overflow = SCALE_SELECT_WIDTH - SCALE_SELECT_CONTAINER_WIDTH;
  13908. maxWidth += 2 * overflow;
  13909. if (maxWidth > SCALE_SELECT_CONTAINER_WIDTH) {
  13910. items.scaleSelect.style.width = "".concat(maxWidth + overflow, "px");
  13911. items.scaleSelectContainer.style.width = "".concat(maxWidth, "px");
  13912. }
  13913. canvas.width = 0;
  13914. canvas.height = 0;
  13915. canvas = ctx = null;
  13916. case 22:
  13917. case "end":
  13918. return _context.stop();
  13919. }
  13920. }
  13921. }, _callee, this);
  13922. }));
  13923. function _adjustScaleWidth() {
  13924. return _adjustScaleWidth2.apply(this, arguments);
  13925. }
  13926. return _adjustScaleWidth;
  13927. }()
  13928. }]);
  13929. return Toolbar;
  13930. }();
  13931. exports.Toolbar = Toolbar;
  13932. /***/ }),
  13933. /* 39 */
  13934. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13935. Object.defineProperty(exports, "__esModule", ({
  13936. value: true
  13937. }));
  13938. exports.ViewHistory = void 0;
  13939. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  13940. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13941. 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); } }
  13942. 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); }); }; }
  13943. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13944. 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); } }
  13945. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13946. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  13947. var ViewHistory = /*#__PURE__*/function () {
  13948. function ViewHistory(fingerprint) {
  13949. var _this = this;
  13950. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  13951. _classCallCheck(this, ViewHistory);
  13952. this.fingerprint = fingerprint;
  13953. this.cacheSize = cacheSize;
  13954. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  13955. var database = JSON.parse(databaseStr || "{}");
  13956. var index = -1;
  13957. if (!Array.isArray(database.files)) {
  13958. database.files = [];
  13959. } else {
  13960. while (database.files.length >= _this.cacheSize) {
  13961. database.files.shift();
  13962. }
  13963. for (var i = 0, ii = database.files.length; i < ii; i++) {
  13964. var branch = database.files[i];
  13965. if (branch.fingerprint === _this.fingerprint) {
  13966. index = i;
  13967. break;
  13968. }
  13969. }
  13970. }
  13971. if (index === -1) {
  13972. index = database.files.push({
  13973. fingerprint: _this.fingerprint
  13974. }) - 1;
  13975. }
  13976. _this.file = database.files[index];
  13977. _this.database = database;
  13978. });
  13979. }
  13980. _createClass(ViewHistory, [{
  13981. key: "_writeToStorage",
  13982. value: function () {
  13983. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  13984. var databaseStr;
  13985. return _regenerator["default"].wrap(function _callee$(_context) {
  13986. while (1) {
  13987. switch (_context.prev = _context.next) {
  13988. case 0:
  13989. databaseStr = JSON.stringify(this.database);
  13990. localStorage.setItem("pdfjs.history", databaseStr);
  13991. case 2:
  13992. case "end":
  13993. return _context.stop();
  13994. }
  13995. }
  13996. }, _callee, this);
  13997. }));
  13998. function _writeToStorage() {
  13999. return _writeToStorage2.apply(this, arguments);
  14000. }
  14001. return _writeToStorage;
  14002. }()
  14003. }, {
  14004. key: "_readFromStorage",
  14005. value: function () {
  14006. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  14007. return _regenerator["default"].wrap(function _callee2$(_context2) {
  14008. while (1) {
  14009. switch (_context2.prev = _context2.next) {
  14010. case 0:
  14011. return _context2.abrupt("return", localStorage.getItem("pdfjs.history"));
  14012. case 1:
  14013. case "end":
  14014. return _context2.stop();
  14015. }
  14016. }
  14017. }, _callee2);
  14018. }));
  14019. function _readFromStorage() {
  14020. return _readFromStorage2.apply(this, arguments);
  14021. }
  14022. return _readFromStorage;
  14023. }()
  14024. }, {
  14025. key: "set",
  14026. value: function () {
  14027. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name, val) {
  14028. return _regenerator["default"].wrap(function _callee3$(_context3) {
  14029. while (1) {
  14030. switch (_context3.prev = _context3.next) {
  14031. case 0:
  14032. _context3.next = 2;
  14033. return this._initializedPromise;
  14034. case 2:
  14035. this.file[name] = val;
  14036. return _context3.abrupt("return", this._writeToStorage());
  14037. case 4:
  14038. case "end":
  14039. return _context3.stop();
  14040. }
  14041. }
  14042. }, _callee3, this);
  14043. }));
  14044. function set(_x, _x2) {
  14045. return _set.apply(this, arguments);
  14046. }
  14047. return set;
  14048. }()
  14049. }, {
  14050. key: "setMultiple",
  14051. value: function () {
  14052. var _setMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(properties) {
  14053. var name;
  14054. return _regenerator["default"].wrap(function _callee4$(_context4) {
  14055. while (1) {
  14056. switch (_context4.prev = _context4.next) {
  14057. case 0:
  14058. _context4.next = 2;
  14059. return this._initializedPromise;
  14060. case 2:
  14061. for (name in properties) {
  14062. this.file[name] = properties[name];
  14063. }
  14064. return _context4.abrupt("return", this._writeToStorage());
  14065. case 4:
  14066. case "end":
  14067. return _context4.stop();
  14068. }
  14069. }
  14070. }, _callee4, this);
  14071. }));
  14072. function setMultiple(_x3) {
  14073. return _setMultiple.apply(this, arguments);
  14074. }
  14075. return setMultiple;
  14076. }()
  14077. }, {
  14078. key: "get",
  14079. value: function () {
  14080. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name, defaultValue) {
  14081. var val;
  14082. return _regenerator["default"].wrap(function _callee5$(_context5) {
  14083. while (1) {
  14084. switch (_context5.prev = _context5.next) {
  14085. case 0:
  14086. _context5.next = 2;
  14087. return this._initializedPromise;
  14088. case 2:
  14089. val = this.file[name];
  14090. return _context5.abrupt("return", val !== undefined ? val : defaultValue);
  14091. case 4:
  14092. case "end":
  14093. return _context5.stop();
  14094. }
  14095. }
  14096. }, _callee5, this);
  14097. }));
  14098. function get(_x4, _x5) {
  14099. return _get.apply(this, arguments);
  14100. }
  14101. return get;
  14102. }()
  14103. }, {
  14104. key: "getMultiple",
  14105. value: function () {
  14106. var _getMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6(properties) {
  14107. var values, name, val;
  14108. return _regenerator["default"].wrap(function _callee6$(_context6) {
  14109. while (1) {
  14110. switch (_context6.prev = _context6.next) {
  14111. case 0:
  14112. _context6.next = 2;
  14113. return this._initializedPromise;
  14114. case 2:
  14115. values = Object.create(null);
  14116. for (name in properties) {
  14117. val = this.file[name];
  14118. values[name] = val !== undefined ? val : properties[name];
  14119. }
  14120. return _context6.abrupt("return", values);
  14121. case 5:
  14122. case "end":
  14123. return _context6.stop();
  14124. }
  14125. }
  14126. }, _callee6, this);
  14127. }));
  14128. function getMultiple(_x6) {
  14129. return _getMultiple.apply(this, arguments);
  14130. }
  14131. return getMultiple;
  14132. }()
  14133. }]);
  14134. return ViewHistory;
  14135. }();
  14136. exports.ViewHistory = ViewHistory;
  14137. /***/ }),
  14138. /* 40 */
  14139. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14140. 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); }
  14141. Object.defineProperty(exports, "__esModule", ({
  14142. value: true
  14143. }));
  14144. exports.GenericCom = void 0;
  14145. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  14146. var _app = __webpack_require__(3);
  14147. var _preferences = __webpack_require__(41);
  14148. var _download_manager = __webpack_require__(42);
  14149. var _genericl10n = __webpack_require__(43);
  14150. var _generic_scripting = __webpack_require__(45);
  14151. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14152. 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); } }
  14153. 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); }); }; }
  14154. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14155. 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); } }
  14156. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14157. 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); }
  14158. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14159. 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); }; }
  14160. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  14161. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  14162. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  14163. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  14164. ;
  14165. var GenericCom = {};
  14166. exports.GenericCom = GenericCom;
  14167. var GenericPreferences = /*#__PURE__*/function (_BasePreferences) {
  14168. _inherits(GenericPreferences, _BasePreferences);
  14169. var _super = _createSuper(GenericPreferences);
  14170. function GenericPreferences() {
  14171. _classCallCheck(this, GenericPreferences);
  14172. return _super.apply(this, arguments);
  14173. }
  14174. _createClass(GenericPreferences, [{
  14175. key: "_writeToStorage",
  14176. value: function () {
  14177. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  14178. return _regenerator["default"].wrap(function _callee$(_context) {
  14179. while (1) {
  14180. switch (_context.prev = _context.next) {
  14181. case 0:
  14182. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  14183. case 1:
  14184. case "end":
  14185. return _context.stop();
  14186. }
  14187. }
  14188. }, _callee);
  14189. }));
  14190. function _writeToStorage(_x) {
  14191. return _writeToStorage2.apply(this, arguments);
  14192. }
  14193. return _writeToStorage;
  14194. }()
  14195. }, {
  14196. key: "_readFromStorage",
  14197. value: function () {
  14198. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  14199. return _regenerator["default"].wrap(function _callee2$(_context2) {
  14200. while (1) {
  14201. switch (_context2.prev = _context2.next) {
  14202. case 0:
  14203. return _context2.abrupt("return", JSON.parse(localStorage.getItem("pdfjs.preferences")));
  14204. case 1:
  14205. case "end":
  14206. return _context2.stop();
  14207. }
  14208. }
  14209. }, _callee2);
  14210. }));
  14211. function _readFromStorage(_x2) {
  14212. return _readFromStorage2.apply(this, arguments);
  14213. }
  14214. return _readFromStorage;
  14215. }()
  14216. }]);
  14217. return GenericPreferences;
  14218. }(_preferences.BasePreferences);
  14219. var GenericExternalServices = /*#__PURE__*/function (_DefaultExternalServi) {
  14220. _inherits(GenericExternalServices, _DefaultExternalServi);
  14221. var _super2 = _createSuper(GenericExternalServices);
  14222. function GenericExternalServices() {
  14223. _classCallCheck(this, GenericExternalServices);
  14224. return _super2.apply(this, arguments);
  14225. }
  14226. _createClass(GenericExternalServices, null, [{
  14227. key: "createDownloadManager",
  14228. value: function createDownloadManager(options) {
  14229. return new _download_manager.DownloadManager();
  14230. }
  14231. }, {
  14232. key: "createPreferences",
  14233. value: function createPreferences() {
  14234. return new GenericPreferences();
  14235. }
  14236. }, {
  14237. key: "createL10n",
  14238. value: function createL10n(_ref) {
  14239. var _ref$locale = _ref.locale,
  14240. locale = _ref$locale === void 0 ? "en-US" : _ref$locale;
  14241. return new _genericl10n.GenericL10n(locale);
  14242. }
  14243. }, {
  14244. key: "createScripting",
  14245. value: function createScripting(_ref2) {
  14246. var sandboxBundleSrc = _ref2.sandboxBundleSrc;
  14247. return new _generic_scripting.GenericScripting(sandboxBundleSrc);
  14248. }
  14249. }]);
  14250. return GenericExternalServices;
  14251. }(_app.DefaultExternalServices);
  14252. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  14253. /***/ }),
  14254. /* 41 */
  14255. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14256. Object.defineProperty(exports, "__esModule", ({
  14257. value: true
  14258. }));
  14259. exports.BasePreferences = void 0;
  14260. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  14261. var _app_options = __webpack_require__(1);
  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 _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); }
  14266. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14267. 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); } }
  14268. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14269. var BasePreferences = /*#__PURE__*/function () {
  14270. function BasePreferences() {
  14271. var _this = this;
  14272. _classCallCheck(this, BasePreferences);
  14273. if (this.constructor === BasePreferences) {
  14274. throw new Error("Cannot initialize BasePreferences.");
  14275. }
  14276. Object.defineProperty(this, "defaults", {
  14277. value: Object.freeze({
  14278. "cursorToolOnLoad": 0,
  14279. "defaultZoomValue": "",
  14280. "disablePageLabels": false,
  14281. "enablePermissions": false,
  14282. "enablePrintAutoRotate": true,
  14283. "enableScripting": true,
  14284. "enableWebGL": false,
  14285. "externalLinkTarget": 0,
  14286. "historyUpdateUrl": false,
  14287. "ignoreDestinationZoom": false,
  14288. "pdfBugEnabled": false,
  14289. "renderer": "canvas",
  14290. "renderInteractiveForms": true,
  14291. "sidebarViewOnLoad": -1,
  14292. "scrollModeOnLoad": -1,
  14293. "spreadModeOnLoad": -1,
  14294. "textLayerMode": 1,
  14295. "useOnlyCssZoom": false,
  14296. "viewerCssTheme": 0,
  14297. "viewOnLoad": 0,
  14298. "disableAutoFetch": false,
  14299. "disableFontFace": false,
  14300. "disableRange": false,
  14301. "disableStream": false
  14302. }),
  14303. writable: false,
  14304. enumerable: true,
  14305. configurable: false
  14306. });
  14307. this.prefs = Object.create(null);
  14308. this._initializedPromise = this._readFromStorage(this.defaults).then(function (prefs) {
  14309. for (var name in _this.defaults) {
  14310. var prefValue = prefs === null || prefs === void 0 ? void 0 : prefs[name];
  14311. if (_typeof(prefValue) === _typeof(_this.defaults[name])) {
  14312. _this.prefs[name] = prefValue;
  14313. }
  14314. }
  14315. });
  14316. }
  14317. _createClass(BasePreferences, [{
  14318. key: "_writeToStorage",
  14319. value: function () {
  14320. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  14321. return _regenerator["default"].wrap(function _callee$(_context) {
  14322. while (1) {
  14323. switch (_context.prev = _context.next) {
  14324. case 0:
  14325. throw new Error("Not implemented: _writeToStorage");
  14326. case 1:
  14327. case "end":
  14328. return _context.stop();
  14329. }
  14330. }
  14331. }, _callee);
  14332. }));
  14333. function _writeToStorage(_x) {
  14334. return _writeToStorage2.apply(this, arguments);
  14335. }
  14336. return _writeToStorage;
  14337. }()
  14338. }, {
  14339. key: "_readFromStorage",
  14340. value: function () {
  14341. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  14342. return _regenerator["default"].wrap(function _callee2$(_context2) {
  14343. while (1) {
  14344. switch (_context2.prev = _context2.next) {
  14345. case 0:
  14346. throw new Error("Not implemented: _readFromStorage");
  14347. case 1:
  14348. case "end":
  14349. return _context2.stop();
  14350. }
  14351. }
  14352. }, _callee2);
  14353. }));
  14354. function _readFromStorage(_x2) {
  14355. return _readFromStorage2.apply(this, arguments);
  14356. }
  14357. return _readFromStorage;
  14358. }()
  14359. }, {
  14360. key: "reset",
  14361. value: function () {
  14362. var _reset = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  14363. return _regenerator["default"].wrap(function _callee3$(_context3) {
  14364. while (1) {
  14365. switch (_context3.prev = _context3.next) {
  14366. case 0:
  14367. _context3.next = 2;
  14368. return this._initializedPromise;
  14369. case 2:
  14370. this.prefs = Object.create(null);
  14371. return _context3.abrupt("return", this._writeToStorage(this.defaults));
  14372. case 4:
  14373. case "end":
  14374. return _context3.stop();
  14375. }
  14376. }
  14377. }, _callee3, this);
  14378. }));
  14379. function reset() {
  14380. return _reset.apply(this, arguments);
  14381. }
  14382. return reset;
  14383. }()
  14384. }, {
  14385. key: "set",
  14386. value: function () {
  14387. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name, value) {
  14388. var defaultValue, valueType, defaultType;
  14389. return _regenerator["default"].wrap(function _callee4$(_context4) {
  14390. while (1) {
  14391. switch (_context4.prev = _context4.next) {
  14392. case 0:
  14393. _context4.next = 2;
  14394. return this._initializedPromise;
  14395. case 2:
  14396. defaultValue = this.defaults[name];
  14397. if (!(defaultValue === undefined)) {
  14398. _context4.next = 7;
  14399. break;
  14400. }
  14401. throw new Error("Set preference: \"".concat(name, "\" is undefined."));
  14402. case 7:
  14403. if (!(value === undefined)) {
  14404. _context4.next = 9;
  14405. break;
  14406. }
  14407. throw new Error("Set preference: no value is specified.");
  14408. case 9:
  14409. valueType = _typeof(value);
  14410. defaultType = _typeof(defaultValue);
  14411. if (!(valueType !== defaultType)) {
  14412. _context4.next = 19;
  14413. break;
  14414. }
  14415. if (!(valueType === "number" && defaultType === "string")) {
  14416. _context4.next = 16;
  14417. break;
  14418. }
  14419. value = value.toString();
  14420. _context4.next = 17;
  14421. break;
  14422. case 16:
  14423. throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", expected a ").concat(defaultType, "."));
  14424. case 17:
  14425. _context4.next = 21;
  14426. break;
  14427. case 19:
  14428. if (!(valueType === "number" && !Number.isInteger(value))) {
  14429. _context4.next = 21;
  14430. break;
  14431. }
  14432. throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
  14433. case 21:
  14434. this.prefs[name] = value;
  14435. return _context4.abrupt("return", this._writeToStorage(this.prefs));
  14436. case 23:
  14437. case "end":
  14438. return _context4.stop();
  14439. }
  14440. }
  14441. }, _callee4, this);
  14442. }));
  14443. function set(_x3, _x4) {
  14444. return _set.apply(this, arguments);
  14445. }
  14446. return set;
  14447. }()
  14448. }, {
  14449. key: "get",
  14450. value: function () {
  14451. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name) {
  14452. var defaultValue, prefValue;
  14453. return _regenerator["default"].wrap(function _callee5$(_context5) {
  14454. while (1) {
  14455. switch (_context5.prev = _context5.next) {
  14456. case 0:
  14457. _context5.next = 2;
  14458. return this._initializedPromise;
  14459. case 2:
  14460. defaultValue = this.defaults[name], prefValue = this.prefs[name];
  14461. if (!(defaultValue === undefined)) {
  14462. _context5.next = 5;
  14463. break;
  14464. }
  14465. throw new Error("Get preference: \"".concat(name, "\" is undefined."));
  14466. case 5:
  14467. return _context5.abrupt("return", prefValue !== undefined ? prefValue : defaultValue);
  14468. case 6:
  14469. case "end":
  14470. return _context5.stop();
  14471. }
  14472. }
  14473. }, _callee5, this);
  14474. }));
  14475. function get(_x5) {
  14476. return _get.apply(this, arguments);
  14477. }
  14478. return get;
  14479. }()
  14480. }, {
  14481. key: "getAll",
  14482. value: function () {
  14483. var _getAll = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  14484. var obj, name, prefValue;
  14485. return _regenerator["default"].wrap(function _callee6$(_context6) {
  14486. while (1) {
  14487. switch (_context6.prev = _context6.next) {
  14488. case 0:
  14489. _context6.next = 2;
  14490. return this._initializedPromise;
  14491. case 2:
  14492. obj = Object.create(null);
  14493. for (name in this.defaults) {
  14494. prefValue = this.prefs[name];
  14495. obj[name] = prefValue !== undefined ? prefValue : this.defaults[name];
  14496. }
  14497. return _context6.abrupt("return", obj);
  14498. case 5:
  14499. case "end":
  14500. return _context6.stop();
  14501. }
  14502. }
  14503. }, _callee6, this);
  14504. }));
  14505. function getAll() {
  14506. return _getAll.apply(this, arguments);
  14507. }
  14508. return getAll;
  14509. }()
  14510. }]);
  14511. return BasePreferences;
  14512. }();
  14513. exports.BasePreferences = BasePreferences;
  14514. /***/ }),
  14515. /* 42 */
  14516. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14517. Object.defineProperty(exports, "__esModule", ({
  14518. value: true
  14519. }));
  14520. exports.DownloadManager = void 0;
  14521. var _pdfjsLib = __webpack_require__(7);
  14522. var _viewer_compatibility = __webpack_require__(2);
  14523. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14524. 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); } }
  14525. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14526. ;
  14527. function _download(blobUrl, filename) {
  14528. var a = document.createElement("a");
  14529. if (!a.click) {
  14530. throw new Error('DownloadManager: "a.click()" is not supported.');
  14531. }
  14532. a.href = blobUrl;
  14533. a.target = "_parent";
  14534. if ("download" in a) {
  14535. a.download = filename;
  14536. }
  14537. (document.body || document.documentElement).appendChild(a);
  14538. a.click();
  14539. a.remove();
  14540. }
  14541. var DownloadManager = /*#__PURE__*/function () {
  14542. function DownloadManager() {
  14543. _classCallCheck(this, DownloadManager);
  14544. this._openBlobUrls = new WeakMap();
  14545. }
  14546. _createClass(DownloadManager, [{
  14547. key: "downloadUrl",
  14548. value: function downloadUrl(url, filename) {
  14549. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  14550. return;
  14551. }
  14552. _download(url + "#pdfjs.action=download", filename);
  14553. }
  14554. }, {
  14555. key: "downloadData",
  14556. value: function downloadData(data, filename, contentType) {
  14557. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
  14558. _download(blobUrl, filename);
  14559. }
  14560. }, {
  14561. key: "openOrDownloadData",
  14562. value: function openOrDownloadData(element, data, filename) {
  14563. var isPdfData = (0, _pdfjsLib.isPdfFile)(filename);
  14564. var contentType = isPdfData ? "application/pdf" : "";
  14565. if (isPdfData && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  14566. var blobUrl = this._openBlobUrls.get(element);
  14567. if (!blobUrl) {
  14568. blobUrl = URL.createObjectURL(new Blob([data], {
  14569. type: contentType
  14570. }));
  14571. this._openBlobUrls.set(element, blobUrl);
  14572. }
  14573. var viewerUrl;
  14574. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  14575. try {
  14576. window.open(viewerUrl);
  14577. return true;
  14578. } catch (ex) {
  14579. console.error("openOrDownloadData: ".concat(ex));
  14580. URL.revokeObjectURL(blobUrl);
  14581. this._openBlobUrls["delete"](element);
  14582. }
  14583. }
  14584. this.downloadData(data, filename, contentType);
  14585. return false;
  14586. }
  14587. }, {
  14588. key: "download",
  14589. value: function download(blob, url, filename) {
  14590. var sourceEventType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "download";
  14591. if (_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  14592. this.downloadUrl(url, filename);
  14593. return;
  14594. }
  14595. var blobUrl = URL.createObjectURL(blob);
  14596. _download(blobUrl, filename);
  14597. }
  14598. }]);
  14599. return DownloadManager;
  14600. }();
  14601. exports.DownloadManager = DownloadManager;
  14602. /***/ }),
  14603. /* 43 */
  14604. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14605. Object.defineProperty(exports, "__esModule", ({
  14606. value: true
  14607. }));
  14608. exports.GenericL10n = void 0;
  14609. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  14610. __webpack_require__(44);
  14611. var _l10n_utils = __webpack_require__(32);
  14612. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14613. 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); } }
  14614. 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); }); }; }
  14615. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14616. 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); } }
  14617. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14618. var webL10n = document.webL10n;
  14619. var GenericL10n = /*#__PURE__*/function () {
  14620. function GenericL10n(lang) {
  14621. _classCallCheck(this, GenericL10n);
  14622. this._lang = lang;
  14623. this._ready = new Promise(function (resolve, reject) {
  14624. webL10n.setLanguage(lang, function () {
  14625. resolve(webL10n);
  14626. });
  14627. });
  14628. }
  14629. _createClass(GenericL10n, [{
  14630. key: "getLanguage",
  14631. value: function () {
  14632. var _getLanguage = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  14633. var l10n;
  14634. return _regenerator["default"].wrap(function _callee$(_context) {
  14635. while (1) {
  14636. switch (_context.prev = _context.next) {
  14637. case 0:
  14638. _context.next = 2;
  14639. return this._ready;
  14640. case 2:
  14641. l10n = _context.sent;
  14642. return _context.abrupt("return", l10n.getLanguage());
  14643. case 4:
  14644. case "end":
  14645. return _context.stop();
  14646. }
  14647. }
  14648. }, _callee, this);
  14649. }));
  14650. function getLanguage() {
  14651. return _getLanguage.apply(this, arguments);
  14652. }
  14653. return getLanguage;
  14654. }()
  14655. }, {
  14656. key: "getDirection",
  14657. value: function () {
  14658. var _getDirection = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  14659. var l10n;
  14660. return _regenerator["default"].wrap(function _callee2$(_context2) {
  14661. while (1) {
  14662. switch (_context2.prev = _context2.next) {
  14663. case 0:
  14664. _context2.next = 2;
  14665. return this._ready;
  14666. case 2:
  14667. l10n = _context2.sent;
  14668. return _context2.abrupt("return", l10n.getDirection());
  14669. case 4:
  14670. case "end":
  14671. return _context2.stop();
  14672. }
  14673. }
  14674. }, _callee2, this);
  14675. }));
  14676. function getDirection() {
  14677. return _getDirection.apply(this, arguments);
  14678. }
  14679. return getDirection;
  14680. }()
  14681. }, {
  14682. key: "get",
  14683. value: function () {
  14684. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(key) {
  14685. var args,
  14686. fallback,
  14687. l10n,
  14688. _args3 = arguments;
  14689. return _regenerator["default"].wrap(function _callee3$(_context3) {
  14690. while (1) {
  14691. switch (_context3.prev = _context3.next) {
  14692. case 0:
  14693. args = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : null;
  14694. fallback = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : (0, _l10n_utils.getL10nFallback)(key, args);
  14695. _context3.next = 4;
  14696. return this._ready;
  14697. case 4:
  14698. l10n = _context3.sent;
  14699. return _context3.abrupt("return", l10n.get(key, args, fallback));
  14700. case 6:
  14701. case "end":
  14702. return _context3.stop();
  14703. }
  14704. }
  14705. }, _callee3, this);
  14706. }));
  14707. function get(_x) {
  14708. return _get.apply(this, arguments);
  14709. }
  14710. return get;
  14711. }()
  14712. }, {
  14713. key: "translate",
  14714. value: function () {
  14715. var _translate = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(element) {
  14716. var l10n;
  14717. return _regenerator["default"].wrap(function _callee4$(_context4) {
  14718. while (1) {
  14719. switch (_context4.prev = _context4.next) {
  14720. case 0:
  14721. _context4.next = 2;
  14722. return this._ready;
  14723. case 2:
  14724. l10n = _context4.sent;
  14725. return _context4.abrupt("return", l10n.translate(element));
  14726. case 4:
  14727. case "end":
  14728. return _context4.stop();
  14729. }
  14730. }
  14731. }, _callee4, this);
  14732. }));
  14733. function translate(_x2) {
  14734. return _translate.apply(this, arguments);
  14735. }
  14736. return translate;
  14737. }()
  14738. }]);
  14739. return GenericL10n;
  14740. }();
  14741. exports.GenericL10n = GenericL10n;
  14742. /***/ }),
  14743. /* 44 */
  14744. /***/ (() => {
  14745. document.webL10n = function (window, document, undefined) {
  14746. var gL10nData = {};
  14747. var gTextData = '';
  14748. var gTextProp = 'textContent';
  14749. var gLanguage = '';
  14750. var gMacros = {};
  14751. var gReadyState = 'loading';
  14752. var gAsyncResourceLoading = true;
  14753. function getL10nResourceLinks() {
  14754. return document.querySelectorAll('link[type="application/l10n"]');
  14755. }
  14756. function getL10nDictionary() {
  14757. var script = document.querySelector('script[type="application/l10n"]');
  14758. return script ? JSON.parse(script.innerHTML) : null;
  14759. }
  14760. function getTranslatableChildren(element) {
  14761. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  14762. }
  14763. function getL10nAttributes(element) {
  14764. if (!element) return {};
  14765. var l10nId = element.getAttribute('data-l10n-id');
  14766. var l10nArgs = element.getAttribute('data-l10n-args');
  14767. var args = {};
  14768. if (l10nArgs) {
  14769. try {
  14770. args = JSON.parse(l10nArgs);
  14771. } catch (e) {
  14772. console.warn('could not parse arguments for #' + l10nId);
  14773. }
  14774. }
  14775. return {
  14776. id: l10nId,
  14777. args: args
  14778. };
  14779. }
  14780. function xhrLoadText(url, onSuccess, onFailure) {
  14781. onSuccess = onSuccess || function _onSuccess(data) {};
  14782. onFailure = onFailure || function _onFailure() {};
  14783. var xhr = new XMLHttpRequest();
  14784. xhr.open('GET', url, gAsyncResourceLoading);
  14785. if (xhr.overrideMimeType) {
  14786. xhr.overrideMimeType('text/plain; charset=utf-8');
  14787. }
  14788. xhr.onreadystatechange = function () {
  14789. if (xhr.readyState == 4) {
  14790. if (xhr.status == 200 || xhr.status === 0) {
  14791. onSuccess(xhr.responseText);
  14792. } else {
  14793. onFailure();
  14794. }
  14795. }
  14796. };
  14797. xhr.onerror = onFailure;
  14798. xhr.ontimeout = onFailure;
  14799. try {
  14800. xhr.send(null);
  14801. } catch (e) {
  14802. onFailure();
  14803. }
  14804. }
  14805. function parseResource(href, lang, successCallback, failureCallback) {
  14806. var baseURL = href.replace(/[^\/]*$/, '') || './';
  14807. function evalString(text) {
  14808. if (text.lastIndexOf('\\') < 0) return text;
  14809. 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, "'");
  14810. }
  14811. function parseProperties(text, parsedPropertiesCallback) {
  14812. var dictionary = {};
  14813. var reBlank = /^\s*|\s*$/;
  14814. var reComment = /^\s*#|^\s*$/;
  14815. var reSection = /^\s*\[(.*)\]\s*$/;
  14816. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  14817. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  14818. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  14819. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  14820. var currentLang = '*';
  14821. var genericLang = lang.split('-', 1)[0];
  14822. var skipLang = false;
  14823. var match = '';
  14824. function nextEntry() {
  14825. while (true) {
  14826. if (!entries.length) {
  14827. parsedRawLinesCallback();
  14828. return;
  14829. }
  14830. var line = entries.shift();
  14831. if (reComment.test(line)) continue;
  14832. if (extendedSyntax) {
  14833. match = reSection.exec(line);
  14834. if (match) {
  14835. currentLang = match[1].toLowerCase();
  14836. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  14837. continue;
  14838. } else if (skipLang) {
  14839. continue;
  14840. }
  14841. match = reImport.exec(line);
  14842. if (match) {
  14843. loadImport(baseURL + match[1], nextEntry);
  14844. return;
  14845. }
  14846. }
  14847. var tmp = line.match(reSplit);
  14848. if (tmp && tmp.length == 3) {
  14849. dictionary[tmp[1]] = evalString(tmp[2]);
  14850. }
  14851. }
  14852. }
  14853. nextEntry();
  14854. }
  14855. function loadImport(url, callback) {
  14856. xhrLoadText(url, function (content) {
  14857. parseRawLines(content, false, callback);
  14858. }, function () {
  14859. console.warn(url + ' not found.');
  14860. callback();
  14861. });
  14862. }
  14863. parseRawLines(text, true, function () {
  14864. parsedPropertiesCallback(dictionary);
  14865. });
  14866. }
  14867. xhrLoadText(href, function (response) {
  14868. gTextData += response;
  14869. parseProperties(response, function (data) {
  14870. for (var key in data) {
  14871. var id,
  14872. prop,
  14873. index = key.lastIndexOf('.');
  14874. if (index > 0) {
  14875. id = key.substring(0, index);
  14876. prop = key.substring(index + 1);
  14877. } else {
  14878. id = key;
  14879. prop = gTextProp;
  14880. }
  14881. if (!gL10nData[id]) {
  14882. gL10nData[id] = {};
  14883. }
  14884. gL10nData[id][prop] = data[key];
  14885. }
  14886. if (successCallback) {
  14887. successCallback();
  14888. }
  14889. });
  14890. }, failureCallback);
  14891. }
  14892. function loadLocale(lang, callback) {
  14893. if (lang) {
  14894. lang = lang.toLowerCase();
  14895. }
  14896. callback = callback || function _callback() {};
  14897. clear();
  14898. gLanguage = lang;
  14899. var langLinks = getL10nResourceLinks();
  14900. var langCount = langLinks.length;
  14901. if (langCount === 0) {
  14902. var dict = getL10nDictionary();
  14903. if (dict && dict.locales && dict.default_locale) {
  14904. console.log('using the embedded JSON directory, early way out');
  14905. gL10nData = dict.locales[lang];
  14906. if (!gL10nData) {
  14907. var defaultLocale = dict.default_locale.toLowerCase();
  14908. for (var anyCaseLang in dict.locales) {
  14909. anyCaseLang = anyCaseLang.toLowerCase();
  14910. if (anyCaseLang === lang) {
  14911. gL10nData = dict.locales[lang];
  14912. break;
  14913. } else if (anyCaseLang === defaultLocale) {
  14914. gL10nData = dict.locales[defaultLocale];
  14915. }
  14916. }
  14917. }
  14918. callback();
  14919. } else {
  14920. console.log('no resource to load, early way out');
  14921. }
  14922. gReadyState = 'complete';
  14923. return;
  14924. }
  14925. var onResourceLoaded = null;
  14926. var gResourceCount = 0;
  14927. onResourceLoaded = function onResourceLoaded() {
  14928. gResourceCount++;
  14929. if (gResourceCount >= langCount) {
  14930. callback();
  14931. gReadyState = 'complete';
  14932. }
  14933. };
  14934. function L10nResourceLink(link) {
  14935. var href = link.href;
  14936. this.load = function (lang, callback) {
  14937. parseResource(href, lang, callback, function () {
  14938. console.warn(href + ' not found.');
  14939. console.warn('"' + lang + '" resource not found');
  14940. gLanguage = '';
  14941. callback();
  14942. });
  14943. };
  14944. }
  14945. for (var i = 0; i < langCount; i++) {
  14946. var resource = new L10nResourceLink(langLinks[i]);
  14947. resource.load(lang, onResourceLoaded);
  14948. }
  14949. }
  14950. function clear() {
  14951. gL10nData = {};
  14952. gTextData = '';
  14953. gLanguage = '';
  14954. }
  14955. function getPluralRules(lang) {
  14956. var locales2rules = {
  14957. 'af': 3,
  14958. 'ak': 4,
  14959. 'am': 4,
  14960. 'ar': 1,
  14961. 'asa': 3,
  14962. 'az': 0,
  14963. 'be': 11,
  14964. 'bem': 3,
  14965. 'bez': 3,
  14966. 'bg': 3,
  14967. 'bh': 4,
  14968. 'bm': 0,
  14969. 'bn': 3,
  14970. 'bo': 0,
  14971. 'br': 20,
  14972. 'brx': 3,
  14973. 'bs': 11,
  14974. 'ca': 3,
  14975. 'cgg': 3,
  14976. 'chr': 3,
  14977. 'cs': 12,
  14978. 'cy': 17,
  14979. 'da': 3,
  14980. 'de': 3,
  14981. 'dv': 3,
  14982. 'dz': 0,
  14983. 'ee': 3,
  14984. 'el': 3,
  14985. 'en': 3,
  14986. 'eo': 3,
  14987. 'es': 3,
  14988. 'et': 3,
  14989. 'eu': 3,
  14990. 'fa': 0,
  14991. 'ff': 5,
  14992. 'fi': 3,
  14993. 'fil': 4,
  14994. 'fo': 3,
  14995. 'fr': 5,
  14996. 'fur': 3,
  14997. 'fy': 3,
  14998. 'ga': 8,
  14999. 'gd': 24,
  15000. 'gl': 3,
  15001. 'gsw': 3,
  15002. 'gu': 3,
  15003. 'guw': 4,
  15004. 'gv': 23,
  15005. 'ha': 3,
  15006. 'haw': 3,
  15007. 'he': 2,
  15008. 'hi': 4,
  15009. 'hr': 11,
  15010. 'hu': 0,
  15011. 'id': 0,
  15012. 'ig': 0,
  15013. 'ii': 0,
  15014. 'is': 3,
  15015. 'it': 3,
  15016. 'iu': 7,
  15017. 'ja': 0,
  15018. 'jmc': 3,
  15019. 'jv': 0,
  15020. 'ka': 0,
  15021. 'kab': 5,
  15022. 'kaj': 3,
  15023. 'kcg': 3,
  15024. 'kde': 0,
  15025. 'kea': 0,
  15026. 'kk': 3,
  15027. 'kl': 3,
  15028. 'km': 0,
  15029. 'kn': 0,
  15030. 'ko': 0,
  15031. 'ksb': 3,
  15032. 'ksh': 21,
  15033. 'ku': 3,
  15034. 'kw': 7,
  15035. 'lag': 18,
  15036. 'lb': 3,
  15037. 'lg': 3,
  15038. 'ln': 4,
  15039. 'lo': 0,
  15040. 'lt': 10,
  15041. 'lv': 6,
  15042. 'mas': 3,
  15043. 'mg': 4,
  15044. 'mk': 16,
  15045. 'ml': 3,
  15046. 'mn': 3,
  15047. 'mo': 9,
  15048. 'mr': 3,
  15049. 'ms': 0,
  15050. 'mt': 15,
  15051. 'my': 0,
  15052. 'nah': 3,
  15053. 'naq': 7,
  15054. 'nb': 3,
  15055. 'nd': 3,
  15056. 'ne': 3,
  15057. 'nl': 3,
  15058. 'nn': 3,
  15059. 'no': 3,
  15060. 'nr': 3,
  15061. 'nso': 4,
  15062. 'ny': 3,
  15063. 'nyn': 3,
  15064. 'om': 3,
  15065. 'or': 3,
  15066. 'pa': 3,
  15067. 'pap': 3,
  15068. 'pl': 13,
  15069. 'ps': 3,
  15070. 'pt': 3,
  15071. 'rm': 3,
  15072. 'ro': 9,
  15073. 'rof': 3,
  15074. 'ru': 11,
  15075. 'rwk': 3,
  15076. 'sah': 0,
  15077. 'saq': 3,
  15078. 'se': 7,
  15079. 'seh': 3,
  15080. 'ses': 0,
  15081. 'sg': 0,
  15082. 'sh': 11,
  15083. 'shi': 19,
  15084. 'sk': 12,
  15085. 'sl': 14,
  15086. 'sma': 7,
  15087. 'smi': 7,
  15088. 'smj': 7,
  15089. 'smn': 7,
  15090. 'sms': 7,
  15091. 'sn': 3,
  15092. 'so': 3,
  15093. 'sq': 3,
  15094. 'sr': 11,
  15095. 'ss': 3,
  15096. 'ssy': 3,
  15097. 'st': 3,
  15098. 'sv': 3,
  15099. 'sw': 3,
  15100. 'syr': 3,
  15101. 'ta': 3,
  15102. 'te': 3,
  15103. 'teo': 3,
  15104. 'th': 0,
  15105. 'ti': 4,
  15106. 'tig': 3,
  15107. 'tk': 3,
  15108. 'tl': 4,
  15109. 'tn': 3,
  15110. 'to': 0,
  15111. 'tr': 0,
  15112. 'ts': 3,
  15113. 'tzm': 22,
  15114. 'uk': 11,
  15115. 'ur': 3,
  15116. 've': 3,
  15117. 'vi': 0,
  15118. 'vun': 3,
  15119. 'wa': 4,
  15120. 'wae': 3,
  15121. 'wo': 0,
  15122. 'xh': 3,
  15123. 'xog': 3,
  15124. 'yo': 0,
  15125. 'zh': 0,
  15126. 'zu': 3
  15127. };
  15128. function isIn(n, list) {
  15129. return list.indexOf(n) !== -1;
  15130. }
  15131. function isBetween(n, start, end) {
  15132. return start <= n && n <= end;
  15133. }
  15134. var pluralRules = {
  15135. '0': function _(n) {
  15136. return 'other';
  15137. },
  15138. '1': function _(n) {
  15139. if (isBetween(n % 100, 3, 10)) return 'few';
  15140. if (n === 0) return 'zero';
  15141. if (isBetween(n % 100, 11, 99)) return 'many';
  15142. if (n == 2) return 'two';
  15143. if (n == 1) return 'one';
  15144. return 'other';
  15145. },
  15146. '2': function _(n) {
  15147. if (n !== 0 && n % 10 === 0) return 'many';
  15148. if (n == 2) return 'two';
  15149. if (n == 1) return 'one';
  15150. return 'other';
  15151. },
  15152. '3': function _(n) {
  15153. if (n == 1) return 'one';
  15154. return 'other';
  15155. },
  15156. '4': function _(n) {
  15157. if (isBetween(n, 0, 1)) return 'one';
  15158. return 'other';
  15159. },
  15160. '5': function _(n) {
  15161. if (isBetween(n, 0, 2) && n != 2) return 'one';
  15162. return 'other';
  15163. },
  15164. '6': function _(n) {
  15165. if (n === 0) return 'zero';
  15166. if (n % 10 == 1 && n % 100 != 11) return 'one';
  15167. return 'other';
  15168. },
  15169. '7': function _(n) {
  15170. if (n == 2) return 'two';
  15171. if (n == 1) return 'one';
  15172. return 'other';
  15173. },
  15174. '8': function _(n) {
  15175. if (isBetween(n, 3, 6)) return 'few';
  15176. if (isBetween(n, 7, 10)) return 'many';
  15177. if (n == 2) return 'two';
  15178. if (n == 1) return 'one';
  15179. return 'other';
  15180. },
  15181. '9': function _(n) {
  15182. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  15183. if (n == 1) return 'one';
  15184. return 'other';
  15185. },
  15186. '10': function _(n) {
  15187. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  15188. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  15189. return 'other';
  15190. },
  15191. '11': function _(n) {
  15192. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  15193. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  15194. if (n % 10 == 1 && n % 100 != 11) return 'one';
  15195. return 'other';
  15196. },
  15197. '12': function _(n) {
  15198. if (isBetween(n, 2, 4)) return 'few';
  15199. if (n == 1) return 'one';
  15200. return 'other';
  15201. },
  15202. '13': function _(n) {
  15203. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  15204. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  15205. if (n == 1) return 'one';
  15206. return 'other';
  15207. },
  15208. '14': function _(n) {
  15209. if (isBetween(n % 100, 3, 4)) return 'few';
  15210. if (n % 100 == 2) return 'two';
  15211. if (n % 100 == 1) return 'one';
  15212. return 'other';
  15213. },
  15214. '15': function _(n) {
  15215. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  15216. if (isBetween(n % 100, 11, 19)) return 'many';
  15217. if (n == 1) return 'one';
  15218. return 'other';
  15219. },
  15220. '16': function _(n) {
  15221. if (n % 10 == 1 && n != 11) return 'one';
  15222. return 'other';
  15223. },
  15224. '17': function _(n) {
  15225. if (n == 3) return 'few';
  15226. if (n === 0) return 'zero';
  15227. if (n == 6) return 'many';
  15228. if (n == 2) return 'two';
  15229. if (n == 1) return 'one';
  15230. return 'other';
  15231. },
  15232. '18': function _(n) {
  15233. if (n === 0) return 'zero';
  15234. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  15235. return 'other';
  15236. },
  15237. '19': function _(n) {
  15238. if (isBetween(n, 2, 10)) return 'few';
  15239. if (isBetween(n, 0, 1)) return 'one';
  15240. return 'other';
  15241. },
  15242. '20': function _(n) {
  15243. 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';
  15244. if (n % 1000000 === 0 && n !== 0) return 'many';
  15245. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  15246. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  15247. return 'other';
  15248. },
  15249. '21': function _(n) {
  15250. if (n === 0) return 'zero';
  15251. if (n == 1) return 'one';
  15252. return 'other';
  15253. },
  15254. '22': function _(n) {
  15255. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  15256. return 'other';
  15257. },
  15258. '23': function _(n) {
  15259. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  15260. return 'other';
  15261. },
  15262. '24': function _(n) {
  15263. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  15264. if (isIn(n, [2, 12])) return 'two';
  15265. if (isIn(n, [1, 11])) return 'one';
  15266. return 'other';
  15267. }
  15268. };
  15269. var index = locales2rules[lang.replace(/-.*$/, '')];
  15270. if (!(index in pluralRules)) {
  15271. console.warn('plural form unknown for [' + lang + ']');
  15272. return function () {
  15273. return 'other';
  15274. };
  15275. }
  15276. return pluralRules[index];
  15277. }
  15278. gMacros.plural = function (str, param, key, prop) {
  15279. var n = parseFloat(param);
  15280. if (isNaN(n)) return str;
  15281. if (prop != gTextProp) return str;
  15282. if (!gMacros._pluralRules) {
  15283. gMacros._pluralRules = getPluralRules(gLanguage);
  15284. }
  15285. var index = '[' + gMacros._pluralRules(n) + ']';
  15286. if (n === 0 && key + '[zero]' in gL10nData) {
  15287. str = gL10nData[key + '[zero]'][prop];
  15288. } else if (n == 1 && key + '[one]' in gL10nData) {
  15289. str = gL10nData[key + '[one]'][prop];
  15290. } else if (n == 2 && key + '[two]' in gL10nData) {
  15291. str = gL10nData[key + '[two]'][prop];
  15292. } else if (key + index in gL10nData) {
  15293. str = gL10nData[key + index][prop];
  15294. } else if (key + '[other]' in gL10nData) {
  15295. str = gL10nData[key + '[other]'][prop];
  15296. }
  15297. return str;
  15298. };
  15299. function getL10nData(key, args, fallback) {
  15300. var data = gL10nData[key];
  15301. if (!data) {
  15302. console.warn('#' + key + ' is undefined.');
  15303. if (!fallback) {
  15304. return null;
  15305. }
  15306. data = fallback;
  15307. }
  15308. var rv = {};
  15309. for (var prop in data) {
  15310. var str = data[prop];
  15311. str = substIndexes(str, args, key, prop);
  15312. str = substArguments(str, args, key);
  15313. rv[prop] = str;
  15314. }
  15315. return rv;
  15316. }
  15317. function substIndexes(str, args, key, prop) {
  15318. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  15319. var reMatch = reIndex.exec(str);
  15320. if (!reMatch || !reMatch.length) return str;
  15321. var macroName = reMatch[1];
  15322. var paramName = reMatch[2];
  15323. var param;
  15324. if (args && paramName in args) {
  15325. param = args[paramName];
  15326. } else if (paramName in gL10nData) {
  15327. param = gL10nData[paramName];
  15328. }
  15329. if (macroName in gMacros) {
  15330. var macro = gMacros[macroName];
  15331. str = macro(str, param, key, prop);
  15332. }
  15333. return str;
  15334. }
  15335. function substArguments(str, args, key) {
  15336. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  15337. return str.replace(reArgs, function (matched_text, arg) {
  15338. if (args && arg in args) {
  15339. return args[arg];
  15340. }
  15341. if (arg in gL10nData) {
  15342. return gL10nData[arg];
  15343. }
  15344. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  15345. return matched_text;
  15346. });
  15347. }
  15348. function translateElement(element) {
  15349. var l10n = getL10nAttributes(element);
  15350. if (!l10n.id) return;
  15351. var data = getL10nData(l10n.id, l10n.args);
  15352. if (!data) {
  15353. console.warn('#' + l10n.id + ' is undefined.');
  15354. return;
  15355. }
  15356. if (data[gTextProp]) {
  15357. if (getChildElementCount(element) === 0) {
  15358. element[gTextProp] = data[gTextProp];
  15359. } else {
  15360. var children = element.childNodes;
  15361. var found = false;
  15362. for (var i = 0, l = children.length; i < l; i++) {
  15363. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  15364. if (found) {
  15365. children[i].nodeValue = '';
  15366. } else {
  15367. children[i].nodeValue = data[gTextProp];
  15368. found = true;
  15369. }
  15370. }
  15371. }
  15372. if (!found) {
  15373. var textNode = document.createTextNode(data[gTextProp]);
  15374. element.insertBefore(textNode, element.firstChild);
  15375. }
  15376. }
  15377. delete data[gTextProp];
  15378. }
  15379. for (var k in data) {
  15380. element[k] = data[k];
  15381. }
  15382. }
  15383. function getChildElementCount(element) {
  15384. if (element.children) {
  15385. return element.children.length;
  15386. }
  15387. if (typeof element.childElementCount !== 'undefined') {
  15388. return element.childElementCount;
  15389. }
  15390. var count = 0;
  15391. for (var i = 0; i < element.childNodes.length; i++) {
  15392. count += element.nodeType === 1 ? 1 : 0;
  15393. }
  15394. return count;
  15395. }
  15396. function translateFragment(element) {
  15397. element = element || document.documentElement;
  15398. var children = getTranslatableChildren(element);
  15399. var elementCount = children.length;
  15400. for (var i = 0; i < elementCount; i++) {
  15401. translateElement(children[i]);
  15402. }
  15403. translateElement(element);
  15404. }
  15405. return {
  15406. get: function get(key, args, fallbackString) {
  15407. var index = key.lastIndexOf('.');
  15408. var prop = gTextProp;
  15409. if (index > 0) {
  15410. prop = key.substring(index + 1);
  15411. key = key.substring(0, index);
  15412. }
  15413. var fallback;
  15414. if (fallbackString) {
  15415. fallback = {};
  15416. fallback[prop] = fallbackString;
  15417. }
  15418. var data = getL10nData(key, args, fallback);
  15419. if (data && prop in data) {
  15420. return data[prop];
  15421. }
  15422. return '{{' + key + '}}';
  15423. },
  15424. getData: function getData() {
  15425. return gL10nData;
  15426. },
  15427. getText: function getText() {
  15428. return gTextData;
  15429. },
  15430. getLanguage: function getLanguage() {
  15431. return gLanguage;
  15432. },
  15433. setLanguage: function setLanguage(lang, callback) {
  15434. loadLocale(lang, function () {
  15435. if (callback) callback();
  15436. });
  15437. },
  15438. getDirection: function getDirection() {
  15439. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  15440. var shortCode = gLanguage.split('-', 1)[0];
  15441. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  15442. },
  15443. translate: translateFragment,
  15444. getReadyState: function getReadyState() {
  15445. return gReadyState;
  15446. },
  15447. ready: function ready(callback) {
  15448. if (!callback) {
  15449. return;
  15450. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  15451. window.setTimeout(function () {
  15452. callback();
  15453. });
  15454. } else if (document.addEventListener) {
  15455. document.addEventListener('localized', function once() {
  15456. document.removeEventListener('localized', once);
  15457. callback();
  15458. });
  15459. }
  15460. }
  15461. };
  15462. }(window, document);
  15463. /***/ }),
  15464. /* 45 */
  15465. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15466. Object.defineProperty(exports, "__esModule", ({
  15467. value: true
  15468. }));
  15469. exports.docPropertiesLookup = docPropertiesLookup;
  15470. exports.GenericScripting = void 0;
  15471. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  15472. var _pdfjsLib = __webpack_require__(7);
  15473. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15474. 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; }
  15475. 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; }
  15476. 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; }
  15477. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15478. 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); } }
  15479. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15480. 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); } }
  15481. 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); }); }; }
  15482. function docPropertiesLookup(_x) {
  15483. return _docPropertiesLookup.apply(this, arguments);
  15484. }
  15485. function _docPropertiesLookup() {
  15486. _docPropertiesLookup = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(pdfDocument) {
  15487. var url, baseUrl, _yield$pdfDocument$ge, info, metadata, contentDispositionFilename, contentLength, _yield$pdfDocument$ge2, length;
  15488. return _regenerator["default"].wrap(function _callee4$(_context4) {
  15489. while (1) {
  15490. switch (_context4.prev = _context4.next) {
  15491. case 0:
  15492. url = "", baseUrl = url.split("#")[0];
  15493. _context4.next = 3;
  15494. return pdfDocument.getMetadata();
  15495. case 3:
  15496. _yield$pdfDocument$ge = _context4.sent;
  15497. info = _yield$pdfDocument$ge.info;
  15498. metadata = _yield$pdfDocument$ge.metadata;
  15499. contentDispositionFilename = _yield$pdfDocument$ge.contentDispositionFilename;
  15500. contentLength = _yield$pdfDocument$ge.contentLength;
  15501. if (contentLength) {
  15502. _context4.next = 14;
  15503. break;
  15504. }
  15505. _context4.next = 11;
  15506. return pdfDocument.getDownloadInfo();
  15507. case 11:
  15508. _yield$pdfDocument$ge2 = _context4.sent;
  15509. length = _yield$pdfDocument$ge2.length;
  15510. contentLength = length;
  15511. case 14:
  15512. return _context4.abrupt("return", _objectSpread(_objectSpread({}, info), {}, {
  15513. baseURL: baseUrl,
  15514. filesize: contentLength,
  15515. filename: contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(url),
  15516. metadata: metadata === null || metadata === void 0 ? void 0 : metadata.getRaw(),
  15517. authors: metadata === null || metadata === void 0 ? void 0 : metadata.get("dc:creator"),
  15518. numPages: pdfDocument.numPages,
  15519. URL: url
  15520. }));
  15521. case 15:
  15522. case "end":
  15523. return _context4.stop();
  15524. }
  15525. }
  15526. }, _callee4);
  15527. }));
  15528. return _docPropertiesLookup.apply(this, arguments);
  15529. }
  15530. var GenericScripting = /*#__PURE__*/function () {
  15531. function GenericScripting(sandboxBundleSrc) {
  15532. _classCallCheck(this, GenericScripting);
  15533. this._ready = (0, _pdfjsLib.loadScript)(sandboxBundleSrc, true).then(function () {
  15534. return window.pdfjsSandbox.QuickJSSandbox();
  15535. });
  15536. }
  15537. _createClass(GenericScripting, [{
  15538. key: "createSandbox",
  15539. value: function () {
  15540. var _createSandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(data) {
  15541. var sandbox;
  15542. return _regenerator["default"].wrap(function _callee$(_context) {
  15543. while (1) {
  15544. switch (_context.prev = _context.next) {
  15545. case 0:
  15546. _context.next = 2;
  15547. return this._ready;
  15548. case 2:
  15549. sandbox = _context.sent;
  15550. sandbox.create(data);
  15551. case 4:
  15552. case "end":
  15553. return _context.stop();
  15554. }
  15555. }
  15556. }, _callee, this);
  15557. }));
  15558. function createSandbox(_x2) {
  15559. return _createSandbox.apply(this, arguments);
  15560. }
  15561. return createSandbox;
  15562. }()
  15563. }, {
  15564. key: "dispatchEventInSandbox",
  15565. value: function () {
  15566. var _dispatchEventInSandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(event) {
  15567. var sandbox;
  15568. return _regenerator["default"].wrap(function _callee2$(_context2) {
  15569. while (1) {
  15570. switch (_context2.prev = _context2.next) {
  15571. case 0:
  15572. _context2.next = 2;
  15573. return this._ready;
  15574. case 2:
  15575. sandbox = _context2.sent;
  15576. sandbox.dispatchEvent(event);
  15577. case 4:
  15578. case "end":
  15579. return _context2.stop();
  15580. }
  15581. }
  15582. }, _callee2, this);
  15583. }));
  15584. function dispatchEventInSandbox(_x3) {
  15585. return _dispatchEventInSandbox.apply(this, arguments);
  15586. }
  15587. return dispatchEventInSandbox;
  15588. }()
  15589. }, {
  15590. key: "destroySandbox",
  15591. value: function () {
  15592. var _destroySandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  15593. var sandbox;
  15594. return _regenerator["default"].wrap(function _callee3$(_context3) {
  15595. while (1) {
  15596. switch (_context3.prev = _context3.next) {
  15597. case 0:
  15598. _context3.next = 2;
  15599. return this._ready;
  15600. case 2:
  15601. sandbox = _context3.sent;
  15602. sandbox.nukeSandbox();
  15603. case 4:
  15604. case "end":
  15605. return _context3.stop();
  15606. }
  15607. }
  15608. }, _callee3, this);
  15609. }));
  15610. function destroySandbox() {
  15611. return _destroySandbox.apply(this, arguments);
  15612. }
  15613. return destroySandbox;
  15614. }()
  15615. }]);
  15616. return GenericScripting;
  15617. }();
  15618. exports.GenericScripting = GenericScripting;
  15619. /***/ }),
  15620. /* 46 */
  15621. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15622. Object.defineProperty(exports, "__esModule", ({
  15623. value: true
  15624. }));
  15625. exports.PDFPrintService = PDFPrintService;
  15626. var _app = __webpack_require__(3);
  15627. var _viewer_compatibility = __webpack_require__(2);
  15628. var activeService = null;
  15629. var overlayManager = null;
  15630. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise) {
  15631. var scratchCanvas = activeService.scratchCanvas;
  15632. var PRINT_UNITS = printResolution / 72.0;
  15633. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  15634. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  15635. var ctx = scratchCanvas.getContext("2d");
  15636. ctx.save();
  15637. ctx.fillStyle = "rgb(255, 255, 255)";
  15638. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  15639. ctx.restore();
  15640. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  15641. var renderContext = {
  15642. canvasContext: ctx,
  15643. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  15644. viewport: pdfPage.getViewport({
  15645. scale: 1,
  15646. rotation: size.rotation
  15647. }),
  15648. intent: "print",
  15649. annotationStorage: pdfDocument.annotationStorage,
  15650. optionalContentConfigPromise: optionalContentConfigPromise
  15651. };
  15652. return pdfPage.render(renderContext).promise;
  15653. });
  15654. }
  15655. function PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution) {
  15656. var optionalContentConfigPromise = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  15657. var l10n = arguments.length > 5 ? arguments[5] : undefined;
  15658. this.pdfDocument = pdfDocument;
  15659. this.pagesOverview = pagesOverview;
  15660. this.printContainer = printContainer;
  15661. this._printResolution = printResolution || 150;
  15662. this._optionalContentConfigPromise = optionalContentConfigPromise || pdfDocument.getOptionalContentConfig();
  15663. this.l10n = l10n;
  15664. this.currentPage = -1;
  15665. this.scratchCanvas = document.createElement("canvas");
  15666. }
  15667. PDFPrintService.prototype = {
  15668. layout: function layout() {
  15669. this.throwIfInactive();
  15670. var body = document.querySelector("body");
  15671. body.setAttribute("data-pdfjsprinting", true);
  15672. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  15673. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  15674. }, this);
  15675. if (!hasEqualPageSizes) {
  15676. console.warn("Not all pages have the same size. The printed " + "result may be incorrect!");
  15677. }
  15678. this.pageStyleSheet = document.createElement("style");
  15679. var pageSize = this.pagesOverview[0];
  15680. this.pageStyleSheet.textContent = "@page { size: " + pageSize.width + "pt " + pageSize.height + "pt;}";
  15681. body.appendChild(this.pageStyleSheet);
  15682. },
  15683. destroy: function destroy() {
  15684. if (activeService !== this) {
  15685. return;
  15686. }
  15687. this.printContainer.textContent = "";
  15688. var body = document.querySelector("body");
  15689. body.removeAttribute("data-pdfjsprinting");
  15690. if (this.pageStyleSheet) {
  15691. this.pageStyleSheet.remove();
  15692. this.pageStyleSheet = null;
  15693. }
  15694. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  15695. this.scratchCanvas = null;
  15696. activeService = null;
  15697. ensureOverlay().then(function () {
  15698. if (overlayManager.active !== "printServiceOverlay") {
  15699. return;
  15700. }
  15701. overlayManager.close("printServiceOverlay");
  15702. });
  15703. },
  15704. renderPages: function renderPages() {
  15705. var _this = this;
  15706. var pageCount = this.pagesOverview.length;
  15707. var renderNextPage = function renderNextPage(resolve, reject) {
  15708. _this.throwIfInactive();
  15709. if (++_this.currentPage >= pageCount) {
  15710. renderProgress(pageCount, pageCount, _this.l10n);
  15711. resolve();
  15712. return;
  15713. }
  15714. var index = _this.currentPage;
  15715. renderProgress(index, pageCount, _this.l10n);
  15716. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index], _this._printResolution, _this._optionalContentConfigPromise).then(_this.useRenderedPage.bind(_this)).then(function () {
  15717. renderNextPage(resolve, reject);
  15718. }, reject);
  15719. };
  15720. return new Promise(renderNextPage);
  15721. },
  15722. useRenderedPage: function useRenderedPage() {
  15723. this.throwIfInactive();
  15724. var img = document.createElement("img");
  15725. var scratchCanvas = this.scratchCanvas;
  15726. if ("toBlob" in scratchCanvas && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  15727. scratchCanvas.toBlob(function (blob) {
  15728. img.src = URL.createObjectURL(blob);
  15729. });
  15730. } else {
  15731. img.src = scratchCanvas.toDataURL();
  15732. }
  15733. var wrapper = document.createElement("div");
  15734. wrapper.appendChild(img);
  15735. this.printContainer.appendChild(wrapper);
  15736. return new Promise(function (resolve, reject) {
  15737. img.onload = resolve;
  15738. img.onerror = reject;
  15739. });
  15740. },
  15741. performPrint: function performPrint() {
  15742. var _this2 = this;
  15743. this.throwIfInactive();
  15744. return new Promise(function (resolve) {
  15745. setTimeout(function () {
  15746. if (!_this2.active) {
  15747. resolve();
  15748. return;
  15749. }
  15750. print.call(window);
  15751. setTimeout(resolve, 20);
  15752. }, 0);
  15753. });
  15754. },
  15755. get active() {
  15756. return this === activeService;
  15757. },
  15758. throwIfInactive: function throwIfInactive() {
  15759. if (!this.active) {
  15760. throw new Error("This print request was cancelled or completed.");
  15761. }
  15762. }
  15763. };
  15764. var print = window.print;
  15765. window.print = function () {
  15766. if (activeService) {
  15767. console.warn("Ignored window.print() because of a pending print job.");
  15768. return;
  15769. }
  15770. ensureOverlay().then(function () {
  15771. if (activeService) {
  15772. overlayManager.open("printServiceOverlay");
  15773. }
  15774. });
  15775. try {
  15776. dispatchEvent("beforeprint");
  15777. } finally {
  15778. if (!activeService) {
  15779. console.error("Expected print service to be initialized.");
  15780. ensureOverlay().then(function () {
  15781. if (overlayManager.active === "printServiceOverlay") {
  15782. overlayManager.close("printServiceOverlay");
  15783. }
  15784. });
  15785. return;
  15786. }
  15787. var activeServiceOnEntry = activeService;
  15788. activeService.renderPages().then(function () {
  15789. return activeServiceOnEntry.performPrint();
  15790. })["catch"](function () {}).then(function () {
  15791. if (activeServiceOnEntry.active) {
  15792. abort();
  15793. }
  15794. });
  15795. }
  15796. };
  15797. function dispatchEvent(eventType) {
  15798. var event = document.createEvent("CustomEvent");
  15799. event.initCustomEvent(eventType, false, false, "custom");
  15800. window.dispatchEvent(event);
  15801. }
  15802. function abort() {
  15803. if (activeService) {
  15804. activeService.destroy();
  15805. dispatchEvent("afterprint");
  15806. }
  15807. }
  15808. function renderProgress(index, total, l10n) {
  15809. var progressContainer = document.getElementById("printServiceOverlay");
  15810. var progress = Math.round(100 * index / total);
  15811. var progressBar = progressContainer.querySelector("progress");
  15812. var progressPerc = progressContainer.querySelector(".relative-progress");
  15813. progressBar.value = progress;
  15814. l10n.get("print_progress_percent", {
  15815. progress: progress
  15816. }).then(function (msg) {
  15817. progressPerc.textContent = msg;
  15818. });
  15819. }
  15820. window.addEventListener("keydown", function (event) {
  15821. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  15822. window.print();
  15823. event.preventDefault();
  15824. if (event.stopImmediatePropagation) {
  15825. event.stopImmediatePropagation();
  15826. } else {
  15827. event.stopPropagation();
  15828. }
  15829. }
  15830. }, true);
  15831. if ("onbeforeprint" in window) {
  15832. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  15833. if (event.detail !== "custom" && event.stopImmediatePropagation) {
  15834. event.stopImmediatePropagation();
  15835. }
  15836. };
  15837. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  15838. window.addEventListener("afterprint", stopPropagationIfNeeded);
  15839. }
  15840. var overlayPromise;
  15841. function ensureOverlay() {
  15842. if (!overlayPromise) {
  15843. overlayManager = _app.PDFViewerApplication.overlayManager;
  15844. if (!overlayManager) {
  15845. throw new Error("The overlay manager has not yet been initialized.");
  15846. }
  15847. overlayPromise = overlayManager.register("printServiceOverlay", document.getElementById("printServiceOverlay"), abort, true);
  15848. document.getElementById("printCancel").onclick = abort;
  15849. }
  15850. return overlayPromise;
  15851. }
  15852. _app.PDFPrintServiceFactory.instance = {
  15853. supportsPrinting: true,
  15854. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, l10n) {
  15855. if (activeService) {
  15856. throw new Error("The print service is created and active.");
  15857. }
  15858. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, l10n);
  15859. return activeService;
  15860. }
  15861. };
  15862. /***/ })
  15863. /******/ ]);
  15864. /************************************************************************/
  15865. /******/ // The module cache
  15866. /******/ var __webpack_module_cache__ = {};
  15867. /******/
  15868. /******/ // The require function
  15869. /******/ function __webpack_require__(moduleId) {
  15870. /******/ // Check if module is in cache
  15871. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  15872. /******/ if (cachedModule !== undefined) {
  15873. /******/ return cachedModule.exports;
  15874. /******/ }
  15875. /******/ // Create a new module (and put it into the cache)
  15876. /******/ var module = __webpack_module_cache__[moduleId] = {
  15877. /******/ id: moduleId,
  15878. /******/ loaded: false,
  15879. /******/ exports: {}
  15880. /******/ };
  15881. /******/
  15882. /******/ // Execute the module function
  15883. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  15884. /******/
  15885. /******/ // Flag the module as loaded
  15886. /******/ module.loaded = true;
  15887. /******/
  15888. /******/ // Return the exports of the module
  15889. /******/ return module.exports;
  15890. /******/ }
  15891. /******/
  15892. /************************************************************************/
  15893. /******/ /* webpack/runtime/node module decorator */
  15894. /******/ (() => {
  15895. /******/ __webpack_require__.nmd = (module) => {
  15896. /******/ module.paths = [];
  15897. /******/ if (!module.children) module.children = [];
  15898. /******/ return module;
  15899. /******/ };
  15900. /******/ })();
  15901. /******/
  15902. /************************************************************************/
  15903. var __webpack_exports__ = {};
  15904. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  15905. (() => {
  15906. var exports = __webpack_exports__;
  15907. Object.defineProperty(exports, "__esModule", ({
  15908. value: true
  15909. }));
  15910. Object.defineProperty(exports, "PDFViewerApplicationOptions", ({
  15911. enumerable: true,
  15912. get: function get() {
  15913. return _app_options.AppOptions;
  15914. }
  15915. }));
  15916. Object.defineProperty(exports, "PDFViewerApplication", ({
  15917. enumerable: true,
  15918. get: function get() {
  15919. return _app.PDFViewerApplication;
  15920. }
  15921. }));
  15922. var _app_options = __webpack_require__(1);
  15923. var _app = __webpack_require__(3);
  15924. var pdfjsVersion = '2.8.335';
  15925. var pdfjsBuild = '228adbf67';
  15926. window.PDFViewerApplication = _app.PDFViewerApplication;
  15927. window.PDFViewerApplicationOptions = _app_options.AppOptions;
  15928. ;
  15929. ;
  15930. {
  15931. __webpack_require__(40);
  15932. }
  15933. ;
  15934. {
  15935. __webpack_require__(46);
  15936. }
  15937. function getViewerConfiguration() {
  15938. var errorWrapper = null;
  15939. errorWrapper = {
  15940. container: document.getElementById("errorWrapper"),
  15941. errorMessage: document.getElementById("errorMessage"),
  15942. closeButton: document.getElementById("errorClose"),
  15943. errorMoreInfo: document.getElementById("errorMoreInfo"),
  15944. moreInfoButton: document.getElementById("errorShowMore"),
  15945. lessInfoButton: document.getElementById("errorShowLess")
  15946. };
  15947. return {
  15948. appContainer: document.body,
  15949. mainContainer: document.getElementById("viewerContainer"),
  15950. viewerContainer: document.getElementById("viewer"),
  15951. eventBus: null,
  15952. toolbar: {
  15953. container: document.getElementById("toolbarViewer"),
  15954. numPages: document.getElementById("numPages"),
  15955. pageNumber: document.getElementById("pageNumber"),
  15956. scaleSelectContainer: document.getElementById("scaleSelectContainer"),
  15957. scaleSelect: document.getElementById("scaleSelect"),
  15958. customScaleOption: document.getElementById("customScaleOption"),
  15959. previous: document.getElementById("previous"),
  15960. next: document.getElementById("next"),
  15961. zoomIn: document.getElementById("zoomIn"),
  15962. zoomOut: document.getElementById("zoomOut"),
  15963. viewFind: document.getElementById("viewFind"),
  15964. openFile: document.getElementById("openFile"),
  15965. print: document.getElementById("print"),
  15966. presentationModeButton: document.getElementById("presentationMode"),
  15967. download: document.getElementById("download"),
  15968. viewBookmark: document.getElementById("viewBookmark")
  15969. },
  15970. secondaryToolbar: {
  15971. toolbar: document.getElementById("secondaryToolbar"),
  15972. toggleButton: document.getElementById("secondaryToolbarToggle"),
  15973. toolbarButtonContainer: document.getElementById("secondaryToolbarButtonContainer"),
  15974. presentationModeButton: document.getElementById("secondaryPresentationMode"),
  15975. openFileButton: document.getElementById("secondaryOpenFile"),
  15976. printButton: document.getElementById("secondaryPrint"),
  15977. downloadButton: document.getElementById("secondaryDownload"),
  15978. viewBookmarkButton: document.getElementById("secondaryViewBookmark"),
  15979. firstPageButton: document.getElementById("firstPage"),
  15980. lastPageButton: document.getElementById("lastPage"),
  15981. pageRotateCwButton: document.getElementById("pageRotateCw"),
  15982. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  15983. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  15984. cursorHandToolButton: document.getElementById("cursorHandTool"),
  15985. scrollVerticalButton: document.getElementById("scrollVertical"),
  15986. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  15987. scrollWrappedButton: document.getElementById("scrollWrapped"),
  15988. spreadNoneButton: document.getElementById("spreadNone"),
  15989. spreadOddButton: document.getElementById("spreadOdd"),
  15990. spreadEvenButton: document.getElementById("spreadEven"),
  15991. documentPropertiesButton: document.getElementById("documentProperties")
  15992. },
  15993. sidebar: {
  15994. outerContainer: document.getElementById("outerContainer"),
  15995. viewerContainer: document.getElementById("viewerContainer"),
  15996. toggleButton: document.getElementById("sidebarToggle"),
  15997. thumbnailButton: document.getElementById("viewThumbnail"),
  15998. outlineButton: document.getElementById("viewOutline"),
  15999. attachmentsButton: document.getElementById("viewAttachments"),
  16000. layersButton: document.getElementById("viewLayers"),
  16001. thumbnailView: document.getElementById("thumbnailView"),
  16002. outlineView: document.getElementById("outlineView"),
  16003. attachmentsView: document.getElementById("attachmentsView"),
  16004. layersView: document.getElementById("layersView"),
  16005. outlineOptionsContainer: document.getElementById("outlineOptionsContainer"),
  16006. currentOutlineItemButton: document.getElementById("currentOutlineItem")
  16007. },
  16008. sidebarResizer: {
  16009. outerContainer: document.getElementById("outerContainer"),
  16010. resizer: document.getElementById("sidebarResizer")
  16011. },
  16012. findBar: {
  16013. bar: document.getElementById("findbar"),
  16014. toggleButton: document.getElementById("viewFind"),
  16015. findField: document.getElementById("findInput"),
  16016. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  16017. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  16018. entireWordCheckbox: document.getElementById("findEntireWord"),
  16019. findMsg: document.getElementById("findMsg"),
  16020. findResultsCount: document.getElementById("findResultsCount"),
  16021. findPreviousButton: document.getElementById("findPrevious"),
  16022. findNextButton: document.getElementById("findNext")
  16023. },
  16024. passwordOverlay: {
  16025. overlayName: "passwordOverlay",
  16026. container: document.getElementById("passwordOverlay"),
  16027. label: document.getElementById("passwordText"),
  16028. input: document.getElementById("password"),
  16029. submitButton: document.getElementById("passwordSubmit"),
  16030. cancelButton: document.getElementById("passwordCancel")
  16031. },
  16032. documentProperties: {
  16033. overlayName: "documentPropertiesOverlay",
  16034. container: document.getElementById("documentPropertiesOverlay"),
  16035. closeButton: document.getElementById("documentPropertiesClose"),
  16036. fields: {
  16037. fileName: document.getElementById("fileNameField"),
  16038. fileSize: document.getElementById("fileSizeField"),
  16039. title: document.getElementById("titleField"),
  16040. author: document.getElementById("authorField"),
  16041. subject: document.getElementById("subjectField"),
  16042. keywords: document.getElementById("keywordsField"),
  16043. creationDate: document.getElementById("creationDateField"),
  16044. modificationDate: document.getElementById("modificationDateField"),
  16045. creator: document.getElementById("creatorField"),
  16046. producer: document.getElementById("producerField"),
  16047. version: document.getElementById("versionField"),
  16048. pageCount: document.getElementById("pageCountField"),
  16049. pageSize: document.getElementById("pageSizeField"),
  16050. linearized: document.getElementById("linearizedField")
  16051. }
  16052. },
  16053. errorWrapper: errorWrapper,
  16054. printContainer: document.getElementById("printContainer"),
  16055. openFileInputName: "fileInput",
  16056. debuggerScriptPath: "./debugger.js"
  16057. };
  16058. }
  16059. function webViewerLoad() {
  16060. var config = getViewerConfiguration();
  16061. var event = document.createEvent("CustomEvent");
  16062. event.initCustomEvent("webviewerloaded", true, true, {
  16063. source: window
  16064. });
  16065. try {
  16066. parent.document.dispatchEvent(event);
  16067. } catch (ex) {
  16068. console.error("webviewerloaded: ".concat(ex));
  16069. document.dispatchEvent(event);
  16070. }
  16071. _app.PDFViewerApplication.run(config);
  16072. }
  16073. if (document.blockUnblockOnload) {
  16074. document.blockUnblockOnload(true);
  16075. }
  16076. if (document.readyState === "interactive" || document.readyState === "complete") {
  16077. webViewerLoad();
  16078. } else {
  16079. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  16080. }
  16081. })();
  16082. /******/ })()
  16083. ;
  16084. //# sourceMappingURL=viewer.js.map