viewer.js 775 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * JavaScript code in this page
  4. *
  5. * Copyright 2022 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) => {
  28. Object.defineProperty(exports, "__esModule", ({
  29. value: true
  30. }));
  31. exports.compatibilityParams = exports.OptionKind = exports.AppOptions = void 0;
  32. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  33. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  34. 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); } }
  35. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  36. var compatibilityParams = Object.create(null);
  37. exports.compatibilityParams = compatibilityParams;
  38. {
  39. var userAgent = navigator.userAgent || "";
  40. var platform = navigator.platform || "";
  41. var maxTouchPoints = navigator.maxTouchPoints || 1;
  42. var isAndroid = /Android/.test(userAgent);
  43. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  44. (function checkCanvasSizeLimitation() {
  45. if (isIOS || isAndroid) {
  46. compatibilityParams.maxCanvasPixels = 5242880;
  47. }
  48. })();
  49. }
  50. var OptionKind = {
  51. VIEWER: 0x02,
  52. API: 0x04,
  53. WORKER: 0x08,
  54. PREFERENCE: 0x80
  55. };
  56. exports.OptionKind = OptionKind;
  57. var defaultOptions = {
  58. annotationMode: {
  59. value: 2,
  60. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  61. },
  62. cursorToolOnLoad: {
  63. value: 0,
  64. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  65. },
  66. defaultUrl: {
  67. value: "compressed.tracemonkey-pldi-09.pdf",
  68. kind: OptionKind.VIEWER
  69. },
  70. defaultZoomValue: {
  71. value: "",
  72. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  73. },
  74. disableHistory: {
  75. value: false,
  76. kind: OptionKind.VIEWER
  77. },
  78. disablePageLabels: {
  79. value: false,
  80. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  81. },
  82. enablePermissions: {
  83. value: false,
  84. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  85. },
  86. enablePrintAutoRotate: {
  87. value: true,
  88. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  89. },
  90. enableScripting: {
  91. value: true,
  92. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  93. },
  94. externalLinkRel: {
  95. value: "noopener noreferrer nofollow",
  96. kind: OptionKind.VIEWER
  97. },
  98. externalLinkTarget: {
  99. value: 0,
  100. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  101. },
  102. historyUpdateUrl: {
  103. value: false,
  104. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  105. },
  106. ignoreDestinationZoom: {
  107. value: false,
  108. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  109. },
  110. imageResourcesPath: {
  111. value: "./images/",
  112. kind: OptionKind.VIEWER
  113. },
  114. maxCanvasPixels: {
  115. value: 16777216,
  116. compatibility: compatibilityParams.maxCanvasPixels,
  117. kind: OptionKind.VIEWER
  118. },
  119. pageColorsBackground: {
  120. value: "Canvas",
  121. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  122. },
  123. pageColorsForeground: {
  124. value: "CanvasText",
  125. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  126. },
  127. pdfBugEnabled: {
  128. value: false,
  129. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  130. },
  131. printResolution: {
  132. value: 150,
  133. kind: OptionKind.VIEWER
  134. },
  135. renderer: {
  136. value: "canvas",
  137. kind: OptionKind.VIEWER
  138. },
  139. sidebarViewOnLoad: {
  140. value: -1,
  141. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  142. },
  143. scrollModeOnLoad: {
  144. value: -1,
  145. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  146. },
  147. spreadModeOnLoad: {
  148. value: -1,
  149. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  150. },
  151. textLayerMode: {
  152. value: 1,
  153. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  154. },
  155. useOnlyCssZoom: {
  156. value: false,
  157. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  158. },
  159. viewerCssTheme: {
  160. value: 0,
  161. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  162. },
  163. viewOnLoad: {
  164. value: 0,
  165. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  166. },
  167. cMapPacked: {
  168. value: true,
  169. kind: OptionKind.API
  170. },
  171. cMapUrl: {
  172. value: "../web/cmaps/",
  173. kind: OptionKind.API
  174. },
  175. disableAutoFetch: {
  176. value: false,
  177. kind: OptionKind.API + OptionKind.PREFERENCE
  178. },
  179. disableFontFace: {
  180. value: false,
  181. kind: OptionKind.API + OptionKind.PREFERENCE
  182. },
  183. disableRange: {
  184. value: false,
  185. kind: OptionKind.API + OptionKind.PREFERENCE
  186. },
  187. disableStream: {
  188. value: false,
  189. kind: OptionKind.API + OptionKind.PREFERENCE
  190. },
  191. docBaseUrl: {
  192. value: "",
  193. kind: OptionKind.API
  194. },
  195. enableXfa: {
  196. value: true,
  197. kind: OptionKind.API + OptionKind.PREFERENCE
  198. },
  199. fontExtraProperties: {
  200. value: false,
  201. kind: OptionKind.API
  202. },
  203. isEvalSupported: {
  204. value: true,
  205. kind: OptionKind.API
  206. },
  207. maxImageSize: {
  208. value: -1,
  209. kind: OptionKind.API
  210. },
  211. pdfBug: {
  212. value: false,
  213. kind: OptionKind.API
  214. },
  215. standardFontDataUrl: {
  216. value: "../web/standard_fonts/",
  217. kind: OptionKind.API
  218. },
  219. verbosity: {
  220. value: 1,
  221. kind: OptionKind.API
  222. },
  223. workerPort: {
  224. value: null,
  225. kind: OptionKind.WORKER
  226. },
  227. workerSrc: {
  228. value: "../build/pdf.worker.js",
  229. kind: OptionKind.WORKER
  230. }
  231. };
  232. {
  233. defaultOptions.disablePreferences = {
  234. value: false,
  235. kind: OptionKind.VIEWER
  236. };
  237. defaultOptions.locale = {
  238. value: navigator.language || "en-US",
  239. kind: OptionKind.VIEWER
  240. };
  241. defaultOptions.sandboxBundleSrc = {
  242. value: "../build/pdf.sandbox.js",
  243. kind: OptionKind.VIEWER
  244. };
  245. defaultOptions.renderer.kind += OptionKind.PREFERENCE;
  246. }
  247. var userOptions = Object.create(null);
  248. var AppOptions = /*#__PURE__*/function () {
  249. function AppOptions() {
  250. _classCallCheck(this, AppOptions);
  251. throw new Error("Cannot initialize AppOptions.");
  252. }
  253. _createClass(AppOptions, null, [{
  254. key: "get",
  255. value: function get(name) {
  256. var userOption = userOptions[name];
  257. if (userOption !== undefined) {
  258. return userOption;
  259. }
  260. var defaultOption = defaultOptions[name];
  261. if (defaultOption !== undefined) {
  262. var _defaultOption$compat;
  263. return (_defaultOption$compat = defaultOption.compatibility) !== null && _defaultOption$compat !== void 0 ? _defaultOption$compat : defaultOption.value;
  264. }
  265. return undefined;
  266. }
  267. }, {
  268. key: "getAll",
  269. value: function getAll() {
  270. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  271. var options = Object.create(null);
  272. for (var name in defaultOptions) {
  273. var _defaultOption$compat2;
  274. var defaultOption = defaultOptions[name];
  275. if (kind) {
  276. if ((kind & defaultOption.kind) === 0) {
  277. continue;
  278. }
  279. if (kind === OptionKind.PREFERENCE) {
  280. var value = defaultOption.value,
  281. valueType = _typeof(value);
  282. if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
  283. options[name] = value;
  284. continue;
  285. }
  286. throw new Error("Invalid type for preference: ".concat(name));
  287. }
  288. }
  289. var userOption = userOptions[name];
  290. options[name] = userOption !== undefined ? userOption : (_defaultOption$compat2 = defaultOption.compatibility) !== null && _defaultOption$compat2 !== void 0 ? _defaultOption$compat2 : defaultOption.value;
  291. }
  292. return options;
  293. }
  294. }, {
  295. key: "set",
  296. value: function set(name, value) {
  297. userOptions[name] = value;
  298. }
  299. }, {
  300. key: "setAll",
  301. value: function setAll(options) {
  302. for (var name in options) {
  303. userOptions[name] = options[name];
  304. }
  305. }
  306. }, {
  307. key: "remove",
  308. value: function remove(name) {
  309. delete userOptions[name];
  310. }
  311. }, {
  312. key: "_hasUserOptions",
  313. value: function _hasUserOptions() {
  314. return Object.keys(userOptions).length > 0;
  315. }
  316. }]);
  317. return AppOptions;
  318. }();
  319. exports.AppOptions = AppOptions;
  320. /***/ }),
  321. /* 2 */
  322. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  323. Object.defineProperty(exports, "__esModule", ({
  324. value: true
  325. }));
  326. exports.PDFViewerApplication = exports.PDFPrintServiceFactory = exports.DefaultExternalServices = void 0;
  327. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  328. var _ui_utils = __webpack_require__(5);
  329. var _app_options = __webpack_require__(1);
  330. var _event_utils = __webpack_require__(6);
  331. var _pdfjsLib = __webpack_require__(7);
  332. var _pdf_cursor_tools = __webpack_require__(8);
  333. var _pdf_link_service = __webpack_require__(10);
  334. var _overlay_manager = __webpack_require__(11);
  335. var _password_prompt = __webpack_require__(13);
  336. var _pdf_attachment_viewer = __webpack_require__(14);
  337. var _pdf_document_properties = __webpack_require__(16);
  338. var _pdf_find_bar = __webpack_require__(17);
  339. var _pdf_find_controller = __webpack_require__(18);
  340. var _pdf_history = __webpack_require__(20);
  341. var _pdf_layer_viewer = __webpack_require__(21);
  342. var _pdf_outline_viewer = __webpack_require__(22);
  343. var _pdf_presentation_mode = __webpack_require__(23);
  344. var _pdf_rendering_queue = __webpack_require__(24);
  345. var _pdf_scripting_manager = __webpack_require__(25);
  346. var _pdf_sidebar = __webpack_require__(26);
  347. var _pdf_sidebar_resizer = __webpack_require__(27);
  348. var _pdf_thumbnail_viewer = __webpack_require__(28);
  349. var _pdf_viewer = __webpack_require__(30);
  350. var _secondary_toolbar = __webpack_require__(39);
  351. var _toolbar = __webpack_require__(40);
  352. var _view_history = __webpack_require__(41);
  353. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  354. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  355. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  356. 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; }
  357. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  358. 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."); }
  359. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
  360. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  361. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
  362. 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); }
  363. 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; }
  364. 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); } }
  365. 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); }); }; }
  366. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  367. 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); } }
  368. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  369. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  370. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  371. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  372. var ViewOnLoad = {
  373. UNKNOWN: -1,
  374. PREVIOUS: 0,
  375. INITIAL: 1
  376. };
  377. var ViewerCssTheme = {
  378. AUTOMATIC: 0,
  379. LIGHT: 1,
  380. DARK: 2
  381. };
  382. 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"];
  383. 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"];
  384. var DefaultExternalServices = /*#__PURE__*/function () {
  385. function DefaultExternalServices() {
  386. _classCallCheck(this, DefaultExternalServices);
  387. throw new Error("Cannot initialize DefaultExternalServices.");
  388. }
  389. _createClass(DefaultExternalServices, null, [{
  390. key: "updateFindControlState",
  391. value: function updateFindControlState(data) {}
  392. }, {
  393. key: "updateFindMatchesCount",
  394. value: function updateFindMatchesCount(data) {}
  395. }, {
  396. key: "initPassiveLoading",
  397. value: function initPassiveLoading(callbacks) {}
  398. }, {
  399. key: "reportTelemetry",
  400. value: function reportTelemetry(data) {}
  401. }, {
  402. key: "createDownloadManager",
  403. value: function createDownloadManager(options) {
  404. throw new Error("Not implemented: createDownloadManager");
  405. }
  406. }, {
  407. key: "createPreferences",
  408. value: function createPreferences() {
  409. throw new Error("Not implemented: createPreferences");
  410. }
  411. }, {
  412. key: "createL10n",
  413. value: function createL10n(options) {
  414. throw new Error("Not implemented: createL10n");
  415. }
  416. }, {
  417. key: "createScripting",
  418. value: function createScripting(options) {
  419. throw new Error("Not implemented: createScripting");
  420. }
  421. }, {
  422. key: "supportsIntegratedFind",
  423. get: function get() {
  424. return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false);
  425. }
  426. }, {
  427. key: "supportsDocumentFonts",
  428. get: function get() {
  429. return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts", true);
  430. }
  431. }, {
  432. key: "supportedMouseWheelZoomModifierKeys",
  433. get: function get() {
  434. return (0, _pdfjsLib.shadow)(this, "supportedMouseWheelZoomModifierKeys", {
  435. ctrlKey: true,
  436. metaKey: true
  437. });
  438. }
  439. }, {
  440. key: "isInAutomation",
  441. get: function get() {
  442. return (0, _pdfjsLib.shadow)(this, "isInAutomation", false);
  443. }
  444. }]);
  445. return DefaultExternalServices;
  446. }();
  447. exports.DefaultExternalServices = DefaultExternalServices;
  448. var PDFViewerApplication = {
  449. initialBookmark: document.location.hash.substring(1),
  450. _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(),
  451. appConfig: null,
  452. pdfDocument: null,
  453. pdfLoadingTask: null,
  454. printService: null,
  455. pdfViewer: null,
  456. pdfThumbnailViewer: null,
  457. pdfRenderingQueue: null,
  458. pdfPresentationMode: null,
  459. pdfDocumentProperties: null,
  460. pdfLinkService: null,
  461. pdfHistory: null,
  462. pdfSidebar: null,
  463. pdfSidebarResizer: null,
  464. pdfOutlineViewer: null,
  465. pdfAttachmentViewer: null,
  466. pdfLayerViewer: null,
  467. pdfCursorTools: null,
  468. pdfScriptingManager: null,
  469. store: null,
  470. downloadManager: null,
  471. overlayManager: null,
  472. preferences: null,
  473. toolbar: null,
  474. secondaryToolbar: null,
  475. eventBus: null,
  476. l10n: null,
  477. isInitialViewSet: false,
  478. downloadComplete: false,
  479. isViewerEmbedded: window.parent !== window,
  480. url: "",
  481. baseUrl: "",
  482. _downloadUrl: "",
  483. externalServices: DefaultExternalServices,
  484. _boundEvents: Object.create(null),
  485. documentInfo: null,
  486. metadata: null,
  487. _contentDispositionFilename: null,
  488. _contentLength: null,
  489. _saveInProgress: false,
  490. _docStats: null,
  491. _wheelUnusedTicks: 0,
  492. _idleCallbacks: new Set(),
  493. _PDFBug: null,
  494. initialize: function initialize(appConfig) {
  495. var _this = this;
  496. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  497. var appContainer;
  498. return _regenerator["default"].wrap(function _callee$(_context) {
  499. while (1) {
  500. switch (_context.prev = _context.next) {
  501. case 0:
  502. _this.preferences = _this.externalServices.createPreferences();
  503. _this.appConfig = appConfig;
  504. _context.next = 4;
  505. return _this._readPreferences();
  506. case 4:
  507. _context.next = 6;
  508. return _this._parseHashParameters();
  509. case 6:
  510. _this._forceCssTheme();
  511. _context.next = 9;
  512. return _this._initializeL10n();
  513. case 9:
  514. if (_this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdf_link_service.LinkTarget.NONE) {
  515. _app_options.AppOptions.set("externalLinkTarget", _pdf_link_service.LinkTarget.TOP);
  516. }
  517. _context.next = 12;
  518. return _this._initializeViewerComponents();
  519. case 12:
  520. _this.bindEvents();
  521. _this.bindWindowEvents();
  522. appContainer = appConfig.appContainer || document.documentElement;
  523. _this.l10n.translate(appContainer).then(function () {
  524. _this.eventBus.dispatch("localized", {
  525. source: _this
  526. });
  527. });
  528. _this._initializedCapability.resolve();
  529. case 17:
  530. case "end":
  531. return _context.stop();
  532. }
  533. }
  534. }, _callee);
  535. }))();
  536. },
  537. _readPreferences: function _readPreferences() {
  538. var _this2 = this;
  539. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  540. return _regenerator["default"].wrap(function _callee2$(_context2) {
  541. while (1) {
  542. switch (_context2.prev = _context2.next) {
  543. case 0:
  544. if (!_app_options.AppOptions.get("disablePreferences")) {
  545. _context2.next = 2;
  546. break;
  547. }
  548. return _context2.abrupt("return");
  549. case 2:
  550. if (_app_options.AppOptions._hasUserOptions()) {
  551. console.warn("_readPreferences: The Preferences may override manually set AppOptions; " + 'please use the "disablePreferences"-option in order to prevent that.');
  552. }
  553. _context2.prev = 3;
  554. _context2.t0 = _app_options.AppOptions;
  555. _context2.next = 7;
  556. return _this2.preferences.getAll();
  557. case 7:
  558. _context2.t1 = _context2.sent;
  559. _context2.t0.setAll.call(_context2.t0, _context2.t1);
  560. _context2.next = 14;
  561. break;
  562. case 11:
  563. _context2.prev = 11;
  564. _context2.t2 = _context2["catch"](3);
  565. console.error("_readPreferences: \"".concat(_context2.t2 === null || _context2.t2 === void 0 ? void 0 : _context2.t2.message, "\"."));
  566. case 14:
  567. case "end":
  568. return _context2.stop();
  569. }
  570. }
  571. }, _callee2, null, [[3, 11]]);
  572. }))();
  573. },
  574. _parseHashParameters: function _parseHashParameters() {
  575. var _this3 = this;
  576. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  577. var hash, _this3$appConfig, mainContainer, viewerContainer, params, enabled;
  578. return _regenerator["default"].wrap(function _callee3$(_context3) {
  579. while (1) {
  580. switch (_context3.prev = _context3.next) {
  581. case 0:
  582. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  583. _context3.next = 2;
  584. break;
  585. }
  586. return _context3.abrupt("return");
  587. case 2:
  588. hash = document.location.hash.substring(1);
  589. if (hash) {
  590. _context3.next = 5;
  591. break;
  592. }
  593. return _context3.abrupt("return");
  594. case 5:
  595. _this3$appConfig = _this3.appConfig, mainContainer = _this3$appConfig.mainContainer, viewerContainer = _this3$appConfig.viewerContainer, params = (0, _ui_utils.parseQueryString)(hash);
  596. if (!(params.get("disableworker") === "true")) {
  597. _context3.next = 15;
  598. break;
  599. }
  600. _context3.prev = 7;
  601. _context3.next = 10;
  602. return loadFakeWorker();
  603. case 10:
  604. _context3.next = 15;
  605. break;
  606. case 12:
  607. _context3.prev = 12;
  608. _context3.t0 = _context3["catch"](7);
  609. console.error("_parseHashParameters: \"".concat(_context3.t0.message, "\"."));
  610. case 15:
  611. if (params.has("disablerange")) {
  612. _app_options.AppOptions.set("disableRange", params.get("disablerange") === "true");
  613. }
  614. if (params.has("disablestream")) {
  615. _app_options.AppOptions.set("disableStream", params.get("disablestream") === "true");
  616. }
  617. if (params.has("disableautofetch")) {
  618. _app_options.AppOptions.set("disableAutoFetch", params.get("disableautofetch") === "true");
  619. }
  620. if (params.has("disablefontface")) {
  621. _app_options.AppOptions.set("disableFontFace", params.get("disablefontface") === "true");
  622. }
  623. if (params.has("disablehistory")) {
  624. _app_options.AppOptions.set("disableHistory", params.get("disablehistory") === "true");
  625. }
  626. if (params.has("verbosity")) {
  627. _app_options.AppOptions.set("verbosity", params.get("verbosity") | 0);
  628. }
  629. if (!params.has("textlayer")) {
  630. _context3.next = 38;
  631. break;
  632. }
  633. _context3.t1 = params.get("textlayer");
  634. _context3.next = _context3.t1 === "off" ? 25 : _context3.t1 === "visible" ? 27 : _context3.t1 === "shadow" ? 27 : _context3.t1 === "hover" ? 27 : 38;
  635. break;
  636. case 25:
  637. _app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
  638. return _context3.abrupt("break", 38);
  639. case 27:
  640. viewerContainer.classList.add("textLayer-".concat(params.get("textlayer")));
  641. _context3.prev = 28;
  642. _context3.next = 31;
  643. return loadPDFBug(_this3);
  644. case 31:
  645. _this3._PDFBug.loadCSS();
  646. _context3.next = 37;
  647. break;
  648. case 34:
  649. _context3.prev = 34;
  650. _context3.t2 = _context3["catch"](28);
  651. console.error("_parseHashParameters: \"".concat(_context3.t2.message, "\"."));
  652. case 37:
  653. return _context3.abrupt("break", 38);
  654. case 38:
  655. if (!params.has("pdfbug")) {
  656. _context3.next = 51;
  657. break;
  658. }
  659. _app_options.AppOptions.set("pdfBug", true);
  660. _app_options.AppOptions.set("fontExtraProperties", true);
  661. enabled = params.get("pdfbug").split(",");
  662. _context3.prev = 42;
  663. _context3.next = 45;
  664. return loadPDFBug(_this3);
  665. case 45:
  666. _this3._PDFBug.init({
  667. OPS: _pdfjsLib.OPS
  668. }, mainContainer, enabled);
  669. _context3.next = 51;
  670. break;
  671. case 48:
  672. _context3.prev = 48;
  673. _context3.t3 = _context3["catch"](42);
  674. console.error("_parseHashParameters: \"".concat(_context3.t3.message, "\"."));
  675. case 51:
  676. if (params.has("locale")) {
  677. _app_options.AppOptions.set("locale", params.get("locale"));
  678. }
  679. case 52:
  680. case "end":
  681. return _context3.stop();
  682. }
  683. }
  684. }, _callee3, null, [[7, 12], [28, 34], [42, 48]]);
  685. }))();
  686. },
  687. _initializeL10n: function _initializeL10n() {
  688. var _this4 = this;
  689. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  690. var dir;
  691. return _regenerator["default"].wrap(function _callee4$(_context4) {
  692. while (1) {
  693. switch (_context4.prev = _context4.next) {
  694. case 0:
  695. _this4.l10n = _this4.externalServices.createL10n({
  696. locale: _app_options.AppOptions.get("locale")
  697. });
  698. _context4.next = 3;
  699. return _this4.l10n.getDirection();
  700. case 3:
  701. dir = _context4.sent;
  702. document.getElementsByTagName("html")[0].dir = dir;
  703. case 5:
  704. case "end":
  705. return _context4.stop();
  706. }
  707. }
  708. }, _callee4);
  709. }))();
  710. },
  711. _forceCssTheme: function _forceCssTheme() {
  712. var cssTheme = _app_options.AppOptions.get("viewerCssTheme");
  713. if (cssTheme === ViewerCssTheme.AUTOMATIC || !Object.values(ViewerCssTheme).includes(cssTheme)) {
  714. return;
  715. }
  716. try {
  717. var styleSheet = document.styleSheets[0];
  718. var cssRules = (styleSheet === null || styleSheet === void 0 ? void 0 : styleSheet.cssRules) || [];
  719. for (var i = 0, ii = cssRules.length; i < ii; i++) {
  720. var _rule$media;
  721. var rule = cssRules[i];
  722. if (rule instanceof CSSMediaRule && ((_rule$media = rule.media) === null || _rule$media === void 0 ? void 0 : _rule$media[0]) === "(prefers-color-scheme: dark)") {
  723. if (cssTheme === ViewerCssTheme.LIGHT) {
  724. styleSheet.deleteRule(i);
  725. return;
  726. }
  727. var darkRules = /^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/.exec(rule.cssText);
  728. if (darkRules !== null && darkRules !== void 0 && darkRules[1]) {
  729. styleSheet.deleteRule(i);
  730. styleSheet.insertRule(darkRules[1], i);
  731. }
  732. return;
  733. }
  734. }
  735. } catch (reason) {
  736. console.error("_forceCssTheme: \"".concat(reason === null || reason === void 0 ? void 0 : reason.message, "\"."));
  737. }
  738. },
  739. _initializeViewerComponents: function _initializeViewerComponents() {
  740. var _this5 = this;
  741. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
  742. var appConfig, externalServices, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, pdfScriptingManager, container, viewer;
  743. return _regenerator["default"].wrap(function _callee5$(_context5) {
  744. while (1) {
  745. switch (_context5.prev = _context5.next) {
  746. case 0:
  747. appConfig = _this5.appConfig, externalServices = _this5.externalServices;
  748. eventBus = externalServices.isInAutomation ? new _event_utils.AutomationEventBus() : new _event_utils.EventBus();
  749. _this5.eventBus = eventBus;
  750. _this5.overlayManager = new _overlay_manager.OverlayManager();
  751. pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  752. pdfRenderingQueue.onIdle = _this5._cleanup.bind(_this5);
  753. _this5.pdfRenderingQueue = pdfRenderingQueue;
  754. pdfLinkService = new _pdf_link_service.PDFLinkService({
  755. eventBus: eventBus,
  756. externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"),
  757. externalLinkRel: _app_options.AppOptions.get("externalLinkRel"),
  758. ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom")
  759. });
  760. _this5.pdfLinkService = pdfLinkService;
  761. downloadManager = externalServices.createDownloadManager();
  762. _this5.downloadManager = downloadManager;
  763. findController = new _pdf_find_controller.PDFFindController({
  764. linkService: pdfLinkService,
  765. eventBus: eventBus
  766. });
  767. _this5.findController = findController;
  768. pdfScriptingManager = new _pdf_scripting_manager.PDFScriptingManager({
  769. eventBus: eventBus,
  770. sandboxBundleSrc: _app_options.AppOptions.get("sandboxBundleSrc"),
  771. scriptingFactory: externalServices,
  772. docPropertiesLookup: _this5._scriptingDocProperties.bind(_this5)
  773. });
  774. _this5.pdfScriptingManager = pdfScriptingManager;
  775. container = appConfig.mainContainer;
  776. viewer = appConfig.viewerContainer;
  777. _this5.pdfViewer = new _pdf_viewer.PDFViewer({
  778. container: container,
  779. viewer: viewer,
  780. eventBus: eventBus,
  781. renderingQueue: pdfRenderingQueue,
  782. linkService: pdfLinkService,
  783. downloadManager: downloadManager,
  784. findController: findController,
  785. scriptingManager: _app_options.AppOptions.get("enableScripting") && pdfScriptingManager,
  786. renderer: _app_options.AppOptions.get("renderer"),
  787. l10n: _this5.l10n,
  788. textLayerMode: _app_options.AppOptions.get("textLayerMode"),
  789. annotationMode: _app_options.AppOptions.get("annotationMode"),
  790. imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"),
  791. enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"),
  792. useOnlyCssZoom: _app_options.AppOptions.get("useOnlyCssZoom"),
  793. maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels"),
  794. enablePermissions: _app_options.AppOptions.get("enablePermissions"),
  795. pageColors: {
  796. background: _app_options.AppOptions.get("pageColorsBackground"),
  797. foreground: _app_options.AppOptions.get("pageColorsForeground")
  798. }
  799. });
  800. pdfRenderingQueue.setViewer(_this5.pdfViewer);
  801. pdfLinkService.setViewer(_this5.pdfViewer);
  802. pdfScriptingManager.setViewer(_this5.pdfViewer);
  803. _this5.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  804. container: appConfig.sidebar.thumbnailView,
  805. eventBus: eventBus,
  806. renderingQueue: pdfRenderingQueue,
  807. linkService: pdfLinkService,
  808. l10n: _this5.l10n
  809. });
  810. pdfRenderingQueue.setThumbnailViewer(_this5.pdfThumbnailViewer);
  811. if (!_this5.isViewerEmbedded && !_app_options.AppOptions.get("disableHistory")) {
  812. _this5.pdfHistory = new _pdf_history.PDFHistory({
  813. linkService: pdfLinkService,
  814. eventBus: eventBus
  815. });
  816. pdfLinkService.setHistory(_this5.pdfHistory);
  817. }
  818. if (!_this5.supportsIntegratedFind) {
  819. _this5.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, _this5.l10n);
  820. }
  821. _this5.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this5.overlayManager, eventBus, _this5.l10n);
  822. _this5.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  823. container: container,
  824. eventBus: eventBus,
  825. cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad")
  826. });
  827. _this5.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, _this5.l10n);
  828. _this5.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, eventBus);
  829. if (_this5.supportsFullscreen) {
  830. _this5.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  831. container: container,
  832. pdfViewer: _this5.pdfViewer,
  833. eventBus: eventBus
  834. });
  835. }
  836. _this5.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this5.overlayManager, _this5.l10n, _this5.isViewerEmbedded);
  837. _this5.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  838. container: appConfig.sidebar.outlineView,
  839. eventBus: eventBus,
  840. linkService: pdfLinkService
  841. });
  842. _this5.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  843. container: appConfig.sidebar.attachmentsView,
  844. eventBus: eventBus,
  845. downloadManager: downloadManager
  846. });
  847. _this5.pdfLayerViewer = new _pdf_layer_viewer.PDFLayerViewer({
  848. container: appConfig.sidebar.layersView,
  849. eventBus: eventBus,
  850. l10n: _this5.l10n
  851. });
  852. _this5.pdfSidebar = new _pdf_sidebar.PDFSidebar({
  853. elements: appConfig.sidebar,
  854. pdfViewer: _this5.pdfViewer,
  855. pdfThumbnailViewer: _this5.pdfThumbnailViewer,
  856. eventBus: eventBus,
  857. l10n: _this5.l10n
  858. });
  859. _this5.pdfSidebar.onToggled = _this5.forceRendering.bind(_this5);
  860. _this5.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, _this5.l10n);
  861. case 37:
  862. case "end":
  863. return _context5.stop();
  864. }
  865. }
  866. }, _callee5);
  867. }))();
  868. },
  869. run: function run(config) {
  870. this.initialize(config).then(webViewerInitialized);
  871. },
  872. get initialized() {
  873. return this._initializedCapability.settled;
  874. },
  875. get initializedPromise() {
  876. return this._initializedCapability.promise;
  877. },
  878. zoomIn: function zoomIn(steps) {
  879. if (this.pdfViewer.isInPresentationMode) {
  880. return;
  881. }
  882. this.pdfViewer.increaseScale(steps);
  883. },
  884. zoomOut: function zoomOut(steps) {
  885. if (this.pdfViewer.isInPresentationMode) {
  886. return;
  887. }
  888. this.pdfViewer.decreaseScale(steps);
  889. },
  890. zoomReset: function zoomReset() {
  891. if (this.pdfViewer.isInPresentationMode) {
  892. return;
  893. }
  894. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  895. },
  896. get pagesCount() {
  897. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  898. },
  899. get page() {
  900. return this.pdfViewer.currentPageNumber;
  901. },
  902. set page(val) {
  903. this.pdfViewer.currentPageNumber = val;
  904. },
  905. get supportsPrinting() {
  906. return PDFPrintServiceFactory.instance.supportsPrinting;
  907. },
  908. get supportsFullscreen() {
  909. return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", document.fullscreenEnabled);
  910. },
  911. get supportsIntegratedFind() {
  912. return this.externalServices.supportsIntegratedFind;
  913. },
  914. get supportsDocumentFonts() {
  915. return this.externalServices.supportsDocumentFonts;
  916. },
  917. get loadingBar() {
  918. var bar = new _ui_utils.ProgressBar("#loadingBar");
  919. return (0, _pdfjsLib.shadow)(this, "loadingBar", bar);
  920. },
  921. get supportedMouseWheelZoomModifierKeys() {
  922. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  923. },
  924. initPassiveLoading: function initPassiveLoading() {
  925. throw new Error("Not implemented: initPassiveLoading");
  926. },
  927. setTitleUsingUrl: function setTitleUsingUrl() {
  928. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  929. var downloadUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  930. this.url = url;
  931. this.baseUrl = url.split("#")[0];
  932. if (downloadUrl) {
  933. this._downloadUrl = downloadUrl === url ? this.baseUrl : downloadUrl.split("#")[0];
  934. }
  935. var title = (0, _pdfjsLib.getPdfFilenameFromUrl)(url, "");
  936. if (!title) {
  937. try {
  938. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  939. } catch (ex) {
  940. title = url;
  941. }
  942. }
  943. this.setTitle(title);
  944. },
  945. setTitle: function setTitle(title) {
  946. if (this.isViewerEmbedded) {
  947. return;
  948. }
  949. document.title = title;
  950. },
  951. get _docFilename() {
  952. return this._contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(this.url);
  953. },
  954. _hideViewBookmark: function _hideViewBookmark() {
  955. var _this$appConfig = this.appConfig,
  956. toolbar = _this$appConfig.toolbar,
  957. secondaryToolbar = _this$appConfig.secondaryToolbar;
  958. toolbar.viewBookmark.hidden = true;
  959. secondaryToolbar.viewBookmarkButton.hidden = true;
  960. },
  961. _cancelIdleCallbacks: function _cancelIdleCallbacks() {
  962. if (!this._idleCallbacks.size) {
  963. return;
  964. }
  965. var _iterator = _createForOfIteratorHelper(this._idleCallbacks),
  966. _step;
  967. try {
  968. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  969. var callback = _step.value;
  970. window.cancelIdleCallback(callback);
  971. }
  972. } catch (err) {
  973. _iterator.e(err);
  974. } finally {
  975. _iterator.f();
  976. }
  977. this._idleCallbacks.clear();
  978. },
  979. close: function close() {
  980. var _this6 = this;
  981. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  982. var _this6$pdfDocument, _this6$pdfHistory, _this6$findBar, _this6$_PDFBug;
  983. var container, promises;
  984. return _regenerator["default"].wrap(function _callee6$(_context6) {
  985. while (1) {
  986. switch (_context6.prev = _context6.next) {
  987. case 0:
  988. _this6._unblockDocumentLoadEvent();
  989. _this6._hideViewBookmark();
  990. container = _this6.appConfig.errorWrapper.container;
  991. container.hidden = true;
  992. if (_this6.pdfLoadingTask) {
  993. _context6.next = 6;
  994. break;
  995. }
  996. return _context6.abrupt("return");
  997. case 6:
  998. if (!(((_this6$pdfDocument = _this6.pdfDocument) === null || _this6$pdfDocument === void 0 ? void 0 : _this6$pdfDocument.annotationStorage.size) > 0 && _this6._annotationStorageModified)) {
  999. _context6.next = 14;
  1000. break;
  1001. }
  1002. _context6.prev = 7;
  1003. _context6.next = 10;
  1004. return _this6.save({
  1005. sourceEventType: "save"
  1006. });
  1007. case 10:
  1008. _context6.next = 14;
  1009. break;
  1010. case 12:
  1011. _context6.prev = 12;
  1012. _context6.t0 = _context6["catch"](7);
  1013. case 14:
  1014. promises = [];
  1015. promises.push(_this6.pdfLoadingTask.destroy());
  1016. _this6.pdfLoadingTask = null;
  1017. if (_this6.pdfDocument) {
  1018. _this6.pdfDocument = null;
  1019. _this6.pdfThumbnailViewer.setDocument(null);
  1020. _this6.pdfViewer.setDocument(null);
  1021. _this6.pdfLinkService.setDocument(null);
  1022. _this6.pdfDocumentProperties.setDocument(null);
  1023. }
  1024. _this6.pdfLinkService.externalLinkEnabled = true;
  1025. _this6.store = null;
  1026. _this6.isInitialViewSet = false;
  1027. _this6.downloadComplete = false;
  1028. _this6.url = "";
  1029. _this6.baseUrl = "";
  1030. _this6._downloadUrl = "";
  1031. _this6.documentInfo = null;
  1032. _this6.metadata = null;
  1033. _this6._contentDispositionFilename = null;
  1034. _this6._contentLength = null;
  1035. _this6._saveInProgress = false;
  1036. _this6._docStats = null;
  1037. _this6._cancelIdleCallbacks();
  1038. promises.push(_this6.pdfScriptingManager.destroyPromise);
  1039. _this6.pdfSidebar.reset();
  1040. _this6.pdfOutlineViewer.reset();
  1041. _this6.pdfAttachmentViewer.reset();
  1042. _this6.pdfLayerViewer.reset();
  1043. (_this6$pdfHistory = _this6.pdfHistory) === null || _this6$pdfHistory === void 0 ? void 0 : _this6$pdfHistory.reset();
  1044. (_this6$findBar = _this6.findBar) === null || _this6$findBar === void 0 ? void 0 : _this6$findBar.reset();
  1045. _this6.toolbar.reset();
  1046. _this6.secondaryToolbar.reset();
  1047. (_this6$_PDFBug = _this6._PDFBug) === null || _this6$_PDFBug === void 0 ? void 0 : _this6$_PDFBug.cleanup();
  1048. _context6.next = 44;
  1049. return Promise.all(promises);
  1050. case 44:
  1051. case "end":
  1052. return _context6.stop();
  1053. }
  1054. }
  1055. }, _callee6, null, [[7, 12]]);
  1056. }))();
  1057. },
  1058. open: function open(file, args) {
  1059. var _this7 = this;
  1060. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
  1061. var workerParameters, key, parameters, apiParameters, _key, value, _key2, loadingTask;
  1062. return _regenerator["default"].wrap(function _callee7$(_context7) {
  1063. while (1) {
  1064. switch (_context7.prev = _context7.next) {
  1065. case 0:
  1066. if (!_this7.pdfLoadingTask) {
  1067. _context7.next = 3;
  1068. break;
  1069. }
  1070. _context7.next = 3;
  1071. return _this7.close();
  1072. case 3:
  1073. workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
  1074. for (key in workerParameters) {
  1075. _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key];
  1076. }
  1077. parameters = Object.create(null);
  1078. if (typeof file === "string") {
  1079. _this7.setTitleUsingUrl(file, file);
  1080. parameters.url = file;
  1081. } else if (file && "byteLength" in file) {
  1082. parameters.data = file;
  1083. } else if (file.url && file.originalUrl) {
  1084. _this7.setTitleUsingUrl(file.originalUrl, file.url);
  1085. parameters.url = file.url;
  1086. }
  1087. apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
  1088. for (_key in apiParameters) {
  1089. value = apiParameters[_key];
  1090. if (_key === "docBaseUrl" && !value) {}
  1091. parameters[_key] = value;
  1092. }
  1093. if (args) {
  1094. for (_key2 in args) {
  1095. parameters[_key2] = args[_key2];
  1096. }
  1097. }
  1098. loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  1099. _this7.pdfLoadingTask = loadingTask;
  1100. loadingTask.onPassword = function (updateCallback, reason) {
  1101. _this7.pdfLinkService.externalLinkEnabled = false;
  1102. _this7.passwordPrompt.setUpdateCallback(updateCallback, reason);
  1103. _this7.passwordPrompt.open();
  1104. };
  1105. loadingTask.onProgress = function (_ref) {
  1106. var loaded = _ref.loaded,
  1107. total = _ref.total;
  1108. _this7.progress(loaded / total);
  1109. };
  1110. loadingTask.onUnsupportedFeature = _this7.fallback.bind(_this7);
  1111. return _context7.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
  1112. _this7.load(pdfDocument);
  1113. }, function (reason) {
  1114. if (loadingTask !== _this7.pdfLoadingTask) {
  1115. return undefined;
  1116. }
  1117. var key = "loading_error";
  1118. if (reason instanceof _pdfjsLib.InvalidPDFException) {
  1119. key = "invalid_file_error";
  1120. } else if (reason instanceof _pdfjsLib.MissingPDFException) {
  1121. key = "missing_file_error";
  1122. } else if (reason instanceof _pdfjsLib.UnexpectedResponseException) {
  1123. key = "unexpected_response_error";
  1124. }
  1125. return _this7.l10n.get(key).then(function (msg) {
  1126. _this7._documentError(msg, {
  1127. message: reason === null || reason === void 0 ? void 0 : reason.message
  1128. });
  1129. throw reason;
  1130. });
  1131. }));
  1132. case 16:
  1133. case "end":
  1134. return _context7.stop();
  1135. }
  1136. }
  1137. }, _callee7);
  1138. }))();
  1139. },
  1140. _ensureDownloadComplete: function _ensureDownloadComplete() {
  1141. if (this.pdfDocument && this.downloadComplete) {
  1142. return;
  1143. }
  1144. throw new Error("PDF document not downloaded.");
  1145. },
  1146. download: function download() {
  1147. var _arguments = arguments,
  1148. _this8 = this;
  1149. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
  1150. var _ref2, _ref2$sourceEventType, sourceEventType, url, filename, data, blob;
  1151. return _regenerator["default"].wrap(function _callee8$(_context8) {
  1152. while (1) {
  1153. switch (_context8.prev = _context8.next) {
  1154. case 0:
  1155. _ref2 = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {}, _ref2$sourceEventType = _ref2.sourceEventType, sourceEventType = _ref2$sourceEventType === void 0 ? "download" : _ref2$sourceEventType;
  1156. url = _this8._downloadUrl, filename = _this8._docFilename;
  1157. _context8.prev = 2;
  1158. _this8._ensureDownloadComplete();
  1159. _context8.next = 6;
  1160. return _this8.pdfDocument.getData();
  1161. case 6:
  1162. data = _context8.sent;
  1163. blob = new Blob([data], {
  1164. type: "application/pdf"
  1165. });
  1166. _context8.next = 10;
  1167. return _this8.downloadManager.download(blob, url, filename, sourceEventType);
  1168. case 10:
  1169. _context8.next = 16;
  1170. break;
  1171. case 12:
  1172. _context8.prev = 12;
  1173. _context8.t0 = _context8["catch"](2);
  1174. _context8.next = 16;
  1175. return _this8.downloadManager.downloadUrl(url, filename);
  1176. case 16:
  1177. case "end":
  1178. return _context8.stop();
  1179. }
  1180. }
  1181. }, _callee8, null, [[2, 12]]);
  1182. }))();
  1183. },
  1184. save: function save() {
  1185. var _arguments2 = arguments,
  1186. _this9 = this;
  1187. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
  1188. var _ref3, _ref3$sourceEventType, sourceEventType, url, filename, data, blob;
  1189. return _regenerator["default"].wrap(function _callee9$(_context9) {
  1190. while (1) {
  1191. switch (_context9.prev = _context9.next) {
  1192. case 0:
  1193. _ref3 = _arguments2.length > 0 && _arguments2[0] !== undefined ? _arguments2[0] : {}, _ref3$sourceEventType = _ref3.sourceEventType, sourceEventType = _ref3$sourceEventType === void 0 ? "download" : _ref3$sourceEventType;
  1194. if (!_this9._saveInProgress) {
  1195. _context9.next = 3;
  1196. break;
  1197. }
  1198. return _context9.abrupt("return");
  1199. case 3:
  1200. _this9._saveInProgress = true;
  1201. _context9.next = 6;
  1202. return _this9.pdfScriptingManager.dispatchWillSave();
  1203. case 6:
  1204. url = _this9._downloadUrl, filename = _this9._docFilename;
  1205. _context9.prev = 7;
  1206. _this9._ensureDownloadComplete();
  1207. _context9.next = 11;
  1208. return _this9.pdfDocument.saveDocument();
  1209. case 11:
  1210. data = _context9.sent;
  1211. blob = new Blob([data], {
  1212. type: "application/pdf"
  1213. });
  1214. _context9.next = 15;
  1215. return _this9.downloadManager.download(blob, url, filename, sourceEventType);
  1216. case 15:
  1217. _context9.next = 22;
  1218. break;
  1219. case 17:
  1220. _context9.prev = 17;
  1221. _context9.t0 = _context9["catch"](7);
  1222. console.error("Error when saving the document: ".concat(_context9.t0.message));
  1223. _context9.next = 22;
  1224. return _this9.download({
  1225. sourceEventType: sourceEventType
  1226. });
  1227. case 22:
  1228. _context9.prev = 22;
  1229. _context9.next = 25;
  1230. return _this9.pdfScriptingManager.dispatchDidSave();
  1231. case 25:
  1232. _this9._saveInProgress = false;
  1233. return _context9.finish(22);
  1234. case 27:
  1235. case "end":
  1236. return _context9.stop();
  1237. }
  1238. }
  1239. }, _callee9, null, [[7, 17, 22, 27]]);
  1240. }))();
  1241. },
  1242. downloadOrSave: function downloadOrSave(options) {
  1243. var _this$pdfDocument;
  1244. if (((_this$pdfDocument = this.pdfDocument) === null || _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage.size) > 0) {
  1245. this.save(options);
  1246. } else {
  1247. this.download(options);
  1248. }
  1249. },
  1250. fallback: function fallback(featureId) {
  1251. this.externalServices.reportTelemetry({
  1252. type: "unsupportedFeature",
  1253. featureId: featureId
  1254. });
  1255. },
  1256. _documentError: function _documentError(message) {
  1257. var _moreInfo$message;
  1258. var moreInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1259. this._unblockDocumentLoadEvent();
  1260. this._otherError(message, moreInfo);
  1261. this.eventBus.dispatch("documenterror", {
  1262. source: this,
  1263. message: message,
  1264. reason: (_moreInfo$message = moreInfo === null || moreInfo === void 0 ? void 0 : moreInfo.message) !== null && _moreInfo$message !== void 0 ? _moreInfo$message : null
  1265. });
  1266. },
  1267. _otherError: function _otherError(message) {
  1268. var moreInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1269. var moreInfoText = [this.l10n.get("error_version_info", {
  1270. version: _pdfjsLib.version || "?",
  1271. build: _pdfjsLib.build || "?"
  1272. })];
  1273. if (moreInfo) {
  1274. moreInfoText.push(this.l10n.get("error_message", {
  1275. message: moreInfo.message
  1276. }));
  1277. if (moreInfo.stack) {
  1278. moreInfoText.push(this.l10n.get("error_stack", {
  1279. stack: moreInfo.stack
  1280. }));
  1281. } else {
  1282. if (moreInfo.filename) {
  1283. moreInfoText.push(this.l10n.get("error_file", {
  1284. file: moreInfo.filename
  1285. }));
  1286. }
  1287. if (moreInfo.lineNumber) {
  1288. moreInfoText.push(this.l10n.get("error_line", {
  1289. line: moreInfo.lineNumber
  1290. }));
  1291. }
  1292. }
  1293. }
  1294. var errorWrapperConfig = this.appConfig.errorWrapper;
  1295. var errorWrapper = errorWrapperConfig.container;
  1296. errorWrapper.hidden = false;
  1297. var errorMessage = errorWrapperConfig.errorMessage;
  1298. errorMessage.textContent = message;
  1299. var closeButton = errorWrapperConfig.closeButton;
  1300. closeButton.onclick = function () {
  1301. errorWrapper.hidden = true;
  1302. };
  1303. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  1304. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  1305. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  1306. moreInfoButton.onclick = function () {
  1307. errorMoreInfo.hidden = false;
  1308. moreInfoButton.hidden = true;
  1309. lessInfoButton.hidden = false;
  1310. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + "px";
  1311. };
  1312. lessInfoButton.onclick = function () {
  1313. errorMoreInfo.hidden = true;
  1314. moreInfoButton.hidden = false;
  1315. lessInfoButton.hidden = true;
  1316. };
  1317. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1318. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1319. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1320. moreInfoButton.hidden = false;
  1321. lessInfoButton.hidden = true;
  1322. Promise.all(moreInfoText).then(function (parts) {
  1323. errorMoreInfo.value = parts.join("\n");
  1324. });
  1325. },
  1326. progress: function progress(level) {
  1327. var _this10 = this;
  1328. if (this.downloadComplete) {
  1329. return;
  1330. }
  1331. var percent = Math.round(level * 100);
  1332. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1333. this.loadingBar.percent = percent;
  1334. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams.disableAutoFetch : _app_options.AppOptions.get("disableAutoFetch");
  1335. if (disableAutoFetch && percent) {
  1336. if (this.disableAutoFetchLoadingBarTimeout) {
  1337. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1338. this.disableAutoFetchLoadingBarTimeout = null;
  1339. }
  1340. this.loadingBar.show();
  1341. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  1342. _this10.loadingBar.hide();
  1343. _this10.disableAutoFetchLoadingBarTimeout = null;
  1344. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1345. }
  1346. }
  1347. },
  1348. load: function load(pdfDocument) {
  1349. var _this11 = this;
  1350. this.pdfDocument = pdfDocument;
  1351. pdfDocument.getDownloadInfo().then(function (_ref4) {
  1352. var length = _ref4.length;
  1353. _this11._contentLength = length;
  1354. _this11.downloadComplete = true;
  1355. _this11.loadingBar.hide();
  1356. firstPagePromise.then(function () {
  1357. _this11.eventBus.dispatch("documentloaded", {
  1358. source: _this11
  1359. });
  1360. });
  1361. });
  1362. var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function () {});
  1363. var pageModePromise = pdfDocument.getPageMode()["catch"](function () {});
  1364. var openActionPromise = pdfDocument.getOpenAction()["catch"](function () {});
  1365. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1366. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1367. var baseDocumentUrl;
  1368. baseDocumentUrl = null;
  1369. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1370. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1371. var pdfViewer = this.pdfViewer;
  1372. pdfViewer.setDocument(pdfDocument);
  1373. var firstPagePromise = pdfViewer.firstPagePromise,
  1374. onePageRendered = pdfViewer.onePageRendered,
  1375. pagesPromise = pdfViewer.pagesPromise;
  1376. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1377. pdfThumbnailViewer.setDocument(pdfDocument);
  1378. var storedPromise = (this.store = new _view_history.ViewHistory(pdfDocument.fingerprints[0])).getMultiple({
  1379. page: null,
  1380. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1381. scrollLeft: "0",
  1382. scrollTop: "0",
  1383. rotation: null,
  1384. sidebarView: _ui_utils.SidebarView.UNKNOWN,
  1385. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  1386. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  1387. })["catch"](function () {
  1388. return Object.create(null);
  1389. });
  1390. firstPagePromise.then(function (pdfPage) {
  1391. _this11.loadingBar.setWidth(_this11.appConfig.viewerContainer);
  1392. _this11._initializeAnnotationStorageCallbacks(pdfDocument);
  1393. Promise.all([_ui_utils.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then( /*#__PURE__*/function () {
  1394. var _ref6 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee10(_ref5) {
  1395. var _ref7, timeStamp, stored, pageLayout, pageMode, openAction, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode, modes;
  1396. return _regenerator["default"].wrap(function _callee10$(_context10) {
  1397. while (1) {
  1398. switch (_context10.prev = _context10.next) {
  1399. case 0:
  1400. _ref7 = _slicedToArray(_ref5, 5), timeStamp = _ref7[0], stored = _ref7[1], pageLayout = _ref7[2], pageMode = _ref7[3], openAction = _ref7[4];
  1401. viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
  1402. _this11._initializePdfHistory({
  1403. fingerprint: pdfDocument.fingerprints[0],
  1404. viewOnLoad: viewOnLoad,
  1405. initialDest: openAction === null || openAction === void 0 ? void 0 : openAction.dest
  1406. });
  1407. initialBookmark = _this11.initialBookmark;
  1408. zoom = _app_options.AppOptions.get("defaultZoomValue");
  1409. hash = zoom ? "zoom=".concat(zoom) : null;
  1410. rotation = null;
  1411. sidebarView = _app_options.AppOptions.get("sidebarViewOnLoad");
  1412. scrollMode = _app_options.AppOptions.get("scrollModeOnLoad");
  1413. spreadMode = _app_options.AppOptions.get("spreadModeOnLoad");
  1414. if (stored.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  1415. hash = "page=".concat(stored.page, "&zoom=").concat(zoom || stored.zoom, ",") + "".concat(stored.scrollLeft, ",").concat(stored.scrollTop);
  1416. rotation = parseInt(stored.rotation, 10);
  1417. if (sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  1418. sidebarView = stored.sidebarView | 0;
  1419. }
  1420. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  1421. scrollMode = stored.scrollMode | 0;
  1422. }
  1423. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1424. spreadMode = stored.spreadMode | 0;
  1425. }
  1426. }
  1427. if (pageMode && sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  1428. sidebarView = (0, _ui_utils.apiPageModeToSidebarView)(pageMode);
  1429. }
  1430. if (pageLayout && scrollMode === _ui_utils.ScrollMode.UNKNOWN && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1431. modes = (0, _ui_utils.apiPageLayoutToViewerModes)(pageLayout);
  1432. spreadMode = modes.spreadMode;
  1433. }
  1434. _this11.setInitialView(hash, {
  1435. rotation: rotation,
  1436. sidebarView: sidebarView,
  1437. scrollMode: scrollMode,
  1438. spreadMode: spreadMode
  1439. });
  1440. _this11.eventBus.dispatch("documentinit", {
  1441. source: _this11
  1442. });
  1443. if (!_this11.isViewerEmbedded) {
  1444. pdfViewer.focus();
  1445. }
  1446. _context10.next = 18;
  1447. return Promise.race([pagesPromise, new Promise(function (resolve) {
  1448. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  1449. })]);
  1450. case 18:
  1451. if (!(!initialBookmark && !hash)) {
  1452. _context10.next = 20;
  1453. break;
  1454. }
  1455. return _context10.abrupt("return");
  1456. case 20:
  1457. if (!pdfViewer.hasEqualPageSizes) {
  1458. _context10.next = 22;
  1459. break;
  1460. }
  1461. return _context10.abrupt("return");
  1462. case 22:
  1463. _this11.initialBookmark = initialBookmark;
  1464. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  1465. _this11.setInitialView(hash);
  1466. case 25:
  1467. case "end":
  1468. return _context10.stop();
  1469. }
  1470. }
  1471. }, _callee10);
  1472. }));
  1473. return function (_x) {
  1474. return _ref6.apply(this, arguments);
  1475. };
  1476. }())["catch"](function () {
  1477. _this11.setInitialView();
  1478. }).then(function () {
  1479. pdfViewer.update();
  1480. });
  1481. });
  1482. pagesPromise.then(function () {
  1483. _this11._unblockDocumentLoadEvent();
  1484. _this11._initializeAutoPrint(pdfDocument, openActionPromise);
  1485. }, function (reason) {
  1486. _this11.l10n.get("loading_error").then(function (msg) {
  1487. _this11._documentError(msg, {
  1488. message: reason === null || reason === void 0 ? void 0 : reason.message
  1489. });
  1490. });
  1491. });
  1492. onePageRendered.then(function (data) {
  1493. _this11.externalServices.reportTelemetry({
  1494. type: "pageInfo",
  1495. timestamp: data.timestamp
  1496. });
  1497. pdfDocument.getOutline().then(function (outline) {
  1498. if (pdfDocument !== _this11.pdfDocument) {
  1499. return;
  1500. }
  1501. _this11.pdfOutlineViewer.render({
  1502. outline: outline,
  1503. pdfDocument: pdfDocument
  1504. });
  1505. });
  1506. pdfDocument.getAttachments().then(function (attachments) {
  1507. if (pdfDocument !== _this11.pdfDocument) {
  1508. return;
  1509. }
  1510. _this11.pdfAttachmentViewer.render({
  1511. attachments: attachments
  1512. });
  1513. });
  1514. pdfViewer.optionalContentConfigPromise.then(function (optionalContentConfig) {
  1515. if (pdfDocument !== _this11.pdfDocument) {
  1516. return;
  1517. }
  1518. _this11.pdfLayerViewer.render({
  1519. optionalContentConfig: optionalContentConfig,
  1520. pdfDocument: pdfDocument
  1521. });
  1522. });
  1523. if ("requestIdleCallback" in window) {
  1524. var callback = window.requestIdleCallback(function () {
  1525. _this11._collectTelemetry(pdfDocument);
  1526. _this11._idleCallbacks["delete"](callback);
  1527. }, {
  1528. timeout: 1000
  1529. });
  1530. _this11._idleCallbacks.add(callback);
  1531. }
  1532. });
  1533. this._initializePageLabels(pdfDocument);
  1534. this._initializeMetadata(pdfDocument);
  1535. },
  1536. _scriptingDocProperties: function _scriptingDocProperties(pdfDocument) {
  1537. var _this12 = this;
  1538. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
  1539. var _this12$metadata, _this12$metadata2;
  1540. return _regenerator["default"].wrap(function _callee11$(_context11) {
  1541. while (1) {
  1542. switch (_context11.prev = _context11.next) {
  1543. case 0:
  1544. if (_this12.documentInfo) {
  1545. _context11.next = 5;
  1546. break;
  1547. }
  1548. _context11.next = 3;
  1549. return new Promise(function (resolve) {
  1550. _this12.eventBus._on("metadataloaded", resolve, {
  1551. once: true
  1552. });
  1553. });
  1554. case 3:
  1555. if (!(pdfDocument !== _this12.pdfDocument)) {
  1556. _context11.next = 5;
  1557. break;
  1558. }
  1559. return _context11.abrupt("return", null);
  1560. case 5:
  1561. if (_this12._contentLength) {
  1562. _context11.next = 10;
  1563. break;
  1564. }
  1565. _context11.next = 8;
  1566. return new Promise(function (resolve) {
  1567. _this12.eventBus._on("documentloaded", resolve, {
  1568. once: true
  1569. });
  1570. });
  1571. case 8:
  1572. if (!(pdfDocument !== _this12.pdfDocument)) {
  1573. _context11.next = 10;
  1574. break;
  1575. }
  1576. return _context11.abrupt("return", null);
  1577. case 10:
  1578. return _context11.abrupt("return", _objectSpread(_objectSpread({}, _this12.documentInfo), {}, {
  1579. baseURL: _this12.baseUrl,
  1580. filesize: _this12._contentLength,
  1581. filename: _this12._docFilename,
  1582. metadata: (_this12$metadata = _this12.metadata) === null || _this12$metadata === void 0 ? void 0 : _this12$metadata.getRaw(),
  1583. authors: (_this12$metadata2 = _this12.metadata) === null || _this12$metadata2 === void 0 ? void 0 : _this12$metadata2.get("dc:creator"),
  1584. numPages: _this12.pagesCount,
  1585. URL: _this12.url
  1586. }));
  1587. case 11:
  1588. case "end":
  1589. return _context11.stop();
  1590. }
  1591. }
  1592. }, _callee11);
  1593. }))();
  1594. },
  1595. _collectTelemetry: function _collectTelemetry(pdfDocument) {
  1596. var _this13 = this;
  1597. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
  1598. var markInfo, tagged;
  1599. return _regenerator["default"].wrap(function _callee12$(_context12) {
  1600. while (1) {
  1601. switch (_context12.prev = _context12.next) {
  1602. case 0:
  1603. _context12.next = 2;
  1604. return _this13.pdfDocument.getMarkInfo();
  1605. case 2:
  1606. markInfo = _context12.sent;
  1607. if (!(pdfDocument !== _this13.pdfDocument)) {
  1608. _context12.next = 5;
  1609. break;
  1610. }
  1611. return _context12.abrupt("return");
  1612. case 5:
  1613. tagged = (markInfo === null || markInfo === void 0 ? void 0 : markInfo.Marked) || false;
  1614. _this13.externalServices.reportTelemetry({
  1615. type: "tagged",
  1616. tagged: tagged
  1617. });
  1618. case 7:
  1619. case "end":
  1620. return _context12.stop();
  1621. }
  1622. }
  1623. }, _callee12);
  1624. }))();
  1625. },
  1626. _initializeAutoPrint: function _initializeAutoPrint(pdfDocument, openActionPromise) {
  1627. var _this14 = this;
  1628. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
  1629. var _yield$Promise$all, _yield$Promise$all2, openAction, javaScript, triggerAutoPrint, _iterator2, _step2, js;
  1630. return _regenerator["default"].wrap(function _callee13$(_context13) {
  1631. while (1) {
  1632. switch (_context13.prev = _context13.next) {
  1633. case 0:
  1634. _context13.next = 2;
  1635. return Promise.all([openActionPromise, !_this14.pdfViewer.enableScripting ? pdfDocument.getJavaScript() : null]);
  1636. case 2:
  1637. _yield$Promise$all = _context13.sent;
  1638. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
  1639. openAction = _yield$Promise$all2[0];
  1640. javaScript = _yield$Promise$all2[1];
  1641. if (!(pdfDocument !== _this14.pdfDocument)) {
  1642. _context13.next = 8;
  1643. break;
  1644. }
  1645. return _context13.abrupt("return");
  1646. case 8:
  1647. triggerAutoPrint = false;
  1648. if ((openAction === null || openAction === void 0 ? void 0 : openAction.action) === "Print") {
  1649. triggerAutoPrint = true;
  1650. }
  1651. if (!javaScript) {
  1652. _context13.next = 31;
  1653. break;
  1654. }
  1655. javaScript.some(function (js) {
  1656. if (!js) {
  1657. return false;
  1658. }
  1659. console.warn("Warning: JavaScript support is not enabled");
  1660. _this14.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  1661. return true;
  1662. });
  1663. if (triggerAutoPrint) {
  1664. _context13.next = 31;
  1665. break;
  1666. }
  1667. _iterator2 = _createForOfIteratorHelper(javaScript);
  1668. _context13.prev = 14;
  1669. _iterator2.s();
  1670. case 16:
  1671. if ((_step2 = _iterator2.n()).done) {
  1672. _context13.next = 23;
  1673. break;
  1674. }
  1675. js = _step2.value;
  1676. if (!(js && _ui_utils.AutoPrintRegExp.test(js))) {
  1677. _context13.next = 21;
  1678. break;
  1679. }
  1680. triggerAutoPrint = true;
  1681. return _context13.abrupt("break", 23);
  1682. case 21:
  1683. _context13.next = 16;
  1684. break;
  1685. case 23:
  1686. _context13.next = 28;
  1687. break;
  1688. case 25:
  1689. _context13.prev = 25;
  1690. _context13.t0 = _context13["catch"](14);
  1691. _iterator2.e(_context13.t0);
  1692. case 28:
  1693. _context13.prev = 28;
  1694. _iterator2.f();
  1695. return _context13.finish(28);
  1696. case 31:
  1697. if (triggerAutoPrint) {
  1698. _this14.triggerPrinting();
  1699. }
  1700. case 32:
  1701. case "end":
  1702. return _context13.stop();
  1703. }
  1704. }
  1705. }, _callee13, null, [[14, 25, 28, 31]]);
  1706. }))();
  1707. },
  1708. _initializeMetadata: function _initializeMetadata(pdfDocument) {
  1709. var _this15 = this;
  1710. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee14() {
  1711. var _this15$_contentDispo, _this15$_contentLengt;
  1712. var _yield$pdfDocument$ge, info, metadata, contentDispositionFilename, contentLength, pdfTitle, metadataTitle, versionId, generatorId, producer, formType;
  1713. return _regenerator["default"].wrap(function _callee14$(_context14) {
  1714. while (1) {
  1715. switch (_context14.prev = _context14.next) {
  1716. case 0:
  1717. _context14.next = 2;
  1718. return pdfDocument.getMetadata();
  1719. case 2:
  1720. _yield$pdfDocument$ge = _context14.sent;
  1721. info = _yield$pdfDocument$ge.info;
  1722. metadata = _yield$pdfDocument$ge.metadata;
  1723. contentDispositionFilename = _yield$pdfDocument$ge.contentDispositionFilename;
  1724. contentLength = _yield$pdfDocument$ge.contentLength;
  1725. if (!(pdfDocument !== _this15.pdfDocument)) {
  1726. _context14.next = 9;
  1727. break;
  1728. }
  1729. return _context14.abrupt("return");
  1730. case 9:
  1731. _this15.documentInfo = info;
  1732. _this15.metadata = metadata;
  1733. (_this15$_contentDispo = _this15._contentDispositionFilename) !== null && _this15$_contentDispo !== void 0 ? _this15$_contentDispo : _this15._contentDispositionFilename = contentDispositionFilename;
  1734. (_this15$_contentLengt = _this15._contentLength) !== null && _this15$_contentLengt !== void 0 ? _this15$_contentLengt : _this15._contentLength = contentLength;
  1735. console.log("PDF ".concat(pdfDocument.fingerprints[0], " [").concat(info.PDFFormatVersion, " ") + "".concat((info.Producer || "-").trim(), " / ").concat((info.Creator || "-").trim(), "] ") + "(PDF.js: ".concat(_pdfjsLib.version || "-", ")"));
  1736. pdfTitle = info === null || info === void 0 ? void 0 : info.Title;
  1737. metadataTitle = metadata === null || metadata === void 0 ? void 0 : metadata.get("dc:title");
  1738. if (metadataTitle) {
  1739. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
  1740. pdfTitle = metadataTitle;
  1741. }
  1742. }
  1743. if (pdfTitle) {
  1744. _this15.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
  1745. } else if (contentDispositionFilename) {
  1746. _this15.setTitle(contentDispositionFilename);
  1747. }
  1748. if (info.IsXFAPresent && !info.IsAcroFormPresent && !pdfDocument.isPureXfa) {
  1749. if (pdfDocument.loadingParams.enableXfa) {
  1750. console.warn("Warning: XFA Foreground documents are not supported");
  1751. } else {
  1752. console.warn("Warning: XFA support is not enabled");
  1753. }
  1754. _this15.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1755. } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !_this15.pdfViewer.renderForms) {
  1756. console.warn("Warning: Interactive form support is not enabled");
  1757. _this15.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1758. }
  1759. if (info.IsSignaturesPresent) {
  1760. console.warn("Warning: Digital signatures validation is not supported");
  1761. _this15.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.signatures);
  1762. }
  1763. versionId = "other";
  1764. if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
  1765. versionId = "v".concat(info.PDFFormatVersion.replace(".", "_"));
  1766. }
  1767. generatorId = "other";
  1768. if (info.Producer) {
  1769. producer = info.Producer.toLowerCase();
  1770. KNOWN_GENERATORS.some(function (generator) {
  1771. if (!producer.includes(generator)) {
  1772. return false;
  1773. }
  1774. generatorId = generator.replace(/[ .-]/g, "_");
  1775. return true;
  1776. });
  1777. }
  1778. formType = null;
  1779. if (info.IsXFAPresent) {
  1780. formType = "xfa";
  1781. } else if (info.IsAcroFormPresent) {
  1782. formType = "acroform";
  1783. }
  1784. _this15.externalServices.reportTelemetry({
  1785. type: "documentInfo",
  1786. version: versionId,
  1787. generator: generatorId,
  1788. formType: formType
  1789. });
  1790. _this15.eventBus.dispatch("metadataloaded", {
  1791. source: _this15
  1792. });
  1793. case 28:
  1794. case "end":
  1795. return _context14.stop();
  1796. }
  1797. }
  1798. }, _callee14);
  1799. }))();
  1800. },
  1801. _initializePageLabels: function _initializePageLabels(pdfDocument) {
  1802. var _this16 = this;
  1803. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee15() {
  1804. var labels, numLabels, standardLabels, emptyLabels, i, label, pdfViewer, pdfThumbnailViewer, toolbar;
  1805. return _regenerator["default"].wrap(function _callee15$(_context15) {
  1806. while (1) {
  1807. switch (_context15.prev = _context15.next) {
  1808. case 0:
  1809. _context15.next = 2;
  1810. return pdfDocument.getPageLabels();
  1811. case 2:
  1812. labels = _context15.sent;
  1813. if (!(pdfDocument !== _this16.pdfDocument)) {
  1814. _context15.next = 5;
  1815. break;
  1816. }
  1817. return _context15.abrupt("return");
  1818. case 5:
  1819. if (!(!labels || _app_options.AppOptions.get("disablePageLabels"))) {
  1820. _context15.next = 7;
  1821. break;
  1822. }
  1823. return _context15.abrupt("return");
  1824. case 7:
  1825. numLabels = labels.length;
  1826. standardLabels = 0, emptyLabels = 0;
  1827. i = 0;
  1828. case 10:
  1829. if (!(i < numLabels)) {
  1830. _context15.next = 24;
  1831. break;
  1832. }
  1833. label = labels[i];
  1834. if (!(label === (i + 1).toString())) {
  1835. _context15.next = 16;
  1836. break;
  1837. }
  1838. standardLabels++;
  1839. _context15.next = 21;
  1840. break;
  1841. case 16:
  1842. if (!(label === "")) {
  1843. _context15.next = 20;
  1844. break;
  1845. }
  1846. emptyLabels++;
  1847. _context15.next = 21;
  1848. break;
  1849. case 20:
  1850. return _context15.abrupt("break", 24);
  1851. case 21:
  1852. i++;
  1853. _context15.next = 10;
  1854. break;
  1855. case 24:
  1856. if (!(standardLabels >= numLabels || emptyLabels >= numLabels)) {
  1857. _context15.next = 26;
  1858. break;
  1859. }
  1860. return _context15.abrupt("return");
  1861. case 26:
  1862. pdfViewer = _this16.pdfViewer, pdfThumbnailViewer = _this16.pdfThumbnailViewer, toolbar = _this16.toolbar;
  1863. pdfViewer.setPageLabels(labels);
  1864. pdfThumbnailViewer.setPageLabels(labels);
  1865. toolbar.setPagesCount(numLabels, true);
  1866. toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1867. case 31:
  1868. case "end":
  1869. return _context15.stop();
  1870. }
  1871. }
  1872. }, _callee15);
  1873. }))();
  1874. },
  1875. _initializePdfHistory: function _initializePdfHistory(_ref8) {
  1876. var fingerprint = _ref8.fingerprint,
  1877. viewOnLoad = _ref8.viewOnLoad,
  1878. _ref8$initialDest = _ref8.initialDest,
  1879. initialDest = _ref8$initialDest === void 0 ? null : _ref8$initialDest;
  1880. if (!this.pdfHistory) {
  1881. return;
  1882. }
  1883. this.pdfHistory.initialize({
  1884. fingerprint: fingerprint,
  1885. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  1886. updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
  1887. });
  1888. if (this.pdfHistory.initialBookmark) {
  1889. this.initialBookmark = this.pdfHistory.initialBookmark;
  1890. this.initialRotation = this.pdfHistory.initialRotation;
  1891. }
  1892. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  1893. this.initialBookmark = JSON.stringify(initialDest);
  1894. this.pdfHistory.push({
  1895. explicitDest: initialDest,
  1896. pageNumber: null
  1897. });
  1898. }
  1899. },
  1900. _initializeAnnotationStorageCallbacks: function _initializeAnnotationStorageCallbacks(pdfDocument) {
  1901. var _this17 = this;
  1902. if (pdfDocument !== this.pdfDocument) {
  1903. return;
  1904. }
  1905. var annotationStorage = pdfDocument.annotationStorage;
  1906. annotationStorage.onSetModified = function () {
  1907. window.addEventListener("beforeunload", beforeUnload);
  1908. _this17._annotationStorageModified = true;
  1909. };
  1910. annotationStorage.onResetModified = function () {
  1911. window.removeEventListener("beforeunload", beforeUnload);
  1912. delete _this17._annotationStorageModified;
  1913. };
  1914. },
  1915. setInitialView: function setInitialView(storedHash) {
  1916. var _this18 = this;
  1917. var _ref9 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1918. rotation = _ref9.rotation,
  1919. sidebarView = _ref9.sidebarView,
  1920. scrollMode = _ref9.scrollMode,
  1921. spreadMode = _ref9.spreadMode;
  1922. var setRotation = function setRotation(angle) {
  1923. if ((0, _ui_utils.isValidRotation)(angle)) {
  1924. _this18.pdfViewer.pagesRotation = angle;
  1925. }
  1926. };
  1927. var setViewerModes = function setViewerModes(scroll, spread) {
  1928. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  1929. _this18.pdfViewer.scrollMode = scroll;
  1930. }
  1931. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  1932. _this18.pdfViewer.spreadMode = spread;
  1933. }
  1934. };
  1935. this.isInitialViewSet = true;
  1936. this.pdfSidebar.setInitialView(sidebarView);
  1937. setViewerModes(scrollMode, spreadMode);
  1938. if (this.initialBookmark) {
  1939. setRotation(this.initialRotation);
  1940. delete this.initialRotation;
  1941. this.pdfLinkService.setHash(this.initialBookmark);
  1942. this.initialBookmark = null;
  1943. } else if (storedHash) {
  1944. setRotation(rotation);
  1945. this.pdfLinkService.setHash(storedHash);
  1946. }
  1947. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  1948. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  1949. if (!this.pdfViewer.currentScaleValue) {
  1950. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1951. }
  1952. },
  1953. _cleanup: function _cleanup() {
  1954. if (!this.pdfDocument) {
  1955. return;
  1956. }
  1957. this.pdfViewer.cleanup();
  1958. this.pdfThumbnailViewer.cleanup();
  1959. this.pdfDocument.cleanup(this.pdfViewer.renderer === _ui_utils.RendererType.SVG);
  1960. },
  1961. forceRendering: function forceRendering() {
  1962. this.pdfRenderingQueue.printing = !!this.printService;
  1963. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  1964. this.pdfRenderingQueue.renderHighestPriority();
  1965. },
  1966. beforePrint: function beforePrint() {
  1967. var _this19 = this;
  1968. this.pdfScriptingManager.dispatchWillPrint();
  1969. if (this.printService) {
  1970. return;
  1971. }
  1972. if (!this.supportsPrinting) {
  1973. this.l10n.get("printing_not_supported").then(function (msg) {
  1974. _this19._otherError(msg);
  1975. });
  1976. return;
  1977. }
  1978. if (!this.pdfViewer.pageViewsReady) {
  1979. this.l10n.get("printing_not_ready").then(function (msg) {
  1980. window.alert(msg);
  1981. });
  1982. return;
  1983. }
  1984. var pagesOverview = this.pdfViewer.getPagesOverview();
  1985. var printContainer = this.appConfig.printContainer;
  1986. var printResolution = _app_options.AppOptions.get("printResolution");
  1987. var optionalContentConfigPromise = this.pdfViewer.optionalContentConfigPromise;
  1988. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, this.l10n);
  1989. this.printService = printService;
  1990. this.forceRendering();
  1991. printService.layout();
  1992. this.externalServices.reportTelemetry({
  1993. type: "print"
  1994. });
  1995. },
  1996. afterPrint: function afterPrint() {
  1997. this.pdfScriptingManager.dispatchDidPrint();
  1998. if (this.printService) {
  1999. var _this$pdfDocument2;
  2000. this.printService.destroy();
  2001. this.printService = null;
  2002. (_this$pdfDocument2 = this.pdfDocument) === null || _this$pdfDocument2 === void 0 ? void 0 : _this$pdfDocument2.annotationStorage.resetModified();
  2003. }
  2004. this.forceRendering();
  2005. },
  2006. rotatePages: function rotatePages(delta) {
  2007. this.pdfViewer.pagesRotation += delta;
  2008. },
  2009. requestPresentationMode: function requestPresentationMode() {
  2010. var _this$pdfPresentation;
  2011. (_this$pdfPresentation = this.pdfPresentationMode) === null || _this$pdfPresentation === void 0 ? void 0 : _this$pdfPresentation.request();
  2012. },
  2013. triggerPrinting: function triggerPrinting() {
  2014. if (!this.supportsPrinting) {
  2015. return;
  2016. }
  2017. window.print();
  2018. },
  2019. bindEvents: function bindEvents() {
  2020. var eventBus = this.eventBus,
  2021. _boundEvents = this._boundEvents;
  2022. _boundEvents.beforePrint = this.beforePrint.bind(this);
  2023. _boundEvents.afterPrint = this.afterPrint.bind(this);
  2024. eventBus._on("resize", webViewerResize);
  2025. eventBus._on("hashchange", webViewerHashchange);
  2026. eventBus._on("beforeprint", _boundEvents.beforePrint);
  2027. eventBus._on("afterprint", _boundEvents.afterPrint);
  2028. eventBus._on("pagerendered", webViewerPageRendered);
  2029. eventBus._on("updateviewarea", webViewerUpdateViewarea);
  2030. eventBus._on("pagechanging", webViewerPageChanging);
  2031. eventBus._on("scalechanging", webViewerScaleChanging);
  2032. eventBus._on("rotationchanging", webViewerRotationChanging);
  2033. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
  2034. eventBus._on("pagemode", webViewerPageMode);
  2035. eventBus._on("namedaction", webViewerNamedAction);
  2036. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
  2037. eventBus._on("presentationmode", webViewerPresentationMode);
  2038. eventBus._on("print", webViewerPrint);
  2039. eventBus._on("download", webViewerDownload);
  2040. eventBus._on("save", webViewerSave);
  2041. eventBus._on("firstpage", webViewerFirstPage);
  2042. eventBus._on("lastpage", webViewerLastPage);
  2043. eventBus._on("nextpage", webViewerNextPage);
  2044. eventBus._on("previouspage", webViewerPreviousPage);
  2045. eventBus._on("zoomin", webViewerZoomIn);
  2046. eventBus._on("zoomout", webViewerZoomOut);
  2047. eventBus._on("zoomreset", webViewerZoomReset);
  2048. eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
  2049. eventBus._on("scalechanged", webViewerScaleChanged);
  2050. eventBus._on("rotatecw", webViewerRotateCw);
  2051. eventBus._on("rotateccw", webViewerRotateCcw);
  2052. eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig);
  2053. eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
  2054. eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
  2055. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
  2056. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
  2057. eventBus._on("documentproperties", webViewerDocumentProperties);
  2058. eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
  2059. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2060. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
  2061. if (_app_options.AppOptions.get("pdfBug")) {
  2062. _boundEvents.reportPageStatsPDFBug = reportPageStatsPDFBug;
  2063. eventBus._on("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2064. eventBus._on("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2065. }
  2066. eventBus._on("fileinputchange", webViewerFileInputChange);
  2067. eventBus._on("openfile", webViewerOpenFile);
  2068. },
  2069. bindWindowEvents: function bindWindowEvents() {
  2070. var eventBus = this.eventBus,
  2071. _boundEvents = this._boundEvents;
  2072. _boundEvents.windowResize = function () {
  2073. eventBus.dispatch("resize", {
  2074. source: window
  2075. });
  2076. };
  2077. _boundEvents.windowHashChange = function () {
  2078. eventBus.dispatch("hashchange", {
  2079. source: window,
  2080. hash: document.location.hash.substring(1)
  2081. });
  2082. };
  2083. _boundEvents.windowBeforePrint = function () {
  2084. eventBus.dispatch("beforeprint", {
  2085. source: window
  2086. });
  2087. };
  2088. _boundEvents.windowAfterPrint = function () {
  2089. eventBus.dispatch("afterprint", {
  2090. source: window
  2091. });
  2092. };
  2093. _boundEvents.windowUpdateFromSandbox = function (event) {
  2094. eventBus.dispatch("updatefromsandbox", {
  2095. source: window,
  2096. detail: event.detail
  2097. });
  2098. };
  2099. window.addEventListener("visibilitychange", webViewerVisibilityChange);
  2100. window.addEventListener("wheel", webViewerWheel, {
  2101. passive: false
  2102. });
  2103. window.addEventListener("touchstart", webViewerTouchStart, {
  2104. passive: false
  2105. });
  2106. window.addEventListener("click", webViewerClick);
  2107. window.addEventListener("keydown", webViewerKeyDown);
  2108. window.addEventListener("resize", _boundEvents.windowResize);
  2109. window.addEventListener("hashchange", _boundEvents.windowHashChange);
  2110. window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2111. window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
  2112. window.addEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  2113. },
  2114. unbindEvents: function unbindEvents() {
  2115. var eventBus = this.eventBus,
  2116. _boundEvents = this._boundEvents;
  2117. eventBus._off("resize", webViewerResize);
  2118. eventBus._off("hashchange", webViewerHashchange);
  2119. eventBus._off("beforeprint", _boundEvents.beforePrint);
  2120. eventBus._off("afterprint", _boundEvents.afterPrint);
  2121. eventBus._off("pagerendered", webViewerPageRendered);
  2122. eventBus._off("updateviewarea", webViewerUpdateViewarea);
  2123. eventBus._off("pagechanging", webViewerPageChanging);
  2124. eventBus._off("scalechanging", webViewerScaleChanging);
  2125. eventBus._off("rotationchanging", webViewerRotationChanging);
  2126. eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
  2127. eventBus._off("pagemode", webViewerPageMode);
  2128. eventBus._off("namedaction", webViewerNamedAction);
  2129. eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
  2130. eventBus._off("presentationmode", webViewerPresentationMode);
  2131. eventBus._off("print", webViewerPrint);
  2132. eventBus._off("download", webViewerDownload);
  2133. eventBus._off("save", webViewerSave);
  2134. eventBus._off("firstpage", webViewerFirstPage);
  2135. eventBus._off("lastpage", webViewerLastPage);
  2136. eventBus._off("nextpage", webViewerNextPage);
  2137. eventBus._off("previouspage", webViewerPreviousPage);
  2138. eventBus._off("zoomin", webViewerZoomIn);
  2139. eventBus._off("zoomout", webViewerZoomOut);
  2140. eventBus._off("zoomreset", webViewerZoomReset);
  2141. eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
  2142. eventBus._off("scalechanged", webViewerScaleChanged);
  2143. eventBus._off("rotatecw", webViewerRotateCw);
  2144. eventBus._off("rotateccw", webViewerRotateCcw);
  2145. eventBus._off("optionalcontentconfig", webViewerOptionalContentConfig);
  2146. eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
  2147. eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
  2148. eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
  2149. eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
  2150. eventBus._off("documentproperties", webViewerDocumentProperties);
  2151. eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
  2152. eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2153. eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
  2154. if (_boundEvents.reportPageStatsPDFBug) {
  2155. eventBus._off("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2156. eventBus._off("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2157. _boundEvents.reportPageStatsPDFBug = null;
  2158. }
  2159. eventBus._off("fileinputchange", webViewerFileInputChange);
  2160. eventBus._off("openfile", webViewerOpenFile);
  2161. _boundEvents.beforePrint = null;
  2162. _boundEvents.afterPrint = null;
  2163. },
  2164. unbindWindowEvents: function unbindWindowEvents() {
  2165. var _boundEvents = this._boundEvents;
  2166. window.removeEventListener("visibilitychange", webViewerVisibilityChange);
  2167. window.removeEventListener("wheel", webViewerWheel, {
  2168. passive: false
  2169. });
  2170. window.removeEventListener("touchstart", webViewerTouchStart, {
  2171. passive: false
  2172. });
  2173. window.removeEventListener("click", webViewerClick);
  2174. window.removeEventListener("keydown", webViewerKeyDown);
  2175. window.removeEventListener("resize", _boundEvents.windowResize);
  2176. window.removeEventListener("hashchange", _boundEvents.windowHashChange);
  2177. window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2178. window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
  2179. window.removeEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  2180. _boundEvents.windowResize = null;
  2181. _boundEvents.windowHashChange = null;
  2182. _boundEvents.windowBeforePrint = null;
  2183. _boundEvents.windowAfterPrint = null;
  2184. _boundEvents.windowUpdateFromSandbox = null;
  2185. },
  2186. accumulateWheelTicks: function accumulateWheelTicks(ticks) {
  2187. if (this._wheelUnusedTicks > 0 && ticks < 0 || this._wheelUnusedTicks < 0 && ticks > 0) {
  2188. this._wheelUnusedTicks = 0;
  2189. }
  2190. this._wheelUnusedTicks += ticks;
  2191. var wholeTicks = Math.sign(this._wheelUnusedTicks) * Math.floor(Math.abs(this._wheelUnusedTicks));
  2192. this._wheelUnusedTicks -= wholeTicks;
  2193. return wholeTicks;
  2194. },
  2195. _unblockDocumentLoadEvent: function _unblockDocumentLoadEvent() {
  2196. var _document$blockUnbloc, _document;
  2197. (_document$blockUnbloc = (_document = document).blockUnblockOnload) === null || _document$blockUnbloc === void 0 ? void 0 : _document$blockUnbloc.call(_document, false);
  2198. this._unblockDocumentLoadEvent = function () {};
  2199. },
  2200. _reportDocumentStatsTelemetry: function _reportDocumentStatsTelemetry() {
  2201. var stats = this.pdfDocument.stats;
  2202. if (stats !== this._docStats) {
  2203. this._docStats = stats;
  2204. this.externalServices.reportTelemetry({
  2205. type: "documentStats",
  2206. stats: stats
  2207. });
  2208. }
  2209. },
  2210. get scriptingReady() {
  2211. return this.pdfScriptingManager.ready;
  2212. }
  2213. };
  2214. exports.PDFViewerApplication = PDFViewerApplication;
  2215. var validateFileURL;
  2216. {
  2217. var HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
  2218. validateFileURL = function validateFileURL(file) {
  2219. if (!file) {
  2220. return;
  2221. }
  2222. try {
  2223. var viewerOrigin = new URL(window.location.href).origin || "null";
  2224. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  2225. return;
  2226. }
  2227. var fileOrigin = new URL(file, window.location.href).origin;
  2228. // if (fileOrigin !== viewerOrigin) {
  2229. // throw new Error("file origin does not match viewer's");
  2230. // }
  2231. } catch (ex) {
  2232. PDFViewerApplication.l10n.get("loading_error").then(function (msg) {
  2233. PDFViewerApplication._documentError(msg, {
  2234. message: ex === null || ex === void 0 ? void 0 : ex.message
  2235. });
  2236. });
  2237. throw ex;
  2238. }
  2239. };
  2240. }
  2241. function loadFakeWorker() {
  2242. return _loadFakeWorker.apply(this, arguments);
  2243. }
  2244. function _loadFakeWorker() {
  2245. _loadFakeWorker = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee16() {
  2246. return _regenerator["default"].wrap(function _callee16$(_context16) {
  2247. while (1) {
  2248. switch (_context16.prev = _context16.next) {
  2249. case 0:
  2250. _pdfjsLib.GlobalWorkerOptions.workerSrc || (_pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get("workerSrc"));
  2251. _context16.next = 3;
  2252. return (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.workerSrc);
  2253. case 3:
  2254. case "end":
  2255. return _context16.stop();
  2256. }
  2257. }
  2258. }, _callee16);
  2259. }));
  2260. return _loadFakeWorker.apply(this, arguments);
  2261. }
  2262. function loadPDFBug(_x2) {
  2263. return _loadPDFBug.apply(this, arguments);
  2264. }
  2265. function _loadPDFBug() {
  2266. _loadPDFBug = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee17(self) {
  2267. var debuggerScriptPath, _yield$__non_webpack_, PDFBug;
  2268. return _regenerator["default"].wrap(function _callee17$(_context17) {
  2269. while (1) {
  2270. switch (_context17.prev = _context17.next) {
  2271. case 0:
  2272. debuggerScriptPath = self.appConfig.debuggerScriptPath;
  2273. _context17.next = 3;
  2274. return import(debuggerScriptPath);
  2275. case 3:
  2276. _yield$__non_webpack_ = _context17.sent;
  2277. PDFBug = _yield$__non_webpack_.PDFBug;
  2278. self._PDFBug = PDFBug;
  2279. case 6:
  2280. case "end":
  2281. return _context17.stop();
  2282. }
  2283. }
  2284. }, _callee17);
  2285. }));
  2286. return _loadPDFBug.apply(this, arguments);
  2287. }
  2288. function reportPageStatsPDFBug(_ref10) {
  2289. var _globalThis$Stats, _pageView$pdfPage;
  2290. var pageNumber = _ref10.pageNumber;
  2291. if (!((_globalThis$Stats = globalThis.Stats) !== null && _globalThis$Stats !== void 0 && _globalThis$Stats.enabled)) {
  2292. return;
  2293. }
  2294. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  2295. globalThis.Stats.add(pageNumber, pageView === null || pageView === void 0 ? void 0 : (_pageView$pdfPage = pageView.pdfPage) === null || _pageView$pdfPage === void 0 ? void 0 : _pageView$pdfPage.stats);
  2296. }
  2297. function webViewerInitialized() {
  2298. var _params$get;
  2299. var appConfig = PDFViewerApplication.appConfig,
  2300. eventBus = PDFViewerApplication.eventBus;
  2301. var file;
  2302. var queryString = document.location.search.substring(1);
  2303. var params = (0, _ui_utils.parseQueryString)(queryString);
  2304. file = (_params$get = params.get("file")) !== null && _params$get !== void 0 ? _params$get : _app_options.AppOptions.get("defaultUrl");
  2305. validateFileURL(file);
  2306. var fileInput = appConfig.openFileInput;
  2307. fileInput.value = null;
  2308. fileInput.addEventListener("change", function (evt) {
  2309. var files = evt.target.files;
  2310. if (!files || files.length === 0) {
  2311. return;
  2312. }
  2313. eventBus.dispatch("fileinputchange", {
  2314. source: this,
  2315. fileInput: evt.target
  2316. });
  2317. });
  2318. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  2319. evt.preventDefault();
  2320. evt.dataTransfer.dropEffect = "move";
  2321. });
  2322. appConfig.mainContainer.addEventListener("drop", function (evt) {
  2323. evt.preventDefault();
  2324. var files = evt.dataTransfer.files;
  2325. if (!files || files.length === 0) {
  2326. return;
  2327. }
  2328. eventBus.dispatch("fileinputchange", {
  2329. source: this,
  2330. fileInput: evt.dataTransfer
  2331. });
  2332. });
  2333. if (!PDFViewerApplication.supportsDocumentFonts) {
  2334. _app_options.AppOptions.set("disableFontFace", true);
  2335. PDFViewerApplication.l10n.get("web_fonts_disabled").then(function (msg) {
  2336. console.warn(msg);
  2337. });
  2338. }
  2339. if (!PDFViewerApplication.supportsPrinting) {
  2340. appConfig.toolbar.print.classList.add("hidden");
  2341. appConfig.secondaryToolbar.printButton.classList.add("hidden");
  2342. }
  2343. if (!PDFViewerApplication.supportsFullscreen) {
  2344. appConfig.toolbar.presentationModeButton.classList.add("hidden");
  2345. appConfig.secondaryToolbar.presentationModeButton.classList.add("hidden");
  2346. }
  2347. if (PDFViewerApplication.supportsIntegratedFind) {
  2348. appConfig.toolbar.viewFind.classList.add("hidden");
  2349. }
  2350. appConfig.mainContainer.addEventListener("transitionend", function (evt) {
  2351. if (evt.target === this) {
  2352. eventBus.dispatch("resize", {
  2353. source: this
  2354. });
  2355. }
  2356. }, true);
  2357. try {
  2358. if (file) {
  2359. PDFViewerApplication.open(file);
  2360. } else {
  2361. PDFViewerApplication._hideViewBookmark();
  2362. }
  2363. } catch (reason) {
  2364. PDFViewerApplication.l10n.get("loading_error").then(function (msg) {
  2365. PDFViewerApplication._documentError(msg, reason);
  2366. });
  2367. }
  2368. }
  2369. function webViewerPageRendered(_ref11) {
  2370. var pageNumber = _ref11.pageNumber,
  2371. error = _ref11.error;
  2372. if (pageNumber === PDFViewerApplication.page) {
  2373. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  2374. }
  2375. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2376. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  2377. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageNumber - 1);
  2378. if (pageView && thumbnailView) {
  2379. thumbnailView.setImage(pageView);
  2380. }
  2381. }
  2382. if (error) {
  2383. PDFViewerApplication.l10n.get("rendering_error").then(function (msg) {
  2384. PDFViewerApplication._otherError(msg, error);
  2385. });
  2386. }
  2387. PDFViewerApplication._reportDocumentStatsTelemetry();
  2388. }
  2389. function webViewerPageMode(_ref12) {
  2390. var mode = _ref12.mode;
  2391. var view;
  2392. switch (mode) {
  2393. case "thumbs":
  2394. view = _ui_utils.SidebarView.THUMBS;
  2395. break;
  2396. case "bookmarks":
  2397. case "outline":
  2398. view = _ui_utils.SidebarView.OUTLINE;
  2399. break;
  2400. case "attachments":
  2401. view = _ui_utils.SidebarView.ATTACHMENTS;
  2402. break;
  2403. case "layers":
  2404. view = _ui_utils.SidebarView.LAYERS;
  2405. break;
  2406. case "none":
  2407. view = _ui_utils.SidebarView.NONE;
  2408. break;
  2409. default:
  2410. console.error('Invalid "pagemode" hash parameter: ' + mode);
  2411. return;
  2412. }
  2413. PDFViewerApplication.pdfSidebar.switchView(view, true);
  2414. }
  2415. function webViewerNamedAction(evt) {
  2416. switch (evt.action) {
  2417. case "GoToPage":
  2418. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2419. break;
  2420. case "Find":
  2421. if (!PDFViewerApplication.supportsIntegratedFind) {
  2422. PDFViewerApplication.findBar.toggle();
  2423. }
  2424. break;
  2425. case "Print":
  2426. PDFViewerApplication.triggerPrinting();
  2427. break;
  2428. case "SaveAs":
  2429. webViewerSave();
  2430. break;
  2431. }
  2432. }
  2433. function webViewerPresentationModeChanged(evt) {
  2434. PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
  2435. }
  2436. function webViewerSidebarViewChanged(evt) {
  2437. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  2438. if (PDFViewerApplication.isInitialViewSet) {
  2439. var _PDFViewerApplication;
  2440. (_PDFViewerApplication = PDFViewerApplication.store) === null || _PDFViewerApplication === void 0 ? void 0 : _PDFViewerApplication.set("sidebarView", evt.view)["catch"](function () {});
  2441. }
  2442. }
  2443. function webViewerUpdateViewarea(evt) {
  2444. var location = evt.location;
  2445. if (PDFViewerApplication.isInitialViewSet) {
  2446. var _PDFViewerApplication2;
  2447. (_PDFViewerApplication2 = PDFViewerApplication.store) === null || _PDFViewerApplication2 === void 0 ? void 0 : _PDFViewerApplication2.setMultiple({
  2448. page: location.pageNumber,
  2449. zoom: location.scale,
  2450. scrollLeft: location.left,
  2451. scrollTop: location.top,
  2452. rotation: location.rotation
  2453. })["catch"](function () {});
  2454. }
  2455. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  2456. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  2457. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  2458. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  2459. var loading = (currentPage === null || currentPage === void 0 ? void 0 : currentPage.renderingState) !== _ui_utils.RenderingStates.FINISHED;
  2460. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  2461. }
  2462. function webViewerScrollModeChanged(evt) {
  2463. if (PDFViewerApplication.isInitialViewSet) {
  2464. var _PDFViewerApplication3;
  2465. (_PDFViewerApplication3 = PDFViewerApplication.store) === null || _PDFViewerApplication3 === void 0 ? void 0 : _PDFViewerApplication3.set("scrollMode", evt.mode)["catch"](function () {});
  2466. }
  2467. }
  2468. function webViewerSpreadModeChanged(evt) {
  2469. if (PDFViewerApplication.isInitialViewSet) {
  2470. var _PDFViewerApplication4;
  2471. (_PDFViewerApplication4 = PDFViewerApplication.store) === null || _PDFViewerApplication4 === void 0 ? void 0 : _PDFViewerApplication4.set("spreadMode", evt.mode)["catch"](function () {});
  2472. }
  2473. }
  2474. function webViewerResize() {
  2475. var pdfDocument = PDFViewerApplication.pdfDocument,
  2476. pdfViewer = PDFViewerApplication.pdfViewer;
  2477. pdfViewer.updateContainerHeightCss();
  2478. if (!pdfDocument) {
  2479. return;
  2480. }
  2481. var currentScaleValue = pdfViewer.currentScaleValue;
  2482. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  2483. pdfViewer.currentScaleValue = currentScaleValue;
  2484. }
  2485. pdfViewer.update();
  2486. }
  2487. function webViewerHashchange(evt) {
  2488. var _PDFViewerApplication5;
  2489. var hash = evt.hash;
  2490. if (!hash) {
  2491. return;
  2492. }
  2493. if (!PDFViewerApplication.isInitialViewSet) {
  2494. PDFViewerApplication.initialBookmark = hash;
  2495. } else if (!((_PDFViewerApplication5 = PDFViewerApplication.pdfHistory) !== null && _PDFViewerApplication5 !== void 0 && _PDFViewerApplication5.popStateInProgress)) {
  2496. PDFViewerApplication.pdfLinkService.setHash(hash);
  2497. }
  2498. }
  2499. {
  2500. var webViewerFileInputChange = function webViewerFileInputChange(evt) {
  2501. var _PDFViewerApplication6;
  2502. if ((_PDFViewerApplication6 = PDFViewerApplication.pdfViewer) !== null && _PDFViewerApplication6 !== void 0 && _PDFViewerApplication6.isInPresentationMode) {
  2503. return;
  2504. }
  2505. var file = evt.fileInput.files[0];
  2506. var url = URL.createObjectURL(file);
  2507. if (file.name) {
  2508. url = {
  2509. url: url,
  2510. originalUrl: file.name
  2511. };
  2512. }
  2513. PDFViewerApplication.open(url);
  2514. };
  2515. var webViewerOpenFile = function webViewerOpenFile(evt) {
  2516. var fileInput = PDFViewerApplication.appConfig.openFileInput;
  2517. fileInput.click();
  2518. };
  2519. }
  2520. function webViewerPresentationMode() {
  2521. PDFViewerApplication.requestPresentationMode();
  2522. }
  2523. function webViewerPrint() {
  2524. PDFViewerApplication.triggerPrinting();
  2525. }
  2526. function webViewerDownload() {
  2527. PDFViewerApplication.downloadOrSave({
  2528. sourceEventType: "download"
  2529. });
  2530. }
  2531. function webViewerSave() {
  2532. PDFViewerApplication.downloadOrSave({
  2533. sourceEventType: "save"
  2534. });
  2535. }
  2536. function webViewerFirstPage() {
  2537. if (PDFViewerApplication.pdfDocument) {
  2538. PDFViewerApplication.page = 1;
  2539. }
  2540. }
  2541. function webViewerLastPage() {
  2542. if (PDFViewerApplication.pdfDocument) {
  2543. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2544. }
  2545. }
  2546. function webViewerNextPage() {
  2547. PDFViewerApplication.pdfViewer.nextPage();
  2548. }
  2549. function webViewerPreviousPage() {
  2550. PDFViewerApplication.pdfViewer.previousPage();
  2551. }
  2552. function webViewerZoomIn() {
  2553. PDFViewerApplication.zoomIn();
  2554. }
  2555. function webViewerZoomOut() {
  2556. PDFViewerApplication.zoomOut();
  2557. }
  2558. function webViewerZoomReset() {
  2559. PDFViewerApplication.zoomReset();
  2560. }
  2561. function webViewerPageNumberChanged(evt) {
  2562. var pdfViewer = PDFViewerApplication.pdfViewer;
  2563. if (evt.value !== "") {
  2564. PDFViewerApplication.pdfLinkService.goToPage(evt.value);
  2565. }
  2566. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  2567. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  2568. }
  2569. }
  2570. function webViewerScaleChanged(evt) {
  2571. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  2572. }
  2573. function webViewerRotateCw() {
  2574. PDFViewerApplication.rotatePages(90);
  2575. }
  2576. function webViewerRotateCcw() {
  2577. PDFViewerApplication.rotatePages(-90);
  2578. }
  2579. function webViewerOptionalContentConfig(evt) {
  2580. PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
  2581. }
  2582. function webViewerSwitchScrollMode(evt) {
  2583. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  2584. }
  2585. function webViewerSwitchSpreadMode(evt) {
  2586. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  2587. }
  2588. function webViewerDocumentProperties() {
  2589. PDFViewerApplication.pdfDocumentProperties.open();
  2590. }
  2591. function webViewerFindFromUrlHash(evt) {
  2592. PDFViewerApplication.eventBus.dispatch("find", {
  2593. source: evt.source,
  2594. type: "",
  2595. query: evt.query,
  2596. phraseSearch: evt.phraseSearch,
  2597. caseSensitive: false,
  2598. entireWord: false,
  2599. highlightAll: true,
  2600. findPrevious: false,
  2601. matchDiacritics: true
  2602. });
  2603. }
  2604. function webViewerUpdateFindMatchesCount(_ref13) {
  2605. var matchesCount = _ref13.matchesCount;
  2606. if (PDFViewerApplication.supportsIntegratedFind) {
  2607. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  2608. } else {
  2609. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  2610. }
  2611. }
  2612. function webViewerUpdateFindControlState(_ref14) {
  2613. var state = _ref14.state,
  2614. previous = _ref14.previous,
  2615. matchesCount = _ref14.matchesCount,
  2616. rawQuery = _ref14.rawQuery;
  2617. if (PDFViewerApplication.supportsIntegratedFind) {
  2618. PDFViewerApplication.externalServices.updateFindControlState({
  2619. result: state,
  2620. findPrevious: previous,
  2621. matchesCount: matchesCount,
  2622. rawQuery: rawQuery
  2623. });
  2624. } else {
  2625. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  2626. }
  2627. }
  2628. function webViewerScaleChanging(evt) {
  2629. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  2630. PDFViewerApplication.pdfViewer.update();
  2631. }
  2632. function webViewerRotationChanging(evt) {
  2633. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  2634. PDFViewerApplication.forceRendering();
  2635. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  2636. }
  2637. function webViewerPageChanging(_ref15) {
  2638. var pageNumber = _ref15.pageNumber,
  2639. pageLabel = _ref15.pageLabel;
  2640. PDFViewerApplication.toolbar.setPageNumber(pageNumber, pageLabel);
  2641. PDFViewerApplication.secondaryToolbar.setPageNumber(pageNumber);
  2642. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2643. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(pageNumber);
  2644. }
  2645. }
  2646. function webViewerVisibilityChange(evt) {
  2647. if (document.visibilityState === "visible") {
  2648. setZoomDisabledTimeout();
  2649. }
  2650. }
  2651. var zoomDisabledTimeout = null;
  2652. function setZoomDisabledTimeout() {
  2653. if (zoomDisabledTimeout) {
  2654. clearTimeout(zoomDisabledTimeout);
  2655. }
  2656. zoomDisabledTimeout = setTimeout(function () {
  2657. zoomDisabledTimeout = null;
  2658. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  2659. }
  2660. function webViewerWheel(evt) {
  2661. var pdfViewer = PDFViewerApplication.pdfViewer,
  2662. supportedMouseWheelZoomModifierKeys = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  2663. if (pdfViewer.isInPresentationMode) {
  2664. return;
  2665. }
  2666. if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
  2667. evt.preventDefault();
  2668. if (zoomDisabledTimeout || document.visibilityState === "hidden") {
  2669. return;
  2670. }
  2671. var deltaMode = evt.deltaMode;
  2672. var delta = (0, _ui_utils.normalizeWheelEventDirection)(evt);
  2673. var previousScale = pdfViewer.currentScale;
  2674. var ticks = 0;
  2675. if (deltaMode === WheelEvent.DOM_DELTA_LINE || deltaMode === WheelEvent.DOM_DELTA_PAGE) {
  2676. if (Math.abs(delta) >= 1) {
  2677. ticks = Math.sign(delta);
  2678. } else {
  2679. ticks = PDFViewerApplication.accumulateWheelTicks(delta);
  2680. }
  2681. } else {
  2682. var PIXELS_PER_LINE_SCALE = 30;
  2683. ticks = PDFViewerApplication.accumulateWheelTicks(delta / PIXELS_PER_LINE_SCALE);
  2684. }
  2685. if (ticks < 0) {
  2686. PDFViewerApplication.zoomOut(-ticks);
  2687. } else if (ticks > 0) {
  2688. PDFViewerApplication.zoomIn(ticks);
  2689. }
  2690. var currentScale = pdfViewer.currentScale;
  2691. if (previousScale !== currentScale) {
  2692. var scaleCorrectionFactor = currentScale / previousScale - 1;
  2693. var rect = pdfViewer.container.getBoundingClientRect();
  2694. var dx = evt.clientX - rect.left;
  2695. var dy = evt.clientY - rect.top;
  2696. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  2697. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  2698. }
  2699. } else {
  2700. setZoomDisabledTimeout();
  2701. }
  2702. }
  2703. function webViewerTouchStart(evt) {
  2704. if (evt.touches.length > 1) {
  2705. evt.preventDefault();
  2706. }
  2707. }
  2708. function webViewerClick(evt) {
  2709. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  2710. return;
  2711. }
  2712. var appConfig = PDFViewerApplication.appConfig;
  2713. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  2714. PDFViewerApplication.secondaryToolbar.close();
  2715. }
  2716. }
  2717. function webViewerKeyDown(evt) {
  2718. if (PDFViewerApplication.overlayManager.active) {
  2719. return;
  2720. }
  2721. var eventBus = PDFViewerApplication.eventBus,
  2722. pdfViewer = PDFViewerApplication.pdfViewer;
  2723. var isViewerInPresentationMode = pdfViewer.isInPresentationMode;
  2724. var handled = false,
  2725. ensureViewerFocused = false;
  2726. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  2727. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  2728. switch (evt.keyCode) {
  2729. case 70:
  2730. if (!PDFViewerApplication.supportsIntegratedFind && !evt.shiftKey) {
  2731. PDFViewerApplication.findBar.open();
  2732. handled = true;
  2733. }
  2734. break;
  2735. case 71:
  2736. if (!PDFViewerApplication.supportsIntegratedFind) {
  2737. var state = PDFViewerApplication.findController.state;
  2738. if (state) {
  2739. var eventState = Object.assign(Object.create(null), state, {
  2740. source: window,
  2741. type: "again",
  2742. findPrevious: cmd === 5 || cmd === 12
  2743. });
  2744. eventBus.dispatch("find", eventState);
  2745. }
  2746. handled = true;
  2747. }
  2748. break;
  2749. case 61:
  2750. case 107:
  2751. case 187:
  2752. case 171:
  2753. if (!isViewerInPresentationMode) {
  2754. PDFViewerApplication.zoomIn();
  2755. }
  2756. handled = true;
  2757. break;
  2758. case 173:
  2759. case 109:
  2760. case 189:
  2761. if (!isViewerInPresentationMode) {
  2762. PDFViewerApplication.zoomOut();
  2763. }
  2764. handled = true;
  2765. break;
  2766. case 48:
  2767. case 96:
  2768. if (!isViewerInPresentationMode) {
  2769. setTimeout(function () {
  2770. PDFViewerApplication.zoomReset();
  2771. });
  2772. handled = false;
  2773. }
  2774. break;
  2775. case 38:
  2776. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2777. PDFViewerApplication.page = 1;
  2778. handled = true;
  2779. ensureViewerFocused = true;
  2780. }
  2781. break;
  2782. case 40:
  2783. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2784. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2785. handled = true;
  2786. ensureViewerFocused = true;
  2787. }
  2788. break;
  2789. }
  2790. }
  2791. if (cmd === 1 || cmd === 8) {
  2792. switch (evt.keyCode) {
  2793. case 83:
  2794. eventBus.dispatch("download", {
  2795. source: window
  2796. });
  2797. handled = true;
  2798. break;
  2799. case 79:
  2800. {
  2801. eventBus.dispatch("openfile", {
  2802. source: window
  2803. });
  2804. handled = true;
  2805. }
  2806. break;
  2807. }
  2808. }
  2809. if (cmd === 3 || cmd === 10) {
  2810. switch (evt.keyCode) {
  2811. case 80:
  2812. PDFViewerApplication.requestPresentationMode();
  2813. handled = true;
  2814. break;
  2815. case 71:
  2816. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2817. handled = true;
  2818. break;
  2819. }
  2820. }
  2821. if (handled) {
  2822. if (ensureViewerFocused && !isViewerInPresentationMode) {
  2823. pdfViewer.focus();
  2824. }
  2825. evt.preventDefault();
  2826. return;
  2827. }
  2828. var curElement = (0, _ui_utils.getActiveOrFocusedElement)();
  2829. var curElementTagName = curElement === null || curElement === void 0 ? void 0 : curElement.tagName.toUpperCase();
  2830. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement !== null && curElement !== void 0 && curElement.isContentEditable) {
  2831. if (evt.keyCode !== 27) {
  2832. return;
  2833. }
  2834. }
  2835. if (cmd === 0) {
  2836. var turnPage = 0,
  2837. turnOnlyIfPageFit = false;
  2838. switch (evt.keyCode) {
  2839. case 38:
  2840. case 33:
  2841. if (pdfViewer.isVerticalScrollbarEnabled) {
  2842. turnOnlyIfPageFit = true;
  2843. }
  2844. turnPage = -1;
  2845. break;
  2846. case 8:
  2847. if (!isViewerInPresentationMode) {
  2848. turnOnlyIfPageFit = true;
  2849. }
  2850. turnPage = -1;
  2851. break;
  2852. case 37:
  2853. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2854. turnOnlyIfPageFit = true;
  2855. }
  2856. case 75:
  2857. case 80:
  2858. turnPage = -1;
  2859. break;
  2860. case 27:
  2861. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  2862. PDFViewerApplication.secondaryToolbar.close();
  2863. handled = true;
  2864. }
  2865. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  2866. PDFViewerApplication.findBar.close();
  2867. handled = true;
  2868. }
  2869. break;
  2870. case 40:
  2871. case 34:
  2872. if (pdfViewer.isVerticalScrollbarEnabled) {
  2873. turnOnlyIfPageFit = true;
  2874. }
  2875. turnPage = 1;
  2876. break;
  2877. case 13:
  2878. case 32:
  2879. if (!isViewerInPresentationMode) {
  2880. turnOnlyIfPageFit = true;
  2881. }
  2882. turnPage = 1;
  2883. break;
  2884. case 39:
  2885. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2886. turnOnlyIfPageFit = true;
  2887. }
  2888. case 74:
  2889. case 78:
  2890. turnPage = 1;
  2891. break;
  2892. case 36:
  2893. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2894. PDFViewerApplication.page = 1;
  2895. handled = true;
  2896. ensureViewerFocused = true;
  2897. }
  2898. break;
  2899. case 35:
  2900. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2901. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2902. handled = true;
  2903. ensureViewerFocused = true;
  2904. }
  2905. break;
  2906. case 83:
  2907. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  2908. break;
  2909. case 72:
  2910. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  2911. break;
  2912. case 82:
  2913. PDFViewerApplication.rotatePages(90);
  2914. break;
  2915. case 115:
  2916. PDFViewerApplication.pdfSidebar.toggle();
  2917. break;
  2918. }
  2919. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  2920. if (turnPage > 0) {
  2921. pdfViewer.nextPage();
  2922. } else {
  2923. pdfViewer.previousPage();
  2924. }
  2925. handled = true;
  2926. }
  2927. }
  2928. if (cmd === 4) {
  2929. switch (evt.keyCode) {
  2930. case 13:
  2931. case 32:
  2932. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  2933. break;
  2934. }
  2935. pdfViewer.previousPage();
  2936. handled = true;
  2937. break;
  2938. case 82:
  2939. PDFViewerApplication.rotatePages(-90);
  2940. break;
  2941. }
  2942. }
  2943. if (!handled && !isViewerInPresentationMode) {
  2944. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  2945. ensureViewerFocused = true;
  2946. }
  2947. }
  2948. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  2949. pdfViewer.focus();
  2950. }
  2951. if (handled) {
  2952. evt.preventDefault();
  2953. }
  2954. }
  2955. function beforeUnload(evt) {
  2956. evt.preventDefault();
  2957. evt.returnValue = "";
  2958. return false;
  2959. }
  2960. var PDFPrintServiceFactory = {
  2961. instance: {
  2962. supportsPrinting: false,
  2963. createPrintService: function createPrintService() {
  2964. throw new Error("Not implemented: createPrintService");
  2965. }
  2966. }
  2967. };
  2968. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  2969. /***/ }),
  2970. /* 3 */
  2971. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  2972. module.exports = __webpack_require__(4);
  2973. /***/ }),
  2974. /* 4 */
  2975. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  2976. /* module decorator */ module = __webpack_require__.nmd(module);
  2977. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  2978. var runtime = function (exports) {
  2979. "use strict";
  2980. var Op = Object.prototype;
  2981. var hasOwn = Op.hasOwnProperty;
  2982. var undefined;
  2983. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  2984. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  2985. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  2986. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  2987. function define(obj, key, value) {
  2988. Object.defineProperty(obj, key, {
  2989. value: value,
  2990. enumerable: true,
  2991. configurable: true,
  2992. writable: true
  2993. });
  2994. return obj[key];
  2995. }
  2996. try {
  2997. define({}, "");
  2998. } catch (err) {
  2999. define = function define(obj, key, value) {
  3000. return obj[key] = value;
  3001. };
  3002. }
  3003. function wrap(innerFn, outerFn, self, tryLocsList) {
  3004. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  3005. var generator = Object.create(protoGenerator.prototype);
  3006. var context = new Context(tryLocsList || []);
  3007. generator._invoke = makeInvokeMethod(innerFn, self, context);
  3008. return generator;
  3009. }
  3010. exports.wrap = wrap;
  3011. function tryCatch(fn, obj, arg) {
  3012. try {
  3013. return {
  3014. type: "normal",
  3015. arg: fn.call(obj, arg)
  3016. };
  3017. } catch (err) {
  3018. return {
  3019. type: "throw",
  3020. arg: err
  3021. };
  3022. }
  3023. }
  3024. var GenStateSuspendedStart = "suspendedStart";
  3025. var GenStateSuspendedYield = "suspendedYield";
  3026. var GenStateExecuting = "executing";
  3027. var GenStateCompleted = "completed";
  3028. var ContinueSentinel = {};
  3029. function Generator() {}
  3030. function GeneratorFunction() {}
  3031. function GeneratorFunctionPrototype() {}
  3032. var IteratorPrototype = {};
  3033. define(IteratorPrototype, iteratorSymbol, function () {
  3034. return this;
  3035. });
  3036. var getProto = Object.getPrototypeOf;
  3037. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  3038. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  3039. IteratorPrototype = NativeIteratorPrototype;
  3040. }
  3041. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  3042. GeneratorFunction.prototype = GeneratorFunctionPrototype;
  3043. define(Gp, "constructor", GeneratorFunctionPrototype);
  3044. define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
  3045. GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
  3046. function defineIteratorMethods(prototype) {
  3047. ["next", "throw", "return"].forEach(function (method) {
  3048. define(prototype, method, function (arg) {
  3049. return this._invoke(method, arg);
  3050. });
  3051. });
  3052. }
  3053. exports.isGeneratorFunction = function (genFun) {
  3054. var ctor = typeof genFun === "function" && genFun.constructor;
  3055. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  3056. };
  3057. exports.mark = function (genFun) {
  3058. if (Object.setPrototypeOf) {
  3059. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  3060. } else {
  3061. genFun.__proto__ = GeneratorFunctionPrototype;
  3062. define(genFun, toStringTagSymbol, "GeneratorFunction");
  3063. }
  3064. genFun.prototype = Object.create(Gp);
  3065. return genFun;
  3066. };
  3067. exports.awrap = function (arg) {
  3068. return {
  3069. __await: arg
  3070. };
  3071. };
  3072. function AsyncIterator(generator, PromiseImpl) {
  3073. function invoke(method, arg, resolve, reject) {
  3074. var record = tryCatch(generator[method], generator, arg);
  3075. if (record.type === "throw") {
  3076. reject(record.arg);
  3077. } else {
  3078. var result = record.arg;
  3079. var value = result.value;
  3080. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  3081. return PromiseImpl.resolve(value.__await).then(function (value) {
  3082. invoke("next", value, resolve, reject);
  3083. }, function (err) {
  3084. invoke("throw", err, resolve, reject);
  3085. });
  3086. }
  3087. return PromiseImpl.resolve(value).then(function (unwrapped) {
  3088. result.value = unwrapped;
  3089. resolve(result);
  3090. }, function (error) {
  3091. return invoke("throw", error, resolve, reject);
  3092. });
  3093. }
  3094. }
  3095. var previousPromise;
  3096. function enqueue(method, arg) {
  3097. function callInvokeWithMethodAndArg() {
  3098. return new PromiseImpl(function (resolve, reject) {
  3099. invoke(method, arg, resolve, reject);
  3100. });
  3101. }
  3102. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  3103. }
  3104. this._invoke = enqueue;
  3105. }
  3106. defineIteratorMethods(AsyncIterator.prototype);
  3107. define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  3108. return this;
  3109. });
  3110. exports.AsyncIterator = AsyncIterator;
  3111. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  3112. if (PromiseImpl === void 0) PromiseImpl = Promise;
  3113. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  3114. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  3115. return result.done ? result.value : iter.next();
  3116. });
  3117. };
  3118. function makeInvokeMethod(innerFn, self, context) {
  3119. var state = GenStateSuspendedStart;
  3120. return function invoke(method, arg) {
  3121. if (state === GenStateExecuting) {
  3122. throw new Error("Generator is already running");
  3123. }
  3124. if (state === GenStateCompleted) {
  3125. if (method === "throw") {
  3126. throw arg;
  3127. }
  3128. return doneResult();
  3129. }
  3130. context.method = method;
  3131. context.arg = arg;
  3132. while (true) {
  3133. var delegate = context.delegate;
  3134. if (delegate) {
  3135. var delegateResult = maybeInvokeDelegate(delegate, context);
  3136. if (delegateResult) {
  3137. if (delegateResult === ContinueSentinel) continue;
  3138. return delegateResult;
  3139. }
  3140. }
  3141. if (context.method === "next") {
  3142. context.sent = context._sent = context.arg;
  3143. } else if (context.method === "throw") {
  3144. if (state === GenStateSuspendedStart) {
  3145. state = GenStateCompleted;
  3146. throw context.arg;
  3147. }
  3148. context.dispatchException(context.arg);
  3149. } else if (context.method === "return") {
  3150. context.abrupt("return", context.arg);
  3151. }
  3152. state = GenStateExecuting;
  3153. var record = tryCatch(innerFn, self, context);
  3154. if (record.type === "normal") {
  3155. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  3156. if (record.arg === ContinueSentinel) {
  3157. continue;
  3158. }
  3159. return {
  3160. value: record.arg,
  3161. done: context.done
  3162. };
  3163. } else if (record.type === "throw") {
  3164. state = GenStateCompleted;
  3165. context.method = "throw";
  3166. context.arg = record.arg;
  3167. }
  3168. }
  3169. };
  3170. }
  3171. function maybeInvokeDelegate(delegate, context) {
  3172. var method = delegate.iterator[context.method];
  3173. if (method === undefined) {
  3174. context.delegate = null;
  3175. if (context.method === "throw") {
  3176. if (delegate.iterator["return"]) {
  3177. context.method = "return";
  3178. context.arg = undefined;
  3179. maybeInvokeDelegate(delegate, context);
  3180. if (context.method === "throw") {
  3181. return ContinueSentinel;
  3182. }
  3183. }
  3184. context.method = "throw";
  3185. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  3186. }
  3187. return ContinueSentinel;
  3188. }
  3189. var record = tryCatch(method, delegate.iterator, context.arg);
  3190. if (record.type === "throw") {
  3191. context.method = "throw";
  3192. context.arg = record.arg;
  3193. context.delegate = null;
  3194. return ContinueSentinel;
  3195. }
  3196. var info = record.arg;
  3197. if (!info) {
  3198. context.method = "throw";
  3199. context.arg = new TypeError("iterator result is not an object");
  3200. context.delegate = null;
  3201. return ContinueSentinel;
  3202. }
  3203. if (info.done) {
  3204. context[delegate.resultName] = info.value;
  3205. context.next = delegate.nextLoc;
  3206. if (context.method !== "return") {
  3207. context.method = "next";
  3208. context.arg = undefined;
  3209. }
  3210. } else {
  3211. return info;
  3212. }
  3213. context.delegate = null;
  3214. return ContinueSentinel;
  3215. }
  3216. defineIteratorMethods(Gp);
  3217. define(Gp, toStringTagSymbol, "Generator");
  3218. define(Gp, iteratorSymbol, function () {
  3219. return this;
  3220. });
  3221. define(Gp, "toString", function () {
  3222. return "[object Generator]";
  3223. });
  3224. function pushTryEntry(locs) {
  3225. var entry = {
  3226. tryLoc: locs[0]
  3227. };
  3228. if (1 in locs) {
  3229. entry.catchLoc = locs[1];
  3230. }
  3231. if (2 in locs) {
  3232. entry.finallyLoc = locs[2];
  3233. entry.afterLoc = locs[3];
  3234. }
  3235. this.tryEntries.push(entry);
  3236. }
  3237. function resetTryEntry(entry) {
  3238. var record = entry.completion || {};
  3239. record.type = "normal";
  3240. delete record.arg;
  3241. entry.completion = record;
  3242. }
  3243. function Context(tryLocsList) {
  3244. this.tryEntries = [{
  3245. tryLoc: "root"
  3246. }];
  3247. tryLocsList.forEach(pushTryEntry, this);
  3248. this.reset(true);
  3249. }
  3250. exports.keys = function (object) {
  3251. var keys = [];
  3252. for (var key in object) {
  3253. keys.push(key);
  3254. }
  3255. keys.reverse();
  3256. return function next() {
  3257. while (keys.length) {
  3258. var key = keys.pop();
  3259. if (key in object) {
  3260. next.value = key;
  3261. next.done = false;
  3262. return next;
  3263. }
  3264. }
  3265. next.done = true;
  3266. return next;
  3267. };
  3268. };
  3269. function values(iterable) {
  3270. if (iterable) {
  3271. var iteratorMethod = iterable[iteratorSymbol];
  3272. if (iteratorMethod) {
  3273. return iteratorMethod.call(iterable);
  3274. }
  3275. if (typeof iterable.next === "function") {
  3276. return iterable;
  3277. }
  3278. if (!isNaN(iterable.length)) {
  3279. var i = -1,
  3280. next = function next() {
  3281. while (++i < iterable.length) {
  3282. if (hasOwn.call(iterable, i)) {
  3283. next.value = iterable[i];
  3284. next.done = false;
  3285. return next;
  3286. }
  3287. }
  3288. next.value = undefined;
  3289. next.done = true;
  3290. return next;
  3291. };
  3292. return next.next = next;
  3293. }
  3294. }
  3295. return {
  3296. next: doneResult
  3297. };
  3298. }
  3299. exports.values = values;
  3300. function doneResult() {
  3301. return {
  3302. value: undefined,
  3303. done: true
  3304. };
  3305. }
  3306. Context.prototype = {
  3307. constructor: Context,
  3308. reset: function reset(skipTempReset) {
  3309. this.prev = 0;
  3310. this.next = 0;
  3311. this.sent = this._sent = undefined;
  3312. this.done = false;
  3313. this.delegate = null;
  3314. this.method = "next";
  3315. this.arg = undefined;
  3316. this.tryEntries.forEach(resetTryEntry);
  3317. if (!skipTempReset) {
  3318. for (var name in this) {
  3319. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  3320. this[name] = undefined;
  3321. }
  3322. }
  3323. }
  3324. },
  3325. stop: function stop() {
  3326. this.done = true;
  3327. var rootEntry = this.tryEntries[0];
  3328. var rootRecord = rootEntry.completion;
  3329. if (rootRecord.type === "throw") {
  3330. throw rootRecord.arg;
  3331. }
  3332. return this.rval;
  3333. },
  3334. dispatchException: function dispatchException(exception) {
  3335. if (this.done) {
  3336. throw exception;
  3337. }
  3338. var context = this;
  3339. function handle(loc, caught) {
  3340. record.type = "throw";
  3341. record.arg = exception;
  3342. context.next = loc;
  3343. if (caught) {
  3344. context.method = "next";
  3345. context.arg = undefined;
  3346. }
  3347. return !!caught;
  3348. }
  3349. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3350. var entry = this.tryEntries[i];
  3351. var record = entry.completion;
  3352. if (entry.tryLoc === "root") {
  3353. return handle("end");
  3354. }
  3355. if (entry.tryLoc <= this.prev) {
  3356. var hasCatch = hasOwn.call(entry, "catchLoc");
  3357. var hasFinally = hasOwn.call(entry, "finallyLoc");
  3358. if (hasCatch && hasFinally) {
  3359. if (this.prev < entry.catchLoc) {
  3360. return handle(entry.catchLoc, true);
  3361. } else if (this.prev < entry.finallyLoc) {
  3362. return handle(entry.finallyLoc);
  3363. }
  3364. } else if (hasCatch) {
  3365. if (this.prev < entry.catchLoc) {
  3366. return handle(entry.catchLoc, true);
  3367. }
  3368. } else if (hasFinally) {
  3369. if (this.prev < entry.finallyLoc) {
  3370. return handle(entry.finallyLoc);
  3371. }
  3372. } else {
  3373. throw new Error("try statement without catch or finally");
  3374. }
  3375. }
  3376. }
  3377. },
  3378. abrupt: function abrupt(type, arg) {
  3379. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3380. var entry = this.tryEntries[i];
  3381. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  3382. var finallyEntry = entry;
  3383. break;
  3384. }
  3385. }
  3386. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  3387. finallyEntry = null;
  3388. }
  3389. var record = finallyEntry ? finallyEntry.completion : {};
  3390. record.type = type;
  3391. record.arg = arg;
  3392. if (finallyEntry) {
  3393. this.method = "next";
  3394. this.next = finallyEntry.finallyLoc;
  3395. return ContinueSentinel;
  3396. }
  3397. return this.complete(record);
  3398. },
  3399. complete: function complete(record, afterLoc) {
  3400. if (record.type === "throw") {
  3401. throw record.arg;
  3402. }
  3403. if (record.type === "break" || record.type === "continue") {
  3404. this.next = record.arg;
  3405. } else if (record.type === "return") {
  3406. this.rval = this.arg = record.arg;
  3407. this.method = "return";
  3408. this.next = "end";
  3409. } else if (record.type === "normal" && afterLoc) {
  3410. this.next = afterLoc;
  3411. }
  3412. return ContinueSentinel;
  3413. },
  3414. finish: function finish(finallyLoc) {
  3415. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3416. var entry = this.tryEntries[i];
  3417. if (entry.finallyLoc === finallyLoc) {
  3418. this.complete(entry.completion, entry.afterLoc);
  3419. resetTryEntry(entry);
  3420. return ContinueSentinel;
  3421. }
  3422. }
  3423. },
  3424. "catch": function _catch(tryLoc) {
  3425. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3426. var entry = this.tryEntries[i];
  3427. if (entry.tryLoc === tryLoc) {
  3428. var record = entry.completion;
  3429. if (record.type === "throw") {
  3430. var thrown = record.arg;
  3431. resetTryEntry(entry);
  3432. }
  3433. return thrown;
  3434. }
  3435. }
  3436. throw new Error("illegal catch attempt");
  3437. },
  3438. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  3439. this.delegate = {
  3440. iterator: values(iterable),
  3441. resultName: resultName,
  3442. nextLoc: nextLoc
  3443. };
  3444. if (this.method === "next") {
  3445. this.arg = undefined;
  3446. }
  3447. return ContinueSentinel;
  3448. }
  3449. };
  3450. return exports;
  3451. }(( false ? 0 : _typeof(module)) === "object" ? module.exports : {});
  3452. try {
  3453. regeneratorRuntime = runtime;
  3454. } catch (accidentalStrictMode) {
  3455. if ((typeof globalThis === "undefined" ? "undefined" : _typeof(globalThis)) === "object") {
  3456. globalThis.regeneratorRuntime = runtime;
  3457. } else {
  3458. Function("r", "regeneratorRuntime = r")(runtime);
  3459. }
  3460. }
  3461. /***/ }),
  3462. /* 5 */
  3463. /***/ ((__unused_webpack_module, exports) => {
  3464. Object.defineProperty(exports, "__esModule", ({
  3465. value: true
  3466. }));
  3467. exports.animationStarted = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports.TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports.SCROLLBAR_PADDING = exports.RenderingStates = exports.RendererType = exports.ProgressBar = exports.PresentationModeState = exports.OutputScale = exports.MIN_SCALE = exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.DEFAULT_SCALE_VALUE = exports.DEFAULT_SCALE_DELTA = exports.DEFAULT_SCALE = exports.AutoPrintRegExp = void 0;
  3468. exports.apiPageLayoutToViewerModes = apiPageLayoutToViewerModes;
  3469. exports.apiPageModeToSidebarView = apiPageModeToSidebarView;
  3470. exports.approximateFraction = approximateFraction;
  3471. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  3472. exports.binarySearchFirstItem = binarySearchFirstItem;
  3473. exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
  3474. exports.getPageSizeInches = getPageSizeInches;
  3475. exports.getVisibleElements = getVisibleElements;
  3476. exports.isPortraitOrientation = isPortraitOrientation;
  3477. exports.isValidRotation = isValidRotation;
  3478. exports.isValidScrollMode = isValidScrollMode;
  3479. exports.isValidSpreadMode = isValidSpreadMode;
  3480. exports.noContextMenuHandler = noContextMenuHandler;
  3481. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  3482. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  3483. exports.parseQueryString = parseQueryString;
  3484. exports.removeNullCharacters = removeNullCharacters;
  3485. exports.roundToDivide = roundToDivide;
  3486. exports.scrollIntoView = scrollIntoView;
  3487. exports.watchScroll = watchScroll;
  3488. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  3489. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  3490. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  3491. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  3492. 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."); }
  3493. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
  3494. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  3495. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
  3496. 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); }
  3497. 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; }
  3498. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3499. 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); } }
  3500. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  3501. var DEFAULT_SCALE_VALUE = "auto";
  3502. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  3503. var DEFAULT_SCALE = 1.0;
  3504. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  3505. var DEFAULT_SCALE_DELTA = 1.1;
  3506. exports.DEFAULT_SCALE_DELTA = DEFAULT_SCALE_DELTA;
  3507. var MIN_SCALE = 0.1;
  3508. exports.MIN_SCALE = MIN_SCALE;
  3509. var MAX_SCALE = 10.0;
  3510. exports.MAX_SCALE = MAX_SCALE;
  3511. var UNKNOWN_SCALE = 0;
  3512. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  3513. var MAX_AUTO_SCALE = 1.25;
  3514. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  3515. var SCROLLBAR_PADDING = 40;
  3516. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  3517. var VERTICAL_PADDING = 5;
  3518. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  3519. var RenderingStates = {
  3520. INITIAL: 0,
  3521. RUNNING: 1,
  3522. PAUSED: 2,
  3523. FINISHED: 3
  3524. };
  3525. exports.RenderingStates = RenderingStates;
  3526. var PresentationModeState = {
  3527. UNKNOWN: 0,
  3528. NORMAL: 1,
  3529. CHANGING: 2,
  3530. FULLSCREEN: 3
  3531. };
  3532. exports.PresentationModeState = PresentationModeState;
  3533. var SidebarView = {
  3534. UNKNOWN: -1,
  3535. NONE: 0,
  3536. THUMBS: 1,
  3537. OUTLINE: 2,
  3538. ATTACHMENTS: 3,
  3539. LAYERS: 4
  3540. };
  3541. exports.SidebarView = SidebarView;
  3542. var RendererType = {
  3543. CANVAS: "canvas",
  3544. SVG: "svg"
  3545. };
  3546. exports.RendererType = RendererType;
  3547. var TextLayerMode = {
  3548. DISABLE: 0,
  3549. ENABLE: 1,
  3550. ENABLE_ENHANCE: 2
  3551. };
  3552. exports.TextLayerMode = TextLayerMode;
  3553. var ScrollMode = {
  3554. UNKNOWN: -1,
  3555. VERTICAL: 0,
  3556. HORIZONTAL: 1,
  3557. WRAPPED: 2,
  3558. PAGE: 3
  3559. };
  3560. exports.ScrollMode = ScrollMode;
  3561. var SpreadMode = {
  3562. UNKNOWN: -1,
  3563. NONE: 0,
  3564. ODD: 1,
  3565. EVEN: 2
  3566. };
  3567. exports.SpreadMode = SpreadMode;
  3568. var AutoPrintRegExp = /\bprint\s*\(/;
  3569. exports.AutoPrintRegExp = AutoPrintRegExp;
  3570. var OutputScale = /*#__PURE__*/function () {
  3571. function OutputScale() {
  3572. _classCallCheck(this, OutputScale);
  3573. var pixelRatio = window.devicePixelRatio || 1;
  3574. this.sx = pixelRatio;
  3575. this.sy = pixelRatio;
  3576. }
  3577. _createClass(OutputScale, [{
  3578. key: "scaled",
  3579. get: function get() {
  3580. return this.sx !== 1 || this.sy !== 1;
  3581. }
  3582. }]);
  3583. return OutputScale;
  3584. }();
  3585. exports.OutputScale = OutputScale;
  3586. function scrollIntoView(element, spot) {
  3587. var scrollMatches = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3588. var parent = element.offsetParent;
  3589. if (!parent) {
  3590. console.error("offsetParent is not set -- cannot scroll");
  3591. return;
  3592. }
  3593. var offsetY = element.offsetTop + element.clientTop;
  3594. var offsetX = element.offsetLeft + element.clientLeft;
  3595. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || scrollMatches && (parent.classList.contains("markedContent") || getComputedStyle(parent).overflow === "hidden")) {
  3596. offsetY += parent.offsetTop;
  3597. offsetX += parent.offsetLeft;
  3598. parent = parent.offsetParent;
  3599. if (!parent) {
  3600. return;
  3601. }
  3602. }
  3603. if (spot) {
  3604. if (spot.top !== undefined) {
  3605. offsetY += spot.top;
  3606. }
  3607. if (spot.left !== undefined) {
  3608. offsetX += spot.left;
  3609. parent.scrollLeft = offsetX;
  3610. }
  3611. }
  3612. parent.scrollTop = offsetY;
  3613. }
  3614. function watchScroll(viewAreaElement, callback) {
  3615. var debounceScroll = function debounceScroll(evt) {
  3616. if (rAF) {
  3617. return;
  3618. }
  3619. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  3620. rAF = null;
  3621. var currentX = viewAreaElement.scrollLeft;
  3622. var lastX = state.lastX;
  3623. if (currentX !== lastX) {
  3624. state.right = currentX > lastX;
  3625. }
  3626. state.lastX = currentX;
  3627. var currentY = viewAreaElement.scrollTop;
  3628. var lastY = state.lastY;
  3629. if (currentY !== lastY) {
  3630. state.down = currentY > lastY;
  3631. }
  3632. state.lastY = currentY;
  3633. callback(state);
  3634. });
  3635. };
  3636. var state = {
  3637. right: true,
  3638. down: true,
  3639. lastX: viewAreaElement.scrollLeft,
  3640. lastY: viewAreaElement.scrollTop,
  3641. _eventHandler: debounceScroll
  3642. };
  3643. var rAF = null;
  3644. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  3645. return state;
  3646. }
  3647. function parseQueryString(query) {
  3648. var params = new Map();
  3649. var _iterator = _createForOfIteratorHelper(new URLSearchParams(query)),
  3650. _step;
  3651. try {
  3652. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  3653. var _step$value = _slicedToArray(_step.value, 2),
  3654. key = _step$value[0],
  3655. value = _step$value[1];
  3656. params.set(key.toLowerCase(), value);
  3657. }
  3658. } catch (err) {
  3659. _iterator.e(err);
  3660. } finally {
  3661. _iterator.f();
  3662. }
  3663. return params;
  3664. }
  3665. var NullCharactersRegExp = /\x00/g;
  3666. var InvisibleCharactersRegExp = /[\x01-\x1F]/g;
  3667. function removeNullCharacters(str) {
  3668. var replaceInvisible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  3669. if (typeof str !== "string") {
  3670. console.error("The argument must be a string.");
  3671. return str;
  3672. }
  3673. if (replaceInvisible) {
  3674. str = str.replace(InvisibleCharactersRegExp, " ");
  3675. }
  3676. return str.replace(NullCharactersRegExp, "");
  3677. }
  3678. function binarySearchFirstItem(items, condition) {
  3679. var start = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  3680. var minIndex = start;
  3681. var maxIndex = items.length - 1;
  3682. if (maxIndex < 0 || !condition(items[maxIndex])) {
  3683. return items.length;
  3684. }
  3685. if (condition(items[minIndex])) {
  3686. return minIndex;
  3687. }
  3688. while (minIndex < maxIndex) {
  3689. var currentIndex = minIndex + maxIndex >> 1;
  3690. var currentItem = items[currentIndex];
  3691. if (condition(currentItem)) {
  3692. maxIndex = currentIndex;
  3693. } else {
  3694. minIndex = currentIndex + 1;
  3695. }
  3696. }
  3697. return minIndex;
  3698. }
  3699. function approximateFraction(x) {
  3700. if (Math.floor(x) === x) {
  3701. return [x, 1];
  3702. }
  3703. var xinv = 1 / x;
  3704. var limit = 8;
  3705. if (xinv > limit) {
  3706. return [1, limit];
  3707. } else if (Math.floor(xinv) === xinv) {
  3708. return [1, xinv];
  3709. }
  3710. var x_ = x > 1 ? xinv : x;
  3711. var a = 0,
  3712. b = 1,
  3713. c = 1,
  3714. d = 1;
  3715. while (true) {
  3716. var p = a + c,
  3717. q = b + d;
  3718. if (q > limit) {
  3719. break;
  3720. }
  3721. if (x_ <= p / q) {
  3722. c = p;
  3723. d = q;
  3724. } else {
  3725. a = p;
  3726. b = q;
  3727. }
  3728. }
  3729. var result;
  3730. if (x_ - a / b < c / d - x_) {
  3731. result = x_ === x ? [a, b] : [b, a];
  3732. } else {
  3733. result = x_ === x ? [c, d] : [d, c];
  3734. }
  3735. return result;
  3736. }
  3737. function roundToDivide(x, div) {
  3738. var r = x % div;
  3739. return r === 0 ? x : Math.round(x - r + div);
  3740. }
  3741. function getPageSizeInches(_ref) {
  3742. var view = _ref.view,
  3743. userUnit = _ref.userUnit,
  3744. rotate = _ref.rotate;
  3745. var _view = _slicedToArray(view, 4),
  3746. x1 = _view[0],
  3747. y1 = _view[1],
  3748. x2 = _view[2],
  3749. y2 = _view[3];
  3750. var changeOrientation = rotate % 180 !== 0;
  3751. var width = (x2 - x1) / 72 * userUnit;
  3752. var height = (y2 - y1) / 72 * userUnit;
  3753. return {
  3754. width: changeOrientation ? height : width,
  3755. height: changeOrientation ? width : height
  3756. };
  3757. }
  3758. function backtrackBeforeAllVisibleElements(index, views, top) {
  3759. if (index < 2) {
  3760. return index;
  3761. }
  3762. var elt = views[index].div;
  3763. var pageTop = elt.offsetTop + elt.clientTop;
  3764. if (pageTop >= top) {
  3765. elt = views[index - 1].div;
  3766. pageTop = elt.offsetTop + elt.clientTop;
  3767. }
  3768. for (var i = index - 2; i >= 0; --i) {
  3769. elt = views[i].div;
  3770. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  3771. break;
  3772. }
  3773. index = i;
  3774. }
  3775. return index;
  3776. }
  3777. function getVisibleElements(_ref2) {
  3778. var scrollEl = _ref2.scrollEl,
  3779. views = _ref2.views,
  3780. _ref2$sortByVisibilit = _ref2.sortByVisibility,
  3781. sortByVisibility = _ref2$sortByVisibilit === void 0 ? false : _ref2$sortByVisibilit,
  3782. _ref2$horizontal = _ref2.horizontal,
  3783. horizontal = _ref2$horizontal === void 0 ? false : _ref2$horizontal,
  3784. _ref2$rtl = _ref2.rtl,
  3785. rtl = _ref2$rtl === void 0 ? false : _ref2$rtl;
  3786. var top = scrollEl.scrollTop,
  3787. bottom = top + scrollEl.clientHeight;
  3788. var left = scrollEl.scrollLeft,
  3789. right = left + scrollEl.clientWidth;
  3790. function isElementBottomAfterViewTop(view) {
  3791. var element = view.div;
  3792. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  3793. return elementBottom > top;
  3794. }
  3795. function isElementNextAfterViewHorizontally(view) {
  3796. var element = view.div;
  3797. var elementLeft = element.offsetLeft + element.clientLeft;
  3798. var elementRight = elementLeft + element.clientWidth;
  3799. return rtl ? elementLeft < right : elementRight > left;
  3800. }
  3801. var visible = [],
  3802. ids = new Set(),
  3803. numViews = views.length;
  3804. var firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  3805. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  3806. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  3807. }
  3808. var lastEdge = horizontal ? right : -1;
  3809. for (var i = firstVisibleElementInd; i < numViews; i++) {
  3810. var view = views[i],
  3811. element = view.div;
  3812. var currentWidth = element.offsetLeft + element.clientLeft;
  3813. var currentHeight = element.offsetTop + element.clientTop;
  3814. var viewWidth = element.clientWidth,
  3815. viewHeight = element.clientHeight;
  3816. var viewRight = currentWidth + viewWidth;
  3817. var viewBottom = currentHeight + viewHeight;
  3818. if (lastEdge === -1) {
  3819. if (viewBottom >= bottom) {
  3820. lastEdge = viewBottom;
  3821. }
  3822. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  3823. break;
  3824. }
  3825. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  3826. continue;
  3827. }
  3828. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  3829. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  3830. var fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  3831. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  3832. var percent = fractionHeight * fractionWidth * 100 | 0;
  3833. visible.push({
  3834. id: view.id,
  3835. x: currentWidth,
  3836. y: currentHeight,
  3837. view: view,
  3838. percent: percent,
  3839. widthPercent: fractionWidth * 100 | 0
  3840. });
  3841. ids.add(view.id);
  3842. }
  3843. var first = visible[0],
  3844. last = visible[visible.length - 1];
  3845. if (sortByVisibility) {
  3846. visible.sort(function (a, b) {
  3847. var pc = a.percent - b.percent;
  3848. if (Math.abs(pc) > 0.001) {
  3849. return -pc;
  3850. }
  3851. return a.id - b.id;
  3852. });
  3853. }
  3854. return {
  3855. first: first,
  3856. last: last,
  3857. views: visible,
  3858. ids: ids
  3859. };
  3860. }
  3861. function noContextMenuHandler(evt) {
  3862. evt.preventDefault();
  3863. }
  3864. function normalizeWheelEventDirection(evt) {
  3865. var delta = Math.hypot(evt.deltaX, evt.deltaY);
  3866. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  3867. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  3868. delta = -delta;
  3869. }
  3870. return delta;
  3871. }
  3872. function normalizeWheelEventDelta(evt) {
  3873. var delta = normalizeWheelEventDirection(evt);
  3874. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  3875. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  3876. var MOUSE_PIXELS_PER_LINE = 30;
  3877. var MOUSE_LINES_PER_PAGE = 30;
  3878. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  3879. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  3880. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  3881. delta /= MOUSE_LINES_PER_PAGE;
  3882. }
  3883. return delta;
  3884. }
  3885. function isValidRotation(angle) {
  3886. return Number.isInteger(angle) && angle % 90 === 0;
  3887. }
  3888. function isValidScrollMode(mode) {
  3889. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  3890. }
  3891. function isValidSpreadMode(mode) {
  3892. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  3893. }
  3894. function isPortraitOrientation(size) {
  3895. return size.width <= size.height;
  3896. }
  3897. var animationStarted = new Promise(function (resolve) {
  3898. window.requestAnimationFrame(resolve);
  3899. });
  3900. exports.animationStarted = animationStarted;
  3901. function clamp(v, min, max) {
  3902. return Math.min(Math.max(v, min), max);
  3903. }
  3904. var _updateBar = /*#__PURE__*/new WeakSet();
  3905. var ProgressBar = /*#__PURE__*/function () {
  3906. function ProgressBar(id) {
  3907. _classCallCheck(this, ProgressBar);
  3908. _classPrivateMethodInitSpec(this, _updateBar);
  3909. if (arguments.length > 1) {
  3910. throw new Error("ProgressBar no longer accepts any additional options, " + "please use CSS rules to modify its appearance instead.");
  3911. }
  3912. this.visible = true;
  3913. this.div = document.querySelector(id + " .progress");
  3914. this.bar = this.div.parentNode;
  3915. this.percent = 0;
  3916. }
  3917. _createClass(ProgressBar, [{
  3918. key: "percent",
  3919. get: function get() {
  3920. return this._percent;
  3921. },
  3922. set: function set(val) {
  3923. this._indeterminate = isNaN(val);
  3924. this._percent = clamp(val, 0, 100);
  3925. _classPrivateMethodGet(this, _updateBar, _updateBar2).call(this);
  3926. }
  3927. }, {
  3928. key: "setWidth",
  3929. value: function setWidth(viewer) {
  3930. if (!viewer) {
  3931. return;
  3932. }
  3933. var container = viewer.parentNode;
  3934. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  3935. if (scrollbarWidth > 0) {
  3936. var doc = document.documentElement;
  3937. doc.style.setProperty("--progressBar-end-offset", "".concat(scrollbarWidth, "px"));
  3938. }
  3939. }
  3940. }, {
  3941. key: "hide",
  3942. value: function hide() {
  3943. if (!this.visible) {
  3944. return;
  3945. }
  3946. this.visible = false;
  3947. this.bar.classList.add("hidden");
  3948. }
  3949. }, {
  3950. key: "show",
  3951. value: function show() {
  3952. if (this.visible) {
  3953. return;
  3954. }
  3955. this.visible = true;
  3956. this.bar.classList.remove("hidden");
  3957. }
  3958. }]);
  3959. return ProgressBar;
  3960. }();
  3961. exports.ProgressBar = ProgressBar;
  3962. function _updateBar2() {
  3963. if (this._indeterminate) {
  3964. this.div.classList.add("indeterminate");
  3965. return;
  3966. }
  3967. this.div.classList.remove("indeterminate");
  3968. var doc = document.documentElement;
  3969. doc.style.setProperty("--progressBar-percent", "".concat(this._percent, "%"));
  3970. }
  3971. function getActiveOrFocusedElement() {
  3972. var curRoot = document;
  3973. var curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  3974. while ((_curActiveOrFocused = curActiveOrFocused) !== null && _curActiveOrFocused !== void 0 && _curActiveOrFocused.shadowRoot) {
  3975. var _curActiveOrFocused;
  3976. curRoot = curActiveOrFocused.shadowRoot;
  3977. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  3978. }
  3979. return curActiveOrFocused;
  3980. }
  3981. function apiPageLayoutToViewerModes(layout) {
  3982. var scrollMode = ScrollMode.VERTICAL,
  3983. spreadMode = SpreadMode.NONE;
  3984. switch (layout) {
  3985. case "SinglePage":
  3986. scrollMode = ScrollMode.PAGE;
  3987. break;
  3988. case "OneColumn":
  3989. break;
  3990. case "TwoPageLeft":
  3991. scrollMode = ScrollMode.PAGE;
  3992. case "TwoColumnLeft":
  3993. spreadMode = SpreadMode.ODD;
  3994. break;
  3995. case "TwoPageRight":
  3996. scrollMode = ScrollMode.PAGE;
  3997. case "TwoColumnRight":
  3998. spreadMode = SpreadMode.EVEN;
  3999. break;
  4000. }
  4001. return {
  4002. scrollMode: scrollMode,
  4003. spreadMode: spreadMode
  4004. };
  4005. }
  4006. function apiPageModeToSidebarView(mode) {
  4007. switch (mode) {
  4008. case "UseNone":
  4009. return SidebarView.NONE;
  4010. case "UseThumbs":
  4011. return SidebarView.THUMBS;
  4012. case "UseOutlines":
  4013. return SidebarView.OUTLINE;
  4014. case "UseAttachments":
  4015. return SidebarView.ATTACHMENTS;
  4016. case "UseOC":
  4017. return SidebarView.LAYERS;
  4018. }
  4019. return SidebarView.NONE;
  4020. }
  4021. /***/ }),
  4022. /* 6 */
  4023. /***/ ((__unused_webpack_module, exports) => {
  4024. Object.defineProperty(exports, "__esModule", ({
  4025. value: true
  4026. }));
  4027. exports.WaitOnType = exports.EventBus = exports.AutomationEventBus = void 0;
  4028. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  4029. 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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
  4030. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  4031. 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); }; }
  4032. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  4033. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  4034. 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; } }
  4035. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  4036. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
  4037. 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); }
  4038. 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; }
  4039. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4040. 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); } }
  4041. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  4042. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  4043. var WaitOnType = {
  4044. EVENT: "event",
  4045. TIMEOUT: "timeout"
  4046. };
  4047. exports.WaitOnType = WaitOnType;
  4048. function waitOnEventOrTimeout(_ref) {
  4049. var target = _ref.target,
  4050. name = _ref.name,
  4051. _ref$delay = _ref.delay,
  4052. delay = _ref$delay === void 0 ? 0 : _ref$delay;
  4053. return new Promise(function (resolve, reject) {
  4054. if (_typeof(target) !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  4055. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  4056. }
  4057. function handler(type) {
  4058. if (target instanceof EventBus) {
  4059. target._off(name, eventHandler);
  4060. } else {
  4061. target.removeEventListener(name, eventHandler);
  4062. }
  4063. if (timeout) {
  4064. clearTimeout(timeout);
  4065. }
  4066. resolve(type);
  4067. }
  4068. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  4069. if (target instanceof EventBus) {
  4070. target._on(name, eventHandler);
  4071. } else {
  4072. target.addEventListener(name, eventHandler);
  4073. }
  4074. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  4075. var timeout = setTimeout(timeoutHandler, delay);
  4076. });
  4077. }
  4078. var EventBus = /*#__PURE__*/function () {
  4079. function EventBus() {
  4080. _classCallCheck(this, EventBus);
  4081. this._listeners = Object.create(null);
  4082. }
  4083. _createClass(EventBus, [{
  4084. key: "on",
  4085. value: function on(eventName, listener) {
  4086. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4087. this._on(eventName, listener, {
  4088. external: true,
  4089. once: options === null || options === void 0 ? void 0 : options.once
  4090. });
  4091. }
  4092. }, {
  4093. key: "off",
  4094. value: function off(eventName, listener) {
  4095. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4096. this._off(eventName, listener, {
  4097. external: true,
  4098. once: options === null || options === void 0 ? void 0 : options.once
  4099. });
  4100. }
  4101. }, {
  4102. key: "dispatch",
  4103. value: function dispatch(eventName, data) {
  4104. var eventListeners = this._listeners[eventName];
  4105. if (!eventListeners || eventListeners.length === 0) {
  4106. return;
  4107. }
  4108. var externalListeners;
  4109. var _iterator = _createForOfIteratorHelper(eventListeners.slice(0)),
  4110. _step;
  4111. try {
  4112. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  4113. var _step$value = _step.value,
  4114. _listener = _step$value.listener,
  4115. external = _step$value.external,
  4116. once = _step$value.once;
  4117. if (once) {
  4118. this._off(eventName, _listener);
  4119. }
  4120. if (external) {
  4121. (externalListeners || (externalListeners = [])).push(_listener);
  4122. continue;
  4123. }
  4124. _listener(data);
  4125. }
  4126. } catch (err) {
  4127. _iterator.e(err);
  4128. } finally {
  4129. _iterator.f();
  4130. }
  4131. if (externalListeners) {
  4132. var _iterator2 = _createForOfIteratorHelper(externalListeners),
  4133. _step2;
  4134. try {
  4135. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  4136. var listener = _step2.value;
  4137. listener(data);
  4138. }
  4139. } catch (err) {
  4140. _iterator2.e(err);
  4141. } finally {
  4142. _iterator2.f();
  4143. }
  4144. externalListeners = null;
  4145. }
  4146. }
  4147. }, {
  4148. key: "_on",
  4149. value: function _on(eventName, listener) {
  4150. var _this$_listeners;
  4151. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4152. var eventListeners = (_this$_listeners = this._listeners)[eventName] || (_this$_listeners[eventName] = []);
  4153. eventListeners.push({
  4154. listener: listener,
  4155. external: (options === null || options === void 0 ? void 0 : options.external) === true,
  4156. once: (options === null || options === void 0 ? void 0 : options.once) === true
  4157. });
  4158. }
  4159. }, {
  4160. key: "_off",
  4161. value: function _off(eventName, listener) {
  4162. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4163. var eventListeners = this._listeners[eventName];
  4164. if (!eventListeners) {
  4165. return;
  4166. }
  4167. for (var i = 0, ii = eventListeners.length; i < ii; i++) {
  4168. if (eventListeners[i].listener === listener) {
  4169. eventListeners.splice(i, 1);
  4170. return;
  4171. }
  4172. }
  4173. }
  4174. }]);
  4175. return EventBus;
  4176. }();
  4177. exports.EventBus = EventBus;
  4178. var AutomationEventBus = /*#__PURE__*/function (_EventBus) {
  4179. _inherits(AutomationEventBus, _EventBus);
  4180. var _super = _createSuper(AutomationEventBus);
  4181. function AutomationEventBus() {
  4182. _classCallCheck(this, AutomationEventBus);
  4183. return _super.apply(this, arguments);
  4184. }
  4185. _createClass(AutomationEventBus, [{
  4186. key: "dispatch",
  4187. value: function dispatch(eventName, data) {
  4188. throw new Error("Not implemented: AutomationEventBus.dispatch");
  4189. }
  4190. }]);
  4191. return AutomationEventBus;
  4192. }(EventBus);
  4193. exports.AutomationEventBus = AutomationEventBus;
  4194. /***/ }),
  4195. /* 7 */
  4196. /***/ ((module) => {
  4197. var pdfjsLib;
  4198. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  4199. pdfjsLib = window["pdfjs-dist/build/pdf"];
  4200. } else {
  4201. pdfjsLib = require("../build/pdf.js");
  4202. }
  4203. module.exports = pdfjsLib;
  4204. /***/ }),
  4205. /* 8 */
  4206. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4207. Object.defineProperty(exports, "__esModule", ({
  4208. value: true
  4209. }));
  4210. exports.PDFCursorTools = exports.CursorTool = void 0;
  4211. var _grab_to_pan = __webpack_require__(9);
  4212. var _ui_utils = __webpack_require__(5);
  4213. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4214. 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); } }
  4215. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  4216. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  4217. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  4218. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  4219. var CursorTool = {
  4220. SELECT: 0,
  4221. HAND: 1,
  4222. ZOOM: 2
  4223. };
  4224. exports.CursorTool = CursorTool;
  4225. var _dispatchEvent = /*#__PURE__*/new WeakSet();
  4226. var _addEventListeners = /*#__PURE__*/new WeakSet();
  4227. var PDFCursorTools = /*#__PURE__*/function () {
  4228. function PDFCursorTools(_ref) {
  4229. var _this = this;
  4230. var container = _ref.container,
  4231. eventBus = _ref.eventBus,
  4232. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  4233. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT : _ref$cursorToolOnLoad;
  4234. _classCallCheck(this, PDFCursorTools);
  4235. _classPrivateMethodInitSpec(this, _addEventListeners);
  4236. _classPrivateMethodInitSpec(this, _dispatchEvent);
  4237. this.container = container;
  4238. this.eventBus = eventBus;
  4239. this.active = CursorTool.SELECT;
  4240. this.activeBeforePresentationMode = null;
  4241. this.handTool = new _grab_to_pan.GrabToPan({
  4242. element: this.container
  4243. });
  4244. _classPrivateMethodGet(this, _addEventListeners, _addEventListeners2).call(this);
  4245. Promise.resolve().then(function () {
  4246. _this.switchTool(cursorToolOnLoad);
  4247. });
  4248. }
  4249. _createClass(PDFCursorTools, [{
  4250. key: "activeTool",
  4251. get: function get() {
  4252. return this.active;
  4253. }
  4254. }, {
  4255. key: "switchTool",
  4256. value: function switchTool(tool) {
  4257. var _this2 = this;
  4258. if (this.activeBeforePresentationMode !== null) {
  4259. return;
  4260. }
  4261. if (tool === this.active) {
  4262. return;
  4263. }
  4264. var disableActiveTool = function disableActiveTool() {
  4265. switch (_this2.active) {
  4266. case CursorTool.SELECT:
  4267. break;
  4268. case CursorTool.HAND:
  4269. _this2.handTool.deactivate();
  4270. break;
  4271. case CursorTool.ZOOM:
  4272. }
  4273. };
  4274. switch (tool) {
  4275. case CursorTool.SELECT:
  4276. disableActiveTool();
  4277. break;
  4278. case CursorTool.HAND:
  4279. disableActiveTool();
  4280. this.handTool.activate();
  4281. break;
  4282. case CursorTool.ZOOM:
  4283. default:
  4284. console.error("switchTool: \"".concat(tool, "\" is an unsupported value."));
  4285. return;
  4286. }
  4287. this.active = tool;
  4288. _classPrivateMethodGet(this, _dispatchEvent, _dispatchEvent2).call(this);
  4289. }
  4290. }]);
  4291. return PDFCursorTools;
  4292. }();
  4293. exports.PDFCursorTools = PDFCursorTools;
  4294. function _dispatchEvent2() {
  4295. this.eventBus.dispatch("cursortoolchanged", {
  4296. source: this,
  4297. tool: this.active
  4298. });
  4299. }
  4300. function _addEventListeners2() {
  4301. var _this3 = this;
  4302. this.eventBus._on("switchcursortool", function (evt) {
  4303. _this3.switchTool(evt.tool);
  4304. });
  4305. this.eventBus._on("presentationmodechanged", function (evt) {
  4306. switch (evt.state) {
  4307. case _ui_utils.PresentationModeState.FULLSCREEN:
  4308. {
  4309. var previouslyActive = _this3.active;
  4310. _this3.switchTool(CursorTool.SELECT);
  4311. _this3.activeBeforePresentationMode = previouslyActive;
  4312. break;
  4313. }
  4314. case _ui_utils.PresentationModeState.NORMAL:
  4315. {
  4316. var _previouslyActive = _this3.activeBeforePresentationMode;
  4317. _this3.activeBeforePresentationMode = null;
  4318. _this3.switchTool(_previouslyActive);
  4319. break;
  4320. }
  4321. }
  4322. });
  4323. }
  4324. /***/ }),
  4325. /* 9 */
  4326. /***/ ((__unused_webpack_module, exports) => {
  4327. Object.defineProperty(exports, "__esModule", ({
  4328. value: true
  4329. }));
  4330. exports.GrabToPan = void 0;
  4331. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4332. 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); } }
  4333. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  4334. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  4335. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  4336. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  4337. var CSS_CLASS_GRAB = "grab-to-pan-grab";
  4338. var _onMouseDown = /*#__PURE__*/new WeakSet();
  4339. var _onMouseMove = /*#__PURE__*/new WeakSet();
  4340. var _endPan = /*#__PURE__*/new WeakSet();
  4341. var GrabToPan = /*#__PURE__*/function () {
  4342. function GrabToPan(options) {
  4343. _classCallCheck(this, GrabToPan);
  4344. _classPrivateMethodInitSpec(this, _endPan);
  4345. _classPrivateMethodInitSpec(this, _onMouseMove);
  4346. _classPrivateMethodInitSpec(this, _onMouseDown);
  4347. this.element = options.element;
  4348. this.document = options.element.ownerDocument;
  4349. if (typeof options.ignoreTarget === "function") {
  4350. this.ignoreTarget = options.ignoreTarget;
  4351. }
  4352. this.onActiveChanged = options.onActiveChanged;
  4353. this.activate = this.activate.bind(this);
  4354. this.deactivate = this.deactivate.bind(this);
  4355. this.toggle = this.toggle.bind(this);
  4356. this._onMouseDown = _classPrivateMethodGet(this, _onMouseDown, _onMouseDown2).bind(this);
  4357. this._onMouseMove = _classPrivateMethodGet(this, _onMouseMove, _onMouseMove2).bind(this);
  4358. this._endPan = _classPrivateMethodGet(this, _endPan, _endPan2).bind(this);
  4359. var overlay = this.overlay = document.createElement("div");
  4360. overlay.className = "grab-to-pan-grabbing";
  4361. }
  4362. _createClass(GrabToPan, [{
  4363. key: "activate",
  4364. value: function activate() {
  4365. if (!this.active) {
  4366. var _this$onActiveChanged;
  4367. this.active = true;
  4368. this.element.addEventListener("mousedown", this._onMouseDown, true);
  4369. this.element.classList.add(CSS_CLASS_GRAB);
  4370. (_this$onActiveChanged = this.onActiveChanged) === null || _this$onActiveChanged === void 0 ? void 0 : _this$onActiveChanged.call(this, true);
  4371. }
  4372. }
  4373. }, {
  4374. key: "deactivate",
  4375. value: function deactivate() {
  4376. if (this.active) {
  4377. var _this$onActiveChanged2;
  4378. this.active = false;
  4379. this.element.removeEventListener("mousedown", this._onMouseDown, true);
  4380. this._endPan();
  4381. this.element.classList.remove(CSS_CLASS_GRAB);
  4382. (_this$onActiveChanged2 = this.onActiveChanged) === null || _this$onActiveChanged2 === void 0 ? void 0 : _this$onActiveChanged2.call(this, false);
  4383. }
  4384. }
  4385. }, {
  4386. key: "toggle",
  4387. value: function toggle() {
  4388. if (this.active) {
  4389. this.deactivate();
  4390. } else {
  4391. this.activate();
  4392. }
  4393. }
  4394. }, {
  4395. key: "ignoreTarget",
  4396. value: function ignoreTarget(node) {
  4397. return node.matches("a[href], a[href] *, input, textarea, button, button *, select, option");
  4398. }
  4399. }]);
  4400. return GrabToPan;
  4401. }();
  4402. exports.GrabToPan = GrabToPan;
  4403. function _onMouseDown2(event) {
  4404. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  4405. return;
  4406. }
  4407. if (event.originalTarget) {
  4408. try {
  4409. event.originalTarget.tagName;
  4410. } catch (e) {
  4411. return;
  4412. }
  4413. }
  4414. this.scrollLeftStart = this.element.scrollLeft;
  4415. this.scrollTopStart = this.element.scrollTop;
  4416. this.clientXStart = event.clientX;
  4417. this.clientYStart = event.clientY;
  4418. this.document.addEventListener("mousemove", this._onMouseMove, true);
  4419. this.document.addEventListener("mouseup", this._endPan, true);
  4420. this.element.addEventListener("scroll", this._endPan, true);
  4421. event.preventDefault();
  4422. event.stopPropagation();
  4423. var focusedElement = document.activeElement;
  4424. if (focusedElement && !focusedElement.contains(event.target)) {
  4425. focusedElement.blur();
  4426. }
  4427. }
  4428. function _onMouseMove2(event) {
  4429. this.element.removeEventListener("scroll", this._endPan, true);
  4430. if (!(event.buttons & 1)) {
  4431. this._endPan();
  4432. return;
  4433. }
  4434. var xDiff = event.clientX - this.clientXStart;
  4435. var yDiff = event.clientY - this.clientYStart;
  4436. var scrollTop = this.scrollTopStart - yDiff;
  4437. var scrollLeft = this.scrollLeftStart - xDiff;
  4438. if (this.element.scrollTo) {
  4439. this.element.scrollTo({
  4440. top: scrollTop,
  4441. left: scrollLeft,
  4442. behavior: "instant"
  4443. });
  4444. } else {
  4445. this.element.scrollTop = scrollTop;
  4446. this.element.scrollLeft = scrollLeft;
  4447. }
  4448. if (!this.overlay.parentNode) {
  4449. document.body.appendChild(this.overlay);
  4450. }
  4451. }
  4452. function _endPan2() {
  4453. this.element.removeEventListener("scroll", this._endPan, true);
  4454. this.document.removeEventListener("mousemove", this._onMouseMove, true);
  4455. this.document.removeEventListener("mouseup", this._endPan, true);
  4456. this.overlay.remove();
  4457. }
  4458. /***/ }),
  4459. /* 10 */
  4460. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4461. Object.defineProperty(exports, "__esModule", ({
  4462. value: true
  4463. }));
  4464. exports.SimpleLinkService = exports.PDFLinkService = exports.LinkTarget = void 0;
  4465. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  4466. var _ui_utils = __webpack_require__(5);
  4467. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4468. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  4469. 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); } }
  4470. 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); }); }; }
  4471. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4472. 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); } }
  4473. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  4474. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  4475. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  4476. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  4477. function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; }
  4478. function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } }
  4479. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  4480. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  4481. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  4482. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  4483. var DEFAULT_LINK_REL = "noopener noreferrer nofollow";
  4484. var LinkTarget = {
  4485. NONE: 0,
  4486. SELF: 1,
  4487. BLANK: 2,
  4488. PARENT: 3,
  4489. TOP: 4
  4490. };
  4491. exports.LinkTarget = LinkTarget;
  4492. function _addLinkAttributes(link) {
  4493. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  4494. url = _ref.url,
  4495. target = _ref.target,
  4496. rel = _ref.rel,
  4497. _ref$enabled = _ref.enabled,
  4498. enabled = _ref$enabled === void 0 ? true : _ref$enabled;
  4499. if (!url || typeof url !== "string") {
  4500. throw new Error('A valid "url" parameter must provided.');
  4501. }
  4502. var urlNullRemoved = (0, _ui_utils.removeNullCharacters)(url);
  4503. if (enabled) {
  4504. link.href = link.title = urlNullRemoved;
  4505. } else {
  4506. link.href = "";
  4507. link.title = "Disabled: ".concat(urlNullRemoved);
  4508. link.onclick = function () {
  4509. return false;
  4510. };
  4511. }
  4512. var targetStr = "";
  4513. switch (target) {
  4514. case LinkTarget.NONE:
  4515. break;
  4516. case LinkTarget.SELF:
  4517. targetStr = "_self";
  4518. break;
  4519. case LinkTarget.BLANK:
  4520. targetStr = "_blank";
  4521. break;
  4522. case LinkTarget.PARENT:
  4523. targetStr = "_parent";
  4524. break;
  4525. case LinkTarget.TOP:
  4526. targetStr = "_top";
  4527. break;
  4528. }
  4529. link.target = targetStr;
  4530. link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
  4531. }
  4532. var _pagesRefCache = /*#__PURE__*/new WeakMap();
  4533. var _goToDestinationHelper = /*#__PURE__*/new WeakSet();
  4534. var PDFLinkService = /*#__PURE__*/function () {
  4535. function PDFLinkService() {
  4536. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  4537. eventBus = _ref2.eventBus,
  4538. _ref2$externalLinkTar = _ref2.externalLinkTarget,
  4539. externalLinkTarget = _ref2$externalLinkTar === void 0 ? null : _ref2$externalLinkTar,
  4540. _ref2$externalLinkRel = _ref2.externalLinkRel,
  4541. externalLinkRel = _ref2$externalLinkRel === void 0 ? null : _ref2$externalLinkRel,
  4542. _ref2$ignoreDestinati = _ref2.ignoreDestinationZoom,
  4543. ignoreDestinationZoom = _ref2$ignoreDestinati === void 0 ? false : _ref2$ignoreDestinati;
  4544. _classCallCheck(this, PDFLinkService);
  4545. _classPrivateMethodInitSpec(this, _goToDestinationHelper);
  4546. _classPrivateFieldInitSpec(this, _pagesRefCache, {
  4547. writable: true,
  4548. value: new Map()
  4549. });
  4550. this.eventBus = eventBus;
  4551. this.externalLinkTarget = externalLinkTarget;
  4552. this.externalLinkRel = externalLinkRel;
  4553. this.externalLinkEnabled = true;
  4554. this._ignoreDestinationZoom = ignoreDestinationZoom;
  4555. this.baseUrl = null;
  4556. this.pdfDocument = null;
  4557. this.pdfViewer = null;
  4558. this.pdfHistory = null;
  4559. }
  4560. _createClass(PDFLinkService, [{
  4561. key: "setDocument",
  4562. value: function setDocument(pdfDocument) {
  4563. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  4564. this.baseUrl = baseUrl;
  4565. this.pdfDocument = pdfDocument;
  4566. _classPrivateFieldGet(this, _pagesRefCache).clear();
  4567. }
  4568. }, {
  4569. key: "setViewer",
  4570. value: function setViewer(pdfViewer) {
  4571. this.pdfViewer = pdfViewer;
  4572. }
  4573. }, {
  4574. key: "setHistory",
  4575. value: function setHistory(pdfHistory) {
  4576. this.pdfHistory = pdfHistory;
  4577. }
  4578. }, {
  4579. key: "pagesCount",
  4580. get: function get() {
  4581. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  4582. }
  4583. }, {
  4584. key: "page",
  4585. get: function get() {
  4586. return this.pdfViewer.currentPageNumber;
  4587. },
  4588. set: function set(value) {
  4589. this.pdfViewer.currentPageNumber = value;
  4590. }
  4591. }, {
  4592. key: "rotation",
  4593. get: function get() {
  4594. return this.pdfViewer.pagesRotation;
  4595. },
  4596. set: function set(value) {
  4597. this.pdfViewer.pagesRotation = value;
  4598. }
  4599. }, {
  4600. key: "goToDestination",
  4601. value: function () {
  4602. var _goToDestination = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(dest) {
  4603. var namedDest, explicitDest;
  4604. return _regenerator["default"].wrap(function _callee$(_context) {
  4605. while (1) {
  4606. switch (_context.prev = _context.next) {
  4607. case 0:
  4608. if (this.pdfDocument) {
  4609. _context.next = 2;
  4610. break;
  4611. }
  4612. return _context.abrupt("return");
  4613. case 2:
  4614. if (!(typeof dest === "string")) {
  4615. _context.next = 9;
  4616. break;
  4617. }
  4618. namedDest = dest;
  4619. _context.next = 6;
  4620. return this.pdfDocument.getDestination(dest);
  4621. case 6:
  4622. explicitDest = _context.sent;
  4623. _context.next = 13;
  4624. break;
  4625. case 9:
  4626. namedDest = null;
  4627. _context.next = 12;
  4628. return dest;
  4629. case 12:
  4630. explicitDest = _context.sent;
  4631. case 13:
  4632. if (Array.isArray(explicitDest)) {
  4633. _context.next = 16;
  4634. break;
  4635. }
  4636. console.error("PDFLinkService.goToDestination: \"".concat(explicitDest, "\" is not ") + "a valid destination array, for dest=\"".concat(dest, "\"."));
  4637. return _context.abrupt("return");
  4638. case 16:
  4639. _classPrivateMethodGet(this, _goToDestinationHelper, _goToDestinationHelper2).call(this, dest, namedDest, explicitDest);
  4640. case 17:
  4641. case "end":
  4642. return _context.stop();
  4643. }
  4644. }
  4645. }, _callee, this);
  4646. }));
  4647. function goToDestination(_x) {
  4648. return _goToDestination.apply(this, arguments);
  4649. }
  4650. return goToDestination;
  4651. }()
  4652. }, {
  4653. key: "goToPage",
  4654. value: function goToPage(val) {
  4655. if (!this.pdfDocument) {
  4656. return;
  4657. }
  4658. var pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
  4659. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  4660. console.error("PDFLinkService.goToPage: \"".concat(val, "\" is not a valid page."));
  4661. return;
  4662. }
  4663. if (this.pdfHistory) {
  4664. this.pdfHistory.pushCurrentPosition();
  4665. this.pdfHistory.pushPage(pageNumber);
  4666. }
  4667. this.pdfViewer.scrollPageIntoView({
  4668. pageNumber: pageNumber
  4669. });
  4670. }
  4671. }, {
  4672. key: "addLinkAttributes",
  4673. value: function addLinkAttributes(link, url) {
  4674. var newWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4675. _addLinkAttributes(link, {
  4676. url: url,
  4677. target: newWindow ? LinkTarget.BLANK : this.externalLinkTarget,
  4678. rel: this.externalLinkRel,
  4679. enabled: this.externalLinkEnabled
  4680. });
  4681. }
  4682. }, {
  4683. key: "getDestinationHash",
  4684. value: function getDestinationHash(dest) {
  4685. if (typeof dest === "string") {
  4686. if (dest.length > 0) {
  4687. return this.getAnchorUrl("#" + escape(dest));
  4688. }
  4689. } else if (Array.isArray(dest)) {
  4690. var str = JSON.stringify(dest);
  4691. if (str.length > 0) {
  4692. return this.getAnchorUrl("#" + escape(str));
  4693. }
  4694. }
  4695. return this.getAnchorUrl("");
  4696. }
  4697. }, {
  4698. key: "getAnchorUrl",
  4699. value: function getAnchorUrl(anchor) {
  4700. return (this.baseUrl || "") + anchor;
  4701. }
  4702. }, {
  4703. key: "setHash",
  4704. value: function setHash(hash) {
  4705. if (!this.pdfDocument) {
  4706. return;
  4707. }
  4708. var pageNumber, dest;
  4709. if (hash.includes("=")) {
  4710. var params = (0, _ui_utils.parseQueryString)(hash);
  4711. if (params.has("search")) {
  4712. this.eventBus.dispatch("findfromurlhash", {
  4713. source: this,
  4714. query: params.get("search").replace(/"/g, ""),
  4715. phraseSearch: params.get("phrase") === "true"
  4716. });
  4717. }
  4718. if (params.has("page")) {
  4719. pageNumber = params.get("page") | 0 || 1;
  4720. }
  4721. if (params.has("zoom")) {
  4722. var zoomArgs = params.get("zoom").split(",");
  4723. var zoomArg = zoomArgs[0];
  4724. var zoomArgNumber = parseFloat(zoomArg);
  4725. if (!zoomArg.includes("Fit")) {
  4726. dest = [null, {
  4727. name: "XYZ"
  4728. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  4729. } else {
  4730. if (zoomArg === "Fit" || zoomArg === "FitB") {
  4731. dest = [null, {
  4732. name: zoomArg
  4733. }];
  4734. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  4735. dest = [null, {
  4736. name: zoomArg
  4737. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  4738. } else if (zoomArg === "FitR") {
  4739. if (zoomArgs.length !== 5) {
  4740. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  4741. } else {
  4742. dest = [null, {
  4743. name: zoomArg
  4744. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  4745. }
  4746. } else {
  4747. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not a valid zoom value."));
  4748. }
  4749. }
  4750. }
  4751. if (dest) {
  4752. this.pdfViewer.scrollPageIntoView({
  4753. pageNumber: pageNumber || this.page,
  4754. destArray: dest,
  4755. allowNegativeOffset: true
  4756. });
  4757. } else if (pageNumber) {
  4758. this.page = pageNumber;
  4759. }
  4760. if (params.has("pagemode")) {
  4761. this.eventBus.dispatch("pagemode", {
  4762. source: this,
  4763. mode: params.get("pagemode")
  4764. });
  4765. }
  4766. if (params.has("nameddest")) {
  4767. this.goToDestination(params.get("nameddest"));
  4768. }
  4769. } else {
  4770. dest = unescape(hash);
  4771. try {
  4772. dest = JSON.parse(dest);
  4773. if (!Array.isArray(dest)) {
  4774. dest = dest.toString();
  4775. }
  4776. } catch (ex) {}
  4777. if (typeof dest === "string" || _classStaticPrivateMethodGet(PDFLinkService, PDFLinkService, _isValidExplicitDestination).call(PDFLinkService, dest)) {
  4778. this.goToDestination(dest);
  4779. return;
  4780. }
  4781. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not a valid destination."));
  4782. }
  4783. }
  4784. }, {
  4785. key: "executeNamedAction",
  4786. value: function executeNamedAction(action) {
  4787. var _this$pdfHistory, _this$pdfHistory2;
  4788. switch (action) {
  4789. case "GoBack":
  4790. (_this$pdfHistory = this.pdfHistory) === null || _this$pdfHistory === void 0 ? void 0 : _this$pdfHistory.back();
  4791. break;
  4792. case "GoForward":
  4793. (_this$pdfHistory2 = this.pdfHistory) === null || _this$pdfHistory2 === void 0 ? void 0 : _this$pdfHistory2.forward();
  4794. break;
  4795. case "NextPage":
  4796. this.pdfViewer.nextPage();
  4797. break;
  4798. case "PrevPage":
  4799. this.pdfViewer.previousPage();
  4800. break;
  4801. case "LastPage":
  4802. this.page = this.pagesCount;
  4803. break;
  4804. case "FirstPage":
  4805. this.page = 1;
  4806. break;
  4807. default:
  4808. break;
  4809. }
  4810. this.eventBus.dispatch("namedaction", {
  4811. source: this,
  4812. action: action
  4813. });
  4814. }
  4815. }, {
  4816. key: "cachePageRef",
  4817. value: function cachePageRef(pageNum, pageRef) {
  4818. if (!pageRef) {
  4819. return;
  4820. }
  4821. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  4822. _classPrivateFieldGet(this, _pagesRefCache).set(refStr, pageNum);
  4823. }
  4824. }, {
  4825. key: "_cachedPageNumber",
  4826. value: function _cachedPageNumber(pageRef) {
  4827. if (!pageRef) {
  4828. return null;
  4829. }
  4830. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  4831. return _classPrivateFieldGet(this, _pagesRefCache).get(refStr) || null;
  4832. }
  4833. }, {
  4834. key: "isPageVisible",
  4835. value: function isPageVisible(pageNumber) {
  4836. return this.pdfViewer.isPageVisible(pageNumber);
  4837. }
  4838. }, {
  4839. key: "isPageCached",
  4840. value: function isPageCached(pageNumber) {
  4841. return this.pdfViewer.isPageCached(pageNumber);
  4842. }
  4843. }]);
  4844. return PDFLinkService;
  4845. }();
  4846. exports.PDFLinkService = PDFLinkService;
  4847. function _goToDestinationHelper2(rawDest) {
  4848. var _this = this;
  4849. var namedDest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  4850. var explicitDest = arguments.length > 2 ? arguments[2] : undefined;
  4851. var destRef = explicitDest[0];
  4852. var pageNumber;
  4853. if (_typeof(destRef) === "object" && destRef !== null) {
  4854. pageNumber = this._cachedPageNumber(destRef);
  4855. if (!pageNumber) {
  4856. this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  4857. _this.cachePageRef(pageIndex + 1, destRef);
  4858. _classPrivateMethodGet(_this, _goToDestinationHelper, _goToDestinationHelper2).call(_this, rawDest, namedDest, explicitDest);
  4859. })["catch"](function () {
  4860. console.error("PDFLinkService.#goToDestinationHelper: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(rawDest, "\"."));
  4861. });
  4862. return;
  4863. }
  4864. } else if (Number.isInteger(destRef)) {
  4865. pageNumber = destRef + 1;
  4866. } else {
  4867. console.error("PDFLinkService.#goToDestinationHelper: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(rawDest, "\"."));
  4868. return;
  4869. }
  4870. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  4871. console.error("PDFLinkService.#goToDestinationHelper: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(rawDest, "\"."));
  4872. return;
  4873. }
  4874. if (this.pdfHistory) {
  4875. this.pdfHistory.pushCurrentPosition();
  4876. this.pdfHistory.push({
  4877. namedDest: namedDest,
  4878. explicitDest: explicitDest,
  4879. pageNumber: pageNumber
  4880. });
  4881. }
  4882. this.pdfViewer.scrollPageIntoView({
  4883. pageNumber: pageNumber,
  4884. destArray: explicitDest,
  4885. ignoreDestinationZoom: this._ignoreDestinationZoom
  4886. });
  4887. }
  4888. function _isValidExplicitDestination(dest) {
  4889. if (!Array.isArray(dest)) {
  4890. return false;
  4891. }
  4892. var destLength = dest.length;
  4893. if (destLength < 2) {
  4894. return false;
  4895. }
  4896. var page = dest[0];
  4897. if (!(_typeof(page) === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  4898. return false;
  4899. }
  4900. var zoom = dest[1];
  4901. if (!(_typeof(zoom) === "object" && typeof zoom.name === "string")) {
  4902. return false;
  4903. }
  4904. var allowNull = true;
  4905. switch (zoom.name) {
  4906. case "XYZ":
  4907. if (destLength !== 5) {
  4908. return false;
  4909. }
  4910. break;
  4911. case "Fit":
  4912. case "FitB":
  4913. return destLength === 2;
  4914. case "FitH":
  4915. case "FitBH":
  4916. case "FitV":
  4917. case "FitBV":
  4918. if (destLength !== 3) {
  4919. return false;
  4920. }
  4921. break;
  4922. case "FitR":
  4923. if (destLength !== 6) {
  4924. return false;
  4925. }
  4926. allowNull = false;
  4927. break;
  4928. default:
  4929. return false;
  4930. }
  4931. for (var i = 2; i < destLength; i++) {
  4932. var param = dest[i];
  4933. if (!(typeof param === "number" || allowNull && param === null)) {
  4934. return false;
  4935. }
  4936. }
  4937. return true;
  4938. }
  4939. var SimpleLinkService = /*#__PURE__*/function () {
  4940. function SimpleLinkService() {
  4941. _classCallCheck(this, SimpleLinkService);
  4942. this.externalLinkEnabled = true;
  4943. }
  4944. _createClass(SimpleLinkService, [{
  4945. key: "pagesCount",
  4946. get: function get() {
  4947. return 0;
  4948. }
  4949. }, {
  4950. key: "page",
  4951. get: function get() {
  4952. return 0;
  4953. },
  4954. set: function set(value) {}
  4955. }, {
  4956. key: "rotation",
  4957. get: function get() {
  4958. return 0;
  4959. },
  4960. set: function set(value) {}
  4961. }, {
  4962. key: "goToDestination",
  4963. value: function () {
  4964. var _goToDestination2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(dest) {
  4965. return _regenerator["default"].wrap(function _callee2$(_context2) {
  4966. while (1) {
  4967. switch (_context2.prev = _context2.next) {
  4968. case 0:
  4969. case "end":
  4970. return _context2.stop();
  4971. }
  4972. }
  4973. }, _callee2);
  4974. }));
  4975. function goToDestination(_x2) {
  4976. return _goToDestination2.apply(this, arguments);
  4977. }
  4978. return goToDestination;
  4979. }()
  4980. }, {
  4981. key: "goToPage",
  4982. value: function goToPage(val) {}
  4983. }, {
  4984. key: "addLinkAttributes",
  4985. value: function addLinkAttributes(link, url) {
  4986. var newWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4987. _addLinkAttributes(link, {
  4988. url: url,
  4989. enabled: this.externalLinkEnabled
  4990. });
  4991. }
  4992. }, {
  4993. key: "getDestinationHash",
  4994. value: function getDestinationHash(dest) {
  4995. return "#";
  4996. }
  4997. }, {
  4998. key: "getAnchorUrl",
  4999. value: function getAnchorUrl(hash) {
  5000. return "#";
  5001. }
  5002. }, {
  5003. key: "setHash",
  5004. value: function setHash(hash) {}
  5005. }, {
  5006. key: "executeNamedAction",
  5007. value: function executeNamedAction(action) {}
  5008. }, {
  5009. key: "cachePageRef",
  5010. value: function cachePageRef(pageNum, pageRef) {}
  5011. }, {
  5012. key: "isPageVisible",
  5013. value: function isPageVisible(pageNumber) {
  5014. return true;
  5015. }
  5016. }, {
  5017. key: "isPageCached",
  5018. value: function isPageCached(pageNumber) {
  5019. return true;
  5020. }
  5021. }]);
  5022. return SimpleLinkService;
  5023. }();
  5024. exports.SimpleLinkService = SimpleLinkService;
  5025. /***/ }),
  5026. /* 11 */
  5027. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5028. Object.defineProperty(exports, "__esModule", ({
  5029. value: true
  5030. }));
  5031. exports.OverlayManager = void 0;
  5032. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  5033. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5034. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  5035. 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); } }
  5036. 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); }); }; }
  5037. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5038. 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); } }
  5039. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  5040. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  5041. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  5042. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  5043. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  5044. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  5045. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  5046. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  5047. var _overlays = /*#__PURE__*/new WeakMap();
  5048. var _active = /*#__PURE__*/new WeakMap();
  5049. var OverlayManager = /*#__PURE__*/function () {
  5050. function OverlayManager() {
  5051. _classCallCheck(this, OverlayManager);
  5052. _classPrivateFieldInitSpec(this, _overlays, {
  5053. writable: true,
  5054. value: new WeakMap()
  5055. });
  5056. _classPrivateFieldInitSpec(this, _active, {
  5057. writable: true,
  5058. value: null
  5059. });
  5060. }
  5061. _createClass(OverlayManager, [{
  5062. key: "active",
  5063. get: function get() {
  5064. return _classPrivateFieldGet(this, _active);
  5065. }
  5066. }, {
  5067. key: "register",
  5068. value: function () {
  5069. var _register = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(dialog) {
  5070. var _this = this;
  5071. var canForceClose,
  5072. dialogPolyfill,
  5073. _args = arguments;
  5074. return _regenerator["default"].wrap(function _callee$(_context) {
  5075. while (1) {
  5076. switch (_context.prev = _context.next) {
  5077. case 0:
  5078. canForceClose = _args.length > 1 && _args[1] !== undefined ? _args[1] : false;
  5079. if (!(_typeof(dialog) !== "object")) {
  5080. _context.next = 5;
  5081. break;
  5082. }
  5083. throw new Error("Not enough parameters.");
  5084. case 5:
  5085. if (!_classPrivateFieldGet(this, _overlays).has(dialog)) {
  5086. _context.next = 7;
  5087. break;
  5088. }
  5089. throw new Error("The overlay is already registered.");
  5090. case 7:
  5091. _classPrivateFieldGet(this, _overlays).set(dialog, {
  5092. canForceClose: canForceClose
  5093. });
  5094. if (!dialog.showModal) {
  5095. dialogPolyfill = __webpack_require__(12);
  5096. dialogPolyfill.registerDialog(dialog);
  5097. }
  5098. dialog.addEventListener("cancel", function (evt) {
  5099. _classPrivateFieldSet(_this, _active, null);
  5100. });
  5101. case 10:
  5102. case "end":
  5103. return _context.stop();
  5104. }
  5105. }
  5106. }, _callee, this);
  5107. }));
  5108. function register(_x) {
  5109. return _register.apply(this, arguments);
  5110. }
  5111. return register;
  5112. }()
  5113. }, {
  5114. key: "unregister",
  5115. value: function () {
  5116. var _unregister = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(dialog) {
  5117. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5118. while (1) {
  5119. switch (_context2.prev = _context2.next) {
  5120. case 0:
  5121. if (_classPrivateFieldGet(this, _overlays).has(dialog)) {
  5122. _context2.next = 4;
  5123. break;
  5124. }
  5125. throw new Error("The overlay does not exist.");
  5126. case 4:
  5127. if (!(_classPrivateFieldGet(this, _active) === dialog)) {
  5128. _context2.next = 6;
  5129. break;
  5130. }
  5131. throw new Error("The overlay cannot be removed while it is active.");
  5132. case 6:
  5133. _classPrivateFieldGet(this, _overlays)["delete"](dialog);
  5134. case 7:
  5135. case "end":
  5136. return _context2.stop();
  5137. }
  5138. }
  5139. }, _callee2, this);
  5140. }));
  5141. function unregister(_x2) {
  5142. return _unregister.apply(this, arguments);
  5143. }
  5144. return unregister;
  5145. }()
  5146. }, {
  5147. key: "open",
  5148. value: function () {
  5149. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(dialog) {
  5150. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5151. while (1) {
  5152. switch (_context3.prev = _context3.next) {
  5153. case 0:
  5154. if (_classPrivateFieldGet(this, _overlays).has(dialog)) {
  5155. _context3.next = 4;
  5156. break;
  5157. }
  5158. throw new Error("The overlay does not exist.");
  5159. case 4:
  5160. if (!_classPrivateFieldGet(this, _active)) {
  5161. _context3.next = 15;
  5162. break;
  5163. }
  5164. if (!(_classPrivateFieldGet(this, _active) === dialog)) {
  5165. _context3.next = 9;
  5166. break;
  5167. }
  5168. throw new Error("The overlay is already active.");
  5169. case 9:
  5170. if (!_classPrivateFieldGet(this, _overlays).get(dialog).canForceClose) {
  5171. _context3.next = 14;
  5172. break;
  5173. }
  5174. _context3.next = 12;
  5175. return this.close();
  5176. case 12:
  5177. _context3.next = 15;
  5178. break;
  5179. case 14:
  5180. throw new Error("Another overlay is currently active.");
  5181. case 15:
  5182. _classPrivateFieldSet(this, _active, dialog);
  5183. dialog.showModal();
  5184. case 17:
  5185. case "end":
  5186. return _context3.stop();
  5187. }
  5188. }
  5189. }, _callee3, this);
  5190. }));
  5191. function open(_x3) {
  5192. return _open.apply(this, arguments);
  5193. }
  5194. return open;
  5195. }()
  5196. }, {
  5197. key: "close",
  5198. value: function () {
  5199. var _close = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  5200. var dialog,
  5201. _args4 = arguments;
  5202. return _regenerator["default"].wrap(function _callee4$(_context4) {
  5203. while (1) {
  5204. switch (_context4.prev = _context4.next) {
  5205. case 0:
  5206. dialog = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : _classPrivateFieldGet(this, _active);
  5207. if (_classPrivateFieldGet(this, _overlays).has(dialog)) {
  5208. _context4.next = 5;
  5209. break;
  5210. }
  5211. throw new Error("The overlay does not exist.");
  5212. case 5:
  5213. if (_classPrivateFieldGet(this, _active)) {
  5214. _context4.next = 9;
  5215. break;
  5216. }
  5217. throw new Error("The overlay is currently not active.");
  5218. case 9:
  5219. if (!(_classPrivateFieldGet(this, _active) !== dialog)) {
  5220. _context4.next = 11;
  5221. break;
  5222. }
  5223. throw new Error("Another overlay is currently active.");
  5224. case 11:
  5225. dialog.close();
  5226. _classPrivateFieldSet(this, _active, null);
  5227. case 13:
  5228. case "end":
  5229. return _context4.stop();
  5230. }
  5231. }
  5232. }, _callee4, this);
  5233. }));
  5234. function close() {
  5235. return _close.apply(this, arguments);
  5236. }
  5237. return close;
  5238. }()
  5239. }]);
  5240. return OverlayManager;
  5241. }();
  5242. exports.OverlayManager = OverlayManager;
  5243. /***/ }),
  5244. /* 12 */
  5245. /***/ ((module, exports, __webpack_require__) => {
  5246. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;
  5247. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  5248. (function (global, factory) {
  5249. ( false ? 0 : _typeof(exports)) === 'object' && "object" !== 'undefined' ? module.exports = factory() : true ? !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  5250. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  5251. (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
  5252. __WEBPACK_AMD_DEFINE_FACTORY__),
  5253. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : (0);
  5254. })(void 0, function () {
  5255. 'use strict';
  5256. var supportCustomEvent = window.CustomEvent;
  5257. if (!supportCustomEvent || _typeof(supportCustomEvent) === 'object') {
  5258. supportCustomEvent = function CustomEvent(event, x) {
  5259. x = x || {};
  5260. var ev = document.createEvent('CustomEvent');
  5261. ev.initCustomEvent(event, !!x.bubbles, !!x.cancelable, x.detail || null);
  5262. return ev;
  5263. };
  5264. supportCustomEvent.prototype = window.Event.prototype;
  5265. }
  5266. function safeDispatchEvent(target, event) {
  5267. var check = 'on' + event.type.toLowerCase();
  5268. if (typeof target[check] === 'function') {
  5269. target[check](event);
  5270. }
  5271. return target.dispatchEvent(event);
  5272. }
  5273. function createsStackingContext(el) {
  5274. while (el && el !== document.body) {
  5275. var s = window.getComputedStyle(el);
  5276. var invalid = function invalid(k, ok) {
  5277. return !(s[k] === undefined || s[k] === ok);
  5278. };
  5279. if (s.opacity < 1 || invalid('zIndex', 'auto') || invalid('transform', 'none') || invalid('mixBlendMode', 'normal') || invalid('filter', 'none') || invalid('perspective', 'none') || s['isolation'] === 'isolate' || s.position === 'fixed' || s.webkitOverflowScrolling === 'touch') {
  5280. return true;
  5281. }
  5282. el = el.parentElement;
  5283. }
  5284. return false;
  5285. }
  5286. function findNearestDialog(el) {
  5287. while (el) {
  5288. if (el.localName === 'dialog') {
  5289. return el;
  5290. }
  5291. if (el.parentElement) {
  5292. el = el.parentElement;
  5293. } else if (el.parentNode) {
  5294. el = el.parentNode.host;
  5295. } else {
  5296. el = null;
  5297. }
  5298. }
  5299. return null;
  5300. }
  5301. function safeBlur(el) {
  5302. while (el && el.shadowRoot && el.shadowRoot.activeElement) {
  5303. el = el.shadowRoot.activeElement;
  5304. }
  5305. if (el && el.blur && el !== document.body) {
  5306. el.blur();
  5307. }
  5308. }
  5309. function inNodeList(nodeList, node) {
  5310. for (var i = 0; i < nodeList.length; ++i) {
  5311. if (nodeList[i] === node) {
  5312. return true;
  5313. }
  5314. }
  5315. return false;
  5316. }
  5317. function isFormMethodDialog(el) {
  5318. if (!el || !el.hasAttribute('method')) {
  5319. return false;
  5320. }
  5321. return el.getAttribute('method').toLowerCase() === 'dialog';
  5322. }
  5323. function findFocusableElementWithin(hostElement) {
  5324. var opts = ['button', 'input', 'keygen', 'select', 'textarea'];
  5325. var query = opts.map(function (el) {
  5326. return el + ':not([disabled])';
  5327. });
  5328. query.push('[tabindex]:not([disabled]):not([tabindex=""])');
  5329. var target = hostElement.querySelector(query.join(', '));
  5330. if (!target && 'attachShadow' in Element.prototype) {
  5331. var elems = hostElement.querySelectorAll('*');
  5332. for (var i = 0; i < elems.length; i++) {
  5333. if (elems[i].tagName && elems[i].shadowRoot) {
  5334. target = findFocusableElementWithin(elems[i].shadowRoot);
  5335. if (target) {
  5336. break;
  5337. }
  5338. }
  5339. }
  5340. }
  5341. return target;
  5342. }
  5343. function isConnected(element) {
  5344. return element.isConnected || document.body.contains(element);
  5345. }
  5346. function findFormSubmitter(event) {
  5347. if (event.submitter) {
  5348. return event.submitter;
  5349. }
  5350. var form = event.target;
  5351. if (!(form instanceof HTMLFormElement)) {
  5352. return null;
  5353. }
  5354. var submitter = dialogPolyfill.formSubmitter;
  5355. if (!submitter) {
  5356. var target = event.target;
  5357. var root = 'getRootNode' in target && target.getRootNode() || document;
  5358. submitter = root.activeElement;
  5359. }
  5360. if (!submitter || submitter.form !== form) {
  5361. return null;
  5362. }
  5363. return submitter;
  5364. }
  5365. function maybeHandleSubmit(event) {
  5366. if (event.defaultPrevented) {
  5367. return;
  5368. }
  5369. var form = event.target;
  5370. var value = dialogPolyfill.imagemapUseValue;
  5371. var submitter = findFormSubmitter(event);
  5372. if (value === null && submitter) {
  5373. value = submitter.value;
  5374. }
  5375. var dialog = findNearestDialog(form);
  5376. if (!dialog) {
  5377. return;
  5378. }
  5379. var formmethod = submitter && submitter.getAttribute('formmethod') || form.getAttribute('method');
  5380. if (formmethod !== 'dialog') {
  5381. return;
  5382. }
  5383. event.preventDefault();
  5384. if (value != null) {
  5385. dialog.close(value);
  5386. } else {
  5387. dialog.close();
  5388. }
  5389. }
  5390. function dialogPolyfillInfo(dialog) {
  5391. this.dialog_ = dialog;
  5392. this.replacedStyleTop_ = false;
  5393. this.openAsModal_ = false;
  5394. if (!dialog.hasAttribute('role')) {
  5395. dialog.setAttribute('role', 'dialog');
  5396. }
  5397. dialog.show = this.show.bind(this);
  5398. dialog.showModal = this.showModal.bind(this);
  5399. dialog.close = this.close.bind(this);
  5400. dialog.addEventListener('submit', maybeHandleSubmit, false);
  5401. if (!('returnValue' in dialog)) {
  5402. dialog.returnValue = '';
  5403. }
  5404. if ('MutationObserver' in window) {
  5405. var mo = new MutationObserver(this.maybeHideModal.bind(this));
  5406. mo.observe(dialog, {
  5407. attributes: true,
  5408. attributeFilter: ['open']
  5409. });
  5410. } else {
  5411. var removed = false;
  5412. var cb = function () {
  5413. removed ? this.downgradeModal() : this.maybeHideModal();
  5414. removed = false;
  5415. }.bind(this);
  5416. var timeout;
  5417. var delayModel = function delayModel(ev) {
  5418. if (ev.target !== dialog) {
  5419. return;
  5420. }
  5421. var cand = 'DOMNodeRemoved';
  5422. removed |= ev.type.substr(0, cand.length) === cand;
  5423. window.clearTimeout(timeout);
  5424. timeout = window.setTimeout(cb, 0);
  5425. };
  5426. ['DOMAttrModified', 'DOMNodeRemoved', 'DOMNodeRemovedFromDocument'].forEach(function (name) {
  5427. dialog.addEventListener(name, delayModel);
  5428. });
  5429. }
  5430. Object.defineProperty(dialog, 'open', {
  5431. set: this.setOpen.bind(this),
  5432. get: dialog.hasAttribute.bind(dialog, 'open')
  5433. });
  5434. this.backdrop_ = document.createElement('div');
  5435. this.backdrop_.className = 'backdrop';
  5436. this.backdrop_.addEventListener('mouseup', this.backdropMouseEvent_.bind(this));
  5437. this.backdrop_.addEventListener('mousedown', this.backdropMouseEvent_.bind(this));
  5438. this.backdrop_.addEventListener('click', this.backdropMouseEvent_.bind(this));
  5439. }
  5440. dialogPolyfillInfo.prototype = {
  5441. get dialog() {
  5442. return this.dialog_;
  5443. },
  5444. maybeHideModal: function maybeHideModal() {
  5445. if (this.dialog_.hasAttribute('open') && isConnected(this.dialog_)) {
  5446. return;
  5447. }
  5448. this.downgradeModal();
  5449. },
  5450. downgradeModal: function downgradeModal() {
  5451. if (!this.openAsModal_) {
  5452. return;
  5453. }
  5454. this.openAsModal_ = false;
  5455. this.dialog_.style.zIndex = '';
  5456. if (this.replacedStyleTop_) {
  5457. this.dialog_.style.top = '';
  5458. this.replacedStyleTop_ = false;
  5459. }
  5460. this.backdrop_.parentNode && this.backdrop_.parentNode.removeChild(this.backdrop_);
  5461. dialogPolyfill.dm.removeDialog(this);
  5462. },
  5463. setOpen: function setOpen(value) {
  5464. if (value) {
  5465. this.dialog_.hasAttribute('open') || this.dialog_.setAttribute('open', '');
  5466. } else {
  5467. this.dialog_.removeAttribute('open');
  5468. this.maybeHideModal();
  5469. }
  5470. },
  5471. backdropMouseEvent_: function backdropMouseEvent_(e) {
  5472. if (!this.dialog_.hasAttribute('tabindex')) {
  5473. var fake = document.createElement('div');
  5474. this.dialog_.insertBefore(fake, this.dialog_.firstChild);
  5475. fake.tabIndex = -1;
  5476. fake.focus();
  5477. this.dialog_.removeChild(fake);
  5478. } else {
  5479. this.dialog_.focus();
  5480. }
  5481. var redirectedEvent = document.createEvent('MouseEvents');
  5482. redirectedEvent.initMouseEvent(e.type, e.bubbles, e.cancelable, window, e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.button, e.relatedTarget);
  5483. this.dialog_.dispatchEvent(redirectedEvent);
  5484. e.stopPropagation();
  5485. },
  5486. focus_: function focus_() {
  5487. var target = this.dialog_.querySelector('[autofocus]:not([disabled])');
  5488. if (!target && this.dialog_.tabIndex >= 0) {
  5489. target = this.dialog_;
  5490. }
  5491. if (!target) {
  5492. target = findFocusableElementWithin(this.dialog_);
  5493. }
  5494. safeBlur(document.activeElement);
  5495. target && target.focus();
  5496. },
  5497. updateZIndex: function updateZIndex(dialogZ, backdropZ) {
  5498. if (dialogZ < backdropZ) {
  5499. throw new Error('dialogZ should never be < backdropZ');
  5500. }
  5501. this.dialog_.style.zIndex = dialogZ;
  5502. this.backdrop_.style.zIndex = backdropZ;
  5503. },
  5504. show: function show() {
  5505. if (!this.dialog_.open) {
  5506. this.setOpen(true);
  5507. this.focus_();
  5508. }
  5509. },
  5510. showModal: function showModal() {
  5511. if (this.dialog_.hasAttribute('open')) {
  5512. throw new Error('Failed to execute \'showModal\' on dialog: The element is already open, and therefore cannot be opened modally.');
  5513. }
  5514. if (!isConnected(this.dialog_)) {
  5515. throw new Error('Failed to execute \'showModal\' on dialog: The element is not in a Document.');
  5516. }
  5517. if (!dialogPolyfill.dm.pushDialog(this)) {
  5518. throw new Error('Failed to execute \'showModal\' on dialog: There are too many open modal dialogs.');
  5519. }
  5520. if (createsStackingContext(this.dialog_.parentElement)) {
  5521. console.warn('A dialog is being shown inside a stacking context. ' + 'This may cause it to be unusable. For more information, see this link: ' + 'https://github.com/GoogleChrome/dialog-polyfill/#stacking-context');
  5522. }
  5523. this.setOpen(true);
  5524. this.openAsModal_ = true;
  5525. if (dialogPolyfill.needsCentering(this.dialog_)) {
  5526. dialogPolyfill.reposition(this.dialog_);
  5527. this.replacedStyleTop_ = true;
  5528. } else {
  5529. this.replacedStyleTop_ = false;
  5530. }
  5531. this.dialog_.parentNode.insertBefore(this.backdrop_, this.dialog_.nextSibling);
  5532. this.focus_();
  5533. },
  5534. close: function close(opt_returnValue) {
  5535. if (!this.dialog_.hasAttribute('open')) {
  5536. throw new Error('Failed to execute \'close\' on dialog: The element does not have an \'open\' attribute, and therefore cannot be closed.');
  5537. }
  5538. this.setOpen(false);
  5539. if (opt_returnValue !== undefined) {
  5540. this.dialog_.returnValue = opt_returnValue;
  5541. }
  5542. var closeEvent = new supportCustomEvent('close', {
  5543. bubbles: false,
  5544. cancelable: false
  5545. });
  5546. safeDispatchEvent(this.dialog_, closeEvent);
  5547. }
  5548. };
  5549. var dialogPolyfill = {};
  5550. dialogPolyfill.reposition = function (element) {
  5551. var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
  5552. var topValue = scrollTop + (window.innerHeight - element.offsetHeight) / 2;
  5553. element.style.top = Math.max(scrollTop, topValue) + 'px';
  5554. };
  5555. dialogPolyfill.isInlinePositionSetByStylesheet = function (element) {
  5556. for (var i = 0; i < document.styleSheets.length; ++i) {
  5557. var styleSheet = document.styleSheets[i];
  5558. var cssRules = null;
  5559. try {
  5560. cssRules = styleSheet.cssRules;
  5561. } catch (e) {}
  5562. if (!cssRules) {
  5563. continue;
  5564. }
  5565. for (var j = 0; j < cssRules.length; ++j) {
  5566. var rule = cssRules[j];
  5567. var selectedNodes = null;
  5568. try {
  5569. selectedNodes = document.querySelectorAll(rule.selectorText);
  5570. } catch (e) {}
  5571. if (!selectedNodes || !inNodeList(selectedNodes, element)) {
  5572. continue;
  5573. }
  5574. var cssTop = rule.style.getPropertyValue('top');
  5575. var cssBottom = rule.style.getPropertyValue('bottom');
  5576. if (cssTop && cssTop !== 'auto' || cssBottom && cssBottom !== 'auto') {
  5577. return true;
  5578. }
  5579. }
  5580. }
  5581. return false;
  5582. };
  5583. dialogPolyfill.needsCentering = function (dialog) {
  5584. var computedStyle = window.getComputedStyle(dialog);
  5585. if (computedStyle.position !== 'absolute') {
  5586. return false;
  5587. }
  5588. if (dialog.style.top !== 'auto' && dialog.style.top !== '' || dialog.style.bottom !== 'auto' && dialog.style.bottom !== '') {
  5589. return false;
  5590. }
  5591. return !dialogPolyfill.isInlinePositionSetByStylesheet(dialog);
  5592. };
  5593. dialogPolyfill.forceRegisterDialog = function (element) {
  5594. if (window.HTMLDialogElement || element.showModal) {
  5595. console.warn('This browser already supports <dialog>, the polyfill ' + 'may not work correctly', element);
  5596. }
  5597. if (element.localName !== 'dialog') {
  5598. throw new Error('Failed to register dialog: The element is not a dialog.');
  5599. }
  5600. new dialogPolyfillInfo(element);
  5601. };
  5602. dialogPolyfill.registerDialog = function (element) {
  5603. if (!element.showModal) {
  5604. dialogPolyfill.forceRegisterDialog(element);
  5605. }
  5606. };
  5607. dialogPolyfill.DialogManager = function () {
  5608. this.pendingDialogStack = [];
  5609. var checkDOM = this.checkDOM_.bind(this);
  5610. this.overlay = document.createElement('div');
  5611. this.overlay.className = '_dialog_overlay';
  5612. this.overlay.addEventListener('click', function (e) {
  5613. this.forwardTab_ = undefined;
  5614. e.stopPropagation();
  5615. checkDOM([]);
  5616. }.bind(this));
  5617. this.handleKey_ = this.handleKey_.bind(this);
  5618. this.handleFocus_ = this.handleFocus_.bind(this);
  5619. this.zIndexLow_ = 100000;
  5620. this.zIndexHigh_ = 100000 + 150;
  5621. this.forwardTab_ = undefined;
  5622. if ('MutationObserver' in window) {
  5623. this.mo_ = new MutationObserver(function (records) {
  5624. var removed = [];
  5625. records.forEach(function (rec) {
  5626. for (var i = 0, c; c = rec.removedNodes[i]; ++i) {
  5627. if (!(c instanceof Element)) {
  5628. continue;
  5629. } else if (c.localName === 'dialog') {
  5630. removed.push(c);
  5631. }
  5632. removed = removed.concat(c.querySelectorAll('dialog'));
  5633. }
  5634. });
  5635. removed.length && checkDOM(removed);
  5636. });
  5637. }
  5638. };
  5639. dialogPolyfill.DialogManager.prototype.blockDocument = function () {
  5640. document.documentElement.addEventListener('focus', this.handleFocus_, true);
  5641. document.addEventListener('keydown', this.handleKey_);
  5642. this.mo_ && this.mo_.observe(document, {
  5643. childList: true,
  5644. subtree: true
  5645. });
  5646. };
  5647. dialogPolyfill.DialogManager.prototype.unblockDocument = function () {
  5648. document.documentElement.removeEventListener('focus', this.handleFocus_, true);
  5649. document.removeEventListener('keydown', this.handleKey_);
  5650. this.mo_ && this.mo_.disconnect();
  5651. };
  5652. dialogPolyfill.DialogManager.prototype.updateStacking = function () {
  5653. var zIndex = this.zIndexHigh_;
  5654. for (var i = 0, dpi; dpi = this.pendingDialogStack[i]; ++i) {
  5655. dpi.updateZIndex(--zIndex, --zIndex);
  5656. if (i === 0) {
  5657. this.overlay.style.zIndex = --zIndex;
  5658. }
  5659. }
  5660. var last = this.pendingDialogStack[0];
  5661. if (last) {
  5662. var p = last.dialog.parentNode || document.body;
  5663. p.appendChild(this.overlay);
  5664. } else if (this.overlay.parentNode) {
  5665. this.overlay.parentNode.removeChild(this.overlay);
  5666. }
  5667. };
  5668. dialogPolyfill.DialogManager.prototype.containedByTopDialog_ = function (candidate) {
  5669. while (candidate = findNearestDialog(candidate)) {
  5670. for (var i = 0, dpi; dpi = this.pendingDialogStack[i]; ++i) {
  5671. if (dpi.dialog === candidate) {
  5672. return i === 0;
  5673. }
  5674. }
  5675. candidate = candidate.parentElement;
  5676. }
  5677. return false;
  5678. };
  5679. dialogPolyfill.DialogManager.prototype.handleFocus_ = function (event) {
  5680. var target = event.composedPath ? event.composedPath()[0] : event.target;
  5681. if (this.containedByTopDialog_(target)) {
  5682. return;
  5683. }
  5684. if (document.activeElement === document.documentElement) {
  5685. return;
  5686. }
  5687. event.preventDefault();
  5688. event.stopPropagation();
  5689. safeBlur(target);
  5690. if (this.forwardTab_ === undefined) {
  5691. return;
  5692. }
  5693. var dpi = this.pendingDialogStack[0];
  5694. var dialog = dpi.dialog;
  5695. var position = dialog.compareDocumentPosition(target);
  5696. if (position & Node.DOCUMENT_POSITION_PRECEDING) {
  5697. if (this.forwardTab_) {
  5698. dpi.focus_();
  5699. } else if (target !== document.documentElement) {
  5700. document.documentElement.focus();
  5701. }
  5702. }
  5703. return false;
  5704. };
  5705. dialogPolyfill.DialogManager.prototype.handleKey_ = function (event) {
  5706. this.forwardTab_ = undefined;
  5707. if (event.keyCode === 27) {
  5708. event.preventDefault();
  5709. event.stopPropagation();
  5710. var cancelEvent = new supportCustomEvent('cancel', {
  5711. bubbles: false,
  5712. cancelable: true
  5713. });
  5714. var dpi = this.pendingDialogStack[0];
  5715. if (dpi && safeDispatchEvent(dpi.dialog, cancelEvent)) {
  5716. dpi.dialog.close();
  5717. }
  5718. } else if (event.keyCode === 9) {
  5719. this.forwardTab_ = !event.shiftKey;
  5720. }
  5721. };
  5722. dialogPolyfill.DialogManager.prototype.checkDOM_ = function (removed) {
  5723. var clone = this.pendingDialogStack.slice();
  5724. clone.forEach(function (dpi) {
  5725. if (removed.indexOf(dpi.dialog) !== -1) {
  5726. dpi.downgradeModal();
  5727. } else {
  5728. dpi.maybeHideModal();
  5729. }
  5730. });
  5731. };
  5732. dialogPolyfill.DialogManager.prototype.pushDialog = function (dpi) {
  5733. var allowed = (this.zIndexHigh_ - this.zIndexLow_) / 2 - 1;
  5734. if (this.pendingDialogStack.length >= allowed) {
  5735. return false;
  5736. }
  5737. if (this.pendingDialogStack.unshift(dpi) === 1) {
  5738. this.blockDocument();
  5739. }
  5740. this.updateStacking();
  5741. return true;
  5742. };
  5743. dialogPolyfill.DialogManager.prototype.removeDialog = function (dpi) {
  5744. var index = this.pendingDialogStack.indexOf(dpi);
  5745. if (index === -1) {
  5746. return;
  5747. }
  5748. this.pendingDialogStack.splice(index, 1);
  5749. if (this.pendingDialogStack.length === 0) {
  5750. this.unblockDocument();
  5751. }
  5752. this.updateStacking();
  5753. };
  5754. dialogPolyfill.dm = new dialogPolyfill.DialogManager();
  5755. dialogPolyfill.formSubmitter = null;
  5756. dialogPolyfill.imagemapUseValue = null;
  5757. if (window.HTMLDialogElement === undefined) {
  5758. var testForm = document.createElement('form');
  5759. testForm.setAttribute('method', 'dialog');
  5760. if (testForm.method !== 'dialog') {
  5761. var methodDescriptor = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, 'method');
  5762. if (methodDescriptor) {
  5763. var realGet = methodDescriptor.get;
  5764. methodDescriptor.get = function () {
  5765. if (isFormMethodDialog(this)) {
  5766. return 'dialog';
  5767. }
  5768. return realGet.call(this);
  5769. };
  5770. var realSet = methodDescriptor.set;
  5771. methodDescriptor.set = function (v) {
  5772. if (typeof v === 'string' && v.toLowerCase() === 'dialog') {
  5773. return this.setAttribute('method', v);
  5774. }
  5775. return realSet.call(this, v);
  5776. };
  5777. Object.defineProperty(HTMLFormElement.prototype, 'method', methodDescriptor);
  5778. }
  5779. }
  5780. document.addEventListener('click', function (ev) {
  5781. dialogPolyfill.formSubmitter = null;
  5782. dialogPolyfill.imagemapUseValue = null;
  5783. if (ev.defaultPrevented) {
  5784. return;
  5785. }
  5786. var target = ev.target;
  5787. if ('composedPath' in ev) {
  5788. var path = ev.composedPath();
  5789. target = path.shift() || target;
  5790. }
  5791. if (!target || !isFormMethodDialog(target.form)) {
  5792. return;
  5793. }
  5794. var valid = target.type === 'submit' && ['button', 'input'].indexOf(target.localName) > -1;
  5795. if (!valid) {
  5796. if (!(target.localName === 'input' && target.type === 'image')) {
  5797. return;
  5798. }
  5799. dialogPolyfill.imagemapUseValue = ev.offsetX + ',' + ev.offsetY;
  5800. }
  5801. var dialog = findNearestDialog(target);
  5802. if (!dialog) {
  5803. return;
  5804. }
  5805. dialogPolyfill.formSubmitter = target;
  5806. }, false);
  5807. document.addEventListener('submit', function (ev) {
  5808. var form = ev.target;
  5809. var dialog = findNearestDialog(form);
  5810. if (dialog) {
  5811. return;
  5812. }
  5813. var submitter = findFormSubmitter(ev);
  5814. var formmethod = submitter && submitter.getAttribute('formmethod') || form.getAttribute('method');
  5815. if (formmethod === 'dialog') {
  5816. ev.preventDefault();
  5817. }
  5818. });
  5819. var nativeFormSubmit = HTMLFormElement.prototype.submit;
  5820. var replacementFormSubmit = function replacementFormSubmit() {
  5821. if (!isFormMethodDialog(this)) {
  5822. return nativeFormSubmit.call(this);
  5823. }
  5824. var dialog = findNearestDialog(this);
  5825. dialog && dialog.close();
  5826. };
  5827. HTMLFormElement.prototype.submit = replacementFormSubmit;
  5828. }
  5829. return dialogPolyfill;
  5830. });
  5831. /***/ }),
  5832. /* 13 */
  5833. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5834. Object.defineProperty(exports, "__esModule", ({
  5835. value: true
  5836. }));
  5837. exports.PasswordPrompt = void 0;
  5838. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  5839. var _pdfjsLib = __webpack_require__(7);
  5840. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5841. 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); } }
  5842. 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); }); }; }
  5843. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5844. 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); } }
  5845. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  5846. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  5847. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  5848. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  5849. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  5850. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  5851. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  5852. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  5853. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  5854. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  5855. var _updateCallback = /*#__PURE__*/new WeakMap();
  5856. var _reason = /*#__PURE__*/new WeakMap();
  5857. var _verify = /*#__PURE__*/new WeakSet();
  5858. var _cancel = /*#__PURE__*/new WeakSet();
  5859. var _invokeCallback = /*#__PURE__*/new WeakSet();
  5860. var PasswordPrompt = /*#__PURE__*/function () {
  5861. function PasswordPrompt(options, overlayManager, l10n) {
  5862. var _this = this;
  5863. var isViewerEmbedded = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  5864. _classCallCheck(this, PasswordPrompt);
  5865. _classPrivateMethodInitSpec(this, _invokeCallback);
  5866. _classPrivateMethodInitSpec(this, _cancel);
  5867. _classPrivateMethodInitSpec(this, _verify);
  5868. _classPrivateFieldInitSpec(this, _updateCallback, {
  5869. writable: true,
  5870. value: null
  5871. });
  5872. _classPrivateFieldInitSpec(this, _reason, {
  5873. writable: true,
  5874. value: null
  5875. });
  5876. this.dialog = options.dialog;
  5877. this.label = options.label;
  5878. this.input = options.input;
  5879. this.submitButton = options.submitButton;
  5880. this.cancelButton = options.cancelButton;
  5881. this.overlayManager = overlayManager;
  5882. this.l10n = l10n;
  5883. this._isViewerEmbedded = isViewerEmbedded;
  5884. this.submitButton.addEventListener("click", _classPrivateMethodGet(this, _verify, _verify2).bind(this));
  5885. this.cancelButton.addEventListener("click", _classPrivateMethodGet(this, _cancel, _cancel2).bind(this));
  5886. this.input.addEventListener("keydown", function (e) {
  5887. if (e.keyCode === 13) {
  5888. _classPrivateMethodGet(_this, _verify, _verify2).call(_this);
  5889. }
  5890. });
  5891. this.overlayManager.register(this.dialog, true);
  5892. this.dialog.addEventListener("close", _classPrivateMethodGet(this, _cancel, _cancel2).bind(this));
  5893. }
  5894. _createClass(PasswordPrompt, [{
  5895. key: "open",
  5896. value: function () {
  5897. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  5898. var passwordIncorrect;
  5899. return _regenerator["default"].wrap(function _callee$(_context) {
  5900. while (1) {
  5901. switch (_context.prev = _context.next) {
  5902. case 0:
  5903. _context.next = 2;
  5904. return this.overlayManager.open(this.dialog);
  5905. case 2:
  5906. passwordIncorrect = _classPrivateFieldGet(this, _reason) === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD;
  5907. if (!this._isViewerEmbedded || passwordIncorrect) {
  5908. this.input.focus();
  5909. }
  5910. _context.next = 6;
  5911. return this.l10n.get("password_".concat(passwordIncorrect ? "invalid" : "label"));
  5912. case 6:
  5913. this.label.textContent = _context.sent;
  5914. case 7:
  5915. case "end":
  5916. return _context.stop();
  5917. }
  5918. }
  5919. }, _callee, this);
  5920. }));
  5921. function open() {
  5922. return _open.apply(this, arguments);
  5923. }
  5924. return open;
  5925. }()
  5926. }, {
  5927. key: "close",
  5928. value: function () {
  5929. var _close = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  5930. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5931. while (1) {
  5932. switch (_context2.prev = _context2.next) {
  5933. case 0:
  5934. if (this.overlayManager.active === this.dialog) {
  5935. this.overlayManager.close(this.dialog);
  5936. }
  5937. case 1:
  5938. case "end":
  5939. return _context2.stop();
  5940. }
  5941. }
  5942. }, _callee2, this);
  5943. }));
  5944. function close() {
  5945. return _close.apply(this, arguments);
  5946. }
  5947. return close;
  5948. }()
  5949. }, {
  5950. key: "setUpdateCallback",
  5951. value: function setUpdateCallback(updateCallback, reason) {
  5952. _classPrivateFieldSet(this, _updateCallback, updateCallback);
  5953. _classPrivateFieldSet(this, _reason, reason);
  5954. }
  5955. }]);
  5956. return PasswordPrompt;
  5957. }();
  5958. exports.PasswordPrompt = PasswordPrompt;
  5959. function _verify2() {
  5960. var password = this.input.value;
  5961. if ((password === null || password === void 0 ? void 0 : password.length) > 0) {
  5962. _classPrivateMethodGet(this, _invokeCallback, _invokeCallback2).call(this, password);
  5963. }
  5964. }
  5965. function _cancel2() {
  5966. _classPrivateMethodGet(this, _invokeCallback, _invokeCallback2).call(this, new Error("PasswordPrompt cancelled."));
  5967. }
  5968. function _invokeCallback2(password) {
  5969. if (!_classPrivateFieldGet(this, _updateCallback)) {
  5970. return;
  5971. }
  5972. this.close();
  5973. this.input.value = "";
  5974. _classPrivateFieldGet(this, _updateCallback).call(this, password);
  5975. _classPrivateFieldSet(this, _updateCallback, null);
  5976. }
  5977. /***/ }),
  5978. /* 14 */
  5979. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5980. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  5981. Object.defineProperty(exports, "__esModule", ({
  5982. value: true
  5983. }));
  5984. exports.PDFAttachmentViewer = void 0;
  5985. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  5986. var _pdfjsLib = __webpack_require__(7);
  5987. var _base_tree_viewer = __webpack_require__(15);
  5988. var _event_utils = __webpack_require__(6);
  5989. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5990. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
  5991. 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); }
  5992. 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; }
  5993. 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); } }
  5994. 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); }); }; }
  5995. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5996. 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); } }
  5997. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  5998. function _get() { 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(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
  5999. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  6000. 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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
  6001. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  6002. 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); }; }
  6003. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  6004. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  6005. 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; } }
  6006. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  6007. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  6008. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  6009. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  6010. var _appendAttachment = /*#__PURE__*/new WeakSet();
  6011. var PDFAttachmentViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  6012. _inherits(PDFAttachmentViewer, _BaseTreeViewer);
  6013. var _super = _createSuper(PDFAttachmentViewer);
  6014. function PDFAttachmentViewer(options) {
  6015. var _this;
  6016. _classCallCheck(this, PDFAttachmentViewer);
  6017. _this = _super.call(this, options);
  6018. _classPrivateMethodInitSpec(_assertThisInitialized(_this), _appendAttachment);
  6019. _this.downloadManager = options.downloadManager;
  6020. _this.eventBus._on("fileattachmentannotation", _classPrivateMethodGet(_assertThisInitialized(_this), _appendAttachment, _appendAttachment2).bind(_assertThisInitialized(_this)));
  6021. return _this;
  6022. }
  6023. _createClass(PDFAttachmentViewer, [{
  6024. key: "reset",
  6025. value: function reset() {
  6026. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6027. _get(_getPrototypeOf(PDFAttachmentViewer.prototype), "reset", this).call(this);
  6028. this._attachments = null;
  6029. if (!keepRenderedCapability) {
  6030. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  6031. }
  6032. this._pendingDispatchEvent = false;
  6033. }
  6034. }, {
  6035. key: "_dispatchEvent",
  6036. value: function () {
  6037. var _dispatchEvent2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(attachmentsCount) {
  6038. return _regenerator["default"].wrap(function _callee$(_context) {
  6039. while (1) {
  6040. switch (_context.prev = _context.next) {
  6041. case 0:
  6042. this._renderedCapability.resolve();
  6043. if (!(attachmentsCount === 0 && !this._pendingDispatchEvent)) {
  6044. _context.next = 7;
  6045. break;
  6046. }
  6047. this._pendingDispatchEvent = true;
  6048. _context.next = 5;
  6049. return (0, _event_utils.waitOnEventOrTimeout)({
  6050. target: this.eventBus,
  6051. name: "annotationlayerrendered",
  6052. delay: 1000
  6053. });
  6054. case 5:
  6055. if (this._pendingDispatchEvent) {
  6056. _context.next = 7;
  6057. break;
  6058. }
  6059. return _context.abrupt("return");
  6060. case 7:
  6061. this._pendingDispatchEvent = false;
  6062. this.eventBus.dispatch("attachmentsloaded", {
  6063. source: this,
  6064. attachmentsCount: attachmentsCount
  6065. });
  6066. case 9:
  6067. case "end":
  6068. return _context.stop();
  6069. }
  6070. }
  6071. }, _callee, this);
  6072. }));
  6073. function _dispatchEvent(_x) {
  6074. return _dispatchEvent2.apply(this, arguments);
  6075. }
  6076. return _dispatchEvent;
  6077. }()
  6078. }, {
  6079. key: "_bindLink",
  6080. value: function _bindLink(element, _ref) {
  6081. var _this2 = this;
  6082. var content = _ref.content,
  6083. filename = _ref.filename;
  6084. element.onclick = function () {
  6085. _this2.downloadManager.openOrDownloadData(element, content, filename);
  6086. return false;
  6087. };
  6088. }
  6089. }, {
  6090. key: "render",
  6091. value: function render(_ref2) {
  6092. var attachments = _ref2.attachments,
  6093. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  6094. keepRenderedCapability = _ref2$keepRenderedCap === void 0 ? false : _ref2$keepRenderedCap;
  6095. if (this._attachments) {
  6096. this.reset(keepRenderedCapability);
  6097. }
  6098. this._attachments = attachments || null;
  6099. if (!attachments) {
  6100. this._dispatchEvent(0);
  6101. return;
  6102. }
  6103. var names = Object.keys(attachments).sort(function (a, b) {
  6104. return a.toLowerCase().localeCompare(b.toLowerCase());
  6105. });
  6106. var fragment = document.createDocumentFragment();
  6107. var attachmentsCount = 0;
  6108. var _iterator = _createForOfIteratorHelper(names),
  6109. _step;
  6110. try {
  6111. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  6112. var name = _step.value;
  6113. var item = attachments[name];
  6114. var content = item.content,
  6115. filename = (0, _pdfjsLib.getFilenameFromUrl)(item.filename);
  6116. var div = document.createElement("div");
  6117. div.className = "treeItem";
  6118. var element = document.createElement("a");
  6119. this._bindLink(element, {
  6120. content: content,
  6121. filename: filename
  6122. });
  6123. element.textContent = this._normalizeTextContent(filename);
  6124. div.appendChild(element);
  6125. fragment.appendChild(div);
  6126. attachmentsCount++;
  6127. }
  6128. } catch (err) {
  6129. _iterator.e(err);
  6130. } finally {
  6131. _iterator.f();
  6132. }
  6133. this._finishRendering(fragment, attachmentsCount);
  6134. }
  6135. }]);
  6136. return PDFAttachmentViewer;
  6137. }(_base_tree_viewer.BaseTreeViewer);
  6138. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  6139. function _appendAttachment2(_ref3) {
  6140. var _this3 = this;
  6141. var filename = _ref3.filename,
  6142. content = _ref3.content;
  6143. var renderedPromise = this._renderedCapability.promise;
  6144. renderedPromise.then(function () {
  6145. if (renderedPromise !== _this3._renderedCapability.promise) {
  6146. return;
  6147. }
  6148. var attachments = _this3._attachments || Object.create(null);
  6149. for (var name in attachments) {
  6150. if (filename === name) {
  6151. return;
  6152. }
  6153. }
  6154. attachments[filename] = {
  6155. filename: filename,
  6156. content: content
  6157. };
  6158. _this3.render({
  6159. attachments: attachments,
  6160. keepRenderedCapability: true
  6161. });
  6162. });
  6163. }
  6164. /***/ }),
  6165. /* 15 */
  6166. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6167. Object.defineProperty(exports, "__esModule", ({
  6168. value: true
  6169. }));
  6170. exports.BaseTreeViewer = void 0;
  6171. var _ui_utils = __webpack_require__(5);
  6172. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
  6173. 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); }
  6174. 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; }
  6175. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6176. 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); } }
  6177. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  6178. var TREEITEM_OFFSET_TOP = -100;
  6179. var TREEITEM_SELECTED_CLASS = "selected";
  6180. var BaseTreeViewer = /*#__PURE__*/function () {
  6181. function BaseTreeViewer(options) {
  6182. _classCallCheck(this, BaseTreeViewer);
  6183. if (this.constructor === BaseTreeViewer) {
  6184. throw new Error("Cannot initialize BaseTreeViewer.");
  6185. }
  6186. this.container = options.container;
  6187. this.eventBus = options.eventBus;
  6188. this.reset();
  6189. }
  6190. _createClass(BaseTreeViewer, [{
  6191. key: "reset",
  6192. value: function reset() {
  6193. this._pdfDocument = null;
  6194. this._lastToggleIsShow = true;
  6195. this._currentTreeItem = null;
  6196. this.container.textContent = "";
  6197. this.container.classList.remove("treeWithDeepNesting");
  6198. }
  6199. }, {
  6200. key: "_dispatchEvent",
  6201. value: function _dispatchEvent(count) {
  6202. throw new Error("Not implemented: _dispatchEvent");
  6203. }
  6204. }, {
  6205. key: "_bindLink",
  6206. value: function _bindLink(element, params) {
  6207. throw new Error("Not implemented: _bindLink");
  6208. }
  6209. }, {
  6210. key: "_normalizeTextContent",
  6211. value: function _normalizeTextContent(str) {
  6212. return (0, _ui_utils.removeNullCharacters)(str, true) || "\u2013";
  6213. }
  6214. }, {
  6215. key: "_addToggleButton",
  6216. value: function _addToggleButton(div) {
  6217. var _this = this;
  6218. var hidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6219. var toggler = document.createElement("div");
  6220. toggler.className = "treeItemToggler";
  6221. if (hidden) {
  6222. toggler.classList.add("treeItemsHidden");
  6223. }
  6224. toggler.onclick = function (evt) {
  6225. evt.stopPropagation();
  6226. toggler.classList.toggle("treeItemsHidden");
  6227. if (evt.shiftKey) {
  6228. var shouldShowAll = !toggler.classList.contains("treeItemsHidden");
  6229. _this._toggleTreeItem(div, shouldShowAll);
  6230. }
  6231. };
  6232. div.insertBefore(toggler, div.firstChild);
  6233. }
  6234. }, {
  6235. key: "_toggleTreeItem",
  6236. value: function _toggleTreeItem(root) {
  6237. var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6238. this._lastToggleIsShow = show;
  6239. var _iterator = _createForOfIteratorHelper(root.querySelectorAll(".treeItemToggler")),
  6240. _step;
  6241. try {
  6242. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  6243. var toggler = _step.value;
  6244. toggler.classList.toggle("treeItemsHidden", !show);
  6245. }
  6246. } catch (err) {
  6247. _iterator.e(err);
  6248. } finally {
  6249. _iterator.f();
  6250. }
  6251. }
  6252. }, {
  6253. key: "_toggleAllTreeItems",
  6254. value: function _toggleAllTreeItems() {
  6255. this._toggleTreeItem(this.container, !this._lastToggleIsShow);
  6256. }
  6257. }, {
  6258. key: "_finishRendering",
  6259. value: function _finishRendering(fragment, count) {
  6260. var hasAnyNesting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6261. if (hasAnyNesting) {
  6262. this.container.classList.add("treeWithDeepNesting");
  6263. this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
  6264. }
  6265. this.container.appendChild(fragment);
  6266. this._dispatchEvent(count);
  6267. }
  6268. }, {
  6269. key: "render",
  6270. value: function render(params) {
  6271. throw new Error("Not implemented: render");
  6272. }
  6273. }, {
  6274. key: "_updateCurrentTreeItem",
  6275. value: function _updateCurrentTreeItem() {
  6276. var treeItem = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  6277. if (this._currentTreeItem) {
  6278. this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS);
  6279. this._currentTreeItem = null;
  6280. }
  6281. if (treeItem) {
  6282. treeItem.classList.add(TREEITEM_SELECTED_CLASS);
  6283. this._currentTreeItem = treeItem;
  6284. }
  6285. }
  6286. }, {
  6287. key: "_scrollToCurrentTreeItem",
  6288. value: function _scrollToCurrentTreeItem(treeItem) {
  6289. if (!treeItem) {
  6290. return;
  6291. }
  6292. var currentNode = treeItem.parentNode;
  6293. while (currentNode && currentNode !== this.container) {
  6294. if (currentNode.classList.contains("treeItem")) {
  6295. var toggler = currentNode.firstElementChild;
  6296. toggler === null || toggler === void 0 ? void 0 : toggler.classList.remove("treeItemsHidden");
  6297. }
  6298. currentNode = currentNode.parentNode;
  6299. }
  6300. this._updateCurrentTreeItem(treeItem);
  6301. this.container.scrollTo(treeItem.offsetLeft, treeItem.offsetTop + TREEITEM_OFFSET_TOP);
  6302. }
  6303. }]);
  6304. return BaseTreeViewer;
  6305. }();
  6306. exports.BaseTreeViewer = BaseTreeViewer;
  6307. /***/ }),
  6308. /* 16 */
  6309. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6310. Object.defineProperty(exports, "__esModule", ({
  6311. value: true
  6312. }));
  6313. exports.PDFDocumentProperties = void 0;
  6314. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  6315. var _pdfjsLib = __webpack_require__(7);
  6316. var _ui_utils = __webpack_require__(5);
  6317. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6318. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  6319. 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."); }
  6320. 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); }
  6321. 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; }
  6322. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
  6323. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  6324. 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); } }
  6325. 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); }); }; }
  6326. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6327. 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); } }
  6328. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  6329. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  6330. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  6331. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  6332. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  6333. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  6334. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  6335. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  6336. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  6337. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  6338. var DEFAULT_FIELD_CONTENT = "-";
  6339. var NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  6340. var US_PAGE_NAMES = {
  6341. "8.5x11": "Letter",
  6342. "8.5x14": "Legal"
  6343. };
  6344. var METRIC_PAGE_NAMES = {
  6345. "297x420": "A3",
  6346. "210x297": "A4"
  6347. };
  6348. function getPageName(size, isPortrait, pageNames) {
  6349. var width = isPortrait ? size.width : size.height;
  6350. var height = isPortrait ? size.height : size.width;
  6351. return pageNames["".concat(width, "x").concat(height)];
  6352. }
  6353. var _fieldData = /*#__PURE__*/new WeakMap();
  6354. var _reset = /*#__PURE__*/new WeakSet();
  6355. var _updateUI = /*#__PURE__*/new WeakSet();
  6356. var _parseFileSize = /*#__PURE__*/new WeakSet();
  6357. var _parsePageSize = /*#__PURE__*/new WeakSet();
  6358. var _parseDate = /*#__PURE__*/new WeakSet();
  6359. var _parseLinearization = /*#__PURE__*/new WeakSet();
  6360. var PDFDocumentProperties = /*#__PURE__*/function () {
  6361. function PDFDocumentProperties(_ref, overlayManager, eventBus, l10n) {
  6362. var _this = this;
  6363. var dialog = _ref.dialog,
  6364. fields = _ref.fields,
  6365. closeButton = _ref.closeButton;
  6366. _classCallCheck(this, PDFDocumentProperties);
  6367. _classPrivateMethodInitSpec(this, _parseLinearization);
  6368. _classPrivateMethodInitSpec(this, _parseDate);
  6369. _classPrivateMethodInitSpec(this, _parsePageSize);
  6370. _classPrivateMethodInitSpec(this, _parseFileSize);
  6371. _classPrivateMethodInitSpec(this, _updateUI);
  6372. _classPrivateMethodInitSpec(this, _reset);
  6373. _classPrivateFieldInitSpec(this, _fieldData, {
  6374. writable: true,
  6375. value: null
  6376. });
  6377. this.dialog = dialog;
  6378. this.fields = fields;
  6379. this.overlayManager = overlayManager;
  6380. this.l10n = l10n;
  6381. _classPrivateMethodGet(this, _reset, _reset2).call(this);
  6382. closeButton.addEventListener("click", this.close.bind(this));
  6383. this.overlayManager.register(this.dialog);
  6384. eventBus._on("pagechanging", function (evt) {
  6385. _this._currentPageNumber = evt.pageNumber;
  6386. });
  6387. eventBus._on("rotationchanging", function (evt) {
  6388. _this._pagesRotation = evt.pagesRotation;
  6389. });
  6390. this._isNonMetricLocale = true;
  6391. l10n.getLanguage().then(function (locale) {
  6392. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  6393. });
  6394. }
  6395. _createClass(PDFDocumentProperties, [{
  6396. key: "open",
  6397. value: function () {
  6398. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  6399. var _this2 = this;
  6400. var 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;
  6401. return _regenerator["default"].wrap(function _callee$(_context) {
  6402. while (1) {
  6403. switch (_context.prev = _context.next) {
  6404. case 0:
  6405. _context.next = 2;
  6406. return Promise.all([this.overlayManager.open(this.dialog), this._dataAvailableCapability.promise]);
  6407. case 2:
  6408. currentPageNumber = this._currentPageNumber;
  6409. pagesRotation = this._pagesRotation;
  6410. if (!(_classPrivateFieldGet(this, _fieldData) && currentPageNumber === _classPrivateFieldGet(this, _fieldData)._currentPageNumber && pagesRotation === _classPrivateFieldGet(this, _fieldData)._pagesRotation)) {
  6411. _context.next = 7;
  6412. break;
  6413. }
  6414. _classPrivateMethodGet(this, _updateUI, _updateUI2).call(this);
  6415. return _context.abrupt("return");
  6416. case 7:
  6417. _context.next = 9;
  6418. return this.pdfDocument.getMetadata();
  6419. case 9:
  6420. _yield$this$pdfDocume = _context.sent;
  6421. info = _yield$this$pdfDocume.info;
  6422. contentDispositionFilename = _yield$this$pdfDocume.contentDispositionFilename;
  6423. contentLength = _yield$this$pdfDocume.contentLength;
  6424. _context.next = 15;
  6425. return Promise.all([contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(this.url), _classPrivateMethodGet(this, _parseFileSize, _parseFileSize2).call(this, contentLength), _classPrivateMethodGet(this, _parseDate, _parseDate2).call(this, info.CreationDate), _classPrivateMethodGet(this, _parseDate, _parseDate2).call(this, info.ModDate), this.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
  6426. return _classPrivateMethodGet(_this2, _parsePageSize, _parsePageSize2).call(_this2, (0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  6427. }), _classPrivateMethodGet(this, _parseLinearization, _parseLinearization2).call(this, info.IsLinearized)]);
  6428. case 15:
  6429. _yield$Promise$all = _context.sent;
  6430. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 6);
  6431. fileName = _yield$Promise$all2[0];
  6432. fileSize = _yield$Promise$all2[1];
  6433. creationDate = _yield$Promise$all2[2];
  6434. modificationDate = _yield$Promise$all2[3];
  6435. pageSize = _yield$Promise$all2[4];
  6436. isLinearized = _yield$Promise$all2[5];
  6437. _classPrivateFieldSet(this, _fieldData, Object.freeze({
  6438. fileName: fileName,
  6439. fileSize: fileSize,
  6440. title: info.Title,
  6441. author: info.Author,
  6442. subject: info.Subject,
  6443. keywords: info.Keywords,
  6444. creationDate: creationDate,
  6445. modificationDate: modificationDate,
  6446. creator: info.Creator,
  6447. producer: info.Producer,
  6448. version: info.PDFFormatVersion,
  6449. pageCount: this.pdfDocument.numPages,
  6450. pageSize: pageSize,
  6451. linearized: isLinearized,
  6452. _currentPageNumber: currentPageNumber,
  6453. _pagesRotation: pagesRotation
  6454. }));
  6455. _classPrivateMethodGet(this, _updateUI, _updateUI2).call(this);
  6456. _context.next = 27;
  6457. return this.pdfDocument.getDownloadInfo();
  6458. case 27:
  6459. _yield$this$pdfDocume2 = _context.sent;
  6460. length = _yield$this$pdfDocume2.length;
  6461. if (!(contentLength === length)) {
  6462. _context.next = 31;
  6463. break;
  6464. }
  6465. return _context.abrupt("return");
  6466. case 31:
  6467. data = Object.assign(Object.create(null), _classPrivateFieldGet(this, _fieldData));
  6468. _context.next = 34;
  6469. return _classPrivateMethodGet(this, _parseFileSize, _parseFileSize2).call(this, length);
  6470. case 34:
  6471. data.fileSize = _context.sent;
  6472. _classPrivateFieldSet(this, _fieldData, Object.freeze(data));
  6473. _classPrivateMethodGet(this, _updateUI, _updateUI2).call(this);
  6474. case 37:
  6475. case "end":
  6476. return _context.stop();
  6477. }
  6478. }
  6479. }, _callee, this);
  6480. }));
  6481. function open() {
  6482. return _open.apply(this, arguments);
  6483. }
  6484. return open;
  6485. }()
  6486. }, {
  6487. key: "close",
  6488. value: function () {
  6489. var _close = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  6490. return _regenerator["default"].wrap(function _callee2$(_context2) {
  6491. while (1) {
  6492. switch (_context2.prev = _context2.next) {
  6493. case 0:
  6494. this.overlayManager.close(this.dialog);
  6495. case 1:
  6496. case "end":
  6497. return _context2.stop();
  6498. }
  6499. }
  6500. }, _callee2, this);
  6501. }));
  6502. function close() {
  6503. return _close.apply(this, arguments);
  6504. }
  6505. return close;
  6506. }()
  6507. }, {
  6508. key: "setDocument",
  6509. value: function setDocument(pdfDocument) {
  6510. var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6511. if (this.pdfDocument) {
  6512. _classPrivateMethodGet(this, _reset, _reset2).call(this);
  6513. _classPrivateMethodGet(this, _updateUI, _updateUI2).call(this, true);
  6514. }
  6515. if (!pdfDocument) {
  6516. return;
  6517. }
  6518. this.pdfDocument = pdfDocument;
  6519. this.url = url;
  6520. this._dataAvailableCapability.resolve();
  6521. }
  6522. }]);
  6523. return PDFDocumentProperties;
  6524. }();
  6525. exports.PDFDocumentProperties = PDFDocumentProperties;
  6526. function _reset2() {
  6527. this.pdfDocument = null;
  6528. this.url = null;
  6529. _classPrivateFieldSet(this, _fieldData, null);
  6530. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  6531. this._currentPageNumber = 1;
  6532. this._pagesRotation = 0;
  6533. }
  6534. function _updateUI2() {
  6535. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6536. if (reset || !_classPrivateFieldGet(this, _fieldData)) {
  6537. for (var id in this.fields) {
  6538. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  6539. }
  6540. return;
  6541. }
  6542. if (this.overlayManager.active !== this.dialog) {
  6543. return;
  6544. }
  6545. for (var _id in this.fields) {
  6546. var content = _classPrivateFieldGet(this, _fieldData)[_id];
  6547. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  6548. }
  6549. }
  6550. function _parseFileSize2() {
  6551. return _parseFileSize3.apply(this, arguments);
  6552. }
  6553. function _parseFileSize3() {
  6554. _parseFileSize3 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  6555. var fileSize,
  6556. kb,
  6557. mb,
  6558. _args3 = arguments;
  6559. return _regenerator["default"].wrap(function _callee3$(_context3) {
  6560. while (1) {
  6561. switch (_context3.prev = _context3.next) {
  6562. case 0:
  6563. fileSize = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : 0;
  6564. kb = fileSize / 1024, mb = kb / 1024;
  6565. if (kb) {
  6566. _context3.next = 4;
  6567. break;
  6568. }
  6569. return _context3.abrupt("return", undefined);
  6570. case 4:
  6571. return _context3.abrupt("return", this.l10n.get("document_properties_".concat(mb >= 1 ? "mb" : "kb"), {
  6572. size_mb: mb >= 1 && (+mb.toPrecision(3)).toLocaleString(),
  6573. size_kb: mb < 1 && (+kb.toPrecision(3)).toLocaleString(),
  6574. size_b: fileSize.toLocaleString()
  6575. }));
  6576. case 5:
  6577. case "end":
  6578. return _context3.stop();
  6579. }
  6580. }
  6581. }, _callee3, this);
  6582. }));
  6583. return _parseFileSize3.apply(this, arguments);
  6584. }
  6585. function _parsePageSize2(_x, _x2) {
  6586. return _parsePageSize3.apply(this, arguments);
  6587. }
  6588. function _parsePageSize3() {
  6589. _parsePageSize3 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(pageSizeInches, pagesRotation) {
  6590. var isPortrait, sizeInches, sizeMillimeters, rawName, exactMillimeters, intMillimeters, _yield$Promise$all3, _yield$Promise$all4, _yield$Promise$all4$, width, height, unit, name, orientation;
  6591. return _regenerator["default"].wrap(function _callee4$(_context4) {
  6592. while (1) {
  6593. switch (_context4.prev = _context4.next) {
  6594. case 0:
  6595. if (pageSizeInches) {
  6596. _context4.next = 2;
  6597. break;
  6598. }
  6599. return _context4.abrupt("return", undefined);
  6600. case 2:
  6601. if (pagesRotation % 180 !== 0) {
  6602. pageSizeInches = {
  6603. width: pageSizeInches.height,
  6604. height: pageSizeInches.width
  6605. };
  6606. }
  6607. isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  6608. sizeInches = {
  6609. width: Math.round(pageSizeInches.width * 100) / 100,
  6610. height: Math.round(pageSizeInches.height * 100) / 100
  6611. };
  6612. sizeMillimeters = {
  6613. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  6614. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  6615. };
  6616. rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  6617. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  6618. exactMillimeters = {
  6619. width: pageSizeInches.width * 25.4,
  6620. height: pageSizeInches.height * 25.4
  6621. };
  6622. intMillimeters = {
  6623. width: Math.round(sizeMillimeters.width),
  6624. height: Math.round(sizeMillimeters.height)
  6625. };
  6626. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  6627. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  6628. if (rawName) {
  6629. sizeInches = {
  6630. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  6631. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  6632. };
  6633. sizeMillimeters = intMillimeters;
  6634. }
  6635. }
  6636. }
  6637. _context4.next = 10;
  6638. 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"))]);
  6639. case 10:
  6640. _yield$Promise$all3 = _context4.sent;
  6641. _yield$Promise$all4 = _slicedToArray(_yield$Promise$all3, 4);
  6642. _yield$Promise$all4$ = _yield$Promise$all4[0];
  6643. width = _yield$Promise$all4$.width;
  6644. height = _yield$Promise$all4$.height;
  6645. unit = _yield$Promise$all4[1];
  6646. name = _yield$Promise$all4[2];
  6647. orientation = _yield$Promise$all4[3];
  6648. return _context4.abrupt("return", this.l10n.get("document_properties_page_size_dimension_".concat(name ? "name_" : "", "string"), {
  6649. width: width.toLocaleString(),
  6650. height: height.toLocaleString(),
  6651. unit: unit,
  6652. name: name,
  6653. orientation: orientation
  6654. }));
  6655. case 19:
  6656. case "end":
  6657. return _context4.stop();
  6658. }
  6659. }
  6660. }, _callee4, this);
  6661. }));
  6662. return _parsePageSize3.apply(this, arguments);
  6663. }
  6664. function _parseDate2(_x3) {
  6665. return _parseDate3.apply(this, arguments);
  6666. }
  6667. function _parseDate3() {
  6668. _parseDate3 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(inputDate) {
  6669. var dateObject;
  6670. return _regenerator["default"].wrap(function _callee5$(_context5) {
  6671. while (1) {
  6672. switch (_context5.prev = _context5.next) {
  6673. case 0:
  6674. dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  6675. if (dateObject) {
  6676. _context5.next = 3;
  6677. break;
  6678. }
  6679. return _context5.abrupt("return", undefined);
  6680. case 3:
  6681. return _context5.abrupt("return", this.l10n.get("document_properties_date_string", {
  6682. date: dateObject.toLocaleDateString(),
  6683. time: dateObject.toLocaleTimeString()
  6684. }));
  6685. case 4:
  6686. case "end":
  6687. return _context5.stop();
  6688. }
  6689. }
  6690. }, _callee5, this);
  6691. }));
  6692. return _parseDate3.apply(this, arguments);
  6693. }
  6694. function _parseLinearization2(isLinearized) {
  6695. return this.l10n.get("document_properties_linearized_".concat(isLinearized ? "yes" : "no"));
  6696. }
  6697. /***/ }),
  6698. /* 17 */
  6699. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6700. Object.defineProperty(exports, "__esModule", ({
  6701. value: true
  6702. }));
  6703. exports.PDFFindBar = void 0;
  6704. var _pdf_find_controller = __webpack_require__(18);
  6705. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6706. 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); } }
  6707. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  6708. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  6709. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  6710. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  6711. var MATCHES_COUNT_LIMIT = 1000;
  6712. var _adjustWidth = /*#__PURE__*/new WeakSet();
  6713. var PDFFindBar = /*#__PURE__*/function () {
  6714. function PDFFindBar(options, eventBus, l10n) {
  6715. var _this = this;
  6716. _classCallCheck(this, PDFFindBar);
  6717. _classPrivateMethodInitSpec(this, _adjustWidth);
  6718. this.opened = false;
  6719. this.bar = options.bar;
  6720. this.toggleButton = options.toggleButton;
  6721. this.findField = options.findField;
  6722. this.highlightAll = options.highlightAllCheckbox;
  6723. this.caseSensitive = options.caseSensitiveCheckbox;
  6724. this.matchDiacritics = options.matchDiacriticsCheckbox;
  6725. this.entireWord = options.entireWordCheckbox;
  6726. this.findMsg = options.findMsg;
  6727. this.findResultsCount = options.findResultsCount;
  6728. this.findPreviousButton = options.findPreviousButton;
  6729. this.findNextButton = options.findNextButton;
  6730. this.eventBus = eventBus;
  6731. this.l10n = l10n;
  6732. this.toggleButton.addEventListener("click", function () {
  6733. _this.toggle();
  6734. });
  6735. this.findField.addEventListener("input", function () {
  6736. _this.dispatchEvent("");
  6737. });
  6738. this.bar.addEventListener("keydown", function (e) {
  6739. switch (e.keyCode) {
  6740. case 13:
  6741. if (e.target === _this.findField) {
  6742. _this.dispatchEvent("again", e.shiftKey);
  6743. }
  6744. break;
  6745. case 27:
  6746. _this.close();
  6747. break;
  6748. }
  6749. });
  6750. this.findPreviousButton.addEventListener("click", function () {
  6751. _this.dispatchEvent("again", true);
  6752. });
  6753. this.findNextButton.addEventListener("click", function () {
  6754. _this.dispatchEvent("again", false);
  6755. });
  6756. this.highlightAll.addEventListener("click", function () {
  6757. _this.dispatchEvent("highlightallchange");
  6758. });
  6759. this.caseSensitive.addEventListener("click", function () {
  6760. _this.dispatchEvent("casesensitivitychange");
  6761. });
  6762. this.entireWord.addEventListener("click", function () {
  6763. _this.dispatchEvent("entirewordchange");
  6764. });
  6765. this.matchDiacritics.addEventListener("click", function () {
  6766. _this.dispatchEvent("diacriticmatchingchange");
  6767. });
  6768. this.eventBus._on("resize", _classPrivateMethodGet(this, _adjustWidth, _adjustWidth2).bind(this));
  6769. }
  6770. _createClass(PDFFindBar, [{
  6771. key: "reset",
  6772. value: function reset() {
  6773. this.updateUIState();
  6774. }
  6775. }, {
  6776. key: "dispatchEvent",
  6777. value: function dispatchEvent(type) {
  6778. var findPrev = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6779. this.eventBus.dispatch("find", {
  6780. source: this,
  6781. type: type,
  6782. query: this.findField.value,
  6783. phraseSearch: true,
  6784. caseSensitive: this.caseSensitive.checked,
  6785. entireWord: this.entireWord.checked,
  6786. highlightAll: this.highlightAll.checked,
  6787. findPrevious: findPrev,
  6788. matchDiacritics: this.matchDiacritics.checked
  6789. });
  6790. }
  6791. }, {
  6792. key: "updateUIState",
  6793. value: function updateUIState(state, previous, matchesCount) {
  6794. var _this2 = this;
  6795. var findMsg = Promise.resolve("");
  6796. var status = "";
  6797. switch (state) {
  6798. case _pdf_find_controller.FindState.FOUND:
  6799. break;
  6800. case _pdf_find_controller.FindState.PENDING:
  6801. status = "pending";
  6802. break;
  6803. case _pdf_find_controller.FindState.NOT_FOUND:
  6804. findMsg = this.l10n.get("find_not_found");
  6805. status = "notFound";
  6806. break;
  6807. case _pdf_find_controller.FindState.WRAPPED:
  6808. findMsg = this.l10n.get("find_reached_".concat(previous ? "top" : "bottom"));
  6809. break;
  6810. }
  6811. this.findField.setAttribute("data-status", status);
  6812. this.findField.setAttribute("aria-invalid", state === _pdf_find_controller.FindState.NOT_FOUND);
  6813. findMsg.then(function (msg) {
  6814. _this2.findMsg.textContent = msg;
  6815. _classPrivateMethodGet(_this2, _adjustWidth, _adjustWidth2).call(_this2);
  6816. });
  6817. this.updateResultsCount(matchesCount);
  6818. }
  6819. }, {
  6820. key: "updateResultsCount",
  6821. value: function updateResultsCount() {
  6822. var _this3 = this;
  6823. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  6824. _ref$current = _ref.current,
  6825. current = _ref$current === void 0 ? 0 : _ref$current,
  6826. _ref$total = _ref.total,
  6827. total = _ref$total === void 0 ? 0 : _ref$total;
  6828. var limit = MATCHES_COUNT_LIMIT;
  6829. var matchCountMsg = Promise.resolve("");
  6830. if (total > 0) {
  6831. if (total > limit) {
  6832. var key = "find_match_count_limit";
  6833. matchCountMsg = this.l10n.get(key, {
  6834. limit: limit
  6835. });
  6836. } else {
  6837. var _key = "find_match_count";
  6838. matchCountMsg = this.l10n.get(_key, {
  6839. current: current,
  6840. total: total
  6841. });
  6842. }
  6843. }
  6844. matchCountMsg.then(function (msg) {
  6845. _this3.findResultsCount.textContent = msg;
  6846. _classPrivateMethodGet(_this3, _adjustWidth, _adjustWidth2).call(_this3);
  6847. });
  6848. }
  6849. }, {
  6850. key: "open",
  6851. value: function open() {
  6852. if (!this.opened) {
  6853. this.opened = true;
  6854. this.toggleButton.classList.add("toggled");
  6855. this.toggleButton.setAttribute("aria-expanded", "true");
  6856. this.bar.classList.remove("hidden");
  6857. }
  6858. this.findField.select();
  6859. this.findField.focus();
  6860. _classPrivateMethodGet(this, _adjustWidth, _adjustWidth2).call(this);
  6861. }
  6862. }, {
  6863. key: "close",
  6864. value: function close() {
  6865. if (!this.opened) {
  6866. return;
  6867. }
  6868. this.opened = false;
  6869. this.toggleButton.classList.remove("toggled");
  6870. this.toggleButton.setAttribute("aria-expanded", "false");
  6871. this.bar.classList.add("hidden");
  6872. this.eventBus.dispatch("findbarclose", {
  6873. source: this
  6874. });
  6875. }
  6876. }, {
  6877. key: "toggle",
  6878. value: function toggle() {
  6879. if (this.opened) {
  6880. this.close();
  6881. } else {
  6882. this.open();
  6883. }
  6884. }
  6885. }]);
  6886. return PDFFindBar;
  6887. }();
  6888. exports.PDFFindBar = PDFFindBar;
  6889. function _adjustWidth2() {
  6890. if (!this.opened) {
  6891. return;
  6892. }
  6893. this.bar.classList.remove("wrapContainers");
  6894. var findbarHeight = this.bar.clientHeight;
  6895. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  6896. if (findbarHeight > inputContainerHeight) {
  6897. this.bar.classList.add("wrapContainers");
  6898. }
  6899. }
  6900. /***/ }),
  6901. /* 18 */
  6902. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6903. Object.defineProperty(exports, "__esModule", ({
  6904. value: true
  6905. }));
  6906. exports.PDFFindController = exports.FindState = void 0;
  6907. var _ui_utils = __webpack_require__(5);
  6908. var _pdfjsLib = __webpack_require__(7);
  6909. var _pdf_find_utils = __webpack_require__(19);
  6910. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
  6911. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  6912. 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."); }
  6913. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
  6914. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  6915. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6916. 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); } }
  6917. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  6918. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  6919. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  6920. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  6921. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  6922. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  6923. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  6924. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  6925. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  6926. 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."); }
  6927. 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); }
  6928. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
  6929. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  6930. 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; }
  6931. var FindState = {
  6932. FOUND: 0,
  6933. NOT_FOUND: 1,
  6934. WRAPPED: 2,
  6935. PENDING: 3
  6936. };
  6937. exports.FindState = FindState;
  6938. var FIND_TIMEOUT = 250;
  6939. var MATCH_SCROLL_OFFSET_TOP = -50;
  6940. var MATCH_SCROLL_OFFSET_LEFT = -400;
  6941. var CHARACTERS_TO_NORMALIZE = {
  6942. "\u2010": "-",
  6943. "\u2018": "'",
  6944. "\u2019": "'",
  6945. "\u201A": "'",
  6946. "\u201B": "'",
  6947. "\u201C": '"',
  6948. "\u201D": '"',
  6949. "\u201E": '"',
  6950. "\u201F": '"',
  6951. "\xBC": "1/4",
  6952. "\xBD": "1/2",
  6953. "\xBE": "3/4"
  6954. };
  6955. var DIACRITICS_EXCEPTION = new Set([0x3099, 0x309a, 0x094d, 0x09cd, 0x0a4d, 0x0acd, 0x0b4d, 0x0bcd, 0x0c4d, 0x0ccd, 0x0d3b, 0x0d3c, 0x0d4d, 0x0dca, 0x0e3a, 0x0eba, 0x0f84, 0x1039, 0x103a, 0x1714, 0x1734, 0x17d2, 0x1a60, 0x1b44, 0x1baa, 0x1bab, 0x1bf2, 0x1bf3, 0x2d7f, 0xa806, 0xa82c, 0xa8c4, 0xa953, 0xa9c0, 0xaaf6, 0xabed, 0x0c56, 0x0f71, 0x0f72, 0x0f7a, 0x0f7b, 0x0f7c, 0x0f7d, 0x0f80, 0x0f74]);
  6956. var DIACRITICS_EXCEPTION_STR = _toConsumableArray(DIACRITICS_EXCEPTION.values()).map(function (x) {
  6957. return String.fromCharCode(x);
  6958. }).join("");
  6959. var DIACRITICS_REG_EXP = /(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD3E\uDD40\uDD42\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE8A-\uDE99]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uDB40[\uDD00-\uDDEF])+/g;
  6960. var SPECIAL_CHARS_REG_EXP = /([\$\(-\+\.\?\[-\^\{-\}])|((?:[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]))|([\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+)|((?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD3E\uDD40\uDD42\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE8A-\uDE99]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uDB40[\uDD00-\uDDEF]))|((?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A]))/g;
  6961. var NOT_DIACRITIC_FROM_END_REG_EXP = /((?:(?![\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD3E\uDD40\uDD42\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE8A-\uDE99]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uDB40[\uDD00-\uDDEF])[\s\S]))(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD3E\uDD40\uDD42\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE8A-\uDE99]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uDB40[\uDD00-\uDDEF])*$/;
  6962. var NOT_DIACRITIC_FROM_START_REG_EXP = /^(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD3E\uDD40\uDD42\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE8A-\uDE99]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uDB40[\uDD00-\uDDEF])*((?:(?![\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD3E\uDD40\uDD42\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE8A-\uDE99]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uDB40[\uDD00-\uDDEF])[\s\S]))/;
  6963. var normalizationRegex = null;
  6964. function normalize(text) {
  6965. if (!normalizationRegex) {
  6966. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  6967. normalizationRegex = new RegExp("([".concat(replace, "])|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(\\n)"), "gum");
  6968. }
  6969. var rawDiacriticsPositions = [];
  6970. var m;
  6971. while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) {
  6972. rawDiacriticsPositions.push([m[0].length, m.index]);
  6973. }
  6974. var normalized = text.normalize("NFD");
  6975. var positions = [[0, 0]];
  6976. var k = 0;
  6977. var shift = 0;
  6978. var shiftOrigin = 0;
  6979. var eol = 0;
  6980. var hasDiacritics = false;
  6981. normalized = normalized.replace(normalizationRegex, function (match, p1, p2, p3, p4, i) {
  6982. i -= shiftOrigin;
  6983. if (p1) {
  6984. var replacement = CHARACTERS_TO_NORMALIZE[match];
  6985. var jj = replacement.length;
  6986. for (var j = 1; j < jj; j++) {
  6987. positions.push([i - shift + j, shift - j]);
  6988. }
  6989. shift -= jj - 1;
  6990. return replacement;
  6991. }
  6992. if (p2) {
  6993. var _rawDiacriticsPositio;
  6994. var hasTrailingDashEOL = p2.endsWith("\n");
  6995. var len = hasTrailingDashEOL ? p2.length - 2 : p2.length;
  6996. hasDiacritics = true;
  6997. var _jj = len;
  6998. if (i + eol === ((_rawDiacriticsPositio = rawDiacriticsPositions[k]) === null || _rawDiacriticsPositio === void 0 ? void 0 : _rawDiacriticsPositio[1])) {
  6999. _jj -= rawDiacriticsPositions[k][0];
  7000. ++k;
  7001. }
  7002. for (var _j = 1; _j < _jj + 1; _j++) {
  7003. positions.push([i - 1 - shift + _j, shift - _j]);
  7004. }
  7005. shift -= _jj;
  7006. shiftOrigin += _jj;
  7007. if (hasTrailingDashEOL) {
  7008. i += len - 1;
  7009. positions.push([i - shift + 1, 1 + shift]);
  7010. shift += 1;
  7011. shiftOrigin += 1;
  7012. eol += 1;
  7013. return p2.slice(0, len);
  7014. }
  7015. return p2;
  7016. }
  7017. if (p3) {
  7018. positions.push([i - shift + 1, 1 + shift]);
  7019. shift += 1;
  7020. shiftOrigin += 1;
  7021. eol += 1;
  7022. return p3.charAt(0);
  7023. }
  7024. positions.push([i - shift + 1, shift - 1]);
  7025. shift -= 1;
  7026. shiftOrigin += 1;
  7027. eol += 1;
  7028. return " ";
  7029. });
  7030. positions.push([normalized.length, shift]);
  7031. return [normalized, positions, hasDiacritics];
  7032. }
  7033. function getOriginalIndex(diffs, pos, len) {
  7034. if (!diffs) {
  7035. return [pos, len];
  7036. }
  7037. var start = pos;
  7038. var end = pos + len;
  7039. var i = (0, _ui_utils.binarySearchFirstItem)(diffs, function (x) {
  7040. return x[0] >= start;
  7041. });
  7042. if (diffs[i][0] > start) {
  7043. --i;
  7044. }
  7045. var j = (0, _ui_utils.binarySearchFirstItem)(diffs, function (x) {
  7046. return x[0] >= end;
  7047. }, i);
  7048. if (diffs[j][0] > end) {
  7049. --j;
  7050. }
  7051. return [start + diffs[i][1], len + diffs[j][1] - diffs[i][1]];
  7052. }
  7053. var _onFind = /*#__PURE__*/new WeakSet();
  7054. var _reset = /*#__PURE__*/new WeakSet();
  7055. var _query = /*#__PURE__*/new WeakMap();
  7056. var _shouldDirtyMatch = /*#__PURE__*/new WeakSet();
  7057. var _isEntireWord = /*#__PURE__*/new WeakSet();
  7058. var _calculateRegExpMatch = /*#__PURE__*/new WeakSet();
  7059. var _convertToRegExpString = /*#__PURE__*/new WeakSet();
  7060. var _calculateMatch = /*#__PURE__*/new WeakSet();
  7061. var _extractText = /*#__PURE__*/new WeakSet();
  7062. var _updatePage = /*#__PURE__*/new WeakSet();
  7063. var _updateAllPages = /*#__PURE__*/new WeakSet();
  7064. var _nextMatch = /*#__PURE__*/new WeakSet();
  7065. var _matchesReady = /*#__PURE__*/new WeakSet();
  7066. var _nextPageMatch = /*#__PURE__*/new WeakSet();
  7067. var _advanceOffsetPage = /*#__PURE__*/new WeakSet();
  7068. var _updateMatch = /*#__PURE__*/new WeakSet();
  7069. var _onFindBarClose = /*#__PURE__*/new WeakSet();
  7070. var _requestMatchesCount = /*#__PURE__*/new WeakSet();
  7071. var _updateUIResultsCount = /*#__PURE__*/new WeakSet();
  7072. var _updateUIState = /*#__PURE__*/new WeakSet();
  7073. var PDFFindController = /*#__PURE__*/function () {
  7074. function PDFFindController(_ref) {
  7075. var _linkService = _ref.linkService,
  7076. eventBus = _ref.eventBus;
  7077. _classCallCheck(this, PDFFindController);
  7078. _classPrivateMethodInitSpec(this, _updateUIState);
  7079. _classPrivateMethodInitSpec(this, _updateUIResultsCount);
  7080. _classPrivateMethodInitSpec(this, _requestMatchesCount);
  7081. _classPrivateMethodInitSpec(this, _onFindBarClose);
  7082. _classPrivateMethodInitSpec(this, _updateMatch);
  7083. _classPrivateMethodInitSpec(this, _advanceOffsetPage);
  7084. _classPrivateMethodInitSpec(this, _nextPageMatch);
  7085. _classPrivateMethodInitSpec(this, _matchesReady);
  7086. _classPrivateMethodInitSpec(this, _nextMatch);
  7087. _classPrivateMethodInitSpec(this, _updateAllPages);
  7088. _classPrivateMethodInitSpec(this, _updatePage);
  7089. _classPrivateMethodInitSpec(this, _extractText);
  7090. _classPrivateMethodInitSpec(this, _calculateMatch);
  7091. _classPrivateMethodInitSpec(this, _convertToRegExpString);
  7092. _classPrivateMethodInitSpec(this, _calculateRegExpMatch);
  7093. _classPrivateMethodInitSpec(this, _isEntireWord);
  7094. _classPrivateMethodInitSpec(this, _shouldDirtyMatch);
  7095. _classPrivateFieldInitSpec(this, _query, {
  7096. get: _get_query,
  7097. set: void 0
  7098. });
  7099. _classPrivateMethodInitSpec(this, _reset);
  7100. _classPrivateMethodInitSpec(this, _onFind);
  7101. this._linkService = _linkService;
  7102. this._eventBus = eventBus;
  7103. _classPrivateMethodGet(this, _reset, _reset2).call(this);
  7104. eventBus._on("find", _classPrivateMethodGet(this, _onFind, _onFind2).bind(this));
  7105. eventBus._on("findbarclose", _classPrivateMethodGet(this, _onFindBarClose, _onFindBarClose2).bind(this));
  7106. }
  7107. _createClass(PDFFindController, [{
  7108. key: "highlightMatches",
  7109. get: function get() {
  7110. return this._highlightMatches;
  7111. }
  7112. }, {
  7113. key: "pageMatches",
  7114. get: function get() {
  7115. return this._pageMatches;
  7116. }
  7117. }, {
  7118. key: "pageMatchesLength",
  7119. get: function get() {
  7120. return this._pageMatchesLength;
  7121. }
  7122. }, {
  7123. key: "selected",
  7124. get: function get() {
  7125. return this._selected;
  7126. }
  7127. }, {
  7128. key: "state",
  7129. get: function get() {
  7130. return this._state;
  7131. }
  7132. }, {
  7133. key: "setDocument",
  7134. value: function setDocument(pdfDocument) {
  7135. if (this._pdfDocument) {
  7136. _classPrivateMethodGet(this, _reset, _reset2).call(this);
  7137. }
  7138. if (!pdfDocument) {
  7139. return;
  7140. }
  7141. this._pdfDocument = pdfDocument;
  7142. this._firstPageCapability.resolve();
  7143. }
  7144. }, {
  7145. key: "scrollMatchIntoView",
  7146. value: function scrollMatchIntoView(_ref2) {
  7147. var _ref2$element = _ref2.element,
  7148. element = _ref2$element === void 0 ? null : _ref2$element,
  7149. _ref2$selectedLeft = _ref2.selectedLeft,
  7150. selectedLeft = _ref2$selectedLeft === void 0 ? 0 : _ref2$selectedLeft,
  7151. _ref2$pageIndex = _ref2.pageIndex,
  7152. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  7153. _ref2$matchIndex = _ref2.matchIndex,
  7154. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  7155. if (!this._scrollMatches || !element) {
  7156. return;
  7157. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  7158. return;
  7159. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  7160. return;
  7161. }
  7162. this._scrollMatches = false;
  7163. var spot = {
  7164. top: MATCH_SCROLL_OFFSET_TOP,
  7165. left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT
  7166. };
  7167. (0, _ui_utils.scrollIntoView)(element, spot, true);
  7168. }
  7169. }]);
  7170. return PDFFindController;
  7171. }();
  7172. exports.PDFFindController = PDFFindController;
  7173. function _onFind2(state) {
  7174. var _this = this;
  7175. if (!state) {
  7176. return;
  7177. }
  7178. var pdfDocument = this._pdfDocument;
  7179. var type = state.type;
  7180. if (this._state === null || _classPrivateMethodGet(this, _shouldDirtyMatch, _shouldDirtyMatch2).call(this, state)) {
  7181. this._dirtyMatch = true;
  7182. }
  7183. this._state = state;
  7184. if (type !== "highlightallchange") {
  7185. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, FindState.PENDING);
  7186. }
  7187. this._firstPageCapability.promise.then(function () {
  7188. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  7189. return;
  7190. }
  7191. _classPrivateMethodGet(_this, _extractText, _extractText2).call(_this);
  7192. var findbarClosed = !_this._highlightMatches;
  7193. var pendingTimeout = !!_this._findTimeout;
  7194. if (_this._findTimeout) {
  7195. clearTimeout(_this._findTimeout);
  7196. _this._findTimeout = null;
  7197. }
  7198. if (!type) {
  7199. _this._findTimeout = setTimeout(function () {
  7200. _classPrivateMethodGet(_this, _nextMatch, _nextMatch2).call(_this);
  7201. _this._findTimeout = null;
  7202. }, FIND_TIMEOUT);
  7203. } else if (_this._dirtyMatch) {
  7204. _classPrivateMethodGet(_this, _nextMatch, _nextMatch2).call(_this);
  7205. } else if (type === "again") {
  7206. _classPrivateMethodGet(_this, _nextMatch, _nextMatch2).call(_this);
  7207. if (findbarClosed && _this._state.highlightAll) {
  7208. _classPrivateMethodGet(_this, _updateAllPages, _updateAllPages2).call(_this);
  7209. }
  7210. } else if (type === "highlightallchange") {
  7211. if (pendingTimeout) {
  7212. _classPrivateMethodGet(_this, _nextMatch, _nextMatch2).call(_this);
  7213. } else {
  7214. _this._highlightMatches = true;
  7215. }
  7216. _classPrivateMethodGet(_this, _updateAllPages, _updateAllPages2).call(_this);
  7217. } else {
  7218. _classPrivateMethodGet(_this, _nextMatch, _nextMatch2).call(_this);
  7219. }
  7220. });
  7221. }
  7222. function _reset2() {
  7223. this._highlightMatches = false;
  7224. this._scrollMatches = false;
  7225. this._pdfDocument = null;
  7226. this._pageMatches = [];
  7227. this._pageMatchesLength = [];
  7228. this._state = null;
  7229. this._selected = {
  7230. pageIdx: -1,
  7231. matchIdx: -1
  7232. };
  7233. this._offset = {
  7234. pageIdx: null,
  7235. matchIdx: null,
  7236. wrapped: false
  7237. };
  7238. this._extractTextPromises = [];
  7239. this._pageContents = [];
  7240. this._pageDiffs = [];
  7241. this._hasDiacritics = [];
  7242. this._matchesCountTotal = 0;
  7243. this._pagesToSearch = null;
  7244. this._pendingFindMatches = new Set();
  7245. this._resumePageIdx = null;
  7246. this._dirtyMatch = false;
  7247. clearTimeout(this._findTimeout);
  7248. this._findTimeout = null;
  7249. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  7250. }
  7251. function _get_query() {
  7252. if (this._state.query !== this._rawQuery) {
  7253. this._rawQuery = this._state.query;
  7254. var _normalize = normalize(this._state.query);
  7255. var _normalize2 = _slicedToArray(_normalize, 1);
  7256. this._normalizedQuery = _normalize2[0];
  7257. }
  7258. return this._normalizedQuery;
  7259. }
  7260. function _shouldDirtyMatch2(state) {
  7261. if (state.query !== this._state.query) {
  7262. return true;
  7263. }
  7264. switch (state.type) {
  7265. case "again":
  7266. var pageNumber = this._selected.pageIdx + 1;
  7267. var linkService = this._linkService;
  7268. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  7269. return true;
  7270. }
  7271. return false;
  7272. case "highlightallchange":
  7273. return false;
  7274. }
  7275. return true;
  7276. }
  7277. function _isEntireWord2(content, startIdx, length) {
  7278. var match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP);
  7279. if (match) {
  7280. var first = content.charCodeAt(startIdx);
  7281. var limit = match[1].charCodeAt(0);
  7282. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  7283. return false;
  7284. }
  7285. }
  7286. match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP);
  7287. if (match) {
  7288. var last = content.charCodeAt(startIdx + length - 1);
  7289. var _limit = match[1].charCodeAt(0);
  7290. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  7291. return false;
  7292. }
  7293. }
  7294. return true;
  7295. }
  7296. function _calculateRegExpMatch2(query, entireWord, pageIndex, pageContent) {
  7297. var matches = [],
  7298. matchesLength = [];
  7299. var diffs = this._pageDiffs[pageIndex];
  7300. var match;
  7301. while ((match = query.exec(pageContent)) !== null) {
  7302. if (entireWord && !_classPrivateMethodGet(this, _isEntireWord, _isEntireWord2).call(this, pageContent, match.index, match[0].length)) {
  7303. continue;
  7304. }
  7305. var _getOriginalIndex = getOriginalIndex(diffs, match.index, match[0].length),
  7306. _getOriginalIndex2 = _slicedToArray(_getOriginalIndex, 2),
  7307. matchPos = _getOriginalIndex2[0],
  7308. matchLen = _getOriginalIndex2[1];
  7309. if (matchLen) {
  7310. matches.push(matchPos);
  7311. matchesLength.push(matchLen);
  7312. }
  7313. }
  7314. this._pageMatches[pageIndex] = matches;
  7315. this._pageMatchesLength[pageIndex] = matchesLength;
  7316. }
  7317. function _convertToRegExpString2(query, hasDiacritics) {
  7318. var matchDiacritics = this._state.matchDiacritics;
  7319. var isUnicode = false;
  7320. query = query.replace(SPECIAL_CHARS_REG_EXP, function (match, p1, p2, p3, p4, p5) {
  7321. if (p1) {
  7322. return "[ ]*\\".concat(p1, "[ ]*");
  7323. }
  7324. if (p2) {
  7325. return "[ ]*".concat(p2, "[ ]*");
  7326. }
  7327. if (p3) {
  7328. return "[ ]+";
  7329. }
  7330. if (matchDiacritics) {
  7331. return p4 || p5;
  7332. }
  7333. if (p4) {
  7334. return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : "";
  7335. }
  7336. if (hasDiacritics) {
  7337. isUnicode = true;
  7338. return "".concat(p5, "\\p{M}*");
  7339. }
  7340. return p5;
  7341. });
  7342. var trailingSpaces = "[ ]*";
  7343. if (query.endsWith(trailingSpaces)) {
  7344. query = query.slice(0, query.length - trailingSpaces.length);
  7345. }
  7346. if (matchDiacritics) {
  7347. if (hasDiacritics) {
  7348. isUnicode = true;
  7349. query = "".concat(query, "(?=[").concat(DIACRITICS_EXCEPTION_STR, "]|[^\\p{M}]|$)");
  7350. }
  7351. }
  7352. return [isUnicode, query];
  7353. }
  7354. function _calculateMatch2(pageIndex) {
  7355. var _this2 = this;
  7356. var query = _classPrivateFieldGet(this, _query);
  7357. if (query.length === 0) {
  7358. return;
  7359. }
  7360. var _this$_state = this._state,
  7361. caseSensitive = _this$_state.caseSensitive,
  7362. entireWord = _this$_state.entireWord,
  7363. phraseSearch = _this$_state.phraseSearch;
  7364. var pageContent = this._pageContents[pageIndex];
  7365. var hasDiacritics = this._hasDiacritics[pageIndex];
  7366. var isUnicode = false;
  7367. if (phraseSearch) {
  7368. var _classPrivateMethodGe = _classPrivateMethodGet(this, _convertToRegExpString, _convertToRegExpString2).call(this, query, hasDiacritics);
  7369. var _classPrivateMethodGe2 = _slicedToArray(_classPrivateMethodGe, 2);
  7370. isUnicode = _classPrivateMethodGe2[0];
  7371. query = _classPrivateMethodGe2[1];
  7372. } else {
  7373. var match = query.match(/\S+/g);
  7374. if (match) {
  7375. query = match.sort().reverse().map(function (q) {
  7376. var _classPrivateMethodGe3 = _classPrivateMethodGet(_this2, _convertToRegExpString, _convertToRegExpString2).call(_this2, q, hasDiacritics),
  7377. _classPrivateMethodGe4 = _slicedToArray(_classPrivateMethodGe3, 2),
  7378. isUnicodePart = _classPrivateMethodGe4[0],
  7379. queryPart = _classPrivateMethodGe4[1];
  7380. isUnicode || (isUnicode = isUnicodePart);
  7381. return "(".concat(queryPart, ")");
  7382. }).join("|");
  7383. }
  7384. }
  7385. var flags = "g".concat(isUnicode ? "u" : "").concat(caseSensitive ? "" : "i");
  7386. query = new RegExp(query, flags);
  7387. _classPrivateMethodGet(this, _calculateRegExpMatch, _calculateRegExpMatch2).call(this, query, entireWord, pageIndex, pageContent);
  7388. if (this._state.highlightAll) {
  7389. _classPrivateMethodGet(this, _updatePage, _updatePage2).call(this, pageIndex);
  7390. }
  7391. if (this._resumePageIdx === pageIndex) {
  7392. this._resumePageIdx = null;
  7393. _classPrivateMethodGet(this, _nextPageMatch, _nextPageMatch2).call(this);
  7394. }
  7395. var pageMatchesCount = this._pageMatches[pageIndex].length;
  7396. if (pageMatchesCount > 0) {
  7397. this._matchesCountTotal += pageMatchesCount;
  7398. _classPrivateMethodGet(this, _updateUIResultsCount, _updateUIResultsCount2).call(this);
  7399. }
  7400. }
  7401. function _extractText2() {
  7402. var _this3 = this;
  7403. if (this._extractTextPromises.length > 0) {
  7404. return;
  7405. }
  7406. var promise = Promise.resolve();
  7407. var _loop = function _loop(i, ii) {
  7408. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  7409. _this3._extractTextPromises[i] = extractTextCapability.promise;
  7410. promise = promise.then(function () {
  7411. return _this3._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  7412. return pdfPage.getTextContent();
  7413. }).then(function (textContent) {
  7414. var strBuf = [];
  7415. var _iterator = _createForOfIteratorHelper(textContent.items),
  7416. _step;
  7417. try {
  7418. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7419. var textItem = _step.value;
  7420. strBuf.push(textItem.str);
  7421. if (textItem.hasEOL) {
  7422. strBuf.push("\n");
  7423. }
  7424. }
  7425. } catch (err) {
  7426. _iterator.e(err);
  7427. } finally {
  7428. _iterator.f();
  7429. }
  7430. var _normalize3 = normalize(strBuf.join(""));
  7431. var _normalize4 = _slicedToArray(_normalize3, 3);
  7432. _this3._pageContents[i] = _normalize4[0];
  7433. _this3._pageDiffs[i] = _normalize4[1];
  7434. _this3._hasDiacritics[i] = _normalize4[2];
  7435. extractTextCapability.resolve();
  7436. }, function (reason) {
  7437. console.error("Unable to get text content for page ".concat(i + 1), reason);
  7438. _this3._pageContents[i] = "";
  7439. _this3._pageDiffs[i] = null;
  7440. _this3._hasDiacritics[i] = false;
  7441. extractTextCapability.resolve();
  7442. });
  7443. });
  7444. };
  7445. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  7446. _loop(i, ii);
  7447. }
  7448. }
  7449. function _updatePage2(index) {
  7450. if (this._scrollMatches && this._selected.pageIdx === index) {
  7451. this._linkService.page = index + 1;
  7452. }
  7453. this._eventBus.dispatch("updatetextlayermatches", {
  7454. source: this,
  7455. pageIndex: index
  7456. });
  7457. }
  7458. function _updateAllPages2() {
  7459. this._eventBus.dispatch("updatetextlayermatches", {
  7460. source: this,
  7461. pageIndex: -1
  7462. });
  7463. }
  7464. function _nextMatch2() {
  7465. var _this4 = this;
  7466. var previous = this._state.findPrevious;
  7467. var currentPageIndex = this._linkService.page - 1;
  7468. var numPages = this._linkService.pagesCount;
  7469. this._highlightMatches = true;
  7470. if (this._dirtyMatch) {
  7471. this._dirtyMatch = false;
  7472. this._selected.pageIdx = this._selected.matchIdx = -1;
  7473. this._offset.pageIdx = currentPageIndex;
  7474. this._offset.matchIdx = null;
  7475. this._offset.wrapped = false;
  7476. this._resumePageIdx = null;
  7477. this._pageMatches.length = 0;
  7478. this._pageMatchesLength.length = 0;
  7479. this._matchesCountTotal = 0;
  7480. _classPrivateMethodGet(this, _updateAllPages, _updateAllPages2).call(this);
  7481. var _loop2 = function _loop2(i) {
  7482. if (_this4._pendingFindMatches.has(i)) {
  7483. return "continue";
  7484. }
  7485. _this4._pendingFindMatches.add(i);
  7486. _this4._extractTextPromises[i].then(function () {
  7487. _this4._pendingFindMatches["delete"](i);
  7488. _classPrivateMethodGet(_this4, _calculateMatch, _calculateMatch2).call(_this4, i);
  7489. });
  7490. };
  7491. for (var i = 0; i < numPages; i++) {
  7492. var _ret = _loop2(i);
  7493. if (_ret === "continue") continue;
  7494. }
  7495. }
  7496. if (_classPrivateFieldGet(this, _query) === "") {
  7497. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, FindState.FOUND);
  7498. return;
  7499. }
  7500. if (this._resumePageIdx) {
  7501. return;
  7502. }
  7503. var offset = this._offset;
  7504. this._pagesToSearch = numPages;
  7505. if (offset.matchIdx !== null) {
  7506. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  7507. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  7508. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  7509. _classPrivateMethodGet(this, _updateMatch, _updateMatch2).call(this, true);
  7510. return;
  7511. }
  7512. _classPrivateMethodGet(this, _advanceOffsetPage, _advanceOffsetPage2).call(this, previous);
  7513. }
  7514. _classPrivateMethodGet(this, _nextPageMatch, _nextPageMatch2).call(this);
  7515. }
  7516. function _matchesReady2(matches) {
  7517. var offset = this._offset;
  7518. var numMatches = matches.length;
  7519. var previous = this._state.findPrevious;
  7520. if (numMatches) {
  7521. offset.matchIdx = previous ? numMatches - 1 : 0;
  7522. _classPrivateMethodGet(this, _updateMatch, _updateMatch2).call(this, true);
  7523. return true;
  7524. }
  7525. _classPrivateMethodGet(this, _advanceOffsetPage, _advanceOffsetPage2).call(this, previous);
  7526. if (offset.wrapped) {
  7527. offset.matchIdx = null;
  7528. if (this._pagesToSearch < 0) {
  7529. _classPrivateMethodGet(this, _updateMatch, _updateMatch2).call(this, false);
  7530. return true;
  7531. }
  7532. }
  7533. return false;
  7534. }
  7535. function _nextPageMatch2() {
  7536. if (this._resumePageIdx !== null) {
  7537. console.error("There can only be one pending page.");
  7538. }
  7539. var matches = null;
  7540. do {
  7541. var pageIdx = this._offset.pageIdx;
  7542. matches = this._pageMatches[pageIdx];
  7543. if (!matches) {
  7544. this._resumePageIdx = pageIdx;
  7545. break;
  7546. }
  7547. } while (!_classPrivateMethodGet(this, _matchesReady, _matchesReady2).call(this, matches));
  7548. }
  7549. function _advanceOffsetPage2(previous) {
  7550. var offset = this._offset;
  7551. var numPages = this._linkService.pagesCount;
  7552. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  7553. offset.matchIdx = null;
  7554. this._pagesToSearch--;
  7555. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  7556. offset.pageIdx = previous ? numPages - 1 : 0;
  7557. offset.wrapped = true;
  7558. }
  7559. }
  7560. function _updateMatch2() {
  7561. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7562. var state = FindState.NOT_FOUND;
  7563. var wrapped = this._offset.wrapped;
  7564. this._offset.wrapped = false;
  7565. if (found) {
  7566. var previousPage = this._selected.pageIdx;
  7567. this._selected.pageIdx = this._offset.pageIdx;
  7568. this._selected.matchIdx = this._offset.matchIdx;
  7569. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  7570. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  7571. _classPrivateMethodGet(this, _updatePage, _updatePage2).call(this, previousPage);
  7572. }
  7573. }
  7574. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, state, this._state.findPrevious);
  7575. if (this._selected.pageIdx !== -1) {
  7576. this._scrollMatches = true;
  7577. _classPrivateMethodGet(this, _updatePage, _updatePage2).call(this, this._selected.pageIdx);
  7578. }
  7579. }
  7580. function _onFindBarClose2(evt) {
  7581. var _this5 = this;
  7582. var pdfDocument = this._pdfDocument;
  7583. this._firstPageCapability.promise.then(function () {
  7584. if (!_this5._pdfDocument || pdfDocument && _this5._pdfDocument !== pdfDocument) {
  7585. return;
  7586. }
  7587. if (_this5._findTimeout) {
  7588. clearTimeout(_this5._findTimeout);
  7589. _this5._findTimeout = null;
  7590. }
  7591. if (_this5._resumePageIdx) {
  7592. _this5._resumePageIdx = null;
  7593. _this5._dirtyMatch = true;
  7594. }
  7595. _classPrivateMethodGet(_this5, _updateUIState, _updateUIState2).call(_this5, FindState.FOUND);
  7596. _this5._highlightMatches = false;
  7597. _classPrivateMethodGet(_this5, _updateAllPages, _updateAllPages2).call(_this5);
  7598. });
  7599. }
  7600. function _requestMatchesCount2() {
  7601. var _this$_selected = this._selected,
  7602. pageIdx = _this$_selected.pageIdx,
  7603. matchIdx = _this$_selected.matchIdx;
  7604. var current = 0,
  7605. total = this._matchesCountTotal;
  7606. if (matchIdx !== -1) {
  7607. for (var i = 0; i < pageIdx; i++) {
  7608. var _this$_pageMatches$i;
  7609. current += ((_this$_pageMatches$i = this._pageMatches[i]) === null || _this$_pageMatches$i === void 0 ? void 0 : _this$_pageMatches$i.length) || 0;
  7610. }
  7611. current += matchIdx + 1;
  7612. }
  7613. if (current < 1 || current > total) {
  7614. current = total = 0;
  7615. }
  7616. return {
  7617. current: current,
  7618. total: total
  7619. };
  7620. }
  7621. function _updateUIResultsCount2() {
  7622. this._eventBus.dispatch("updatefindmatchescount", {
  7623. source: this,
  7624. matchesCount: _classPrivateMethodGet(this, _requestMatchesCount, _requestMatchesCount2).call(this)
  7625. });
  7626. }
  7627. function _updateUIState2(state) {
  7628. var _this$_state$query, _this$_state2;
  7629. var previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7630. this._eventBus.dispatch("updatefindcontrolstate", {
  7631. source: this,
  7632. state: state,
  7633. previous: previous,
  7634. matchesCount: _classPrivateMethodGet(this, _requestMatchesCount, _requestMatchesCount2).call(this),
  7635. 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
  7636. });
  7637. }
  7638. /***/ }),
  7639. /* 19 */
  7640. /***/ ((__unused_webpack_module, exports) => {
  7641. Object.defineProperty(exports, "__esModule", ({
  7642. value: true
  7643. }));
  7644. exports.CharacterType = void 0;
  7645. exports.getCharacterType = getCharacterType;
  7646. var CharacterType = {
  7647. SPACE: 0,
  7648. ALPHA_LETTER: 1,
  7649. PUNCT: 2,
  7650. HAN_LETTER: 3,
  7651. KATAKANA_LETTER: 4,
  7652. HIRAGANA_LETTER: 5,
  7653. HALFWIDTH_KATAKANA_LETTER: 6,
  7654. THAI_LETTER: 7
  7655. };
  7656. exports.CharacterType = CharacterType;
  7657. function isAlphabeticalScript(charCode) {
  7658. return charCode < 0x2e80;
  7659. }
  7660. function isAscii(charCode) {
  7661. return (charCode & 0xff80) === 0;
  7662. }
  7663. function isAsciiAlpha(charCode) {
  7664. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  7665. }
  7666. function isAsciiDigit(charCode) {
  7667. return charCode >= 0x30 && charCode <= 0x39;
  7668. }
  7669. function isAsciiSpace(charCode) {
  7670. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  7671. }
  7672. function isHan(charCode) {
  7673. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  7674. }
  7675. function isKatakana(charCode) {
  7676. return charCode >= 0x30a0 && charCode <= 0x30ff;
  7677. }
  7678. function isHiragana(charCode) {
  7679. return charCode >= 0x3040 && charCode <= 0x309f;
  7680. }
  7681. function isHalfwidthKatakana(charCode) {
  7682. return charCode >= 0xff60 && charCode <= 0xff9f;
  7683. }
  7684. function isThai(charCode) {
  7685. return (charCode & 0xff80) === 0x0e00;
  7686. }
  7687. function getCharacterType(charCode) {
  7688. if (isAlphabeticalScript(charCode)) {
  7689. if (isAscii(charCode)) {
  7690. if (isAsciiSpace(charCode)) {
  7691. return CharacterType.SPACE;
  7692. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  7693. return CharacterType.ALPHA_LETTER;
  7694. }
  7695. return CharacterType.PUNCT;
  7696. } else if (isThai(charCode)) {
  7697. return CharacterType.THAI_LETTER;
  7698. } else if (charCode === 0xa0) {
  7699. return CharacterType.SPACE;
  7700. }
  7701. return CharacterType.ALPHA_LETTER;
  7702. }
  7703. if (isHan(charCode)) {
  7704. return CharacterType.HAN_LETTER;
  7705. } else if (isKatakana(charCode)) {
  7706. return CharacterType.KATAKANA_LETTER;
  7707. } else if (isHiragana(charCode)) {
  7708. return CharacterType.HIRAGANA_LETTER;
  7709. } else if (isHalfwidthKatakana(charCode)) {
  7710. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  7711. }
  7712. return CharacterType.ALPHA_LETTER;
  7713. }
  7714. /***/ }),
  7715. /* 20 */
  7716. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7717. Object.defineProperty(exports, "__esModule", ({
  7718. value: true
  7719. }));
  7720. exports.PDFHistory = void 0;
  7721. exports.isDestArraysEqual = isDestArraysEqual;
  7722. exports.isDestHashesEqual = isDestHashesEqual;
  7723. var _ui_utils = __webpack_require__(5);
  7724. var _event_utils = __webpack_require__(6);
  7725. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  7726. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  7727. 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."); }
  7728. 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); }
  7729. 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; }
  7730. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
  7731. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  7732. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7733. 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); } }
  7734. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  7735. var HASH_CHANGE_TIMEOUT = 1000;
  7736. var POSITION_UPDATED_THRESHOLD = 50;
  7737. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  7738. function getCurrentHash() {
  7739. return document.location.hash;
  7740. }
  7741. var PDFHistory = /*#__PURE__*/function () {
  7742. function PDFHistory(_ref) {
  7743. var _this = this;
  7744. var linkService = _ref.linkService,
  7745. eventBus = _ref.eventBus;
  7746. _classCallCheck(this, PDFHistory);
  7747. this.linkService = linkService;
  7748. this.eventBus = eventBus;
  7749. this._initialized = false;
  7750. this._fingerprint = "";
  7751. this.reset();
  7752. this._boundEvents = null;
  7753. this.eventBus._on("pagesinit", function () {
  7754. _this._isPagesLoaded = false;
  7755. _this.eventBus._on("pagesloaded", function (evt) {
  7756. _this._isPagesLoaded = !!evt.pagesCount;
  7757. }, {
  7758. once: true
  7759. });
  7760. });
  7761. }
  7762. _createClass(PDFHistory, [{
  7763. key: "initialize",
  7764. value: function initialize(_ref2) {
  7765. var fingerprint = _ref2.fingerprint,
  7766. _ref2$resetHistory = _ref2.resetHistory,
  7767. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  7768. _ref2$updateUrl = _ref2.updateUrl,
  7769. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  7770. if (!fingerprint || typeof fingerprint !== "string") {
  7771. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  7772. return;
  7773. }
  7774. if (this._initialized) {
  7775. this.reset();
  7776. }
  7777. var reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  7778. this._fingerprint = fingerprint;
  7779. this._updateUrl = updateUrl === true;
  7780. this._initialized = true;
  7781. this._bindEvents();
  7782. var state = window.history.state;
  7783. this._popStateInProgress = false;
  7784. this._blockHashChange = 0;
  7785. this._currentHash = getCurrentHash();
  7786. this._numPositionUpdates = 0;
  7787. this._uid = this._maxUid = 0;
  7788. this._destination = null;
  7789. this._position = null;
  7790. if (!this._isValidState(state, true) || resetHistory) {
  7791. var _this$_parseCurrentHa = this._parseCurrentHash(true),
  7792. hash = _this$_parseCurrentHa.hash,
  7793. page = _this$_parseCurrentHa.page,
  7794. rotation = _this$_parseCurrentHa.rotation;
  7795. if (!hash || reInitialized || resetHistory) {
  7796. this._pushOrReplaceState(null, true);
  7797. return;
  7798. }
  7799. this._pushOrReplaceState({
  7800. hash: hash,
  7801. page: page,
  7802. rotation: rotation
  7803. }, true);
  7804. return;
  7805. }
  7806. var destination = state.destination;
  7807. this._updateInternalState(destination, state.uid, true);
  7808. if (destination.rotation !== undefined) {
  7809. this._initialRotation = destination.rotation;
  7810. }
  7811. if (destination.dest) {
  7812. this._initialBookmark = JSON.stringify(destination.dest);
  7813. this._destination.page = null;
  7814. } else if (destination.hash) {
  7815. this._initialBookmark = destination.hash;
  7816. } else if (destination.page) {
  7817. this._initialBookmark = "page=".concat(destination.page);
  7818. }
  7819. }
  7820. }, {
  7821. key: "reset",
  7822. value: function reset() {
  7823. if (this._initialized) {
  7824. this._pageHide();
  7825. this._initialized = false;
  7826. this._unbindEvents();
  7827. }
  7828. if (this._updateViewareaTimeout) {
  7829. clearTimeout(this._updateViewareaTimeout);
  7830. this._updateViewareaTimeout = null;
  7831. }
  7832. this._initialBookmark = null;
  7833. this._initialRotation = null;
  7834. }
  7835. }, {
  7836. key: "push",
  7837. value: function push(_ref3) {
  7838. var _this2 = this;
  7839. var _ref3$namedDest = _ref3.namedDest,
  7840. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  7841. explicitDest = _ref3.explicitDest,
  7842. pageNumber = _ref3.pageNumber;
  7843. if (!this._initialized) {
  7844. return;
  7845. }
  7846. if (namedDest && typeof namedDest !== "string") {
  7847. console.error("PDFHistory.push: " + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  7848. return;
  7849. } else if (!Array.isArray(explicitDest)) {
  7850. console.error("PDFHistory.push: " + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  7851. return;
  7852. } else if (!this._isValidPage(pageNumber)) {
  7853. if (pageNumber !== null || this._destination) {
  7854. console.error("PDFHistory.push: " + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  7855. return;
  7856. }
  7857. }
  7858. var hash = namedDest || JSON.stringify(explicitDest);
  7859. if (!hash) {
  7860. return;
  7861. }
  7862. var forceReplace = false;
  7863. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  7864. if (this._destination.page) {
  7865. return;
  7866. }
  7867. forceReplace = true;
  7868. }
  7869. if (this._popStateInProgress && !forceReplace) {
  7870. return;
  7871. }
  7872. this._pushOrReplaceState({
  7873. dest: explicitDest,
  7874. hash: hash,
  7875. page: pageNumber,
  7876. rotation: this.linkService.rotation
  7877. }, forceReplace);
  7878. if (!this._popStateInProgress) {
  7879. this._popStateInProgress = true;
  7880. Promise.resolve().then(function () {
  7881. _this2._popStateInProgress = false;
  7882. });
  7883. }
  7884. }
  7885. }, {
  7886. key: "pushPage",
  7887. value: function pushPage(pageNumber) {
  7888. var _this$_destination,
  7889. _this3 = this;
  7890. if (!this._initialized) {
  7891. return;
  7892. }
  7893. if (!this._isValidPage(pageNumber)) {
  7894. console.error("PDFHistory.pushPage: \"".concat(pageNumber, "\" is not a valid page number."));
  7895. return;
  7896. }
  7897. if (((_this$_destination = this._destination) === null || _this$_destination === void 0 ? void 0 : _this$_destination.page) === pageNumber) {
  7898. return;
  7899. }
  7900. if (this._popStateInProgress) {
  7901. return;
  7902. }
  7903. this._pushOrReplaceState({
  7904. dest: null,
  7905. hash: "page=".concat(pageNumber),
  7906. page: pageNumber,
  7907. rotation: this.linkService.rotation
  7908. });
  7909. if (!this._popStateInProgress) {
  7910. this._popStateInProgress = true;
  7911. Promise.resolve().then(function () {
  7912. _this3._popStateInProgress = false;
  7913. });
  7914. }
  7915. }
  7916. }, {
  7917. key: "pushCurrentPosition",
  7918. value: function pushCurrentPosition() {
  7919. if (!this._initialized || this._popStateInProgress) {
  7920. return;
  7921. }
  7922. this._tryPushCurrentPosition();
  7923. }
  7924. }, {
  7925. key: "back",
  7926. value: function back() {
  7927. if (!this._initialized || this._popStateInProgress) {
  7928. return;
  7929. }
  7930. var state = window.history.state;
  7931. if (this._isValidState(state) && state.uid > 0) {
  7932. window.history.back();
  7933. }
  7934. }
  7935. }, {
  7936. key: "forward",
  7937. value: function forward() {
  7938. if (!this._initialized || this._popStateInProgress) {
  7939. return;
  7940. }
  7941. var state = window.history.state;
  7942. if (this._isValidState(state) && state.uid < this._maxUid) {
  7943. window.history.forward();
  7944. }
  7945. }
  7946. }, {
  7947. key: "popStateInProgress",
  7948. get: function get() {
  7949. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  7950. }
  7951. }, {
  7952. key: "initialBookmark",
  7953. get: function get() {
  7954. return this._initialized ? this._initialBookmark : null;
  7955. }
  7956. }, {
  7957. key: "initialRotation",
  7958. get: function get() {
  7959. return this._initialized ? this._initialRotation : null;
  7960. }
  7961. }, {
  7962. key: "_pushOrReplaceState",
  7963. value: function _pushOrReplaceState(destination) {
  7964. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7965. var shouldReplace = forceReplace || !this._destination;
  7966. var newState = {
  7967. fingerprint: this._fingerprint,
  7968. uid: shouldReplace ? this._uid : this._uid + 1,
  7969. destination: destination
  7970. };
  7971. this._updateInternalState(destination, newState.uid);
  7972. var newUrl;
  7973. if (this._updateUrl && destination !== null && destination !== void 0 && destination.hash) {
  7974. var baseUrl = document.location.href.split("#")[0];
  7975. if (!baseUrl.startsWith("file://")) {
  7976. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  7977. }
  7978. }
  7979. if (shouldReplace) {
  7980. window.history.replaceState(newState, "", newUrl);
  7981. } else {
  7982. window.history.pushState(newState, "", newUrl);
  7983. }
  7984. }
  7985. }, {
  7986. key: "_tryPushCurrentPosition",
  7987. value: function _tryPushCurrentPosition() {
  7988. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7989. if (!this._position) {
  7990. return;
  7991. }
  7992. var position = this._position;
  7993. if (temporary) {
  7994. position = Object.assign(Object.create(null), this._position);
  7995. position.temporary = true;
  7996. }
  7997. if (!this._destination) {
  7998. this._pushOrReplaceState(position);
  7999. return;
  8000. }
  8001. if (this._destination.temporary) {
  8002. this._pushOrReplaceState(position, true);
  8003. return;
  8004. }
  8005. if (this._destination.hash === position.hash) {
  8006. return;
  8007. }
  8008. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  8009. return;
  8010. }
  8011. var forceReplace = false;
  8012. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  8013. if (this._destination.dest !== undefined || !this._destination.first) {
  8014. return;
  8015. }
  8016. forceReplace = true;
  8017. }
  8018. this._pushOrReplaceState(position, forceReplace);
  8019. }
  8020. }, {
  8021. key: "_isValidPage",
  8022. value: function _isValidPage(val) {
  8023. return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount;
  8024. }
  8025. }, {
  8026. key: "_isValidState",
  8027. value: function _isValidState(state) {
  8028. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8029. if (!state) {
  8030. return false;
  8031. }
  8032. if (state.fingerprint !== this._fingerprint) {
  8033. if (checkReload) {
  8034. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  8035. return false;
  8036. }
  8037. var _performance$getEntri = performance.getEntriesByType("navigation"),
  8038. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  8039. perfEntry = _performance$getEntri2[0];
  8040. if ((perfEntry === null || perfEntry === void 0 ? void 0 : perfEntry.type) !== "reload") {
  8041. return false;
  8042. }
  8043. } else {
  8044. return false;
  8045. }
  8046. }
  8047. if (!Number.isInteger(state.uid) || state.uid < 0) {
  8048. return false;
  8049. }
  8050. if (state.destination === null || _typeof(state.destination) !== "object") {
  8051. return false;
  8052. }
  8053. return true;
  8054. }
  8055. }, {
  8056. key: "_updateInternalState",
  8057. value: function _updateInternalState(destination, uid) {
  8058. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8059. if (this._updateViewareaTimeout) {
  8060. clearTimeout(this._updateViewareaTimeout);
  8061. this._updateViewareaTimeout = null;
  8062. }
  8063. if (removeTemporary && destination !== null && destination !== void 0 && destination.temporary) {
  8064. delete destination.temporary;
  8065. }
  8066. this._destination = destination;
  8067. this._uid = uid;
  8068. this._maxUid = Math.max(this._maxUid, uid);
  8069. this._numPositionUpdates = 0;
  8070. }
  8071. }, {
  8072. key: "_parseCurrentHash",
  8073. value: function _parseCurrentHash() {
  8074. var checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8075. var hash = unescape(getCurrentHash()).substring(1);
  8076. var params = (0, _ui_utils.parseQueryString)(hash);
  8077. var nameddest = params.get("nameddest") || "";
  8078. var page = params.get("page") | 0;
  8079. if (!this._isValidPage(page) || checkNameddest && nameddest.length > 0) {
  8080. page = null;
  8081. }
  8082. return {
  8083. hash: hash,
  8084. page: page,
  8085. rotation: this.linkService.rotation
  8086. };
  8087. }
  8088. }, {
  8089. key: "_updateViewarea",
  8090. value: function _updateViewarea(_ref4) {
  8091. var _this4 = this;
  8092. var location = _ref4.location;
  8093. if (this._updateViewareaTimeout) {
  8094. clearTimeout(this._updateViewareaTimeout);
  8095. this._updateViewareaTimeout = null;
  8096. }
  8097. this._position = {
  8098. hash: location.pdfOpenParams.substring(1),
  8099. page: this.linkService.page,
  8100. first: location.pageNumber,
  8101. rotation: location.rotation
  8102. };
  8103. if (this._popStateInProgress) {
  8104. return;
  8105. }
  8106. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  8107. this._numPositionUpdates++;
  8108. }
  8109. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  8110. this._updateViewareaTimeout = setTimeout(function () {
  8111. if (!_this4._popStateInProgress) {
  8112. _this4._tryPushCurrentPosition(true);
  8113. }
  8114. _this4._updateViewareaTimeout = null;
  8115. }, UPDATE_VIEWAREA_TIMEOUT);
  8116. }
  8117. }
  8118. }, {
  8119. key: "_popState",
  8120. value: function _popState(_ref5) {
  8121. var _this5 = this;
  8122. var state = _ref5.state;
  8123. var newHash = getCurrentHash(),
  8124. hashChanged = this._currentHash !== newHash;
  8125. this._currentHash = newHash;
  8126. if (!state) {
  8127. this._uid++;
  8128. var _this$_parseCurrentHa2 = this._parseCurrentHash(),
  8129. hash = _this$_parseCurrentHa2.hash,
  8130. page = _this$_parseCurrentHa2.page,
  8131. rotation = _this$_parseCurrentHa2.rotation;
  8132. this._pushOrReplaceState({
  8133. hash: hash,
  8134. page: page,
  8135. rotation: rotation
  8136. }, true);
  8137. return;
  8138. }
  8139. if (!this._isValidState(state)) {
  8140. return;
  8141. }
  8142. this._popStateInProgress = true;
  8143. if (hashChanged) {
  8144. this._blockHashChange++;
  8145. (0, _event_utils.waitOnEventOrTimeout)({
  8146. target: window,
  8147. name: "hashchange",
  8148. delay: HASH_CHANGE_TIMEOUT
  8149. }).then(function () {
  8150. _this5._blockHashChange--;
  8151. });
  8152. }
  8153. var destination = state.destination;
  8154. this._updateInternalState(destination, state.uid, true);
  8155. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  8156. this.linkService.rotation = destination.rotation;
  8157. }
  8158. if (destination.dest) {
  8159. this.linkService.goToDestination(destination.dest);
  8160. } else if (destination.hash) {
  8161. this.linkService.setHash(destination.hash);
  8162. } else if (destination.page) {
  8163. this.linkService.page = destination.page;
  8164. }
  8165. Promise.resolve().then(function () {
  8166. _this5._popStateInProgress = false;
  8167. });
  8168. }
  8169. }, {
  8170. key: "_pageHide",
  8171. value: function _pageHide() {
  8172. if (!this._destination || this._destination.temporary) {
  8173. this._tryPushCurrentPosition();
  8174. }
  8175. }
  8176. }, {
  8177. key: "_bindEvents",
  8178. value: function _bindEvents() {
  8179. if (this._boundEvents) {
  8180. return;
  8181. }
  8182. this._boundEvents = {
  8183. updateViewarea: this._updateViewarea.bind(this),
  8184. popState: this._popState.bind(this),
  8185. pageHide: this._pageHide.bind(this)
  8186. };
  8187. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  8188. window.addEventListener("popstate", this._boundEvents.popState);
  8189. window.addEventListener("pagehide", this._boundEvents.pageHide);
  8190. }
  8191. }, {
  8192. key: "_unbindEvents",
  8193. value: function _unbindEvents() {
  8194. if (!this._boundEvents) {
  8195. return;
  8196. }
  8197. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  8198. window.removeEventListener("popstate", this._boundEvents.popState);
  8199. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  8200. this._boundEvents = null;
  8201. }
  8202. }]);
  8203. return PDFHistory;
  8204. }();
  8205. exports.PDFHistory = PDFHistory;
  8206. function isDestHashesEqual(destHash, pushHash) {
  8207. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  8208. return false;
  8209. }
  8210. if (destHash === pushHash) {
  8211. return true;
  8212. }
  8213. var nameddest = (0, _ui_utils.parseQueryString)(destHash).get("nameddest");
  8214. if (nameddest === pushHash) {
  8215. return true;
  8216. }
  8217. return false;
  8218. }
  8219. function isDestArraysEqual(firstDest, secondDest) {
  8220. function isEntryEqual(first, second) {
  8221. if (_typeof(first) !== _typeof(second)) {
  8222. return false;
  8223. }
  8224. if (Array.isArray(first) || Array.isArray(second)) {
  8225. return false;
  8226. }
  8227. if (first !== null && _typeof(first) === "object" && second !== null) {
  8228. if (Object.keys(first).length !== Object.keys(second).length) {
  8229. return false;
  8230. }
  8231. for (var key in first) {
  8232. if (!isEntryEqual(first[key], second[key])) {
  8233. return false;
  8234. }
  8235. }
  8236. return true;
  8237. }
  8238. return first === second || Number.isNaN(first) && Number.isNaN(second);
  8239. }
  8240. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  8241. return false;
  8242. }
  8243. if (firstDest.length !== secondDest.length) {
  8244. return false;
  8245. }
  8246. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  8247. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  8248. return false;
  8249. }
  8250. }
  8251. return true;
  8252. }
  8253. /***/ }),
  8254. /* 21 */
  8255. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8256. Object.defineProperty(exports, "__esModule", ({
  8257. value: true
  8258. }));
  8259. exports.PDFLayerViewer = void 0;
  8260. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  8261. var _base_tree_viewer = __webpack_require__(15);
  8262. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8263. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  8264. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
  8265. 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); }
  8266. 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; }
  8267. 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); } }
  8268. 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); }); }; }
  8269. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8270. 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); } }
  8271. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  8272. function _get() { 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(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
  8273. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  8274. 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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8275. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8276. 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); }; }
  8277. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  8278. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8279. 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; } }
  8280. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8281. var PDFLayerViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  8282. _inherits(PDFLayerViewer, _BaseTreeViewer);
  8283. var _super = _createSuper(PDFLayerViewer);
  8284. function PDFLayerViewer(options) {
  8285. var _this;
  8286. _classCallCheck(this, PDFLayerViewer);
  8287. _this = _super.call(this, options);
  8288. _this.l10n = options.l10n;
  8289. _this.eventBus._on("resetlayers", _this._resetLayers.bind(_assertThisInitialized(_this)));
  8290. _this.eventBus._on("togglelayerstree", _this._toggleAllTreeItems.bind(_assertThisInitialized(_this)));
  8291. return _this;
  8292. }
  8293. _createClass(PDFLayerViewer, [{
  8294. key: "reset",
  8295. value: function reset() {
  8296. _get(_getPrototypeOf(PDFLayerViewer.prototype), "reset", this).call(this);
  8297. this._optionalContentConfig = null;
  8298. }
  8299. }, {
  8300. key: "_dispatchEvent",
  8301. value: function _dispatchEvent(layersCount) {
  8302. this.eventBus.dispatch("layersloaded", {
  8303. source: this,
  8304. layersCount: layersCount
  8305. });
  8306. }
  8307. }, {
  8308. key: "_bindLink",
  8309. value: function _bindLink(element, _ref) {
  8310. var _this2 = this;
  8311. var groupId = _ref.groupId,
  8312. input = _ref.input;
  8313. var setVisibility = function setVisibility() {
  8314. _this2._optionalContentConfig.setVisibility(groupId, input.checked);
  8315. _this2.eventBus.dispatch("optionalcontentconfig", {
  8316. source: _this2,
  8317. promise: Promise.resolve(_this2._optionalContentConfig)
  8318. });
  8319. };
  8320. element.onclick = function (evt) {
  8321. if (evt.target === input) {
  8322. setVisibility();
  8323. return true;
  8324. } else if (evt.target !== element) {
  8325. return true;
  8326. }
  8327. input.checked = !input.checked;
  8328. setVisibility();
  8329. return false;
  8330. };
  8331. }
  8332. }, {
  8333. key: "_setNestedName",
  8334. value: function () {
  8335. var _setNestedName2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(element, _ref2) {
  8336. var _ref2$name, name;
  8337. return _regenerator["default"].wrap(function _callee$(_context) {
  8338. while (1) {
  8339. switch (_context.prev = _context.next) {
  8340. case 0:
  8341. _ref2$name = _ref2.name, name = _ref2$name === void 0 ? null : _ref2$name;
  8342. if (!(typeof name === "string")) {
  8343. _context.next = 4;
  8344. break;
  8345. }
  8346. element.textContent = this._normalizeTextContent(name);
  8347. return _context.abrupt("return");
  8348. case 4:
  8349. _context.next = 6;
  8350. return this.l10n.get("additional_layers");
  8351. case 6:
  8352. element.textContent = _context.sent;
  8353. element.style.fontStyle = "italic";
  8354. case 8:
  8355. case "end":
  8356. return _context.stop();
  8357. }
  8358. }
  8359. }, _callee, this);
  8360. }));
  8361. function _setNestedName(_x, _x2) {
  8362. return _setNestedName2.apply(this, arguments);
  8363. }
  8364. return _setNestedName;
  8365. }()
  8366. }, {
  8367. key: "_addToggleButton",
  8368. value: function _addToggleButton(div, _ref3) {
  8369. var _ref3$name = _ref3.name,
  8370. name = _ref3$name === void 0 ? null : _ref3$name;
  8371. _get(_getPrototypeOf(PDFLayerViewer.prototype), "_addToggleButton", this).call(this, div, name === null);
  8372. }
  8373. }, {
  8374. key: "_toggleAllTreeItems",
  8375. value: function _toggleAllTreeItems() {
  8376. if (!this._optionalContentConfig) {
  8377. return;
  8378. }
  8379. _get(_getPrototypeOf(PDFLayerViewer.prototype), "_toggleAllTreeItems", this).call(this);
  8380. }
  8381. }, {
  8382. key: "render",
  8383. value: function render(_ref4) {
  8384. var optionalContentConfig = _ref4.optionalContentConfig,
  8385. pdfDocument = _ref4.pdfDocument;
  8386. if (this._optionalContentConfig) {
  8387. this.reset();
  8388. }
  8389. this._optionalContentConfig = optionalContentConfig || null;
  8390. this._pdfDocument = pdfDocument || null;
  8391. var groups = optionalContentConfig === null || optionalContentConfig === void 0 ? void 0 : optionalContentConfig.getOrder();
  8392. if (!groups) {
  8393. this._dispatchEvent(0);
  8394. return;
  8395. }
  8396. var fragment = document.createDocumentFragment(),
  8397. queue = [{
  8398. parent: fragment,
  8399. groups: groups
  8400. }];
  8401. var layersCount = 0,
  8402. hasAnyNesting = false;
  8403. while (queue.length > 0) {
  8404. var levelData = queue.shift();
  8405. var _iterator = _createForOfIteratorHelper(levelData.groups),
  8406. _step;
  8407. try {
  8408. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8409. var groupId = _step.value;
  8410. var div = document.createElement("div");
  8411. div.className = "treeItem";
  8412. var element = document.createElement("a");
  8413. div.appendChild(element);
  8414. if (_typeof(groupId) === "object") {
  8415. hasAnyNesting = true;
  8416. this._addToggleButton(div, groupId);
  8417. this._setNestedName(element, groupId);
  8418. var itemsDiv = document.createElement("div");
  8419. itemsDiv.className = "treeItems";
  8420. div.appendChild(itemsDiv);
  8421. queue.push({
  8422. parent: itemsDiv,
  8423. groups: groupId.order
  8424. });
  8425. } else {
  8426. var group = optionalContentConfig.getGroup(groupId);
  8427. var input = document.createElement("input");
  8428. this._bindLink(element, {
  8429. groupId: groupId,
  8430. input: input
  8431. });
  8432. input.type = "checkbox";
  8433. input.id = groupId;
  8434. input.checked = group.visible;
  8435. var label = document.createElement("label");
  8436. label.setAttribute("for", groupId);
  8437. label.textContent = this._normalizeTextContent(group.name);
  8438. element.appendChild(input);
  8439. element.appendChild(label);
  8440. layersCount++;
  8441. }
  8442. levelData.parent.appendChild(div);
  8443. }
  8444. } catch (err) {
  8445. _iterator.e(err);
  8446. } finally {
  8447. _iterator.f();
  8448. }
  8449. }
  8450. this._finishRendering(fragment, layersCount, hasAnyNesting);
  8451. }
  8452. }, {
  8453. key: "_resetLayers",
  8454. value: function () {
  8455. var _resetLayers2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  8456. var optionalContentConfig;
  8457. return _regenerator["default"].wrap(function _callee2$(_context2) {
  8458. while (1) {
  8459. switch (_context2.prev = _context2.next) {
  8460. case 0:
  8461. if (this._optionalContentConfig) {
  8462. _context2.next = 2;
  8463. break;
  8464. }
  8465. return _context2.abrupt("return");
  8466. case 2:
  8467. _context2.next = 4;
  8468. return this._pdfDocument.getOptionalContentConfig();
  8469. case 4:
  8470. optionalContentConfig = _context2.sent;
  8471. this.eventBus.dispatch("optionalcontentconfig", {
  8472. source: this,
  8473. promise: Promise.resolve(optionalContentConfig)
  8474. });
  8475. this.render({
  8476. optionalContentConfig: optionalContentConfig,
  8477. pdfDocument: this._pdfDocument
  8478. });
  8479. case 7:
  8480. case "end":
  8481. return _context2.stop();
  8482. }
  8483. }
  8484. }, _callee2, this);
  8485. }));
  8486. function _resetLayers() {
  8487. return _resetLayers2.apply(this, arguments);
  8488. }
  8489. return _resetLayers;
  8490. }()
  8491. }]);
  8492. return PDFLayerViewer;
  8493. }(_base_tree_viewer.BaseTreeViewer);
  8494. exports.PDFLayerViewer = PDFLayerViewer;
  8495. /***/ }),
  8496. /* 22 */
  8497. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8498. Object.defineProperty(exports, "__esModule", ({
  8499. value: true
  8500. }));
  8501. exports.PDFOutlineViewer = void 0;
  8502. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  8503. var _base_tree_viewer = __webpack_require__(15);
  8504. var _pdfjsLib = __webpack_require__(7);
  8505. var _ui_utils = __webpack_require__(5);
  8506. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8507. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  8508. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  8509. 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."); }
  8510. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
  8511. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  8512. 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); } }
  8513. 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); }); }; }
  8514. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
  8515. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  8516. 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."); }
  8517. 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); }
  8518. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
  8519. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  8520. 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; }
  8521. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8522. 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); } }
  8523. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  8524. function _get() { 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(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
  8525. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  8526. 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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8527. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8528. 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); }; }
  8529. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  8530. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8531. 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; } }
  8532. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8533. var PDFOutlineViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  8534. _inherits(PDFOutlineViewer, _BaseTreeViewer);
  8535. var _super = _createSuper(PDFOutlineViewer);
  8536. function PDFOutlineViewer(options) {
  8537. var _this;
  8538. _classCallCheck(this, PDFOutlineViewer);
  8539. _this = _super.call(this, options);
  8540. _this.linkService = options.linkService;
  8541. _this.eventBus._on("toggleoutlinetree", _this._toggleAllTreeItems.bind(_assertThisInitialized(_this)));
  8542. _this.eventBus._on("currentoutlineitem", _this._currentOutlineItem.bind(_assertThisInitialized(_this)));
  8543. _this.eventBus._on("pagechanging", function (evt) {
  8544. _this._currentPageNumber = evt.pageNumber;
  8545. });
  8546. _this.eventBus._on("pagesloaded", function (evt) {
  8547. _this._isPagesLoaded = !!evt.pagesCount;
  8548. if (_this._currentOutlineItemCapability && !_this._currentOutlineItemCapability.settled) {
  8549. _this._currentOutlineItemCapability.resolve(_this._isPagesLoaded);
  8550. }
  8551. });
  8552. _this.eventBus._on("sidebarviewchanged", function (evt) {
  8553. _this._sidebarView = evt.view;
  8554. });
  8555. return _this;
  8556. }
  8557. _createClass(PDFOutlineViewer, [{
  8558. key: "reset",
  8559. value: function reset() {
  8560. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "reset", this).call(this);
  8561. this._outline = null;
  8562. this._pageNumberToDestHashCapability = null;
  8563. this._currentPageNumber = 1;
  8564. this._isPagesLoaded = null;
  8565. if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
  8566. this._currentOutlineItemCapability.resolve(false);
  8567. }
  8568. this._currentOutlineItemCapability = null;
  8569. }
  8570. }, {
  8571. key: "_dispatchEvent",
  8572. value: function _dispatchEvent(outlineCount) {
  8573. var _this$_pdfDocument;
  8574. this._currentOutlineItemCapability = (0, _pdfjsLib.createPromiseCapability)();
  8575. if (outlineCount === 0 || (_this$_pdfDocument = this._pdfDocument) !== null && _this$_pdfDocument !== void 0 && _this$_pdfDocument.loadingParams.disableAutoFetch) {
  8576. this._currentOutlineItemCapability.resolve(false);
  8577. } else if (this._isPagesLoaded !== null) {
  8578. this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
  8579. }
  8580. this.eventBus.dispatch("outlineloaded", {
  8581. source: this,
  8582. outlineCount: outlineCount,
  8583. currentOutlineItemPromise: this._currentOutlineItemCapability.promise
  8584. });
  8585. }
  8586. }, {
  8587. key: "_bindLink",
  8588. value: function _bindLink(element, _ref) {
  8589. var _this2 = this;
  8590. var url = _ref.url,
  8591. newWindow = _ref.newWindow,
  8592. dest = _ref.dest;
  8593. var linkService = this.linkService;
  8594. if (url) {
  8595. linkService.addLinkAttributes(element, url, newWindow);
  8596. return;
  8597. }
  8598. element.href = linkService.getDestinationHash(dest);
  8599. element.onclick = function (evt) {
  8600. _this2._updateCurrentTreeItem(evt.target.parentNode);
  8601. if (dest) {
  8602. linkService.goToDestination(dest);
  8603. }
  8604. return false;
  8605. };
  8606. }
  8607. }, {
  8608. key: "_setStyles",
  8609. value: function _setStyles(element, _ref2) {
  8610. var bold = _ref2.bold,
  8611. italic = _ref2.italic;
  8612. if (bold) {
  8613. element.style.fontWeight = "bold";
  8614. }
  8615. if (italic) {
  8616. element.style.fontStyle = "italic";
  8617. }
  8618. }
  8619. }, {
  8620. key: "_addToggleButton",
  8621. value: function _addToggleButton(div, _ref3) {
  8622. var count = _ref3.count,
  8623. items = _ref3.items;
  8624. var hidden = false;
  8625. if (count < 0) {
  8626. var totalCount = items.length;
  8627. if (totalCount > 0) {
  8628. var queue = _toConsumableArray(items);
  8629. while (queue.length > 0) {
  8630. var _queue$shift = queue.shift(),
  8631. nestedCount = _queue$shift.count,
  8632. nestedItems = _queue$shift.items;
  8633. if (nestedCount > 0 && nestedItems.length > 0) {
  8634. totalCount += nestedItems.length;
  8635. queue.push.apply(queue, _toConsumableArray(nestedItems));
  8636. }
  8637. }
  8638. }
  8639. if (Math.abs(count) === totalCount) {
  8640. hidden = true;
  8641. }
  8642. }
  8643. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "_addToggleButton", this).call(this, div, hidden);
  8644. }
  8645. }, {
  8646. key: "_toggleAllTreeItems",
  8647. value: function _toggleAllTreeItems() {
  8648. if (!this._outline) {
  8649. return;
  8650. }
  8651. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "_toggleAllTreeItems", this).call(this);
  8652. }
  8653. }, {
  8654. key: "render",
  8655. value: function render(_ref4) {
  8656. var outline = _ref4.outline,
  8657. pdfDocument = _ref4.pdfDocument;
  8658. if (this._outline) {
  8659. this.reset();
  8660. }
  8661. this._outline = outline || null;
  8662. this._pdfDocument = pdfDocument || null;
  8663. if (!outline) {
  8664. this._dispatchEvent(0);
  8665. return;
  8666. }
  8667. var fragment = document.createDocumentFragment();
  8668. var queue = [{
  8669. parent: fragment,
  8670. items: outline
  8671. }];
  8672. var outlineCount = 0,
  8673. hasAnyNesting = false;
  8674. while (queue.length > 0) {
  8675. var levelData = queue.shift();
  8676. var _iterator = _createForOfIteratorHelper(levelData.items),
  8677. _step;
  8678. try {
  8679. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8680. var item = _step.value;
  8681. var div = document.createElement("div");
  8682. div.className = "treeItem";
  8683. var element = document.createElement("a");
  8684. this._bindLink(element, item);
  8685. this._setStyles(element, item);
  8686. element.textContent = this._normalizeTextContent(item.title);
  8687. div.appendChild(element);
  8688. if (item.items.length > 0) {
  8689. hasAnyNesting = true;
  8690. this._addToggleButton(div, item);
  8691. var itemsDiv = document.createElement("div");
  8692. itemsDiv.className = "treeItems";
  8693. div.appendChild(itemsDiv);
  8694. queue.push({
  8695. parent: itemsDiv,
  8696. items: item.items
  8697. });
  8698. }
  8699. levelData.parent.appendChild(div);
  8700. outlineCount++;
  8701. }
  8702. } catch (err) {
  8703. _iterator.e(err);
  8704. } finally {
  8705. _iterator.f();
  8706. }
  8707. }
  8708. this._finishRendering(fragment, outlineCount, hasAnyNesting);
  8709. }
  8710. }, {
  8711. key: "_currentOutlineItem",
  8712. value: function () {
  8713. var _currentOutlineItem2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  8714. var pageNumberToDestHash, i, destHash, linkElement;
  8715. return _regenerator["default"].wrap(function _callee$(_context) {
  8716. while (1) {
  8717. switch (_context.prev = _context.next) {
  8718. case 0:
  8719. if (this._isPagesLoaded) {
  8720. _context.next = 2;
  8721. break;
  8722. }
  8723. throw new Error("_currentOutlineItem: All pages have not been loaded.");
  8724. case 2:
  8725. if (!(!this._outline || !this._pdfDocument)) {
  8726. _context.next = 4;
  8727. break;
  8728. }
  8729. return _context.abrupt("return");
  8730. case 4:
  8731. _context.next = 6;
  8732. return this._getPageNumberToDestHash(this._pdfDocument);
  8733. case 6:
  8734. pageNumberToDestHash = _context.sent;
  8735. if (pageNumberToDestHash) {
  8736. _context.next = 9;
  8737. break;
  8738. }
  8739. return _context.abrupt("return");
  8740. case 9:
  8741. this._updateCurrentTreeItem(null);
  8742. if (!(this._sidebarView !== _ui_utils.SidebarView.OUTLINE)) {
  8743. _context.next = 12;
  8744. break;
  8745. }
  8746. return _context.abrupt("return");
  8747. case 12:
  8748. i = this._currentPageNumber;
  8749. case 13:
  8750. if (!(i > 0)) {
  8751. _context.next = 25;
  8752. break;
  8753. }
  8754. destHash = pageNumberToDestHash.get(i);
  8755. if (destHash) {
  8756. _context.next = 17;
  8757. break;
  8758. }
  8759. return _context.abrupt("continue", 22);
  8760. case 17:
  8761. linkElement = this.container.querySelector("a[href=\"".concat(destHash, "\"]"));
  8762. if (linkElement) {
  8763. _context.next = 20;
  8764. break;
  8765. }
  8766. return _context.abrupt("continue", 22);
  8767. case 20:
  8768. this._scrollToCurrentTreeItem(linkElement.parentNode);
  8769. return _context.abrupt("break", 25);
  8770. case 22:
  8771. i--;
  8772. _context.next = 13;
  8773. break;
  8774. case 25:
  8775. case "end":
  8776. return _context.stop();
  8777. }
  8778. }
  8779. }, _callee, this);
  8780. }));
  8781. function _currentOutlineItem() {
  8782. return _currentOutlineItem2.apply(this, arguments);
  8783. }
  8784. return _currentOutlineItem;
  8785. }()
  8786. }, {
  8787. key: "_getPageNumberToDestHash",
  8788. value: function () {
  8789. var _getPageNumberToDestHash2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pdfDocument) {
  8790. var pageNumberToDestHash, pageNumberNesting, queue, levelData, currentNesting, _iterator2, _step2, _step2$value, dest, items, explicitDest, pageNumber, _explicitDest, _explicitDest2, destRef, destHash;
  8791. return _regenerator["default"].wrap(function _callee2$(_context2) {
  8792. while (1) {
  8793. switch (_context2.prev = _context2.next) {
  8794. case 0:
  8795. if (!this._pageNumberToDestHashCapability) {
  8796. _context2.next = 2;
  8797. break;
  8798. }
  8799. return _context2.abrupt("return", this._pageNumberToDestHashCapability.promise);
  8800. case 2:
  8801. this._pageNumberToDestHashCapability = (0, _pdfjsLib.createPromiseCapability)();
  8802. pageNumberToDestHash = new Map(), pageNumberNesting = new Map();
  8803. queue = [{
  8804. nesting: 0,
  8805. items: this._outline
  8806. }];
  8807. case 5:
  8808. if (!(queue.length > 0)) {
  8809. _context2.next = 56;
  8810. break;
  8811. }
  8812. levelData = queue.shift(), currentNesting = levelData.nesting;
  8813. _iterator2 = _createForOfIteratorHelper(levelData.items);
  8814. _context2.prev = 8;
  8815. _iterator2.s();
  8816. case 10:
  8817. if ((_step2 = _iterator2.n()).done) {
  8818. _context2.next = 46;
  8819. break;
  8820. }
  8821. _step2$value = _step2.value, dest = _step2$value.dest, items = _step2$value.items;
  8822. explicitDest = void 0, pageNumber = void 0;
  8823. if (!(typeof dest === "string")) {
  8824. _context2.next = 21;
  8825. break;
  8826. }
  8827. _context2.next = 16;
  8828. return pdfDocument.getDestination(dest);
  8829. case 16:
  8830. explicitDest = _context2.sent;
  8831. if (!(pdfDocument !== this._pdfDocument)) {
  8832. _context2.next = 19;
  8833. break;
  8834. }
  8835. return _context2.abrupt("return", null);
  8836. case 19:
  8837. _context2.next = 22;
  8838. break;
  8839. case 21:
  8840. explicitDest = dest;
  8841. case 22:
  8842. if (!Array.isArray(explicitDest)) {
  8843. _context2.next = 43;
  8844. break;
  8845. }
  8846. _explicitDest = explicitDest, _explicitDest2 = _slicedToArray(_explicitDest, 1), destRef = _explicitDest2[0];
  8847. if (!(_typeof(destRef) === "object" && destRef !== null)) {
  8848. _context2.next = 41;
  8849. break;
  8850. }
  8851. pageNumber = this.linkService._cachedPageNumber(destRef);
  8852. if (pageNumber) {
  8853. _context2.next = 39;
  8854. break;
  8855. }
  8856. _context2.prev = 27;
  8857. _context2.next = 30;
  8858. return pdfDocument.getPageIndex(destRef);
  8859. case 30:
  8860. _context2.t0 = _context2.sent;
  8861. pageNumber = _context2.t0 + 1;
  8862. if (!(pdfDocument !== this._pdfDocument)) {
  8863. _context2.next = 34;
  8864. break;
  8865. }
  8866. return _context2.abrupt("return", null);
  8867. case 34:
  8868. this.linkService.cachePageRef(pageNumber, destRef);
  8869. _context2.next = 39;
  8870. break;
  8871. case 37:
  8872. _context2.prev = 37;
  8873. _context2.t1 = _context2["catch"](27);
  8874. case 39:
  8875. _context2.next = 42;
  8876. break;
  8877. case 41:
  8878. if (Number.isInteger(destRef)) {
  8879. pageNumber = destRef + 1;
  8880. }
  8881. case 42:
  8882. if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) {
  8883. destHash = this.linkService.getDestinationHash(dest);
  8884. pageNumberToDestHash.set(pageNumber, destHash);
  8885. pageNumberNesting.set(pageNumber, currentNesting);
  8886. }
  8887. case 43:
  8888. if (items.length > 0) {
  8889. queue.push({
  8890. nesting: currentNesting + 1,
  8891. items: items
  8892. });
  8893. }
  8894. case 44:
  8895. _context2.next = 10;
  8896. break;
  8897. case 46:
  8898. _context2.next = 51;
  8899. break;
  8900. case 48:
  8901. _context2.prev = 48;
  8902. _context2.t2 = _context2["catch"](8);
  8903. _iterator2.e(_context2.t2);
  8904. case 51:
  8905. _context2.prev = 51;
  8906. _iterator2.f();
  8907. return _context2.finish(51);
  8908. case 54:
  8909. _context2.next = 5;
  8910. break;
  8911. case 56:
  8912. this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null);
  8913. return _context2.abrupt("return", this._pageNumberToDestHashCapability.promise);
  8914. case 58:
  8915. case "end":
  8916. return _context2.stop();
  8917. }
  8918. }
  8919. }, _callee2, this, [[8, 48, 51, 54], [27, 37]]);
  8920. }));
  8921. function _getPageNumberToDestHash(_x) {
  8922. return _getPageNumberToDestHash2.apply(this, arguments);
  8923. }
  8924. return _getPageNumberToDestHash;
  8925. }()
  8926. }]);
  8927. return PDFOutlineViewer;
  8928. }(_base_tree_viewer.BaseTreeViewer);
  8929. exports.PDFOutlineViewer = PDFOutlineViewer;
  8930. /***/ }),
  8931. /* 23 */
  8932. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8933. Object.defineProperty(exports, "__esModule", ({
  8934. value: true
  8935. }));
  8936. exports.PDFPresentationMode = void 0;
  8937. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  8938. var _ui_utils = __webpack_require__(5);
  8939. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8940. 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); } }
  8941. 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); }); }; }
  8942. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8943. 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); } }
  8944. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  8945. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  8946. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  8947. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  8948. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  8949. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  8950. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  8951. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  8952. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  8953. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  8954. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  8955. var ACTIVE_SELECTOR = "pdfPresentationMode";
  8956. var CONTROLS_SELECTOR = "pdfPresentationModeControls";
  8957. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  8958. var PAGE_SWITCH_THRESHOLD = 0.1;
  8959. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  8960. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  8961. var _state = /*#__PURE__*/new WeakMap();
  8962. var _args = /*#__PURE__*/new WeakMap();
  8963. var _mouseWheel = /*#__PURE__*/new WeakSet();
  8964. var _notifyStateChange = /*#__PURE__*/new WeakSet();
  8965. var _enter = /*#__PURE__*/new WeakSet();
  8966. var _exit = /*#__PURE__*/new WeakSet();
  8967. var _mouseDown = /*#__PURE__*/new WeakSet();
  8968. var _contextMenu = /*#__PURE__*/new WeakSet();
  8969. var _showControls = /*#__PURE__*/new WeakSet();
  8970. var _hideControls = /*#__PURE__*/new WeakSet();
  8971. var _resetMouseScrollState = /*#__PURE__*/new WeakSet();
  8972. var _touchSwipe = /*#__PURE__*/new WeakSet();
  8973. var _addWindowListeners = /*#__PURE__*/new WeakSet();
  8974. var _removeWindowListeners = /*#__PURE__*/new WeakSet();
  8975. var _fullscreenChange = /*#__PURE__*/new WeakSet();
  8976. var _addFullscreenChangeListeners = /*#__PURE__*/new WeakSet();
  8977. var _removeFullscreenChangeListeners = /*#__PURE__*/new WeakSet();
  8978. var PDFPresentationMode = /*#__PURE__*/function () {
  8979. function PDFPresentationMode(_ref) {
  8980. var container = _ref.container,
  8981. pdfViewer = _ref.pdfViewer,
  8982. eventBus = _ref.eventBus;
  8983. _classCallCheck(this, PDFPresentationMode);
  8984. _classPrivateMethodInitSpec(this, _removeFullscreenChangeListeners);
  8985. _classPrivateMethodInitSpec(this, _addFullscreenChangeListeners);
  8986. _classPrivateMethodInitSpec(this, _fullscreenChange);
  8987. _classPrivateMethodInitSpec(this, _removeWindowListeners);
  8988. _classPrivateMethodInitSpec(this, _addWindowListeners);
  8989. _classPrivateMethodInitSpec(this, _touchSwipe);
  8990. _classPrivateMethodInitSpec(this, _resetMouseScrollState);
  8991. _classPrivateMethodInitSpec(this, _hideControls);
  8992. _classPrivateMethodInitSpec(this, _showControls);
  8993. _classPrivateMethodInitSpec(this, _contextMenu);
  8994. _classPrivateMethodInitSpec(this, _mouseDown);
  8995. _classPrivateMethodInitSpec(this, _exit);
  8996. _classPrivateMethodInitSpec(this, _enter);
  8997. _classPrivateMethodInitSpec(this, _notifyStateChange);
  8998. _classPrivateMethodInitSpec(this, _mouseWheel);
  8999. _classPrivateFieldInitSpec(this, _state, {
  9000. writable: true,
  9001. value: _ui_utils.PresentationModeState.UNKNOWN
  9002. });
  9003. _classPrivateFieldInitSpec(this, _args, {
  9004. writable: true,
  9005. value: null
  9006. });
  9007. this.container = container;
  9008. this.pdfViewer = pdfViewer;
  9009. this.eventBus = eventBus;
  9010. this.contextMenuOpen = false;
  9011. this.mouseScrollTimeStamp = 0;
  9012. this.mouseScrollDelta = 0;
  9013. this.touchSwipeState = null;
  9014. }
  9015. _createClass(PDFPresentationMode, [{
  9016. key: "request",
  9017. value: function () {
  9018. var _request = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  9019. var container, pdfViewer, promise;
  9020. return _regenerator["default"].wrap(function _callee$(_context) {
  9021. while (1) {
  9022. switch (_context.prev = _context.next) {
  9023. case 0:
  9024. container = this.container, pdfViewer = this.pdfViewer;
  9025. if (!(this.active || !pdfViewer.pagesCount || !container.requestFullscreen)) {
  9026. _context.next = 3;
  9027. break;
  9028. }
  9029. return _context.abrupt("return", false);
  9030. case 3:
  9031. _classPrivateMethodGet(this, _addFullscreenChangeListeners, _addFullscreenChangeListeners2).call(this);
  9032. _classPrivateMethodGet(this, _notifyStateChange, _notifyStateChange2).call(this, _ui_utils.PresentationModeState.CHANGING);
  9033. promise = container.requestFullscreen();
  9034. _classPrivateFieldSet(this, _args, {
  9035. pageNumber: pdfViewer.currentPageNumber,
  9036. scaleValue: pdfViewer.currentScaleValue,
  9037. scrollMode: pdfViewer.scrollMode,
  9038. spreadMode: null
  9039. });
  9040. if (pdfViewer.spreadMode !== _ui_utils.SpreadMode.NONE && !(pdfViewer.pageViewsReady && pdfViewer.hasEqualPageSizes)) {
  9041. console.warn("Ignoring Spread modes when entering PresentationMode, " + "since the document may contain varying page sizes.");
  9042. _classPrivateFieldGet(this, _args).spreadMode = pdfViewer.spreadMode;
  9043. }
  9044. _context.prev = 8;
  9045. _context.next = 11;
  9046. return promise;
  9047. case 11:
  9048. return _context.abrupt("return", true);
  9049. case 14:
  9050. _context.prev = 14;
  9051. _context.t0 = _context["catch"](8);
  9052. _classPrivateMethodGet(this, _removeFullscreenChangeListeners, _removeFullscreenChangeListeners2).call(this);
  9053. _classPrivateMethodGet(this, _notifyStateChange, _notifyStateChange2).call(this, _ui_utils.PresentationModeState.NORMAL);
  9054. case 18:
  9055. return _context.abrupt("return", false);
  9056. case 19:
  9057. case "end":
  9058. return _context.stop();
  9059. }
  9060. }
  9061. }, _callee, this, [[8, 14]]);
  9062. }));
  9063. function request() {
  9064. return _request.apply(this, arguments);
  9065. }
  9066. return request;
  9067. }()
  9068. }, {
  9069. key: "active",
  9070. get: function get() {
  9071. return _classPrivateFieldGet(this, _state) === _ui_utils.PresentationModeState.CHANGING || _classPrivateFieldGet(this, _state) === _ui_utils.PresentationModeState.FULLSCREEN;
  9072. }
  9073. }]);
  9074. return PDFPresentationMode;
  9075. }();
  9076. exports.PDFPresentationMode = PDFPresentationMode;
  9077. function _mouseWheel2(evt) {
  9078. if (!this.active) {
  9079. return;
  9080. }
  9081. evt.preventDefault();
  9082. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  9083. var currentTime = Date.now();
  9084. var storedTime = this.mouseScrollTimeStamp;
  9085. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  9086. return;
  9087. }
  9088. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  9089. _classPrivateMethodGet(this, _resetMouseScrollState, _resetMouseScrollState2).call(this);
  9090. }
  9091. this.mouseScrollDelta += delta;
  9092. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  9093. var totalDelta = this.mouseScrollDelta;
  9094. _classPrivateMethodGet(this, _resetMouseScrollState, _resetMouseScrollState2).call(this);
  9095. var success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage();
  9096. if (success) {
  9097. this.mouseScrollTimeStamp = currentTime;
  9098. }
  9099. }
  9100. }
  9101. function _notifyStateChange2(state) {
  9102. _classPrivateFieldSet(this, _state, state);
  9103. this.eventBus.dispatch("presentationmodechanged", {
  9104. source: this,
  9105. state: state
  9106. });
  9107. }
  9108. function _enter2() {
  9109. var _this = this;
  9110. _classPrivateMethodGet(this, _notifyStateChange, _notifyStateChange2).call(this, _ui_utils.PresentationModeState.FULLSCREEN);
  9111. this.container.classList.add(ACTIVE_SELECTOR);
  9112. setTimeout(function () {
  9113. _this.pdfViewer.scrollMode = _ui_utils.ScrollMode.PAGE;
  9114. if (_classPrivateFieldGet(_this, _args).spreadMode !== null) {
  9115. _this.pdfViewer.spreadMode = _ui_utils.SpreadMode.NONE;
  9116. }
  9117. _this.pdfViewer.currentPageNumber = _classPrivateFieldGet(_this, _args).pageNumber;
  9118. _this.pdfViewer.currentScaleValue = "page-fit";
  9119. }, 0);
  9120. _classPrivateMethodGet(this, _addWindowListeners, _addWindowListeners2).call(this);
  9121. _classPrivateMethodGet(this, _showControls, _showControls2).call(this);
  9122. this.contextMenuOpen = false;
  9123. window.getSelection().removeAllRanges();
  9124. }
  9125. function _exit2() {
  9126. var _this2 = this;
  9127. var pageNumber = this.pdfViewer.currentPageNumber;
  9128. this.container.classList.remove(ACTIVE_SELECTOR);
  9129. setTimeout(function () {
  9130. _classPrivateMethodGet(_this2, _removeFullscreenChangeListeners, _removeFullscreenChangeListeners2).call(_this2);
  9131. _classPrivateMethodGet(_this2, _notifyStateChange, _notifyStateChange2).call(_this2, _ui_utils.PresentationModeState.NORMAL);
  9132. _this2.pdfViewer.scrollMode = _classPrivateFieldGet(_this2, _args).scrollMode;
  9133. if (_classPrivateFieldGet(_this2, _args).spreadMode !== null) {
  9134. _this2.pdfViewer.spreadMode = _classPrivateFieldGet(_this2, _args).spreadMode;
  9135. }
  9136. _this2.pdfViewer.currentScaleValue = _classPrivateFieldGet(_this2, _args).scaleValue;
  9137. _this2.pdfViewer.currentPageNumber = pageNumber;
  9138. _classPrivateFieldSet(_this2, _args, null);
  9139. }, 0);
  9140. _classPrivateMethodGet(this, _removeWindowListeners, _removeWindowListeners2).call(this);
  9141. _classPrivateMethodGet(this, _hideControls, _hideControls2).call(this);
  9142. _classPrivateMethodGet(this, _resetMouseScrollState, _resetMouseScrollState2).call(this);
  9143. this.contextMenuOpen = false;
  9144. }
  9145. function _mouseDown2(evt) {
  9146. if (this.contextMenuOpen) {
  9147. this.contextMenuOpen = false;
  9148. evt.preventDefault();
  9149. return;
  9150. }
  9151. if (evt.button === 0) {
  9152. var isInternalLink = evt.target.href && evt.target.classList.contains("internalLink");
  9153. if (!isInternalLink) {
  9154. evt.preventDefault();
  9155. if (evt.shiftKey) {
  9156. this.pdfViewer.previousPage();
  9157. } else {
  9158. this.pdfViewer.nextPage();
  9159. }
  9160. }
  9161. }
  9162. }
  9163. function _contextMenu2() {
  9164. this.contextMenuOpen = true;
  9165. }
  9166. function _showControls2() {
  9167. var _this3 = this;
  9168. if (this.controlsTimeout) {
  9169. clearTimeout(this.controlsTimeout);
  9170. } else {
  9171. this.container.classList.add(CONTROLS_SELECTOR);
  9172. }
  9173. this.controlsTimeout = setTimeout(function () {
  9174. _this3.container.classList.remove(CONTROLS_SELECTOR);
  9175. delete _this3.controlsTimeout;
  9176. }, DELAY_BEFORE_HIDING_CONTROLS);
  9177. }
  9178. function _hideControls2() {
  9179. if (!this.controlsTimeout) {
  9180. return;
  9181. }
  9182. clearTimeout(this.controlsTimeout);
  9183. this.container.classList.remove(CONTROLS_SELECTOR);
  9184. delete this.controlsTimeout;
  9185. }
  9186. function _resetMouseScrollState2() {
  9187. this.mouseScrollTimeStamp = 0;
  9188. this.mouseScrollDelta = 0;
  9189. }
  9190. function _touchSwipe2(evt) {
  9191. if (!this.active) {
  9192. return;
  9193. }
  9194. if (evt.touches.length > 1) {
  9195. this.touchSwipeState = null;
  9196. return;
  9197. }
  9198. switch (evt.type) {
  9199. case "touchstart":
  9200. this.touchSwipeState = {
  9201. startX: evt.touches[0].pageX,
  9202. startY: evt.touches[0].pageY,
  9203. endX: evt.touches[0].pageX,
  9204. endY: evt.touches[0].pageY
  9205. };
  9206. break;
  9207. case "touchmove":
  9208. if (this.touchSwipeState === null) {
  9209. return;
  9210. }
  9211. this.touchSwipeState.endX = evt.touches[0].pageX;
  9212. this.touchSwipeState.endY = evt.touches[0].pageY;
  9213. evt.preventDefault();
  9214. break;
  9215. case "touchend":
  9216. if (this.touchSwipeState === null) {
  9217. return;
  9218. }
  9219. var delta = 0;
  9220. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  9221. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  9222. var absAngle = Math.abs(Math.atan2(dy, dx));
  9223. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  9224. delta = dx;
  9225. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  9226. delta = dy;
  9227. }
  9228. if (delta > 0) {
  9229. this.pdfViewer.previousPage();
  9230. } else if (delta < 0) {
  9231. this.pdfViewer.nextPage();
  9232. }
  9233. break;
  9234. }
  9235. }
  9236. function _addWindowListeners2() {
  9237. this.showControlsBind = _classPrivateMethodGet(this, _showControls, _showControls2).bind(this);
  9238. this.mouseDownBind = _classPrivateMethodGet(this, _mouseDown, _mouseDown2).bind(this);
  9239. this.mouseWheelBind = _classPrivateMethodGet(this, _mouseWheel, _mouseWheel2).bind(this);
  9240. this.resetMouseScrollStateBind = _classPrivateMethodGet(this, _resetMouseScrollState, _resetMouseScrollState2).bind(this);
  9241. this.contextMenuBind = _classPrivateMethodGet(this, _contextMenu, _contextMenu2).bind(this);
  9242. this.touchSwipeBind = _classPrivateMethodGet(this, _touchSwipe, _touchSwipe2).bind(this);
  9243. window.addEventListener("mousemove", this.showControlsBind);
  9244. window.addEventListener("mousedown", this.mouseDownBind);
  9245. window.addEventListener("wheel", this.mouseWheelBind, {
  9246. passive: false
  9247. });
  9248. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  9249. window.addEventListener("contextmenu", this.contextMenuBind);
  9250. window.addEventListener("touchstart", this.touchSwipeBind);
  9251. window.addEventListener("touchmove", this.touchSwipeBind);
  9252. window.addEventListener("touchend", this.touchSwipeBind);
  9253. }
  9254. function _removeWindowListeners2() {
  9255. window.removeEventListener("mousemove", this.showControlsBind);
  9256. window.removeEventListener("mousedown", this.mouseDownBind);
  9257. window.removeEventListener("wheel", this.mouseWheelBind, {
  9258. passive: false
  9259. });
  9260. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  9261. window.removeEventListener("contextmenu", this.contextMenuBind);
  9262. window.removeEventListener("touchstart", this.touchSwipeBind);
  9263. window.removeEventListener("touchmove", this.touchSwipeBind);
  9264. window.removeEventListener("touchend", this.touchSwipeBind);
  9265. delete this.showControlsBind;
  9266. delete this.mouseDownBind;
  9267. delete this.mouseWheelBind;
  9268. delete this.resetMouseScrollStateBind;
  9269. delete this.contextMenuBind;
  9270. delete this.touchSwipeBind;
  9271. }
  9272. function _fullscreenChange2() {
  9273. if (document.fullscreenElement) {
  9274. _classPrivateMethodGet(this, _enter, _enter2).call(this);
  9275. } else {
  9276. _classPrivateMethodGet(this, _exit, _exit2).call(this);
  9277. }
  9278. }
  9279. function _addFullscreenChangeListeners2() {
  9280. this.fullscreenChangeBind = _classPrivateMethodGet(this, _fullscreenChange, _fullscreenChange2).bind(this);
  9281. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  9282. }
  9283. function _removeFullscreenChangeListeners2() {
  9284. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  9285. delete this.fullscreenChangeBind;
  9286. }
  9287. /***/ }),
  9288. /* 24 */
  9289. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9290. Object.defineProperty(exports, "__esModule", ({
  9291. value: true
  9292. }));
  9293. exports.PDFRenderingQueue = void 0;
  9294. var _pdfjsLib = __webpack_require__(7);
  9295. var _ui_utils = __webpack_require__(5);
  9296. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9297. 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); } }
  9298. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  9299. var CLEANUP_TIMEOUT = 30000;
  9300. var PDFRenderingQueue = /*#__PURE__*/function () {
  9301. function PDFRenderingQueue() {
  9302. _classCallCheck(this, PDFRenderingQueue);
  9303. this.pdfViewer = null;
  9304. this.pdfThumbnailViewer = null;
  9305. this.onIdle = null;
  9306. this.highestPriorityPage = null;
  9307. this.idleTimeout = null;
  9308. this.printing = false;
  9309. this.isThumbnailViewEnabled = false;
  9310. }
  9311. _createClass(PDFRenderingQueue, [{
  9312. key: "setViewer",
  9313. value: function setViewer(pdfViewer) {
  9314. this.pdfViewer = pdfViewer;
  9315. }
  9316. }, {
  9317. key: "setThumbnailViewer",
  9318. value: function setThumbnailViewer(pdfThumbnailViewer) {
  9319. this.pdfThumbnailViewer = pdfThumbnailViewer;
  9320. }
  9321. }, {
  9322. key: "isHighestPriority",
  9323. value: function isHighestPriority(view) {
  9324. return this.highestPriorityPage === view.renderingId;
  9325. }
  9326. }, {
  9327. key: "hasViewer",
  9328. value: function hasViewer() {
  9329. return !!this.pdfViewer;
  9330. }
  9331. }, {
  9332. key: "renderHighestPriority",
  9333. value: function renderHighestPriority(currentlyVisiblePages) {
  9334. var _this$pdfThumbnailVie;
  9335. if (this.idleTimeout) {
  9336. clearTimeout(this.idleTimeout);
  9337. this.idleTimeout = null;
  9338. }
  9339. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  9340. return;
  9341. }
  9342. if (this.isThumbnailViewEnabled && (_this$pdfThumbnailVie = this.pdfThumbnailViewer) !== null && _this$pdfThumbnailVie !== void 0 && _this$pdfThumbnailVie.forceRendering()) {
  9343. return;
  9344. }
  9345. if (this.printing) {
  9346. return;
  9347. }
  9348. if (this.onIdle) {
  9349. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  9350. }
  9351. }
  9352. }, {
  9353. key: "getHighestPriority",
  9354. value: function getHighestPriority(visible, views, scrolledDown) {
  9355. var preRenderExtra = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9356. var visibleViews = visible.views,
  9357. numVisible = visibleViews.length;
  9358. if (numVisible === 0) {
  9359. return null;
  9360. }
  9361. for (var i = 0; i < numVisible; i++) {
  9362. var view = visibleViews[i].view;
  9363. if (!this.isViewFinished(view)) {
  9364. return view;
  9365. }
  9366. }
  9367. var firstId = visible.first.id,
  9368. lastId = visible.last.id;
  9369. if (lastId - firstId + 1 > numVisible) {
  9370. var visibleIds = visible.ids;
  9371. for (var _i = 1, ii = lastId - firstId; _i < ii; _i++) {
  9372. var holeId = scrolledDown ? firstId + _i : lastId - _i;
  9373. if (visibleIds.has(holeId)) {
  9374. continue;
  9375. }
  9376. var holeView = views[holeId - 1];
  9377. if (!this.isViewFinished(holeView)) {
  9378. return holeView;
  9379. }
  9380. }
  9381. }
  9382. var preRenderIndex = scrolledDown ? lastId : firstId - 2;
  9383. var preRenderView = views[preRenderIndex];
  9384. if (preRenderView && !this.isViewFinished(preRenderView)) {
  9385. return preRenderView;
  9386. }
  9387. if (preRenderExtra) {
  9388. preRenderIndex += scrolledDown ? 1 : -1;
  9389. preRenderView = views[preRenderIndex];
  9390. if (preRenderView && !this.isViewFinished(preRenderView)) {
  9391. return preRenderView;
  9392. }
  9393. }
  9394. return null;
  9395. }
  9396. }, {
  9397. key: "isViewFinished",
  9398. value: function isViewFinished(view) {
  9399. return view.renderingState === _ui_utils.RenderingStates.FINISHED;
  9400. }
  9401. }, {
  9402. key: "renderView",
  9403. value: function renderView(view) {
  9404. var _this = this;
  9405. switch (view.renderingState) {
  9406. case _ui_utils.RenderingStates.FINISHED:
  9407. return false;
  9408. case _ui_utils.RenderingStates.PAUSED:
  9409. this.highestPriorityPage = view.renderingId;
  9410. view.resume();
  9411. break;
  9412. case _ui_utils.RenderingStates.RUNNING:
  9413. this.highestPriorityPage = view.renderingId;
  9414. break;
  9415. case _ui_utils.RenderingStates.INITIAL:
  9416. this.highestPriorityPage = view.renderingId;
  9417. view.draw()["finally"](function () {
  9418. _this.renderHighestPriority();
  9419. })["catch"](function (reason) {
  9420. if (reason instanceof _pdfjsLib.RenderingCancelledException) {
  9421. return;
  9422. }
  9423. console.error("renderView: \"".concat(reason, "\""));
  9424. });
  9425. break;
  9426. }
  9427. return true;
  9428. }
  9429. }]);
  9430. return PDFRenderingQueue;
  9431. }();
  9432. exports.PDFRenderingQueue = PDFRenderingQueue;
  9433. /***/ }),
  9434. /* 25 */
  9435. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9436. Object.defineProperty(exports, "__esModule", ({
  9437. value: true
  9438. }));
  9439. exports.PDFScriptingManager = void 0;
  9440. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  9441. var _ui_utils = __webpack_require__(5);
  9442. var _pdfjsLib = __webpack_require__(7);
  9443. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9444. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  9445. 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."); }
  9446. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
  9447. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  9448. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  9449. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  9450. 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; }
  9451. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
  9452. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  9453. 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."); }
  9454. 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); }
  9455. 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; }
  9456. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
  9457. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  9458. 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); } }
  9459. 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); }); }; }
  9460. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9461. 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); } }
  9462. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  9463. var PDFScriptingManager = /*#__PURE__*/function () {
  9464. function PDFScriptingManager(_ref) {
  9465. var eventBus = _ref.eventBus,
  9466. _ref$sandboxBundleSrc = _ref.sandboxBundleSrc,
  9467. sandboxBundleSrc = _ref$sandboxBundleSrc === void 0 ? null : _ref$sandboxBundleSrc,
  9468. _ref$scriptingFactory = _ref.scriptingFactory,
  9469. scriptingFactory = _ref$scriptingFactory === void 0 ? null : _ref$scriptingFactory,
  9470. _ref$docPropertiesLoo = _ref.docPropertiesLookup,
  9471. docPropertiesLookup = _ref$docPropertiesLoo === void 0 ? null : _ref$docPropertiesLoo;
  9472. _classCallCheck(this, PDFScriptingManager);
  9473. this._pdfDocument = null;
  9474. this._pdfViewer = null;
  9475. this._closeCapability = null;
  9476. this._destroyCapability = null;
  9477. this._scripting = null;
  9478. this._mouseState = Object.create(null);
  9479. this._ready = false;
  9480. this._eventBus = eventBus;
  9481. this._sandboxBundleSrc = sandboxBundleSrc;
  9482. this._scriptingFactory = scriptingFactory;
  9483. this._docPropertiesLookup = docPropertiesLookup;
  9484. }
  9485. _createClass(PDFScriptingManager, [{
  9486. key: "setViewer",
  9487. value: function setViewer(pdfViewer) {
  9488. this._pdfViewer = pdfViewer;
  9489. }
  9490. }, {
  9491. key: "setDocument",
  9492. value: function () {
  9493. var _setDocument = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pdfDocument) {
  9494. var _this = this,
  9495. _this$_scripting3;
  9496. var _yield$Promise$all, _yield$Promise$all2, objects, calculationOrder, docActions, _iterator, _step, _step$value, name, listener, _iterator2, _step2, _step2$value, _name, _listener, docProperties;
  9497. return _regenerator["default"].wrap(function _callee2$(_context2) {
  9498. while (1) {
  9499. switch (_context2.prev = _context2.next) {
  9500. case 0:
  9501. if (!this._pdfDocument) {
  9502. _context2.next = 3;
  9503. break;
  9504. }
  9505. _context2.next = 3;
  9506. return this._destroyScripting();
  9507. case 3:
  9508. this._pdfDocument = pdfDocument;
  9509. if (pdfDocument) {
  9510. _context2.next = 6;
  9511. break;
  9512. }
  9513. return _context2.abrupt("return");
  9514. case 6:
  9515. _context2.next = 8;
  9516. return Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
  9517. case 8:
  9518. _yield$Promise$all = _context2.sent;
  9519. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
  9520. objects = _yield$Promise$all2[0];
  9521. calculationOrder = _yield$Promise$all2[1];
  9522. docActions = _yield$Promise$all2[2];
  9523. if (!(!objects && !docActions)) {
  9524. _context2.next = 17;
  9525. break;
  9526. }
  9527. _context2.next = 16;
  9528. return this._destroyScripting();
  9529. case 16:
  9530. return _context2.abrupt("return");
  9531. case 17:
  9532. if (!(pdfDocument !== this._pdfDocument)) {
  9533. _context2.next = 19;
  9534. break;
  9535. }
  9536. return _context2.abrupt("return");
  9537. case 19:
  9538. _context2.prev = 19;
  9539. this._scripting = this._createScripting();
  9540. _context2.next = 29;
  9541. break;
  9542. case 23:
  9543. _context2.prev = 23;
  9544. _context2.t0 = _context2["catch"](19);
  9545. console.error("PDFScriptingManager.setDocument: \"".concat(_context2.t0 === null || _context2.t0 === void 0 ? void 0 : _context2.t0.message, "\"."));
  9546. _context2.next = 28;
  9547. return this._destroyScripting();
  9548. case 28:
  9549. return _context2.abrupt("return");
  9550. case 29:
  9551. this._internalEvents.set("updatefromsandbox", function (event) {
  9552. if ((event === null || event === void 0 ? void 0 : event.source) !== window) {
  9553. return;
  9554. }
  9555. _this._updateFromSandbox(event.detail);
  9556. });
  9557. this._internalEvents.set("dispatcheventinsandbox", function (event) {
  9558. var _this$_scripting;
  9559. (_this$_scripting = _this._scripting) === null || _this$_scripting === void 0 ? void 0 : _this$_scripting.dispatchEventInSandbox(event.detail);
  9560. });
  9561. this._internalEvents.set("pagechanging", function (_ref2) {
  9562. var pageNumber = _ref2.pageNumber,
  9563. previous = _ref2.previous;
  9564. if (pageNumber === previous) {
  9565. return;
  9566. }
  9567. _this._dispatchPageClose(previous);
  9568. _this._dispatchPageOpen(pageNumber);
  9569. });
  9570. this._internalEvents.set("pagerendered", function (_ref3) {
  9571. var pageNumber = _ref3.pageNumber;
  9572. if (!_this._pageOpenPending.has(pageNumber)) {
  9573. return;
  9574. }
  9575. if (pageNumber !== _this._pdfViewer.currentPageNumber) {
  9576. return;
  9577. }
  9578. _this._dispatchPageOpen(pageNumber);
  9579. });
  9580. this._internalEvents.set("pagesdestroy", /*#__PURE__*/function () {
  9581. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(event) {
  9582. var _this$_scripting2, _this$_closeCapabilit;
  9583. return _regenerator["default"].wrap(function _callee$(_context) {
  9584. while (1) {
  9585. switch (_context.prev = _context.next) {
  9586. case 0:
  9587. _context.next = 2;
  9588. return _this._dispatchPageClose(_this._pdfViewer.currentPageNumber);
  9589. case 2:
  9590. _context.next = 4;
  9591. return (_this$_scripting2 = _this._scripting) === null || _this$_scripting2 === void 0 ? void 0 : _this$_scripting2.dispatchEventInSandbox({
  9592. id: "doc",
  9593. name: "WillClose"
  9594. });
  9595. case 4:
  9596. (_this$_closeCapabilit = _this._closeCapability) === null || _this$_closeCapabilit === void 0 ? void 0 : _this$_closeCapabilit.resolve();
  9597. case 5:
  9598. case "end":
  9599. return _context.stop();
  9600. }
  9601. }
  9602. }, _callee);
  9603. }));
  9604. return function (_x2) {
  9605. return _ref4.apply(this, arguments);
  9606. };
  9607. }());
  9608. this._domEvents.set("mousedown", function (event) {
  9609. _this._mouseState.isDown = true;
  9610. });
  9611. this._domEvents.set("mouseup", function (event) {
  9612. _this._mouseState.isDown = false;
  9613. });
  9614. _iterator = _createForOfIteratorHelper(this._internalEvents);
  9615. try {
  9616. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  9617. _step$value = _slicedToArray(_step.value, 2), name = _step$value[0], listener = _step$value[1];
  9618. this._eventBus._on(name, listener);
  9619. }
  9620. } catch (err) {
  9621. _iterator.e(err);
  9622. } finally {
  9623. _iterator.f();
  9624. }
  9625. _iterator2 = _createForOfIteratorHelper(this._domEvents);
  9626. try {
  9627. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  9628. _step2$value = _slicedToArray(_step2.value, 2), _name = _step2$value[0], _listener = _step2$value[1];
  9629. window.addEventListener(_name, _listener, true);
  9630. }
  9631. } catch (err) {
  9632. _iterator2.e(err);
  9633. } finally {
  9634. _iterator2.f();
  9635. }
  9636. _context2.prev = 40;
  9637. _context2.next = 43;
  9638. return this._getDocProperties();
  9639. case 43:
  9640. docProperties = _context2.sent;
  9641. if (!(pdfDocument !== this._pdfDocument)) {
  9642. _context2.next = 46;
  9643. break;
  9644. }
  9645. return _context2.abrupt("return");
  9646. case 46:
  9647. _context2.next = 48;
  9648. return this._scripting.createSandbox({
  9649. objects: objects,
  9650. calculationOrder: calculationOrder,
  9651. appInfo: {
  9652. platform: navigator.platform,
  9653. language: navigator.language
  9654. },
  9655. docInfo: _objectSpread(_objectSpread({}, docProperties), {}, {
  9656. actions: docActions
  9657. })
  9658. });
  9659. case 48:
  9660. this._eventBus.dispatch("sandboxcreated", {
  9661. source: this
  9662. });
  9663. _context2.next = 57;
  9664. break;
  9665. case 51:
  9666. _context2.prev = 51;
  9667. _context2.t1 = _context2["catch"](40);
  9668. console.error("PDFScriptingManager.setDocument: \"".concat(_context2.t1 === null || _context2.t1 === void 0 ? void 0 : _context2.t1.message, "\"."));
  9669. _context2.next = 56;
  9670. return this._destroyScripting();
  9671. case 56:
  9672. return _context2.abrupt("return");
  9673. case 57:
  9674. _context2.next = 59;
  9675. return (_this$_scripting3 = this._scripting) === null || _this$_scripting3 === void 0 ? void 0 : _this$_scripting3.dispatchEventInSandbox({
  9676. id: "doc",
  9677. name: "Open"
  9678. });
  9679. case 59:
  9680. _context2.next = 61;
  9681. return this._dispatchPageOpen(this._pdfViewer.currentPageNumber, true);
  9682. case 61:
  9683. Promise.resolve().then(function () {
  9684. if (pdfDocument === _this._pdfDocument) {
  9685. _this._ready = true;
  9686. }
  9687. });
  9688. case 62:
  9689. case "end":
  9690. return _context2.stop();
  9691. }
  9692. }
  9693. }, _callee2, this, [[19, 23], [40, 51]]);
  9694. }));
  9695. function setDocument(_x) {
  9696. return _setDocument.apply(this, arguments);
  9697. }
  9698. return setDocument;
  9699. }()
  9700. }, {
  9701. key: "dispatchWillSave",
  9702. value: function () {
  9703. var _dispatchWillSave = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(detail) {
  9704. var _this$_scripting4;
  9705. return _regenerator["default"].wrap(function _callee3$(_context3) {
  9706. while (1) {
  9707. switch (_context3.prev = _context3.next) {
  9708. case 0:
  9709. return _context3.abrupt("return", (_this$_scripting4 = this._scripting) === null || _this$_scripting4 === void 0 ? void 0 : _this$_scripting4.dispatchEventInSandbox({
  9710. id: "doc",
  9711. name: "WillSave"
  9712. }));
  9713. case 1:
  9714. case "end":
  9715. return _context3.stop();
  9716. }
  9717. }
  9718. }, _callee3, this);
  9719. }));
  9720. function dispatchWillSave(_x3) {
  9721. return _dispatchWillSave.apply(this, arguments);
  9722. }
  9723. return dispatchWillSave;
  9724. }()
  9725. }, {
  9726. key: "dispatchDidSave",
  9727. value: function () {
  9728. var _dispatchDidSave = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(detail) {
  9729. var _this$_scripting5;
  9730. return _regenerator["default"].wrap(function _callee4$(_context4) {
  9731. while (1) {
  9732. switch (_context4.prev = _context4.next) {
  9733. case 0:
  9734. return _context4.abrupt("return", (_this$_scripting5 = this._scripting) === null || _this$_scripting5 === void 0 ? void 0 : _this$_scripting5.dispatchEventInSandbox({
  9735. id: "doc",
  9736. name: "DidSave"
  9737. }));
  9738. case 1:
  9739. case "end":
  9740. return _context4.stop();
  9741. }
  9742. }
  9743. }, _callee4, this);
  9744. }));
  9745. function dispatchDidSave(_x4) {
  9746. return _dispatchDidSave.apply(this, arguments);
  9747. }
  9748. return dispatchDidSave;
  9749. }()
  9750. }, {
  9751. key: "dispatchWillPrint",
  9752. value: function () {
  9753. var _dispatchWillPrint = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(detail) {
  9754. var _this$_scripting6;
  9755. return _regenerator["default"].wrap(function _callee5$(_context5) {
  9756. while (1) {
  9757. switch (_context5.prev = _context5.next) {
  9758. case 0:
  9759. return _context5.abrupt("return", (_this$_scripting6 = this._scripting) === null || _this$_scripting6 === void 0 ? void 0 : _this$_scripting6.dispatchEventInSandbox({
  9760. id: "doc",
  9761. name: "WillPrint"
  9762. }));
  9763. case 1:
  9764. case "end":
  9765. return _context5.stop();
  9766. }
  9767. }
  9768. }, _callee5, this);
  9769. }));
  9770. function dispatchWillPrint(_x5) {
  9771. return _dispatchWillPrint.apply(this, arguments);
  9772. }
  9773. return dispatchWillPrint;
  9774. }()
  9775. }, {
  9776. key: "dispatchDidPrint",
  9777. value: function () {
  9778. var _dispatchDidPrint = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6(detail) {
  9779. var _this$_scripting7;
  9780. return _regenerator["default"].wrap(function _callee6$(_context6) {
  9781. while (1) {
  9782. switch (_context6.prev = _context6.next) {
  9783. case 0:
  9784. return _context6.abrupt("return", (_this$_scripting7 = this._scripting) === null || _this$_scripting7 === void 0 ? void 0 : _this$_scripting7.dispatchEventInSandbox({
  9785. id: "doc",
  9786. name: "DidPrint"
  9787. }));
  9788. case 1:
  9789. case "end":
  9790. return _context6.stop();
  9791. }
  9792. }
  9793. }, _callee6, this);
  9794. }));
  9795. function dispatchDidPrint(_x6) {
  9796. return _dispatchDidPrint.apply(this, arguments);
  9797. }
  9798. return dispatchDidPrint;
  9799. }()
  9800. }, {
  9801. key: "mouseState",
  9802. get: function get() {
  9803. return this._mouseState;
  9804. }
  9805. }, {
  9806. key: "destroyPromise",
  9807. get: function get() {
  9808. var _this$_destroyCapabil;
  9809. return ((_this$_destroyCapabil = this._destroyCapability) === null || _this$_destroyCapabil === void 0 ? void 0 : _this$_destroyCapabil.promise) || null;
  9810. }
  9811. }, {
  9812. key: "ready",
  9813. get: function get() {
  9814. return this._ready;
  9815. }
  9816. }, {
  9817. key: "_internalEvents",
  9818. get: function get() {
  9819. return (0, _pdfjsLib.shadow)(this, "_internalEvents", new Map());
  9820. }
  9821. }, {
  9822. key: "_domEvents",
  9823. get: function get() {
  9824. return (0, _pdfjsLib.shadow)(this, "_domEvents", new Map());
  9825. }
  9826. }, {
  9827. key: "_pageOpenPending",
  9828. get: function get() {
  9829. return (0, _pdfjsLib.shadow)(this, "_pageOpenPending", new Set());
  9830. }
  9831. }, {
  9832. key: "_visitedPages",
  9833. get: function get() {
  9834. return (0, _pdfjsLib.shadow)(this, "_visitedPages", new Map());
  9835. }
  9836. }, {
  9837. key: "_updateFromSandbox",
  9838. value: function () {
  9839. var _updateFromSandbox2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7(detail) {
  9840. var isInPresentationMode, id, siblings, command, value, modes, ids, _iterator3, _step3, elementId, element, _this$_pdfDocument;
  9841. return _regenerator["default"].wrap(function _callee7$(_context7) {
  9842. while (1) {
  9843. switch (_context7.prev = _context7.next) {
  9844. case 0:
  9845. isInPresentationMode = this._pdfViewer.isInPresentationMode || this._pdfViewer.isChangingPresentationMode;
  9846. id = detail.id, siblings = detail.siblings, command = detail.command, value = detail.value;
  9847. if (id) {
  9848. _context7.next = 46;
  9849. break;
  9850. }
  9851. _context7.t0 = command;
  9852. _context7.next = _context7.t0 === "clear" ? 6 : _context7.t0 === "error" ? 8 : _context7.t0 === "layout" ? 10 : _context7.t0 === "page-num" ? 15 : _context7.t0 === "print" ? 17 : _context7.t0 === "println" ? 21 : _context7.t0 === "zoom" ? 23 : _context7.t0 === "SaveAs" ? 27 : _context7.t0 === "FirstPage" ? 29 : _context7.t0 === "LastPage" ? 31 : _context7.t0 === "NextPage" ? 33 : _context7.t0 === "PrevPage" ? 35 : _context7.t0 === "ZoomViewIn" ? 37 : _context7.t0 === "ZoomViewOut" ? 41 : 45;
  9853. break;
  9854. case 6:
  9855. console.clear();
  9856. return _context7.abrupt("break", 45);
  9857. case 8:
  9858. console.error(value);
  9859. return _context7.abrupt("break", 45);
  9860. case 10:
  9861. if (!isInPresentationMode) {
  9862. _context7.next = 12;
  9863. break;
  9864. }
  9865. return _context7.abrupt("return");
  9866. case 12:
  9867. modes = (0, _ui_utils.apiPageLayoutToViewerModes)(value);
  9868. this._pdfViewer.spreadMode = modes.spreadMode;
  9869. return _context7.abrupt("break", 45);
  9870. case 15:
  9871. this._pdfViewer.currentPageNumber = value + 1;
  9872. return _context7.abrupt("break", 45);
  9873. case 17:
  9874. _context7.next = 19;
  9875. return this._pdfViewer.pagesPromise;
  9876. case 19:
  9877. this._eventBus.dispatch("print", {
  9878. source: this
  9879. });
  9880. return _context7.abrupt("break", 45);
  9881. case 21:
  9882. console.log(value);
  9883. return _context7.abrupt("break", 45);
  9884. case 23:
  9885. if (!isInPresentationMode) {
  9886. _context7.next = 25;
  9887. break;
  9888. }
  9889. return _context7.abrupt("return");
  9890. case 25:
  9891. this._pdfViewer.currentScaleValue = value;
  9892. return _context7.abrupt("break", 45);
  9893. case 27:
  9894. this._eventBus.dispatch("save", {
  9895. source: this
  9896. });
  9897. return _context7.abrupt("break", 45);
  9898. case 29:
  9899. this._pdfViewer.currentPageNumber = 1;
  9900. return _context7.abrupt("break", 45);
  9901. case 31:
  9902. this._pdfViewer.currentPageNumber = this._pdfViewer.pagesCount;
  9903. return _context7.abrupt("break", 45);
  9904. case 33:
  9905. this._pdfViewer.nextPage();
  9906. return _context7.abrupt("break", 45);
  9907. case 35:
  9908. this._pdfViewer.previousPage();
  9909. return _context7.abrupt("break", 45);
  9910. case 37:
  9911. if (!isInPresentationMode) {
  9912. _context7.next = 39;
  9913. break;
  9914. }
  9915. return _context7.abrupt("return");
  9916. case 39:
  9917. this._pdfViewer.increaseScale();
  9918. return _context7.abrupt("break", 45);
  9919. case 41:
  9920. if (!isInPresentationMode) {
  9921. _context7.next = 43;
  9922. break;
  9923. }
  9924. return _context7.abrupt("return");
  9925. case 43:
  9926. this._pdfViewer.decreaseScale();
  9927. return _context7.abrupt("break", 45);
  9928. case 45:
  9929. return _context7.abrupt("return");
  9930. case 46:
  9931. if (!isInPresentationMode) {
  9932. _context7.next = 49;
  9933. break;
  9934. }
  9935. if (!detail.focus) {
  9936. _context7.next = 49;
  9937. break;
  9938. }
  9939. return _context7.abrupt("return");
  9940. case 49:
  9941. delete detail.id;
  9942. delete detail.siblings;
  9943. ids = siblings ? [id].concat(_toConsumableArray(siblings)) : [id];
  9944. _iterator3 = _createForOfIteratorHelper(ids);
  9945. try {
  9946. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  9947. elementId = _step3.value;
  9948. element = document.getElementById(elementId);
  9949. if (element) {
  9950. element.dispatchEvent(new CustomEvent("updatefromsandbox", {
  9951. detail: detail
  9952. }));
  9953. } else {
  9954. (_this$_pdfDocument = this._pdfDocument) === null || _this$_pdfDocument === void 0 ? void 0 : _this$_pdfDocument.annotationStorage.setValue(elementId, detail);
  9955. }
  9956. }
  9957. } catch (err) {
  9958. _iterator3.e(err);
  9959. } finally {
  9960. _iterator3.f();
  9961. }
  9962. case 54:
  9963. case "end":
  9964. return _context7.stop();
  9965. }
  9966. }
  9967. }, _callee7, this);
  9968. }));
  9969. function _updateFromSandbox(_x7) {
  9970. return _updateFromSandbox2.apply(this, arguments);
  9971. }
  9972. return _updateFromSandbox;
  9973. }()
  9974. }, {
  9975. key: "_dispatchPageOpen",
  9976. value: function () {
  9977. var _dispatchPageOpen2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee9(pageNumber) {
  9978. var _this2 = this;
  9979. var initialize,
  9980. pdfDocument,
  9981. visitedPages,
  9982. pageView,
  9983. actionsPromise,
  9984. _args9 = arguments;
  9985. return _regenerator["default"].wrap(function _callee9$(_context9) {
  9986. while (1) {
  9987. switch (_context9.prev = _context9.next) {
  9988. case 0:
  9989. initialize = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : false;
  9990. pdfDocument = this._pdfDocument, visitedPages = this._visitedPages;
  9991. if (initialize) {
  9992. this._closeCapability = (0, _pdfjsLib.createPromiseCapability)();
  9993. }
  9994. if (this._closeCapability) {
  9995. _context9.next = 5;
  9996. break;
  9997. }
  9998. return _context9.abrupt("return");
  9999. case 5:
  10000. pageView = this._pdfViewer.getPageView(pageNumber - 1);
  10001. if (!((pageView === null || pageView === void 0 ? void 0 : pageView.renderingState) !== _ui_utils.RenderingStates.FINISHED)) {
  10002. _context9.next = 9;
  10003. break;
  10004. }
  10005. this._pageOpenPending.add(pageNumber);
  10006. return _context9.abrupt("return");
  10007. case 9:
  10008. this._pageOpenPending["delete"](pageNumber);
  10009. actionsPromise = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
  10010. var _pageView$pdfPage, _this2$_scripting;
  10011. var actions;
  10012. return _regenerator["default"].wrap(function _callee8$(_context8) {
  10013. while (1) {
  10014. switch (_context8.prev = _context8.next) {
  10015. case 0:
  10016. _context8.next = 2;
  10017. return !visitedPages.has(pageNumber) ? (_pageView$pdfPage = pageView.pdfPage) === null || _pageView$pdfPage === void 0 ? void 0 : _pageView$pdfPage.getJSActions() : null;
  10018. case 2:
  10019. actions = _context8.sent;
  10020. if (!(pdfDocument !== _this2._pdfDocument)) {
  10021. _context8.next = 5;
  10022. break;
  10023. }
  10024. return _context8.abrupt("return");
  10025. case 5:
  10026. _context8.next = 7;
  10027. return (_this2$_scripting = _this2._scripting) === null || _this2$_scripting === void 0 ? void 0 : _this2$_scripting.dispatchEventInSandbox({
  10028. id: "page",
  10029. name: "PageOpen",
  10030. pageNumber: pageNumber,
  10031. actions: actions
  10032. });
  10033. case 7:
  10034. case "end":
  10035. return _context8.stop();
  10036. }
  10037. }
  10038. }, _callee8);
  10039. }))();
  10040. visitedPages.set(pageNumber, actionsPromise);
  10041. case 12:
  10042. case "end":
  10043. return _context9.stop();
  10044. }
  10045. }
  10046. }, _callee9, this);
  10047. }));
  10048. function _dispatchPageOpen(_x8) {
  10049. return _dispatchPageOpen2.apply(this, arguments);
  10050. }
  10051. return _dispatchPageOpen;
  10052. }()
  10053. }, {
  10054. key: "_dispatchPageClose",
  10055. value: function () {
  10056. var _dispatchPageClose2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee10(pageNumber) {
  10057. var _this$_scripting8;
  10058. var pdfDocument, visitedPages, actionsPromise;
  10059. return _regenerator["default"].wrap(function _callee10$(_context10) {
  10060. while (1) {
  10061. switch (_context10.prev = _context10.next) {
  10062. case 0:
  10063. pdfDocument = this._pdfDocument, visitedPages = this._visitedPages;
  10064. if (this._closeCapability) {
  10065. _context10.next = 3;
  10066. break;
  10067. }
  10068. return _context10.abrupt("return");
  10069. case 3:
  10070. if (!this._pageOpenPending.has(pageNumber)) {
  10071. _context10.next = 5;
  10072. break;
  10073. }
  10074. return _context10.abrupt("return");
  10075. case 5:
  10076. actionsPromise = visitedPages.get(pageNumber);
  10077. if (actionsPromise) {
  10078. _context10.next = 8;
  10079. break;
  10080. }
  10081. return _context10.abrupt("return");
  10082. case 8:
  10083. visitedPages.set(pageNumber, null);
  10084. _context10.next = 11;
  10085. return actionsPromise;
  10086. case 11:
  10087. if (!(pdfDocument !== this._pdfDocument)) {
  10088. _context10.next = 13;
  10089. break;
  10090. }
  10091. return _context10.abrupt("return");
  10092. case 13:
  10093. _context10.next = 15;
  10094. return (_this$_scripting8 = this._scripting) === null || _this$_scripting8 === void 0 ? void 0 : _this$_scripting8.dispatchEventInSandbox({
  10095. id: "page",
  10096. name: "PageClose",
  10097. pageNumber: pageNumber
  10098. });
  10099. case 15:
  10100. case "end":
  10101. return _context10.stop();
  10102. }
  10103. }
  10104. }, _callee10, this);
  10105. }));
  10106. function _dispatchPageClose(_x9) {
  10107. return _dispatchPageClose2.apply(this, arguments);
  10108. }
  10109. return _dispatchPageClose;
  10110. }()
  10111. }, {
  10112. key: "_getDocProperties",
  10113. value: function () {
  10114. var _getDocProperties2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
  10115. return _regenerator["default"].wrap(function _callee11$(_context11) {
  10116. while (1) {
  10117. switch (_context11.prev = _context11.next) {
  10118. case 0:
  10119. if (!this._docPropertiesLookup) {
  10120. _context11.next = 2;
  10121. break;
  10122. }
  10123. return _context11.abrupt("return", this._docPropertiesLookup(this._pdfDocument));
  10124. case 2:
  10125. throw new Error("_getDocProperties: Unable to lookup properties.");
  10126. case 3:
  10127. case "end":
  10128. return _context11.stop();
  10129. }
  10130. }
  10131. }, _callee11, this);
  10132. }));
  10133. function _getDocProperties() {
  10134. return _getDocProperties2.apply(this, arguments);
  10135. }
  10136. return _getDocProperties;
  10137. }()
  10138. }, {
  10139. key: "_createScripting",
  10140. value: function _createScripting() {
  10141. this._destroyCapability = (0, _pdfjsLib.createPromiseCapability)();
  10142. if (this._scripting) {
  10143. throw new Error("_createScripting: Scripting already exists.");
  10144. }
  10145. if (this._scriptingFactory) {
  10146. return this._scriptingFactory.createScripting({
  10147. sandboxBundleSrc: this._sandboxBundleSrc
  10148. });
  10149. }
  10150. throw new Error("_createScripting: Cannot create scripting.");
  10151. }
  10152. }, {
  10153. key: "_destroyScripting",
  10154. value: function () {
  10155. var _destroyScripting2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
  10156. var _this$_destroyCapabil3;
  10157. var _this$_destroyCapabil2, _iterator4, _step4, _step4$value, name, listener, _iterator5, _step5, _step5$value, _name2, _listener2;
  10158. return _regenerator["default"].wrap(function _callee12$(_context12) {
  10159. while (1) {
  10160. switch (_context12.prev = _context12.next) {
  10161. case 0:
  10162. if (this._scripting) {
  10163. _context12.next = 4;
  10164. break;
  10165. }
  10166. this._pdfDocument = null;
  10167. (_this$_destroyCapabil2 = this._destroyCapability) === null || _this$_destroyCapabil2 === void 0 ? void 0 : _this$_destroyCapabil2.resolve();
  10168. return _context12.abrupt("return");
  10169. case 4:
  10170. if (!this._closeCapability) {
  10171. _context12.next = 8;
  10172. break;
  10173. }
  10174. _context12.next = 7;
  10175. return Promise.race([this._closeCapability.promise, new Promise(function (resolve) {
  10176. setTimeout(resolve, 1000);
  10177. })])["catch"](function (reason) {});
  10178. case 7:
  10179. this._closeCapability = null;
  10180. case 8:
  10181. this._pdfDocument = null;
  10182. _context12.prev = 9;
  10183. _context12.next = 12;
  10184. return this._scripting.destroySandbox();
  10185. case 12:
  10186. _context12.next = 16;
  10187. break;
  10188. case 14:
  10189. _context12.prev = 14;
  10190. _context12.t0 = _context12["catch"](9);
  10191. case 16:
  10192. _iterator4 = _createForOfIteratorHelper(this._internalEvents);
  10193. try {
  10194. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  10195. _step4$value = _slicedToArray(_step4.value, 2), name = _step4$value[0], listener = _step4$value[1];
  10196. this._eventBus._off(name, listener);
  10197. }
  10198. } catch (err) {
  10199. _iterator4.e(err);
  10200. } finally {
  10201. _iterator4.f();
  10202. }
  10203. this._internalEvents.clear();
  10204. _iterator5 = _createForOfIteratorHelper(this._domEvents);
  10205. try {
  10206. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  10207. _step5$value = _slicedToArray(_step5.value, 2), _name2 = _step5$value[0], _listener2 = _step5$value[1];
  10208. window.removeEventListener(_name2, _listener2, true);
  10209. }
  10210. } catch (err) {
  10211. _iterator5.e(err);
  10212. } finally {
  10213. _iterator5.f();
  10214. }
  10215. this._domEvents.clear();
  10216. this._pageOpenPending.clear();
  10217. this._visitedPages.clear();
  10218. this._scripting = null;
  10219. delete this._mouseState.isDown;
  10220. this._ready = false;
  10221. (_this$_destroyCapabil3 = this._destroyCapability) === null || _this$_destroyCapabil3 === void 0 ? void 0 : _this$_destroyCapabil3.resolve();
  10222. case 28:
  10223. case "end":
  10224. return _context12.stop();
  10225. }
  10226. }
  10227. }, _callee12, this, [[9, 14]]);
  10228. }));
  10229. function _destroyScripting() {
  10230. return _destroyScripting2.apply(this, arguments);
  10231. }
  10232. return _destroyScripting;
  10233. }()
  10234. }]);
  10235. return PDFScriptingManager;
  10236. }();
  10237. exports.PDFScriptingManager = PDFScriptingManager;
  10238. /***/ }),
  10239. /* 26 */
  10240. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10241. Object.defineProperty(exports, "__esModule", ({
  10242. value: true
  10243. }));
  10244. exports.PDFSidebar = void 0;
  10245. var _ui_utils = __webpack_require__(5);
  10246. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10247. 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); } }
  10248. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  10249. var UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  10250. var PDFSidebar = /*#__PURE__*/function () {
  10251. function PDFSidebar(_ref) {
  10252. var elements = _ref.elements,
  10253. pdfViewer = _ref.pdfViewer,
  10254. pdfThumbnailViewer = _ref.pdfThumbnailViewer,
  10255. eventBus = _ref.eventBus,
  10256. l10n = _ref.l10n;
  10257. _classCallCheck(this, PDFSidebar);
  10258. this.isOpen = false;
  10259. this.active = _ui_utils.SidebarView.THUMBS;
  10260. this.isInitialViewSet = false;
  10261. this.onToggled = null;
  10262. this.pdfViewer = pdfViewer;
  10263. this.pdfThumbnailViewer = pdfThumbnailViewer;
  10264. this.outerContainer = elements.outerContainer;
  10265. this.sidebarContainer = elements.sidebarContainer;
  10266. this.toggleButton = elements.toggleButton;
  10267. this.thumbnailButton = elements.thumbnailButton;
  10268. this.outlineButton = elements.outlineButton;
  10269. this.attachmentsButton = elements.attachmentsButton;
  10270. this.layersButton = elements.layersButton;
  10271. this.thumbnailView = elements.thumbnailView;
  10272. this.outlineView = elements.outlineView;
  10273. this.attachmentsView = elements.attachmentsView;
  10274. this.layersView = elements.layersView;
  10275. this._outlineOptionsContainer = elements.outlineOptionsContainer;
  10276. this._currentOutlineItemButton = elements.currentOutlineItemButton;
  10277. this.eventBus = eventBus;
  10278. this.l10n = l10n;
  10279. this._addEventListeners();
  10280. }
  10281. _createClass(PDFSidebar, [{
  10282. key: "reset",
  10283. value: function reset() {
  10284. this.isInitialViewSet = false;
  10285. this._hideUINotification(true);
  10286. this.switchView(_ui_utils.SidebarView.THUMBS);
  10287. this.outlineButton.disabled = false;
  10288. this.attachmentsButton.disabled = false;
  10289. this.layersButton.disabled = false;
  10290. this._currentOutlineItemButton.disabled = true;
  10291. }
  10292. }, {
  10293. key: "visibleView",
  10294. get: function get() {
  10295. return this.isOpen ? this.active : _ui_utils.SidebarView.NONE;
  10296. }
  10297. }, {
  10298. key: "isThumbnailViewVisible",
  10299. get: function get() {
  10300. return this.isOpen && this.active === _ui_utils.SidebarView.THUMBS;
  10301. }
  10302. }, {
  10303. key: "isOutlineViewVisible",
  10304. get: function get() {
  10305. return this.isOpen && this.active === _ui_utils.SidebarView.OUTLINE;
  10306. }
  10307. }, {
  10308. key: "isAttachmentsViewVisible",
  10309. get: function get() {
  10310. return this.isOpen && this.active === _ui_utils.SidebarView.ATTACHMENTS;
  10311. }
  10312. }, {
  10313. key: "isLayersViewVisible",
  10314. get: function get() {
  10315. return this.isOpen && this.active === _ui_utils.SidebarView.LAYERS;
  10316. }
  10317. }, {
  10318. key: "setInitialView",
  10319. value: function setInitialView() {
  10320. var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _ui_utils.SidebarView.NONE;
  10321. if (this.isInitialViewSet) {
  10322. return;
  10323. }
  10324. this.isInitialViewSet = true;
  10325. if (view === _ui_utils.SidebarView.NONE || view === _ui_utils.SidebarView.UNKNOWN) {
  10326. this._dispatchEvent();
  10327. return;
  10328. }
  10329. if (!this._switchView(view, true)) {
  10330. this._dispatchEvent();
  10331. }
  10332. }
  10333. }, {
  10334. key: "switchView",
  10335. value: function switchView(view) {
  10336. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10337. this._switchView(view, forceOpen);
  10338. }
  10339. }, {
  10340. key: "_switchView",
  10341. value: function _switchView(view) {
  10342. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10343. var isViewChanged = view !== this.active;
  10344. var shouldForceRendering = false;
  10345. switch (view) {
  10346. case _ui_utils.SidebarView.NONE:
  10347. if (this.isOpen) {
  10348. this.close();
  10349. return true;
  10350. }
  10351. return false;
  10352. case _ui_utils.SidebarView.THUMBS:
  10353. if (this.isOpen && isViewChanged) {
  10354. shouldForceRendering = true;
  10355. }
  10356. break;
  10357. case _ui_utils.SidebarView.OUTLINE:
  10358. if (this.outlineButton.disabled) {
  10359. return false;
  10360. }
  10361. break;
  10362. case _ui_utils.SidebarView.ATTACHMENTS:
  10363. if (this.attachmentsButton.disabled) {
  10364. return false;
  10365. }
  10366. break;
  10367. case _ui_utils.SidebarView.LAYERS:
  10368. if (this.layersButton.disabled) {
  10369. return false;
  10370. }
  10371. break;
  10372. default:
  10373. console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
  10374. return false;
  10375. }
  10376. this.active = view;
  10377. var isThumbs = view === _ui_utils.SidebarView.THUMBS,
  10378. isOutline = view === _ui_utils.SidebarView.OUTLINE,
  10379. isAttachments = view === _ui_utils.SidebarView.ATTACHMENTS,
  10380. isLayers = view === _ui_utils.SidebarView.LAYERS;
  10381. this.thumbnailButton.classList.toggle("toggled", isThumbs);
  10382. this.outlineButton.classList.toggle("toggled", isOutline);
  10383. this.attachmentsButton.classList.toggle("toggled", isAttachments);
  10384. this.layersButton.classList.toggle("toggled", isLayers);
  10385. this.thumbnailButton.setAttribute("aria-checked", isThumbs);
  10386. this.outlineButton.setAttribute("aria-checked", isOutline);
  10387. this.attachmentsButton.setAttribute("aria-checked", isAttachments);
  10388. this.layersButton.setAttribute("aria-checked", isLayers);
  10389. this.thumbnailView.classList.toggle("hidden", !isThumbs);
  10390. this.outlineView.classList.toggle("hidden", !isOutline);
  10391. this.attachmentsView.classList.toggle("hidden", !isAttachments);
  10392. this.layersView.classList.toggle("hidden", !isLayers);
  10393. this._outlineOptionsContainer.classList.toggle("hidden", !isOutline);
  10394. if (forceOpen && !this.isOpen) {
  10395. this.open();
  10396. return true;
  10397. }
  10398. if (shouldForceRendering) {
  10399. this._updateThumbnailViewer();
  10400. this._forceRendering();
  10401. }
  10402. if (isViewChanged) {
  10403. this._dispatchEvent();
  10404. }
  10405. return isViewChanged;
  10406. }
  10407. }, {
  10408. key: "open",
  10409. value: function open() {
  10410. if (this.isOpen) {
  10411. return;
  10412. }
  10413. this.isOpen = true;
  10414. this.toggleButton.classList.add("toggled");
  10415. this.toggleButton.setAttribute("aria-expanded", "true");
  10416. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  10417. if (this.active === _ui_utils.SidebarView.THUMBS) {
  10418. this._updateThumbnailViewer();
  10419. }
  10420. this._forceRendering();
  10421. this._dispatchEvent();
  10422. this._hideUINotification();
  10423. }
  10424. }, {
  10425. key: "close",
  10426. value: function close() {
  10427. if (!this.isOpen) {
  10428. return;
  10429. }
  10430. this.isOpen = false;
  10431. this.toggleButton.classList.remove("toggled");
  10432. this.toggleButton.setAttribute("aria-expanded", "false");
  10433. this.outerContainer.classList.add("sidebarMoving");
  10434. this.outerContainer.classList.remove("sidebarOpen");
  10435. this._forceRendering();
  10436. this._dispatchEvent();
  10437. }
  10438. }, {
  10439. key: "toggle",
  10440. value: function toggle() {
  10441. if (this.isOpen) {
  10442. this.close();
  10443. } else {
  10444. this.open();
  10445. }
  10446. }
  10447. }, {
  10448. key: "_dispatchEvent",
  10449. value: function _dispatchEvent() {
  10450. this.eventBus.dispatch("sidebarviewchanged", {
  10451. source: this,
  10452. view: this.visibleView
  10453. });
  10454. }
  10455. }, {
  10456. key: "_forceRendering",
  10457. value: function _forceRendering() {
  10458. if (this.onToggled) {
  10459. this.onToggled();
  10460. } else {
  10461. this.pdfViewer.forceRendering();
  10462. this.pdfThumbnailViewer.forceRendering();
  10463. }
  10464. }
  10465. }, {
  10466. key: "_updateThumbnailViewer",
  10467. value: function _updateThumbnailViewer() {
  10468. var pdfViewer = this.pdfViewer,
  10469. pdfThumbnailViewer = this.pdfThumbnailViewer;
  10470. var pagesCount = pdfViewer.pagesCount;
  10471. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  10472. var pageView = pdfViewer.getPageView(pageIndex);
  10473. if ((pageView === null || pageView === void 0 ? void 0 : pageView.renderingState) === _ui_utils.RenderingStates.FINISHED) {
  10474. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  10475. thumbnailView.setImage(pageView);
  10476. }
  10477. }
  10478. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  10479. }
  10480. }, {
  10481. key: "_showUINotification",
  10482. value: function _showUINotification() {
  10483. var _this = this;
  10484. this.l10n.get("toggle_sidebar_notification2.title").then(function (msg) {
  10485. _this.toggleButton.title = msg;
  10486. });
  10487. if (!this.isOpen) {
  10488. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  10489. }
  10490. }
  10491. }, {
  10492. key: "_hideUINotification",
  10493. value: function _hideUINotification() {
  10494. var _this2 = this;
  10495. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10496. if (this.isOpen || reset) {
  10497. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  10498. }
  10499. if (reset) {
  10500. this.l10n.get("toggle_sidebar.title").then(function (msg) {
  10501. _this2.toggleButton.title = msg;
  10502. });
  10503. }
  10504. }
  10505. }, {
  10506. key: "_addEventListeners",
  10507. value: function _addEventListeners() {
  10508. var _this3 = this;
  10509. this.sidebarContainer.addEventListener("transitionend", function (evt) {
  10510. if (evt.target === _this3.sidebarContainer) {
  10511. _this3.outerContainer.classList.remove("sidebarMoving");
  10512. }
  10513. });
  10514. this.toggleButton.addEventListener("click", function () {
  10515. _this3.toggle();
  10516. });
  10517. this.thumbnailButton.addEventListener("click", function () {
  10518. _this3.switchView(_ui_utils.SidebarView.THUMBS);
  10519. });
  10520. this.outlineButton.addEventListener("click", function () {
  10521. _this3.switchView(_ui_utils.SidebarView.OUTLINE);
  10522. });
  10523. this.outlineButton.addEventListener("dblclick", function () {
  10524. _this3.eventBus.dispatch("toggleoutlinetree", {
  10525. source: _this3
  10526. });
  10527. });
  10528. this.attachmentsButton.addEventListener("click", function () {
  10529. _this3.switchView(_ui_utils.SidebarView.ATTACHMENTS);
  10530. });
  10531. this.layersButton.addEventListener("click", function () {
  10532. _this3.switchView(_ui_utils.SidebarView.LAYERS);
  10533. });
  10534. this.layersButton.addEventListener("dblclick", function () {
  10535. _this3.eventBus.dispatch("resetlayers", {
  10536. source: _this3
  10537. });
  10538. });
  10539. this._currentOutlineItemButton.addEventListener("click", function () {
  10540. _this3.eventBus.dispatch("currentoutlineitem", {
  10541. source: _this3
  10542. });
  10543. });
  10544. var onTreeLoaded = function onTreeLoaded(count, button, view) {
  10545. button.disabled = !count;
  10546. if (count) {
  10547. _this3._showUINotification();
  10548. } else if (_this3.active === view) {
  10549. _this3.switchView(_ui_utils.SidebarView.THUMBS);
  10550. }
  10551. };
  10552. this.eventBus._on("outlineloaded", function (evt) {
  10553. onTreeLoaded(evt.outlineCount, _this3.outlineButton, _ui_utils.SidebarView.OUTLINE);
  10554. evt.currentOutlineItemPromise.then(function (enabled) {
  10555. if (!_this3.isInitialViewSet) {
  10556. return;
  10557. }
  10558. _this3._currentOutlineItemButton.disabled = !enabled;
  10559. });
  10560. });
  10561. this.eventBus._on("attachmentsloaded", function (evt) {
  10562. onTreeLoaded(evt.attachmentsCount, _this3.attachmentsButton, _ui_utils.SidebarView.ATTACHMENTS);
  10563. });
  10564. this.eventBus._on("layersloaded", function (evt) {
  10565. onTreeLoaded(evt.layersCount, _this3.layersButton, _ui_utils.SidebarView.LAYERS);
  10566. });
  10567. this.eventBus._on("presentationmodechanged", function (evt) {
  10568. if (evt.state === _ui_utils.PresentationModeState.NORMAL && _this3.isThumbnailViewVisible) {
  10569. _this3._updateThumbnailViewer();
  10570. }
  10571. });
  10572. }
  10573. }]);
  10574. return PDFSidebar;
  10575. }();
  10576. exports.PDFSidebar = PDFSidebar;
  10577. /***/ }),
  10578. /* 27 */
  10579. /***/ ((__unused_webpack_module, exports) => {
  10580. Object.defineProperty(exports, "__esModule", ({
  10581. value: true
  10582. }));
  10583. exports.PDFSidebarResizer = void 0;
  10584. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10585. 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); } }
  10586. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  10587. var SIDEBAR_WIDTH_VAR = "--sidebar-width";
  10588. var SIDEBAR_MIN_WIDTH = 200;
  10589. var SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  10590. var PDFSidebarResizer = /*#__PURE__*/function () {
  10591. function PDFSidebarResizer(options, eventBus, l10n) {
  10592. var _this = this;
  10593. _classCallCheck(this, PDFSidebarResizer);
  10594. this.isRTL = false;
  10595. this.sidebarOpen = false;
  10596. this.doc = document.documentElement;
  10597. this._width = null;
  10598. this._outerContainerWidth = null;
  10599. this._boundEvents = Object.create(null);
  10600. this.outerContainer = options.outerContainer;
  10601. this.resizer = options.resizer;
  10602. this.eventBus = eventBus;
  10603. l10n.getDirection().then(function (dir) {
  10604. _this.isRTL = dir === "rtl";
  10605. });
  10606. this._addEventListeners();
  10607. }
  10608. _createClass(PDFSidebarResizer, [{
  10609. key: "outerContainerWidth",
  10610. get: function get() {
  10611. return this._outerContainerWidth || (this._outerContainerWidth = this.outerContainer.clientWidth);
  10612. }
  10613. }, {
  10614. key: "_updateWidth",
  10615. value: function _updateWidth() {
  10616. var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10617. var maxWidth = Math.floor(this.outerContainerWidth / 2);
  10618. if (width > maxWidth) {
  10619. width = maxWidth;
  10620. }
  10621. if (width < SIDEBAR_MIN_WIDTH) {
  10622. width = SIDEBAR_MIN_WIDTH;
  10623. }
  10624. if (width === this._width) {
  10625. return false;
  10626. }
  10627. this._width = width;
  10628. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(width, "px"));
  10629. return true;
  10630. }
  10631. }, {
  10632. key: "_mouseMove",
  10633. value: function _mouseMove(evt) {
  10634. var width = evt.clientX;
  10635. if (this.isRTL) {
  10636. width = this.outerContainerWidth - width;
  10637. }
  10638. this._updateWidth(width);
  10639. }
  10640. }, {
  10641. key: "_mouseUp",
  10642. value: function _mouseUp(evt) {
  10643. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  10644. this.eventBus.dispatch("resize", {
  10645. source: this
  10646. });
  10647. var _boundEvents = this._boundEvents;
  10648. window.removeEventListener("mousemove", _boundEvents.mouseMove);
  10649. window.removeEventListener("mouseup", _boundEvents.mouseUp);
  10650. }
  10651. }, {
  10652. key: "_addEventListeners",
  10653. value: function _addEventListeners() {
  10654. var _this2 = this;
  10655. var _boundEvents = this._boundEvents;
  10656. _boundEvents.mouseMove = this._mouseMove.bind(this);
  10657. _boundEvents.mouseUp = this._mouseUp.bind(this);
  10658. this.resizer.addEventListener("mousedown", function (evt) {
  10659. if (evt.button !== 0) {
  10660. return;
  10661. }
  10662. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  10663. window.addEventListener("mousemove", _boundEvents.mouseMove);
  10664. window.addEventListener("mouseup", _boundEvents.mouseUp);
  10665. });
  10666. this.eventBus._on("sidebarviewchanged", function (evt) {
  10667. _this2.sidebarOpen = !!(evt !== null && evt !== void 0 && evt.view);
  10668. });
  10669. this.eventBus._on("resize", function (evt) {
  10670. if ((evt === null || evt === void 0 ? void 0 : evt.source) !== window) {
  10671. return;
  10672. }
  10673. _this2._outerContainerWidth = null;
  10674. if (!_this2._width) {
  10675. return;
  10676. }
  10677. if (!_this2.sidebarOpen) {
  10678. _this2._updateWidth(_this2._width);
  10679. return;
  10680. }
  10681. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  10682. var updated = _this2._updateWidth(_this2._width);
  10683. Promise.resolve().then(function () {
  10684. _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  10685. if (updated) {
  10686. _this2.eventBus.dispatch("resize", {
  10687. source: _this2
  10688. });
  10689. }
  10690. });
  10691. });
  10692. }
  10693. }]);
  10694. return PDFSidebarResizer;
  10695. }();
  10696. exports.PDFSidebarResizer = PDFSidebarResizer;
  10697. /***/ }),
  10698. /* 28 */
  10699. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10700. Object.defineProperty(exports, "__esModule", ({
  10701. value: true
  10702. }));
  10703. exports.PDFThumbnailViewer = void 0;
  10704. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  10705. var _ui_utils = __webpack_require__(5);
  10706. var _pdf_thumbnail_view = __webpack_require__(29);
  10707. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  10708. 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); } }
  10709. 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); }); }; }
  10710. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
  10711. 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); }
  10712. 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; }
  10713. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10714. 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); } }
  10715. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  10716. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  10717. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  10718. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  10719. var THUMBNAIL_SCROLL_MARGIN = -19;
  10720. var THUMBNAIL_SELECTED_CLASS = "selected";
  10721. var _ensurePdfPageLoaded = /*#__PURE__*/new WeakSet();
  10722. var _getScrollAhead = /*#__PURE__*/new WeakSet();
  10723. var PDFThumbnailViewer = /*#__PURE__*/function () {
  10724. function PDFThumbnailViewer(_ref) {
  10725. var _this = this;
  10726. var container = _ref.container,
  10727. eventBus = _ref.eventBus,
  10728. linkService = _ref.linkService,
  10729. renderingQueue = _ref.renderingQueue,
  10730. l10n = _ref.l10n;
  10731. _classCallCheck(this, PDFThumbnailViewer);
  10732. _classPrivateMethodInitSpec(this, _getScrollAhead);
  10733. _classPrivateMethodInitSpec(this, _ensurePdfPageLoaded);
  10734. this.container = container;
  10735. this.linkService = linkService;
  10736. this.renderingQueue = renderingQueue;
  10737. this.l10n = l10n;
  10738. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  10739. this._resetView();
  10740. eventBus._on("optionalcontentconfigchanged", function () {
  10741. _this._setImageDisabled = true;
  10742. });
  10743. }
  10744. _createClass(PDFThumbnailViewer, [{
  10745. key: "_scrollUpdated",
  10746. value: function _scrollUpdated() {
  10747. this.renderingQueue.renderHighestPriority();
  10748. }
  10749. }, {
  10750. key: "getThumbnail",
  10751. value: function getThumbnail(index) {
  10752. return this._thumbnails[index];
  10753. }
  10754. }, {
  10755. key: "_getVisibleThumbs",
  10756. value: function _getVisibleThumbs() {
  10757. return (0, _ui_utils.getVisibleElements)({
  10758. scrollEl: this.container,
  10759. views: this._thumbnails
  10760. });
  10761. }
  10762. }, {
  10763. key: "scrollThumbnailIntoView",
  10764. value: function scrollThumbnailIntoView(pageNumber) {
  10765. if (!this.pdfDocument) {
  10766. return;
  10767. }
  10768. var thumbnailView = this._thumbnails[pageNumber - 1];
  10769. if (!thumbnailView) {
  10770. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  10771. return;
  10772. }
  10773. if (pageNumber !== this._currentPageNumber) {
  10774. var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  10775. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  10776. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  10777. }
  10778. var _this$_getVisibleThum = this._getVisibleThumbs(),
  10779. first = _this$_getVisibleThum.first,
  10780. last = _this$_getVisibleThum.last,
  10781. views = _this$_getVisibleThum.views;
  10782. if (views.length > 0) {
  10783. var shouldScroll = false;
  10784. if (pageNumber <= first.id || pageNumber >= last.id) {
  10785. shouldScroll = true;
  10786. } else {
  10787. var _iterator = _createForOfIteratorHelper(views),
  10788. _step;
  10789. try {
  10790. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  10791. var _step$value = _step.value,
  10792. id = _step$value.id,
  10793. percent = _step$value.percent;
  10794. if (id !== pageNumber) {
  10795. continue;
  10796. }
  10797. shouldScroll = percent < 100;
  10798. break;
  10799. }
  10800. } catch (err) {
  10801. _iterator.e(err);
  10802. } finally {
  10803. _iterator.f();
  10804. }
  10805. }
  10806. if (shouldScroll) {
  10807. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  10808. top: THUMBNAIL_SCROLL_MARGIN
  10809. });
  10810. }
  10811. }
  10812. this._currentPageNumber = pageNumber;
  10813. }
  10814. }, {
  10815. key: "pagesRotation",
  10816. get: function get() {
  10817. return this._pagesRotation;
  10818. },
  10819. set: function set(rotation) {
  10820. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  10821. throw new Error("Invalid thumbnails rotation angle.");
  10822. }
  10823. if (!this.pdfDocument) {
  10824. return;
  10825. }
  10826. if (this._pagesRotation === rotation) {
  10827. return;
  10828. }
  10829. this._pagesRotation = rotation;
  10830. var updateArgs = {
  10831. rotation: rotation
  10832. };
  10833. var _iterator2 = _createForOfIteratorHelper(this._thumbnails),
  10834. _step2;
  10835. try {
  10836. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  10837. var thumbnail = _step2.value;
  10838. thumbnail.update(updateArgs);
  10839. }
  10840. } catch (err) {
  10841. _iterator2.e(err);
  10842. } finally {
  10843. _iterator2.f();
  10844. }
  10845. }
  10846. }, {
  10847. key: "cleanup",
  10848. value: function cleanup() {
  10849. var _iterator3 = _createForOfIteratorHelper(this._thumbnails),
  10850. _step3;
  10851. try {
  10852. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  10853. var thumbnail = _step3.value;
  10854. if (thumbnail.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  10855. thumbnail.reset();
  10856. }
  10857. }
  10858. } catch (err) {
  10859. _iterator3.e(err);
  10860. } finally {
  10861. _iterator3.f();
  10862. }
  10863. _pdf_thumbnail_view.TempImageFactory.destroyCanvas();
  10864. }
  10865. }, {
  10866. key: "_resetView",
  10867. value: function _resetView() {
  10868. this._thumbnails = [];
  10869. this._currentPageNumber = 1;
  10870. this._pageLabels = null;
  10871. this._pagesRotation = 0;
  10872. this._optionalContentConfigPromise = null;
  10873. this._setImageDisabled = false;
  10874. this.container.textContent = "";
  10875. }
  10876. }, {
  10877. key: "setDocument",
  10878. value: function setDocument(pdfDocument) {
  10879. var _this2 = this;
  10880. if (this.pdfDocument) {
  10881. this._cancelRendering();
  10882. this._resetView();
  10883. }
  10884. this.pdfDocument = pdfDocument;
  10885. if (!pdfDocument) {
  10886. return;
  10887. }
  10888. var firstPagePromise = pdfDocument.getPage(1);
  10889. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  10890. firstPagePromise.then(function (firstPdfPage) {
  10891. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  10892. var pagesCount = pdfDocument.numPages;
  10893. var viewport = firstPdfPage.getViewport({
  10894. scale: 1
  10895. });
  10896. var checkSetImageDisabled = function checkSetImageDisabled() {
  10897. return _this2._setImageDisabled;
  10898. };
  10899. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  10900. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  10901. container: _this2.container,
  10902. id: pageNum,
  10903. defaultViewport: viewport.clone(),
  10904. optionalContentConfigPromise: optionalContentConfigPromise,
  10905. linkService: _this2.linkService,
  10906. renderingQueue: _this2.renderingQueue,
  10907. checkSetImageDisabled: checkSetImageDisabled,
  10908. l10n: _this2.l10n
  10909. });
  10910. _this2._thumbnails.push(thumbnail);
  10911. }
  10912. var firstThumbnailView = _this2._thumbnails[0];
  10913. if (firstThumbnailView) {
  10914. firstThumbnailView.setPdfPage(firstPdfPage);
  10915. }
  10916. var thumbnailView = _this2._thumbnails[_this2._currentPageNumber - 1];
  10917. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  10918. })["catch"](function (reason) {
  10919. console.error("Unable to initialize thumbnail viewer", reason);
  10920. });
  10921. }
  10922. }, {
  10923. key: "_cancelRendering",
  10924. value: function _cancelRendering() {
  10925. var _iterator4 = _createForOfIteratorHelper(this._thumbnails),
  10926. _step4;
  10927. try {
  10928. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  10929. var thumbnail = _step4.value;
  10930. thumbnail.cancelRendering();
  10931. }
  10932. } catch (err) {
  10933. _iterator4.e(err);
  10934. } finally {
  10935. _iterator4.f();
  10936. }
  10937. }
  10938. }, {
  10939. key: "setPageLabels",
  10940. value: function setPageLabels(labels) {
  10941. if (!this.pdfDocument) {
  10942. return;
  10943. }
  10944. if (!labels) {
  10945. this._pageLabels = null;
  10946. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  10947. this._pageLabels = null;
  10948. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  10949. } else {
  10950. this._pageLabels = labels;
  10951. }
  10952. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  10953. var _this$_pageLabels$i, _this$_pageLabels;
  10954. 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);
  10955. }
  10956. }
  10957. }, {
  10958. key: "forceRendering",
  10959. value: function forceRendering() {
  10960. var _this3 = this;
  10961. var visibleThumbs = this._getVisibleThumbs();
  10962. var scrollAhead = _classPrivateMethodGet(this, _getScrollAhead, _getScrollAhead2).call(this, visibleThumbs);
  10963. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, scrollAhead);
  10964. if (thumbView) {
  10965. _classPrivateMethodGet(this, _ensurePdfPageLoaded, _ensurePdfPageLoaded2).call(this, thumbView).then(function () {
  10966. _this3.renderingQueue.renderView(thumbView);
  10967. });
  10968. return true;
  10969. }
  10970. return false;
  10971. }
  10972. }]);
  10973. return PDFThumbnailViewer;
  10974. }();
  10975. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  10976. function _ensurePdfPageLoaded2(_x) {
  10977. return _ensurePdfPageLoaded3.apply(this, arguments);
  10978. }
  10979. function _ensurePdfPageLoaded3() {
  10980. _ensurePdfPageLoaded3 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(thumbView) {
  10981. var pdfPage;
  10982. return _regenerator["default"].wrap(function _callee$(_context) {
  10983. while (1) {
  10984. switch (_context.prev = _context.next) {
  10985. case 0:
  10986. if (!thumbView.pdfPage) {
  10987. _context.next = 2;
  10988. break;
  10989. }
  10990. return _context.abrupt("return", thumbView.pdfPage);
  10991. case 2:
  10992. _context.prev = 2;
  10993. _context.next = 5;
  10994. return this.pdfDocument.getPage(thumbView.id);
  10995. case 5:
  10996. pdfPage = _context.sent;
  10997. if (!thumbView.pdfPage) {
  10998. thumbView.setPdfPage(pdfPage);
  10999. }
  11000. return _context.abrupt("return", pdfPage);
  11001. case 10:
  11002. _context.prev = 10;
  11003. _context.t0 = _context["catch"](2);
  11004. console.error("Unable to get page for thumb view", _context.t0);
  11005. return _context.abrupt("return", null);
  11006. case 14:
  11007. case "end":
  11008. return _context.stop();
  11009. }
  11010. }
  11011. }, _callee, this, [[2, 10]]);
  11012. }));
  11013. return _ensurePdfPageLoaded3.apply(this, arguments);
  11014. }
  11015. function _getScrollAhead2(visible) {
  11016. var _visible$first, _visible$last;
  11017. if (((_visible$first = visible.first) === null || _visible$first === void 0 ? void 0 : _visible$first.id) === 1) {
  11018. return true;
  11019. } else if (((_visible$last = visible.last) === null || _visible$last === void 0 ? void 0 : _visible$last.id) === this._thumbnails.length) {
  11020. return false;
  11021. }
  11022. return this.scroll.down;
  11023. }
  11024. /***/ }),
  11025. /* 29 */
  11026. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11027. Object.defineProperty(exports, "__esModule", ({
  11028. value: true
  11029. }));
  11030. exports.TempImageFactory = exports.PDFThumbnailView = void 0;
  11031. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  11032. var _ui_utils = __webpack_require__(5);
  11033. var _pdfjsLib = __webpack_require__(7);
  11034. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11035. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  11036. 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."); }
  11037. 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); }
  11038. 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; }
  11039. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
  11040. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  11041. 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); } }
  11042. 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); }); }; }
  11043. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11044. 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); } }
  11045. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  11046. function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { _classCheckPrivateStaticAccess(receiver, classConstructor); _classCheckPrivateStaticFieldDescriptor(descriptor, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  11047. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  11048. function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { _classCheckPrivateStaticAccess(receiver, classConstructor); _classCheckPrivateStaticFieldDescriptor(descriptor, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  11049. function _classCheckPrivateStaticFieldDescriptor(descriptor, action) { if (descriptor === undefined) { throw new TypeError("attempted to " + action + " private static field before its declaration"); } }
  11050. function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } }
  11051. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  11052. var DRAW_UPSCALE_FACTOR = 2;
  11053. var MAX_NUM_SCALING_STEPS = 3;
  11054. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  11055. var THUMBNAIL_WIDTH = 98;
  11056. var TempImageFactory = /*#__PURE__*/function () {
  11057. function TempImageFactory() {
  11058. _classCallCheck(this, TempImageFactory);
  11059. }
  11060. _createClass(TempImageFactory, null, [{
  11061. key: "getCanvas",
  11062. value: function getCanvas(width, height) {
  11063. var tempCanvas = _classStaticPrivateFieldSpecGet(this, TempImageFactory, _tempCanvas) || _classStaticPrivateFieldSpecSet(this, TempImageFactory, _tempCanvas, document.createElement("canvas"));
  11064. tempCanvas.width = width;
  11065. tempCanvas.height = height;
  11066. var ctx = tempCanvas.getContext("2d", {
  11067. alpha: false
  11068. });
  11069. ctx.save();
  11070. ctx.fillStyle = "rgb(255, 255, 255)";
  11071. ctx.fillRect(0, 0, width, height);
  11072. ctx.restore();
  11073. return [tempCanvas, tempCanvas.getContext("2d")];
  11074. }
  11075. }, {
  11076. key: "destroyCanvas",
  11077. value: function destroyCanvas() {
  11078. var tempCanvas = _classStaticPrivateFieldSpecGet(this, TempImageFactory, _tempCanvas);
  11079. if (tempCanvas) {
  11080. tempCanvas.width = 0;
  11081. tempCanvas.height = 0;
  11082. }
  11083. _classStaticPrivateFieldSpecSet(this, TempImageFactory, _tempCanvas, null);
  11084. }
  11085. }]);
  11086. return TempImageFactory;
  11087. }();
  11088. exports.TempImageFactory = TempImageFactory;
  11089. var _tempCanvas = {
  11090. writable: true,
  11091. value: null
  11092. };
  11093. var PDFThumbnailView = /*#__PURE__*/function () {
  11094. function PDFThumbnailView(_ref) {
  11095. var container = _ref.container,
  11096. id = _ref.id,
  11097. defaultViewport = _ref.defaultViewport,
  11098. optionalContentConfigPromise = _ref.optionalContentConfigPromise,
  11099. linkService = _ref.linkService,
  11100. renderingQueue = _ref.renderingQueue,
  11101. checkSetImageDisabled = _ref.checkSetImageDisabled,
  11102. l10n = _ref.l10n;
  11103. _classCallCheck(this, PDFThumbnailView);
  11104. this.id = id;
  11105. this.renderingId = "thumbnail" + id;
  11106. this.pageLabel = null;
  11107. this.pdfPage = null;
  11108. this.rotation = 0;
  11109. this.viewport = defaultViewport;
  11110. this.pdfPageRotate = defaultViewport.rotation;
  11111. this._optionalContentConfigPromise = optionalContentConfigPromise || null;
  11112. this.linkService = linkService;
  11113. this.renderingQueue = renderingQueue;
  11114. this.renderTask = null;
  11115. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  11116. this.resume = null;
  11117. this._checkSetImageDisabled = checkSetImageDisabled || function () {
  11118. return false;
  11119. };
  11120. var pageWidth = this.viewport.width,
  11121. pageHeight = this.viewport.height,
  11122. pageRatio = pageWidth / pageHeight;
  11123. this.canvasWidth = THUMBNAIL_WIDTH;
  11124. this.canvasHeight = this.canvasWidth / pageRatio | 0;
  11125. this.scale = this.canvasWidth / pageWidth;
  11126. this.l10n = l10n;
  11127. var anchor = document.createElement("a");
  11128. anchor.href = linkService.getAnchorUrl("#page=" + id);
  11129. this._thumbPageTitle.then(function (msg) {
  11130. anchor.title = msg;
  11131. });
  11132. anchor.onclick = function () {
  11133. linkService.goToPage(id);
  11134. return false;
  11135. };
  11136. this.anchor = anchor;
  11137. var div = document.createElement("div");
  11138. div.className = "thumbnail";
  11139. div.setAttribute("data-page-number", this.id);
  11140. this.div = div;
  11141. var ring = document.createElement("div");
  11142. ring.className = "thumbnailSelectionRing";
  11143. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  11144. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  11145. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  11146. this.ring = ring;
  11147. div.appendChild(ring);
  11148. anchor.appendChild(div);
  11149. container.appendChild(anchor);
  11150. }
  11151. _createClass(PDFThumbnailView, [{
  11152. key: "setPdfPage",
  11153. value: function setPdfPage(pdfPage) {
  11154. this.pdfPage = pdfPage;
  11155. this.pdfPageRotate = pdfPage.rotate;
  11156. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  11157. this.viewport = pdfPage.getViewport({
  11158. scale: 1,
  11159. rotation: totalRotation
  11160. });
  11161. this.reset();
  11162. }
  11163. }, {
  11164. key: "reset",
  11165. value: function reset() {
  11166. this.cancelRendering();
  11167. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  11168. var pageWidth = this.viewport.width,
  11169. pageHeight = this.viewport.height,
  11170. pageRatio = pageWidth / pageHeight;
  11171. this.canvasHeight = this.canvasWidth / pageRatio | 0;
  11172. this.scale = this.canvasWidth / pageWidth;
  11173. this.div.removeAttribute("data-loaded");
  11174. var ring = this.ring;
  11175. ring.textContent = "";
  11176. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  11177. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  11178. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  11179. if (this.canvas) {
  11180. this.canvas.width = 0;
  11181. this.canvas.height = 0;
  11182. delete this.canvas;
  11183. }
  11184. if (this.image) {
  11185. this.image.removeAttribute("src");
  11186. delete this.image;
  11187. }
  11188. }
  11189. }, {
  11190. key: "update",
  11191. value: function update(_ref2) {
  11192. var _ref2$rotation = _ref2.rotation,
  11193. rotation = _ref2$rotation === void 0 ? null : _ref2$rotation;
  11194. if (typeof rotation === "number") {
  11195. this.rotation = rotation;
  11196. }
  11197. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  11198. this.viewport = this.viewport.clone({
  11199. scale: 1,
  11200. rotation: totalRotation
  11201. });
  11202. this.reset();
  11203. }
  11204. }, {
  11205. key: "cancelRendering",
  11206. value: function cancelRendering() {
  11207. if (this.renderTask) {
  11208. this.renderTask.cancel();
  11209. this.renderTask = null;
  11210. }
  11211. this.resume = null;
  11212. }
  11213. }, {
  11214. key: "_getPageDrawContext",
  11215. value: function _getPageDrawContext() {
  11216. var upscaleFactor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  11217. var canvas = document.createElement("canvas");
  11218. var ctx = canvas.getContext("2d", {
  11219. alpha: false
  11220. });
  11221. var outputScale = new _ui_utils.OutputScale();
  11222. canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0;
  11223. canvas.height = upscaleFactor * this.canvasHeight * outputScale.sy | 0;
  11224. var transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  11225. return {
  11226. ctx: ctx,
  11227. canvas: canvas,
  11228. transform: transform
  11229. };
  11230. }
  11231. }, {
  11232. key: "_convertCanvasToImage",
  11233. value: function _convertCanvasToImage(canvas) {
  11234. if (this.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  11235. throw new Error("_convertCanvasToImage: Rendering has not finished.");
  11236. }
  11237. var reducedCanvas = this._reduceImage(canvas);
  11238. var image = document.createElement("img");
  11239. image.className = "thumbnailImage";
  11240. this._thumbPageCanvas.then(function (msg) {
  11241. image.setAttribute("aria-label", msg);
  11242. });
  11243. image.style.width = this.canvasWidth + "px";
  11244. image.style.height = this.canvasHeight + "px";
  11245. image.src = reducedCanvas.toDataURL();
  11246. this.image = image;
  11247. this.div.setAttribute("data-loaded", true);
  11248. this.ring.appendChild(image);
  11249. reducedCanvas.width = 0;
  11250. reducedCanvas.height = 0;
  11251. }
  11252. }, {
  11253. key: "draw",
  11254. value: function draw() {
  11255. var _this = this;
  11256. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  11257. console.error("Must be in new state before drawing");
  11258. return Promise.resolve();
  11259. }
  11260. var pdfPage = this.pdfPage;
  11261. if (!pdfPage) {
  11262. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  11263. return Promise.reject(new Error("pdfPage is not loaded"));
  11264. }
  11265. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  11266. var finishRenderTask = /*#__PURE__*/function () {
  11267. var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  11268. var error,
  11269. _args = arguments;
  11270. return _regenerator["default"].wrap(function _callee$(_context) {
  11271. while (1) {
  11272. switch (_context.prev = _context.next) {
  11273. case 0:
  11274. error = _args.length > 0 && _args[0] !== undefined ? _args[0] : null;
  11275. if (renderTask === _this.renderTask) {
  11276. _this.renderTask = null;
  11277. }
  11278. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  11279. _context.next = 4;
  11280. break;
  11281. }
  11282. return _context.abrupt("return");
  11283. case 4:
  11284. _this.renderingState = _ui_utils.RenderingStates.FINISHED;
  11285. _this._convertCanvasToImage(canvas);
  11286. if (!error) {
  11287. _context.next = 8;
  11288. break;
  11289. }
  11290. throw error;
  11291. case 8:
  11292. case "end":
  11293. return _context.stop();
  11294. }
  11295. }
  11296. }, _callee);
  11297. }));
  11298. return function finishRenderTask() {
  11299. return _ref3.apply(this, arguments);
  11300. };
  11301. }();
  11302. var _this$_getPageDrawCon = this._getPageDrawContext(DRAW_UPSCALE_FACTOR),
  11303. ctx = _this$_getPageDrawCon.ctx,
  11304. canvas = _this$_getPageDrawCon.canvas,
  11305. transform = _this$_getPageDrawCon.transform;
  11306. var drawViewport = this.viewport.clone({
  11307. scale: DRAW_UPSCALE_FACTOR * this.scale
  11308. });
  11309. var renderContinueCallback = function renderContinueCallback(cont) {
  11310. if (!_this.renderingQueue.isHighestPriority(_this)) {
  11311. _this.renderingState = _ui_utils.RenderingStates.PAUSED;
  11312. _this.resume = function () {
  11313. _this.renderingState = _ui_utils.RenderingStates.RUNNING;
  11314. cont();
  11315. };
  11316. return;
  11317. }
  11318. cont();
  11319. };
  11320. var renderContext = {
  11321. canvasContext: ctx,
  11322. transform: transform,
  11323. viewport: drawViewport,
  11324. optionalContentConfigPromise: this._optionalContentConfigPromise
  11325. };
  11326. var renderTask = this.renderTask = pdfPage.render(renderContext);
  11327. renderTask.onContinue = renderContinueCallback;
  11328. var resultPromise = renderTask.promise.then(function () {
  11329. return finishRenderTask(null);
  11330. }, function (error) {
  11331. return finishRenderTask(error);
  11332. });
  11333. resultPromise["finally"](function () {
  11334. canvas.width = 0;
  11335. canvas.height = 0;
  11336. var pageCached = _this.linkService.isPageCached(_this.id);
  11337. if (!pageCached) {
  11338. var _this$pdfPage;
  11339. (_this$pdfPage = _this.pdfPage) === null || _this$pdfPage === void 0 ? void 0 : _this$pdfPage.cleanup();
  11340. }
  11341. });
  11342. return resultPromise;
  11343. }
  11344. }, {
  11345. key: "setImage",
  11346. value: function setImage(pageView) {
  11347. if (this._checkSetImageDisabled()) {
  11348. return;
  11349. }
  11350. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  11351. return;
  11352. }
  11353. var canvas = pageView.canvas,
  11354. pdfPage = pageView.pdfPage;
  11355. if (!canvas) {
  11356. return;
  11357. }
  11358. if (!this.pdfPage) {
  11359. this.setPdfPage(pdfPage);
  11360. }
  11361. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  11362. this._convertCanvasToImage(canvas);
  11363. }
  11364. }, {
  11365. key: "_reduceImage",
  11366. value: function _reduceImage(img) {
  11367. var _this$_getPageDrawCon2 = this._getPageDrawContext(),
  11368. ctx = _this$_getPageDrawCon2.ctx,
  11369. canvas = _this$_getPageDrawCon2.canvas;
  11370. if (img.width <= 2 * canvas.width) {
  11371. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  11372. return canvas;
  11373. }
  11374. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  11375. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  11376. var _TempImageFactory$get = TempImageFactory.getCanvas(reducedWidth, reducedHeight),
  11377. _TempImageFactory$get2 = _slicedToArray(_TempImageFactory$get, 2),
  11378. reducedImage = _TempImageFactory$get2[0],
  11379. reducedImageCtx = _TempImageFactory$get2[1];
  11380. while (reducedWidth > img.width || reducedHeight > img.height) {
  11381. reducedWidth >>= 1;
  11382. reducedHeight >>= 1;
  11383. }
  11384. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  11385. while (reducedWidth > 2 * canvas.width) {
  11386. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  11387. reducedWidth >>= 1;
  11388. reducedHeight >>= 1;
  11389. }
  11390. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  11391. return canvas;
  11392. }
  11393. }, {
  11394. key: "_thumbPageTitle",
  11395. get: function get() {
  11396. var _this$pageLabel;
  11397. return this.l10n.get("thumb_page_title", {
  11398. page: (_this$pageLabel = this.pageLabel) !== null && _this$pageLabel !== void 0 ? _this$pageLabel : this.id
  11399. });
  11400. }
  11401. }, {
  11402. key: "_thumbPageCanvas",
  11403. get: function get() {
  11404. var _this$pageLabel2;
  11405. return this.l10n.get("thumb_page_canvas", {
  11406. page: (_this$pageLabel2 = this.pageLabel) !== null && _this$pageLabel2 !== void 0 ? _this$pageLabel2 : this.id
  11407. });
  11408. }
  11409. }, {
  11410. key: "setPageLabel",
  11411. value: function setPageLabel(label) {
  11412. var _this2 = this;
  11413. this.pageLabel = typeof label === "string" ? label : null;
  11414. this._thumbPageTitle.then(function (msg) {
  11415. _this2.anchor.title = msg;
  11416. });
  11417. if (this.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  11418. return;
  11419. }
  11420. this._thumbPageCanvas.then(function (msg) {
  11421. var _this2$image;
  11422. (_this2$image = _this2.image) === null || _this2$image === void 0 ? void 0 : _this2$image.setAttribute("aria-label", msg);
  11423. });
  11424. }
  11425. }]);
  11426. return PDFThumbnailView;
  11427. }();
  11428. exports.PDFThumbnailView = PDFThumbnailView;
  11429. /***/ }),
  11430. /* 30 */
  11431. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11432. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  11433. Object.defineProperty(exports, "__esModule", ({
  11434. value: true
  11435. }));
  11436. exports.PDFViewer = exports.PDFSinglePageViewer = void 0;
  11437. var _ui_utils = __webpack_require__(5);
  11438. var _base_viewer = __webpack_require__(31);
  11439. function _get() { 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(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
  11440. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  11441. 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); } }
  11442. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  11443. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11444. 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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
  11445. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11446. 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); }; }
  11447. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  11448. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11449. 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; } }
  11450. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11451. var PDFViewer = /*#__PURE__*/function (_BaseViewer) {
  11452. _inherits(PDFViewer, _BaseViewer);
  11453. var _super = _createSuper(PDFViewer);
  11454. function PDFViewer() {
  11455. _classCallCheck(this, PDFViewer);
  11456. return _super.apply(this, arguments);
  11457. }
  11458. return _createClass(PDFViewer);
  11459. }(_base_viewer.BaseViewer);
  11460. exports.PDFViewer = PDFViewer;
  11461. var PDFSinglePageViewer = /*#__PURE__*/function (_BaseViewer2) {
  11462. _inherits(PDFSinglePageViewer, _BaseViewer2);
  11463. var _super2 = _createSuper(PDFSinglePageViewer);
  11464. function PDFSinglePageViewer() {
  11465. _classCallCheck(this, PDFSinglePageViewer);
  11466. return _super2.apply(this, arguments);
  11467. }
  11468. _createClass(PDFSinglePageViewer, [{
  11469. key: "_resetView",
  11470. value: function _resetView() {
  11471. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  11472. this._scrollMode = _ui_utils.ScrollMode.PAGE;
  11473. this._spreadMode = _ui_utils.SpreadMode.NONE;
  11474. }
  11475. }, {
  11476. key: "scrollMode",
  11477. set: function set(mode) {}
  11478. }, {
  11479. key: "_updateScrollMode",
  11480. value: function _updateScrollMode() {}
  11481. }, {
  11482. key: "spreadMode",
  11483. set: function set(mode) {}
  11484. }, {
  11485. key: "_updateSpreadMode",
  11486. value: function _updateSpreadMode() {}
  11487. }]);
  11488. return PDFSinglePageViewer;
  11489. }(_base_viewer.BaseViewer);
  11490. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  11491. /***/ }),
  11492. /* 31 */
  11493. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11494. Object.defineProperty(exports, "__esModule", ({
  11495. value: true
  11496. }));
  11497. exports.PagesCountLimit = exports.PDFPageViewBuffer = exports.BaseViewer = void 0;
  11498. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  11499. var _pdfjsLib = __webpack_require__(7);
  11500. var _ui_utils = __webpack_require__(5);
  11501. var _annotation_layer_builder = __webpack_require__(32);
  11502. var _l10n_utils = __webpack_require__(33);
  11503. var _pdf_page_view = __webpack_require__(34);
  11504. var _pdf_rendering_queue = __webpack_require__(24);
  11505. var _pdf_link_service = __webpack_require__(10);
  11506. var _struct_tree_layer_builder = __webpack_require__(35);
  11507. var _text_highlighter = __webpack_require__(36);
  11508. var _text_layer_builder = __webpack_require__(37);
  11509. var _xfa_layer_builder = __webpack_require__(38);
  11510. var _Symbol$iterator;
  11511. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11512. 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); } }
  11513. 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); }); }; }
  11514. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  11515. 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."); }
  11516. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
  11517. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  11518. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
  11519. 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); }
  11520. 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; }
  11521. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11522. 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); } }
  11523. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  11524. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  11525. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  11526. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  11527. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  11528. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  11529. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  11530. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  11531. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  11532. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  11533. var DEFAULT_CACHE_SIZE = 10;
  11534. var ENABLE_PERMISSIONS_CLASS = "enablePermissions";
  11535. var PagesCountLimit = {
  11536. FORCE_SCROLL_MODE_PAGE: 15000,
  11537. FORCE_LAZY_PAGE_INIT: 7500,
  11538. PAUSE_EAGER_PAGE_INIT: 250
  11539. };
  11540. exports.PagesCountLimit = PagesCountLimit;
  11541. var _buf = /*#__PURE__*/new WeakMap();
  11542. var _size = /*#__PURE__*/new WeakMap();
  11543. var _destroyFirstView = /*#__PURE__*/new WeakSet();
  11544. _Symbol$iterator = Symbol.iterator;
  11545. var PDFPageViewBuffer = /*#__PURE__*/function () {
  11546. function PDFPageViewBuffer(size) {
  11547. _classCallCheck(this, PDFPageViewBuffer);
  11548. _classPrivateMethodInitSpec(this, _destroyFirstView);
  11549. _classPrivateFieldInitSpec(this, _buf, {
  11550. writable: true,
  11551. value: new Set()
  11552. });
  11553. _classPrivateFieldInitSpec(this, _size, {
  11554. writable: true,
  11555. value: 0
  11556. });
  11557. _classPrivateFieldSet(this, _size, size);
  11558. }
  11559. _createClass(PDFPageViewBuffer, [{
  11560. key: "push",
  11561. value: function push(view) {
  11562. var buf = _classPrivateFieldGet(this, _buf);
  11563. if (buf.has(view)) {
  11564. buf["delete"](view);
  11565. }
  11566. buf.add(view);
  11567. if (buf.size > _classPrivateFieldGet(this, _size)) {
  11568. _classPrivateMethodGet(this, _destroyFirstView, _destroyFirstView2).call(this);
  11569. }
  11570. }
  11571. }, {
  11572. key: "resize",
  11573. value: function resize(newSize) {
  11574. var idsToKeep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  11575. _classPrivateFieldSet(this, _size, newSize);
  11576. var buf = _classPrivateFieldGet(this, _buf);
  11577. if (idsToKeep) {
  11578. var ii = buf.size;
  11579. var i = 1;
  11580. var _iterator = _createForOfIteratorHelper(buf),
  11581. _step;
  11582. try {
  11583. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11584. var view = _step.value;
  11585. if (idsToKeep.has(view.id)) {
  11586. buf["delete"](view);
  11587. buf.add(view);
  11588. }
  11589. if (++i > ii) {
  11590. break;
  11591. }
  11592. }
  11593. } catch (err) {
  11594. _iterator.e(err);
  11595. } finally {
  11596. _iterator.f();
  11597. }
  11598. }
  11599. while (buf.size > _classPrivateFieldGet(this, _size)) {
  11600. _classPrivateMethodGet(this, _destroyFirstView, _destroyFirstView2).call(this);
  11601. }
  11602. }
  11603. }, {
  11604. key: "has",
  11605. value: function has(view) {
  11606. return _classPrivateFieldGet(this, _buf).has(view);
  11607. }
  11608. }, {
  11609. key: _Symbol$iterator,
  11610. value: function value() {
  11611. return _classPrivateFieldGet(this, _buf).keys();
  11612. }
  11613. }]);
  11614. return PDFPageViewBuffer;
  11615. }();
  11616. exports.PDFPageViewBuffer = PDFPageViewBuffer;
  11617. function _destroyFirstView2() {
  11618. var firstView = _classPrivateFieldGet(this, _buf).keys().next().value;
  11619. firstView === null || firstView === void 0 ? void 0 : firstView.destroy();
  11620. _classPrivateFieldGet(this, _buf)["delete"](firstView);
  11621. }
  11622. var _buffer = /*#__PURE__*/new WeakMap();
  11623. var _annotationMode = /*#__PURE__*/new WeakMap();
  11624. var _previousAnnotationMode = /*#__PURE__*/new WeakMap();
  11625. var _enablePermissions = /*#__PURE__*/new WeakMap();
  11626. var _previousContainerHeight = /*#__PURE__*/new WeakMap();
  11627. var _scrollModePageState = /*#__PURE__*/new WeakMap();
  11628. var _onVisibilityChange = /*#__PURE__*/new WeakMap();
  11629. var _initializePermissions = /*#__PURE__*/new WeakSet();
  11630. var _onePageRenderedOrForceFetch = /*#__PURE__*/new WeakSet();
  11631. var _ensurePageViewVisible = /*#__PURE__*/new WeakSet();
  11632. var _scrollIntoView = /*#__PURE__*/new WeakSet();
  11633. var _isSameScale = /*#__PURE__*/new WeakSet();
  11634. var _resetCurrentPageView = /*#__PURE__*/new WeakSet();
  11635. var _ensurePdfPageLoaded = /*#__PURE__*/new WeakSet();
  11636. var _getScrollAhead = /*#__PURE__*/new WeakSet();
  11637. var _toggleLoadingIconSpinner = /*#__PURE__*/new WeakSet();
  11638. var BaseViewer = /*#__PURE__*/function () {
  11639. function BaseViewer(options) {
  11640. var _this$container,
  11641. _this$viewer,
  11642. _options$textLayerMod,
  11643. _options$annotationMo,
  11644. _this = this;
  11645. _classCallCheck(this, BaseViewer);
  11646. _classPrivateMethodInitSpec(this, _toggleLoadingIconSpinner);
  11647. _classPrivateMethodInitSpec(this, _getScrollAhead);
  11648. _classPrivateMethodInitSpec(this, _ensurePdfPageLoaded);
  11649. _classPrivateMethodInitSpec(this, _resetCurrentPageView);
  11650. _classPrivateMethodInitSpec(this, _isSameScale);
  11651. _classPrivateMethodInitSpec(this, _scrollIntoView);
  11652. _classPrivateMethodInitSpec(this, _ensurePageViewVisible);
  11653. _classPrivateMethodInitSpec(this, _onePageRenderedOrForceFetch);
  11654. _classPrivateMethodInitSpec(this, _initializePermissions);
  11655. _classPrivateFieldInitSpec(this, _buffer, {
  11656. writable: true,
  11657. value: null
  11658. });
  11659. _classPrivateFieldInitSpec(this, _annotationMode, {
  11660. writable: true,
  11661. value: _pdfjsLib.AnnotationMode.ENABLE_FORMS
  11662. });
  11663. _classPrivateFieldInitSpec(this, _previousAnnotationMode, {
  11664. writable: true,
  11665. value: null
  11666. });
  11667. _classPrivateFieldInitSpec(this, _enablePermissions, {
  11668. writable: true,
  11669. value: false
  11670. });
  11671. _classPrivateFieldInitSpec(this, _previousContainerHeight, {
  11672. writable: true,
  11673. value: 0
  11674. });
  11675. _classPrivateFieldInitSpec(this, _scrollModePageState, {
  11676. writable: true,
  11677. value: null
  11678. });
  11679. _classPrivateFieldInitSpec(this, _onVisibilityChange, {
  11680. writable: true,
  11681. value: null
  11682. });
  11683. if (this.constructor === BaseViewer) {
  11684. throw new Error("Cannot initialize BaseViewer.");
  11685. }
  11686. var viewerVersion = '2.14.305';
  11687. if (_pdfjsLib.version !== viewerVersion) {
  11688. throw new Error("The API version \"".concat(_pdfjsLib.version, "\" does not match the Viewer version \"").concat(viewerVersion, "\"."));
  11689. }
  11690. this.container = options.container;
  11691. this.viewer = options.viewer || options.container.firstElementChild;
  11692. 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")) {
  11693. throw new Error("Invalid `container` and/or `viewer` option.");
  11694. }
  11695. if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") {
  11696. throw new Error("The `container` must be absolutely positioned.");
  11697. }
  11698. this.eventBus = options.eventBus;
  11699. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  11700. this.downloadManager = options.downloadManager || null;
  11701. this.findController = options.findController || null;
  11702. this._scriptingManager = options.scriptingManager || null;
  11703. this.removePageBorders = options.removePageBorders || false;
  11704. this.textLayerMode = (_options$textLayerMod = options.textLayerMode) !== null && _options$textLayerMod !== void 0 ? _options$textLayerMod : _ui_utils.TextLayerMode.ENABLE;
  11705. _classPrivateFieldSet(this, _annotationMode, (_options$annotationMo = options.annotationMode) !== null && _options$annotationMo !== void 0 ? _options$annotationMo : _pdfjsLib.AnnotationMode.ENABLE_FORMS);
  11706. this.imageResourcesPath = options.imageResourcesPath || "";
  11707. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  11708. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  11709. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  11710. this.maxCanvasPixels = options.maxCanvasPixels;
  11711. this.l10n = options.l10n || _l10n_utils.NullL10n;
  11712. _classPrivateFieldSet(this, _enablePermissions, options.enablePermissions || false);
  11713. this.pageColors = options.pageColors || null;
  11714. if (options.pageColors && (!CSS.supports("color", options.pageColors.background) || !CSS.supports("color", options.pageColors.foreground))) {
  11715. if (options.pageColors.background || options.pageColors.foreground) {
  11716. console.warn("Ignoring `pageColors`-option, since the browser doesn't support the values used.");
  11717. }
  11718. this.pageColors = null;
  11719. }
  11720. this.defaultRenderingQueue = !options.renderingQueue;
  11721. if (this.defaultRenderingQueue) {
  11722. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  11723. this.renderingQueue.setViewer(this);
  11724. } else {
  11725. this.renderingQueue = options.renderingQueue;
  11726. }
  11727. this._doc = document.documentElement;
  11728. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  11729. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  11730. this._onBeforeDraw = this._onAfterDraw = null;
  11731. this._resetView();
  11732. if (this.removePageBorders) {
  11733. this.viewer.classList.add("removePageBorders");
  11734. }
  11735. this.updateContainerHeightCss();
  11736. Promise.resolve().then(function () {
  11737. _this.eventBus.dispatch("baseviewerinit", {
  11738. source: _this
  11739. });
  11740. });
  11741. }
  11742. _createClass(BaseViewer, [{
  11743. key: "pagesCount",
  11744. get: function get() {
  11745. return this._pages.length;
  11746. }
  11747. }, {
  11748. key: "getPageView",
  11749. value: function getPageView(index) {
  11750. return this._pages[index];
  11751. }
  11752. }, {
  11753. key: "pageViewsReady",
  11754. get: function get() {
  11755. if (!this._pagesCapability.settled) {
  11756. return false;
  11757. }
  11758. return this._pages.every(function (pageView) {
  11759. return pageView === null || pageView === void 0 ? void 0 : pageView.pdfPage;
  11760. });
  11761. }
  11762. }, {
  11763. key: "renderForms",
  11764. get: function get() {
  11765. return _classPrivateFieldGet(this, _annotationMode) === _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  11766. }
  11767. }, {
  11768. key: "enableScripting",
  11769. get: function get() {
  11770. return !!this._scriptingManager;
  11771. }
  11772. }, {
  11773. key: "currentPageNumber",
  11774. get: function get() {
  11775. return this._currentPageNumber;
  11776. },
  11777. set: function set(val) {
  11778. if (!Number.isInteger(val)) {
  11779. throw new Error("Invalid page number.");
  11780. }
  11781. if (!this.pdfDocument) {
  11782. return;
  11783. }
  11784. if (!this._setCurrentPageNumber(val, true)) {
  11785. console.error("currentPageNumber: \"".concat(val, "\" is not a valid page."));
  11786. }
  11787. }
  11788. }, {
  11789. key: "_setCurrentPageNumber",
  11790. value: function _setCurrentPageNumber(val) {
  11791. var _this$_pageLabels, _this$_pageLabels2;
  11792. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  11793. if (this._currentPageNumber === val) {
  11794. if (resetCurrentPageView) {
  11795. _classPrivateMethodGet(this, _resetCurrentPageView, _resetCurrentPageView2).call(this);
  11796. }
  11797. return true;
  11798. }
  11799. if (!(0 < val && val <= this.pagesCount)) {
  11800. return false;
  11801. }
  11802. var previous = this._currentPageNumber;
  11803. this._currentPageNumber = val;
  11804. this.eventBus.dispatch("pagechanging", {
  11805. source: this,
  11806. pageNumber: val,
  11807. 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,
  11808. previous: previous
  11809. });
  11810. if (resetCurrentPageView) {
  11811. _classPrivateMethodGet(this, _resetCurrentPageView, _resetCurrentPageView2).call(this);
  11812. }
  11813. return true;
  11814. }
  11815. }, {
  11816. key: "currentPageLabel",
  11817. get: function get() {
  11818. var _this$_pageLabels3, _this$_pageLabels4;
  11819. 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;
  11820. },
  11821. set: function set(val) {
  11822. if (!this.pdfDocument) {
  11823. return;
  11824. }
  11825. var page = val | 0;
  11826. if (this._pageLabels) {
  11827. var i = this._pageLabels.indexOf(val);
  11828. if (i >= 0) {
  11829. page = i + 1;
  11830. }
  11831. }
  11832. if (!this._setCurrentPageNumber(page, true)) {
  11833. console.error("currentPageLabel: \"".concat(val, "\" is not a valid page."));
  11834. }
  11835. }
  11836. }, {
  11837. key: "currentScale",
  11838. get: function get() {
  11839. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  11840. },
  11841. set: function set(val) {
  11842. if (isNaN(val)) {
  11843. throw new Error("Invalid numeric scale.");
  11844. }
  11845. if (!this.pdfDocument) {
  11846. return;
  11847. }
  11848. this._setScale(val, false);
  11849. }
  11850. }, {
  11851. key: "currentScaleValue",
  11852. get: function get() {
  11853. return this._currentScaleValue;
  11854. },
  11855. set: function set(val) {
  11856. if (!this.pdfDocument) {
  11857. return;
  11858. }
  11859. this._setScale(val, false);
  11860. }
  11861. }, {
  11862. key: "pagesRotation",
  11863. get: function get() {
  11864. return this._pagesRotation;
  11865. },
  11866. set: function set(rotation) {
  11867. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  11868. throw new Error("Invalid pages rotation angle.");
  11869. }
  11870. if (!this.pdfDocument) {
  11871. return;
  11872. }
  11873. rotation %= 360;
  11874. if (rotation < 0) {
  11875. rotation += 360;
  11876. }
  11877. if (this._pagesRotation === rotation) {
  11878. return;
  11879. }
  11880. this._pagesRotation = rotation;
  11881. var pageNumber = this._currentPageNumber;
  11882. var updateArgs = {
  11883. rotation: rotation
  11884. };
  11885. var _iterator2 = _createForOfIteratorHelper(this._pages),
  11886. _step2;
  11887. try {
  11888. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  11889. var pageView = _step2.value;
  11890. pageView.update(updateArgs);
  11891. }
  11892. } catch (err) {
  11893. _iterator2.e(err);
  11894. } finally {
  11895. _iterator2.f();
  11896. }
  11897. if (this._currentScaleValue) {
  11898. this._setScale(this._currentScaleValue, true);
  11899. }
  11900. this.eventBus.dispatch("rotationchanging", {
  11901. source: this,
  11902. pagesRotation: rotation,
  11903. pageNumber: pageNumber
  11904. });
  11905. if (this.defaultRenderingQueue) {
  11906. this.update();
  11907. }
  11908. }
  11909. }, {
  11910. key: "firstPagePromise",
  11911. get: function get() {
  11912. return this.pdfDocument ? this._firstPageCapability.promise : null;
  11913. }
  11914. }, {
  11915. key: "onePageRendered",
  11916. get: function get() {
  11917. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  11918. }
  11919. }, {
  11920. key: "pagesPromise",
  11921. get: function get() {
  11922. return this.pdfDocument ? this._pagesCapability.promise : null;
  11923. }
  11924. }, {
  11925. key: "setDocument",
  11926. value: function setDocument(pdfDocument) {
  11927. var _this2 = this;
  11928. if (this.pdfDocument) {
  11929. this.eventBus.dispatch("pagesdestroy", {
  11930. source: this
  11931. });
  11932. this._cancelRendering();
  11933. this._resetView();
  11934. if (this.findController) {
  11935. this.findController.setDocument(null);
  11936. }
  11937. if (this._scriptingManager) {
  11938. this._scriptingManager.setDocument(null);
  11939. }
  11940. }
  11941. this.pdfDocument = pdfDocument;
  11942. if (!pdfDocument) {
  11943. return;
  11944. }
  11945. var isPureXfa = pdfDocument.isPureXfa;
  11946. var pagesCount = pdfDocument.numPages;
  11947. var firstPagePromise = pdfDocument.getPage(1);
  11948. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  11949. var permissionsPromise = _classPrivateFieldGet(this, _enablePermissions) ? pdfDocument.getPermissions() : Promise.resolve();
  11950. if (pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  11951. console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");
  11952. var mode = this._scrollMode = _ui_utils.ScrollMode.PAGE;
  11953. this.eventBus.dispatch("scrollmodechanged", {
  11954. source: this,
  11955. mode: mode
  11956. });
  11957. }
  11958. this._pagesCapability.promise.then(function () {
  11959. _this2.eventBus.dispatch("pagesloaded", {
  11960. source: _this2,
  11961. pagesCount: pagesCount
  11962. });
  11963. }, function () {});
  11964. this._onBeforeDraw = function (evt) {
  11965. var pageView = _this2._pages[evt.pageNumber - 1];
  11966. if (!pageView) {
  11967. return;
  11968. }
  11969. _classPrivateFieldGet(_this2, _buffer).push(pageView);
  11970. };
  11971. this.eventBus._on("pagerender", this._onBeforeDraw);
  11972. this._onAfterDraw = function (evt) {
  11973. if (evt.cssTransform || _this2._onePageRenderedCapability.settled) {
  11974. return;
  11975. }
  11976. _this2._onePageRenderedCapability.resolve({
  11977. timestamp: evt.timestamp
  11978. });
  11979. _this2.eventBus._off("pagerendered", _this2._onAfterDraw);
  11980. _this2._onAfterDraw = null;
  11981. if (_classPrivateFieldGet(_this2, _onVisibilityChange)) {
  11982. document.removeEventListener("visibilitychange", _classPrivateFieldGet(_this2, _onVisibilityChange));
  11983. _classPrivateFieldSet(_this2, _onVisibilityChange, null);
  11984. }
  11985. };
  11986. this.eventBus._on("pagerendered", this._onAfterDraw);
  11987. Promise.all([firstPagePromise, permissionsPromise]).then(function (_ref) {
  11988. var _ref2 = _slicedToArray(_ref, 2),
  11989. firstPdfPage = _ref2[0],
  11990. permissions = _ref2[1];
  11991. if (pdfDocument !== _this2.pdfDocument) {
  11992. return;
  11993. }
  11994. _this2._firstPageCapability.resolve(firstPdfPage);
  11995. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  11996. _classPrivateMethodGet(_this2, _initializePermissions, _initializePermissions2).call(_this2, permissions);
  11997. var viewerElement = _this2._scrollMode === _ui_utils.ScrollMode.PAGE ? null : _this2.viewer;
  11998. var scale = _this2.currentScale;
  11999. var viewport = firstPdfPage.getViewport({
  12000. scale: scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
  12001. });
  12002. var textLayerFactory = _this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && !isPureXfa ? _this2 : null;
  12003. var annotationLayerFactory = _classPrivateFieldGet(_this2, _annotationMode) !== _pdfjsLib.AnnotationMode.DISABLE ? _this2 : null;
  12004. var xfaLayerFactory = isPureXfa ? _this2 : null;
  12005. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  12006. var pageView = new _pdf_page_view.PDFPageView({
  12007. container: viewerElement,
  12008. eventBus: _this2.eventBus,
  12009. id: pageNum,
  12010. scale: scale,
  12011. defaultViewport: viewport.clone(),
  12012. optionalContentConfigPromise: optionalContentConfigPromise,
  12013. renderingQueue: _this2.renderingQueue,
  12014. textLayerFactory: textLayerFactory,
  12015. textLayerMode: _this2.textLayerMode,
  12016. annotationLayerFactory: annotationLayerFactory,
  12017. annotationMode: _classPrivateFieldGet(_this2, _annotationMode),
  12018. xfaLayerFactory: xfaLayerFactory,
  12019. textHighlighterFactory: _this2,
  12020. structTreeLayerFactory: _this2,
  12021. imageResourcesPath: _this2.imageResourcesPath,
  12022. renderer: _this2.renderer,
  12023. useOnlyCssZoom: _this2.useOnlyCssZoom,
  12024. maxCanvasPixels: _this2.maxCanvasPixels,
  12025. pageColors: _this2.pageColors,
  12026. l10n: _this2.l10n
  12027. });
  12028. _this2._pages.push(pageView);
  12029. }
  12030. var firstPageView = _this2._pages[0];
  12031. if (firstPageView) {
  12032. firstPageView.setPdfPage(firstPdfPage);
  12033. _this2.linkService.cachePageRef(1, firstPdfPage.ref);
  12034. }
  12035. if (_this2._scrollMode === _ui_utils.ScrollMode.PAGE) {
  12036. _classPrivateMethodGet(_this2, _ensurePageViewVisible, _ensurePageViewVisible2).call(_this2);
  12037. } else if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  12038. _this2._updateSpreadMode();
  12039. }
  12040. _classPrivateMethodGet(_this2, _onePageRenderedOrForceFetch, _onePageRenderedOrForceFetch2).call(_this2).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  12041. var getPagesLeft, _loop, _pageNum;
  12042. return _regenerator["default"].wrap(function _callee$(_context2) {
  12043. while (1) {
  12044. switch (_context2.prev = _context2.next) {
  12045. case 0:
  12046. if (_this2.findController) {
  12047. _this2.findController.setDocument(pdfDocument);
  12048. }
  12049. if (_this2._scriptingManager) {
  12050. _this2._scriptingManager.setDocument(pdfDocument);
  12051. }
  12052. if (!(pdfDocument.loadingParams.disableAutoFetch || pagesCount > PagesCountLimit.FORCE_LAZY_PAGE_INIT)) {
  12053. _context2.next = 5;
  12054. break;
  12055. }
  12056. _this2._pagesCapability.resolve();
  12057. return _context2.abrupt("return");
  12058. case 5:
  12059. getPagesLeft = pagesCount - 1;
  12060. if (!(getPagesLeft <= 0)) {
  12061. _context2.next = 9;
  12062. break;
  12063. }
  12064. _this2._pagesCapability.resolve();
  12065. return _context2.abrupt("return");
  12066. case 9:
  12067. _loop = /*#__PURE__*/_regenerator["default"].mark(function _loop(_pageNum) {
  12068. var promise;
  12069. return _regenerator["default"].wrap(function _loop$(_context) {
  12070. while (1) {
  12071. switch (_context.prev = _context.next) {
  12072. case 0:
  12073. promise = pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  12074. var pageView = _this2._pages[_pageNum - 1];
  12075. if (!pageView.pdfPage) {
  12076. pageView.setPdfPage(pdfPage);
  12077. }
  12078. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  12079. if (--getPagesLeft === 0) {
  12080. _this2._pagesCapability.resolve();
  12081. }
  12082. }, function (reason) {
  12083. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  12084. if (--getPagesLeft === 0) {
  12085. _this2._pagesCapability.resolve();
  12086. }
  12087. });
  12088. if (!(_pageNum % PagesCountLimit.PAUSE_EAGER_PAGE_INIT === 0)) {
  12089. _context.next = 4;
  12090. break;
  12091. }
  12092. _context.next = 4;
  12093. return promise;
  12094. case 4:
  12095. case "end":
  12096. return _context.stop();
  12097. }
  12098. }
  12099. }, _loop);
  12100. });
  12101. _pageNum = 2;
  12102. case 11:
  12103. if (!(_pageNum <= pagesCount)) {
  12104. _context2.next = 16;
  12105. break;
  12106. }
  12107. return _context2.delegateYield(_loop(_pageNum), "t0", 13);
  12108. case 13:
  12109. ++_pageNum;
  12110. _context2.next = 11;
  12111. break;
  12112. case 16:
  12113. case "end":
  12114. return _context2.stop();
  12115. }
  12116. }
  12117. }, _callee);
  12118. })));
  12119. _this2.eventBus.dispatch("pagesinit", {
  12120. source: _this2
  12121. });
  12122. pdfDocument.getMetadata().then(function (_ref4) {
  12123. var info = _ref4.info;
  12124. if (pdfDocument !== _this2.pdfDocument) {
  12125. return;
  12126. }
  12127. if (info.Language) {
  12128. _this2.viewer.lang = info.Language;
  12129. }
  12130. });
  12131. if (_this2.defaultRenderingQueue) {
  12132. _this2.update();
  12133. }
  12134. })["catch"](function (reason) {
  12135. console.error("Unable to initialize viewer", reason);
  12136. _this2._pagesCapability.reject(reason);
  12137. });
  12138. }
  12139. }, {
  12140. key: "setPageLabels",
  12141. value: function setPageLabels(labels) {
  12142. if (!this.pdfDocument) {
  12143. return;
  12144. }
  12145. if (!labels) {
  12146. this._pageLabels = null;
  12147. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  12148. this._pageLabels = null;
  12149. console.error("setPageLabels: Invalid page labels.");
  12150. } else {
  12151. this._pageLabels = labels;
  12152. }
  12153. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  12154. var _this$_pageLabels$i, _this$_pageLabels5;
  12155. 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);
  12156. }
  12157. }
  12158. }, {
  12159. key: "_resetView",
  12160. value: function _resetView() {
  12161. this._pages = [];
  12162. this._currentPageNumber = 1;
  12163. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  12164. this._currentScaleValue = null;
  12165. this._pageLabels = null;
  12166. _classPrivateFieldSet(this, _buffer, new PDFPageViewBuffer(DEFAULT_CACHE_SIZE));
  12167. this._location = null;
  12168. this._pagesRotation = 0;
  12169. this._optionalContentConfigPromise = null;
  12170. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  12171. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  12172. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  12173. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  12174. this._previousScrollMode = _ui_utils.ScrollMode.UNKNOWN;
  12175. this._spreadMode = _ui_utils.SpreadMode.NONE;
  12176. _classPrivateFieldSet(this, _scrollModePageState, {
  12177. previousPageNumber: 1,
  12178. scrollDown: true,
  12179. pages: []
  12180. });
  12181. if (this._onBeforeDraw) {
  12182. this.eventBus._off("pagerender", this._onBeforeDraw);
  12183. this._onBeforeDraw = null;
  12184. }
  12185. if (this._onAfterDraw) {
  12186. this.eventBus._off("pagerendered", this._onAfterDraw);
  12187. this._onAfterDraw = null;
  12188. }
  12189. if (_classPrivateFieldGet(this, _onVisibilityChange)) {
  12190. document.removeEventListener("visibilitychange", _classPrivateFieldGet(this, _onVisibilityChange));
  12191. _classPrivateFieldSet(this, _onVisibilityChange, null);
  12192. }
  12193. this.viewer.textContent = "";
  12194. this._updateScrollMode();
  12195. this.viewer.removeAttribute("lang");
  12196. this.viewer.classList.remove(ENABLE_PERMISSIONS_CLASS);
  12197. if (_classPrivateFieldGet(this, _previousAnnotationMode) !== null) {
  12198. _classPrivateFieldSet(this, _annotationMode, _classPrivateFieldGet(this, _previousAnnotationMode));
  12199. _classPrivateFieldSet(this, _previousAnnotationMode, null);
  12200. }
  12201. }
  12202. }, {
  12203. key: "_scrollUpdate",
  12204. value: function _scrollUpdate() {
  12205. if (this.pagesCount === 0) {
  12206. return;
  12207. }
  12208. this.update();
  12209. }
  12210. }, {
  12211. key: "_setScaleUpdatePages",
  12212. value: function _setScaleUpdatePages(newScale, newValue) {
  12213. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  12214. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  12215. this._currentScaleValue = newValue.toString();
  12216. if (_classPrivateMethodGet(this, _isSameScale, _isSameScale2).call(this, newScale)) {
  12217. if (preset) {
  12218. this.eventBus.dispatch("scalechanging", {
  12219. source: this,
  12220. scale: newScale,
  12221. presetValue: newValue
  12222. });
  12223. }
  12224. return;
  12225. }
  12226. this._doc.style.setProperty("--zoom-factor", newScale);
  12227. var updateArgs = {
  12228. scale: newScale
  12229. };
  12230. var _iterator3 = _createForOfIteratorHelper(this._pages),
  12231. _step3;
  12232. try {
  12233. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  12234. var pageView = _step3.value;
  12235. pageView.update(updateArgs);
  12236. }
  12237. } catch (err) {
  12238. _iterator3.e(err);
  12239. } finally {
  12240. _iterator3.f();
  12241. }
  12242. this._currentScale = newScale;
  12243. if (!noScroll) {
  12244. var page = this._currentPageNumber,
  12245. dest;
  12246. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  12247. page = this._location.pageNumber;
  12248. dest = [null, {
  12249. name: "XYZ"
  12250. }, this._location.left, this._location.top, null];
  12251. }
  12252. this.scrollPageIntoView({
  12253. pageNumber: page,
  12254. destArray: dest,
  12255. allowNegativeOffset: true
  12256. });
  12257. }
  12258. this.eventBus.dispatch("scalechanging", {
  12259. source: this,
  12260. scale: newScale,
  12261. presetValue: preset ? newValue : undefined
  12262. });
  12263. if (this.defaultRenderingQueue) {
  12264. this.update();
  12265. }
  12266. this.updateContainerHeightCss();
  12267. }
  12268. }, {
  12269. key: "_pageWidthScaleFactor",
  12270. get: function get() {
  12271. if (this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL) {
  12272. return 2;
  12273. }
  12274. return 1;
  12275. }
  12276. }, {
  12277. key: "_setScale",
  12278. value: function _setScale(value) {
  12279. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12280. var scale = parseFloat(value);
  12281. if (scale > 0) {
  12282. this._setScaleUpdatePages(scale, value, noScroll, false);
  12283. } else {
  12284. var currentPage = this._pages[this._currentPageNumber - 1];
  12285. if (!currentPage) {
  12286. return;
  12287. }
  12288. var hPadding = _ui_utils.SCROLLBAR_PADDING,
  12289. vPadding = _ui_utils.VERTICAL_PADDING;
  12290. if (this.isInPresentationMode) {
  12291. hPadding = vPadding = 4;
  12292. } else if (this.removePageBorders) {
  12293. hPadding = vPadding = 0;
  12294. } else if (this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL) {
  12295. var _ref5 = [vPadding, hPadding];
  12296. hPadding = _ref5[0];
  12297. vPadding = _ref5[1];
  12298. }
  12299. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this._pageWidthScaleFactor;
  12300. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  12301. switch (value) {
  12302. case "page-actual":
  12303. scale = 1;
  12304. break;
  12305. case "page-width":
  12306. scale = pageWidthScale;
  12307. break;
  12308. case "page-height":
  12309. scale = pageHeightScale;
  12310. break;
  12311. case "page-fit":
  12312. scale = Math.min(pageWidthScale, pageHeightScale);
  12313. break;
  12314. case "auto":
  12315. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  12316. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  12317. break;
  12318. default:
  12319. console.error("_setScale: \"".concat(value, "\" is an unknown zoom value."));
  12320. return;
  12321. }
  12322. this._setScaleUpdatePages(scale, value, noScroll, true);
  12323. }
  12324. }
  12325. }, {
  12326. key: "pageLabelToPageNumber",
  12327. value: function pageLabelToPageNumber(label) {
  12328. if (!this._pageLabels) {
  12329. return null;
  12330. }
  12331. var i = this._pageLabels.indexOf(label);
  12332. if (i < 0) {
  12333. return null;
  12334. }
  12335. return i + 1;
  12336. }
  12337. }, {
  12338. key: "scrollPageIntoView",
  12339. value: function scrollPageIntoView(_ref6) {
  12340. var pageNumber = _ref6.pageNumber,
  12341. _ref6$destArray = _ref6.destArray,
  12342. destArray = _ref6$destArray === void 0 ? null : _ref6$destArray,
  12343. _ref6$allowNegativeOf = _ref6.allowNegativeOffset,
  12344. allowNegativeOffset = _ref6$allowNegativeOf === void 0 ? false : _ref6$allowNegativeOf,
  12345. _ref6$ignoreDestinati = _ref6.ignoreDestinationZoom,
  12346. ignoreDestinationZoom = _ref6$ignoreDestinati === void 0 ? false : _ref6$ignoreDestinati;
  12347. if (!this.pdfDocument) {
  12348. return;
  12349. }
  12350. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  12351. if (!pageView) {
  12352. console.error("scrollPageIntoView: \"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  12353. return;
  12354. }
  12355. if (this.isInPresentationMode || !destArray) {
  12356. this._setCurrentPageNumber(pageNumber, true);
  12357. return;
  12358. }
  12359. var x = 0,
  12360. y = 0;
  12361. var width = 0,
  12362. height = 0,
  12363. widthScale,
  12364. heightScale;
  12365. var changeOrientation = pageView.rotation % 180 !== 0;
  12366. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  12367. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  12368. var scale = 0;
  12369. switch (destArray[1].name) {
  12370. case "XYZ":
  12371. x = destArray[2];
  12372. y = destArray[3];
  12373. scale = destArray[4];
  12374. x = x !== null ? x : 0;
  12375. y = y !== null ? y : pageHeight;
  12376. break;
  12377. case "Fit":
  12378. case "FitB":
  12379. scale = "page-fit";
  12380. break;
  12381. case "FitH":
  12382. case "FitBH":
  12383. y = destArray[2];
  12384. scale = "page-width";
  12385. if (y === null && this._location) {
  12386. x = this._location.left;
  12387. y = this._location.top;
  12388. } else if (typeof y !== "number" || y < 0) {
  12389. y = pageHeight;
  12390. }
  12391. break;
  12392. case "FitV":
  12393. case "FitBV":
  12394. x = destArray[2];
  12395. width = pageWidth;
  12396. height = pageHeight;
  12397. scale = "page-height";
  12398. break;
  12399. case "FitR":
  12400. x = destArray[2];
  12401. y = destArray[3];
  12402. width = destArray[4] - x;
  12403. height = destArray[5] - y;
  12404. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  12405. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  12406. widthScale = (this.container.clientWidth - hPadding) / width / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  12407. heightScale = (this.container.clientHeight - vPadding) / height / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  12408. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  12409. break;
  12410. default:
  12411. console.error("scrollPageIntoView: \"".concat(destArray[1].name, "\" is not a valid destination type."));
  12412. return;
  12413. }
  12414. if (!ignoreDestinationZoom) {
  12415. if (scale && scale !== this._currentScale) {
  12416. this.currentScaleValue = scale;
  12417. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  12418. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  12419. }
  12420. }
  12421. if (scale === "page-fit" && !destArray[4]) {
  12422. _classPrivateMethodGet(this, _scrollIntoView, _scrollIntoView2).call(this, pageView);
  12423. return;
  12424. }
  12425. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  12426. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  12427. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  12428. if (!allowNegativeOffset) {
  12429. left = Math.max(left, 0);
  12430. top = Math.max(top, 0);
  12431. }
  12432. _classPrivateMethodGet(this, _scrollIntoView, _scrollIntoView2).call(this, pageView, {
  12433. left: left,
  12434. top: top
  12435. });
  12436. }
  12437. }, {
  12438. key: "_updateLocation",
  12439. value: function _updateLocation(firstPage) {
  12440. var currentScale = this._currentScale;
  12441. var currentScaleValue = this._currentScaleValue;
  12442. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  12443. var pageNumber = firstPage.id;
  12444. var currentPageView = this._pages[pageNumber - 1];
  12445. var container = this.container;
  12446. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  12447. var intLeft = Math.round(topLeft[0]);
  12448. var intTop = Math.round(topLeft[1]);
  12449. var pdfOpenParams = "#page=".concat(pageNumber);
  12450. if (!this.isInPresentationMode) {
  12451. pdfOpenParams += "&zoom=".concat(normalizedScaleValue, ",").concat(intLeft, ",").concat(intTop);
  12452. }
  12453. this._location = {
  12454. pageNumber: pageNumber,
  12455. scale: normalizedScaleValue,
  12456. top: intTop,
  12457. left: intLeft,
  12458. rotation: this._pagesRotation,
  12459. pdfOpenParams: pdfOpenParams
  12460. };
  12461. }
  12462. }, {
  12463. key: "update",
  12464. value: function update() {
  12465. var visible = this._getVisiblePages();
  12466. var visiblePages = visible.views,
  12467. numVisiblePages = visiblePages.length;
  12468. if (numVisiblePages === 0) {
  12469. return;
  12470. }
  12471. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  12472. _classPrivateFieldGet(this, _buffer).resize(newCacheSize, visible.ids);
  12473. this.renderingQueue.renderHighestPriority(visible);
  12474. var isSimpleLayout = this._spreadMode === _ui_utils.SpreadMode.NONE && (this._scrollMode === _ui_utils.ScrollMode.PAGE || this._scrollMode === _ui_utils.ScrollMode.VERTICAL);
  12475. var currentId = this._currentPageNumber;
  12476. var stillFullyVisible = false;
  12477. var _iterator4 = _createForOfIteratorHelper(visiblePages),
  12478. _step4;
  12479. try {
  12480. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  12481. var page = _step4.value;
  12482. if (page.percent < 100) {
  12483. break;
  12484. }
  12485. if (page.id === currentId && isSimpleLayout) {
  12486. stillFullyVisible = true;
  12487. break;
  12488. }
  12489. }
  12490. } catch (err) {
  12491. _iterator4.e(err);
  12492. } finally {
  12493. _iterator4.f();
  12494. }
  12495. this._setCurrentPageNumber(stillFullyVisible ? currentId : visiblePages[0].id);
  12496. this._updateLocation(visible.first);
  12497. this.eventBus.dispatch("updateviewarea", {
  12498. source: this,
  12499. location: this._location
  12500. });
  12501. }
  12502. }, {
  12503. key: "containsElement",
  12504. value: function containsElement(element) {
  12505. return this.container.contains(element);
  12506. }
  12507. }, {
  12508. key: "focus",
  12509. value: function focus() {
  12510. this.container.focus();
  12511. }
  12512. }, {
  12513. key: "_isContainerRtl",
  12514. get: function get() {
  12515. return getComputedStyle(this.container).direction === "rtl";
  12516. }
  12517. }, {
  12518. key: "isInPresentationMode",
  12519. get: function get() {
  12520. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  12521. }
  12522. }, {
  12523. key: "isChangingPresentationMode",
  12524. get: function get() {
  12525. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  12526. }
  12527. }, {
  12528. key: "isHorizontalScrollbarEnabled",
  12529. get: function get() {
  12530. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  12531. }
  12532. }, {
  12533. key: "isVerticalScrollbarEnabled",
  12534. get: function get() {
  12535. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  12536. }
  12537. }, {
  12538. key: "_getVisiblePages",
  12539. value: function _getVisiblePages() {
  12540. var views = this._scrollMode === _ui_utils.ScrollMode.PAGE ? _classPrivateFieldGet(this, _scrollModePageState).pages : this._pages,
  12541. horizontal = this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL,
  12542. rtl = horizontal && this._isContainerRtl;
  12543. return (0, _ui_utils.getVisibleElements)({
  12544. scrollEl: this.container,
  12545. views: views,
  12546. sortByVisibility: true,
  12547. horizontal: horizontal,
  12548. rtl: rtl
  12549. });
  12550. }
  12551. }, {
  12552. key: "isPageVisible",
  12553. value: function isPageVisible(pageNumber) {
  12554. if (!this.pdfDocument) {
  12555. return false;
  12556. }
  12557. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  12558. console.error("isPageVisible: \"".concat(pageNumber, "\" is not a valid page."));
  12559. return false;
  12560. }
  12561. return this._getVisiblePages().ids.has(pageNumber);
  12562. }
  12563. }, {
  12564. key: "isPageCached",
  12565. value: function isPageCached(pageNumber) {
  12566. if (!this.pdfDocument) {
  12567. return false;
  12568. }
  12569. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  12570. console.error("isPageCached: \"".concat(pageNumber, "\" is not a valid page."));
  12571. return false;
  12572. }
  12573. var pageView = this._pages[pageNumber - 1];
  12574. return _classPrivateFieldGet(this, _buffer).has(pageView);
  12575. }
  12576. }, {
  12577. key: "cleanup",
  12578. value: function cleanup() {
  12579. var _iterator5 = _createForOfIteratorHelper(this._pages),
  12580. _step5;
  12581. try {
  12582. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  12583. var pageView = _step5.value;
  12584. if (pageView.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  12585. pageView.reset();
  12586. }
  12587. }
  12588. } catch (err) {
  12589. _iterator5.e(err);
  12590. } finally {
  12591. _iterator5.f();
  12592. }
  12593. }
  12594. }, {
  12595. key: "_cancelRendering",
  12596. value: function _cancelRendering() {
  12597. var _iterator6 = _createForOfIteratorHelper(this._pages),
  12598. _step6;
  12599. try {
  12600. for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
  12601. var pageView = _step6.value;
  12602. pageView.cancelRendering();
  12603. }
  12604. } catch (err) {
  12605. _iterator6.e(err);
  12606. } finally {
  12607. _iterator6.f();
  12608. }
  12609. }
  12610. }, {
  12611. key: "forceRendering",
  12612. value: function forceRendering(currentlyVisiblePages) {
  12613. var _this3 = this;
  12614. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  12615. var scrollAhead = _classPrivateMethodGet(this, _getScrollAhead, _getScrollAhead2).call(this, visiblePages);
  12616. var preRenderExtra = this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL;
  12617. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead, preRenderExtra);
  12618. _classPrivateMethodGet(this, _toggleLoadingIconSpinner, _toggleLoadingIconSpinner2).call(this, visiblePages.ids);
  12619. if (pageView) {
  12620. _classPrivateMethodGet(this, _ensurePdfPageLoaded, _ensurePdfPageLoaded2).call(this, pageView).then(function () {
  12621. _this3.renderingQueue.renderView(pageView);
  12622. });
  12623. return true;
  12624. }
  12625. return false;
  12626. }
  12627. }, {
  12628. key: "createTextLayerBuilder",
  12629. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  12630. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  12631. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  12632. var highlighter = arguments.length > 5 ? arguments[5] : undefined;
  12633. return new _text_layer_builder.TextLayerBuilder({
  12634. textLayerDiv: textLayerDiv,
  12635. eventBus: eventBus,
  12636. pageIndex: pageIndex,
  12637. viewport: viewport,
  12638. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection,
  12639. highlighter: highlighter
  12640. });
  12641. }
  12642. }, {
  12643. key: "createTextHighlighter",
  12644. value: function createTextHighlighter(pageIndex, eventBus) {
  12645. return new _text_highlighter.TextHighlighter({
  12646. eventBus: eventBus,
  12647. pageIndex: pageIndex,
  12648. findController: this.isInPresentationMode ? null : this.findController
  12649. });
  12650. }
  12651. }, {
  12652. key: "createAnnotationLayerBuilder",
  12653. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  12654. var _this$pdfDocument, _this$pdfDocument2, _this$pdfDocument3, _this$_scriptingManag;
  12655. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  12656. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  12657. var renderForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  12658. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _l10n_utils.NullL10n;
  12659. var enableScripting = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
  12660. var hasJSActionsPromise = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  12661. var mouseState = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
  12662. var fieldObjectsPromise = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : null;
  12663. var annotationCanvasMap = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : null;
  12664. return new _annotation_layer_builder.AnnotationLayerBuilder({
  12665. pageDiv: pageDiv,
  12666. pdfPage: pdfPage,
  12667. annotationStorage: annotationStorage || ((_this$pdfDocument = this.pdfDocument) === null || _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage),
  12668. imageResourcesPath: imageResourcesPath,
  12669. renderForms: renderForms,
  12670. linkService: this.linkService,
  12671. downloadManager: this.downloadManager,
  12672. l10n: l10n,
  12673. enableScripting: enableScripting !== null && enableScripting !== void 0 ? enableScripting : this.enableScripting,
  12674. hasJSActionsPromise: hasJSActionsPromise || ((_this$pdfDocument2 = this.pdfDocument) === null || _this$pdfDocument2 === void 0 ? void 0 : _this$pdfDocument2.hasJSActions()),
  12675. fieldObjectsPromise: fieldObjectsPromise || ((_this$pdfDocument3 = this.pdfDocument) === null || _this$pdfDocument3 === void 0 ? void 0 : _this$pdfDocument3.getFieldObjects()),
  12676. mouseState: mouseState || ((_this$_scriptingManag = this._scriptingManager) === null || _this$_scriptingManag === void 0 ? void 0 : _this$_scriptingManag.mouseState),
  12677. annotationCanvasMap: annotationCanvasMap
  12678. });
  12679. }
  12680. }, {
  12681. key: "createXfaLayerBuilder",
  12682. value: function createXfaLayerBuilder(pageDiv, pdfPage) {
  12683. var _this$pdfDocument4;
  12684. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  12685. return new _xfa_layer_builder.XfaLayerBuilder({
  12686. pageDiv: pageDiv,
  12687. pdfPage: pdfPage,
  12688. annotationStorage: annotationStorage || ((_this$pdfDocument4 = this.pdfDocument) === null || _this$pdfDocument4 === void 0 ? void 0 : _this$pdfDocument4.annotationStorage),
  12689. linkService: this.linkService
  12690. });
  12691. }
  12692. }, {
  12693. key: "createStructTreeLayerBuilder",
  12694. value: function createStructTreeLayerBuilder(pdfPage) {
  12695. return new _struct_tree_layer_builder.StructTreeLayerBuilder({
  12696. pdfPage: pdfPage
  12697. });
  12698. }
  12699. }, {
  12700. key: "hasEqualPageSizes",
  12701. get: function get() {
  12702. var firstPageView = this._pages[0];
  12703. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  12704. var pageView = this._pages[i];
  12705. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  12706. return false;
  12707. }
  12708. }
  12709. return true;
  12710. }
  12711. }, {
  12712. key: "getPagesOverview",
  12713. value: function getPagesOverview() {
  12714. var _this4 = this;
  12715. return this._pages.map(function (pageView) {
  12716. var viewport = pageView.pdfPage.getViewport({
  12717. scale: 1
  12718. });
  12719. if (!_this4.enablePrintAutoRotate || (0, _ui_utils.isPortraitOrientation)(viewport)) {
  12720. return {
  12721. width: viewport.width,
  12722. height: viewport.height,
  12723. rotation: viewport.rotation
  12724. };
  12725. }
  12726. return {
  12727. width: viewport.height,
  12728. height: viewport.width,
  12729. rotation: (viewport.rotation - 90) % 360
  12730. };
  12731. });
  12732. }
  12733. }, {
  12734. key: "optionalContentConfigPromise",
  12735. get: function get() {
  12736. if (!this.pdfDocument) {
  12737. return Promise.resolve(null);
  12738. }
  12739. if (!this._optionalContentConfigPromise) {
  12740. return this.pdfDocument.getOptionalContentConfig();
  12741. }
  12742. return this._optionalContentConfigPromise;
  12743. },
  12744. set: function set(promise) {
  12745. if (!(promise instanceof Promise)) {
  12746. throw new Error("Invalid optionalContentConfigPromise: ".concat(promise));
  12747. }
  12748. if (!this.pdfDocument) {
  12749. return;
  12750. }
  12751. if (!this._optionalContentConfigPromise) {
  12752. return;
  12753. }
  12754. this._optionalContentConfigPromise = promise;
  12755. var updateArgs = {
  12756. optionalContentConfigPromise: promise
  12757. };
  12758. var _iterator7 = _createForOfIteratorHelper(this._pages),
  12759. _step7;
  12760. try {
  12761. for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
  12762. var pageView = _step7.value;
  12763. pageView.update(updateArgs);
  12764. }
  12765. } catch (err) {
  12766. _iterator7.e(err);
  12767. } finally {
  12768. _iterator7.f();
  12769. }
  12770. this.update();
  12771. this.eventBus.dispatch("optionalcontentconfigchanged", {
  12772. source: this,
  12773. promise: promise
  12774. });
  12775. }
  12776. }, {
  12777. key: "scrollMode",
  12778. get: function get() {
  12779. return this._scrollMode;
  12780. },
  12781. set: function set(mode) {
  12782. if (this._scrollMode === mode) {
  12783. return;
  12784. }
  12785. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  12786. throw new Error("Invalid scroll mode: ".concat(mode));
  12787. }
  12788. if (this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  12789. return;
  12790. }
  12791. this._previousScrollMode = this._scrollMode;
  12792. this._scrollMode = mode;
  12793. this.eventBus.dispatch("scrollmodechanged", {
  12794. source: this,
  12795. mode: mode
  12796. });
  12797. this._updateScrollMode(this._currentPageNumber);
  12798. }
  12799. }, {
  12800. key: "_updateScrollMode",
  12801. value: function _updateScrollMode() {
  12802. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  12803. var scrollMode = this._scrollMode,
  12804. viewer = this.viewer;
  12805. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  12806. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  12807. if (!this.pdfDocument || !pageNumber) {
  12808. return;
  12809. }
  12810. if (scrollMode === _ui_utils.ScrollMode.PAGE) {
  12811. _classPrivateMethodGet(this, _ensurePageViewVisible, _ensurePageViewVisible2).call(this);
  12812. } else if (this._previousScrollMode === _ui_utils.ScrollMode.PAGE) {
  12813. this._updateSpreadMode();
  12814. }
  12815. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  12816. this._setScale(this._currentScaleValue, true);
  12817. }
  12818. this._setCurrentPageNumber(pageNumber, true);
  12819. this.update();
  12820. }
  12821. }, {
  12822. key: "spreadMode",
  12823. get: function get() {
  12824. return this._spreadMode;
  12825. },
  12826. set: function set(mode) {
  12827. if (this._spreadMode === mode) {
  12828. return;
  12829. }
  12830. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  12831. throw new Error("Invalid spread mode: ".concat(mode));
  12832. }
  12833. this._spreadMode = mode;
  12834. this.eventBus.dispatch("spreadmodechanged", {
  12835. source: this,
  12836. mode: mode
  12837. });
  12838. this._updateSpreadMode(this._currentPageNumber);
  12839. }
  12840. }, {
  12841. key: "_updateSpreadMode",
  12842. value: function _updateSpreadMode() {
  12843. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  12844. if (!this.pdfDocument) {
  12845. return;
  12846. }
  12847. var viewer = this.viewer,
  12848. pages = this._pages;
  12849. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  12850. _classPrivateMethodGet(this, _ensurePageViewVisible, _ensurePageViewVisible2).call(this);
  12851. } else {
  12852. viewer.textContent = "";
  12853. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  12854. var _iterator8 = _createForOfIteratorHelper(this._pages),
  12855. _step8;
  12856. try {
  12857. for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
  12858. var pageView = _step8.value;
  12859. viewer.appendChild(pageView.div);
  12860. }
  12861. } catch (err) {
  12862. _iterator8.e(err);
  12863. } finally {
  12864. _iterator8.f();
  12865. }
  12866. } else {
  12867. var parity = this._spreadMode - 1;
  12868. var spread = null;
  12869. for (var i = 0, ii = pages.length; i < ii; ++i) {
  12870. if (spread === null) {
  12871. spread = document.createElement("div");
  12872. spread.className = "spread";
  12873. viewer.appendChild(spread);
  12874. } else if (i % 2 === parity) {
  12875. spread = spread.cloneNode(false);
  12876. viewer.appendChild(spread);
  12877. }
  12878. spread.appendChild(pages[i].div);
  12879. }
  12880. }
  12881. }
  12882. if (!pageNumber) {
  12883. return;
  12884. }
  12885. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  12886. this._setScale(this._currentScaleValue, true);
  12887. }
  12888. this._setCurrentPageNumber(pageNumber, true);
  12889. this.update();
  12890. }
  12891. }, {
  12892. key: "_getPageAdvance",
  12893. value: function _getPageAdvance(currentPageNumber) {
  12894. var previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12895. switch (this._scrollMode) {
  12896. case _ui_utils.ScrollMode.WRAPPED:
  12897. {
  12898. var _this$_getVisiblePage = this._getVisiblePages(),
  12899. views = _this$_getVisiblePage.views,
  12900. pageLayout = new Map();
  12901. var _iterator9 = _createForOfIteratorHelper(views),
  12902. _step9;
  12903. try {
  12904. for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
  12905. var _step9$value = _step9.value,
  12906. id = _step9$value.id,
  12907. y = _step9$value.y,
  12908. percent = _step9$value.percent,
  12909. widthPercent = _step9$value.widthPercent;
  12910. if (percent === 0 || widthPercent < 100) {
  12911. continue;
  12912. }
  12913. var yArray = pageLayout.get(y);
  12914. if (!yArray) {
  12915. pageLayout.set(y, yArray || (yArray = []));
  12916. }
  12917. yArray.push(id);
  12918. }
  12919. } catch (err) {
  12920. _iterator9.e(err);
  12921. } finally {
  12922. _iterator9.f();
  12923. }
  12924. var _iterator10 = _createForOfIteratorHelper(pageLayout.values()),
  12925. _step10;
  12926. try {
  12927. for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
  12928. var _yArray = _step10.value;
  12929. var currentIndex = _yArray.indexOf(currentPageNumber);
  12930. if (currentIndex === -1) {
  12931. continue;
  12932. }
  12933. var numPages = _yArray.length;
  12934. if (numPages === 1) {
  12935. break;
  12936. }
  12937. if (previous) {
  12938. for (var i = currentIndex - 1, ii = 0; i >= ii; i--) {
  12939. var currentId = _yArray[i],
  12940. expectedId = _yArray[i + 1] - 1;
  12941. if (currentId < expectedId) {
  12942. return currentPageNumber - expectedId;
  12943. }
  12944. }
  12945. } else {
  12946. for (var _i2 = currentIndex + 1, _ii = numPages; _i2 < _ii; _i2++) {
  12947. var _currentId = _yArray[_i2],
  12948. _expectedId = _yArray[_i2 - 1] + 1;
  12949. if (_currentId > _expectedId) {
  12950. return _expectedId - currentPageNumber;
  12951. }
  12952. }
  12953. }
  12954. if (previous) {
  12955. var firstId = _yArray[0];
  12956. if (firstId < currentPageNumber) {
  12957. return currentPageNumber - firstId + 1;
  12958. }
  12959. } else {
  12960. var lastId = _yArray[numPages - 1];
  12961. if (lastId > currentPageNumber) {
  12962. return lastId - currentPageNumber + 1;
  12963. }
  12964. }
  12965. break;
  12966. }
  12967. } catch (err) {
  12968. _iterator10.e(err);
  12969. } finally {
  12970. _iterator10.f();
  12971. }
  12972. break;
  12973. }
  12974. case _ui_utils.ScrollMode.HORIZONTAL:
  12975. {
  12976. break;
  12977. }
  12978. case _ui_utils.ScrollMode.PAGE:
  12979. case _ui_utils.ScrollMode.VERTICAL:
  12980. {
  12981. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  12982. break;
  12983. }
  12984. var parity = this._spreadMode - 1;
  12985. if (previous && currentPageNumber % 2 !== parity) {
  12986. break;
  12987. } else if (!previous && currentPageNumber % 2 === parity) {
  12988. break;
  12989. }
  12990. var _this$_getVisiblePage2 = this._getVisiblePages(),
  12991. _views = _this$_getVisiblePage2.views,
  12992. _expectedId2 = previous ? currentPageNumber - 1 : currentPageNumber + 1;
  12993. var _iterator11 = _createForOfIteratorHelper(_views),
  12994. _step11;
  12995. try {
  12996. for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
  12997. var _step11$value = _step11.value,
  12998. _id = _step11$value.id,
  12999. _percent = _step11$value.percent,
  13000. _widthPercent = _step11$value.widthPercent;
  13001. if (_id !== _expectedId2) {
  13002. continue;
  13003. }
  13004. if (_percent > 0 && _widthPercent === 100) {
  13005. return 2;
  13006. }
  13007. break;
  13008. }
  13009. } catch (err) {
  13010. _iterator11.e(err);
  13011. } finally {
  13012. _iterator11.f();
  13013. }
  13014. break;
  13015. }
  13016. }
  13017. return 1;
  13018. }
  13019. }, {
  13020. key: "nextPage",
  13021. value: function nextPage() {
  13022. var currentPageNumber = this._currentPageNumber,
  13023. pagesCount = this.pagesCount;
  13024. if (currentPageNumber >= pagesCount) {
  13025. return false;
  13026. }
  13027. var advance = this._getPageAdvance(currentPageNumber, false) || 1;
  13028. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  13029. return true;
  13030. }
  13031. }, {
  13032. key: "previousPage",
  13033. value: function previousPage() {
  13034. var currentPageNumber = this._currentPageNumber;
  13035. if (currentPageNumber <= 1) {
  13036. return false;
  13037. }
  13038. var advance = this._getPageAdvance(currentPageNumber, true) || 1;
  13039. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  13040. return true;
  13041. }
  13042. }, {
  13043. key: "increaseScale",
  13044. value: function increaseScale() {
  13045. var steps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  13046. var newScale = this._currentScale;
  13047. do {
  13048. newScale = (newScale * _ui_utils.DEFAULT_SCALE_DELTA).toFixed(2);
  13049. newScale = Math.ceil(newScale * 10) / 10;
  13050. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  13051. } while (--steps > 0 && newScale < _ui_utils.MAX_SCALE);
  13052. this.currentScaleValue = newScale;
  13053. }
  13054. }, {
  13055. key: "decreaseScale",
  13056. value: function decreaseScale() {
  13057. var steps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  13058. var newScale = this._currentScale;
  13059. do {
  13060. newScale = (newScale / _ui_utils.DEFAULT_SCALE_DELTA).toFixed(2);
  13061. newScale = Math.floor(newScale * 10) / 10;
  13062. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  13063. } while (--steps > 0 && newScale > _ui_utils.MIN_SCALE);
  13064. this.currentScaleValue = newScale;
  13065. }
  13066. }, {
  13067. key: "updateContainerHeightCss",
  13068. value: function updateContainerHeightCss() {
  13069. var height = this.container.clientHeight;
  13070. if (height !== _classPrivateFieldGet(this, _previousContainerHeight)) {
  13071. _classPrivateFieldSet(this, _previousContainerHeight, height);
  13072. this._doc.style.setProperty("--viewer-container-height", "".concat(height, "px"));
  13073. }
  13074. }
  13075. }]);
  13076. return BaseViewer;
  13077. }();
  13078. exports.BaseViewer = BaseViewer;
  13079. function _initializePermissions2(permissions) {
  13080. if (!permissions) {
  13081. return;
  13082. }
  13083. if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY)) {
  13084. this.viewer.classList.add(ENABLE_PERMISSIONS_CLASS);
  13085. }
  13086. if (!permissions.includes(_pdfjsLib.PermissionFlag.MODIFY_ANNOTATIONS) && !permissions.includes(_pdfjsLib.PermissionFlag.FILL_INTERACTIVE_FORMS)) {
  13087. if (_classPrivateFieldGet(this, _annotationMode) === _pdfjsLib.AnnotationMode.ENABLE_FORMS) {
  13088. _classPrivateFieldSet(this, _previousAnnotationMode, _classPrivateFieldGet(this, _annotationMode));
  13089. _classPrivateFieldSet(this, _annotationMode, _pdfjsLib.AnnotationMode.ENABLE);
  13090. }
  13091. }
  13092. }
  13093. function _onePageRenderedOrForceFetch2() {
  13094. var _this5 = this;
  13095. if (document.visibilityState === "hidden" || !this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  13096. return Promise.resolve();
  13097. }
  13098. var visibilityChangePromise = new Promise(function (resolve) {
  13099. _classPrivateFieldSet(_this5, _onVisibilityChange, function () {
  13100. if (document.visibilityState !== "hidden") {
  13101. return;
  13102. }
  13103. resolve();
  13104. document.removeEventListener("visibilitychange", _classPrivateFieldGet(_this5, _onVisibilityChange));
  13105. _classPrivateFieldSet(_this5, _onVisibilityChange, null);
  13106. });
  13107. document.addEventListener("visibilitychange", _classPrivateFieldGet(_this5, _onVisibilityChange));
  13108. });
  13109. return Promise.race([this._onePageRenderedCapability.promise, visibilityChangePromise]);
  13110. }
  13111. function _ensurePageViewVisible2() {
  13112. if (this._scrollMode !== _ui_utils.ScrollMode.PAGE) {
  13113. throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");
  13114. }
  13115. var pageNumber = this._currentPageNumber,
  13116. state = _classPrivateFieldGet(this, _scrollModePageState),
  13117. viewer = this.viewer;
  13118. viewer.textContent = "";
  13119. state.pages.length = 0;
  13120. if (this._spreadMode === _ui_utils.SpreadMode.NONE && !this.isInPresentationMode) {
  13121. var pageView = this._pages[pageNumber - 1];
  13122. viewer.appendChild(pageView.div);
  13123. state.pages.push(pageView);
  13124. } else {
  13125. var pageIndexSet = new Set(),
  13126. parity = this._spreadMode - 1;
  13127. if (parity === -1) {
  13128. pageIndexSet.add(pageNumber - 1);
  13129. } else if (pageNumber % 2 !== parity) {
  13130. pageIndexSet.add(pageNumber - 1);
  13131. pageIndexSet.add(pageNumber);
  13132. } else {
  13133. pageIndexSet.add(pageNumber - 2);
  13134. pageIndexSet.add(pageNumber - 1);
  13135. }
  13136. var spread = document.createElement("div");
  13137. spread.className = "spread";
  13138. if (this.isInPresentationMode) {
  13139. var dummyPage = document.createElement("div");
  13140. dummyPage.className = "dummyPage";
  13141. spread.appendChild(dummyPage);
  13142. }
  13143. var _iterator12 = _createForOfIteratorHelper(pageIndexSet),
  13144. _step12;
  13145. try {
  13146. for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
  13147. var i = _step12.value;
  13148. var _pageView = this._pages[i];
  13149. if (!_pageView) {
  13150. continue;
  13151. }
  13152. spread.appendChild(_pageView.div);
  13153. state.pages.push(_pageView);
  13154. }
  13155. } catch (err) {
  13156. _iterator12.e(err);
  13157. } finally {
  13158. _iterator12.f();
  13159. }
  13160. viewer.appendChild(spread);
  13161. }
  13162. state.scrollDown = pageNumber >= state.previousPageNumber;
  13163. state.previousPageNumber = pageNumber;
  13164. }
  13165. function _scrollIntoView2(pageView) {
  13166. var pageSpot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  13167. var div = pageView.div,
  13168. id = pageView.id;
  13169. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  13170. this._setCurrentPageNumber(id);
  13171. _classPrivateMethodGet(this, _ensurePageViewVisible, _ensurePageViewVisible2).call(this);
  13172. this.update();
  13173. }
  13174. if (!pageSpot && !this.isInPresentationMode) {
  13175. var left = div.offsetLeft + div.clientLeft,
  13176. right = left + div.clientWidth;
  13177. var _this$container2 = this.container,
  13178. scrollLeft = _this$container2.scrollLeft,
  13179. clientWidth = _this$container2.clientWidth;
  13180. if (this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) {
  13181. pageSpot = {
  13182. left: 0,
  13183. top: 0
  13184. };
  13185. }
  13186. }
  13187. (0, _ui_utils.scrollIntoView)(div, pageSpot);
  13188. }
  13189. function _isSameScale2(newScale) {
  13190. return newScale === this._currentScale || Math.abs(newScale - this._currentScale) < 1e-15;
  13191. }
  13192. function _resetCurrentPageView2() {
  13193. var pageView = this._pages[this._currentPageNumber - 1];
  13194. if (this.isInPresentationMode) {
  13195. this._setScale(this._currentScaleValue, true);
  13196. }
  13197. _classPrivateMethodGet(this, _scrollIntoView, _scrollIntoView2).call(this, pageView);
  13198. }
  13199. function _ensurePdfPageLoaded2(_x) {
  13200. return _ensurePdfPageLoaded3.apply(this, arguments);
  13201. }
  13202. function _ensurePdfPageLoaded3() {
  13203. _ensurePdfPageLoaded3 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pageView) {
  13204. var _this$linkService$_ca, _this$linkService, pdfPage;
  13205. return _regenerator["default"].wrap(function _callee2$(_context3) {
  13206. while (1) {
  13207. switch (_context3.prev = _context3.next) {
  13208. case 0:
  13209. if (!pageView.pdfPage) {
  13210. _context3.next = 2;
  13211. break;
  13212. }
  13213. return _context3.abrupt("return", pageView.pdfPage);
  13214. case 2:
  13215. _context3.prev = 2;
  13216. _context3.next = 5;
  13217. return this.pdfDocument.getPage(pageView.id);
  13218. case 5:
  13219. pdfPage = _context3.sent;
  13220. if (!pageView.pdfPage) {
  13221. pageView.setPdfPage(pdfPage);
  13222. }
  13223. if (!((_this$linkService$_ca = (_this$linkService = this.linkService)._cachedPageNumber) !== null && _this$linkService$_ca !== void 0 && _this$linkService$_ca.call(_this$linkService, pdfPage.ref))) {
  13224. this.linkService.cachePageRef(pageView.id, pdfPage.ref);
  13225. }
  13226. return _context3.abrupt("return", pdfPage);
  13227. case 11:
  13228. _context3.prev = 11;
  13229. _context3.t0 = _context3["catch"](2);
  13230. console.error("Unable to get page for page view", _context3.t0);
  13231. return _context3.abrupt("return", null);
  13232. case 15:
  13233. case "end":
  13234. return _context3.stop();
  13235. }
  13236. }
  13237. }, _callee2, this, [[2, 11]]);
  13238. }));
  13239. return _ensurePdfPageLoaded3.apply(this, arguments);
  13240. }
  13241. function _getScrollAhead2(visible) {
  13242. var _visible$first, _visible$last;
  13243. if (((_visible$first = visible.first) === null || _visible$first === void 0 ? void 0 : _visible$first.id) === 1) {
  13244. return true;
  13245. } else if (((_visible$last = visible.last) === null || _visible$last === void 0 ? void 0 : _visible$last.id) === this.pagesCount) {
  13246. return false;
  13247. }
  13248. switch (this._scrollMode) {
  13249. case _ui_utils.ScrollMode.PAGE:
  13250. return _classPrivateFieldGet(this, _scrollModePageState).scrollDown;
  13251. case _ui_utils.ScrollMode.HORIZONTAL:
  13252. return this.scroll.right;
  13253. }
  13254. return this.scroll.down;
  13255. }
  13256. function _toggleLoadingIconSpinner2(visibleIds) {
  13257. var _iterator13 = _createForOfIteratorHelper(visibleIds),
  13258. _step13;
  13259. try {
  13260. for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
  13261. var id = _step13.value;
  13262. var pageView = this._pages[id - 1];
  13263. pageView === null || pageView === void 0 ? void 0 : pageView.toggleLoadingIconSpinner(true);
  13264. }
  13265. } catch (err) {
  13266. _iterator13.e(err);
  13267. } finally {
  13268. _iterator13.f();
  13269. }
  13270. var _iterator14 = _createForOfIteratorHelper(_classPrivateFieldGet(this, _buffer)),
  13271. _step14;
  13272. try {
  13273. for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
  13274. var _pageView2 = _step14.value;
  13275. if (visibleIds.has(_pageView2.id)) {
  13276. continue;
  13277. }
  13278. _pageView2.toggleLoadingIconSpinner(false);
  13279. }
  13280. } catch (err) {
  13281. _iterator14.e(err);
  13282. } finally {
  13283. _iterator14.f();
  13284. }
  13285. }
  13286. /***/ }),
  13287. /* 32 */
  13288. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13289. Object.defineProperty(exports, "__esModule", ({
  13290. value: true
  13291. }));
  13292. exports.AnnotationLayerBuilder = void 0;
  13293. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  13294. var _pdfjsLib = __webpack_require__(7);
  13295. var _l10n_utils = __webpack_require__(33);
  13296. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13297. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  13298. 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."); }
  13299. 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); }
  13300. 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; }
  13301. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
  13302. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  13303. 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); } }
  13304. 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); }); }; }
  13305. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13306. 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); } }
  13307. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  13308. var AnnotationLayerBuilder = /*#__PURE__*/function () {
  13309. function AnnotationLayerBuilder(_ref) {
  13310. var pageDiv = _ref.pageDiv,
  13311. pdfPage = _ref.pdfPage,
  13312. linkService = _ref.linkService,
  13313. downloadManager = _ref.downloadManager,
  13314. _ref$annotationStorag = _ref.annotationStorage,
  13315. annotationStorage = _ref$annotationStorag === void 0 ? null : _ref$annotationStorag,
  13316. _ref$imageResourcesPa = _ref.imageResourcesPath,
  13317. imageResourcesPath = _ref$imageResourcesPa === void 0 ? "" : _ref$imageResourcesPa,
  13318. _ref$renderForms = _ref.renderForms,
  13319. renderForms = _ref$renderForms === void 0 ? true : _ref$renderForms,
  13320. _ref$l10n = _ref.l10n,
  13321. l10n = _ref$l10n === void 0 ? _l10n_utils.NullL10n : _ref$l10n,
  13322. _ref$enableScripting = _ref.enableScripting,
  13323. enableScripting = _ref$enableScripting === void 0 ? false : _ref$enableScripting,
  13324. _ref$hasJSActionsProm = _ref.hasJSActionsPromise,
  13325. hasJSActionsPromise = _ref$hasJSActionsProm === void 0 ? null : _ref$hasJSActionsProm,
  13326. _ref$fieldObjectsProm = _ref.fieldObjectsPromise,
  13327. fieldObjectsPromise = _ref$fieldObjectsProm === void 0 ? null : _ref$fieldObjectsProm,
  13328. _ref$mouseState = _ref.mouseState,
  13329. mouseState = _ref$mouseState === void 0 ? null : _ref$mouseState,
  13330. _ref$annotationCanvas = _ref.annotationCanvasMap,
  13331. annotationCanvasMap = _ref$annotationCanvas === void 0 ? null : _ref$annotationCanvas;
  13332. _classCallCheck(this, AnnotationLayerBuilder);
  13333. this.pageDiv = pageDiv;
  13334. this.pdfPage = pdfPage;
  13335. this.linkService = linkService;
  13336. this.downloadManager = downloadManager;
  13337. this.imageResourcesPath = imageResourcesPath;
  13338. this.renderForms = renderForms;
  13339. this.l10n = l10n;
  13340. this.annotationStorage = annotationStorage;
  13341. this.enableScripting = enableScripting;
  13342. this._hasJSActionsPromise = hasJSActionsPromise;
  13343. this._fieldObjectsPromise = fieldObjectsPromise;
  13344. this._mouseState = mouseState;
  13345. this._annotationCanvasMap = annotationCanvasMap;
  13346. this.div = null;
  13347. this._cancelled = false;
  13348. }
  13349. _createClass(AnnotationLayerBuilder, [{
  13350. key: "render",
  13351. value: function () {
  13352. var _render = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(viewport) {
  13353. var intent,
  13354. _yield$Promise$all,
  13355. _yield$Promise$all2,
  13356. annotations,
  13357. _yield$Promise$all2$,
  13358. hasJSActions,
  13359. _yield$Promise$all2$2,
  13360. fieldObjects,
  13361. parameters,
  13362. _args = arguments;
  13363. return _regenerator["default"].wrap(function _callee$(_context) {
  13364. while (1) {
  13365. switch (_context.prev = _context.next) {
  13366. case 0:
  13367. intent = _args.length > 1 && _args[1] !== undefined ? _args[1] : "display";
  13368. _context.next = 3;
  13369. return Promise.all([this.pdfPage.getAnnotations({
  13370. intent: intent
  13371. }), this._hasJSActionsPromise, this._fieldObjectsPromise]);
  13372. case 3:
  13373. _yield$Promise$all = _context.sent;
  13374. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
  13375. annotations = _yield$Promise$all2[0];
  13376. _yield$Promise$all2$ = _yield$Promise$all2[1];
  13377. hasJSActions = _yield$Promise$all2$ === void 0 ? false : _yield$Promise$all2$;
  13378. _yield$Promise$all2$2 = _yield$Promise$all2[2];
  13379. fieldObjects = _yield$Promise$all2$2 === void 0 ? null : _yield$Promise$all2$2;
  13380. if (!(this._cancelled || annotations.length === 0)) {
  13381. _context.next = 12;
  13382. break;
  13383. }
  13384. return _context.abrupt("return");
  13385. case 12:
  13386. parameters = {
  13387. viewport: viewport.clone({
  13388. dontFlip: true
  13389. }),
  13390. div: this.div,
  13391. annotations: annotations,
  13392. page: this.pdfPage,
  13393. imageResourcesPath: this.imageResourcesPath,
  13394. renderForms: this.renderForms,
  13395. linkService: this.linkService,
  13396. downloadManager: this.downloadManager,
  13397. annotationStorage: this.annotationStorage,
  13398. enableScripting: this.enableScripting,
  13399. hasJSActions: hasJSActions,
  13400. fieldObjects: fieldObjects,
  13401. mouseState: this._mouseState,
  13402. annotationCanvasMap: this._annotationCanvasMap
  13403. };
  13404. if (this.div) {
  13405. _pdfjsLib.AnnotationLayer.update(parameters);
  13406. } else {
  13407. this.div = document.createElement("div");
  13408. this.div.className = "annotationLayer";
  13409. this.pageDiv.appendChild(this.div);
  13410. parameters.div = this.div;
  13411. _pdfjsLib.AnnotationLayer.render(parameters);
  13412. this.l10n.translate(this.div);
  13413. }
  13414. case 14:
  13415. case "end":
  13416. return _context.stop();
  13417. }
  13418. }
  13419. }, _callee, this);
  13420. }));
  13421. function render(_x) {
  13422. return _render.apply(this, arguments);
  13423. }
  13424. return render;
  13425. }()
  13426. }, {
  13427. key: "cancel",
  13428. value: function cancel() {
  13429. this._cancelled = true;
  13430. }
  13431. }, {
  13432. key: "hide",
  13433. value: function hide() {
  13434. if (!this.div) {
  13435. return;
  13436. }
  13437. this.div.hidden = true;
  13438. }
  13439. }]);
  13440. return AnnotationLayerBuilder;
  13441. }();
  13442. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  13443. /***/ }),
  13444. /* 33 */
  13445. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13446. Object.defineProperty(exports, "__esModule", ({
  13447. value: true
  13448. }));
  13449. exports.NullL10n = void 0;
  13450. exports.fixupLangCode = fixupLangCode;
  13451. exports.getL10nFallback = getL10nFallback;
  13452. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  13453. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13454. 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); } }
  13455. 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); }); }; }
  13456. var DEFAULT_L10N_STRINGS = {
  13457. of_pages: "of {{pagesCount}}",
  13458. page_of_pages: "({{pageNumber}} of {{pagesCount}})",
  13459. document_properties_kb: "{{size_kb}} KB ({{size_b}} bytes)",
  13460. document_properties_mb: "{{size_mb}} MB ({{size_b}} bytes)",
  13461. document_properties_date_string: "{{date}}, {{time}}",
  13462. document_properties_page_size_unit_inches: "in",
  13463. document_properties_page_size_unit_millimeters: "mm",
  13464. document_properties_page_size_orientation_portrait: "portrait",
  13465. document_properties_page_size_orientation_landscape: "landscape",
  13466. document_properties_page_size_name_a3: "A3",
  13467. document_properties_page_size_name_a4: "A4",
  13468. document_properties_page_size_name_letter: "Letter",
  13469. document_properties_page_size_name_legal: "Legal",
  13470. document_properties_page_size_dimension_string: "{{width}} × {{height}} {{unit}} ({{orientation}})",
  13471. document_properties_page_size_dimension_name_string: "{{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})",
  13472. document_properties_linearized_yes: "Yes",
  13473. document_properties_linearized_no: "No",
  13474. print_progress_percent: "{{progress}}%",
  13475. "toggle_sidebar.title": "Toggle Sidebar",
  13476. "toggle_sidebar_notification2.title": "Toggle Sidebar (document contains outline/attachments/layers)",
  13477. additional_layers: "Additional Layers",
  13478. page_landmark: "Page {{page}}",
  13479. thumb_page_title: "Page {{page}}",
  13480. thumb_page_canvas: "Thumbnail of Page {{page}}",
  13481. find_reached_top: "Reached top of document, continued from bottom",
  13482. find_reached_bottom: "Reached end of document, continued from top",
  13483. "find_match_count[one]": "{{current}} of {{total}} match",
  13484. "find_match_count[other]": "{{current}} of {{total}} matches",
  13485. "find_match_count_limit[one]": "More than {{limit}} match",
  13486. "find_match_count_limit[other]": "More than {{limit}} matches",
  13487. find_not_found: "Phrase not found",
  13488. error_version_info: "PDF.js v{{version}} (build: {{build}})",
  13489. error_message: "Message: {{message}}",
  13490. error_stack: "Stack: {{stack}}",
  13491. error_file: "File: {{file}}",
  13492. error_line: "Line: {{line}}",
  13493. rendering_error: "An error occurred while rendering the page.",
  13494. page_scale_width: "Page Width",
  13495. page_scale_fit: "Page Fit",
  13496. page_scale_auto: "Automatic Zoom",
  13497. page_scale_actual: "Actual Size",
  13498. page_scale_percent: "{{scale}}%",
  13499. loading: "Loading…",
  13500. loading_error: "An error occurred while loading the PDF.",
  13501. invalid_file_error: "Invalid or corrupted PDF file.",
  13502. missing_file_error: "Missing PDF file.",
  13503. unexpected_response_error: "Unexpected server response.",
  13504. printing_not_supported: "Warning: Printing is not fully supported by this browser.",
  13505. printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
  13506. web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts."
  13507. };
  13508. function getL10nFallback(key, args) {
  13509. switch (key) {
  13510. case "find_match_count":
  13511. key = "find_match_count[".concat(args.total === 1 ? "one" : "other", "]");
  13512. break;
  13513. case "find_match_count_limit":
  13514. key = "find_match_count_limit[".concat(args.limit === 1 ? "one" : "other", "]");
  13515. break;
  13516. }
  13517. return DEFAULT_L10N_STRINGS[key] || "";
  13518. }
  13519. var PARTIAL_LANG_CODES = {
  13520. en: "en-US",
  13521. es: "es-ES",
  13522. fy: "fy-NL",
  13523. ga: "ga-IE",
  13524. gu: "gu-IN",
  13525. hi: "hi-IN",
  13526. hy: "hy-AM",
  13527. nb: "nb-NO",
  13528. ne: "ne-NP",
  13529. nn: "nn-NO",
  13530. pa: "pa-IN",
  13531. pt: "pt-PT",
  13532. sv: "sv-SE",
  13533. zh: "zh-CN"
  13534. };
  13535. function fixupLangCode(langCode) {
  13536. return PARTIAL_LANG_CODES[langCode === null || langCode === void 0 ? void 0 : langCode.toLowerCase()] || langCode;
  13537. }
  13538. function formatL10nValue(text, args) {
  13539. if (!args) {
  13540. return text;
  13541. }
  13542. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  13543. return name in args ? args[name] : "{{" + name + "}}";
  13544. });
  13545. }
  13546. var NullL10n = {
  13547. getLanguage: function getLanguage() {
  13548. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  13549. return _regenerator["default"].wrap(function _callee$(_context) {
  13550. while (1) {
  13551. switch (_context.prev = _context.next) {
  13552. case 0:
  13553. return _context.abrupt("return", "en-us");
  13554. case 1:
  13555. case "end":
  13556. return _context.stop();
  13557. }
  13558. }
  13559. }, _callee);
  13560. }))();
  13561. },
  13562. getDirection: function getDirection() {
  13563. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  13564. return _regenerator["default"].wrap(function _callee2$(_context2) {
  13565. while (1) {
  13566. switch (_context2.prev = _context2.next) {
  13567. case 0:
  13568. return _context2.abrupt("return", "ltr");
  13569. case 1:
  13570. case "end":
  13571. return _context2.stop();
  13572. }
  13573. }
  13574. }, _callee2);
  13575. }))();
  13576. },
  13577. get: function get(key) {
  13578. var _arguments = arguments;
  13579. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  13580. var args, fallback;
  13581. return _regenerator["default"].wrap(function _callee3$(_context3) {
  13582. while (1) {
  13583. switch (_context3.prev = _context3.next) {
  13584. case 0:
  13585. args = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : null;
  13586. fallback = _arguments.length > 2 && _arguments[2] !== undefined ? _arguments[2] : getL10nFallback(key, args);
  13587. return _context3.abrupt("return", formatL10nValue(fallback, args));
  13588. case 3:
  13589. case "end":
  13590. return _context3.stop();
  13591. }
  13592. }
  13593. }, _callee3);
  13594. }))();
  13595. },
  13596. translate: function translate(element) {
  13597. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  13598. return _regenerator["default"].wrap(function _callee4$(_context4) {
  13599. while (1) {
  13600. switch (_context4.prev = _context4.next) {
  13601. case 0:
  13602. case "end":
  13603. return _context4.stop();
  13604. }
  13605. }
  13606. }, _callee4);
  13607. }))();
  13608. }
  13609. };
  13610. exports.NullL10n = NullL10n;
  13611. /***/ }),
  13612. /* 34 */
  13613. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13614. Object.defineProperty(exports, "__esModule", ({
  13615. value: true
  13616. }));
  13617. exports.PDFPageView = void 0;
  13618. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  13619. var _pdfjsLib = __webpack_require__(7);
  13620. var _ui_utils = __webpack_require__(5);
  13621. var _app_options = __webpack_require__(1);
  13622. var _l10n_utils = __webpack_require__(33);
  13623. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13624. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
  13625. 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); }
  13626. 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; }
  13627. 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); } }
  13628. 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); }); }; }
  13629. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13630. 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); } }
  13631. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  13632. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  13633. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  13634. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  13635. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  13636. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  13637. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  13638. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  13639. var MAX_CANVAS_PIXELS = _app_options.compatibilityParams.maxCanvasPixels || 16777216;
  13640. var _annotationMode = /*#__PURE__*/new WeakMap();
  13641. var PDFPageView = /*#__PURE__*/function () {
  13642. function PDFPageView(options) {
  13643. var _options$textLayerMod, _options$annotationMo, _options$textHighligh, _this$renderingQueue;
  13644. _classCallCheck(this, PDFPageView);
  13645. _classPrivateFieldInitSpec(this, _annotationMode, {
  13646. writable: true,
  13647. value: _pdfjsLib.AnnotationMode.ENABLE_FORMS
  13648. });
  13649. var container = options.container;
  13650. var defaultViewport = options.defaultViewport;
  13651. this.id = options.id;
  13652. this.renderingId = "page" + this.id;
  13653. this.pdfPage = null;
  13654. this.pageLabel = null;
  13655. this.rotation = 0;
  13656. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  13657. this.viewport = defaultViewport;
  13658. this.pdfPageRotate = defaultViewport.rotation;
  13659. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  13660. this.hasRestrictedScaling = false;
  13661. this.textLayerMode = (_options$textLayerMod = options.textLayerMode) !== null && _options$textLayerMod !== void 0 ? _options$textLayerMod : _ui_utils.TextLayerMode.ENABLE;
  13662. _classPrivateFieldSet(this, _annotationMode, (_options$annotationMo = options.annotationMode) !== null && _options$annotationMo !== void 0 ? _options$annotationMo : _pdfjsLib.AnnotationMode.ENABLE_FORMS);
  13663. this.imageResourcesPath = options.imageResourcesPath || "";
  13664. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  13665. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  13666. this.pageColors = options.pageColors || null;
  13667. this.eventBus = options.eventBus;
  13668. this.renderingQueue = options.renderingQueue;
  13669. this.textLayerFactory = options.textLayerFactory;
  13670. this.annotationLayerFactory = options.annotationLayerFactory;
  13671. this.xfaLayerFactory = options.xfaLayerFactory;
  13672. this.textHighlighter = (_options$textHighligh = options.textHighlighterFactory) === null || _options$textHighligh === void 0 ? void 0 : _options$textHighligh.createTextHighlighter(this.id - 1, this.eventBus);
  13673. this.structTreeLayerFactory = options.structTreeLayerFactory;
  13674. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  13675. this.l10n = options.l10n || _l10n_utils.NullL10n;
  13676. this.paintTask = null;
  13677. this.paintedViewportMap = new WeakMap();
  13678. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  13679. this.resume = null;
  13680. this._renderError = null;
  13681. this._isStandalone = !((_this$renderingQueue = this.renderingQueue) !== null && _this$renderingQueue !== void 0 && _this$renderingQueue.hasViewer());
  13682. this._annotationCanvasMap = null;
  13683. this.annotationLayer = null;
  13684. this.textLayer = null;
  13685. this.zoomLayer = null;
  13686. this.xfaLayer = null;
  13687. this.structTreeLayer = null;
  13688. var div = document.createElement("div");
  13689. div.className = "page";
  13690. div.style.width = Math.floor(this.viewport.width) + "px";
  13691. div.style.height = Math.floor(this.viewport.height) + "px";
  13692. div.setAttribute("data-page-number", this.id);
  13693. div.setAttribute("role", "region");
  13694. this.l10n.get("page_landmark", {
  13695. page: this.id
  13696. }).then(function (msg) {
  13697. div.setAttribute("aria-label", msg);
  13698. });
  13699. this.div = div;
  13700. container === null || container === void 0 ? void 0 : container.appendChild(div);
  13701. }
  13702. _createClass(PDFPageView, [{
  13703. key: "setPdfPage",
  13704. value: function setPdfPage(pdfPage) {
  13705. this.pdfPage = pdfPage;
  13706. this.pdfPageRotate = pdfPage.rotate;
  13707. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  13708. this.viewport = pdfPage.getViewport({
  13709. scale: this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS,
  13710. rotation: totalRotation
  13711. });
  13712. this.reset();
  13713. }
  13714. }, {
  13715. key: "destroy",
  13716. value: function destroy() {
  13717. this.reset();
  13718. if (this.pdfPage) {
  13719. this.pdfPage.cleanup();
  13720. }
  13721. }
  13722. }, {
  13723. key: "_renderAnnotationLayer",
  13724. value: function () {
  13725. var _renderAnnotationLayer2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  13726. var error;
  13727. return _regenerator["default"].wrap(function _callee$(_context) {
  13728. while (1) {
  13729. switch (_context.prev = _context.next) {
  13730. case 0:
  13731. error = null;
  13732. _context.prev = 1;
  13733. _context.next = 4;
  13734. return this.annotationLayer.render(this.viewport, "display");
  13735. case 4:
  13736. _context.next = 9;
  13737. break;
  13738. case 6:
  13739. _context.prev = 6;
  13740. _context.t0 = _context["catch"](1);
  13741. error = _context.t0;
  13742. case 9:
  13743. _context.prev = 9;
  13744. this.eventBus.dispatch("annotationlayerrendered", {
  13745. source: this,
  13746. pageNumber: this.id,
  13747. error: error
  13748. });
  13749. return _context.finish(9);
  13750. case 12:
  13751. case "end":
  13752. return _context.stop();
  13753. }
  13754. }
  13755. }, _callee, this, [[1, 6, 9, 12]]);
  13756. }));
  13757. function _renderAnnotationLayer() {
  13758. return _renderAnnotationLayer2.apply(this, arguments);
  13759. }
  13760. return _renderAnnotationLayer;
  13761. }()
  13762. }, {
  13763. key: "_renderXfaLayer",
  13764. value: function () {
  13765. var _renderXfaLayer2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  13766. var error, result;
  13767. return _regenerator["default"].wrap(function _callee2$(_context2) {
  13768. while (1) {
  13769. switch (_context2.prev = _context2.next) {
  13770. case 0:
  13771. error = null;
  13772. _context2.prev = 1;
  13773. _context2.next = 4;
  13774. return this.xfaLayer.render(this.viewport, "display");
  13775. case 4:
  13776. result = _context2.sent;
  13777. if (this.textHighlighter) {
  13778. this._buildXfaTextContentItems(result.textDivs);
  13779. }
  13780. _context2.next = 11;
  13781. break;
  13782. case 8:
  13783. _context2.prev = 8;
  13784. _context2.t0 = _context2["catch"](1);
  13785. error = _context2.t0;
  13786. case 11:
  13787. _context2.prev = 11;
  13788. this.eventBus.dispatch("xfalayerrendered", {
  13789. source: this,
  13790. pageNumber: this.id,
  13791. error: error
  13792. });
  13793. return _context2.finish(11);
  13794. case 14:
  13795. case "end":
  13796. return _context2.stop();
  13797. }
  13798. }
  13799. }, _callee2, this, [[1, 8, 11, 14]]);
  13800. }));
  13801. function _renderXfaLayer() {
  13802. return _renderXfaLayer2.apply(this, arguments);
  13803. }
  13804. return _renderXfaLayer;
  13805. }()
  13806. }, {
  13807. key: "_buildXfaTextContentItems",
  13808. value: function () {
  13809. var _buildXfaTextContentItems2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(textDivs) {
  13810. var text, items, _iterator, _step, item;
  13811. return _regenerator["default"].wrap(function _callee3$(_context3) {
  13812. while (1) {
  13813. switch (_context3.prev = _context3.next) {
  13814. case 0:
  13815. _context3.next = 2;
  13816. return this.pdfPage.getTextContent();
  13817. case 2:
  13818. text = _context3.sent;
  13819. items = [];
  13820. _iterator = _createForOfIteratorHelper(text.items);
  13821. try {
  13822. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  13823. item = _step.value;
  13824. items.push(item.str);
  13825. }
  13826. } catch (err) {
  13827. _iterator.e(err);
  13828. } finally {
  13829. _iterator.f();
  13830. }
  13831. this.textHighlighter.setTextMapping(textDivs, items);
  13832. this.textHighlighter.enable();
  13833. case 8:
  13834. case "end":
  13835. return _context3.stop();
  13836. }
  13837. }
  13838. }, _callee3, this);
  13839. }));
  13840. function _buildXfaTextContentItems(_x) {
  13841. return _buildXfaTextContentItems2.apply(this, arguments);
  13842. }
  13843. return _buildXfaTextContentItems;
  13844. }()
  13845. }, {
  13846. key: "_resetZoomLayer",
  13847. value: function _resetZoomLayer() {
  13848. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  13849. if (!this.zoomLayer) {
  13850. return;
  13851. }
  13852. var zoomLayerCanvas = this.zoomLayer.firstChild;
  13853. this.paintedViewportMap["delete"](zoomLayerCanvas);
  13854. zoomLayerCanvas.width = 0;
  13855. zoomLayerCanvas.height = 0;
  13856. if (removeFromDOM) {
  13857. this.zoomLayer.remove();
  13858. }
  13859. this.zoomLayer = null;
  13860. }
  13861. }, {
  13862. key: "reset",
  13863. value: function reset() {
  13864. var _this$annotationLayer,
  13865. _this$xfaLayer,
  13866. _this = this;
  13867. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  13868. _ref$keepZoomLayer = _ref.keepZoomLayer,
  13869. keepZoomLayer = _ref$keepZoomLayer === void 0 ? false : _ref$keepZoomLayer,
  13870. _ref$keepAnnotationLa = _ref.keepAnnotationLayer,
  13871. keepAnnotationLayer = _ref$keepAnnotationLa === void 0 ? false : _ref$keepAnnotationLa,
  13872. _ref$keepXfaLayer = _ref.keepXfaLayer,
  13873. keepXfaLayer = _ref$keepXfaLayer === void 0 ? false : _ref$keepXfaLayer;
  13874. this.cancelRendering({
  13875. keepAnnotationLayer: keepAnnotationLayer,
  13876. keepXfaLayer: keepXfaLayer
  13877. });
  13878. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  13879. var div = this.div;
  13880. div.style.width = Math.floor(this.viewport.width) + "px";
  13881. div.style.height = Math.floor(this.viewport.height) + "px";
  13882. var childNodes = div.childNodes,
  13883. zoomLayerNode = keepZoomLayer && this.zoomLayer || null,
  13884. annotationLayerNode = keepAnnotationLayer && ((_this$annotationLayer = this.annotationLayer) === null || _this$annotationLayer === void 0 ? void 0 : _this$annotationLayer.div) || null,
  13885. xfaLayerNode = keepXfaLayer && ((_this$xfaLayer = this.xfaLayer) === null || _this$xfaLayer === void 0 ? void 0 : _this$xfaLayer.div) || null;
  13886. for (var i = childNodes.length - 1; i >= 0; i--) {
  13887. var node = childNodes[i];
  13888. switch (node) {
  13889. case zoomLayerNode:
  13890. case annotationLayerNode:
  13891. case xfaLayerNode:
  13892. continue;
  13893. }
  13894. node.remove();
  13895. }
  13896. div.removeAttribute("data-loaded");
  13897. if (annotationLayerNode) {
  13898. this.annotationLayer.hide();
  13899. }
  13900. if (xfaLayerNode) {
  13901. this.xfaLayer.hide();
  13902. }
  13903. if (!zoomLayerNode) {
  13904. if (this.canvas) {
  13905. this.paintedViewportMap["delete"](this.canvas);
  13906. this.canvas.width = 0;
  13907. this.canvas.height = 0;
  13908. delete this.canvas;
  13909. }
  13910. this._resetZoomLayer();
  13911. }
  13912. if (this.svg) {
  13913. this.paintedViewportMap["delete"](this.svg);
  13914. delete this.svg;
  13915. }
  13916. this.loadingIconDiv = document.createElement("div");
  13917. this.loadingIconDiv.className = "loadingIcon notVisible";
  13918. if (this._isStandalone) {
  13919. this.toggleLoadingIconSpinner(true);
  13920. }
  13921. this.loadingIconDiv.setAttribute("role", "img");
  13922. this.l10n.get("loading").then(function (msg) {
  13923. var _this$loadingIconDiv;
  13924. (_this$loadingIconDiv = _this.loadingIconDiv) === null || _this$loadingIconDiv === void 0 ? void 0 : _this$loadingIconDiv.setAttribute("aria-label", msg);
  13925. });
  13926. div.appendChild(this.loadingIconDiv);
  13927. }
  13928. }, {
  13929. key: "update",
  13930. value: function update(_ref2) {
  13931. var _ref2$scale = _ref2.scale,
  13932. scale = _ref2$scale === void 0 ? 0 : _ref2$scale,
  13933. _ref2$rotation = _ref2.rotation,
  13934. rotation = _ref2$rotation === void 0 ? null : _ref2$rotation,
  13935. _ref2$optionalContent = _ref2.optionalContentConfigPromise,
  13936. optionalContentConfigPromise = _ref2$optionalContent === void 0 ? null : _ref2$optionalContent;
  13937. this.scale = scale || this.scale;
  13938. if (typeof rotation === "number") {
  13939. this.rotation = rotation;
  13940. }
  13941. if (optionalContentConfigPromise instanceof Promise) {
  13942. this._optionalContentConfigPromise = optionalContentConfigPromise;
  13943. }
  13944. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  13945. this.viewport = this.viewport.clone({
  13946. scale: this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS,
  13947. rotation: totalRotation
  13948. });
  13949. if (this._isStandalone) {
  13950. var style = document.documentElement.style;
  13951. style.setProperty("--zoom-factor", this.scale);
  13952. }
  13953. if (this.svg) {
  13954. this.cssTransform({
  13955. target: this.svg,
  13956. redrawAnnotationLayer: true,
  13957. redrawXfaLayer: true
  13958. });
  13959. this.eventBus.dispatch("pagerendered", {
  13960. source: this,
  13961. pageNumber: this.id,
  13962. cssTransform: true,
  13963. timestamp: performance.now(),
  13964. error: this._renderError
  13965. });
  13966. return;
  13967. }
  13968. var isScalingRestricted = false;
  13969. if (this.canvas && this.maxCanvasPixels > 0) {
  13970. var outputScale = this.outputScale;
  13971. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  13972. isScalingRestricted = true;
  13973. }
  13974. }
  13975. if (this.canvas) {
  13976. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  13977. this.cssTransform({
  13978. target: this.canvas,
  13979. redrawAnnotationLayer: true,
  13980. redrawXfaLayer: true
  13981. });
  13982. this.eventBus.dispatch("pagerendered", {
  13983. source: this,
  13984. pageNumber: this.id,
  13985. cssTransform: true,
  13986. timestamp: performance.now(),
  13987. error: this._renderError
  13988. });
  13989. return;
  13990. }
  13991. if (!this.zoomLayer && !this.canvas.hidden) {
  13992. this.zoomLayer = this.canvas.parentNode;
  13993. this.zoomLayer.style.position = "absolute";
  13994. }
  13995. }
  13996. if (this.zoomLayer) {
  13997. this.cssTransform({
  13998. target: this.zoomLayer.firstChild
  13999. });
  14000. }
  14001. this.reset({
  14002. keepZoomLayer: true,
  14003. keepAnnotationLayer: true,
  14004. keepXfaLayer: true
  14005. });
  14006. }
  14007. }, {
  14008. key: "cancelRendering",
  14009. value: function cancelRendering() {
  14010. var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  14011. _ref3$keepAnnotationL = _ref3.keepAnnotationLayer,
  14012. keepAnnotationLayer = _ref3$keepAnnotationL === void 0 ? false : _ref3$keepAnnotationL,
  14013. _ref3$keepXfaLayer = _ref3.keepXfaLayer,
  14014. keepXfaLayer = _ref3$keepXfaLayer === void 0 ? false : _ref3$keepXfaLayer;
  14015. if (this.paintTask) {
  14016. this.paintTask.cancel();
  14017. this.paintTask = null;
  14018. }
  14019. this.resume = null;
  14020. if (this.textLayer) {
  14021. this.textLayer.cancel();
  14022. this.textLayer = null;
  14023. }
  14024. if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) {
  14025. this.annotationLayer.cancel();
  14026. this.annotationLayer = null;
  14027. this._annotationCanvasMap = null;
  14028. }
  14029. if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) {
  14030. var _this$textHighlighter;
  14031. this.xfaLayer.cancel();
  14032. this.xfaLayer = null;
  14033. (_this$textHighlighter = this.textHighlighter) === null || _this$textHighlighter === void 0 ? void 0 : _this$textHighlighter.disable();
  14034. }
  14035. if (this._onTextLayerRendered) {
  14036. this.eventBus._off("textlayerrendered", this._onTextLayerRendered);
  14037. this._onTextLayerRendered = null;
  14038. }
  14039. }
  14040. }, {
  14041. key: "cssTransform",
  14042. value: function cssTransform(_ref4) {
  14043. var target = _ref4.target,
  14044. _ref4$redrawAnnotatio = _ref4.redrawAnnotationLayer,
  14045. redrawAnnotationLayer = _ref4$redrawAnnotatio === void 0 ? false : _ref4$redrawAnnotatio,
  14046. _ref4$redrawXfaLayer = _ref4.redrawXfaLayer,
  14047. redrawXfaLayer = _ref4$redrawXfaLayer === void 0 ? false : _ref4$redrawXfaLayer;
  14048. var width = this.viewport.width;
  14049. var height = this.viewport.height;
  14050. var div = this.div;
  14051. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
  14052. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
  14053. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  14054. var absRotation = Math.abs(relativeRotation);
  14055. var scaleX = 1,
  14056. scaleY = 1;
  14057. if (absRotation === 90 || absRotation === 270) {
  14058. scaleX = height / width;
  14059. scaleY = width / height;
  14060. }
  14061. target.style.transform = "rotate(".concat(relativeRotation, "deg) scale(").concat(scaleX, ", ").concat(scaleY, ")");
  14062. if (this.textLayer) {
  14063. var textLayerViewport = this.textLayer.viewport;
  14064. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  14065. var textAbsRotation = Math.abs(textRelativeRotation);
  14066. var scale = width / textLayerViewport.width;
  14067. if (textAbsRotation === 90 || textAbsRotation === 270) {
  14068. scale = width / textLayerViewport.height;
  14069. }
  14070. var textLayerDiv = this.textLayer.textLayerDiv;
  14071. var transX, transY;
  14072. switch (textAbsRotation) {
  14073. case 0:
  14074. transX = transY = 0;
  14075. break;
  14076. case 90:
  14077. transX = 0;
  14078. transY = "-" + textLayerDiv.style.height;
  14079. break;
  14080. case 180:
  14081. transX = "-" + textLayerDiv.style.width;
  14082. transY = "-" + textLayerDiv.style.height;
  14083. break;
  14084. case 270:
  14085. transX = "-" + textLayerDiv.style.width;
  14086. transY = 0;
  14087. break;
  14088. default:
  14089. console.error("Bad rotation value.");
  14090. break;
  14091. }
  14092. textLayerDiv.style.transform = "rotate(".concat(textAbsRotation, "deg) ") + "scale(".concat(scale, ") ") + "translate(".concat(transX, ", ").concat(transY, ")");
  14093. textLayerDiv.style.transformOrigin = "0% 0%";
  14094. }
  14095. if (redrawAnnotationLayer && this.annotationLayer) {
  14096. this._renderAnnotationLayer();
  14097. }
  14098. if (redrawXfaLayer && this.xfaLayer) {
  14099. this._renderXfaLayer();
  14100. }
  14101. }
  14102. }, {
  14103. key: "width",
  14104. get: function get() {
  14105. return this.viewport.width;
  14106. }
  14107. }, {
  14108. key: "height",
  14109. get: function get() {
  14110. return this.viewport.height;
  14111. }
  14112. }, {
  14113. key: "getPagePoint",
  14114. value: function getPagePoint(x, y) {
  14115. return this.viewport.convertToPdfPoint(x, y);
  14116. }
  14117. }, {
  14118. key: "toggleLoadingIconSpinner",
  14119. value: function toggleLoadingIconSpinner() {
  14120. var _this$loadingIconDiv2;
  14121. var viewVisible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  14122. (_this$loadingIconDiv2 = this.loadingIconDiv) === null || _this$loadingIconDiv2 === void 0 ? void 0 : _this$loadingIconDiv2.classList.toggle("notVisible", !viewVisible);
  14123. }
  14124. }, {
  14125. key: "draw",
  14126. value: function draw() {
  14127. var _this$annotationLayer2,
  14128. _this$xfaLayer2,
  14129. _this2 = this;
  14130. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  14131. console.error("Must be in new state before drawing");
  14132. this.reset();
  14133. }
  14134. var div = this.div,
  14135. pdfPage = this.pdfPage;
  14136. if (!pdfPage) {
  14137. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  14138. if (this.loadingIconDiv) {
  14139. this.loadingIconDiv.remove();
  14140. delete this.loadingIconDiv;
  14141. }
  14142. return Promise.reject(new Error("pdfPage is not loaded"));
  14143. }
  14144. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  14145. var canvasWrapper = document.createElement("div");
  14146. canvasWrapper.style.width = div.style.width;
  14147. canvasWrapper.style.height = div.style.height;
  14148. canvasWrapper.classList.add("canvasWrapper");
  14149. if ((_this$annotationLayer2 = this.annotationLayer) !== null && _this$annotationLayer2 !== void 0 && _this$annotationLayer2.div) {
  14150. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  14151. } else {
  14152. div.appendChild(canvasWrapper);
  14153. }
  14154. var textLayer = null;
  14155. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  14156. var _this$annotationLayer3;
  14157. var textLayerDiv = document.createElement("div");
  14158. textLayerDiv.className = "textLayer";
  14159. textLayerDiv.style.width = canvasWrapper.style.width;
  14160. textLayerDiv.style.height = canvasWrapper.style.height;
  14161. if ((_this$annotationLayer3 = this.annotationLayer) !== null && _this$annotationLayer3 !== void 0 && _this$annotationLayer3.div) {
  14162. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  14163. } else {
  14164. div.appendChild(textLayerDiv);
  14165. }
  14166. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, this.eventBus, this.textHighlighter);
  14167. }
  14168. this.textLayer = textLayer;
  14169. if (_classPrivateFieldGet(this, _annotationMode) !== _pdfjsLib.AnnotationMode.DISABLE && this.annotationLayerFactory) {
  14170. this._annotationCanvasMap || (this._annotationCanvasMap = new Map());
  14171. this.annotationLayer || (this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, null, this.imageResourcesPath, _classPrivateFieldGet(this, _annotationMode) === _pdfjsLib.AnnotationMode.ENABLE_FORMS, this.l10n, null, null, null, null, this._annotationCanvasMap));
  14172. }
  14173. if ((_this$xfaLayer2 = this.xfaLayer) !== null && _this$xfaLayer2 !== void 0 && _this$xfaLayer2.div) {
  14174. div.appendChild(this.xfaLayer.div);
  14175. }
  14176. var renderContinueCallback = null;
  14177. if (this.renderingQueue) {
  14178. renderContinueCallback = function renderContinueCallback(cont) {
  14179. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  14180. _this2.renderingState = _ui_utils.RenderingStates.PAUSED;
  14181. _this2.resume = function () {
  14182. _this2.renderingState = _ui_utils.RenderingStates.RUNNING;
  14183. cont();
  14184. };
  14185. return;
  14186. }
  14187. cont();
  14188. };
  14189. }
  14190. var finishPaintTask = /*#__PURE__*/function () {
  14191. var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  14192. var error,
  14193. _args4 = arguments;
  14194. return _regenerator["default"].wrap(function _callee4$(_context4) {
  14195. while (1) {
  14196. switch (_context4.prev = _context4.next) {
  14197. case 0:
  14198. error = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : null;
  14199. if (paintTask === _this2.paintTask) {
  14200. _this2.paintTask = null;
  14201. }
  14202. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  14203. _context4.next = 5;
  14204. break;
  14205. }
  14206. _this2._renderError = null;
  14207. return _context4.abrupt("return");
  14208. case 5:
  14209. _this2._renderError = error;
  14210. _this2.renderingState = _ui_utils.RenderingStates.FINISHED;
  14211. if (_this2.loadingIconDiv) {
  14212. _this2.loadingIconDiv.remove();
  14213. delete _this2.loadingIconDiv;
  14214. }
  14215. _this2._resetZoomLayer(true);
  14216. _this2.eventBus.dispatch("pagerendered", {
  14217. source: _this2,
  14218. pageNumber: _this2.id,
  14219. cssTransform: false,
  14220. timestamp: performance.now(),
  14221. error: _this2._renderError
  14222. });
  14223. if (!error) {
  14224. _context4.next = 12;
  14225. break;
  14226. }
  14227. throw error;
  14228. case 12:
  14229. case "end":
  14230. return _context4.stop();
  14231. }
  14232. }
  14233. }, _callee4);
  14234. }));
  14235. return function finishPaintTask() {
  14236. return _ref5.apply(this, arguments);
  14237. };
  14238. }();
  14239. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  14240. paintTask.onRenderContinue = renderContinueCallback;
  14241. this.paintTask = paintTask;
  14242. var resultPromise = paintTask.promise.then(function () {
  14243. return finishPaintTask(null).then(function () {
  14244. if (textLayer) {
  14245. var readableStream = pdfPage.streamTextContent({
  14246. includeMarkedContent: true
  14247. });
  14248. textLayer.setTextContentStream(readableStream);
  14249. textLayer.render();
  14250. }
  14251. if (_this2.annotationLayer) {
  14252. _this2._renderAnnotationLayer();
  14253. }
  14254. });
  14255. }, function (reason) {
  14256. return finishPaintTask(reason);
  14257. });
  14258. if (this.xfaLayerFactory) {
  14259. if (!this.xfaLayer) {
  14260. this.xfaLayer = this.xfaLayerFactory.createXfaLayerBuilder(div, pdfPage, null);
  14261. }
  14262. this._renderXfaLayer();
  14263. }
  14264. if (this.structTreeLayerFactory && this.textLayer && this.canvas) {
  14265. this._onTextLayerRendered = function (event) {
  14266. if (event.pageNumber !== _this2.id) {
  14267. return;
  14268. }
  14269. _this2.eventBus._off("textlayerrendered", _this2._onTextLayerRendered);
  14270. _this2._onTextLayerRendered = null;
  14271. if (!_this2.canvas) {
  14272. return;
  14273. }
  14274. _this2.pdfPage.getStructTree().then(function (tree) {
  14275. if (!tree) {
  14276. return;
  14277. }
  14278. if (!_this2.canvas) {
  14279. return;
  14280. }
  14281. var treeDom = _this2.structTreeLayer.render(tree);
  14282. treeDom.classList.add("structTree");
  14283. _this2.canvas.appendChild(treeDom);
  14284. });
  14285. };
  14286. this.eventBus._on("textlayerrendered", this._onTextLayerRendered);
  14287. this.structTreeLayer = this.structTreeLayerFactory.createStructTreeLayerBuilder(pdfPage);
  14288. }
  14289. div.setAttribute("data-loaded", true);
  14290. this.eventBus.dispatch("pagerender", {
  14291. source: this,
  14292. pageNumber: this.id
  14293. });
  14294. return resultPromise;
  14295. }
  14296. }, {
  14297. key: "paintOnCanvas",
  14298. value: function paintOnCanvas(canvasWrapper) {
  14299. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  14300. var result = {
  14301. promise: renderCapability.promise,
  14302. onRenderContinue: function onRenderContinue(cont) {
  14303. cont();
  14304. },
  14305. cancel: function cancel() {
  14306. renderTask.cancel();
  14307. }
  14308. };
  14309. var viewport = this.viewport;
  14310. var canvas = document.createElement("canvas");
  14311. canvas.hidden = true;
  14312. var isCanvasHidden = true;
  14313. var showCanvas = function showCanvas() {
  14314. if (isCanvasHidden) {
  14315. canvas.hidden = false;
  14316. isCanvasHidden = false;
  14317. }
  14318. };
  14319. canvasWrapper.appendChild(canvas);
  14320. this.canvas = canvas;
  14321. var ctx = canvas.getContext("2d", {
  14322. alpha: false
  14323. });
  14324. var outputScale = this.outputScale = new _ui_utils.OutputScale();
  14325. if (this.useOnlyCssZoom) {
  14326. var actualSizeViewport = viewport.clone({
  14327. scale: _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
  14328. });
  14329. outputScale.sx *= actualSizeViewport.width / viewport.width;
  14330. outputScale.sy *= actualSizeViewport.height / viewport.height;
  14331. }
  14332. if (this.maxCanvasPixels > 0) {
  14333. var pixelsInViewport = viewport.width * viewport.height;
  14334. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  14335. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  14336. outputScale.sx = maxScale;
  14337. outputScale.sy = maxScale;
  14338. this.hasRestrictedScaling = true;
  14339. } else {
  14340. this.hasRestrictedScaling = false;
  14341. }
  14342. }
  14343. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  14344. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  14345. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  14346. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  14347. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
  14348. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
  14349. this.paintedViewportMap.set(canvas, viewport);
  14350. var transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  14351. var renderContext = {
  14352. canvasContext: ctx,
  14353. transform: transform,
  14354. viewport: this.viewport,
  14355. annotationMode: _classPrivateFieldGet(this, _annotationMode),
  14356. optionalContentConfigPromise: this._optionalContentConfigPromise,
  14357. annotationCanvasMap: this._annotationCanvasMap,
  14358. pageColors: this.pageColors
  14359. };
  14360. var renderTask = this.pdfPage.render(renderContext);
  14361. renderTask.onContinue = function (cont) {
  14362. showCanvas();
  14363. if (result.onRenderContinue) {
  14364. result.onRenderContinue(cont);
  14365. } else {
  14366. cont();
  14367. }
  14368. };
  14369. renderTask.promise.then(function () {
  14370. showCanvas();
  14371. renderCapability.resolve();
  14372. }, function (error) {
  14373. showCanvas();
  14374. renderCapability.reject(error);
  14375. });
  14376. return result;
  14377. }
  14378. }, {
  14379. key: "paintOnSvg",
  14380. value: function paintOnSvg(wrapper) {
  14381. var _this3 = this;
  14382. var cancelled = false;
  14383. var ensureNotCancelled = function ensureNotCancelled() {
  14384. if (cancelled) {
  14385. throw new _pdfjsLib.RenderingCancelledException("Rendering cancelled, page ".concat(_this3.id), "svg");
  14386. }
  14387. };
  14388. var pdfPage = this.pdfPage;
  14389. var actualSizeViewport = this.viewport.clone({
  14390. scale: _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
  14391. });
  14392. var promise = pdfPage.getOperatorList({
  14393. annotationMode: _classPrivateFieldGet(this, _annotationMode)
  14394. }).then(function (opList) {
  14395. ensureNotCancelled();
  14396. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  14397. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  14398. ensureNotCancelled();
  14399. _this3.svg = svg;
  14400. _this3.paintedViewportMap.set(svg, actualSizeViewport);
  14401. svg.style.width = wrapper.style.width;
  14402. svg.style.height = wrapper.style.height;
  14403. _this3.renderingState = _ui_utils.RenderingStates.FINISHED;
  14404. wrapper.appendChild(svg);
  14405. });
  14406. });
  14407. return {
  14408. promise: promise,
  14409. onRenderContinue: function onRenderContinue(cont) {
  14410. cont();
  14411. },
  14412. cancel: function cancel() {
  14413. cancelled = true;
  14414. }
  14415. };
  14416. }
  14417. }, {
  14418. key: "setPageLabel",
  14419. value: function setPageLabel(label) {
  14420. this.pageLabel = typeof label === "string" ? label : null;
  14421. if (this.pageLabel !== null) {
  14422. this.div.setAttribute("data-page-label", this.pageLabel);
  14423. } else {
  14424. this.div.removeAttribute("data-page-label");
  14425. }
  14426. }
  14427. }]);
  14428. return PDFPageView;
  14429. }();
  14430. exports.PDFPageView = PDFPageView;
  14431. /***/ }),
  14432. /* 35 */
  14433. /***/ ((__unused_webpack_module, exports) => {
  14434. Object.defineProperty(exports, "__esModule", ({
  14435. value: true
  14436. }));
  14437. exports.StructTreeLayerBuilder = void 0;
  14438. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
  14439. 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); }
  14440. 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; }
  14441. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14442. 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); } }
  14443. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  14444. var PDF_ROLE_TO_HTML_ROLE = {
  14445. Document: null,
  14446. DocumentFragment: null,
  14447. Part: "group",
  14448. Sect: "group",
  14449. Div: "group",
  14450. Aside: "note",
  14451. NonStruct: "none",
  14452. P: null,
  14453. H: "heading",
  14454. Title: null,
  14455. FENote: "note",
  14456. Sub: "group",
  14457. Lbl: null,
  14458. Span: null,
  14459. Em: null,
  14460. Strong: null,
  14461. Link: "link",
  14462. Annot: "note",
  14463. Form: "form",
  14464. Ruby: null,
  14465. RB: null,
  14466. RT: null,
  14467. RP: null,
  14468. Warichu: null,
  14469. WT: null,
  14470. WP: null,
  14471. L: "list",
  14472. LI: "listitem",
  14473. LBody: null,
  14474. Table: "table",
  14475. TR: "row",
  14476. TH: "columnheader",
  14477. TD: "cell",
  14478. THead: "columnheader",
  14479. TBody: null,
  14480. TFoot: null,
  14481. Caption: null,
  14482. Figure: "figure",
  14483. Formula: null,
  14484. Artifact: null
  14485. };
  14486. var HEADING_PATTERN = /^H(\d+)$/;
  14487. var StructTreeLayerBuilder = /*#__PURE__*/function () {
  14488. function StructTreeLayerBuilder(_ref) {
  14489. var pdfPage = _ref.pdfPage;
  14490. _classCallCheck(this, StructTreeLayerBuilder);
  14491. this.pdfPage = pdfPage;
  14492. }
  14493. _createClass(StructTreeLayerBuilder, [{
  14494. key: "render",
  14495. value: function render(structTree) {
  14496. return this._walk(structTree);
  14497. }
  14498. }, {
  14499. key: "_setAttributes",
  14500. value: function _setAttributes(structElement, htmlElement) {
  14501. if (structElement.alt !== undefined) {
  14502. htmlElement.setAttribute("aria-label", structElement.alt);
  14503. }
  14504. if (structElement.id !== undefined) {
  14505. htmlElement.setAttribute("aria-owns", structElement.id);
  14506. }
  14507. if (structElement.lang !== undefined) {
  14508. htmlElement.setAttribute("lang", structElement.lang);
  14509. }
  14510. }
  14511. }, {
  14512. key: "_walk",
  14513. value: function _walk(node) {
  14514. if (!node) {
  14515. return null;
  14516. }
  14517. var element = document.createElement("span");
  14518. if ("role" in node) {
  14519. var role = node.role;
  14520. var match = role.match(HEADING_PATTERN);
  14521. if (match) {
  14522. element.setAttribute("role", "heading");
  14523. element.setAttribute("aria-level", match[1]);
  14524. } else if (PDF_ROLE_TO_HTML_ROLE[role]) {
  14525. element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]);
  14526. }
  14527. }
  14528. this._setAttributes(node, element);
  14529. if (node.children) {
  14530. if (node.children.length === 1 && "id" in node.children[0]) {
  14531. this._setAttributes(node.children[0], element);
  14532. } else {
  14533. var _iterator = _createForOfIteratorHelper(node.children),
  14534. _step;
  14535. try {
  14536. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  14537. var kid = _step.value;
  14538. element.appendChild(this._walk(kid));
  14539. }
  14540. } catch (err) {
  14541. _iterator.e(err);
  14542. } finally {
  14543. _iterator.f();
  14544. }
  14545. }
  14546. }
  14547. return element;
  14548. }
  14549. }]);
  14550. return StructTreeLayerBuilder;
  14551. }();
  14552. exports.StructTreeLayerBuilder = StructTreeLayerBuilder;
  14553. /***/ }),
  14554. /* 36 */
  14555. /***/ ((__unused_webpack_module, exports) => {
  14556. Object.defineProperty(exports, "__esModule", ({
  14557. value: true
  14558. }));
  14559. exports.TextHighlighter = void 0;
  14560. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14561. 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); } }
  14562. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  14563. var TextHighlighter = /*#__PURE__*/function () {
  14564. function TextHighlighter(_ref) {
  14565. var findController = _ref.findController,
  14566. eventBus = _ref.eventBus,
  14567. pageIndex = _ref.pageIndex;
  14568. _classCallCheck(this, TextHighlighter);
  14569. this.findController = findController;
  14570. this.matches = [];
  14571. this.eventBus = eventBus;
  14572. this.pageIdx = pageIndex;
  14573. this._onUpdateTextLayerMatches = null;
  14574. this.textDivs = null;
  14575. this.textContentItemsStr = null;
  14576. this.enabled = false;
  14577. }
  14578. _createClass(TextHighlighter, [{
  14579. key: "setTextMapping",
  14580. value: function setTextMapping(divs, texts) {
  14581. this.textDivs = divs;
  14582. this.textContentItemsStr = texts;
  14583. }
  14584. }, {
  14585. key: "enable",
  14586. value: function enable() {
  14587. var _this = this;
  14588. if (!this.textDivs || !this.textContentItemsStr) {
  14589. throw new Error("Text divs and strings have not been set.");
  14590. }
  14591. if (this.enabled) {
  14592. throw new Error("TextHighlighter is already enabled.");
  14593. }
  14594. this.enabled = true;
  14595. if (!this._onUpdateTextLayerMatches) {
  14596. this._onUpdateTextLayerMatches = function (evt) {
  14597. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  14598. _this._updateMatches();
  14599. }
  14600. };
  14601. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  14602. }
  14603. this._updateMatches();
  14604. }
  14605. }, {
  14606. key: "disable",
  14607. value: function disable() {
  14608. if (!this.enabled) {
  14609. return;
  14610. }
  14611. this.enabled = false;
  14612. if (this._onUpdateTextLayerMatches) {
  14613. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  14614. this._onUpdateTextLayerMatches = null;
  14615. }
  14616. }
  14617. }, {
  14618. key: "_convertMatches",
  14619. value: function _convertMatches(matches, matchesLength) {
  14620. if (!matches) {
  14621. return [];
  14622. }
  14623. var textContentItemsStr = this.textContentItemsStr;
  14624. var i = 0,
  14625. iIndex = 0;
  14626. var end = textContentItemsStr.length - 1;
  14627. var result = [];
  14628. for (var m = 0, mm = matches.length; m < mm; m++) {
  14629. var matchIdx = matches[m];
  14630. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  14631. iIndex += textContentItemsStr[i].length;
  14632. i++;
  14633. }
  14634. if (i === textContentItemsStr.length) {
  14635. console.error("Could not find a matching mapping");
  14636. }
  14637. var match = {
  14638. begin: {
  14639. divIdx: i,
  14640. offset: matchIdx - iIndex
  14641. }
  14642. };
  14643. matchIdx += matchesLength[m];
  14644. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  14645. iIndex += textContentItemsStr[i].length;
  14646. i++;
  14647. }
  14648. match.end = {
  14649. divIdx: i,
  14650. offset: matchIdx - iIndex
  14651. };
  14652. result.push(match);
  14653. }
  14654. return result;
  14655. }
  14656. }, {
  14657. key: "_renderMatches",
  14658. value: function _renderMatches(matches) {
  14659. if (matches.length === 0) {
  14660. return;
  14661. }
  14662. var findController = this.findController,
  14663. pageIdx = this.pageIdx;
  14664. var textContentItemsStr = this.textContentItemsStr,
  14665. textDivs = this.textDivs;
  14666. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  14667. var selectedMatchIdx = findController.selected.matchIdx;
  14668. var highlightAll = findController.state.highlightAll;
  14669. var prevEnd = null;
  14670. var infinity = {
  14671. divIdx: -1,
  14672. offset: undefined
  14673. };
  14674. function beginText(begin, className) {
  14675. var divIdx = begin.divIdx;
  14676. textDivs[divIdx].textContent = "";
  14677. return appendTextToDiv(divIdx, 0, begin.offset, className);
  14678. }
  14679. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  14680. var div = textDivs[divIdx];
  14681. if (div.nodeType === Node.TEXT_NODE) {
  14682. var span = document.createElement("span");
  14683. div.parentNode.insertBefore(span, div);
  14684. span.appendChild(div);
  14685. textDivs[divIdx] = span;
  14686. div = span;
  14687. }
  14688. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  14689. var node = document.createTextNode(content);
  14690. if (className) {
  14691. var _span = document.createElement("span");
  14692. _span.className = "".concat(className, " appended");
  14693. _span.appendChild(node);
  14694. div.appendChild(_span);
  14695. return className.includes("selected") ? _span.offsetLeft : 0;
  14696. }
  14697. div.appendChild(node);
  14698. return 0;
  14699. }
  14700. var i0 = selectedMatchIdx,
  14701. i1 = i0 + 1;
  14702. if (highlightAll) {
  14703. i0 = 0;
  14704. i1 = matches.length;
  14705. } else if (!isSelectedPage) {
  14706. return;
  14707. }
  14708. for (var i = i0; i < i1; i++) {
  14709. var match = matches[i];
  14710. var begin = match.begin;
  14711. var end = match.end;
  14712. var isSelected = isSelectedPage && i === selectedMatchIdx;
  14713. var highlightSuffix = isSelected ? " selected" : "";
  14714. var selectedLeft = 0;
  14715. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  14716. if (prevEnd !== null) {
  14717. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  14718. }
  14719. beginText(begin);
  14720. } else {
  14721. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  14722. }
  14723. if (begin.divIdx === end.divIdx) {
  14724. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  14725. } else {
  14726. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  14727. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  14728. textDivs[n0].className = "highlight middle" + highlightSuffix;
  14729. }
  14730. beginText(end, "highlight end" + highlightSuffix);
  14731. }
  14732. prevEnd = end;
  14733. if (isSelected) {
  14734. findController.scrollMatchIntoView({
  14735. element: textDivs[begin.divIdx],
  14736. selectedLeft: selectedLeft,
  14737. pageIndex: pageIdx,
  14738. matchIndex: selectedMatchIdx
  14739. });
  14740. }
  14741. }
  14742. if (prevEnd) {
  14743. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  14744. }
  14745. }
  14746. }, {
  14747. key: "_updateMatches",
  14748. value: function _updateMatches() {
  14749. if (!this.enabled) {
  14750. return;
  14751. }
  14752. var findController = this.findController,
  14753. matches = this.matches,
  14754. pageIdx = this.pageIdx;
  14755. var textContentItemsStr = this.textContentItemsStr,
  14756. textDivs = this.textDivs;
  14757. var clearedUntilDivIdx = -1;
  14758. for (var i = 0, ii = matches.length; i < ii; i++) {
  14759. var match = matches[i];
  14760. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  14761. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  14762. var div = textDivs[n];
  14763. div.textContent = textContentItemsStr[n];
  14764. div.className = "";
  14765. }
  14766. clearedUntilDivIdx = match.end.divIdx + 1;
  14767. }
  14768. if (!(findController !== null && findController !== void 0 && findController.highlightMatches)) {
  14769. return;
  14770. }
  14771. var pageMatches = findController.pageMatches[pageIdx] || null;
  14772. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  14773. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  14774. this._renderMatches(this.matches);
  14775. }
  14776. }]);
  14777. return TextHighlighter;
  14778. }();
  14779. exports.TextHighlighter = TextHighlighter;
  14780. /***/ }),
  14781. /* 37 */
  14782. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14783. Object.defineProperty(exports, "__esModule", ({
  14784. value: true
  14785. }));
  14786. exports.TextLayerBuilder = void 0;
  14787. var _pdfjsLib = __webpack_require__(7);
  14788. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14789. 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); } }
  14790. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  14791. var EXPAND_DIVS_TIMEOUT = 300;
  14792. var TextLayerBuilder = /*#__PURE__*/function () {
  14793. function TextLayerBuilder(_ref) {
  14794. var textLayerDiv = _ref.textLayerDiv,
  14795. eventBus = _ref.eventBus,
  14796. pageIndex = _ref.pageIndex,
  14797. viewport = _ref.viewport,
  14798. _ref$highlighter = _ref.highlighter,
  14799. highlighter = _ref$highlighter === void 0 ? null : _ref$highlighter,
  14800. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  14801. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  14802. _classCallCheck(this, TextLayerBuilder);
  14803. this.textLayerDiv = textLayerDiv;
  14804. this.eventBus = eventBus;
  14805. this.textContent = null;
  14806. this.textContentItemsStr = [];
  14807. this.textContentStream = null;
  14808. this.renderingDone = false;
  14809. this.pageNumber = pageIndex + 1;
  14810. this.viewport = viewport;
  14811. this.textDivs = [];
  14812. this.textLayerRenderTask = null;
  14813. this.highlighter = highlighter;
  14814. this.enhanceTextSelection = enhanceTextSelection;
  14815. this._bindMouse();
  14816. }
  14817. _createClass(TextLayerBuilder, [{
  14818. key: "_finishRendering",
  14819. value: function _finishRendering() {
  14820. this.renderingDone = true;
  14821. if (!this.enhanceTextSelection) {
  14822. var endOfContent = document.createElement("div");
  14823. endOfContent.className = "endOfContent";
  14824. this.textLayerDiv.appendChild(endOfContent);
  14825. }
  14826. this.eventBus.dispatch("textlayerrendered", {
  14827. source: this,
  14828. pageNumber: this.pageNumber,
  14829. numTextDivs: this.textDivs.length
  14830. });
  14831. }
  14832. }, {
  14833. key: "render",
  14834. value: function render() {
  14835. var _this$highlighter,
  14836. _this = this;
  14837. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  14838. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  14839. return;
  14840. }
  14841. this.cancel();
  14842. this.textDivs.length = 0;
  14843. (_this$highlighter = this.highlighter) === null || _this$highlighter === void 0 ? void 0 : _this$highlighter.setTextMapping(this.textDivs, this.textContentItemsStr);
  14844. var textLayerFrag = document.createDocumentFragment();
  14845. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  14846. textContent: this.textContent,
  14847. textContentStream: this.textContentStream,
  14848. container: textLayerFrag,
  14849. viewport: this.viewport,
  14850. textDivs: this.textDivs,
  14851. textContentItemsStr: this.textContentItemsStr,
  14852. timeout: timeout,
  14853. enhanceTextSelection: this.enhanceTextSelection
  14854. });
  14855. this.textLayerRenderTask.promise.then(function () {
  14856. var _this$highlighter2;
  14857. _this.textLayerDiv.appendChild(textLayerFrag);
  14858. _this._finishRendering();
  14859. (_this$highlighter2 = _this.highlighter) === null || _this$highlighter2 === void 0 ? void 0 : _this$highlighter2.enable();
  14860. }, function (reason) {});
  14861. }
  14862. }, {
  14863. key: "cancel",
  14864. value: function cancel() {
  14865. var _this$highlighter3;
  14866. if (this.textLayerRenderTask) {
  14867. this.textLayerRenderTask.cancel();
  14868. this.textLayerRenderTask = null;
  14869. }
  14870. (_this$highlighter3 = this.highlighter) === null || _this$highlighter3 === void 0 ? void 0 : _this$highlighter3.disable();
  14871. }
  14872. }, {
  14873. key: "setTextContentStream",
  14874. value: function setTextContentStream(readableStream) {
  14875. this.cancel();
  14876. this.textContentStream = readableStream;
  14877. }
  14878. }, {
  14879. key: "setTextContent",
  14880. value: function setTextContent(textContent) {
  14881. this.cancel();
  14882. this.textContent = textContent;
  14883. }
  14884. }, {
  14885. key: "_bindMouse",
  14886. value: function _bindMouse() {
  14887. var _this2 = this;
  14888. var div = this.textLayerDiv;
  14889. var expandDivsTimer = null;
  14890. div.addEventListener("mousedown", function (evt) {
  14891. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  14892. _this2.textLayerRenderTask.expandTextDivs(true);
  14893. if (expandDivsTimer) {
  14894. clearTimeout(expandDivsTimer);
  14895. expandDivsTimer = null;
  14896. }
  14897. return;
  14898. }
  14899. var end = div.querySelector(".endOfContent");
  14900. if (!end) {
  14901. return;
  14902. }
  14903. var adjustTop = evt.target !== div;
  14904. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  14905. if (adjustTop) {
  14906. var divBounds = div.getBoundingClientRect();
  14907. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  14908. end.style.top = (r * 100).toFixed(2) + "%";
  14909. }
  14910. end.classList.add("active");
  14911. });
  14912. div.addEventListener("mouseup", function () {
  14913. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  14914. expandDivsTimer = setTimeout(function () {
  14915. if (_this2.textLayerRenderTask) {
  14916. _this2.textLayerRenderTask.expandTextDivs(false);
  14917. }
  14918. expandDivsTimer = null;
  14919. }, EXPAND_DIVS_TIMEOUT);
  14920. return;
  14921. }
  14922. var end = div.querySelector(".endOfContent");
  14923. if (!end) {
  14924. return;
  14925. }
  14926. end.style.top = "";
  14927. end.classList.remove("active");
  14928. });
  14929. }
  14930. }]);
  14931. return TextLayerBuilder;
  14932. }();
  14933. exports.TextLayerBuilder = TextLayerBuilder;
  14934. /***/ }),
  14935. /* 38 */
  14936. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14937. Object.defineProperty(exports, "__esModule", ({
  14938. value: true
  14939. }));
  14940. exports.XfaLayerBuilder = void 0;
  14941. var _pdfjsLib = __webpack_require__(7);
  14942. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14943. 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); } }
  14944. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  14945. var XfaLayerBuilder = /*#__PURE__*/function () {
  14946. function XfaLayerBuilder(_ref) {
  14947. var pageDiv = _ref.pageDiv,
  14948. pdfPage = _ref.pdfPage,
  14949. _ref$annotationStorag = _ref.annotationStorage,
  14950. annotationStorage = _ref$annotationStorag === void 0 ? null : _ref$annotationStorag,
  14951. linkService = _ref.linkService,
  14952. _ref$xfaHtml = _ref.xfaHtml,
  14953. xfaHtml = _ref$xfaHtml === void 0 ? null : _ref$xfaHtml;
  14954. _classCallCheck(this, XfaLayerBuilder);
  14955. this.pageDiv = pageDiv;
  14956. this.pdfPage = pdfPage;
  14957. this.annotationStorage = annotationStorage;
  14958. this.linkService = linkService;
  14959. this.xfaHtml = xfaHtml;
  14960. this.div = null;
  14961. this._cancelled = false;
  14962. }
  14963. _createClass(XfaLayerBuilder, [{
  14964. key: "render",
  14965. value: function render(viewport) {
  14966. var _this = this;
  14967. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  14968. if (intent === "print") {
  14969. var parameters = {
  14970. viewport: viewport.clone({
  14971. dontFlip: true
  14972. }),
  14973. div: this.div,
  14974. xfaHtml: this.xfaHtml,
  14975. annotationStorage: this.annotationStorage,
  14976. linkService: this.linkService,
  14977. intent: intent
  14978. };
  14979. var div = document.createElement("div");
  14980. this.pageDiv.appendChild(div);
  14981. parameters.div = div;
  14982. var result = _pdfjsLib.XfaLayer.render(parameters);
  14983. return Promise.resolve(result);
  14984. }
  14985. return this.pdfPage.getXfa().then(function (xfaHtml) {
  14986. if (_this._cancelled || !xfaHtml) {
  14987. return {
  14988. textDivs: []
  14989. };
  14990. }
  14991. var parameters = {
  14992. viewport: viewport.clone({
  14993. dontFlip: true
  14994. }),
  14995. div: _this.div,
  14996. xfaHtml: xfaHtml,
  14997. annotationStorage: _this.annotationStorage,
  14998. linkService: _this.linkService,
  14999. intent: intent
  15000. };
  15001. if (_this.div) {
  15002. return _pdfjsLib.XfaLayer.update(parameters);
  15003. }
  15004. _this.div = document.createElement("div");
  15005. _this.pageDiv.appendChild(_this.div);
  15006. parameters.div = _this.div;
  15007. return _pdfjsLib.XfaLayer.render(parameters);
  15008. })["catch"](function (error) {
  15009. console.error(error);
  15010. });
  15011. }
  15012. }, {
  15013. key: "cancel",
  15014. value: function cancel() {
  15015. this._cancelled = true;
  15016. }
  15017. }, {
  15018. key: "hide",
  15019. value: function hide() {
  15020. if (!this.div) {
  15021. return;
  15022. }
  15023. this.div.hidden = true;
  15024. }
  15025. }]);
  15026. return XfaLayerBuilder;
  15027. }();
  15028. exports.XfaLayerBuilder = XfaLayerBuilder;
  15029. /***/ }),
  15030. /* 39 */
  15031. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15032. Object.defineProperty(exports, "__esModule", ({
  15033. value: true
  15034. }));
  15035. exports.SecondaryToolbar = void 0;
  15036. var _ui_utils = __webpack_require__(5);
  15037. var _pdf_cursor_tools = __webpack_require__(8);
  15038. var _base_viewer = __webpack_require__(31);
  15039. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
  15040. 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); }
  15041. 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; }
  15042. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15043. 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); } }
  15044. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  15045. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  15046. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  15047. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  15048. var _updateUIState = /*#__PURE__*/new WeakSet();
  15049. var _bindClickListeners = /*#__PURE__*/new WeakSet();
  15050. var _bindCursorToolsListener = /*#__PURE__*/new WeakSet();
  15051. var _bindScrollModeListener = /*#__PURE__*/new WeakSet();
  15052. var _bindSpreadModeListener = /*#__PURE__*/new WeakSet();
  15053. var SecondaryToolbar = /*#__PURE__*/function () {
  15054. function SecondaryToolbar(options, eventBus) {
  15055. _classCallCheck(this, SecondaryToolbar);
  15056. _classPrivateMethodInitSpec(this, _bindSpreadModeListener);
  15057. _classPrivateMethodInitSpec(this, _bindScrollModeListener);
  15058. _classPrivateMethodInitSpec(this, _bindCursorToolsListener);
  15059. _classPrivateMethodInitSpec(this, _bindClickListeners);
  15060. _classPrivateMethodInitSpec(this, _updateUIState);
  15061. this.toolbar = options.toolbar;
  15062. this.toggleButton = options.toggleButton;
  15063. this.buttons = [{
  15064. element: options.presentationModeButton,
  15065. eventName: "presentationmode",
  15066. close: true
  15067. }, {
  15068. element: options.printButton,
  15069. eventName: "print",
  15070. close: true
  15071. }, {
  15072. element: options.downloadButton,
  15073. eventName: "download",
  15074. close: true
  15075. }, {
  15076. element: options.viewBookmarkButton,
  15077. eventName: null,
  15078. close: true
  15079. }, {
  15080. element: options.firstPageButton,
  15081. eventName: "firstpage",
  15082. close: true
  15083. }, {
  15084. element: options.lastPageButton,
  15085. eventName: "lastpage",
  15086. close: true
  15087. }, {
  15088. element: options.pageRotateCwButton,
  15089. eventName: "rotatecw",
  15090. close: false
  15091. }, {
  15092. element: options.pageRotateCcwButton,
  15093. eventName: "rotateccw",
  15094. close: false
  15095. }, {
  15096. element: options.cursorSelectToolButton,
  15097. eventName: "switchcursortool",
  15098. eventDetails: {
  15099. tool: _pdf_cursor_tools.CursorTool.SELECT
  15100. },
  15101. close: true
  15102. }, {
  15103. element: options.cursorHandToolButton,
  15104. eventName: "switchcursortool",
  15105. eventDetails: {
  15106. tool: _pdf_cursor_tools.CursorTool.HAND
  15107. },
  15108. close: true
  15109. }, {
  15110. element: options.scrollPageButton,
  15111. eventName: "switchscrollmode",
  15112. eventDetails: {
  15113. mode: _ui_utils.ScrollMode.PAGE
  15114. },
  15115. close: true
  15116. }, {
  15117. element: options.scrollVerticalButton,
  15118. eventName: "switchscrollmode",
  15119. eventDetails: {
  15120. mode: _ui_utils.ScrollMode.VERTICAL
  15121. },
  15122. close: true
  15123. }, {
  15124. element: options.scrollHorizontalButton,
  15125. eventName: "switchscrollmode",
  15126. eventDetails: {
  15127. mode: _ui_utils.ScrollMode.HORIZONTAL
  15128. },
  15129. close: true
  15130. }, {
  15131. element: options.scrollWrappedButton,
  15132. eventName: "switchscrollmode",
  15133. eventDetails: {
  15134. mode: _ui_utils.ScrollMode.WRAPPED
  15135. },
  15136. close: true
  15137. }, {
  15138. element: options.spreadNoneButton,
  15139. eventName: "switchspreadmode",
  15140. eventDetails: {
  15141. mode: _ui_utils.SpreadMode.NONE
  15142. },
  15143. close: true
  15144. }, {
  15145. element: options.spreadOddButton,
  15146. eventName: "switchspreadmode",
  15147. eventDetails: {
  15148. mode: _ui_utils.SpreadMode.ODD
  15149. },
  15150. close: true
  15151. }, {
  15152. element: options.spreadEvenButton,
  15153. eventName: "switchspreadmode",
  15154. eventDetails: {
  15155. mode: _ui_utils.SpreadMode.EVEN
  15156. },
  15157. close: true
  15158. }, {
  15159. element: options.documentPropertiesButton,
  15160. eventName: "documentproperties",
  15161. close: true
  15162. }];
  15163. this.buttons.push({
  15164. element: options.openFileButton,
  15165. eventName: "openfile",
  15166. close: true
  15167. });
  15168. this.items = {
  15169. firstPage: options.firstPageButton,
  15170. lastPage: options.lastPageButton,
  15171. pageRotateCw: options.pageRotateCwButton,
  15172. pageRotateCcw: options.pageRotateCcwButton
  15173. };
  15174. this.eventBus = eventBus;
  15175. this.opened = false;
  15176. this.reset();
  15177. _classPrivateMethodGet(this, _bindClickListeners, _bindClickListeners2).call(this);
  15178. _classPrivateMethodGet(this, _bindCursorToolsListener, _bindCursorToolsListener2).call(this, options);
  15179. _classPrivateMethodGet(this, _bindScrollModeListener, _bindScrollModeListener2).call(this, options);
  15180. _classPrivateMethodGet(this, _bindSpreadModeListener, _bindSpreadModeListener2).call(this, options);
  15181. }
  15182. _createClass(SecondaryToolbar, [{
  15183. key: "isOpen",
  15184. get: function get() {
  15185. return this.opened;
  15186. }
  15187. }, {
  15188. key: "setPageNumber",
  15189. value: function setPageNumber(pageNumber) {
  15190. this.pageNumber = pageNumber;
  15191. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this);
  15192. }
  15193. }, {
  15194. key: "setPagesCount",
  15195. value: function setPagesCount(pagesCount) {
  15196. this.pagesCount = pagesCount;
  15197. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this);
  15198. }
  15199. }, {
  15200. key: "reset",
  15201. value: function reset() {
  15202. this.pageNumber = 0;
  15203. this.pagesCount = 0;
  15204. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this);
  15205. this.eventBus.dispatch("secondarytoolbarreset", {
  15206. source: this
  15207. });
  15208. }
  15209. }, {
  15210. key: "open",
  15211. value: function open() {
  15212. if (this.opened) {
  15213. return;
  15214. }
  15215. this.opened = true;
  15216. this.toggleButton.classList.add("toggled");
  15217. this.toggleButton.setAttribute("aria-expanded", "true");
  15218. this.toolbar.classList.remove("hidden");
  15219. }
  15220. }, {
  15221. key: "close",
  15222. value: function close() {
  15223. if (!this.opened) {
  15224. return;
  15225. }
  15226. this.opened = false;
  15227. this.toolbar.classList.add("hidden");
  15228. this.toggleButton.classList.remove("toggled");
  15229. this.toggleButton.setAttribute("aria-expanded", "false");
  15230. }
  15231. }, {
  15232. key: "toggle",
  15233. value: function toggle() {
  15234. if (this.opened) {
  15235. this.close();
  15236. } else {
  15237. this.open();
  15238. }
  15239. }
  15240. }]);
  15241. return SecondaryToolbar;
  15242. }();
  15243. exports.SecondaryToolbar = SecondaryToolbar;
  15244. function _updateUIState2() {
  15245. this.items.firstPage.disabled = this.pageNumber <= 1;
  15246. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  15247. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  15248. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  15249. }
  15250. function _bindClickListeners2() {
  15251. var _this = this;
  15252. this.toggleButton.addEventListener("click", this.toggle.bind(this));
  15253. var _iterator = _createForOfIteratorHelper(this.buttons),
  15254. _step;
  15255. try {
  15256. var _loop = function _loop() {
  15257. var _step$value = _step.value,
  15258. element = _step$value.element,
  15259. eventName = _step$value.eventName,
  15260. close = _step$value.close,
  15261. eventDetails = _step$value.eventDetails;
  15262. element.addEventListener("click", function (evt) {
  15263. if (eventName !== null) {
  15264. var details = {
  15265. source: _this
  15266. };
  15267. for (var property in eventDetails) {
  15268. details[property] = eventDetails[property];
  15269. }
  15270. _this.eventBus.dispatch(eventName, details);
  15271. }
  15272. if (close) {
  15273. _this.close();
  15274. }
  15275. });
  15276. };
  15277. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  15278. _loop();
  15279. }
  15280. } catch (err) {
  15281. _iterator.e(err);
  15282. } finally {
  15283. _iterator.f();
  15284. }
  15285. }
  15286. function _bindCursorToolsListener2(_ref) {
  15287. var cursorSelectToolButton = _ref.cursorSelectToolButton,
  15288. cursorHandToolButton = _ref.cursorHandToolButton;
  15289. this.eventBus._on("cursortoolchanged", function (_ref2) {
  15290. var tool = _ref2.tool;
  15291. var isSelect = tool === _pdf_cursor_tools.CursorTool.SELECT,
  15292. isHand = tool === _pdf_cursor_tools.CursorTool.HAND;
  15293. cursorSelectToolButton.classList.toggle("toggled", isSelect);
  15294. cursorHandToolButton.classList.toggle("toggled", isHand);
  15295. cursorSelectToolButton.setAttribute("aria-checked", isSelect);
  15296. cursorHandToolButton.setAttribute("aria-checked", isHand);
  15297. });
  15298. }
  15299. function _bindScrollModeListener2(_ref3) {
  15300. var _this2 = this;
  15301. var scrollPageButton = _ref3.scrollPageButton,
  15302. scrollVerticalButton = _ref3.scrollVerticalButton,
  15303. scrollHorizontalButton = _ref3.scrollHorizontalButton,
  15304. scrollWrappedButton = _ref3.scrollWrappedButton,
  15305. spreadNoneButton = _ref3.spreadNoneButton,
  15306. spreadOddButton = _ref3.spreadOddButton,
  15307. spreadEvenButton = _ref3.spreadEvenButton;
  15308. var scrollModeChanged = function scrollModeChanged(_ref4) {
  15309. var mode = _ref4.mode;
  15310. var isPage = mode === _ui_utils.ScrollMode.PAGE,
  15311. isVertical = mode === _ui_utils.ScrollMode.VERTICAL,
  15312. isHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL,
  15313. isWrapped = mode === _ui_utils.ScrollMode.WRAPPED;
  15314. scrollPageButton.classList.toggle("toggled", isPage);
  15315. scrollVerticalButton.classList.toggle("toggled", isVertical);
  15316. scrollHorizontalButton.classList.toggle("toggled", isHorizontal);
  15317. scrollWrappedButton.classList.toggle("toggled", isWrapped);
  15318. scrollPageButton.setAttribute("aria-checked", isPage);
  15319. scrollVerticalButton.setAttribute("aria-checked", isVertical);
  15320. scrollHorizontalButton.setAttribute("aria-checked", isHorizontal);
  15321. scrollWrappedButton.setAttribute("aria-checked", isWrapped);
  15322. var forceScrollModePage = _this2.pagesCount > _base_viewer.PagesCountLimit.FORCE_SCROLL_MODE_PAGE;
  15323. scrollPageButton.disabled = forceScrollModePage;
  15324. scrollVerticalButton.disabled = forceScrollModePage;
  15325. scrollHorizontalButton.disabled = forceScrollModePage;
  15326. scrollWrappedButton.disabled = forceScrollModePage;
  15327. spreadNoneButton.disabled = isHorizontal;
  15328. spreadOddButton.disabled = isHorizontal;
  15329. spreadEvenButton.disabled = isHorizontal;
  15330. };
  15331. this.eventBus._on("scrollmodechanged", scrollModeChanged);
  15332. this.eventBus._on("secondarytoolbarreset", function (evt) {
  15333. if (evt.source === _this2) {
  15334. scrollModeChanged({
  15335. mode: _ui_utils.ScrollMode.VERTICAL
  15336. });
  15337. }
  15338. });
  15339. }
  15340. function _bindSpreadModeListener2(_ref5) {
  15341. var _this3 = this;
  15342. var spreadNoneButton = _ref5.spreadNoneButton,
  15343. spreadOddButton = _ref5.spreadOddButton,
  15344. spreadEvenButton = _ref5.spreadEvenButton;
  15345. function spreadModeChanged(_ref6) {
  15346. var mode = _ref6.mode;
  15347. var isNone = mode === _ui_utils.SpreadMode.NONE,
  15348. isOdd = mode === _ui_utils.SpreadMode.ODD,
  15349. isEven = mode === _ui_utils.SpreadMode.EVEN;
  15350. spreadNoneButton.classList.toggle("toggled", isNone);
  15351. spreadOddButton.classList.toggle("toggled", isOdd);
  15352. spreadEvenButton.classList.toggle("toggled", isEven);
  15353. spreadNoneButton.setAttribute("aria-checked", isNone);
  15354. spreadOddButton.setAttribute("aria-checked", isOdd);
  15355. spreadEvenButton.setAttribute("aria-checked", isEven);
  15356. }
  15357. this.eventBus._on("spreadmodechanged", spreadModeChanged);
  15358. this.eventBus._on("secondarytoolbarreset", function (evt) {
  15359. if (evt.source === _this3) {
  15360. spreadModeChanged({
  15361. mode: _ui_utils.SpreadMode.NONE
  15362. });
  15363. }
  15364. });
  15365. }
  15366. /***/ }),
  15367. /* 40 */
  15368. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15369. Object.defineProperty(exports, "__esModule", ({
  15370. value: true
  15371. }));
  15372. exports.Toolbar = void 0;
  15373. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  15374. var _ui_utils = __webpack_require__(5);
  15375. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15376. 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); } }
  15377. 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); }); }; }
  15378. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
  15379. 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); }
  15380. 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; }
  15381. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15382. 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); } }
  15383. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  15384. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  15385. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  15386. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  15387. var PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
  15388. var _adjustScaleWidth = /*#__PURE__*/new WeakSet();
  15389. var Toolbar = /*#__PURE__*/function () {
  15390. function Toolbar(options, eventBus, _l10n) {
  15391. _classCallCheck(this, Toolbar);
  15392. _classPrivateMethodInitSpec(this, _adjustScaleWidth);
  15393. this.toolbar = options.container;
  15394. this.eventBus = eventBus;
  15395. this.l10n = _l10n;
  15396. this.buttons = [{
  15397. element: options.previous,
  15398. eventName: "previouspage"
  15399. }, {
  15400. element: options.next,
  15401. eventName: "nextpage"
  15402. }, {
  15403. element: options.zoomIn,
  15404. eventName: "zoomin"
  15405. }, {
  15406. element: options.zoomOut,
  15407. eventName: "zoomout"
  15408. }, {
  15409. element: options.print,
  15410. eventName: "print"
  15411. }, {
  15412. element: options.presentationModeButton,
  15413. eventName: "presentationmode"
  15414. }, {
  15415. element: options.download,
  15416. eventName: "download"
  15417. }, {
  15418. element: options.viewBookmark,
  15419. eventName: null
  15420. }];
  15421. this.buttons.push({
  15422. element: options.openFile,
  15423. eventName: "openfile"
  15424. });
  15425. this.items = {
  15426. numPages: options.numPages,
  15427. pageNumber: options.pageNumber,
  15428. scaleSelect: options.scaleSelect,
  15429. customScaleOption: options.customScaleOption,
  15430. previous: options.previous,
  15431. next: options.next,
  15432. zoomIn: options.zoomIn,
  15433. zoomOut: options.zoomOut
  15434. };
  15435. this._wasLocalized = false;
  15436. this.reset();
  15437. this._bindListeners();
  15438. }
  15439. _createClass(Toolbar, [{
  15440. key: "setPageNumber",
  15441. value: function setPageNumber(pageNumber, pageLabel) {
  15442. this.pageNumber = pageNumber;
  15443. this.pageLabel = pageLabel;
  15444. this._updateUIState(false);
  15445. }
  15446. }, {
  15447. key: "setPagesCount",
  15448. value: function setPagesCount(pagesCount, hasPageLabels) {
  15449. this.pagesCount = pagesCount;
  15450. this.hasPageLabels = hasPageLabels;
  15451. this._updateUIState(true);
  15452. }
  15453. }, {
  15454. key: "setPageScale",
  15455. value: function setPageScale(pageScaleValue, pageScale) {
  15456. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  15457. this.pageScale = pageScale;
  15458. this._updateUIState(false);
  15459. }
  15460. }, {
  15461. key: "reset",
  15462. value: function reset() {
  15463. this.pageNumber = 0;
  15464. this.pageLabel = null;
  15465. this.hasPageLabels = false;
  15466. this.pagesCount = 0;
  15467. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  15468. this.pageScale = _ui_utils.DEFAULT_SCALE;
  15469. this._updateUIState(true);
  15470. this.updateLoadingIndicatorState();
  15471. }
  15472. }, {
  15473. key: "_bindListeners",
  15474. value: function _bindListeners() {
  15475. var _this = this;
  15476. var _this$items = this.items,
  15477. pageNumber = _this$items.pageNumber,
  15478. scaleSelect = _this$items.scaleSelect;
  15479. var self = this;
  15480. var _iterator = _createForOfIteratorHelper(this.buttons),
  15481. _step;
  15482. try {
  15483. var _loop = function _loop() {
  15484. var _step$value = _step.value,
  15485. element = _step$value.element,
  15486. eventName = _step$value.eventName;
  15487. element.addEventListener("click", function (evt) {
  15488. if (eventName !== null) {
  15489. _this.eventBus.dispatch(eventName, {
  15490. source: _this
  15491. });
  15492. }
  15493. });
  15494. };
  15495. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  15496. _loop();
  15497. }
  15498. } catch (err) {
  15499. _iterator.e(err);
  15500. } finally {
  15501. _iterator.f();
  15502. }
  15503. pageNumber.addEventListener("click", function () {
  15504. this.select();
  15505. });
  15506. pageNumber.addEventListener("change", function () {
  15507. self.eventBus.dispatch("pagenumberchanged", {
  15508. source: self,
  15509. value: this.value
  15510. });
  15511. });
  15512. scaleSelect.addEventListener("change", function () {
  15513. if (this.value === "custom") {
  15514. return;
  15515. }
  15516. self.eventBus.dispatch("scalechanged", {
  15517. source: self,
  15518. value: this.value
  15519. });
  15520. });
  15521. scaleSelect.addEventListener("click", function (evt) {
  15522. var target = evt.target;
  15523. if (this.value === self.pageScaleValue && target.tagName.toUpperCase() === "OPTION") {
  15524. this.blur();
  15525. }
  15526. });
  15527. scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  15528. this.eventBus._on("localized", function () {
  15529. _this._wasLocalized = true;
  15530. _classPrivateMethodGet(_this, _adjustScaleWidth, _adjustScaleWidth2).call(_this);
  15531. _this._updateUIState(true);
  15532. });
  15533. }
  15534. }, {
  15535. key: "_updateUIState",
  15536. value: function _updateUIState() {
  15537. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  15538. if (!this._wasLocalized) {
  15539. return;
  15540. }
  15541. var pageNumber = this.pageNumber,
  15542. pagesCount = this.pagesCount,
  15543. pageScaleValue = this.pageScaleValue,
  15544. pageScale = this.pageScale,
  15545. items = this.items;
  15546. if (resetNumPages) {
  15547. if (this.hasPageLabels) {
  15548. items.pageNumber.type = "text";
  15549. } else {
  15550. items.pageNumber.type = "number";
  15551. this.l10n.get("of_pages", {
  15552. pagesCount: pagesCount
  15553. }).then(function (msg) {
  15554. items.numPages.textContent = msg;
  15555. });
  15556. }
  15557. items.pageNumber.max = pagesCount;
  15558. }
  15559. if (this.hasPageLabels) {
  15560. items.pageNumber.value = this.pageLabel;
  15561. this.l10n.get("page_of_pages", {
  15562. pageNumber: pageNumber,
  15563. pagesCount: pagesCount
  15564. }).then(function (msg) {
  15565. items.numPages.textContent = msg;
  15566. });
  15567. } else {
  15568. items.pageNumber.value = pageNumber;
  15569. }
  15570. items.previous.disabled = pageNumber <= 1;
  15571. items.next.disabled = pageNumber >= pagesCount;
  15572. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  15573. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  15574. this.l10n.get("page_scale_percent", {
  15575. scale: Math.round(pageScale * 10000) / 100
  15576. }).then(function (msg) {
  15577. var predefinedValueFound = false;
  15578. var _iterator2 = _createForOfIteratorHelper(items.scaleSelect.options),
  15579. _step2;
  15580. try {
  15581. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  15582. var option = _step2.value;
  15583. if (option.value !== pageScaleValue) {
  15584. option.selected = false;
  15585. continue;
  15586. }
  15587. option.selected = true;
  15588. predefinedValueFound = true;
  15589. }
  15590. } catch (err) {
  15591. _iterator2.e(err);
  15592. } finally {
  15593. _iterator2.f();
  15594. }
  15595. if (!predefinedValueFound) {
  15596. items.customScaleOption.textContent = msg;
  15597. items.customScaleOption.selected = true;
  15598. }
  15599. });
  15600. }
  15601. }, {
  15602. key: "updateLoadingIndicatorState",
  15603. value: function updateLoadingIndicatorState() {
  15604. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  15605. var pageNumberInput = this.items.pageNumber;
  15606. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  15607. }
  15608. }]);
  15609. return Toolbar;
  15610. }();
  15611. exports.Toolbar = Toolbar;
  15612. function _adjustScaleWidth2() {
  15613. return _adjustScaleWidth3.apply(this, arguments);
  15614. }
  15615. function _adjustScaleWidth3() {
  15616. _adjustScaleWidth3 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  15617. var items, l10n, predefinedValuesPromise, style, scaleSelectContainerWidth, scaleSelectOverflow, canvas, ctx, maxWidth, _iterator3, _step3, predefinedValue, _ctx$measureText, width, doc;
  15618. return _regenerator["default"].wrap(function _callee$(_context) {
  15619. while (1) {
  15620. switch (_context.prev = _context.next) {
  15621. case 0:
  15622. items = this.items, l10n = this.l10n;
  15623. predefinedValuesPromise = Promise.all([l10n.get("page_scale_auto"), l10n.get("page_scale_actual"), l10n.get("page_scale_fit"), l10n.get("page_scale_width")]);
  15624. _context.next = 4;
  15625. return _ui_utils.animationStarted;
  15626. case 4:
  15627. style = getComputedStyle(items.scaleSelect), scaleSelectContainerWidth = parseInt(style.getPropertyValue("--scale-select-container-width"), 10), scaleSelectOverflow = parseInt(style.getPropertyValue("--scale-select-overflow"), 10);
  15628. canvas = document.createElement("canvas");
  15629. ctx = canvas.getContext("2d", {
  15630. alpha: false
  15631. });
  15632. ctx.font = "".concat(style.fontSize, " ").concat(style.fontFamily);
  15633. maxWidth = 0;
  15634. _context.t0 = _createForOfIteratorHelper;
  15635. _context.next = 12;
  15636. return predefinedValuesPromise;
  15637. case 12:
  15638. _context.t1 = _context.sent;
  15639. _iterator3 = (0, _context.t0)(_context.t1);
  15640. try {
  15641. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  15642. predefinedValue = _step3.value;
  15643. _ctx$measureText = ctx.measureText(predefinedValue), width = _ctx$measureText.width;
  15644. if (width > maxWidth) {
  15645. maxWidth = width;
  15646. }
  15647. }
  15648. } catch (err) {
  15649. _iterator3.e(err);
  15650. } finally {
  15651. _iterator3.f();
  15652. }
  15653. maxWidth += 2 * scaleSelectOverflow;
  15654. if (maxWidth > scaleSelectContainerWidth) {
  15655. doc = document.documentElement;
  15656. doc.style.setProperty("--scale-select-container-width", "".concat(maxWidth, "px"));
  15657. }
  15658. canvas.width = 0;
  15659. canvas.height = 0;
  15660. case 19:
  15661. case "end":
  15662. return _context.stop();
  15663. }
  15664. }
  15665. }, _callee, this);
  15666. }));
  15667. return _adjustScaleWidth3.apply(this, arguments);
  15668. }
  15669. /***/ }),
  15670. /* 41 */
  15671. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15672. Object.defineProperty(exports, "__esModule", ({
  15673. value: true
  15674. }));
  15675. exports.ViewHistory = void 0;
  15676. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  15677. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15678. 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); } }
  15679. 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); }); }; }
  15680. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15681. 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); } }
  15682. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  15683. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  15684. var ViewHistory = /*#__PURE__*/function () {
  15685. function ViewHistory(fingerprint) {
  15686. var _this = this;
  15687. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  15688. _classCallCheck(this, ViewHistory);
  15689. this.fingerprint = fingerprint;
  15690. this.cacheSize = cacheSize;
  15691. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  15692. var database = JSON.parse(databaseStr || "{}");
  15693. var index = -1;
  15694. if (!Array.isArray(database.files)) {
  15695. database.files = [];
  15696. } else {
  15697. while (database.files.length >= _this.cacheSize) {
  15698. database.files.shift();
  15699. }
  15700. for (var i = 0, ii = database.files.length; i < ii; i++) {
  15701. var branch = database.files[i];
  15702. if (branch.fingerprint === _this.fingerprint) {
  15703. index = i;
  15704. break;
  15705. }
  15706. }
  15707. }
  15708. if (index === -1) {
  15709. index = database.files.push({
  15710. fingerprint: _this.fingerprint
  15711. }) - 1;
  15712. }
  15713. _this.file = database.files[index];
  15714. _this.database = database;
  15715. });
  15716. }
  15717. _createClass(ViewHistory, [{
  15718. key: "_writeToStorage",
  15719. value: function () {
  15720. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  15721. var databaseStr;
  15722. return _regenerator["default"].wrap(function _callee$(_context) {
  15723. while (1) {
  15724. switch (_context.prev = _context.next) {
  15725. case 0:
  15726. databaseStr = JSON.stringify(this.database);
  15727. localStorage.setItem("pdfjs.history", databaseStr);
  15728. case 2:
  15729. case "end":
  15730. return _context.stop();
  15731. }
  15732. }
  15733. }, _callee, this);
  15734. }));
  15735. function _writeToStorage() {
  15736. return _writeToStorage2.apply(this, arguments);
  15737. }
  15738. return _writeToStorage;
  15739. }()
  15740. }, {
  15741. key: "_readFromStorage",
  15742. value: function () {
  15743. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  15744. return _regenerator["default"].wrap(function _callee2$(_context2) {
  15745. while (1) {
  15746. switch (_context2.prev = _context2.next) {
  15747. case 0:
  15748. return _context2.abrupt("return", localStorage.getItem("pdfjs.history"));
  15749. case 1:
  15750. case "end":
  15751. return _context2.stop();
  15752. }
  15753. }
  15754. }, _callee2);
  15755. }));
  15756. function _readFromStorage() {
  15757. return _readFromStorage2.apply(this, arguments);
  15758. }
  15759. return _readFromStorage;
  15760. }()
  15761. }, {
  15762. key: "set",
  15763. value: function () {
  15764. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name, val) {
  15765. return _regenerator["default"].wrap(function _callee3$(_context3) {
  15766. while (1) {
  15767. switch (_context3.prev = _context3.next) {
  15768. case 0:
  15769. _context3.next = 2;
  15770. return this._initializedPromise;
  15771. case 2:
  15772. this.file[name] = val;
  15773. return _context3.abrupt("return", this._writeToStorage());
  15774. case 4:
  15775. case "end":
  15776. return _context3.stop();
  15777. }
  15778. }
  15779. }, _callee3, this);
  15780. }));
  15781. function set(_x, _x2) {
  15782. return _set.apply(this, arguments);
  15783. }
  15784. return set;
  15785. }()
  15786. }, {
  15787. key: "setMultiple",
  15788. value: function () {
  15789. var _setMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(properties) {
  15790. var name;
  15791. return _regenerator["default"].wrap(function _callee4$(_context4) {
  15792. while (1) {
  15793. switch (_context4.prev = _context4.next) {
  15794. case 0:
  15795. _context4.next = 2;
  15796. return this._initializedPromise;
  15797. case 2:
  15798. for (name in properties) {
  15799. this.file[name] = properties[name];
  15800. }
  15801. return _context4.abrupt("return", this._writeToStorage());
  15802. case 4:
  15803. case "end":
  15804. return _context4.stop();
  15805. }
  15806. }
  15807. }, _callee4, this);
  15808. }));
  15809. function setMultiple(_x3) {
  15810. return _setMultiple.apply(this, arguments);
  15811. }
  15812. return setMultiple;
  15813. }()
  15814. }, {
  15815. key: "get",
  15816. value: function () {
  15817. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name, defaultValue) {
  15818. var val;
  15819. return _regenerator["default"].wrap(function _callee5$(_context5) {
  15820. while (1) {
  15821. switch (_context5.prev = _context5.next) {
  15822. case 0:
  15823. _context5.next = 2;
  15824. return this._initializedPromise;
  15825. case 2:
  15826. val = this.file[name];
  15827. return _context5.abrupt("return", val !== undefined ? val : defaultValue);
  15828. case 4:
  15829. case "end":
  15830. return _context5.stop();
  15831. }
  15832. }
  15833. }, _callee5, this);
  15834. }));
  15835. function get(_x4, _x5) {
  15836. return _get.apply(this, arguments);
  15837. }
  15838. return get;
  15839. }()
  15840. }, {
  15841. key: "getMultiple",
  15842. value: function () {
  15843. var _getMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6(properties) {
  15844. var values, name, val;
  15845. return _regenerator["default"].wrap(function _callee6$(_context6) {
  15846. while (1) {
  15847. switch (_context6.prev = _context6.next) {
  15848. case 0:
  15849. _context6.next = 2;
  15850. return this._initializedPromise;
  15851. case 2:
  15852. values = Object.create(null);
  15853. for (name in properties) {
  15854. val = this.file[name];
  15855. values[name] = val !== undefined ? val : properties[name];
  15856. }
  15857. return _context6.abrupt("return", values);
  15858. case 5:
  15859. case "end":
  15860. return _context6.stop();
  15861. }
  15862. }
  15863. }, _callee6, this);
  15864. }));
  15865. function getMultiple(_x6) {
  15866. return _getMultiple.apply(this, arguments);
  15867. }
  15868. return getMultiple;
  15869. }()
  15870. }]);
  15871. return ViewHistory;
  15872. }();
  15873. exports.ViewHistory = ViewHistory;
  15874. /***/ }),
  15875. /* 42 */
  15876. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15877. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  15878. Object.defineProperty(exports, "__esModule", ({
  15879. value: true
  15880. }));
  15881. exports.GenericCom = void 0;
  15882. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  15883. var _app = __webpack_require__(2);
  15884. var _preferences = __webpack_require__(43);
  15885. var _download_manager = __webpack_require__(44);
  15886. var _genericl10n = __webpack_require__(45);
  15887. var _generic_scripting = __webpack_require__(47);
  15888. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15889. 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); } }
  15890. 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); }); }; }
  15891. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15892. 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); } }
  15893. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  15894. 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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
  15895. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  15896. 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); }; }
  15897. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  15898. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  15899. 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; } }
  15900. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  15901. ;
  15902. var GenericCom = {};
  15903. exports.GenericCom = GenericCom;
  15904. var GenericPreferences = /*#__PURE__*/function (_BasePreferences) {
  15905. _inherits(GenericPreferences, _BasePreferences);
  15906. var _super = _createSuper(GenericPreferences);
  15907. function GenericPreferences() {
  15908. _classCallCheck(this, GenericPreferences);
  15909. return _super.apply(this, arguments);
  15910. }
  15911. _createClass(GenericPreferences, [{
  15912. key: "_writeToStorage",
  15913. value: function () {
  15914. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  15915. return _regenerator["default"].wrap(function _callee$(_context) {
  15916. while (1) {
  15917. switch (_context.prev = _context.next) {
  15918. case 0:
  15919. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  15920. case 1:
  15921. case "end":
  15922. return _context.stop();
  15923. }
  15924. }
  15925. }, _callee);
  15926. }));
  15927. function _writeToStorage(_x) {
  15928. return _writeToStorage2.apply(this, arguments);
  15929. }
  15930. return _writeToStorage;
  15931. }()
  15932. }, {
  15933. key: "_readFromStorage",
  15934. value: function () {
  15935. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  15936. return _regenerator["default"].wrap(function _callee2$(_context2) {
  15937. while (1) {
  15938. switch (_context2.prev = _context2.next) {
  15939. case 0:
  15940. return _context2.abrupt("return", JSON.parse(localStorage.getItem("pdfjs.preferences")));
  15941. case 1:
  15942. case "end":
  15943. return _context2.stop();
  15944. }
  15945. }
  15946. }, _callee2);
  15947. }));
  15948. function _readFromStorage(_x2) {
  15949. return _readFromStorage2.apply(this, arguments);
  15950. }
  15951. return _readFromStorage;
  15952. }()
  15953. }]);
  15954. return GenericPreferences;
  15955. }(_preferences.BasePreferences);
  15956. var GenericExternalServices = /*#__PURE__*/function (_DefaultExternalServi) {
  15957. _inherits(GenericExternalServices, _DefaultExternalServi);
  15958. var _super2 = _createSuper(GenericExternalServices);
  15959. function GenericExternalServices() {
  15960. _classCallCheck(this, GenericExternalServices);
  15961. return _super2.apply(this, arguments);
  15962. }
  15963. _createClass(GenericExternalServices, null, [{
  15964. key: "createDownloadManager",
  15965. value: function createDownloadManager(options) {
  15966. return new _download_manager.DownloadManager();
  15967. }
  15968. }, {
  15969. key: "createPreferences",
  15970. value: function createPreferences() {
  15971. return new GenericPreferences();
  15972. }
  15973. }, {
  15974. key: "createL10n",
  15975. value: function createL10n(_ref) {
  15976. var _ref$locale = _ref.locale,
  15977. locale = _ref$locale === void 0 ? "en-US" : _ref$locale;
  15978. return new _genericl10n.GenericL10n(locale);
  15979. }
  15980. }, {
  15981. key: "createScripting",
  15982. value: function createScripting(_ref2) {
  15983. var sandboxBundleSrc = _ref2.sandboxBundleSrc;
  15984. return new _generic_scripting.GenericScripting(sandboxBundleSrc);
  15985. }
  15986. }]);
  15987. return GenericExternalServices;
  15988. }(_app.DefaultExternalServices);
  15989. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  15990. /***/ }),
  15991. /* 43 */
  15992. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15993. Object.defineProperty(exports, "__esModule", ({
  15994. value: true
  15995. }));
  15996. exports.BasePreferences = void 0;
  15997. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  15998. var _app_options = __webpack_require__(1);
  15999. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  16000. 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); } }
  16001. 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); }); }; }
  16002. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  16003. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16004. 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); } }
  16005. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  16006. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  16007. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  16008. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  16009. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  16010. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  16011. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  16012. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  16013. var _defaults = /*#__PURE__*/new WeakMap();
  16014. var _prefs = /*#__PURE__*/new WeakMap();
  16015. var _initializedPromise = /*#__PURE__*/new WeakMap();
  16016. var BasePreferences = /*#__PURE__*/function () {
  16017. function BasePreferences() {
  16018. var _this = this;
  16019. _classCallCheck(this, BasePreferences);
  16020. _classPrivateFieldInitSpec(this, _defaults, {
  16021. writable: true,
  16022. value: Object.freeze({
  16023. "annotationMode": 2,
  16024. "cursorToolOnLoad": 0,
  16025. "defaultZoomValue": "",
  16026. "disablePageLabels": false,
  16027. "enablePermissions": false,
  16028. "enablePrintAutoRotate": true,
  16029. "enableScripting": true,
  16030. "externalLinkTarget": 0,
  16031. "historyUpdateUrl": false,
  16032. "ignoreDestinationZoom": false,
  16033. "pageColorsBackground": "Canvas",
  16034. "pageColorsForeground": "CanvasText",
  16035. "pdfBugEnabled": false,
  16036. "renderer": "canvas",
  16037. "sidebarViewOnLoad": -1,
  16038. "scrollModeOnLoad": -1,
  16039. "spreadModeOnLoad": -1,
  16040. "textLayerMode": 1,
  16041. "useOnlyCssZoom": false,
  16042. "viewerCssTheme": 0,
  16043. "viewOnLoad": 0,
  16044. "disableAutoFetch": false,
  16045. "disableFontFace": false,
  16046. "disableRange": false,
  16047. "disableStream": false,
  16048. "enableXfa": true
  16049. })
  16050. });
  16051. _classPrivateFieldInitSpec(this, _prefs, {
  16052. writable: true,
  16053. value: Object.create(null)
  16054. });
  16055. _classPrivateFieldInitSpec(this, _initializedPromise, {
  16056. writable: true,
  16057. value: null
  16058. });
  16059. if (this.constructor === BasePreferences) {
  16060. throw new Error("Cannot initialize BasePreferences.");
  16061. }
  16062. _classPrivateFieldSet(this, _initializedPromise, this._readFromStorage(_classPrivateFieldGet(this, _defaults)).then(function (prefs) {
  16063. for (var name in _classPrivateFieldGet(_this, _defaults)) {
  16064. var prefValue = prefs === null || prefs === void 0 ? void 0 : prefs[name];
  16065. if (_typeof(prefValue) === _typeof(_classPrivateFieldGet(_this, _defaults)[name])) {
  16066. _classPrivateFieldGet(_this, _prefs)[name] = prefValue;
  16067. }
  16068. }
  16069. }));
  16070. }
  16071. _createClass(BasePreferences, [{
  16072. key: "_writeToStorage",
  16073. value: function () {
  16074. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  16075. return _regenerator["default"].wrap(function _callee$(_context) {
  16076. while (1) {
  16077. switch (_context.prev = _context.next) {
  16078. case 0:
  16079. throw new Error("Not implemented: _writeToStorage");
  16080. case 1:
  16081. case "end":
  16082. return _context.stop();
  16083. }
  16084. }
  16085. }, _callee);
  16086. }));
  16087. function _writeToStorage(_x) {
  16088. return _writeToStorage2.apply(this, arguments);
  16089. }
  16090. return _writeToStorage;
  16091. }()
  16092. }, {
  16093. key: "_readFromStorage",
  16094. value: function () {
  16095. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  16096. return _regenerator["default"].wrap(function _callee2$(_context2) {
  16097. while (1) {
  16098. switch (_context2.prev = _context2.next) {
  16099. case 0:
  16100. throw new Error("Not implemented: _readFromStorage");
  16101. case 1:
  16102. case "end":
  16103. return _context2.stop();
  16104. }
  16105. }
  16106. }, _callee2);
  16107. }));
  16108. function _readFromStorage(_x2) {
  16109. return _readFromStorage2.apply(this, arguments);
  16110. }
  16111. return _readFromStorage;
  16112. }()
  16113. }, {
  16114. key: "reset",
  16115. value: function () {
  16116. var _reset = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  16117. var _this2 = this;
  16118. var prefs;
  16119. return _regenerator["default"].wrap(function _callee3$(_context3) {
  16120. while (1) {
  16121. switch (_context3.prev = _context3.next) {
  16122. case 0:
  16123. _context3.next = 2;
  16124. return _classPrivateFieldGet(this, _initializedPromise);
  16125. case 2:
  16126. prefs = _classPrivateFieldGet(this, _prefs);
  16127. _classPrivateFieldSet(this, _prefs, Object.create(null));
  16128. return _context3.abrupt("return", this._writeToStorage(_classPrivateFieldGet(this, _defaults))["catch"](function (reason) {
  16129. _classPrivateFieldSet(_this2, _prefs, prefs);
  16130. throw reason;
  16131. }));
  16132. case 5:
  16133. case "end":
  16134. return _context3.stop();
  16135. }
  16136. }
  16137. }, _callee3, this);
  16138. }));
  16139. function reset() {
  16140. return _reset.apply(this, arguments);
  16141. }
  16142. return reset;
  16143. }()
  16144. }, {
  16145. key: "set",
  16146. value: function () {
  16147. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name, value) {
  16148. var _this3 = this;
  16149. var defaultValue, prefs, valueType, defaultType;
  16150. return _regenerator["default"].wrap(function _callee4$(_context4) {
  16151. while (1) {
  16152. switch (_context4.prev = _context4.next) {
  16153. case 0:
  16154. _context4.next = 2;
  16155. return _classPrivateFieldGet(this, _initializedPromise);
  16156. case 2:
  16157. defaultValue = _classPrivateFieldGet(this, _defaults)[name], prefs = _classPrivateFieldGet(this, _prefs);
  16158. if (!(defaultValue === undefined)) {
  16159. _context4.next = 7;
  16160. break;
  16161. }
  16162. throw new Error("Set preference: \"".concat(name, "\" is undefined."));
  16163. case 7:
  16164. if (!(value === undefined)) {
  16165. _context4.next = 9;
  16166. break;
  16167. }
  16168. throw new Error("Set preference: no value is specified.");
  16169. case 9:
  16170. valueType = _typeof(value), defaultType = _typeof(defaultValue);
  16171. if (!(valueType !== defaultType)) {
  16172. _context4.next = 18;
  16173. break;
  16174. }
  16175. if (!(valueType === "number" && defaultType === "string")) {
  16176. _context4.next = 15;
  16177. break;
  16178. }
  16179. value = value.toString();
  16180. _context4.next = 16;
  16181. break;
  16182. case 15:
  16183. throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", expected a ").concat(defaultType, "."));
  16184. case 16:
  16185. _context4.next = 20;
  16186. break;
  16187. case 18:
  16188. if (!(valueType === "number" && !Number.isInteger(value))) {
  16189. _context4.next = 20;
  16190. break;
  16191. }
  16192. throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
  16193. case 20:
  16194. _classPrivateFieldGet(this, _prefs)[name] = value;
  16195. return _context4.abrupt("return", this._writeToStorage(_classPrivateFieldGet(this, _prefs))["catch"](function (reason) {
  16196. _classPrivateFieldSet(_this3, _prefs, prefs);
  16197. throw reason;
  16198. }));
  16199. case 22:
  16200. case "end":
  16201. return _context4.stop();
  16202. }
  16203. }
  16204. }, _callee4, this);
  16205. }));
  16206. function set(_x3, _x4) {
  16207. return _set.apply(this, arguments);
  16208. }
  16209. return set;
  16210. }()
  16211. }, {
  16212. key: "get",
  16213. value: function () {
  16214. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name) {
  16215. var _classPrivateFieldGet2;
  16216. var defaultValue;
  16217. return _regenerator["default"].wrap(function _callee5$(_context5) {
  16218. while (1) {
  16219. switch (_context5.prev = _context5.next) {
  16220. case 0:
  16221. _context5.next = 2;
  16222. return _classPrivateFieldGet(this, _initializedPromise);
  16223. case 2:
  16224. defaultValue = _classPrivateFieldGet(this, _defaults)[name];
  16225. if (!(defaultValue === undefined)) {
  16226. _context5.next = 5;
  16227. break;
  16228. }
  16229. throw new Error("Get preference: \"".concat(name, "\" is undefined."));
  16230. case 5:
  16231. return _context5.abrupt("return", (_classPrivateFieldGet2 = _classPrivateFieldGet(this, _prefs)[name]) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : defaultValue);
  16232. case 6:
  16233. case "end":
  16234. return _context5.stop();
  16235. }
  16236. }
  16237. }, _callee5, this);
  16238. }));
  16239. function get(_x5) {
  16240. return _get.apply(this, arguments);
  16241. }
  16242. return get;
  16243. }()
  16244. }, {
  16245. key: "getAll",
  16246. value: function () {
  16247. var _getAll = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  16248. var obj, name, _classPrivateFieldGet3;
  16249. return _regenerator["default"].wrap(function _callee6$(_context6) {
  16250. while (1) {
  16251. switch (_context6.prev = _context6.next) {
  16252. case 0:
  16253. _context6.next = 2;
  16254. return _classPrivateFieldGet(this, _initializedPromise);
  16255. case 2:
  16256. obj = Object.create(null);
  16257. for (name in _classPrivateFieldGet(this, _defaults)) {
  16258. obj[name] = (_classPrivateFieldGet3 = _classPrivateFieldGet(this, _prefs)[name]) !== null && _classPrivateFieldGet3 !== void 0 ? _classPrivateFieldGet3 : _classPrivateFieldGet(this, _defaults)[name];
  16259. }
  16260. return _context6.abrupt("return", obj);
  16261. case 5:
  16262. case "end":
  16263. return _context6.stop();
  16264. }
  16265. }
  16266. }, _callee6, this);
  16267. }));
  16268. function getAll() {
  16269. return _getAll.apply(this, arguments);
  16270. }
  16271. return getAll;
  16272. }()
  16273. }]);
  16274. return BasePreferences;
  16275. }();
  16276. exports.BasePreferences = BasePreferences;
  16277. /***/ }),
  16278. /* 44 */
  16279. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  16280. Object.defineProperty(exports, "__esModule", ({
  16281. value: true
  16282. }));
  16283. exports.DownloadManager = void 0;
  16284. var _pdfjsLib = __webpack_require__(7);
  16285. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16286. 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); } }
  16287. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  16288. ;
  16289. function _download(blobUrl, filename) {
  16290. var a = document.createElement("a");
  16291. if (!a.click) {
  16292. throw new Error('DownloadManager: "a.click()" is not supported.');
  16293. }
  16294. a.href = blobUrl;
  16295. a.target = "_parent";
  16296. if ("download" in a) {
  16297. a.download = filename;
  16298. }
  16299. (document.body || document.documentElement).appendChild(a);
  16300. a.click();
  16301. a.remove();
  16302. }
  16303. var DownloadManager = /*#__PURE__*/function () {
  16304. function DownloadManager() {
  16305. _classCallCheck(this, DownloadManager);
  16306. this._openBlobUrls = new WeakMap();
  16307. }
  16308. _createClass(DownloadManager, [{
  16309. key: "downloadUrl",
  16310. value: function downloadUrl(url, filename) {
  16311. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  16312. console.error("downloadUrl - not a valid URL: ".concat(url));
  16313. return;
  16314. }
  16315. _download(url + "#pdfjs.action=download", filename);
  16316. }
  16317. }, {
  16318. key: "downloadData",
  16319. value: function downloadData(data, filename, contentType) {
  16320. var blobUrl = URL.createObjectURL(new Blob([data], {
  16321. type: contentType
  16322. }));
  16323. _download(blobUrl, filename);
  16324. }
  16325. }, {
  16326. key: "openOrDownloadData",
  16327. value: function openOrDownloadData(element, data, filename) {
  16328. var isPdfData = (0, _pdfjsLib.isPdfFile)(filename);
  16329. var contentType = isPdfData ? "application/pdf" : "";
  16330. if (isPdfData) {
  16331. var blobUrl = this._openBlobUrls.get(element);
  16332. if (!blobUrl) {
  16333. blobUrl = URL.createObjectURL(new Blob([data], {
  16334. type: contentType
  16335. }));
  16336. this._openBlobUrls.set(element, blobUrl);
  16337. }
  16338. var viewerUrl;
  16339. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  16340. try {
  16341. window.open(viewerUrl);
  16342. return true;
  16343. } catch (ex) {
  16344. console.error("openOrDownloadData: ".concat(ex));
  16345. URL.revokeObjectURL(blobUrl);
  16346. this._openBlobUrls["delete"](element);
  16347. }
  16348. }
  16349. this.downloadData(data, filename, contentType);
  16350. return false;
  16351. }
  16352. }, {
  16353. key: "download",
  16354. value: function download(blob, url, filename) {
  16355. var sourceEventType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "download";
  16356. var blobUrl = URL.createObjectURL(blob);
  16357. _download(blobUrl, filename);
  16358. }
  16359. }]);
  16360. return DownloadManager;
  16361. }();
  16362. exports.DownloadManager = DownloadManager;
  16363. /***/ }),
  16364. /* 45 */
  16365. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  16366. Object.defineProperty(exports, "__esModule", ({
  16367. value: true
  16368. }));
  16369. exports.GenericL10n = void 0;
  16370. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  16371. __webpack_require__(46);
  16372. var _l10n_utils = __webpack_require__(33);
  16373. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  16374. 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); } }
  16375. 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); }); }; }
  16376. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16377. 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); } }
  16378. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  16379. var webL10n = document.webL10n;
  16380. var GenericL10n = /*#__PURE__*/function () {
  16381. function GenericL10n(lang) {
  16382. _classCallCheck(this, GenericL10n);
  16383. this._lang = lang;
  16384. this._ready = new Promise(function (resolve, reject) {
  16385. webL10n.setLanguage((0, _l10n_utils.fixupLangCode)(lang), function () {
  16386. resolve(webL10n);
  16387. });
  16388. });
  16389. }
  16390. _createClass(GenericL10n, [{
  16391. key: "getLanguage",
  16392. value: function () {
  16393. var _getLanguage = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  16394. var l10n;
  16395. return _regenerator["default"].wrap(function _callee$(_context) {
  16396. while (1) {
  16397. switch (_context.prev = _context.next) {
  16398. case 0:
  16399. _context.next = 2;
  16400. return this._ready;
  16401. case 2:
  16402. l10n = _context.sent;
  16403. return _context.abrupt("return", l10n.getLanguage());
  16404. case 4:
  16405. case "end":
  16406. return _context.stop();
  16407. }
  16408. }
  16409. }, _callee, this);
  16410. }));
  16411. function getLanguage() {
  16412. return _getLanguage.apply(this, arguments);
  16413. }
  16414. return getLanguage;
  16415. }()
  16416. }, {
  16417. key: "getDirection",
  16418. value: function () {
  16419. var _getDirection = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  16420. var l10n;
  16421. return _regenerator["default"].wrap(function _callee2$(_context2) {
  16422. while (1) {
  16423. switch (_context2.prev = _context2.next) {
  16424. case 0:
  16425. _context2.next = 2;
  16426. return this._ready;
  16427. case 2:
  16428. l10n = _context2.sent;
  16429. return _context2.abrupt("return", l10n.getDirection());
  16430. case 4:
  16431. case "end":
  16432. return _context2.stop();
  16433. }
  16434. }
  16435. }, _callee2, this);
  16436. }));
  16437. function getDirection() {
  16438. return _getDirection.apply(this, arguments);
  16439. }
  16440. return getDirection;
  16441. }()
  16442. }, {
  16443. key: "get",
  16444. value: function () {
  16445. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(key) {
  16446. var args,
  16447. fallback,
  16448. l10n,
  16449. _args3 = arguments;
  16450. return _regenerator["default"].wrap(function _callee3$(_context3) {
  16451. while (1) {
  16452. switch (_context3.prev = _context3.next) {
  16453. case 0:
  16454. args = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : null;
  16455. fallback = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : (0, _l10n_utils.getL10nFallback)(key, args);
  16456. _context3.next = 4;
  16457. return this._ready;
  16458. case 4:
  16459. l10n = _context3.sent;
  16460. return _context3.abrupt("return", l10n.get(key, args, fallback));
  16461. case 6:
  16462. case "end":
  16463. return _context3.stop();
  16464. }
  16465. }
  16466. }, _callee3, this);
  16467. }));
  16468. function get(_x) {
  16469. return _get.apply(this, arguments);
  16470. }
  16471. return get;
  16472. }()
  16473. }, {
  16474. key: "translate",
  16475. value: function () {
  16476. var _translate = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(element) {
  16477. var l10n;
  16478. return _regenerator["default"].wrap(function _callee4$(_context4) {
  16479. while (1) {
  16480. switch (_context4.prev = _context4.next) {
  16481. case 0:
  16482. _context4.next = 2;
  16483. return this._ready;
  16484. case 2:
  16485. l10n = _context4.sent;
  16486. return _context4.abrupt("return", l10n.translate(element));
  16487. case 4:
  16488. case "end":
  16489. return _context4.stop();
  16490. }
  16491. }
  16492. }, _callee4, this);
  16493. }));
  16494. function translate(_x2) {
  16495. return _translate.apply(this, arguments);
  16496. }
  16497. return translate;
  16498. }()
  16499. }]);
  16500. return GenericL10n;
  16501. }();
  16502. exports.GenericL10n = GenericL10n;
  16503. /***/ }),
  16504. /* 46 */
  16505. /***/ (() => {
  16506. document.webL10n = function (window, document, undefined) {
  16507. var gL10nData = {};
  16508. var gTextData = '';
  16509. var gTextProp = 'textContent';
  16510. var gLanguage = '';
  16511. var gMacros = {};
  16512. var gReadyState = 'loading';
  16513. var gAsyncResourceLoading = true;
  16514. function getL10nResourceLinks() {
  16515. return document.querySelectorAll('link[type="application/l10n"]');
  16516. }
  16517. function getL10nDictionary() {
  16518. var script = document.querySelector('script[type="application/l10n"]');
  16519. return script ? JSON.parse(script.innerHTML) : null;
  16520. }
  16521. function getTranslatableChildren(element) {
  16522. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  16523. }
  16524. function getL10nAttributes(element) {
  16525. if (!element) return {};
  16526. var l10nId = element.getAttribute('data-l10n-id');
  16527. var l10nArgs = element.getAttribute('data-l10n-args');
  16528. var args = {};
  16529. if (l10nArgs) {
  16530. try {
  16531. args = JSON.parse(l10nArgs);
  16532. } catch (e) {
  16533. console.warn('could not parse arguments for #' + l10nId);
  16534. }
  16535. }
  16536. return {
  16537. id: l10nId,
  16538. args: args
  16539. };
  16540. }
  16541. function xhrLoadText(url, onSuccess, onFailure) {
  16542. onSuccess = onSuccess || function _onSuccess(data) {};
  16543. onFailure = onFailure || function _onFailure() {};
  16544. var xhr = new XMLHttpRequest();
  16545. xhr.open('GET', url, gAsyncResourceLoading);
  16546. if (xhr.overrideMimeType) {
  16547. xhr.overrideMimeType('text/plain; charset=utf-8');
  16548. }
  16549. xhr.onreadystatechange = function () {
  16550. if (xhr.readyState == 4) {
  16551. if (xhr.status == 200 || xhr.status === 0) {
  16552. onSuccess(xhr.responseText);
  16553. } else {
  16554. onFailure();
  16555. }
  16556. }
  16557. };
  16558. xhr.onerror = onFailure;
  16559. xhr.ontimeout = onFailure;
  16560. try {
  16561. xhr.send(null);
  16562. } catch (e) {
  16563. onFailure();
  16564. }
  16565. }
  16566. function parseResource(href, lang, successCallback, failureCallback) {
  16567. var baseURL = href.replace(/[^\/]*$/, '') || './';
  16568. function evalString(text) {
  16569. if (text.lastIndexOf('\\') < 0) return text;
  16570. 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, "'");
  16571. }
  16572. function parseProperties(text, parsedPropertiesCallback) {
  16573. var dictionary = {};
  16574. var reBlank = /^\s*|\s*$/;
  16575. var reComment = /^\s*#|^\s*$/;
  16576. var reSection = /^\s*\[(.*)\]\s*$/;
  16577. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  16578. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  16579. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  16580. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  16581. var currentLang = '*';
  16582. var genericLang = lang.split('-', 1)[0];
  16583. var skipLang = false;
  16584. var match = '';
  16585. function nextEntry() {
  16586. while (true) {
  16587. if (!entries.length) {
  16588. parsedRawLinesCallback();
  16589. return;
  16590. }
  16591. var line = entries.shift();
  16592. if (reComment.test(line)) continue;
  16593. if (extendedSyntax) {
  16594. match = reSection.exec(line);
  16595. if (match) {
  16596. currentLang = match[1].toLowerCase();
  16597. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  16598. continue;
  16599. } else if (skipLang) {
  16600. continue;
  16601. }
  16602. match = reImport.exec(line);
  16603. if (match) {
  16604. loadImport(baseURL + match[1], nextEntry);
  16605. return;
  16606. }
  16607. }
  16608. var tmp = line.match(reSplit);
  16609. if (tmp && tmp.length == 3) {
  16610. dictionary[tmp[1]] = evalString(tmp[2]);
  16611. }
  16612. }
  16613. }
  16614. nextEntry();
  16615. }
  16616. function loadImport(url, callback) {
  16617. xhrLoadText(url, function (content) {
  16618. parseRawLines(content, false, callback);
  16619. }, function () {
  16620. console.warn(url + ' not found.');
  16621. callback();
  16622. });
  16623. }
  16624. parseRawLines(text, true, function () {
  16625. parsedPropertiesCallback(dictionary);
  16626. });
  16627. }
  16628. xhrLoadText(href, function (response) {
  16629. gTextData += response;
  16630. parseProperties(response, function (data) {
  16631. for (var key in data) {
  16632. var id,
  16633. prop,
  16634. index = key.lastIndexOf('.');
  16635. if (index > 0) {
  16636. id = key.substring(0, index);
  16637. prop = key.substring(index + 1);
  16638. } else {
  16639. id = key;
  16640. prop = gTextProp;
  16641. }
  16642. if (!gL10nData[id]) {
  16643. gL10nData[id] = {};
  16644. }
  16645. gL10nData[id][prop] = data[key];
  16646. }
  16647. if (successCallback) {
  16648. successCallback();
  16649. }
  16650. });
  16651. }, failureCallback);
  16652. }
  16653. function loadLocale(lang, callback) {
  16654. if (lang) {
  16655. lang = lang.toLowerCase();
  16656. }
  16657. callback = callback || function _callback() {};
  16658. clear();
  16659. gLanguage = lang;
  16660. var langLinks = getL10nResourceLinks();
  16661. var langCount = langLinks.length;
  16662. if (langCount === 0) {
  16663. var dict = getL10nDictionary();
  16664. if (dict && dict.locales && dict.default_locale) {
  16665. console.log('using the embedded JSON directory, early way out');
  16666. gL10nData = dict.locales[lang];
  16667. if (!gL10nData) {
  16668. var defaultLocale = dict.default_locale.toLowerCase();
  16669. for (var anyCaseLang in dict.locales) {
  16670. anyCaseLang = anyCaseLang.toLowerCase();
  16671. if (anyCaseLang === lang) {
  16672. gL10nData = dict.locales[lang];
  16673. break;
  16674. } else if (anyCaseLang === defaultLocale) {
  16675. gL10nData = dict.locales[defaultLocale];
  16676. }
  16677. }
  16678. }
  16679. callback();
  16680. } else {
  16681. console.log('no resource to load, early way out');
  16682. }
  16683. gReadyState = 'complete';
  16684. return;
  16685. }
  16686. var onResourceLoaded = null;
  16687. var gResourceCount = 0;
  16688. onResourceLoaded = function onResourceLoaded() {
  16689. gResourceCount++;
  16690. if (gResourceCount >= langCount) {
  16691. callback();
  16692. gReadyState = 'complete';
  16693. }
  16694. };
  16695. function L10nResourceLink(link) {
  16696. var href = link.href;
  16697. this.load = function (lang, callback) {
  16698. parseResource(href, lang, callback, function () {
  16699. console.warn(href + ' not found.');
  16700. console.warn('"' + lang + '" resource not found');
  16701. gLanguage = '';
  16702. callback();
  16703. });
  16704. };
  16705. }
  16706. for (var i = 0; i < langCount; i++) {
  16707. var resource = new L10nResourceLink(langLinks[i]);
  16708. resource.load(lang, onResourceLoaded);
  16709. }
  16710. }
  16711. function clear() {
  16712. gL10nData = {};
  16713. gTextData = '';
  16714. gLanguage = '';
  16715. }
  16716. function getPluralRules(lang) {
  16717. var locales2rules = {
  16718. 'af': 3,
  16719. 'ak': 4,
  16720. 'am': 4,
  16721. 'ar': 1,
  16722. 'asa': 3,
  16723. 'az': 0,
  16724. 'be': 11,
  16725. 'bem': 3,
  16726. 'bez': 3,
  16727. 'bg': 3,
  16728. 'bh': 4,
  16729. 'bm': 0,
  16730. 'bn': 3,
  16731. 'bo': 0,
  16732. 'br': 20,
  16733. 'brx': 3,
  16734. 'bs': 11,
  16735. 'ca': 3,
  16736. 'cgg': 3,
  16737. 'chr': 3,
  16738. 'cs': 12,
  16739. 'cy': 17,
  16740. 'da': 3,
  16741. 'de': 3,
  16742. 'dv': 3,
  16743. 'dz': 0,
  16744. 'ee': 3,
  16745. 'el': 3,
  16746. 'en': 3,
  16747. 'eo': 3,
  16748. 'es': 3,
  16749. 'et': 3,
  16750. 'eu': 3,
  16751. 'fa': 0,
  16752. 'ff': 5,
  16753. 'fi': 3,
  16754. 'fil': 4,
  16755. 'fo': 3,
  16756. 'fr': 5,
  16757. 'fur': 3,
  16758. 'fy': 3,
  16759. 'ga': 8,
  16760. 'gd': 24,
  16761. 'gl': 3,
  16762. 'gsw': 3,
  16763. 'gu': 3,
  16764. 'guw': 4,
  16765. 'gv': 23,
  16766. 'ha': 3,
  16767. 'haw': 3,
  16768. 'he': 2,
  16769. 'hi': 4,
  16770. 'hr': 11,
  16771. 'hu': 0,
  16772. 'id': 0,
  16773. 'ig': 0,
  16774. 'ii': 0,
  16775. 'is': 3,
  16776. 'it': 3,
  16777. 'iu': 7,
  16778. 'ja': 0,
  16779. 'jmc': 3,
  16780. 'jv': 0,
  16781. 'ka': 0,
  16782. 'kab': 5,
  16783. 'kaj': 3,
  16784. 'kcg': 3,
  16785. 'kde': 0,
  16786. 'kea': 0,
  16787. 'kk': 3,
  16788. 'kl': 3,
  16789. 'km': 0,
  16790. 'kn': 0,
  16791. 'ko': 0,
  16792. 'ksb': 3,
  16793. 'ksh': 21,
  16794. 'ku': 3,
  16795. 'kw': 7,
  16796. 'lag': 18,
  16797. 'lb': 3,
  16798. 'lg': 3,
  16799. 'ln': 4,
  16800. 'lo': 0,
  16801. 'lt': 10,
  16802. 'lv': 6,
  16803. 'mas': 3,
  16804. 'mg': 4,
  16805. 'mk': 16,
  16806. 'ml': 3,
  16807. 'mn': 3,
  16808. 'mo': 9,
  16809. 'mr': 3,
  16810. 'ms': 0,
  16811. 'mt': 15,
  16812. 'my': 0,
  16813. 'nah': 3,
  16814. 'naq': 7,
  16815. 'nb': 3,
  16816. 'nd': 3,
  16817. 'ne': 3,
  16818. 'nl': 3,
  16819. 'nn': 3,
  16820. 'no': 3,
  16821. 'nr': 3,
  16822. 'nso': 4,
  16823. 'ny': 3,
  16824. 'nyn': 3,
  16825. 'om': 3,
  16826. 'or': 3,
  16827. 'pa': 3,
  16828. 'pap': 3,
  16829. 'pl': 13,
  16830. 'ps': 3,
  16831. 'pt': 3,
  16832. 'rm': 3,
  16833. 'ro': 9,
  16834. 'rof': 3,
  16835. 'ru': 11,
  16836. 'rwk': 3,
  16837. 'sah': 0,
  16838. 'saq': 3,
  16839. 'se': 7,
  16840. 'seh': 3,
  16841. 'ses': 0,
  16842. 'sg': 0,
  16843. 'sh': 11,
  16844. 'shi': 19,
  16845. 'sk': 12,
  16846. 'sl': 14,
  16847. 'sma': 7,
  16848. 'smi': 7,
  16849. 'smj': 7,
  16850. 'smn': 7,
  16851. 'sms': 7,
  16852. 'sn': 3,
  16853. 'so': 3,
  16854. 'sq': 3,
  16855. 'sr': 11,
  16856. 'ss': 3,
  16857. 'ssy': 3,
  16858. 'st': 3,
  16859. 'sv': 3,
  16860. 'sw': 3,
  16861. 'syr': 3,
  16862. 'ta': 3,
  16863. 'te': 3,
  16864. 'teo': 3,
  16865. 'th': 0,
  16866. 'ti': 4,
  16867. 'tig': 3,
  16868. 'tk': 3,
  16869. 'tl': 4,
  16870. 'tn': 3,
  16871. 'to': 0,
  16872. 'tr': 0,
  16873. 'ts': 3,
  16874. 'tzm': 22,
  16875. 'uk': 11,
  16876. 'ur': 3,
  16877. 've': 3,
  16878. 'vi': 0,
  16879. 'vun': 3,
  16880. 'wa': 4,
  16881. 'wae': 3,
  16882. 'wo': 0,
  16883. 'xh': 3,
  16884. 'xog': 3,
  16885. 'yo': 0,
  16886. 'zh': 0,
  16887. 'zu': 3
  16888. };
  16889. function isIn(n, list) {
  16890. return list.indexOf(n) !== -1;
  16891. }
  16892. function isBetween(n, start, end) {
  16893. return start <= n && n <= end;
  16894. }
  16895. var pluralRules = {
  16896. '0': function _(n) {
  16897. return 'other';
  16898. },
  16899. '1': function _(n) {
  16900. if (isBetween(n % 100, 3, 10)) return 'few';
  16901. if (n === 0) return 'zero';
  16902. if (isBetween(n % 100, 11, 99)) return 'many';
  16903. if (n == 2) return 'two';
  16904. if (n == 1) return 'one';
  16905. return 'other';
  16906. },
  16907. '2': function _(n) {
  16908. if (n !== 0 && n % 10 === 0) return 'many';
  16909. if (n == 2) return 'two';
  16910. if (n == 1) return 'one';
  16911. return 'other';
  16912. },
  16913. '3': function _(n) {
  16914. if (n == 1) return 'one';
  16915. return 'other';
  16916. },
  16917. '4': function _(n) {
  16918. if (isBetween(n, 0, 1)) return 'one';
  16919. return 'other';
  16920. },
  16921. '5': function _(n) {
  16922. if (isBetween(n, 0, 2) && n != 2) return 'one';
  16923. return 'other';
  16924. },
  16925. '6': function _(n) {
  16926. if (n === 0) return 'zero';
  16927. if (n % 10 == 1 && n % 100 != 11) return 'one';
  16928. return 'other';
  16929. },
  16930. '7': function _(n) {
  16931. if (n == 2) return 'two';
  16932. if (n == 1) return 'one';
  16933. return 'other';
  16934. },
  16935. '8': function _(n) {
  16936. if (isBetween(n, 3, 6)) return 'few';
  16937. if (isBetween(n, 7, 10)) return 'many';
  16938. if (n == 2) return 'two';
  16939. if (n == 1) return 'one';
  16940. return 'other';
  16941. },
  16942. '9': function _(n) {
  16943. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  16944. if (n == 1) return 'one';
  16945. return 'other';
  16946. },
  16947. '10': function _(n) {
  16948. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  16949. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  16950. return 'other';
  16951. },
  16952. '11': function _(n) {
  16953. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  16954. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  16955. if (n % 10 == 1 && n % 100 != 11) return 'one';
  16956. return 'other';
  16957. },
  16958. '12': function _(n) {
  16959. if (isBetween(n, 2, 4)) return 'few';
  16960. if (n == 1) return 'one';
  16961. return 'other';
  16962. },
  16963. '13': function _(n) {
  16964. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  16965. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  16966. if (n == 1) return 'one';
  16967. return 'other';
  16968. },
  16969. '14': function _(n) {
  16970. if (isBetween(n % 100, 3, 4)) return 'few';
  16971. if (n % 100 == 2) return 'two';
  16972. if (n % 100 == 1) return 'one';
  16973. return 'other';
  16974. },
  16975. '15': function _(n) {
  16976. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  16977. if (isBetween(n % 100, 11, 19)) return 'many';
  16978. if (n == 1) return 'one';
  16979. return 'other';
  16980. },
  16981. '16': function _(n) {
  16982. if (n % 10 == 1 && n != 11) return 'one';
  16983. return 'other';
  16984. },
  16985. '17': function _(n) {
  16986. if (n == 3) return 'few';
  16987. if (n === 0) return 'zero';
  16988. if (n == 6) return 'many';
  16989. if (n == 2) return 'two';
  16990. if (n == 1) return 'one';
  16991. return 'other';
  16992. },
  16993. '18': function _(n) {
  16994. if (n === 0) return 'zero';
  16995. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  16996. return 'other';
  16997. },
  16998. '19': function _(n) {
  16999. if (isBetween(n, 2, 10)) return 'few';
  17000. if (isBetween(n, 0, 1)) return 'one';
  17001. return 'other';
  17002. },
  17003. '20': function _(n) {
  17004. 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';
  17005. if (n % 1000000 === 0 && n !== 0) return 'many';
  17006. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  17007. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  17008. return 'other';
  17009. },
  17010. '21': function _(n) {
  17011. if (n === 0) return 'zero';
  17012. if (n == 1) return 'one';
  17013. return 'other';
  17014. },
  17015. '22': function _(n) {
  17016. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  17017. return 'other';
  17018. },
  17019. '23': function _(n) {
  17020. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  17021. return 'other';
  17022. },
  17023. '24': function _(n) {
  17024. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  17025. if (isIn(n, [2, 12])) return 'two';
  17026. if (isIn(n, [1, 11])) return 'one';
  17027. return 'other';
  17028. }
  17029. };
  17030. var index = locales2rules[lang.replace(/-.*$/, '')];
  17031. if (!(index in pluralRules)) {
  17032. console.warn('plural form unknown for [' + lang + ']');
  17033. return function () {
  17034. return 'other';
  17035. };
  17036. }
  17037. return pluralRules[index];
  17038. }
  17039. gMacros.plural = function (str, param, key, prop) {
  17040. var n = parseFloat(param);
  17041. if (isNaN(n)) return str;
  17042. if (prop != gTextProp) return str;
  17043. if (!gMacros._pluralRules) {
  17044. gMacros._pluralRules = getPluralRules(gLanguage);
  17045. }
  17046. var index = '[' + gMacros._pluralRules(n) + ']';
  17047. if (n === 0 && key + '[zero]' in gL10nData) {
  17048. str = gL10nData[key + '[zero]'][prop];
  17049. } else if (n == 1 && key + '[one]' in gL10nData) {
  17050. str = gL10nData[key + '[one]'][prop];
  17051. } else if (n == 2 && key + '[two]' in gL10nData) {
  17052. str = gL10nData[key + '[two]'][prop];
  17053. } else if (key + index in gL10nData) {
  17054. str = gL10nData[key + index][prop];
  17055. } else if (key + '[other]' in gL10nData) {
  17056. str = gL10nData[key + '[other]'][prop];
  17057. }
  17058. return str;
  17059. };
  17060. function getL10nData(key, args, fallback) {
  17061. var data = gL10nData[key];
  17062. if (!data) {
  17063. console.warn('#' + key + ' is undefined.');
  17064. if (!fallback) {
  17065. return null;
  17066. }
  17067. data = fallback;
  17068. }
  17069. var rv = {};
  17070. for (var prop in data) {
  17071. var str = data[prop];
  17072. str = substIndexes(str, args, key, prop);
  17073. str = substArguments(str, args, key);
  17074. rv[prop] = str;
  17075. }
  17076. return rv;
  17077. }
  17078. function substIndexes(str, args, key, prop) {
  17079. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  17080. var reMatch = reIndex.exec(str);
  17081. if (!reMatch || !reMatch.length) return str;
  17082. var macroName = reMatch[1];
  17083. var paramName = reMatch[2];
  17084. var param;
  17085. if (args && paramName in args) {
  17086. param = args[paramName];
  17087. } else if (paramName in gL10nData) {
  17088. param = gL10nData[paramName];
  17089. }
  17090. if (macroName in gMacros) {
  17091. var macro = gMacros[macroName];
  17092. str = macro(str, param, key, prop);
  17093. }
  17094. return str;
  17095. }
  17096. function substArguments(str, args, key) {
  17097. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  17098. return str.replace(reArgs, function (matched_text, arg) {
  17099. if (args && arg in args) {
  17100. return args[arg];
  17101. }
  17102. if (arg in gL10nData) {
  17103. return gL10nData[arg];
  17104. }
  17105. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  17106. return matched_text;
  17107. });
  17108. }
  17109. function translateElement(element) {
  17110. var l10n = getL10nAttributes(element);
  17111. if (!l10n.id) return;
  17112. var data = getL10nData(l10n.id, l10n.args);
  17113. if (!data) {
  17114. console.warn('#' + l10n.id + ' is undefined.');
  17115. return;
  17116. }
  17117. if (data[gTextProp]) {
  17118. if (getChildElementCount(element) === 0) {
  17119. element[gTextProp] = data[gTextProp];
  17120. } else {
  17121. var children = element.childNodes;
  17122. var found = false;
  17123. for (var i = 0, l = children.length; i < l; i++) {
  17124. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  17125. if (found) {
  17126. children[i].nodeValue = '';
  17127. } else {
  17128. children[i].nodeValue = data[gTextProp];
  17129. found = true;
  17130. }
  17131. }
  17132. }
  17133. if (!found) {
  17134. var textNode = document.createTextNode(data[gTextProp]);
  17135. element.insertBefore(textNode, element.firstChild);
  17136. }
  17137. }
  17138. delete data[gTextProp];
  17139. }
  17140. for (var k in data) {
  17141. element[k] = data[k];
  17142. }
  17143. }
  17144. function getChildElementCount(element) {
  17145. if (element.children) {
  17146. return element.children.length;
  17147. }
  17148. if (typeof element.childElementCount !== 'undefined') {
  17149. return element.childElementCount;
  17150. }
  17151. var count = 0;
  17152. for (var i = 0; i < element.childNodes.length; i++) {
  17153. count += element.nodeType === 1 ? 1 : 0;
  17154. }
  17155. return count;
  17156. }
  17157. function translateFragment(element) {
  17158. element = element || document.documentElement;
  17159. var children = getTranslatableChildren(element);
  17160. var elementCount = children.length;
  17161. for (var i = 0; i < elementCount; i++) {
  17162. translateElement(children[i]);
  17163. }
  17164. translateElement(element);
  17165. }
  17166. return {
  17167. get: function get(key, args, fallbackString) {
  17168. var index = key.lastIndexOf('.');
  17169. var prop = gTextProp;
  17170. if (index > 0) {
  17171. prop = key.substring(index + 1);
  17172. key = key.substring(0, index);
  17173. }
  17174. var fallback;
  17175. if (fallbackString) {
  17176. fallback = {};
  17177. fallback[prop] = fallbackString;
  17178. }
  17179. var data = getL10nData(key, args, fallback);
  17180. if (data && prop in data) {
  17181. return data[prop];
  17182. }
  17183. return '{{' + key + '}}';
  17184. },
  17185. getData: function getData() {
  17186. return gL10nData;
  17187. },
  17188. getText: function getText() {
  17189. return gTextData;
  17190. },
  17191. getLanguage: function getLanguage() {
  17192. return gLanguage;
  17193. },
  17194. setLanguage: function setLanguage(lang, callback) {
  17195. loadLocale(lang, function () {
  17196. if (callback) callback();
  17197. });
  17198. },
  17199. getDirection: function getDirection() {
  17200. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  17201. var shortCode = gLanguage.split('-', 1)[0];
  17202. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  17203. },
  17204. translate: translateFragment,
  17205. getReadyState: function getReadyState() {
  17206. return gReadyState;
  17207. },
  17208. ready: function ready(callback) {
  17209. if (!callback) {
  17210. return;
  17211. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  17212. window.setTimeout(function () {
  17213. callback();
  17214. });
  17215. } else if (document.addEventListener) {
  17216. document.addEventListener('localized', function once() {
  17217. document.removeEventListener('localized', once);
  17218. callback();
  17219. });
  17220. }
  17221. }
  17222. };
  17223. }(window, document);
  17224. /***/ }),
  17225. /* 47 */
  17226. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  17227. Object.defineProperty(exports, "__esModule", ({
  17228. value: true
  17229. }));
  17230. exports.GenericScripting = void 0;
  17231. exports.docPropertiesLookup = docPropertiesLookup;
  17232. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  17233. var _pdfjsLib = __webpack_require__(7);
  17234. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  17235. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  17236. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  17237. 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; }
  17238. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17239. 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); } }
  17240. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  17241. 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); } }
  17242. 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); }); }; }
  17243. function docPropertiesLookup(_x) {
  17244. return _docPropertiesLookup.apply(this, arguments);
  17245. }
  17246. function _docPropertiesLookup() {
  17247. _docPropertiesLookup = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(pdfDocument) {
  17248. var url, baseUrl, _yield$pdfDocument$ge, info, metadata, contentDispositionFilename, contentLength, _yield$pdfDocument$ge2, length;
  17249. return _regenerator["default"].wrap(function _callee4$(_context4) {
  17250. while (1) {
  17251. switch (_context4.prev = _context4.next) {
  17252. case 0:
  17253. url = "", baseUrl = url.split("#")[0];
  17254. _context4.next = 3;
  17255. return pdfDocument.getMetadata();
  17256. case 3:
  17257. _yield$pdfDocument$ge = _context4.sent;
  17258. info = _yield$pdfDocument$ge.info;
  17259. metadata = _yield$pdfDocument$ge.metadata;
  17260. contentDispositionFilename = _yield$pdfDocument$ge.contentDispositionFilename;
  17261. contentLength = _yield$pdfDocument$ge.contentLength;
  17262. if (contentLength) {
  17263. _context4.next = 14;
  17264. break;
  17265. }
  17266. _context4.next = 11;
  17267. return pdfDocument.getDownloadInfo();
  17268. case 11:
  17269. _yield$pdfDocument$ge2 = _context4.sent;
  17270. length = _yield$pdfDocument$ge2.length;
  17271. contentLength = length;
  17272. case 14:
  17273. return _context4.abrupt("return", _objectSpread(_objectSpread({}, info), {}, {
  17274. baseURL: baseUrl,
  17275. filesize: contentLength,
  17276. filename: contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(url),
  17277. metadata: metadata === null || metadata === void 0 ? void 0 : metadata.getRaw(),
  17278. authors: metadata === null || metadata === void 0 ? void 0 : metadata.get("dc:creator"),
  17279. numPages: pdfDocument.numPages,
  17280. URL: url
  17281. }));
  17282. case 15:
  17283. case "end":
  17284. return _context4.stop();
  17285. }
  17286. }
  17287. }, _callee4);
  17288. }));
  17289. return _docPropertiesLookup.apply(this, arguments);
  17290. }
  17291. var GenericScripting = /*#__PURE__*/function () {
  17292. function GenericScripting(sandboxBundleSrc) {
  17293. _classCallCheck(this, GenericScripting);
  17294. this._ready = (0, _pdfjsLib.loadScript)(sandboxBundleSrc, true).then(function () {
  17295. return window.pdfjsSandbox.QuickJSSandbox();
  17296. });
  17297. }
  17298. _createClass(GenericScripting, [{
  17299. key: "createSandbox",
  17300. value: function () {
  17301. var _createSandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(data) {
  17302. var sandbox;
  17303. return _regenerator["default"].wrap(function _callee$(_context) {
  17304. while (1) {
  17305. switch (_context.prev = _context.next) {
  17306. case 0:
  17307. _context.next = 2;
  17308. return this._ready;
  17309. case 2:
  17310. sandbox = _context.sent;
  17311. sandbox.create(data);
  17312. case 4:
  17313. case "end":
  17314. return _context.stop();
  17315. }
  17316. }
  17317. }, _callee, this);
  17318. }));
  17319. function createSandbox(_x2) {
  17320. return _createSandbox.apply(this, arguments);
  17321. }
  17322. return createSandbox;
  17323. }()
  17324. }, {
  17325. key: "dispatchEventInSandbox",
  17326. value: function () {
  17327. var _dispatchEventInSandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(event) {
  17328. var sandbox;
  17329. return _regenerator["default"].wrap(function _callee2$(_context2) {
  17330. while (1) {
  17331. switch (_context2.prev = _context2.next) {
  17332. case 0:
  17333. _context2.next = 2;
  17334. return this._ready;
  17335. case 2:
  17336. sandbox = _context2.sent;
  17337. setTimeout(function () {
  17338. return sandbox.dispatchEvent(event);
  17339. }, 0);
  17340. case 4:
  17341. case "end":
  17342. return _context2.stop();
  17343. }
  17344. }
  17345. }, _callee2, this);
  17346. }));
  17347. function dispatchEventInSandbox(_x3) {
  17348. return _dispatchEventInSandbox.apply(this, arguments);
  17349. }
  17350. return dispatchEventInSandbox;
  17351. }()
  17352. }, {
  17353. key: "destroySandbox",
  17354. value: function () {
  17355. var _destroySandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  17356. var sandbox;
  17357. return _regenerator["default"].wrap(function _callee3$(_context3) {
  17358. while (1) {
  17359. switch (_context3.prev = _context3.next) {
  17360. case 0:
  17361. _context3.next = 2;
  17362. return this._ready;
  17363. case 2:
  17364. sandbox = _context3.sent;
  17365. sandbox.nukeSandbox();
  17366. case 4:
  17367. case "end":
  17368. return _context3.stop();
  17369. }
  17370. }
  17371. }, _callee3, this);
  17372. }));
  17373. function destroySandbox() {
  17374. return _destroySandbox.apply(this, arguments);
  17375. }
  17376. return destroySandbox;
  17377. }()
  17378. }]);
  17379. return GenericScripting;
  17380. }();
  17381. exports.GenericScripting = GenericScripting;
  17382. /***/ }),
  17383. /* 48 */
  17384. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  17385. Object.defineProperty(exports, "__esModule", ({
  17386. value: true
  17387. }));
  17388. exports.PDFPrintService = PDFPrintService;
  17389. var _pdfjsLib = __webpack_require__(7);
  17390. var _app = __webpack_require__(2);
  17391. var _print_utils = __webpack_require__(49);
  17392. var activeService = null;
  17393. var dialog = null;
  17394. var overlayManager = null;
  17395. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise) {
  17396. var scratchCanvas = activeService.scratchCanvas;
  17397. var PRINT_UNITS = printResolution / _pdfjsLib.PixelsPerInch.PDF;
  17398. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  17399. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  17400. var ctx = scratchCanvas.getContext("2d");
  17401. ctx.save();
  17402. ctx.fillStyle = "rgb(255, 255, 255)";
  17403. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  17404. ctx.restore();
  17405. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  17406. var renderContext = {
  17407. canvasContext: ctx,
  17408. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  17409. viewport: pdfPage.getViewport({
  17410. scale: 1,
  17411. rotation: size.rotation
  17412. }),
  17413. intent: "print",
  17414. annotationMode: _pdfjsLib.AnnotationMode.ENABLE_STORAGE,
  17415. optionalContentConfigPromise: optionalContentConfigPromise
  17416. };
  17417. return pdfPage.render(renderContext).promise;
  17418. });
  17419. }
  17420. function PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution) {
  17421. var optionalContentConfigPromise = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  17422. var l10n = arguments.length > 5 ? arguments[5] : undefined;
  17423. this.pdfDocument = pdfDocument;
  17424. this.pagesOverview = pagesOverview;
  17425. this.printContainer = printContainer;
  17426. this._printResolution = printResolution || 150;
  17427. this._optionalContentConfigPromise = optionalContentConfigPromise || pdfDocument.getOptionalContentConfig();
  17428. this.l10n = l10n;
  17429. this.currentPage = -1;
  17430. this.scratchCanvas = document.createElement("canvas");
  17431. }
  17432. PDFPrintService.prototype = {
  17433. layout: function layout() {
  17434. this.throwIfInactive();
  17435. var body = document.querySelector("body");
  17436. body.setAttribute("data-pdfjsprinting", true);
  17437. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  17438. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  17439. }, this);
  17440. if (!hasEqualPageSizes) {
  17441. console.warn("Not all pages have the same size. The printed " + "result may be incorrect!");
  17442. }
  17443. this.pageStyleSheet = document.createElement("style");
  17444. var pageSize = this.pagesOverview[0];
  17445. this.pageStyleSheet.textContent = "@page { size: " + pageSize.width + "pt " + pageSize.height + "pt;}";
  17446. body.appendChild(this.pageStyleSheet);
  17447. },
  17448. destroy: function destroy() {
  17449. if (activeService !== this) {
  17450. return;
  17451. }
  17452. this.printContainer.textContent = "";
  17453. var body = document.querySelector("body");
  17454. body.removeAttribute("data-pdfjsprinting");
  17455. if (this.pageStyleSheet) {
  17456. this.pageStyleSheet.remove();
  17457. this.pageStyleSheet = null;
  17458. }
  17459. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  17460. this.scratchCanvas = null;
  17461. activeService = null;
  17462. ensureOverlay().then(function () {
  17463. if (overlayManager.active === dialog) {
  17464. overlayManager.close(dialog);
  17465. }
  17466. });
  17467. },
  17468. renderPages: function renderPages() {
  17469. var _this = this;
  17470. if (this.pdfDocument.isPureXfa) {
  17471. (0, _print_utils.getXfaHtmlForPrinting)(this.printContainer, this.pdfDocument);
  17472. return Promise.resolve();
  17473. }
  17474. var pageCount = this.pagesOverview.length;
  17475. var renderNextPage = function renderNextPage(resolve, reject) {
  17476. _this.throwIfInactive();
  17477. if (++_this.currentPage >= pageCount) {
  17478. renderProgress(pageCount, pageCount, _this.l10n);
  17479. resolve();
  17480. return;
  17481. }
  17482. var index = _this.currentPage;
  17483. renderProgress(index, pageCount, _this.l10n);
  17484. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index], _this._printResolution, _this._optionalContentConfigPromise).then(_this.useRenderedPage.bind(_this)).then(function () {
  17485. renderNextPage(resolve, reject);
  17486. }, reject);
  17487. };
  17488. return new Promise(renderNextPage);
  17489. },
  17490. useRenderedPage: function useRenderedPage() {
  17491. this.throwIfInactive();
  17492. var img = document.createElement("img");
  17493. var scratchCanvas = this.scratchCanvas;
  17494. if ("toBlob" in scratchCanvas) {
  17495. scratchCanvas.toBlob(function (blob) {
  17496. img.src = URL.createObjectURL(blob);
  17497. });
  17498. } else {
  17499. img.src = scratchCanvas.toDataURL();
  17500. }
  17501. var wrapper = document.createElement("div");
  17502. wrapper.className = "printedPage";
  17503. wrapper.appendChild(img);
  17504. this.printContainer.appendChild(wrapper);
  17505. return new Promise(function (resolve, reject) {
  17506. img.onload = resolve;
  17507. img.onerror = reject;
  17508. });
  17509. },
  17510. performPrint: function performPrint() {
  17511. var _this2 = this;
  17512. this.throwIfInactive();
  17513. return new Promise(function (resolve) {
  17514. setTimeout(function () {
  17515. if (!_this2.active) {
  17516. resolve();
  17517. return;
  17518. }
  17519. print.call(window);
  17520. setTimeout(resolve, 20);
  17521. }, 0);
  17522. });
  17523. },
  17524. get active() {
  17525. return this === activeService;
  17526. },
  17527. throwIfInactive: function throwIfInactive() {
  17528. if (!this.active) {
  17529. throw new Error("This print request was cancelled or completed.");
  17530. }
  17531. }
  17532. };
  17533. var print = window.print;
  17534. window.print = function () {
  17535. if (activeService) {
  17536. console.warn("Ignored window.print() because of a pending print job.");
  17537. return;
  17538. }
  17539. ensureOverlay().then(function () {
  17540. if (activeService) {
  17541. overlayManager.open(dialog);
  17542. }
  17543. });
  17544. try {
  17545. dispatchEvent("beforeprint");
  17546. } finally {
  17547. if (!activeService) {
  17548. console.error("Expected print service to be initialized.");
  17549. ensureOverlay().then(function () {
  17550. if (overlayManager.active === dialog) {
  17551. overlayManager.close(dialog);
  17552. }
  17553. });
  17554. return;
  17555. }
  17556. var activeServiceOnEntry = activeService;
  17557. activeService.renderPages().then(function () {
  17558. return activeServiceOnEntry.performPrint();
  17559. })["catch"](function () {}).then(function () {
  17560. if (activeServiceOnEntry.active) {
  17561. abort();
  17562. }
  17563. });
  17564. }
  17565. };
  17566. function dispatchEvent(eventType) {
  17567. var event = document.createEvent("CustomEvent");
  17568. event.initCustomEvent(eventType, false, false, "custom");
  17569. window.dispatchEvent(event);
  17570. }
  17571. function abort() {
  17572. if (activeService) {
  17573. activeService.destroy();
  17574. dispatchEvent("afterprint");
  17575. }
  17576. }
  17577. function renderProgress(index, total, l10n) {
  17578. dialog || (dialog = document.getElementById("printServiceDialog"));
  17579. var progress = Math.round(100 * index / total);
  17580. var progressBar = dialog.querySelector("progress");
  17581. var progressPerc = dialog.querySelector(".relative-progress");
  17582. progressBar.value = progress;
  17583. l10n.get("print_progress_percent", {
  17584. progress: progress
  17585. }).then(function (msg) {
  17586. progressPerc.textContent = msg;
  17587. });
  17588. }
  17589. window.addEventListener("keydown", function (event) {
  17590. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  17591. window.print();
  17592. event.preventDefault();
  17593. if (event.stopImmediatePropagation) {
  17594. event.stopImmediatePropagation();
  17595. } else {
  17596. event.stopPropagation();
  17597. }
  17598. }
  17599. }, true);
  17600. if ("onbeforeprint" in window) {
  17601. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  17602. if (event.detail !== "custom" && event.stopImmediatePropagation) {
  17603. event.stopImmediatePropagation();
  17604. }
  17605. };
  17606. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  17607. window.addEventListener("afterprint", stopPropagationIfNeeded);
  17608. }
  17609. var overlayPromise;
  17610. function ensureOverlay() {
  17611. if (!overlayPromise) {
  17612. overlayManager = _app.PDFViewerApplication.overlayManager;
  17613. if (!overlayManager) {
  17614. throw new Error("The overlay manager has not yet been initialized.");
  17615. }
  17616. dialog || (dialog = document.getElementById("printServiceDialog"));
  17617. overlayPromise = overlayManager.register(dialog, true);
  17618. document.getElementById("printCancel").onclick = abort;
  17619. dialog.addEventListener("close", abort);
  17620. }
  17621. return overlayPromise;
  17622. }
  17623. _app.PDFPrintServiceFactory.instance = {
  17624. supportsPrinting: true,
  17625. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, l10n) {
  17626. if (activeService) {
  17627. throw new Error("The print service is created and active.");
  17628. }
  17629. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, l10n);
  17630. return activeService;
  17631. }
  17632. };
  17633. /***/ }),
  17634. /* 49 */
  17635. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  17636. Object.defineProperty(exports, "__esModule", ({
  17637. value: true
  17638. }));
  17639. exports.getXfaHtmlForPrinting = getXfaHtmlForPrinting;
  17640. var _pdfjsLib = __webpack_require__(7);
  17641. var _pdf_link_service = __webpack_require__(10);
  17642. var _xfa_layer_builder = __webpack_require__(38);
  17643. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
  17644. 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); }
  17645. 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; }
  17646. function getXfaHtmlForPrinting(printContainer, pdfDocument) {
  17647. var xfaHtml = pdfDocument.allXfaHtml;
  17648. var linkService = new _pdf_link_service.SimpleLinkService();
  17649. var scale = Math.round(_pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100;
  17650. var _iterator = _createForOfIteratorHelper(xfaHtml.children),
  17651. _step;
  17652. try {
  17653. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  17654. var xfaPage = _step.value;
  17655. var page = document.createElement("div");
  17656. page.className = "xfaPrintedPage";
  17657. printContainer.appendChild(page);
  17658. var builder = new _xfa_layer_builder.XfaLayerBuilder({
  17659. pageDiv: page,
  17660. pdfPage: null,
  17661. annotationStorage: pdfDocument.annotationStorage,
  17662. linkService: linkService,
  17663. xfaHtml: xfaPage
  17664. });
  17665. var viewport = (0, _pdfjsLib.getXfaPageViewport)(xfaPage, {
  17666. scale: scale
  17667. });
  17668. builder.render(viewport, "print");
  17669. }
  17670. } catch (err) {
  17671. _iterator.e(err);
  17672. } finally {
  17673. _iterator.f();
  17674. }
  17675. }
  17676. /***/ })
  17677. /******/ ]);
  17678. /************************************************************************/
  17679. /******/ // The module cache
  17680. /******/ var __webpack_module_cache__ = {};
  17681. /******/
  17682. /******/ // The require function
  17683. /******/ function __webpack_require__(moduleId) {
  17684. /******/ // Check if module is in cache
  17685. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  17686. /******/ if (cachedModule !== undefined) {
  17687. /******/ return cachedModule.exports;
  17688. /******/ }
  17689. /******/ // Create a new module (and put it into the cache)
  17690. /******/ var module = __webpack_module_cache__[moduleId] = {
  17691. /******/ id: moduleId,
  17692. /******/ loaded: false,
  17693. /******/ exports: {}
  17694. /******/ };
  17695. /******/
  17696. /******/ // Execute the module function
  17697. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  17698. /******/
  17699. /******/ // Flag the module as loaded
  17700. /******/ module.loaded = true;
  17701. /******/
  17702. /******/ // Return the exports of the module
  17703. /******/ return module.exports;
  17704. /******/ }
  17705. /******/
  17706. /************************************************************************/
  17707. /******/ /* webpack/runtime/node module decorator */
  17708. /******/ (() => {
  17709. /******/ __webpack_require__.nmd = (module) => {
  17710. /******/ module.paths = [];
  17711. /******/ if (!module.children) module.children = [];
  17712. /******/ return module;
  17713. /******/ };
  17714. /******/ })();
  17715. /******/
  17716. /************************************************************************/
  17717. var __webpack_exports__ = {};
  17718. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  17719. (() => {
  17720. var exports = __webpack_exports__;
  17721. Object.defineProperty(exports, "__esModule", ({
  17722. value: true
  17723. }));
  17724. Object.defineProperty(exports, "PDFViewerApplication", ({
  17725. enumerable: true,
  17726. get: function get() {
  17727. return _app.PDFViewerApplication;
  17728. }
  17729. }));
  17730. Object.defineProperty(exports, "PDFViewerApplicationOptions", ({
  17731. enumerable: true,
  17732. get: function get() {
  17733. return _app_options.AppOptions;
  17734. }
  17735. }));
  17736. var _app_options = __webpack_require__(1);
  17737. var _app = __webpack_require__(2);
  17738. var _document$blockUnbloc, _document;
  17739. var pdfjsVersion = '2.14.305';
  17740. var pdfjsBuild = 'eaaa8b4ad';
  17741. window.PDFViewerApplication = _app.PDFViewerApplication;
  17742. window.PDFViewerApplicationOptions = _app_options.AppOptions;
  17743. ;
  17744. ;
  17745. {
  17746. __webpack_require__(42);
  17747. }
  17748. ;
  17749. {
  17750. __webpack_require__(48);
  17751. }
  17752. function getViewerConfiguration() {
  17753. var errorWrapper = null;
  17754. errorWrapper = {
  17755. container: document.getElementById("errorWrapper"),
  17756. errorMessage: document.getElementById("errorMessage"),
  17757. closeButton: document.getElementById("errorClose"),
  17758. errorMoreInfo: document.getElementById("errorMoreInfo"),
  17759. moreInfoButton: document.getElementById("errorShowMore"),
  17760. lessInfoButton: document.getElementById("errorShowLess")
  17761. };
  17762. return {
  17763. appContainer: document.body,
  17764. mainContainer: document.getElementById("viewerContainer"),
  17765. viewerContainer: document.getElementById("viewer"),
  17766. toolbar: {
  17767. container: document.getElementById("toolbarViewer"),
  17768. numPages: document.getElementById("numPages"),
  17769. pageNumber: document.getElementById("pageNumber"),
  17770. scaleSelect: document.getElementById("scaleSelect"),
  17771. customScaleOption: document.getElementById("customScaleOption"),
  17772. previous: document.getElementById("previous"),
  17773. next: document.getElementById("next"),
  17774. zoomIn: document.getElementById("zoomIn"),
  17775. zoomOut: document.getElementById("zoomOut"),
  17776. viewFind: document.getElementById("viewFind"),
  17777. openFile: document.getElementById("openFile"),
  17778. print: document.getElementById("print"),
  17779. presentationModeButton: document.getElementById("presentationMode"),
  17780. download: document.getElementById("download"),
  17781. viewBookmark: document.getElementById("viewBookmark")
  17782. },
  17783. secondaryToolbar: {
  17784. toolbar: document.getElementById("secondaryToolbar"),
  17785. toggleButton: document.getElementById("secondaryToolbarToggle"),
  17786. presentationModeButton: document.getElementById("secondaryPresentationMode"),
  17787. openFileButton: document.getElementById("secondaryOpenFile"),
  17788. printButton: document.getElementById("secondaryPrint"),
  17789. downloadButton: document.getElementById("secondaryDownload"),
  17790. viewBookmarkButton: document.getElementById("secondaryViewBookmark"),
  17791. firstPageButton: document.getElementById("firstPage"),
  17792. lastPageButton: document.getElementById("lastPage"),
  17793. pageRotateCwButton: document.getElementById("pageRotateCw"),
  17794. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  17795. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  17796. cursorHandToolButton: document.getElementById("cursorHandTool"),
  17797. scrollPageButton: document.getElementById("scrollPage"),
  17798. scrollVerticalButton: document.getElementById("scrollVertical"),
  17799. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  17800. scrollWrappedButton: document.getElementById("scrollWrapped"),
  17801. spreadNoneButton: document.getElementById("spreadNone"),
  17802. spreadOddButton: document.getElementById("spreadOdd"),
  17803. spreadEvenButton: document.getElementById("spreadEven"),
  17804. documentPropertiesButton: document.getElementById("documentProperties")
  17805. },
  17806. sidebar: {
  17807. outerContainer: document.getElementById("outerContainer"),
  17808. sidebarContainer: document.getElementById("sidebarContainer"),
  17809. toggleButton: document.getElementById("sidebarToggle"),
  17810. thumbnailButton: document.getElementById("viewThumbnail"),
  17811. outlineButton: document.getElementById("viewOutline"),
  17812. attachmentsButton: document.getElementById("viewAttachments"),
  17813. layersButton: document.getElementById("viewLayers"),
  17814. thumbnailView: document.getElementById("thumbnailView"),
  17815. outlineView: document.getElementById("outlineView"),
  17816. attachmentsView: document.getElementById("attachmentsView"),
  17817. layersView: document.getElementById("layersView"),
  17818. outlineOptionsContainer: document.getElementById("outlineOptionsContainer"),
  17819. currentOutlineItemButton: document.getElementById("currentOutlineItem")
  17820. },
  17821. sidebarResizer: {
  17822. outerContainer: document.getElementById("outerContainer"),
  17823. resizer: document.getElementById("sidebarResizer")
  17824. },
  17825. findBar: {
  17826. bar: document.getElementById("findbar"),
  17827. toggleButton: document.getElementById("viewFind"),
  17828. findField: document.getElementById("findInput"),
  17829. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  17830. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  17831. matchDiacriticsCheckbox: document.getElementById("findMatchDiacritics"),
  17832. entireWordCheckbox: document.getElementById("findEntireWord"),
  17833. findMsg: document.getElementById("findMsg"),
  17834. findResultsCount: document.getElementById("findResultsCount"),
  17835. findPreviousButton: document.getElementById("findPrevious"),
  17836. findNextButton: document.getElementById("findNext")
  17837. },
  17838. passwordOverlay: {
  17839. dialog: document.getElementById("passwordDialog"),
  17840. label: document.getElementById("passwordText"),
  17841. input: document.getElementById("password"),
  17842. submitButton: document.getElementById("passwordSubmit"),
  17843. cancelButton: document.getElementById("passwordCancel")
  17844. },
  17845. documentProperties: {
  17846. dialog: document.getElementById("documentPropertiesDialog"),
  17847. closeButton: document.getElementById("documentPropertiesClose"),
  17848. fields: {
  17849. fileName: document.getElementById("fileNameField"),
  17850. fileSize: document.getElementById("fileSizeField"),
  17851. title: document.getElementById("titleField"),
  17852. author: document.getElementById("authorField"),
  17853. subject: document.getElementById("subjectField"),
  17854. keywords: document.getElementById("keywordsField"),
  17855. creationDate: document.getElementById("creationDateField"),
  17856. modificationDate: document.getElementById("modificationDateField"),
  17857. creator: document.getElementById("creatorField"),
  17858. producer: document.getElementById("producerField"),
  17859. version: document.getElementById("versionField"),
  17860. pageCount: document.getElementById("pageCountField"),
  17861. pageSize: document.getElementById("pageSizeField"),
  17862. linearized: document.getElementById("linearizedField")
  17863. }
  17864. },
  17865. errorWrapper: errorWrapper,
  17866. printContainer: document.getElementById("printContainer"),
  17867. openFileInput: document.getElementById("fileInput"),
  17868. debuggerScriptPath: "./debugger.js"
  17869. };
  17870. }
  17871. function webViewerLoad() {
  17872. var config = getViewerConfiguration();
  17873. var event = document.createEvent("CustomEvent");
  17874. event.initCustomEvent("webviewerloaded", true, true, {
  17875. source: window
  17876. });
  17877. try {
  17878. parent.document.dispatchEvent(event);
  17879. } catch (ex) {
  17880. console.error("webviewerloaded: ".concat(ex));
  17881. document.dispatchEvent(event);
  17882. }
  17883. _app.PDFViewerApplication.run(config);
  17884. }
  17885. (_document$blockUnbloc = (_document = document).blockUnblockOnload) === null || _document$blockUnbloc === void 0 ? void 0 : _document$blockUnbloc.call(_document, true);
  17886. if (document.readyState === "interactive" || document.readyState === "complete") {
  17887. webViewerLoad();
  17888. } else {
  17889. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  17890. }
  17891. })();
  17892. /******/ })()
  17893. ;
  17894. //# sourceMappingURL=viewer.js.map