pdf.js.bytes 715 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2019 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. (function webpackUniversalModuleDefinition(root, factory) {
  23. if(typeof exports === 'object' && typeof module === 'object')
  24. module.exports = factory();
  25. else if(typeof define === 'function' && define.amd)
  26. define("pdfjs-dist/build/pdf", [], factory);
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/build/pdf"] = factory();
  29. else
  30. root["pdfjs-dist/build/pdf"] = root.pdfjsLib = factory();
  31. })(this, function() {
  32. return /******/ (function(modules) { // webpackBootstrap
  33. /******/ // The module cache
  34. /******/ var installedModules = {};
  35. /******/
  36. /******/ // The require function
  37. /******/ function __w_pdfjs_require__(moduleId) {
  38. /******/
  39. /******/ // Check if module is in cache
  40. /******/ if(installedModules[moduleId]) {
  41. /******/ return installedModules[moduleId].exports;
  42. /******/ }
  43. /******/ // Create a new module (and put it into the cache)
  44. /******/ var module = installedModules[moduleId] = {
  45. /******/ i: moduleId,
  46. /******/ l: false,
  47. /******/ exports: {}
  48. /******/ };
  49. /******/
  50. /******/ // Execute the module function
  51. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  52. /******/
  53. /******/ // Flag the module as loaded
  54. /******/ module.l = true;
  55. /******/
  56. /******/ // Return the exports of the module
  57. /******/ return module.exports;
  58. /******/ }
  59. /******/
  60. /******/
  61. /******/ // expose the modules object (__webpack_modules__)
  62. /******/ __w_pdfjs_require__.m = modules;
  63. /******/
  64. /******/ // expose the module cache
  65. /******/ __w_pdfjs_require__.c = installedModules;
  66. /******/
  67. /******/ // define getter function for harmony exports
  68. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  69. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  70. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  71. /******/ }
  72. /******/ };
  73. /******/
  74. /******/ // define __esModule on exports
  75. /******/ __w_pdfjs_require__.r = function(exports) {
  76. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  77. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  78. /******/ }
  79. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  80. /******/ };
  81. /******/
  82. /******/ // create a fake namespace object
  83. /******/ // mode & 1: value is a module id, require it
  84. /******/ // mode & 2: merge all properties of value into the ns
  85. /******/ // mode & 4: return value when already ns object
  86. /******/ // mode & 8|1: behave like require
  87. /******/ __w_pdfjs_require__.t = function(value, mode) {
  88. /******/ if(mode & 1) value = __w_pdfjs_require__(value);
  89. /******/ if(mode & 8) return value;
  90. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  91. /******/ var ns = Object.create(null);
  92. /******/ __w_pdfjs_require__.r(ns);
  93. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  94. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __w_pdfjs_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  95. /******/ return ns;
  96. /******/ };
  97. /******/
  98. /******/ // getDefaultExport function for compatibility with non-harmony modules
  99. /******/ __w_pdfjs_require__.n = function(module) {
  100. /******/ var getter = module && module.__esModule ?
  101. /******/ function getDefault() { return module['default']; } :
  102. /******/ function getModuleExports() { return module; };
  103. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  104. /******/ return getter;
  105. /******/ };
  106. /******/
  107. /******/ // Object.prototype.hasOwnProperty.call
  108. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  109. /******/
  110. /******/ // __webpack_public_path__
  111. /******/ __w_pdfjs_require__.p = "";
  112. /******/
  113. /******/
  114. /******/ // Load entry module and return exports
  115. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 0);
  116. /******/ })
  117. /************************************************************************/
  118. /******/ ([
  119. /* 0 */
  120. /***/ (function(module, exports, __w_pdfjs_require__) {
  121. "use strict";
  122. var pdfjsVersion = '2.2.228';
  123. var pdfjsBuild = 'd7afb74a';
  124. var pdfjsSharedUtil = __w_pdfjs_require__(1);
  125. var pdfjsDisplayAPI = __w_pdfjs_require__(147);
  126. var pdfjsDisplayTextLayer = __w_pdfjs_require__(162);
  127. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(163);
  128. var pdfjsDisplayDisplayUtils = __w_pdfjs_require__(151);
  129. var pdfjsDisplaySVG = __w_pdfjs_require__(164);
  130. var pdfjsDisplayWorkerOptions = __w_pdfjs_require__(156);
  131. var pdfjsDisplayAPICompatibility = __w_pdfjs_require__(153);
  132. {
  133. var isNodeJS = __w_pdfjs_require__(4);
  134. if (isNodeJS()) {
  135. var PDFNodeStream = __w_pdfjs_require__(165).PDFNodeStream;
  136. pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) {
  137. return new PDFNodeStream(params);
  138. });
  139. } else {
  140. var PDFNetworkStream = __w_pdfjs_require__(168).PDFNetworkStream;
  141. var PDFFetchStream;
  142. if (pdfjsDisplayDisplayUtils.isFetchSupported()) {
  143. PDFFetchStream = __w_pdfjs_require__(169).PDFFetchStream;
  144. }
  145. pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) {
  146. if (PDFFetchStream && pdfjsDisplayDisplayUtils.isValidFetchUrl(params.url)) {
  147. return new PDFFetchStream(params);
  148. }
  149. return new PDFNetworkStream(params);
  150. });
  151. }
  152. }
  153. exports.build = pdfjsDisplayAPI.build;
  154. exports.version = pdfjsDisplayAPI.version;
  155. exports.getDocument = pdfjsDisplayAPI.getDocument;
  156. exports.LoopbackPort = pdfjsDisplayAPI.LoopbackPort;
  157. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  158. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  159. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  160. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  161. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  162. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  163. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  164. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  165. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  166. exports.NativeImageDecoding = pdfjsSharedUtil.NativeImageDecoding;
  167. exports.CMapCompressionType = pdfjsSharedUtil.CMapCompressionType;
  168. exports.PermissionFlag = pdfjsSharedUtil.PermissionFlag;
  169. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  170. exports.OPS = pdfjsSharedUtil.OPS;
  171. exports.VerbosityLevel = pdfjsSharedUtil.VerbosityLevel;
  172. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  173. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  174. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  175. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  176. exports.shadow = pdfjsSharedUtil.shadow;
  177. exports.Util = pdfjsSharedUtil.Util;
  178. exports.ReadableStream = pdfjsSharedUtil.ReadableStream;
  179. exports.URL = pdfjsSharedUtil.URL;
  180. exports.RenderingCancelledException = pdfjsDisplayDisplayUtils.RenderingCancelledException;
  181. exports.getFilenameFromUrl = pdfjsDisplayDisplayUtils.getFilenameFromUrl;
  182. exports.LinkTarget = pdfjsDisplayDisplayUtils.LinkTarget;
  183. exports.addLinkAttributes = pdfjsDisplayDisplayUtils.addLinkAttributes;
  184. exports.loadScript = pdfjsDisplayDisplayUtils.loadScript;
  185. exports.PDFDateString = pdfjsDisplayDisplayUtils.PDFDateString;
  186. exports.GlobalWorkerOptions = pdfjsDisplayWorkerOptions.GlobalWorkerOptions;
  187. exports.apiCompatibilityParams = pdfjsDisplayAPICompatibility.apiCompatibilityParams;
  188. /***/ }),
  189. /* 1 */
  190. /***/ (function(module, exports, __w_pdfjs_require__) {
  191. "use strict";
  192. Object.defineProperty(exports, "__esModule", {
  193. value: true
  194. });
  195. exports.arrayByteLength = arrayByteLength;
  196. exports.arraysToBytes = arraysToBytes;
  197. exports.assert = assert;
  198. exports.bytesToString = bytesToString;
  199. exports.createPromiseCapability = createPromiseCapability;
  200. exports.getVerbosityLevel = getVerbosityLevel;
  201. exports.info = info;
  202. exports.isArrayBuffer = isArrayBuffer;
  203. exports.isArrayEqual = isArrayEqual;
  204. exports.isBool = isBool;
  205. exports.isEmptyObj = isEmptyObj;
  206. exports.isNum = isNum;
  207. exports.isString = isString;
  208. exports.isSpace = isSpace;
  209. exports.isSameOrigin = isSameOrigin;
  210. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  211. exports.isLittleEndian = isLittleEndian;
  212. exports.isEvalSupported = isEvalSupported;
  213. exports.log2 = log2;
  214. exports.readInt8 = readInt8;
  215. exports.readUint16 = readUint16;
  216. exports.readUint32 = readUint32;
  217. exports.removeNullCharacters = removeNullCharacters;
  218. exports.setVerbosityLevel = setVerbosityLevel;
  219. exports.shadow = shadow;
  220. exports.string32 = string32;
  221. exports.stringToBytes = stringToBytes;
  222. exports.stringToPDFString = stringToPDFString;
  223. exports.stringToUTF8String = stringToUTF8String;
  224. exports.utf8StringToString = utf8StringToString;
  225. exports.warn = warn;
  226. exports.unreachable = unreachable;
  227. Object.defineProperty(exports, "ReadableStream", {
  228. enumerable: true,
  229. get: function get() {
  230. return _streams_polyfill.ReadableStream;
  231. }
  232. });
  233. Object.defineProperty(exports, "URL", {
  234. enumerable: true,
  235. get: function get() {
  236. return _url_polyfill.URL;
  237. }
  238. });
  239. exports.createObjectURL = exports.FormatError = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = void 0;
  240. __w_pdfjs_require__(2);
  241. var _streams_polyfill = __w_pdfjs_require__(143);
  242. var _url_polyfill = __w_pdfjs_require__(145);
  243. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  244. var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  245. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  246. var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  247. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  248. var NativeImageDecoding = {
  249. NONE: 'none',
  250. DECODE: 'decode',
  251. DISPLAY: 'display'
  252. };
  253. exports.NativeImageDecoding = NativeImageDecoding;
  254. var PermissionFlag = {
  255. PRINT: 0x04,
  256. MODIFY_CONTENTS: 0x08,
  257. COPY: 0x10,
  258. MODIFY_ANNOTATIONS: 0x20,
  259. FILL_INTERACTIVE_FORMS: 0x100,
  260. COPY_FOR_ACCESSIBILITY: 0x200,
  261. ASSEMBLE: 0x400,
  262. PRINT_HIGH_QUALITY: 0x800
  263. };
  264. exports.PermissionFlag = PermissionFlag;
  265. var TextRenderingMode = {
  266. FILL: 0,
  267. STROKE: 1,
  268. FILL_STROKE: 2,
  269. INVISIBLE: 3,
  270. FILL_ADD_TO_PATH: 4,
  271. STROKE_ADD_TO_PATH: 5,
  272. FILL_STROKE_ADD_TO_PATH: 6,
  273. ADD_TO_PATH: 7,
  274. FILL_STROKE_MASK: 3,
  275. ADD_TO_PATH_FLAG: 4
  276. };
  277. exports.TextRenderingMode = TextRenderingMode;
  278. var ImageKind = {
  279. GRAYSCALE_1BPP: 1,
  280. RGB_24BPP: 2,
  281. RGBA_32BPP: 3
  282. };
  283. exports.ImageKind = ImageKind;
  284. var AnnotationType = {
  285. TEXT: 1,
  286. LINK: 2,
  287. FREETEXT: 3,
  288. LINE: 4,
  289. SQUARE: 5,
  290. CIRCLE: 6,
  291. POLYGON: 7,
  292. POLYLINE: 8,
  293. HIGHLIGHT: 9,
  294. UNDERLINE: 10,
  295. SQUIGGLY: 11,
  296. STRIKEOUT: 12,
  297. STAMP: 13,
  298. CARET: 14,
  299. INK: 15,
  300. POPUP: 16,
  301. FILEATTACHMENT: 17,
  302. SOUND: 18,
  303. MOVIE: 19,
  304. WIDGET: 20,
  305. SCREEN: 21,
  306. PRINTERMARK: 22,
  307. TRAPNET: 23,
  308. WATERMARK: 24,
  309. THREED: 25,
  310. REDACT: 26
  311. };
  312. exports.AnnotationType = AnnotationType;
  313. var AnnotationFlag = {
  314. INVISIBLE: 0x01,
  315. HIDDEN: 0x02,
  316. PRINT: 0x04,
  317. NOZOOM: 0x08,
  318. NOROTATE: 0x10,
  319. NOVIEW: 0x20,
  320. READONLY: 0x40,
  321. LOCKED: 0x80,
  322. TOGGLENOVIEW: 0x100,
  323. LOCKEDCONTENTS: 0x200
  324. };
  325. exports.AnnotationFlag = AnnotationFlag;
  326. var AnnotationFieldFlag = {
  327. READONLY: 0x0000001,
  328. REQUIRED: 0x0000002,
  329. NOEXPORT: 0x0000004,
  330. MULTILINE: 0x0001000,
  331. PASSWORD: 0x0002000,
  332. NOTOGGLETOOFF: 0x0004000,
  333. RADIO: 0x0008000,
  334. PUSHBUTTON: 0x0010000,
  335. COMBO: 0x0020000,
  336. EDIT: 0x0040000,
  337. SORT: 0x0080000,
  338. FILESELECT: 0x0100000,
  339. MULTISELECT: 0x0200000,
  340. DONOTSPELLCHECK: 0x0400000,
  341. DONOTSCROLL: 0x0800000,
  342. COMB: 0x1000000,
  343. RICHTEXT: 0x2000000,
  344. RADIOSINUNISON: 0x2000000,
  345. COMMITONSELCHANGE: 0x4000000
  346. };
  347. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  348. var AnnotationBorderStyleType = {
  349. SOLID: 1,
  350. DASHED: 2,
  351. BEVELED: 3,
  352. INSET: 4,
  353. UNDERLINE: 5
  354. };
  355. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  356. var StreamType = {
  357. UNKNOWN: 0,
  358. FLATE: 1,
  359. LZW: 2,
  360. DCT: 3,
  361. JPX: 4,
  362. JBIG: 5,
  363. A85: 6,
  364. AHX: 7,
  365. CCF: 8,
  366. RL: 9
  367. };
  368. exports.StreamType = StreamType;
  369. var FontType = {
  370. UNKNOWN: 0,
  371. TYPE1: 1,
  372. TYPE1C: 2,
  373. CIDFONTTYPE0: 3,
  374. CIDFONTTYPE0C: 4,
  375. TRUETYPE: 5,
  376. CIDFONTTYPE2: 6,
  377. TYPE3: 7,
  378. OPENTYPE: 8,
  379. TYPE0: 9,
  380. MMTYPE1: 10
  381. };
  382. exports.FontType = FontType;
  383. var VerbosityLevel = {
  384. ERRORS: 0,
  385. WARNINGS: 1,
  386. INFOS: 5
  387. };
  388. exports.VerbosityLevel = VerbosityLevel;
  389. var CMapCompressionType = {
  390. NONE: 0,
  391. BINARY: 1,
  392. STREAM: 2
  393. };
  394. exports.CMapCompressionType = CMapCompressionType;
  395. var OPS = {
  396. dependency: 1,
  397. setLineWidth: 2,
  398. setLineCap: 3,
  399. setLineJoin: 4,
  400. setMiterLimit: 5,
  401. setDash: 6,
  402. setRenderingIntent: 7,
  403. setFlatness: 8,
  404. setGState: 9,
  405. save: 10,
  406. restore: 11,
  407. transform: 12,
  408. moveTo: 13,
  409. lineTo: 14,
  410. curveTo: 15,
  411. curveTo2: 16,
  412. curveTo3: 17,
  413. closePath: 18,
  414. rectangle: 19,
  415. stroke: 20,
  416. closeStroke: 21,
  417. fill: 22,
  418. eoFill: 23,
  419. fillStroke: 24,
  420. eoFillStroke: 25,
  421. closeFillStroke: 26,
  422. closeEOFillStroke: 27,
  423. endPath: 28,
  424. clip: 29,
  425. eoClip: 30,
  426. beginText: 31,
  427. endText: 32,
  428. setCharSpacing: 33,
  429. setWordSpacing: 34,
  430. setHScale: 35,
  431. setLeading: 36,
  432. setFont: 37,
  433. setTextRenderingMode: 38,
  434. setTextRise: 39,
  435. moveText: 40,
  436. setLeadingMoveText: 41,
  437. setTextMatrix: 42,
  438. nextLine: 43,
  439. showText: 44,
  440. showSpacedText: 45,
  441. nextLineShowText: 46,
  442. nextLineSetSpacingShowText: 47,
  443. setCharWidth: 48,
  444. setCharWidthAndBounds: 49,
  445. setStrokeColorSpace: 50,
  446. setFillColorSpace: 51,
  447. setStrokeColor: 52,
  448. setStrokeColorN: 53,
  449. setFillColor: 54,
  450. setFillColorN: 55,
  451. setStrokeGray: 56,
  452. setFillGray: 57,
  453. setStrokeRGBColor: 58,
  454. setFillRGBColor: 59,
  455. setStrokeCMYKColor: 60,
  456. setFillCMYKColor: 61,
  457. shadingFill: 62,
  458. beginInlineImage: 63,
  459. beginImageData: 64,
  460. endInlineImage: 65,
  461. paintXObject: 66,
  462. markPoint: 67,
  463. markPointProps: 68,
  464. beginMarkedContent: 69,
  465. beginMarkedContentProps: 70,
  466. endMarkedContent: 71,
  467. beginCompat: 72,
  468. endCompat: 73,
  469. paintFormXObjectBegin: 74,
  470. paintFormXObjectEnd: 75,
  471. beginGroup: 76,
  472. endGroup: 77,
  473. beginAnnotations: 78,
  474. endAnnotations: 79,
  475. beginAnnotation: 80,
  476. endAnnotation: 81,
  477. paintJpegXObject: 82,
  478. paintImageMaskXObject: 83,
  479. paintImageMaskXObjectGroup: 84,
  480. paintImageXObject: 85,
  481. paintInlineImageXObject: 86,
  482. paintInlineImageXObjectGroup: 87,
  483. paintImageXObjectRepeat: 88,
  484. paintImageMaskXObjectRepeat: 89,
  485. paintSolidColorImageMask: 90,
  486. constructPath: 91
  487. };
  488. exports.OPS = OPS;
  489. var UNSUPPORTED_FEATURES = {
  490. unknown: 'unknown',
  491. forms: 'forms',
  492. javaScript: 'javaScript',
  493. smask: 'smask',
  494. shadingPattern: 'shadingPattern',
  495. font: 'font'
  496. };
  497. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  498. var PasswordResponses = {
  499. NEED_PASSWORD: 1,
  500. INCORRECT_PASSWORD: 2
  501. };
  502. exports.PasswordResponses = PasswordResponses;
  503. var verbosity = VerbosityLevel.WARNINGS;
  504. function setVerbosityLevel(level) {
  505. if (Number.isInteger(level)) {
  506. verbosity = level;
  507. }
  508. }
  509. function getVerbosityLevel() {
  510. return verbosity;
  511. }
  512. function info(msg) {
  513. if (verbosity >= VerbosityLevel.INFOS) {
  514. console.log('Info: ' + msg);
  515. }
  516. }
  517. function warn(msg) {
  518. if (verbosity >= VerbosityLevel.WARNINGS) {
  519. console.log('Warning: ' + msg);
  520. }
  521. }
  522. function unreachable(msg) {
  523. throw new Error(msg);
  524. }
  525. function assert(cond, msg) {
  526. if (!cond) {
  527. unreachable(msg);
  528. }
  529. }
  530. function isSameOrigin(baseUrl, otherUrl) {
  531. try {
  532. var base = new _url_polyfill.URL(baseUrl);
  533. if (!base.origin || base.origin === 'null') {
  534. return false;
  535. }
  536. } catch (e) {
  537. return false;
  538. }
  539. var other = new _url_polyfill.URL(otherUrl, base);
  540. return base.origin === other.origin;
  541. }
  542. function _isValidProtocol(url) {
  543. if (!url) {
  544. return false;
  545. }
  546. switch (url.protocol) {
  547. case 'http:':
  548. case 'https:':
  549. case 'ftp:':
  550. case 'mailto:':
  551. case 'tel:':
  552. return true;
  553. default:
  554. return false;
  555. }
  556. }
  557. function createValidAbsoluteUrl(url, baseUrl) {
  558. if (!url) {
  559. return null;
  560. }
  561. try {
  562. var absoluteUrl = baseUrl ? new _url_polyfill.URL(url, baseUrl) : new _url_polyfill.URL(url);
  563. if (_isValidProtocol(absoluteUrl)) {
  564. return absoluteUrl;
  565. }
  566. } catch (ex) {}
  567. return null;
  568. }
  569. function shadow(obj, prop, value) {
  570. Object.defineProperty(obj, prop, {
  571. value: value,
  572. enumerable: true,
  573. configurable: true,
  574. writable: false
  575. });
  576. return value;
  577. }
  578. var PasswordException = function PasswordExceptionClosure() {
  579. function PasswordException(msg, code) {
  580. this.name = 'PasswordException';
  581. this.message = msg;
  582. this.code = code;
  583. }
  584. PasswordException.prototype = new Error();
  585. PasswordException.constructor = PasswordException;
  586. return PasswordException;
  587. }();
  588. exports.PasswordException = PasswordException;
  589. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  590. function UnknownErrorException(msg, details) {
  591. this.name = 'UnknownErrorException';
  592. this.message = msg;
  593. this.details = details;
  594. }
  595. UnknownErrorException.prototype = new Error();
  596. UnknownErrorException.constructor = UnknownErrorException;
  597. return UnknownErrorException;
  598. }();
  599. exports.UnknownErrorException = UnknownErrorException;
  600. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  601. function InvalidPDFException(msg) {
  602. this.name = 'InvalidPDFException';
  603. this.message = msg;
  604. }
  605. InvalidPDFException.prototype = new Error();
  606. InvalidPDFException.constructor = InvalidPDFException;
  607. return InvalidPDFException;
  608. }();
  609. exports.InvalidPDFException = InvalidPDFException;
  610. var MissingPDFException = function MissingPDFExceptionClosure() {
  611. function MissingPDFException(msg) {
  612. this.name = 'MissingPDFException';
  613. this.message = msg;
  614. }
  615. MissingPDFException.prototype = new Error();
  616. MissingPDFException.constructor = MissingPDFException;
  617. return MissingPDFException;
  618. }();
  619. exports.MissingPDFException = MissingPDFException;
  620. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  621. function UnexpectedResponseException(msg, status) {
  622. this.name = 'UnexpectedResponseException';
  623. this.message = msg;
  624. this.status = status;
  625. }
  626. UnexpectedResponseException.prototype = new Error();
  627. UnexpectedResponseException.constructor = UnexpectedResponseException;
  628. return UnexpectedResponseException;
  629. }();
  630. exports.UnexpectedResponseException = UnexpectedResponseException;
  631. var FormatError = function FormatErrorClosure() {
  632. function FormatError(msg) {
  633. this.message = msg;
  634. }
  635. FormatError.prototype = new Error();
  636. FormatError.prototype.name = 'FormatError';
  637. FormatError.constructor = FormatError;
  638. return FormatError;
  639. }();
  640. exports.FormatError = FormatError;
  641. var AbortException = function AbortExceptionClosure() {
  642. function AbortException(msg) {
  643. this.name = 'AbortException';
  644. this.message = msg;
  645. }
  646. AbortException.prototype = new Error();
  647. AbortException.constructor = AbortException;
  648. return AbortException;
  649. }();
  650. exports.AbortException = AbortException;
  651. var NullCharactersRegExp = /\x00/g;
  652. function removeNullCharacters(str) {
  653. if (typeof str !== 'string') {
  654. warn('The argument for removeNullCharacters must be a string.');
  655. return str;
  656. }
  657. return str.replace(NullCharactersRegExp, '');
  658. }
  659. function bytesToString(bytes) {
  660. assert(bytes !== null && _typeof(bytes) === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  661. var length = bytes.length;
  662. var MAX_ARGUMENT_COUNT = 8192;
  663. if (length < MAX_ARGUMENT_COUNT) {
  664. return String.fromCharCode.apply(null, bytes);
  665. }
  666. var strBuf = [];
  667. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  668. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  669. var chunk = bytes.subarray(i, chunkEnd);
  670. strBuf.push(String.fromCharCode.apply(null, chunk));
  671. }
  672. return strBuf.join('');
  673. }
  674. function stringToBytes(str) {
  675. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  676. var length = str.length;
  677. var bytes = new Uint8Array(length);
  678. for (var i = 0; i < length; ++i) {
  679. bytes[i] = str.charCodeAt(i) & 0xFF;
  680. }
  681. return bytes;
  682. }
  683. function arrayByteLength(arr) {
  684. if (arr.length !== undefined) {
  685. return arr.length;
  686. }
  687. assert(arr.byteLength !== undefined);
  688. return arr.byteLength;
  689. }
  690. function arraysToBytes(arr) {
  691. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  692. return arr[0];
  693. }
  694. var resultLength = 0;
  695. var i,
  696. ii = arr.length;
  697. var item, itemLength;
  698. for (i = 0; i < ii; i++) {
  699. item = arr[i];
  700. itemLength = arrayByteLength(item);
  701. resultLength += itemLength;
  702. }
  703. var pos = 0;
  704. var data = new Uint8Array(resultLength);
  705. for (i = 0; i < ii; i++) {
  706. item = arr[i];
  707. if (!(item instanceof Uint8Array)) {
  708. if (typeof item === 'string') {
  709. item = stringToBytes(item);
  710. } else {
  711. item = new Uint8Array(item);
  712. }
  713. }
  714. itemLength = item.byteLength;
  715. data.set(item, pos);
  716. pos += itemLength;
  717. }
  718. return data;
  719. }
  720. function string32(value) {
  721. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  722. }
  723. function log2(x) {
  724. if (x <= 0) {
  725. return 0;
  726. }
  727. return Math.ceil(Math.log2(x));
  728. }
  729. function readInt8(data, start) {
  730. return data[start] << 24 >> 24;
  731. }
  732. function readUint16(data, offset) {
  733. return data[offset] << 8 | data[offset + 1];
  734. }
  735. function readUint32(data, offset) {
  736. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  737. }
  738. function isLittleEndian() {
  739. var buffer8 = new Uint8Array(4);
  740. buffer8[0] = 1;
  741. var view32 = new Uint32Array(buffer8.buffer, 0, 1);
  742. return view32[0] === 1;
  743. }
  744. function isEvalSupported() {
  745. try {
  746. new Function('');
  747. return true;
  748. } catch (e) {
  749. return false;
  750. }
  751. }
  752. var Util = function UtilClosure() {
  753. function Util() {}
  754. var rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')'];
  755. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  756. rgbBuf[1] = r;
  757. rgbBuf[3] = g;
  758. rgbBuf[5] = b;
  759. return rgbBuf.join('');
  760. };
  761. Util.transform = function Util_transform(m1, m2) {
  762. return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
  763. };
  764. Util.applyTransform = function Util_applyTransform(p, m) {
  765. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  766. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  767. return [xt, yt];
  768. };
  769. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  770. var d = m[0] * m[3] - m[1] * m[2];
  771. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  772. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  773. return [xt, yt];
  774. };
  775. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  776. var p1 = Util.applyTransform(r, m);
  777. var p2 = Util.applyTransform(r.slice(2, 4), m);
  778. var p3 = Util.applyTransform([r[0], r[3]], m);
  779. var p4 = Util.applyTransform([r[2], r[1]], m);
  780. return [Math.min(p1[0], p2[0], p3[0], p4[0]), Math.min(p1[1], p2[1], p3[1], p4[1]), Math.max(p1[0], p2[0], p3[0], p4[0]), Math.max(p1[1], p2[1], p3[1], p4[1])];
  781. };
  782. Util.inverseTransform = function Util_inverseTransform(m) {
  783. var d = m[0] * m[3] - m[1] * m[2];
  784. return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
  785. };
  786. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  787. return [m[0] * v[0] + m[1] * v[1] + m[2] * v[2], m[3] * v[0] + m[4] * v[1] + m[5] * v[2], m[6] * v[0] + m[7] * v[1] + m[8] * v[2]];
  788. };
  789. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  790. var transpose = [m[0], m[2], m[1], m[3]];
  791. var a = m[0] * transpose[0] + m[1] * transpose[2];
  792. var b = m[0] * transpose[1] + m[1] * transpose[3];
  793. var c = m[2] * transpose[0] + m[3] * transpose[2];
  794. var d = m[2] * transpose[1] + m[3] * transpose[3];
  795. var first = (a + d) / 2;
  796. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  797. var sx = first + second || 1;
  798. var sy = first - second || 1;
  799. return [Math.sqrt(sx), Math.sqrt(sy)];
  800. };
  801. Util.normalizeRect = function Util_normalizeRect(rect) {
  802. var r = rect.slice(0);
  803. if (rect[0] > rect[2]) {
  804. r[0] = rect[2];
  805. r[2] = rect[0];
  806. }
  807. if (rect[1] > rect[3]) {
  808. r[1] = rect[3];
  809. r[3] = rect[1];
  810. }
  811. return r;
  812. };
  813. Util.intersect = function Util_intersect(rect1, rect2) {
  814. function compare(a, b) {
  815. return a - b;
  816. }
  817. var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare),
  818. orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare),
  819. result = [];
  820. rect1 = Util.normalizeRect(rect1);
  821. rect2 = Util.normalizeRect(rect2);
  822. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  823. result[0] = orderedX[1];
  824. result[2] = orderedX[2];
  825. } else {
  826. return false;
  827. }
  828. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  829. result[1] = orderedY[1];
  830. result[3] = orderedY[2];
  831. } else {
  832. return false;
  833. }
  834. return result;
  835. };
  836. return Util;
  837. }();
  838. exports.Util = Util;
  839. var PDFStringTranslateTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2D8, 0x2C7, 0x2C6, 0x2D9, 0x2DD, 0x2DB, 0x2DA, 0x2DC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203A, 0x2212, 0x2030, 0x201E, 0x201C, 0x201D, 0x2018, 0x2019, 0x201A, 0x2122, 0xFB01, 0xFB02, 0x141, 0x152, 0x160, 0x178, 0x17D, 0x131, 0x142, 0x153, 0x161, 0x17E, 0, 0x20AC];
  840. function stringToPDFString(str) {
  841. var i,
  842. n = str.length,
  843. strBuf = [];
  844. if (str[0] === '\xFE' && str[1] === '\xFF') {
  845. for (i = 2; i < n; i += 2) {
  846. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  847. }
  848. } else {
  849. for (i = 0; i < n; ++i) {
  850. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  851. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  852. }
  853. }
  854. return strBuf.join('');
  855. }
  856. function stringToUTF8String(str) {
  857. return decodeURIComponent(escape(str));
  858. }
  859. function utf8StringToString(str) {
  860. return unescape(encodeURIComponent(str));
  861. }
  862. function isEmptyObj(obj) {
  863. for (var key in obj) {
  864. return false;
  865. }
  866. return true;
  867. }
  868. function isBool(v) {
  869. return typeof v === 'boolean';
  870. }
  871. function isNum(v) {
  872. return typeof v === 'number';
  873. }
  874. function isString(v) {
  875. return typeof v === 'string';
  876. }
  877. function isArrayBuffer(v) {
  878. return _typeof(v) === 'object' && v !== null && v.byteLength !== undefined;
  879. }
  880. function isArrayEqual(arr1, arr2) {
  881. if (arr1.length !== arr2.length) {
  882. return false;
  883. }
  884. return arr1.every(function (element, index) {
  885. return element === arr2[index];
  886. });
  887. }
  888. function isSpace(ch) {
  889. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  890. }
  891. function createPromiseCapability() {
  892. var capability = Object.create(null);
  893. var isSettled = false;
  894. Object.defineProperty(capability, 'settled', {
  895. get: function get() {
  896. return isSettled;
  897. }
  898. });
  899. capability.promise = new Promise(function (resolve, reject) {
  900. capability.resolve = function (data) {
  901. isSettled = true;
  902. resolve(data);
  903. };
  904. capability.reject = function (reason) {
  905. isSettled = true;
  906. reject(reason);
  907. };
  908. });
  909. return capability;
  910. }
  911. var createObjectURL = function createObjectURLClosure() {
  912. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  913. return function createObjectURL(data, contentType) {
  914. var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  915. if (!forceDataSchema && _url_polyfill.URL.createObjectURL) {
  916. var blob = new Blob([data], {
  917. type: contentType
  918. });
  919. return _url_polyfill.URL.createObjectURL(blob);
  920. }
  921. var buffer = 'data:' + contentType + ';base64,';
  922. for (var i = 0, ii = data.length; i < ii; i += 3) {
  923. var b1 = data[i] & 0xFF;
  924. var b2 = data[i + 1] & 0xFF;
  925. var b3 = data[i + 2] & 0xFF;
  926. var d1 = b1 >> 2,
  927. d2 = (b1 & 3) << 4 | b2 >> 4;
  928. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  929. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  930. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  931. }
  932. return buffer;
  933. };
  934. }();
  935. exports.createObjectURL = createObjectURL;
  936. /***/ }),
  937. /* 2 */
  938. /***/ (function(module, exports, __w_pdfjs_require__) {
  939. "use strict";
  940. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  941. var globalScope = __w_pdfjs_require__(3);
  942. if (!globalScope._pdfjsCompatibilityChecked) {
  943. globalScope._pdfjsCompatibilityChecked = true;
  944. var isNodeJS = __w_pdfjs_require__(4);
  945. var hasDOM = (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object';
  946. (function checkNodeBtoa() {
  947. if (globalScope.btoa || !isNodeJS()) {
  948. return;
  949. }
  950. globalScope.btoa = function (chars) {
  951. return Buffer.from(chars, 'binary').toString('base64');
  952. };
  953. })();
  954. (function checkNodeAtob() {
  955. if (globalScope.atob || !isNodeJS()) {
  956. return;
  957. }
  958. globalScope.atob = function (input) {
  959. return Buffer.from(input, 'base64').toString('binary');
  960. };
  961. })();
  962. (function checkChildNodeRemove() {
  963. if (!hasDOM) {
  964. return;
  965. }
  966. if (typeof Element.prototype.remove !== 'undefined') {
  967. return;
  968. }
  969. Element.prototype.remove = function () {
  970. if (this.parentNode) {
  971. this.parentNode.removeChild(this);
  972. }
  973. };
  974. })();
  975. (function checkDOMTokenListAddRemove() {
  976. if (!hasDOM || isNodeJS()) {
  977. return;
  978. }
  979. var div = document.createElement('div');
  980. div.classList.add('testOne', 'testTwo');
  981. if (div.classList.contains('testOne') === true && div.classList.contains('testTwo') === true) {
  982. return;
  983. }
  984. var OriginalDOMTokenListAdd = DOMTokenList.prototype.add;
  985. var OriginalDOMTokenListRemove = DOMTokenList.prototype.remove;
  986. DOMTokenList.prototype.add = function () {
  987. for (var _len = arguments.length, tokens = new Array(_len), _key = 0; _key < _len; _key++) {
  988. tokens[_key] = arguments[_key];
  989. }
  990. for (var _i = 0, _tokens = tokens; _i < _tokens.length; _i++) {
  991. var token = _tokens[_i];
  992. OriginalDOMTokenListAdd.call(this, token);
  993. }
  994. };
  995. DOMTokenList.prototype.remove = function () {
  996. for (var _len2 = arguments.length, tokens = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  997. tokens[_key2] = arguments[_key2];
  998. }
  999. for (var _i2 = 0, _tokens2 = tokens; _i2 < _tokens2.length; _i2++) {
  1000. var token = _tokens2[_i2];
  1001. OriginalDOMTokenListRemove.call(this, token);
  1002. }
  1003. };
  1004. })();
  1005. (function checkDOMTokenListToggle() {
  1006. if (!hasDOM || isNodeJS()) {
  1007. return;
  1008. }
  1009. var div = document.createElement('div');
  1010. if (div.classList.toggle('test', 0) === false) {
  1011. return;
  1012. }
  1013. DOMTokenList.prototype.toggle = function (token) {
  1014. var force = arguments.length > 1 ? !!arguments[1] : !this.contains(token);
  1015. return this[force ? 'add' : 'remove'](token), force;
  1016. };
  1017. })();
  1018. (function checkStringStartsWith() {
  1019. if (String.prototype.startsWith) {
  1020. return;
  1021. }
  1022. __w_pdfjs_require__(5);
  1023. })();
  1024. (function checkStringEndsWith() {
  1025. if (String.prototype.endsWith) {
  1026. return;
  1027. }
  1028. __w_pdfjs_require__(36);
  1029. })();
  1030. (function checkStringIncludes() {
  1031. if (String.prototype.includes) {
  1032. return;
  1033. }
  1034. __w_pdfjs_require__(38);
  1035. })();
  1036. (function checkArrayIncludes() {
  1037. if (Array.prototype.includes) {
  1038. return;
  1039. }
  1040. __w_pdfjs_require__(40);
  1041. })();
  1042. (function checkArrayFrom() {
  1043. if (Array.from) {
  1044. return;
  1045. }
  1046. __w_pdfjs_require__(47);
  1047. })();
  1048. (function checkObjectAssign() {
  1049. if (Object.assign) {
  1050. return;
  1051. }
  1052. __w_pdfjs_require__(70);
  1053. })();
  1054. (function checkMathLog2() {
  1055. if (Math.log2) {
  1056. return;
  1057. }
  1058. Math.log2 = __w_pdfjs_require__(75);
  1059. })();
  1060. (function checkNumberIsNaN() {
  1061. if (Number.isNaN) {
  1062. return;
  1063. }
  1064. Number.isNaN = __w_pdfjs_require__(77);
  1065. })();
  1066. (function checkNumberIsInteger() {
  1067. if (Number.isInteger) {
  1068. return;
  1069. }
  1070. Number.isInteger = __w_pdfjs_require__(79);
  1071. })();
  1072. (function checkPromise() {
  1073. if (globalScope.Promise && globalScope.Promise.prototype && globalScope.Promise.prototype["finally"]) {
  1074. return;
  1075. }
  1076. globalScope.Promise = __w_pdfjs_require__(82);
  1077. })();
  1078. (function checkWeakMap() {
  1079. if (globalScope.WeakMap) {
  1080. return;
  1081. }
  1082. globalScope.WeakMap = __w_pdfjs_require__(102);
  1083. })();
  1084. (function checkWeakSet() {
  1085. if (globalScope.WeakSet) {
  1086. return;
  1087. }
  1088. globalScope.WeakSet = __w_pdfjs_require__(119);
  1089. })();
  1090. (function checkStringCodePointAt() {
  1091. if (String.codePointAt) {
  1092. return;
  1093. }
  1094. String.codePointAt = __w_pdfjs_require__(123);
  1095. })();
  1096. (function checkStringFromCodePoint() {
  1097. if (String.fromCodePoint) {
  1098. return;
  1099. }
  1100. String.fromCodePoint = __w_pdfjs_require__(125);
  1101. })();
  1102. (function checkSymbol() {
  1103. if (globalScope.Symbol) {
  1104. return;
  1105. }
  1106. __w_pdfjs_require__(127);
  1107. })();
  1108. (function checkStringPadStart() {
  1109. if (String.prototype.padStart) {
  1110. return;
  1111. }
  1112. __w_pdfjs_require__(134);
  1113. })();
  1114. (function checkStringPadEnd() {
  1115. if (String.prototype.padEnd) {
  1116. return;
  1117. }
  1118. __w_pdfjs_require__(138);
  1119. })();
  1120. (function checkObjectValues() {
  1121. if (Object.values) {
  1122. return;
  1123. }
  1124. Object.values = __w_pdfjs_require__(140);
  1125. })();
  1126. }
  1127. /***/ }),
  1128. /* 3 */
  1129. /***/ (function(module, exports, __w_pdfjs_require__) {
  1130. "use strict";
  1131. module.exports = typeof window !== 'undefined' && window.Math === Math ? window : typeof global !== 'undefined' && global.Math === Math ? global : typeof self !== 'undefined' && self.Math === Math ? self : {};
  1132. /***/ }),
  1133. /* 4 */
  1134. /***/ (function(module, exports, __w_pdfjs_require__) {
  1135. "use strict";
  1136. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1137. module.exports = function isNodeJS() {
  1138. return (typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && process + '' === '[object process]' && !process.versions['nw'] && !process.versions['electron'];
  1139. };
  1140. /***/ }),
  1141. /* 5 */
  1142. /***/ (function(module, exports, __w_pdfjs_require__) {
  1143. "use strict";
  1144. __w_pdfjs_require__(6);
  1145. module.exports = __w_pdfjs_require__(9).String.startsWith;
  1146. /***/ }),
  1147. /* 6 */
  1148. /***/ (function(module, exports, __w_pdfjs_require__) {
  1149. "use strict";
  1150. var $export = __w_pdfjs_require__(7);
  1151. var toLength = __w_pdfjs_require__(28);
  1152. var context = __w_pdfjs_require__(30);
  1153. var STARTS_WITH = 'startsWith';
  1154. var $startsWith = ''[STARTS_WITH];
  1155. $export($export.P + $export.F * __w_pdfjs_require__(35)(STARTS_WITH), 'String', {
  1156. startsWith: function startsWith(searchString) {
  1157. var that = context(this, searchString, STARTS_WITH);
  1158. var index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length));
  1159. var search = String(searchString);
  1160. return $startsWith ? $startsWith.call(that, search, index) : that.slice(index, index + search.length) === search;
  1161. }
  1162. });
  1163. /***/ }),
  1164. /* 7 */
  1165. /***/ (function(module, exports, __w_pdfjs_require__) {
  1166. "use strict";
  1167. var global = __w_pdfjs_require__(8);
  1168. var core = __w_pdfjs_require__(9);
  1169. var hide = __w_pdfjs_require__(10);
  1170. var redefine = __w_pdfjs_require__(20);
  1171. var ctx = __w_pdfjs_require__(26);
  1172. var PROTOTYPE = 'prototype';
  1173. var $export = function $export(type, name, source) {
  1174. var IS_FORCED = type & $export.F;
  1175. var IS_GLOBAL = type & $export.G;
  1176. var IS_STATIC = type & $export.S;
  1177. var IS_PROTO = type & $export.P;
  1178. var IS_BIND = type & $export.B;
  1179. var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE];
  1180. var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
  1181. var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
  1182. var key, own, out, exp;
  1183. if (IS_GLOBAL) source = name;
  1184. for (key in source) {
  1185. own = !IS_FORCED && target && target[key] !== undefined;
  1186. out = (own ? target : source)[key];
  1187. exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  1188. if (target) redefine(target, key, out, type & $export.U);
  1189. if (exports[key] != out) hide(exports, key, exp);
  1190. if (IS_PROTO && expProto[key] != out) expProto[key] = out;
  1191. }
  1192. };
  1193. global.core = core;
  1194. $export.F = 1;
  1195. $export.G = 2;
  1196. $export.S = 4;
  1197. $export.P = 8;
  1198. $export.B = 16;
  1199. $export.W = 32;
  1200. $export.U = 64;
  1201. $export.R = 128;
  1202. module.exports = $export;
  1203. /***/ }),
  1204. /* 8 */
  1205. /***/ (function(module, exports, __w_pdfjs_require__) {
  1206. "use strict";
  1207. var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
  1208. if (typeof __g == 'number') __g = global;
  1209. /***/ }),
  1210. /* 9 */
  1211. /***/ (function(module, exports, __w_pdfjs_require__) {
  1212. "use strict";
  1213. var core = module.exports = {
  1214. version: '2.6.9'
  1215. };
  1216. if (typeof __e == 'number') __e = core;
  1217. /***/ }),
  1218. /* 10 */
  1219. /***/ (function(module, exports, __w_pdfjs_require__) {
  1220. "use strict";
  1221. var dP = __w_pdfjs_require__(11);
  1222. var createDesc = __w_pdfjs_require__(19);
  1223. module.exports = __w_pdfjs_require__(15) ? function (object, key, value) {
  1224. return dP.f(object, key, createDesc(1, value));
  1225. } : function (object, key, value) {
  1226. object[key] = value;
  1227. return object;
  1228. };
  1229. /***/ }),
  1230. /* 11 */
  1231. /***/ (function(module, exports, __w_pdfjs_require__) {
  1232. "use strict";
  1233. var anObject = __w_pdfjs_require__(12);
  1234. var IE8_DOM_DEFINE = __w_pdfjs_require__(14);
  1235. var toPrimitive = __w_pdfjs_require__(18);
  1236. var dP = Object.defineProperty;
  1237. exports.f = __w_pdfjs_require__(15) ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  1238. anObject(O);
  1239. P = toPrimitive(P, true);
  1240. anObject(Attributes);
  1241. if (IE8_DOM_DEFINE) try {
  1242. return dP(O, P, Attributes);
  1243. } catch (e) {}
  1244. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  1245. if ('value' in Attributes) O[P] = Attributes.value;
  1246. return O;
  1247. };
  1248. /***/ }),
  1249. /* 12 */
  1250. /***/ (function(module, exports, __w_pdfjs_require__) {
  1251. "use strict";
  1252. var isObject = __w_pdfjs_require__(13);
  1253. module.exports = function (it) {
  1254. if (!isObject(it)) throw TypeError(it + ' is not an object!');
  1255. return it;
  1256. };
  1257. /***/ }),
  1258. /* 13 */
  1259. /***/ (function(module, exports, __w_pdfjs_require__) {
  1260. "use strict";
  1261. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1262. module.exports = function (it) {
  1263. return _typeof(it) === 'object' ? it !== null : typeof it === 'function';
  1264. };
  1265. /***/ }),
  1266. /* 14 */
  1267. /***/ (function(module, exports, __w_pdfjs_require__) {
  1268. "use strict";
  1269. module.exports = !__w_pdfjs_require__(15) && !__w_pdfjs_require__(16)(function () {
  1270. return Object.defineProperty(__w_pdfjs_require__(17)('div'), 'a', {
  1271. get: function get() {
  1272. return 7;
  1273. }
  1274. }).a != 7;
  1275. });
  1276. /***/ }),
  1277. /* 15 */
  1278. /***/ (function(module, exports, __w_pdfjs_require__) {
  1279. "use strict";
  1280. module.exports = !__w_pdfjs_require__(16)(function () {
  1281. return Object.defineProperty({}, 'a', {
  1282. get: function get() {
  1283. return 7;
  1284. }
  1285. }).a != 7;
  1286. });
  1287. /***/ }),
  1288. /* 16 */
  1289. /***/ (function(module, exports, __w_pdfjs_require__) {
  1290. "use strict";
  1291. module.exports = function (exec) {
  1292. try {
  1293. return !!exec();
  1294. } catch (e) {
  1295. return true;
  1296. }
  1297. };
  1298. /***/ }),
  1299. /* 17 */
  1300. /***/ (function(module, exports, __w_pdfjs_require__) {
  1301. "use strict";
  1302. var isObject = __w_pdfjs_require__(13);
  1303. var document = __w_pdfjs_require__(8).document;
  1304. var is = isObject(document) && isObject(document.createElement);
  1305. module.exports = function (it) {
  1306. return is ? document.createElement(it) : {};
  1307. };
  1308. /***/ }),
  1309. /* 18 */
  1310. /***/ (function(module, exports, __w_pdfjs_require__) {
  1311. "use strict";
  1312. var isObject = __w_pdfjs_require__(13);
  1313. module.exports = function (it, S) {
  1314. if (!isObject(it)) return it;
  1315. var fn, val;
  1316. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  1317. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  1318. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  1319. throw TypeError("Can't convert object to primitive value");
  1320. };
  1321. /***/ }),
  1322. /* 19 */
  1323. /***/ (function(module, exports, __w_pdfjs_require__) {
  1324. "use strict";
  1325. module.exports = function (bitmap, value) {
  1326. return {
  1327. enumerable: !(bitmap & 1),
  1328. configurable: !(bitmap & 2),
  1329. writable: !(bitmap & 4),
  1330. value: value
  1331. };
  1332. };
  1333. /***/ }),
  1334. /* 20 */
  1335. /***/ (function(module, exports, __w_pdfjs_require__) {
  1336. "use strict";
  1337. var global = __w_pdfjs_require__(8);
  1338. var hide = __w_pdfjs_require__(10);
  1339. var has = __w_pdfjs_require__(21);
  1340. var SRC = __w_pdfjs_require__(22)('src');
  1341. var $toString = __w_pdfjs_require__(23);
  1342. var TO_STRING = 'toString';
  1343. var TPL = ('' + $toString).split(TO_STRING);
  1344. __w_pdfjs_require__(9).inspectSource = function (it) {
  1345. return $toString.call(it);
  1346. };
  1347. (module.exports = function (O, key, val, safe) {
  1348. var isFunction = typeof val == 'function';
  1349. if (isFunction) has(val, 'name') || hide(val, 'name', key);
  1350. if (O[key] === val) return;
  1351. if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
  1352. if (O === global) {
  1353. O[key] = val;
  1354. } else if (!safe) {
  1355. delete O[key];
  1356. hide(O, key, val);
  1357. } else if (O[key]) {
  1358. O[key] = val;
  1359. } else {
  1360. hide(O, key, val);
  1361. }
  1362. })(Function.prototype, TO_STRING, function toString() {
  1363. return typeof this == 'function' && this[SRC] || $toString.call(this);
  1364. });
  1365. /***/ }),
  1366. /* 21 */
  1367. /***/ (function(module, exports, __w_pdfjs_require__) {
  1368. "use strict";
  1369. var hasOwnProperty = {}.hasOwnProperty;
  1370. module.exports = function (it, key) {
  1371. return hasOwnProperty.call(it, key);
  1372. };
  1373. /***/ }),
  1374. /* 22 */
  1375. /***/ (function(module, exports, __w_pdfjs_require__) {
  1376. "use strict";
  1377. var id = 0;
  1378. var px = Math.random();
  1379. module.exports = function (key) {
  1380. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  1381. };
  1382. /***/ }),
  1383. /* 23 */
  1384. /***/ (function(module, exports, __w_pdfjs_require__) {
  1385. "use strict";
  1386. module.exports = __w_pdfjs_require__(24)('native-function-to-string', Function.toString);
  1387. /***/ }),
  1388. /* 24 */
  1389. /***/ (function(module, exports, __w_pdfjs_require__) {
  1390. "use strict";
  1391. var core = __w_pdfjs_require__(9);
  1392. var global = __w_pdfjs_require__(8);
  1393. var SHARED = '__core-js_shared__';
  1394. var store = global[SHARED] || (global[SHARED] = {});
  1395. (module.exports = function (key, value) {
  1396. return store[key] || (store[key] = value !== undefined ? value : {});
  1397. })('versions', []).push({
  1398. version: core.version,
  1399. mode: __w_pdfjs_require__(25) ? 'pure' : 'global',
  1400. copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
  1401. });
  1402. /***/ }),
  1403. /* 25 */
  1404. /***/ (function(module, exports, __w_pdfjs_require__) {
  1405. "use strict";
  1406. module.exports = false;
  1407. /***/ }),
  1408. /* 26 */
  1409. /***/ (function(module, exports, __w_pdfjs_require__) {
  1410. "use strict";
  1411. var aFunction = __w_pdfjs_require__(27);
  1412. module.exports = function (fn, that, length) {
  1413. aFunction(fn);
  1414. if (that === undefined) return fn;
  1415. switch (length) {
  1416. case 1:
  1417. return function (a) {
  1418. return fn.call(that, a);
  1419. };
  1420. case 2:
  1421. return function (a, b) {
  1422. return fn.call(that, a, b);
  1423. };
  1424. case 3:
  1425. return function (a, b, c) {
  1426. return fn.call(that, a, b, c);
  1427. };
  1428. }
  1429. return function () {
  1430. return fn.apply(that, arguments);
  1431. };
  1432. };
  1433. /***/ }),
  1434. /* 27 */
  1435. /***/ (function(module, exports, __w_pdfjs_require__) {
  1436. "use strict";
  1437. module.exports = function (it) {
  1438. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  1439. return it;
  1440. };
  1441. /***/ }),
  1442. /* 28 */
  1443. /***/ (function(module, exports, __w_pdfjs_require__) {
  1444. "use strict";
  1445. var toInteger = __w_pdfjs_require__(29);
  1446. var min = Math.min;
  1447. module.exports = function (it) {
  1448. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0;
  1449. };
  1450. /***/ }),
  1451. /* 29 */
  1452. /***/ (function(module, exports, __w_pdfjs_require__) {
  1453. "use strict";
  1454. var ceil = Math.ceil;
  1455. var floor = Math.floor;
  1456. module.exports = function (it) {
  1457. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  1458. };
  1459. /***/ }),
  1460. /* 30 */
  1461. /***/ (function(module, exports, __w_pdfjs_require__) {
  1462. "use strict";
  1463. var isRegExp = __w_pdfjs_require__(31);
  1464. var defined = __w_pdfjs_require__(34);
  1465. module.exports = function (that, searchString, NAME) {
  1466. if (isRegExp(searchString)) throw TypeError('String#' + NAME + " doesn't accept regex!");
  1467. return String(defined(that));
  1468. };
  1469. /***/ }),
  1470. /* 31 */
  1471. /***/ (function(module, exports, __w_pdfjs_require__) {
  1472. "use strict";
  1473. var isObject = __w_pdfjs_require__(13);
  1474. var cof = __w_pdfjs_require__(32);
  1475. var MATCH = __w_pdfjs_require__(33)('match');
  1476. module.exports = function (it) {
  1477. var isRegExp;
  1478. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');
  1479. };
  1480. /***/ }),
  1481. /* 32 */
  1482. /***/ (function(module, exports, __w_pdfjs_require__) {
  1483. "use strict";
  1484. var toString = {}.toString;
  1485. module.exports = function (it) {
  1486. return toString.call(it).slice(8, -1);
  1487. };
  1488. /***/ }),
  1489. /* 33 */
  1490. /***/ (function(module, exports, __w_pdfjs_require__) {
  1491. "use strict";
  1492. var store = __w_pdfjs_require__(24)('wks');
  1493. var uid = __w_pdfjs_require__(22);
  1494. var _Symbol = __w_pdfjs_require__(8).Symbol;
  1495. var USE_SYMBOL = typeof _Symbol == 'function';
  1496. var $exports = module.exports = function (name) {
  1497. return store[name] || (store[name] = USE_SYMBOL && _Symbol[name] || (USE_SYMBOL ? _Symbol : uid)('Symbol.' + name));
  1498. };
  1499. $exports.store = store;
  1500. /***/ }),
  1501. /* 34 */
  1502. /***/ (function(module, exports, __w_pdfjs_require__) {
  1503. "use strict";
  1504. module.exports = function (it) {
  1505. if (it == undefined) throw TypeError("Can't call method on " + it);
  1506. return it;
  1507. };
  1508. /***/ }),
  1509. /* 35 */
  1510. /***/ (function(module, exports, __w_pdfjs_require__) {
  1511. "use strict";
  1512. var MATCH = __w_pdfjs_require__(33)('match');
  1513. module.exports = function (KEY) {
  1514. var re = /./;
  1515. try {
  1516. '/./'[KEY](re);
  1517. } catch (e) {
  1518. try {
  1519. re[MATCH] = false;
  1520. return !'/./'[KEY](re);
  1521. } catch (f) {}
  1522. }
  1523. return true;
  1524. };
  1525. /***/ }),
  1526. /* 36 */
  1527. /***/ (function(module, exports, __w_pdfjs_require__) {
  1528. "use strict";
  1529. __w_pdfjs_require__(37);
  1530. module.exports = __w_pdfjs_require__(9).String.endsWith;
  1531. /***/ }),
  1532. /* 37 */
  1533. /***/ (function(module, exports, __w_pdfjs_require__) {
  1534. "use strict";
  1535. var $export = __w_pdfjs_require__(7);
  1536. var toLength = __w_pdfjs_require__(28);
  1537. var context = __w_pdfjs_require__(30);
  1538. var ENDS_WITH = 'endsWith';
  1539. var $endsWith = ''[ENDS_WITH];
  1540. $export($export.P + $export.F * __w_pdfjs_require__(35)(ENDS_WITH), 'String', {
  1541. endsWith: function endsWith(searchString) {
  1542. var that = context(this, searchString, ENDS_WITH);
  1543. var endPosition = arguments.length > 1 ? arguments[1] : undefined;
  1544. var len = toLength(that.length);
  1545. var end = endPosition === undefined ? len : Math.min(toLength(endPosition), len);
  1546. var search = String(searchString);
  1547. return $endsWith ? $endsWith.call(that, search, end) : that.slice(end - search.length, end) === search;
  1548. }
  1549. });
  1550. /***/ }),
  1551. /* 38 */
  1552. /***/ (function(module, exports, __w_pdfjs_require__) {
  1553. "use strict";
  1554. __w_pdfjs_require__(39);
  1555. module.exports = __w_pdfjs_require__(9).String.includes;
  1556. /***/ }),
  1557. /* 39 */
  1558. /***/ (function(module, exports, __w_pdfjs_require__) {
  1559. "use strict";
  1560. var $export = __w_pdfjs_require__(7);
  1561. var context = __w_pdfjs_require__(30);
  1562. var INCLUDES = 'includes';
  1563. $export($export.P + $export.F * __w_pdfjs_require__(35)(INCLUDES), 'String', {
  1564. includes: function includes(searchString) {
  1565. return !!~context(this, searchString, INCLUDES).indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
  1566. }
  1567. });
  1568. /***/ }),
  1569. /* 40 */
  1570. /***/ (function(module, exports, __w_pdfjs_require__) {
  1571. "use strict";
  1572. __w_pdfjs_require__(41);
  1573. module.exports = __w_pdfjs_require__(9).Array.includes;
  1574. /***/ }),
  1575. /* 41 */
  1576. /***/ (function(module, exports, __w_pdfjs_require__) {
  1577. "use strict";
  1578. var $export = __w_pdfjs_require__(7);
  1579. var $includes = __w_pdfjs_require__(42)(true);
  1580. $export($export.P, 'Array', {
  1581. includes: function includes(el) {
  1582. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  1583. }
  1584. });
  1585. __w_pdfjs_require__(46)('includes');
  1586. /***/ }),
  1587. /* 42 */
  1588. /***/ (function(module, exports, __w_pdfjs_require__) {
  1589. "use strict";
  1590. var toIObject = __w_pdfjs_require__(43);
  1591. var toLength = __w_pdfjs_require__(28);
  1592. var toAbsoluteIndex = __w_pdfjs_require__(45);
  1593. module.exports = function (IS_INCLUDES) {
  1594. return function ($this, el, fromIndex) {
  1595. var O = toIObject($this);
  1596. var length = toLength(O.length);
  1597. var index = toAbsoluteIndex(fromIndex, length);
  1598. var value;
  1599. if (IS_INCLUDES && el != el) while (length > index) {
  1600. value = O[index++];
  1601. if (value != value) return true;
  1602. } else for (; length > index; index++) {
  1603. if (IS_INCLUDES || index in O) {
  1604. if (O[index] === el) return IS_INCLUDES || index || 0;
  1605. }
  1606. }
  1607. return !IS_INCLUDES && -1;
  1608. };
  1609. };
  1610. /***/ }),
  1611. /* 43 */
  1612. /***/ (function(module, exports, __w_pdfjs_require__) {
  1613. "use strict";
  1614. var IObject = __w_pdfjs_require__(44);
  1615. var defined = __w_pdfjs_require__(34);
  1616. module.exports = function (it) {
  1617. return IObject(defined(it));
  1618. };
  1619. /***/ }),
  1620. /* 44 */
  1621. /***/ (function(module, exports, __w_pdfjs_require__) {
  1622. "use strict";
  1623. var cof = __w_pdfjs_require__(32);
  1624. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  1625. return cof(it) == 'String' ? it.split('') : Object(it);
  1626. };
  1627. /***/ }),
  1628. /* 45 */
  1629. /***/ (function(module, exports, __w_pdfjs_require__) {
  1630. "use strict";
  1631. var toInteger = __w_pdfjs_require__(29);
  1632. var max = Math.max;
  1633. var min = Math.min;
  1634. module.exports = function (index, length) {
  1635. index = toInteger(index);
  1636. return index < 0 ? max(index + length, 0) : min(index, length);
  1637. };
  1638. /***/ }),
  1639. /* 46 */
  1640. /***/ (function(module, exports, __w_pdfjs_require__) {
  1641. "use strict";
  1642. var UNSCOPABLES = __w_pdfjs_require__(33)('unscopables');
  1643. var ArrayProto = Array.prototype;
  1644. if (ArrayProto[UNSCOPABLES] == undefined) __w_pdfjs_require__(10)(ArrayProto, UNSCOPABLES, {});
  1645. module.exports = function (key) {
  1646. ArrayProto[UNSCOPABLES][key] = true;
  1647. };
  1648. /***/ }),
  1649. /* 47 */
  1650. /***/ (function(module, exports, __w_pdfjs_require__) {
  1651. "use strict";
  1652. __w_pdfjs_require__(48);
  1653. __w_pdfjs_require__(63);
  1654. module.exports = __w_pdfjs_require__(9).Array.from;
  1655. /***/ }),
  1656. /* 48 */
  1657. /***/ (function(module, exports, __w_pdfjs_require__) {
  1658. "use strict";
  1659. var $at = __w_pdfjs_require__(49)(true);
  1660. __w_pdfjs_require__(50)(String, 'String', function (iterated) {
  1661. this._t = String(iterated);
  1662. this._i = 0;
  1663. }, function () {
  1664. var O = this._t;
  1665. var index = this._i;
  1666. var point;
  1667. if (index >= O.length) return {
  1668. value: undefined,
  1669. done: true
  1670. };
  1671. point = $at(O, index);
  1672. this._i += point.length;
  1673. return {
  1674. value: point,
  1675. done: false
  1676. };
  1677. });
  1678. /***/ }),
  1679. /* 49 */
  1680. /***/ (function(module, exports, __w_pdfjs_require__) {
  1681. "use strict";
  1682. var toInteger = __w_pdfjs_require__(29);
  1683. var defined = __w_pdfjs_require__(34);
  1684. module.exports = function (TO_STRING) {
  1685. return function (that, pos) {
  1686. var s = String(defined(that));
  1687. var i = toInteger(pos);
  1688. var l = s.length;
  1689. var a, b;
  1690. if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
  1691. a = s.charCodeAt(i);
  1692. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  1693. };
  1694. };
  1695. /***/ }),
  1696. /* 50 */
  1697. /***/ (function(module, exports, __w_pdfjs_require__) {
  1698. "use strict";
  1699. var LIBRARY = __w_pdfjs_require__(25);
  1700. var $export = __w_pdfjs_require__(7);
  1701. var redefine = __w_pdfjs_require__(20);
  1702. var hide = __w_pdfjs_require__(10);
  1703. var Iterators = __w_pdfjs_require__(51);
  1704. var $iterCreate = __w_pdfjs_require__(52);
  1705. var setToStringTag = __w_pdfjs_require__(60);
  1706. var getPrototypeOf = __w_pdfjs_require__(61);
  1707. var ITERATOR = __w_pdfjs_require__(33)('iterator');
  1708. var BUGGY = !([].keys && 'next' in [].keys());
  1709. var FF_ITERATOR = '@@iterator';
  1710. var KEYS = 'keys';
  1711. var VALUES = 'values';
  1712. var returnThis = function returnThis() {
  1713. return this;
  1714. };
  1715. module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
  1716. $iterCreate(Constructor, NAME, next);
  1717. var getMethod = function getMethod(kind) {
  1718. if (!BUGGY && kind in proto) return proto[kind];
  1719. switch (kind) {
  1720. case KEYS:
  1721. return function keys() {
  1722. return new Constructor(this, kind);
  1723. };
  1724. case VALUES:
  1725. return function values() {
  1726. return new Constructor(this, kind);
  1727. };
  1728. }
  1729. return function entries() {
  1730. return new Constructor(this, kind);
  1731. };
  1732. };
  1733. var TAG = NAME + ' Iterator';
  1734. var DEF_VALUES = DEFAULT == VALUES;
  1735. var VALUES_BUG = false;
  1736. var proto = Base.prototype;
  1737. var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
  1738. var $default = $native || getMethod(DEFAULT);
  1739. var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
  1740. var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
  1741. var methods, key, IteratorPrototype;
  1742. if ($anyNative) {
  1743. IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
  1744. if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
  1745. setToStringTag(IteratorPrototype, TAG, true);
  1746. if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
  1747. }
  1748. }
  1749. if (DEF_VALUES && $native && $native.name !== VALUES) {
  1750. VALUES_BUG = true;
  1751. $default = function values() {
  1752. return $native.call(this);
  1753. };
  1754. }
  1755. if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
  1756. hide(proto, ITERATOR, $default);
  1757. }
  1758. Iterators[NAME] = $default;
  1759. Iterators[TAG] = returnThis;
  1760. if (DEFAULT) {
  1761. methods = {
  1762. values: DEF_VALUES ? $default : getMethod(VALUES),
  1763. keys: IS_SET ? $default : getMethod(KEYS),
  1764. entries: $entries
  1765. };
  1766. if (FORCED) for (key in methods) {
  1767. if (!(key in proto)) redefine(proto, key, methods[key]);
  1768. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  1769. }
  1770. return methods;
  1771. };
  1772. /***/ }),
  1773. /* 51 */
  1774. /***/ (function(module, exports, __w_pdfjs_require__) {
  1775. "use strict";
  1776. module.exports = {};
  1777. /***/ }),
  1778. /* 52 */
  1779. /***/ (function(module, exports, __w_pdfjs_require__) {
  1780. "use strict";
  1781. var create = __w_pdfjs_require__(53);
  1782. var descriptor = __w_pdfjs_require__(19);
  1783. var setToStringTag = __w_pdfjs_require__(60);
  1784. var IteratorPrototype = {};
  1785. __w_pdfjs_require__(10)(IteratorPrototype, __w_pdfjs_require__(33)('iterator'), function () {
  1786. return this;
  1787. });
  1788. module.exports = function (Constructor, NAME, next) {
  1789. Constructor.prototype = create(IteratorPrototype, {
  1790. next: descriptor(1, next)
  1791. });
  1792. setToStringTag(Constructor, NAME + ' Iterator');
  1793. };
  1794. /***/ }),
  1795. /* 53 */
  1796. /***/ (function(module, exports, __w_pdfjs_require__) {
  1797. "use strict";
  1798. var anObject = __w_pdfjs_require__(12);
  1799. var dPs = __w_pdfjs_require__(54);
  1800. var enumBugKeys = __w_pdfjs_require__(58);
  1801. var IE_PROTO = __w_pdfjs_require__(57)('IE_PROTO');
  1802. var Empty = function Empty() {};
  1803. var PROTOTYPE = 'prototype';
  1804. var _createDict = function createDict() {
  1805. var iframe = __w_pdfjs_require__(17)('iframe');
  1806. var i = enumBugKeys.length;
  1807. var lt = '<';
  1808. var gt = '>';
  1809. var iframeDocument;
  1810. iframe.style.display = 'none';
  1811. __w_pdfjs_require__(59).appendChild(iframe);
  1812. iframe.src = 'javascript:';
  1813. iframeDocument = iframe.contentWindow.document;
  1814. iframeDocument.open();
  1815. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  1816. iframeDocument.close();
  1817. _createDict = iframeDocument.F;
  1818. while (i--) {
  1819. delete _createDict[PROTOTYPE][enumBugKeys[i]];
  1820. }
  1821. return _createDict();
  1822. };
  1823. module.exports = Object.create || function create(O, Properties) {
  1824. var result;
  1825. if (O !== null) {
  1826. Empty[PROTOTYPE] = anObject(O);
  1827. result = new Empty();
  1828. Empty[PROTOTYPE] = null;
  1829. result[IE_PROTO] = O;
  1830. } else result = _createDict();
  1831. return Properties === undefined ? result : dPs(result, Properties);
  1832. };
  1833. /***/ }),
  1834. /* 54 */
  1835. /***/ (function(module, exports, __w_pdfjs_require__) {
  1836. "use strict";
  1837. var dP = __w_pdfjs_require__(11);
  1838. var anObject = __w_pdfjs_require__(12);
  1839. var getKeys = __w_pdfjs_require__(55);
  1840. module.exports = __w_pdfjs_require__(15) ? Object.defineProperties : function defineProperties(O, Properties) {
  1841. anObject(O);
  1842. var keys = getKeys(Properties);
  1843. var length = keys.length;
  1844. var i = 0;
  1845. var P;
  1846. while (length > i) {
  1847. dP.f(O, P = keys[i++], Properties[P]);
  1848. }
  1849. return O;
  1850. };
  1851. /***/ }),
  1852. /* 55 */
  1853. /***/ (function(module, exports, __w_pdfjs_require__) {
  1854. "use strict";
  1855. var $keys = __w_pdfjs_require__(56);
  1856. var enumBugKeys = __w_pdfjs_require__(58);
  1857. module.exports = Object.keys || function keys(O) {
  1858. return $keys(O, enumBugKeys);
  1859. };
  1860. /***/ }),
  1861. /* 56 */
  1862. /***/ (function(module, exports, __w_pdfjs_require__) {
  1863. "use strict";
  1864. var has = __w_pdfjs_require__(21);
  1865. var toIObject = __w_pdfjs_require__(43);
  1866. var arrayIndexOf = __w_pdfjs_require__(42)(false);
  1867. var IE_PROTO = __w_pdfjs_require__(57)('IE_PROTO');
  1868. module.exports = function (object, names) {
  1869. var O = toIObject(object);
  1870. var i = 0;
  1871. var result = [];
  1872. var key;
  1873. for (key in O) {
  1874. if (key != IE_PROTO) has(O, key) && result.push(key);
  1875. }
  1876. while (names.length > i) {
  1877. if (has(O, key = names[i++])) {
  1878. ~arrayIndexOf(result, key) || result.push(key);
  1879. }
  1880. }
  1881. return result;
  1882. };
  1883. /***/ }),
  1884. /* 57 */
  1885. /***/ (function(module, exports, __w_pdfjs_require__) {
  1886. "use strict";
  1887. var shared = __w_pdfjs_require__(24)('keys');
  1888. var uid = __w_pdfjs_require__(22);
  1889. module.exports = function (key) {
  1890. return shared[key] || (shared[key] = uid(key));
  1891. };
  1892. /***/ }),
  1893. /* 58 */
  1894. /***/ (function(module, exports, __w_pdfjs_require__) {
  1895. "use strict";
  1896. module.exports = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(',');
  1897. /***/ }),
  1898. /* 59 */
  1899. /***/ (function(module, exports, __w_pdfjs_require__) {
  1900. "use strict";
  1901. var document = __w_pdfjs_require__(8).document;
  1902. module.exports = document && document.documentElement;
  1903. /***/ }),
  1904. /* 60 */
  1905. /***/ (function(module, exports, __w_pdfjs_require__) {
  1906. "use strict";
  1907. var def = __w_pdfjs_require__(11).f;
  1908. var has = __w_pdfjs_require__(21);
  1909. var TAG = __w_pdfjs_require__(33)('toStringTag');
  1910. module.exports = function (it, tag, stat) {
  1911. if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, {
  1912. configurable: true,
  1913. value: tag
  1914. });
  1915. };
  1916. /***/ }),
  1917. /* 61 */
  1918. /***/ (function(module, exports, __w_pdfjs_require__) {
  1919. "use strict";
  1920. var has = __w_pdfjs_require__(21);
  1921. var toObject = __w_pdfjs_require__(62);
  1922. var IE_PROTO = __w_pdfjs_require__(57)('IE_PROTO');
  1923. var ObjectProto = Object.prototype;
  1924. module.exports = Object.getPrototypeOf || function (O) {
  1925. O = toObject(O);
  1926. if (has(O, IE_PROTO)) return O[IE_PROTO];
  1927. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  1928. return O.constructor.prototype;
  1929. }
  1930. return O instanceof Object ? ObjectProto : null;
  1931. };
  1932. /***/ }),
  1933. /* 62 */
  1934. /***/ (function(module, exports, __w_pdfjs_require__) {
  1935. "use strict";
  1936. var defined = __w_pdfjs_require__(34);
  1937. module.exports = function (it) {
  1938. return Object(defined(it));
  1939. };
  1940. /***/ }),
  1941. /* 63 */
  1942. /***/ (function(module, exports, __w_pdfjs_require__) {
  1943. "use strict";
  1944. var ctx = __w_pdfjs_require__(26);
  1945. var $export = __w_pdfjs_require__(7);
  1946. var toObject = __w_pdfjs_require__(62);
  1947. var call = __w_pdfjs_require__(64);
  1948. var isArrayIter = __w_pdfjs_require__(65);
  1949. var toLength = __w_pdfjs_require__(28);
  1950. var createProperty = __w_pdfjs_require__(66);
  1951. var getIterFn = __w_pdfjs_require__(67);
  1952. $export($export.S + $export.F * !__w_pdfjs_require__(69)(function (iter) {
  1953. Array.from(iter);
  1954. }), 'Array', {
  1955. from: function from(arrayLike) {
  1956. var O = toObject(arrayLike);
  1957. var C = typeof this == 'function' ? this : Array;
  1958. var aLen = arguments.length;
  1959. var mapfn = aLen > 1 ? arguments[1] : undefined;
  1960. var mapping = mapfn !== undefined;
  1961. var index = 0;
  1962. var iterFn = getIterFn(O);
  1963. var length, result, step, iterator;
  1964. if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
  1965. if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {
  1966. for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
  1967. createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
  1968. }
  1969. } else {
  1970. length = toLength(O.length);
  1971. for (result = new C(length); length > index; index++) {
  1972. createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
  1973. }
  1974. }
  1975. result.length = index;
  1976. return result;
  1977. }
  1978. });
  1979. /***/ }),
  1980. /* 64 */
  1981. /***/ (function(module, exports, __w_pdfjs_require__) {
  1982. "use strict";
  1983. var anObject = __w_pdfjs_require__(12);
  1984. module.exports = function (iterator, fn, value, entries) {
  1985. try {
  1986. return entries ? fn(anObject(value)[0], value[1]) : fn(value);
  1987. } catch (e) {
  1988. var ret = iterator['return'];
  1989. if (ret !== undefined) anObject(ret.call(iterator));
  1990. throw e;
  1991. }
  1992. };
  1993. /***/ }),
  1994. /* 65 */
  1995. /***/ (function(module, exports, __w_pdfjs_require__) {
  1996. "use strict";
  1997. var Iterators = __w_pdfjs_require__(51);
  1998. var ITERATOR = __w_pdfjs_require__(33)('iterator');
  1999. var ArrayProto = Array.prototype;
  2000. module.exports = function (it) {
  2001. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  2002. };
  2003. /***/ }),
  2004. /* 66 */
  2005. /***/ (function(module, exports, __w_pdfjs_require__) {
  2006. "use strict";
  2007. var $defineProperty = __w_pdfjs_require__(11);
  2008. var createDesc = __w_pdfjs_require__(19);
  2009. module.exports = function (object, index, value) {
  2010. if (index in object) $defineProperty.f(object, index, createDesc(0, value));else object[index] = value;
  2011. };
  2012. /***/ }),
  2013. /* 67 */
  2014. /***/ (function(module, exports, __w_pdfjs_require__) {
  2015. "use strict";
  2016. var classof = __w_pdfjs_require__(68);
  2017. var ITERATOR = __w_pdfjs_require__(33)('iterator');
  2018. var Iterators = __w_pdfjs_require__(51);
  2019. module.exports = __w_pdfjs_require__(9).getIteratorMethod = function (it) {
  2020. if (it != undefined) return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)];
  2021. };
  2022. /***/ }),
  2023. /* 68 */
  2024. /***/ (function(module, exports, __w_pdfjs_require__) {
  2025. "use strict";
  2026. var cof = __w_pdfjs_require__(32);
  2027. var TAG = __w_pdfjs_require__(33)('toStringTag');
  2028. var ARG = cof(function () {
  2029. return arguments;
  2030. }()) == 'Arguments';
  2031. var tryGet = function tryGet(it, key) {
  2032. try {
  2033. return it[key];
  2034. } catch (e) {}
  2035. };
  2036. module.exports = function (it) {
  2037. var O, T, B;
  2038. return it === undefined ? 'Undefined' : it === null ? 'Null' : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T : ARG ? cof(O) : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  2039. };
  2040. /***/ }),
  2041. /* 69 */
  2042. /***/ (function(module, exports, __w_pdfjs_require__) {
  2043. "use strict";
  2044. var ITERATOR = __w_pdfjs_require__(33)('iterator');
  2045. var SAFE_CLOSING = false;
  2046. try {
  2047. var riter = [7][ITERATOR]();
  2048. riter['return'] = function () {
  2049. SAFE_CLOSING = true;
  2050. };
  2051. Array.from(riter, function () {
  2052. throw 2;
  2053. });
  2054. } catch (e) {}
  2055. module.exports = function (exec, skipClosing) {
  2056. if (!skipClosing && !SAFE_CLOSING) return false;
  2057. var safe = false;
  2058. try {
  2059. var arr = [7];
  2060. var iter = arr[ITERATOR]();
  2061. iter.next = function () {
  2062. return {
  2063. done: safe = true
  2064. };
  2065. };
  2066. arr[ITERATOR] = function () {
  2067. return iter;
  2068. };
  2069. exec(arr);
  2070. } catch (e) {}
  2071. return safe;
  2072. };
  2073. /***/ }),
  2074. /* 70 */
  2075. /***/ (function(module, exports, __w_pdfjs_require__) {
  2076. "use strict";
  2077. __w_pdfjs_require__(71);
  2078. module.exports = __w_pdfjs_require__(9).Object.assign;
  2079. /***/ }),
  2080. /* 71 */
  2081. /***/ (function(module, exports, __w_pdfjs_require__) {
  2082. "use strict";
  2083. var $export = __w_pdfjs_require__(7);
  2084. $export($export.S + $export.F, 'Object', {
  2085. assign: __w_pdfjs_require__(72)
  2086. });
  2087. /***/ }),
  2088. /* 72 */
  2089. /***/ (function(module, exports, __w_pdfjs_require__) {
  2090. "use strict";
  2091. var DESCRIPTORS = __w_pdfjs_require__(15);
  2092. var getKeys = __w_pdfjs_require__(55);
  2093. var gOPS = __w_pdfjs_require__(73);
  2094. var pIE = __w_pdfjs_require__(74);
  2095. var toObject = __w_pdfjs_require__(62);
  2096. var IObject = __w_pdfjs_require__(44);
  2097. var $assign = Object.assign;
  2098. module.exports = !$assign || __w_pdfjs_require__(16)(function () {
  2099. var A = {};
  2100. var B = {};
  2101. var S = Symbol();
  2102. var K = 'abcdefghijklmnopqrst';
  2103. A[S] = 7;
  2104. K.split('').forEach(function (k) {
  2105. B[k] = k;
  2106. });
  2107. return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
  2108. }) ? function assign(target, source) {
  2109. var T = toObject(target);
  2110. var aLen = arguments.length;
  2111. var index = 1;
  2112. var getSymbols = gOPS.f;
  2113. var isEnum = pIE.f;
  2114. while (aLen > index) {
  2115. var S = IObject(arguments[index++]);
  2116. var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
  2117. var length = keys.length;
  2118. var j = 0;
  2119. var key;
  2120. while (length > j) {
  2121. key = keys[j++];
  2122. if (!DESCRIPTORS || isEnum.call(S, key)) T[key] = S[key];
  2123. }
  2124. }
  2125. return T;
  2126. } : $assign;
  2127. /***/ }),
  2128. /* 73 */
  2129. /***/ (function(module, exports, __w_pdfjs_require__) {
  2130. "use strict";
  2131. exports.f = Object.getOwnPropertySymbols;
  2132. /***/ }),
  2133. /* 74 */
  2134. /***/ (function(module, exports, __w_pdfjs_require__) {
  2135. "use strict";
  2136. exports.f = {}.propertyIsEnumerable;
  2137. /***/ }),
  2138. /* 75 */
  2139. /***/ (function(module, exports, __w_pdfjs_require__) {
  2140. "use strict";
  2141. __w_pdfjs_require__(76);
  2142. module.exports = __w_pdfjs_require__(9).Math.log2;
  2143. /***/ }),
  2144. /* 76 */
  2145. /***/ (function(module, exports, __w_pdfjs_require__) {
  2146. "use strict";
  2147. var $export = __w_pdfjs_require__(7);
  2148. $export($export.S, 'Math', {
  2149. log2: function log2(x) {
  2150. return Math.log(x) / Math.LN2;
  2151. }
  2152. });
  2153. /***/ }),
  2154. /* 77 */
  2155. /***/ (function(module, exports, __w_pdfjs_require__) {
  2156. "use strict";
  2157. __w_pdfjs_require__(78);
  2158. module.exports = __w_pdfjs_require__(9).Number.isNaN;
  2159. /***/ }),
  2160. /* 78 */
  2161. /***/ (function(module, exports, __w_pdfjs_require__) {
  2162. "use strict";
  2163. var $export = __w_pdfjs_require__(7);
  2164. $export($export.S, 'Number', {
  2165. isNaN: function isNaN(number) {
  2166. return number != number;
  2167. }
  2168. });
  2169. /***/ }),
  2170. /* 79 */
  2171. /***/ (function(module, exports, __w_pdfjs_require__) {
  2172. "use strict";
  2173. __w_pdfjs_require__(80);
  2174. module.exports = __w_pdfjs_require__(9).Number.isInteger;
  2175. /***/ }),
  2176. /* 80 */
  2177. /***/ (function(module, exports, __w_pdfjs_require__) {
  2178. "use strict";
  2179. var $export = __w_pdfjs_require__(7);
  2180. $export($export.S, 'Number', {
  2181. isInteger: __w_pdfjs_require__(81)
  2182. });
  2183. /***/ }),
  2184. /* 81 */
  2185. /***/ (function(module, exports, __w_pdfjs_require__) {
  2186. "use strict";
  2187. var isObject = __w_pdfjs_require__(13);
  2188. var floor = Math.floor;
  2189. module.exports = function isInteger(it) {
  2190. return !isObject(it) && isFinite(it) && floor(it) === it;
  2191. };
  2192. /***/ }),
  2193. /* 82 */
  2194. /***/ (function(module, exports, __w_pdfjs_require__) {
  2195. "use strict";
  2196. __w_pdfjs_require__(83);
  2197. __w_pdfjs_require__(48);
  2198. __w_pdfjs_require__(84);
  2199. __w_pdfjs_require__(87);
  2200. __w_pdfjs_require__(100);
  2201. __w_pdfjs_require__(101);
  2202. module.exports = __w_pdfjs_require__(9).Promise;
  2203. /***/ }),
  2204. /* 83 */
  2205. /***/ (function(module, exports, __w_pdfjs_require__) {
  2206. "use strict";
  2207. var classof = __w_pdfjs_require__(68);
  2208. var test = {};
  2209. test[__w_pdfjs_require__(33)('toStringTag')] = 'z';
  2210. if (test + '' != '[object z]') {
  2211. __w_pdfjs_require__(20)(Object.prototype, 'toString', function toString() {
  2212. return '[object ' + classof(this) + ']';
  2213. }, true);
  2214. }
  2215. /***/ }),
  2216. /* 84 */
  2217. /***/ (function(module, exports, __w_pdfjs_require__) {
  2218. "use strict";
  2219. var $iterators = __w_pdfjs_require__(85);
  2220. var getKeys = __w_pdfjs_require__(55);
  2221. var redefine = __w_pdfjs_require__(20);
  2222. var global = __w_pdfjs_require__(8);
  2223. var hide = __w_pdfjs_require__(10);
  2224. var Iterators = __w_pdfjs_require__(51);
  2225. var wks = __w_pdfjs_require__(33);
  2226. var ITERATOR = wks('iterator');
  2227. var TO_STRING_TAG = wks('toStringTag');
  2228. var ArrayValues = Iterators.Array;
  2229. var DOMIterables = {
  2230. CSSRuleList: true,
  2231. CSSStyleDeclaration: false,
  2232. CSSValueList: false,
  2233. ClientRectList: false,
  2234. DOMRectList: false,
  2235. DOMStringList: false,
  2236. DOMTokenList: true,
  2237. DataTransferItemList: false,
  2238. FileList: false,
  2239. HTMLAllCollection: false,
  2240. HTMLCollection: false,
  2241. HTMLFormElement: false,
  2242. HTMLSelectElement: false,
  2243. MediaList: true,
  2244. MimeTypeArray: false,
  2245. NamedNodeMap: false,
  2246. NodeList: true,
  2247. PaintRequestList: false,
  2248. Plugin: false,
  2249. PluginArray: false,
  2250. SVGLengthList: false,
  2251. SVGNumberList: false,
  2252. SVGPathSegList: false,
  2253. SVGPointList: false,
  2254. SVGStringList: false,
  2255. SVGTransformList: false,
  2256. SourceBufferList: false,
  2257. StyleSheetList: true,
  2258. TextTrackCueList: false,
  2259. TextTrackList: false,
  2260. TouchList: false
  2261. };
  2262. for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) {
  2263. var NAME = collections[i];
  2264. var explicit = DOMIterables[NAME];
  2265. var Collection = global[NAME];
  2266. var proto = Collection && Collection.prototype;
  2267. var key;
  2268. if (proto) {
  2269. if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues);
  2270. if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
  2271. Iterators[NAME] = ArrayValues;
  2272. if (explicit) for (key in $iterators) {
  2273. if (!proto[key]) redefine(proto, key, $iterators[key], true);
  2274. }
  2275. }
  2276. }
  2277. /***/ }),
  2278. /* 85 */
  2279. /***/ (function(module, exports, __w_pdfjs_require__) {
  2280. "use strict";
  2281. var addToUnscopables = __w_pdfjs_require__(46);
  2282. var step = __w_pdfjs_require__(86);
  2283. var Iterators = __w_pdfjs_require__(51);
  2284. var toIObject = __w_pdfjs_require__(43);
  2285. module.exports = __w_pdfjs_require__(50)(Array, 'Array', function (iterated, kind) {
  2286. this._t = toIObject(iterated);
  2287. this._i = 0;
  2288. this._k = kind;
  2289. }, function () {
  2290. var O = this._t;
  2291. var kind = this._k;
  2292. var index = this._i++;
  2293. if (!O || index >= O.length) {
  2294. this._t = undefined;
  2295. return step(1);
  2296. }
  2297. if (kind == 'keys') return step(0, index);
  2298. if (kind == 'values') return step(0, O[index]);
  2299. return step(0, [index, O[index]]);
  2300. }, 'values');
  2301. Iterators.Arguments = Iterators.Array;
  2302. addToUnscopables('keys');
  2303. addToUnscopables('values');
  2304. addToUnscopables('entries');
  2305. /***/ }),
  2306. /* 86 */
  2307. /***/ (function(module, exports, __w_pdfjs_require__) {
  2308. "use strict";
  2309. module.exports = function (done, value) {
  2310. return {
  2311. value: value,
  2312. done: !!done
  2313. };
  2314. };
  2315. /***/ }),
  2316. /* 87 */
  2317. /***/ (function(module, exports, __w_pdfjs_require__) {
  2318. "use strict";
  2319. var LIBRARY = __w_pdfjs_require__(25);
  2320. var global = __w_pdfjs_require__(8);
  2321. var ctx = __w_pdfjs_require__(26);
  2322. var classof = __w_pdfjs_require__(68);
  2323. var $export = __w_pdfjs_require__(7);
  2324. var isObject = __w_pdfjs_require__(13);
  2325. var aFunction = __w_pdfjs_require__(27);
  2326. var anInstance = __w_pdfjs_require__(88);
  2327. var forOf = __w_pdfjs_require__(89);
  2328. var speciesConstructor = __w_pdfjs_require__(90);
  2329. var task = __w_pdfjs_require__(91).set;
  2330. var microtask = __w_pdfjs_require__(93)();
  2331. var newPromiseCapabilityModule = __w_pdfjs_require__(94);
  2332. var perform = __w_pdfjs_require__(95);
  2333. var userAgent = __w_pdfjs_require__(96);
  2334. var promiseResolve = __w_pdfjs_require__(97);
  2335. var PROMISE = 'Promise';
  2336. var TypeError = global.TypeError;
  2337. var process = global.process;
  2338. var versions = process && process.versions;
  2339. var v8 = versions && versions.v8 || '';
  2340. var $Promise = global[PROMISE];
  2341. var isNode = classof(process) == 'process';
  2342. var empty = function empty() {};
  2343. var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
  2344. var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;
  2345. var USE_NATIVE = !!function () {
  2346. try {
  2347. var promise = $Promise.resolve(1);
  2348. var FakePromise = (promise.constructor = {})[__w_pdfjs_require__(33)('species')] = function (exec) {
  2349. exec(empty, empty);
  2350. };
  2351. return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise && v8.indexOf('6.6') !== 0 && userAgent.indexOf('Chrome/66') === -1;
  2352. } catch (e) {}
  2353. }();
  2354. var isThenable = function isThenable(it) {
  2355. var then;
  2356. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  2357. };
  2358. var notify = function notify(promise, isReject) {
  2359. if (promise._n) return;
  2360. promise._n = true;
  2361. var chain = promise._c;
  2362. microtask(function () {
  2363. var value = promise._v;
  2364. var ok = promise._s == 1;
  2365. var i = 0;
  2366. var run = function run(reaction) {
  2367. var handler = ok ? reaction.ok : reaction.fail;
  2368. var resolve = reaction.resolve;
  2369. var reject = reaction.reject;
  2370. var domain = reaction.domain;
  2371. var result, then, exited;
  2372. try {
  2373. if (handler) {
  2374. if (!ok) {
  2375. if (promise._h == 2) onHandleUnhandled(promise);
  2376. promise._h = 1;
  2377. }
  2378. if (handler === true) result = value;else {
  2379. if (domain) domain.enter();
  2380. result = handler(value);
  2381. if (domain) {
  2382. domain.exit();
  2383. exited = true;
  2384. }
  2385. }
  2386. if (result === reaction.promise) {
  2387. reject(TypeError('Promise-chain cycle'));
  2388. } else if (then = isThenable(result)) {
  2389. then.call(result, resolve, reject);
  2390. } else resolve(result);
  2391. } else reject(value);
  2392. } catch (e) {
  2393. if (domain && !exited) domain.exit();
  2394. reject(e);
  2395. }
  2396. };
  2397. while (chain.length > i) {
  2398. run(chain[i++]);
  2399. }
  2400. promise._c = [];
  2401. promise._n = false;
  2402. if (isReject && !promise._h) onUnhandled(promise);
  2403. });
  2404. };
  2405. var onUnhandled = function onUnhandled(promise) {
  2406. task.call(global, function () {
  2407. var value = promise._v;
  2408. var unhandled = isUnhandled(promise);
  2409. var result, handler, console;
  2410. if (unhandled) {
  2411. result = perform(function () {
  2412. if (isNode) {
  2413. process.emit('unhandledRejection', value, promise);
  2414. } else if (handler = global.onunhandledrejection) {
  2415. handler({
  2416. promise: promise,
  2417. reason: value
  2418. });
  2419. } else if ((console = global.console) && console.error) {
  2420. console.error('Unhandled promise rejection', value);
  2421. }
  2422. });
  2423. promise._h = isNode || isUnhandled(promise) ? 2 : 1;
  2424. }
  2425. promise._a = undefined;
  2426. if (unhandled && result.e) throw result.v;
  2427. });
  2428. };
  2429. var isUnhandled = function isUnhandled(promise) {
  2430. return promise._h !== 1 && (promise._a || promise._c).length === 0;
  2431. };
  2432. var onHandleUnhandled = function onHandleUnhandled(promise) {
  2433. task.call(global, function () {
  2434. var handler;
  2435. if (isNode) {
  2436. process.emit('rejectionHandled', promise);
  2437. } else if (handler = global.onrejectionhandled) {
  2438. handler({
  2439. promise: promise,
  2440. reason: promise._v
  2441. });
  2442. }
  2443. });
  2444. };
  2445. var $reject = function $reject(value) {
  2446. var promise = this;
  2447. if (promise._d) return;
  2448. promise._d = true;
  2449. promise = promise._w || promise;
  2450. promise._v = value;
  2451. promise._s = 2;
  2452. if (!promise._a) promise._a = promise._c.slice();
  2453. notify(promise, true);
  2454. };
  2455. var $resolve = function $resolve(value) {
  2456. var promise = this;
  2457. var then;
  2458. if (promise._d) return;
  2459. promise._d = true;
  2460. promise = promise._w || promise;
  2461. try {
  2462. if (promise === value) throw TypeError("Promise can't be resolved itself");
  2463. if (then = isThenable(value)) {
  2464. microtask(function () {
  2465. var wrapper = {
  2466. _w: promise,
  2467. _d: false
  2468. };
  2469. try {
  2470. then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
  2471. } catch (e) {
  2472. $reject.call(wrapper, e);
  2473. }
  2474. });
  2475. } else {
  2476. promise._v = value;
  2477. promise._s = 1;
  2478. notify(promise, false);
  2479. }
  2480. } catch (e) {
  2481. $reject.call({
  2482. _w: promise,
  2483. _d: false
  2484. }, e);
  2485. }
  2486. };
  2487. if (!USE_NATIVE) {
  2488. $Promise = function Promise(executor) {
  2489. anInstance(this, $Promise, PROMISE, '_h');
  2490. aFunction(executor);
  2491. Internal.call(this);
  2492. try {
  2493. executor(ctx($resolve, this, 1), ctx($reject, this, 1));
  2494. } catch (err) {
  2495. $reject.call(this, err);
  2496. }
  2497. };
  2498. Internal = function Promise(executor) {
  2499. this._c = [];
  2500. this._a = undefined;
  2501. this._s = 0;
  2502. this._d = false;
  2503. this._v = undefined;
  2504. this._h = 0;
  2505. this._n = false;
  2506. };
  2507. Internal.prototype = __w_pdfjs_require__(98)($Promise.prototype, {
  2508. then: function then(onFulfilled, onRejected) {
  2509. var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
  2510. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  2511. reaction.fail = typeof onRejected == 'function' && onRejected;
  2512. reaction.domain = isNode ? process.domain : undefined;
  2513. this._c.push(reaction);
  2514. if (this._a) this._a.push(reaction);
  2515. if (this._s) notify(this, false);
  2516. return reaction.promise;
  2517. },
  2518. 'catch': function _catch(onRejected) {
  2519. return this.then(undefined, onRejected);
  2520. }
  2521. });
  2522. OwnPromiseCapability = function OwnPromiseCapability() {
  2523. var promise = new Internal();
  2524. this.promise = promise;
  2525. this.resolve = ctx($resolve, promise, 1);
  2526. this.reject = ctx($reject, promise, 1);
  2527. };
  2528. newPromiseCapabilityModule.f = newPromiseCapability = function newPromiseCapability(C) {
  2529. return C === $Promise || C === Wrapper ? new OwnPromiseCapability(C) : newGenericPromiseCapability(C);
  2530. };
  2531. }
  2532. $export($export.G + $export.W + $export.F * !USE_NATIVE, {
  2533. Promise: $Promise
  2534. });
  2535. __w_pdfjs_require__(60)($Promise, PROMISE);
  2536. __w_pdfjs_require__(99)(PROMISE);
  2537. Wrapper = __w_pdfjs_require__(9)[PROMISE];
  2538. $export($export.S + $export.F * !USE_NATIVE, PROMISE, {
  2539. reject: function reject(r) {
  2540. var capability = newPromiseCapability(this);
  2541. var $$reject = capability.reject;
  2542. $$reject(r);
  2543. return capability.promise;
  2544. }
  2545. });
  2546. $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
  2547. resolve: function resolve(x) {
  2548. return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);
  2549. }
  2550. });
  2551. $export($export.S + $export.F * !(USE_NATIVE && __w_pdfjs_require__(69)(function (iter) {
  2552. $Promise.all(iter)['catch'](empty);
  2553. })), PROMISE, {
  2554. all: function all(iterable) {
  2555. var C = this;
  2556. var capability = newPromiseCapability(C);
  2557. var resolve = capability.resolve;
  2558. var reject = capability.reject;
  2559. var result = perform(function () {
  2560. var values = [];
  2561. var index = 0;
  2562. var remaining = 1;
  2563. forOf(iterable, false, function (promise) {
  2564. var $index = index++;
  2565. var alreadyCalled = false;
  2566. values.push(undefined);
  2567. remaining++;
  2568. C.resolve(promise).then(function (value) {
  2569. if (alreadyCalled) return;
  2570. alreadyCalled = true;
  2571. values[$index] = value;
  2572. --remaining || resolve(values);
  2573. }, reject);
  2574. });
  2575. --remaining || resolve(values);
  2576. });
  2577. if (result.e) reject(result.v);
  2578. return capability.promise;
  2579. },
  2580. race: function race(iterable) {
  2581. var C = this;
  2582. var capability = newPromiseCapability(C);
  2583. var reject = capability.reject;
  2584. var result = perform(function () {
  2585. forOf(iterable, false, function (promise) {
  2586. C.resolve(promise).then(capability.resolve, reject);
  2587. });
  2588. });
  2589. if (result.e) reject(result.v);
  2590. return capability.promise;
  2591. }
  2592. });
  2593. /***/ }),
  2594. /* 88 */
  2595. /***/ (function(module, exports, __w_pdfjs_require__) {
  2596. "use strict";
  2597. module.exports = function (it, Constructor, name, forbiddenField) {
  2598. if (!(it instanceof Constructor) || forbiddenField !== undefined && forbiddenField in it) {
  2599. throw TypeError(name + ': incorrect invocation!');
  2600. }
  2601. return it;
  2602. };
  2603. /***/ }),
  2604. /* 89 */
  2605. /***/ (function(module, exports, __w_pdfjs_require__) {
  2606. "use strict";
  2607. var ctx = __w_pdfjs_require__(26);
  2608. var call = __w_pdfjs_require__(64);
  2609. var isArrayIter = __w_pdfjs_require__(65);
  2610. var anObject = __w_pdfjs_require__(12);
  2611. var toLength = __w_pdfjs_require__(28);
  2612. var getIterFn = __w_pdfjs_require__(67);
  2613. var BREAK = {};
  2614. var RETURN = {};
  2615. var _exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
  2616. var iterFn = ITERATOR ? function () {
  2617. return iterable;
  2618. } : getIterFn(iterable);
  2619. var f = ctx(fn, that, entries ? 2 : 1);
  2620. var index = 0;
  2621. var length, step, iterator, result;
  2622. if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
  2623. if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
  2624. result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
  2625. if (result === BREAK || result === RETURN) return result;
  2626. } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
  2627. result = call(iterator, f, step.value, entries);
  2628. if (result === BREAK || result === RETURN) return result;
  2629. }
  2630. };
  2631. _exports.BREAK = BREAK;
  2632. _exports.RETURN = RETURN;
  2633. /***/ }),
  2634. /* 90 */
  2635. /***/ (function(module, exports, __w_pdfjs_require__) {
  2636. "use strict";
  2637. var anObject = __w_pdfjs_require__(12);
  2638. var aFunction = __w_pdfjs_require__(27);
  2639. var SPECIES = __w_pdfjs_require__(33)('species');
  2640. module.exports = function (O, D) {
  2641. var C = anObject(O).constructor;
  2642. var S;
  2643. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
  2644. };
  2645. /***/ }),
  2646. /* 91 */
  2647. /***/ (function(module, exports, __w_pdfjs_require__) {
  2648. "use strict";
  2649. var ctx = __w_pdfjs_require__(26);
  2650. var invoke = __w_pdfjs_require__(92);
  2651. var html = __w_pdfjs_require__(59);
  2652. var cel = __w_pdfjs_require__(17);
  2653. var global = __w_pdfjs_require__(8);
  2654. var process = global.process;
  2655. var setTask = global.setImmediate;
  2656. var clearTask = global.clearImmediate;
  2657. var MessageChannel = global.MessageChannel;
  2658. var Dispatch = global.Dispatch;
  2659. var counter = 0;
  2660. var queue = {};
  2661. var ONREADYSTATECHANGE = 'onreadystatechange';
  2662. var defer, channel, port;
  2663. var run = function run() {
  2664. var id = +this;
  2665. if (queue.hasOwnProperty(id)) {
  2666. var fn = queue[id];
  2667. delete queue[id];
  2668. fn();
  2669. }
  2670. };
  2671. var listener = function listener(event) {
  2672. run.call(event.data);
  2673. };
  2674. if (!setTask || !clearTask) {
  2675. setTask = function setImmediate(fn) {
  2676. var args = [];
  2677. var i = 1;
  2678. while (arguments.length > i) {
  2679. args.push(arguments[i++]);
  2680. }
  2681. queue[++counter] = function () {
  2682. invoke(typeof fn == 'function' ? fn : Function(fn), args);
  2683. };
  2684. defer(counter);
  2685. return counter;
  2686. };
  2687. clearTask = function clearImmediate(id) {
  2688. delete queue[id];
  2689. };
  2690. if (__w_pdfjs_require__(32)(process) == 'process') {
  2691. defer = function defer(id) {
  2692. process.nextTick(ctx(run, id, 1));
  2693. };
  2694. } else if (Dispatch && Dispatch.now) {
  2695. defer = function defer(id) {
  2696. Dispatch.now(ctx(run, id, 1));
  2697. };
  2698. } else if (MessageChannel) {
  2699. channel = new MessageChannel();
  2700. port = channel.port2;
  2701. channel.port1.onmessage = listener;
  2702. defer = ctx(port.postMessage, port, 1);
  2703. } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
  2704. defer = function defer(id) {
  2705. global.postMessage(id + '', '*');
  2706. };
  2707. global.addEventListener('message', listener, false);
  2708. } else if (ONREADYSTATECHANGE in cel('script')) {
  2709. defer = function defer(id) {
  2710. html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
  2711. html.removeChild(this);
  2712. run.call(id);
  2713. };
  2714. };
  2715. } else {
  2716. defer = function defer(id) {
  2717. setTimeout(ctx(run, id, 1), 0);
  2718. };
  2719. }
  2720. }
  2721. module.exports = {
  2722. set: setTask,
  2723. clear: clearTask
  2724. };
  2725. /***/ }),
  2726. /* 92 */
  2727. /***/ (function(module, exports, __w_pdfjs_require__) {
  2728. "use strict";
  2729. module.exports = function (fn, args, that) {
  2730. var un = that === undefined;
  2731. switch (args.length) {
  2732. case 0:
  2733. return un ? fn() : fn.call(that);
  2734. case 1:
  2735. return un ? fn(args[0]) : fn.call(that, args[0]);
  2736. case 2:
  2737. return un ? fn(args[0], args[1]) : fn.call(that, args[0], args[1]);
  2738. case 3:
  2739. return un ? fn(args[0], args[1], args[2]) : fn.call(that, args[0], args[1], args[2]);
  2740. case 4:
  2741. return un ? fn(args[0], args[1], args[2], args[3]) : fn.call(that, args[0], args[1], args[2], args[3]);
  2742. }
  2743. return fn.apply(that, args);
  2744. };
  2745. /***/ }),
  2746. /* 93 */
  2747. /***/ (function(module, exports, __w_pdfjs_require__) {
  2748. "use strict";
  2749. var global = __w_pdfjs_require__(8);
  2750. var macrotask = __w_pdfjs_require__(91).set;
  2751. var Observer = global.MutationObserver || global.WebKitMutationObserver;
  2752. var process = global.process;
  2753. var Promise = global.Promise;
  2754. var isNode = __w_pdfjs_require__(32)(process) == 'process';
  2755. module.exports = function () {
  2756. var head, last, notify;
  2757. var flush = function flush() {
  2758. var parent, fn;
  2759. if (isNode && (parent = process.domain)) parent.exit();
  2760. while (head) {
  2761. fn = head.fn;
  2762. head = head.next;
  2763. try {
  2764. fn();
  2765. } catch (e) {
  2766. if (head) notify();else last = undefined;
  2767. throw e;
  2768. }
  2769. }
  2770. last = undefined;
  2771. if (parent) parent.enter();
  2772. };
  2773. if (isNode) {
  2774. notify = function notify() {
  2775. process.nextTick(flush);
  2776. };
  2777. } else if (Observer && !(global.navigator && global.navigator.standalone)) {
  2778. var toggle = true;
  2779. var node = document.createTextNode('');
  2780. new Observer(flush).observe(node, {
  2781. characterData: true
  2782. });
  2783. notify = function notify() {
  2784. node.data = toggle = !toggle;
  2785. };
  2786. } else if (Promise && Promise.resolve) {
  2787. var promise = Promise.resolve(undefined);
  2788. notify = function notify() {
  2789. promise.then(flush);
  2790. };
  2791. } else {
  2792. notify = function notify() {
  2793. macrotask.call(global, flush);
  2794. };
  2795. }
  2796. return function (fn) {
  2797. var task = {
  2798. fn: fn,
  2799. next: undefined
  2800. };
  2801. if (last) last.next = task;
  2802. if (!head) {
  2803. head = task;
  2804. notify();
  2805. }
  2806. last = task;
  2807. };
  2808. };
  2809. /***/ }),
  2810. /* 94 */
  2811. /***/ (function(module, exports, __w_pdfjs_require__) {
  2812. "use strict";
  2813. var aFunction = __w_pdfjs_require__(27);
  2814. function PromiseCapability(C) {
  2815. var resolve, reject;
  2816. this.promise = new C(function ($$resolve, $$reject) {
  2817. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  2818. resolve = $$resolve;
  2819. reject = $$reject;
  2820. });
  2821. this.resolve = aFunction(resolve);
  2822. this.reject = aFunction(reject);
  2823. }
  2824. module.exports.f = function (C) {
  2825. return new PromiseCapability(C);
  2826. };
  2827. /***/ }),
  2828. /* 95 */
  2829. /***/ (function(module, exports, __w_pdfjs_require__) {
  2830. "use strict";
  2831. module.exports = function (exec) {
  2832. try {
  2833. return {
  2834. e: false,
  2835. v: exec()
  2836. };
  2837. } catch (e) {
  2838. return {
  2839. e: true,
  2840. v: e
  2841. };
  2842. }
  2843. };
  2844. /***/ }),
  2845. /* 96 */
  2846. /***/ (function(module, exports, __w_pdfjs_require__) {
  2847. "use strict";
  2848. var global = __w_pdfjs_require__(8);
  2849. var navigator = global.navigator;
  2850. module.exports = navigator && navigator.userAgent || '';
  2851. /***/ }),
  2852. /* 97 */
  2853. /***/ (function(module, exports, __w_pdfjs_require__) {
  2854. "use strict";
  2855. var anObject = __w_pdfjs_require__(12);
  2856. var isObject = __w_pdfjs_require__(13);
  2857. var newPromiseCapability = __w_pdfjs_require__(94);
  2858. module.exports = function (C, x) {
  2859. anObject(C);
  2860. if (isObject(x) && x.constructor === C) return x;
  2861. var promiseCapability = newPromiseCapability.f(C);
  2862. var resolve = promiseCapability.resolve;
  2863. resolve(x);
  2864. return promiseCapability.promise;
  2865. };
  2866. /***/ }),
  2867. /* 98 */
  2868. /***/ (function(module, exports, __w_pdfjs_require__) {
  2869. "use strict";
  2870. var redefine = __w_pdfjs_require__(20);
  2871. module.exports = function (target, src, safe) {
  2872. for (var key in src) {
  2873. redefine(target, key, src[key], safe);
  2874. }
  2875. return target;
  2876. };
  2877. /***/ }),
  2878. /* 99 */
  2879. /***/ (function(module, exports, __w_pdfjs_require__) {
  2880. "use strict";
  2881. var global = __w_pdfjs_require__(8);
  2882. var dP = __w_pdfjs_require__(11);
  2883. var DESCRIPTORS = __w_pdfjs_require__(15);
  2884. var SPECIES = __w_pdfjs_require__(33)('species');
  2885. module.exports = function (KEY) {
  2886. var C = global[KEY];
  2887. if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
  2888. configurable: true,
  2889. get: function get() {
  2890. return this;
  2891. }
  2892. });
  2893. };
  2894. /***/ }),
  2895. /* 100 */
  2896. /***/ (function(module, exports, __w_pdfjs_require__) {
  2897. "use strict";
  2898. var $export = __w_pdfjs_require__(7);
  2899. var core = __w_pdfjs_require__(9);
  2900. var global = __w_pdfjs_require__(8);
  2901. var speciesConstructor = __w_pdfjs_require__(90);
  2902. var promiseResolve = __w_pdfjs_require__(97);
  2903. $export($export.P + $export.R, 'Promise', {
  2904. 'finally': function _finally(onFinally) {
  2905. var C = speciesConstructor(this, core.Promise || global.Promise);
  2906. var isFunction = typeof onFinally == 'function';
  2907. return this.then(isFunction ? function (x) {
  2908. return promiseResolve(C, onFinally()).then(function () {
  2909. return x;
  2910. });
  2911. } : onFinally, isFunction ? function (e) {
  2912. return promiseResolve(C, onFinally()).then(function () {
  2913. throw e;
  2914. });
  2915. } : onFinally);
  2916. }
  2917. });
  2918. /***/ }),
  2919. /* 101 */
  2920. /***/ (function(module, exports, __w_pdfjs_require__) {
  2921. "use strict";
  2922. var $export = __w_pdfjs_require__(7);
  2923. var newPromiseCapability = __w_pdfjs_require__(94);
  2924. var perform = __w_pdfjs_require__(95);
  2925. $export($export.S, 'Promise', {
  2926. 'try': function _try(callbackfn) {
  2927. var promiseCapability = newPromiseCapability.f(this);
  2928. var result = perform(callbackfn);
  2929. (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
  2930. return promiseCapability.promise;
  2931. }
  2932. });
  2933. /***/ }),
  2934. /* 102 */
  2935. /***/ (function(module, exports, __w_pdfjs_require__) {
  2936. "use strict";
  2937. __w_pdfjs_require__(83);
  2938. __w_pdfjs_require__(84);
  2939. __w_pdfjs_require__(103);
  2940. __w_pdfjs_require__(115);
  2941. __w_pdfjs_require__(117);
  2942. module.exports = __w_pdfjs_require__(9).WeakMap;
  2943. /***/ }),
  2944. /* 103 */
  2945. /***/ (function(module, exports, __w_pdfjs_require__) {
  2946. "use strict";
  2947. var global = __w_pdfjs_require__(8);
  2948. var each = __w_pdfjs_require__(104)(0);
  2949. var redefine = __w_pdfjs_require__(20);
  2950. var meta = __w_pdfjs_require__(108);
  2951. var assign = __w_pdfjs_require__(72);
  2952. var weak = __w_pdfjs_require__(109);
  2953. var isObject = __w_pdfjs_require__(13);
  2954. var validate = __w_pdfjs_require__(110);
  2955. var NATIVE_WEAK_MAP = __w_pdfjs_require__(110);
  2956. var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
  2957. var WEAK_MAP = 'WeakMap';
  2958. var getWeak = meta.getWeak;
  2959. var isExtensible = Object.isExtensible;
  2960. var uncaughtFrozenStore = weak.ufstore;
  2961. var InternalMap;
  2962. var wrapper = function wrapper(get) {
  2963. return function WeakMap() {
  2964. return get(this, arguments.length > 0 ? arguments[0] : undefined);
  2965. };
  2966. };
  2967. var methods = {
  2968. get: function get(key) {
  2969. if (isObject(key)) {
  2970. var data = getWeak(key);
  2971. if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key);
  2972. return data ? data[this._i] : undefined;
  2973. }
  2974. },
  2975. set: function set(key, value) {
  2976. return weak.def(validate(this, WEAK_MAP), key, value);
  2977. }
  2978. };
  2979. var $WeakMap = module.exports = __w_pdfjs_require__(111)(WEAK_MAP, wrapper, methods, weak, true, true);
  2980. if (NATIVE_WEAK_MAP && IS_IE11) {
  2981. InternalMap = weak.getConstructor(wrapper, WEAK_MAP);
  2982. assign(InternalMap.prototype, methods);
  2983. meta.NEED = true;
  2984. each(['delete', 'has', 'get', 'set'], function (key) {
  2985. var proto = $WeakMap.prototype;
  2986. var method = proto[key];
  2987. redefine(proto, key, function (a, b) {
  2988. if (isObject(a) && !isExtensible(a)) {
  2989. if (!this._f) this._f = new InternalMap();
  2990. var result = this._f[key](a, b);
  2991. return key == 'set' ? this : result;
  2992. }
  2993. return method.call(this, a, b);
  2994. });
  2995. });
  2996. }
  2997. /***/ }),
  2998. /* 104 */
  2999. /***/ (function(module, exports, __w_pdfjs_require__) {
  3000. "use strict";
  3001. var ctx = __w_pdfjs_require__(26);
  3002. var IObject = __w_pdfjs_require__(44);
  3003. var toObject = __w_pdfjs_require__(62);
  3004. var toLength = __w_pdfjs_require__(28);
  3005. var asc = __w_pdfjs_require__(105);
  3006. module.exports = function (TYPE, $create) {
  3007. var IS_MAP = TYPE == 1;
  3008. var IS_FILTER = TYPE == 2;
  3009. var IS_SOME = TYPE == 3;
  3010. var IS_EVERY = TYPE == 4;
  3011. var IS_FIND_INDEX = TYPE == 6;
  3012. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  3013. var create = $create || asc;
  3014. return function ($this, callbackfn, that) {
  3015. var O = toObject($this);
  3016. var self = IObject(O);
  3017. var f = ctx(callbackfn, that, 3);
  3018. var length = toLength(self.length);
  3019. var index = 0;
  3020. var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  3021. var val, res;
  3022. for (; length > index; index++) {
  3023. if (NO_HOLES || index in self) {
  3024. val = self[index];
  3025. res = f(val, index, O);
  3026. if (TYPE) {
  3027. if (IS_MAP) result[index] = res;else if (res) switch (TYPE) {
  3028. case 3:
  3029. return true;
  3030. case 5:
  3031. return val;
  3032. case 6:
  3033. return index;
  3034. case 2:
  3035. result.push(val);
  3036. } else if (IS_EVERY) return false;
  3037. }
  3038. }
  3039. }
  3040. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  3041. };
  3042. };
  3043. /***/ }),
  3044. /* 105 */
  3045. /***/ (function(module, exports, __w_pdfjs_require__) {
  3046. "use strict";
  3047. var speciesConstructor = __w_pdfjs_require__(106);
  3048. module.exports = function (original, length) {
  3049. return new (speciesConstructor(original))(length);
  3050. };
  3051. /***/ }),
  3052. /* 106 */
  3053. /***/ (function(module, exports, __w_pdfjs_require__) {
  3054. "use strict";
  3055. var isObject = __w_pdfjs_require__(13);
  3056. var isArray = __w_pdfjs_require__(107);
  3057. var SPECIES = __w_pdfjs_require__(33)('species');
  3058. module.exports = function (original) {
  3059. var C;
  3060. if (isArray(original)) {
  3061. C = original.constructor;
  3062. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  3063. if (isObject(C)) {
  3064. C = C[SPECIES];
  3065. if (C === null) C = undefined;
  3066. }
  3067. }
  3068. return C === undefined ? Array : C;
  3069. };
  3070. /***/ }),
  3071. /* 107 */
  3072. /***/ (function(module, exports, __w_pdfjs_require__) {
  3073. "use strict";
  3074. var cof = __w_pdfjs_require__(32);
  3075. module.exports = Array.isArray || function isArray(arg) {
  3076. return cof(arg) == 'Array';
  3077. };
  3078. /***/ }),
  3079. /* 108 */
  3080. /***/ (function(module, exports, __w_pdfjs_require__) {
  3081. "use strict";
  3082. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3083. var META = __w_pdfjs_require__(22)('meta');
  3084. var isObject = __w_pdfjs_require__(13);
  3085. var has = __w_pdfjs_require__(21);
  3086. var setDesc = __w_pdfjs_require__(11).f;
  3087. var id = 0;
  3088. var isExtensible = Object.isExtensible || function () {
  3089. return true;
  3090. };
  3091. var FREEZE = !__w_pdfjs_require__(16)(function () {
  3092. return isExtensible(Object.preventExtensions({}));
  3093. });
  3094. var setMeta = function setMeta(it) {
  3095. setDesc(it, META, {
  3096. value: {
  3097. i: 'O' + ++id,
  3098. w: {}
  3099. }
  3100. });
  3101. };
  3102. var fastKey = function fastKey(it, create) {
  3103. if (!isObject(it)) return _typeof(it) == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  3104. if (!has(it, META)) {
  3105. if (!isExtensible(it)) return 'F';
  3106. if (!create) return 'E';
  3107. setMeta(it);
  3108. }
  3109. return it[META].i;
  3110. };
  3111. var getWeak = function getWeak(it, create) {
  3112. if (!has(it, META)) {
  3113. if (!isExtensible(it)) return true;
  3114. if (!create) return false;
  3115. setMeta(it);
  3116. }
  3117. return it[META].w;
  3118. };
  3119. var onFreeze = function onFreeze(it) {
  3120. if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
  3121. return it;
  3122. };
  3123. var meta = module.exports = {
  3124. KEY: META,
  3125. NEED: false,
  3126. fastKey: fastKey,
  3127. getWeak: getWeak,
  3128. onFreeze: onFreeze
  3129. };
  3130. /***/ }),
  3131. /* 109 */
  3132. /***/ (function(module, exports, __w_pdfjs_require__) {
  3133. "use strict";
  3134. var redefineAll = __w_pdfjs_require__(98);
  3135. var getWeak = __w_pdfjs_require__(108).getWeak;
  3136. var anObject = __w_pdfjs_require__(12);
  3137. var isObject = __w_pdfjs_require__(13);
  3138. var anInstance = __w_pdfjs_require__(88);
  3139. var forOf = __w_pdfjs_require__(89);
  3140. var createArrayMethod = __w_pdfjs_require__(104);
  3141. var $has = __w_pdfjs_require__(21);
  3142. var validate = __w_pdfjs_require__(110);
  3143. var arrayFind = createArrayMethod(5);
  3144. var arrayFindIndex = createArrayMethod(6);
  3145. var id = 0;
  3146. var uncaughtFrozenStore = function uncaughtFrozenStore(that) {
  3147. return that._l || (that._l = new UncaughtFrozenStore());
  3148. };
  3149. var UncaughtFrozenStore = function UncaughtFrozenStore() {
  3150. this.a = [];
  3151. };
  3152. var findUncaughtFrozen = function findUncaughtFrozen(store, key) {
  3153. return arrayFind(store.a, function (it) {
  3154. return it[0] === key;
  3155. });
  3156. };
  3157. UncaughtFrozenStore.prototype = {
  3158. get: function get(key) {
  3159. var entry = findUncaughtFrozen(this, key);
  3160. if (entry) return entry[1];
  3161. },
  3162. has: function has(key) {
  3163. return !!findUncaughtFrozen(this, key);
  3164. },
  3165. set: function set(key, value) {
  3166. var entry = findUncaughtFrozen(this, key);
  3167. if (entry) entry[1] = value;else this.a.push([key, value]);
  3168. },
  3169. 'delete': function _delete(key) {
  3170. var index = arrayFindIndex(this.a, function (it) {
  3171. return it[0] === key;
  3172. });
  3173. if (~index) this.a.splice(index, 1);
  3174. return !!~index;
  3175. }
  3176. };
  3177. module.exports = {
  3178. getConstructor: function getConstructor(wrapper, NAME, IS_MAP, ADDER) {
  3179. var C = wrapper(function (that, iterable) {
  3180. anInstance(that, C, NAME, '_i');
  3181. that._t = NAME;
  3182. that._i = id++;
  3183. that._l = undefined;
  3184. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  3185. });
  3186. redefineAll(C.prototype, {
  3187. 'delete': function _delete(key) {
  3188. if (!isObject(key)) return false;
  3189. var data = getWeak(key);
  3190. if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key);
  3191. return data && $has(data, this._i) && delete data[this._i];
  3192. },
  3193. has: function has(key) {
  3194. if (!isObject(key)) return false;
  3195. var data = getWeak(key);
  3196. if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key);
  3197. return data && $has(data, this._i);
  3198. }
  3199. });
  3200. return C;
  3201. },
  3202. def: function def(that, key, value) {
  3203. var data = getWeak(anObject(key), true);
  3204. if (data === true) uncaughtFrozenStore(that).set(key, value);else data[that._i] = value;
  3205. return that;
  3206. },
  3207. ufstore: uncaughtFrozenStore
  3208. };
  3209. /***/ }),
  3210. /* 110 */
  3211. /***/ (function(module, exports, __w_pdfjs_require__) {
  3212. "use strict";
  3213. var isObject = __w_pdfjs_require__(13);
  3214. module.exports = function (it, TYPE) {
  3215. if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
  3216. return it;
  3217. };
  3218. /***/ }),
  3219. /* 111 */
  3220. /***/ (function(module, exports, __w_pdfjs_require__) {
  3221. "use strict";
  3222. var global = __w_pdfjs_require__(8);
  3223. var $export = __w_pdfjs_require__(7);
  3224. var redefine = __w_pdfjs_require__(20);
  3225. var redefineAll = __w_pdfjs_require__(98);
  3226. var meta = __w_pdfjs_require__(108);
  3227. var forOf = __w_pdfjs_require__(89);
  3228. var anInstance = __w_pdfjs_require__(88);
  3229. var isObject = __w_pdfjs_require__(13);
  3230. var fails = __w_pdfjs_require__(16);
  3231. var $iterDetect = __w_pdfjs_require__(69);
  3232. var setToStringTag = __w_pdfjs_require__(60);
  3233. var inheritIfRequired = __w_pdfjs_require__(112);
  3234. module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
  3235. var Base = global[NAME];
  3236. var C = Base;
  3237. var ADDER = IS_MAP ? 'set' : 'add';
  3238. var proto = C && C.prototype;
  3239. var O = {};
  3240. var fixMethod = function fixMethod(KEY) {
  3241. var fn = proto[KEY];
  3242. redefine(proto, KEY, KEY == 'delete' ? function (a) {
  3243. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  3244. } : KEY == 'has' ? function has(a) {
  3245. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  3246. } : KEY == 'get' ? function get(a) {
  3247. return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
  3248. } : KEY == 'add' ? function add(a) {
  3249. fn.call(this, a === 0 ? 0 : a);
  3250. return this;
  3251. } : function set(a, b) {
  3252. fn.call(this, a === 0 ? 0 : a, b);
  3253. return this;
  3254. });
  3255. };
  3256. if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {
  3257. new C().entries().next();
  3258. }))) {
  3259. C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
  3260. redefineAll(C.prototype, methods);
  3261. meta.NEED = true;
  3262. } else {
  3263. var instance = new C();
  3264. var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
  3265. var THROWS_ON_PRIMITIVES = fails(function () {
  3266. instance.has(1);
  3267. });
  3268. var ACCEPT_ITERABLES = $iterDetect(function (iter) {
  3269. new C(iter);
  3270. });
  3271. var BUGGY_ZERO = !IS_WEAK && fails(function () {
  3272. var $instance = new C();
  3273. var index = 5;
  3274. while (index--) {
  3275. $instance[ADDER](index, index);
  3276. }
  3277. return !$instance.has(-0);
  3278. });
  3279. if (!ACCEPT_ITERABLES) {
  3280. C = wrapper(function (target, iterable) {
  3281. anInstance(target, C, NAME);
  3282. var that = inheritIfRequired(new Base(), target, C);
  3283. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  3284. return that;
  3285. });
  3286. C.prototype = proto;
  3287. proto.constructor = C;
  3288. }
  3289. if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
  3290. fixMethod('delete');
  3291. fixMethod('has');
  3292. IS_MAP && fixMethod('get');
  3293. }
  3294. if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
  3295. if (IS_WEAK && proto.clear) delete proto.clear;
  3296. }
  3297. setToStringTag(C, NAME);
  3298. O[NAME] = C;
  3299. $export($export.G + $export.W + $export.F * (C != Base), O);
  3300. if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
  3301. return C;
  3302. };
  3303. /***/ }),
  3304. /* 112 */
  3305. /***/ (function(module, exports, __w_pdfjs_require__) {
  3306. "use strict";
  3307. var isObject = __w_pdfjs_require__(13);
  3308. var setPrototypeOf = __w_pdfjs_require__(113).set;
  3309. module.exports = function (that, target, C) {
  3310. var S = target.constructor;
  3311. var P;
  3312. if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf) {
  3313. setPrototypeOf(that, P);
  3314. }
  3315. return that;
  3316. };
  3317. /***/ }),
  3318. /* 113 */
  3319. /***/ (function(module, exports, __w_pdfjs_require__) {
  3320. "use strict";
  3321. var isObject = __w_pdfjs_require__(13);
  3322. var anObject = __w_pdfjs_require__(12);
  3323. var check = function check(O, proto) {
  3324. anObject(O);
  3325. if (!isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
  3326. };
  3327. module.exports = {
  3328. set: Object.setPrototypeOf || ('__proto__' in {} ? function (test, buggy, set) {
  3329. try {
  3330. set = __w_pdfjs_require__(26)(Function.call, __w_pdfjs_require__(114).f(Object.prototype, '__proto__').set, 2);
  3331. set(test, []);
  3332. buggy = !(test instanceof Array);
  3333. } catch (e) {
  3334. buggy = true;
  3335. }
  3336. return function setPrototypeOf(O, proto) {
  3337. check(O, proto);
  3338. if (buggy) O.__proto__ = proto;else set(O, proto);
  3339. return O;
  3340. };
  3341. }({}, false) : undefined),
  3342. check: check
  3343. };
  3344. /***/ }),
  3345. /* 114 */
  3346. /***/ (function(module, exports, __w_pdfjs_require__) {
  3347. "use strict";
  3348. var pIE = __w_pdfjs_require__(74);
  3349. var createDesc = __w_pdfjs_require__(19);
  3350. var toIObject = __w_pdfjs_require__(43);
  3351. var toPrimitive = __w_pdfjs_require__(18);
  3352. var has = __w_pdfjs_require__(21);
  3353. var IE8_DOM_DEFINE = __w_pdfjs_require__(14);
  3354. var gOPD = Object.getOwnPropertyDescriptor;
  3355. exports.f = __w_pdfjs_require__(15) ? gOPD : function getOwnPropertyDescriptor(O, P) {
  3356. O = toIObject(O);
  3357. P = toPrimitive(P, true);
  3358. if (IE8_DOM_DEFINE) try {
  3359. return gOPD(O, P);
  3360. } catch (e) {}
  3361. if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
  3362. };
  3363. /***/ }),
  3364. /* 115 */
  3365. /***/ (function(module, exports, __w_pdfjs_require__) {
  3366. "use strict";
  3367. __w_pdfjs_require__(116)('WeakMap');
  3368. /***/ }),
  3369. /* 116 */
  3370. /***/ (function(module, exports, __w_pdfjs_require__) {
  3371. "use strict";
  3372. var $export = __w_pdfjs_require__(7);
  3373. module.exports = function (COLLECTION) {
  3374. $export($export.S, COLLECTION, {
  3375. of: function of() {
  3376. var length = arguments.length;
  3377. var A = new Array(length);
  3378. while (length--) {
  3379. A[length] = arguments[length];
  3380. }
  3381. return new this(A);
  3382. }
  3383. });
  3384. };
  3385. /***/ }),
  3386. /* 117 */
  3387. /***/ (function(module, exports, __w_pdfjs_require__) {
  3388. "use strict";
  3389. __w_pdfjs_require__(118)('WeakMap');
  3390. /***/ }),
  3391. /* 118 */
  3392. /***/ (function(module, exports, __w_pdfjs_require__) {
  3393. "use strict";
  3394. var $export = __w_pdfjs_require__(7);
  3395. var aFunction = __w_pdfjs_require__(27);
  3396. var ctx = __w_pdfjs_require__(26);
  3397. var forOf = __w_pdfjs_require__(89);
  3398. module.exports = function (COLLECTION) {
  3399. $export($export.S, COLLECTION, {
  3400. from: function from(source) {
  3401. var mapFn = arguments[1];
  3402. var mapping, A, n, cb;
  3403. aFunction(this);
  3404. mapping = mapFn !== undefined;
  3405. if (mapping) aFunction(mapFn);
  3406. if (source == undefined) return new this();
  3407. A = [];
  3408. if (mapping) {
  3409. n = 0;
  3410. cb = ctx(mapFn, arguments[2], 2);
  3411. forOf(source, false, function (nextItem) {
  3412. A.push(cb(nextItem, n++));
  3413. });
  3414. } else {
  3415. forOf(source, false, A.push, A);
  3416. }
  3417. return new this(A);
  3418. }
  3419. });
  3420. };
  3421. /***/ }),
  3422. /* 119 */
  3423. /***/ (function(module, exports, __w_pdfjs_require__) {
  3424. "use strict";
  3425. __w_pdfjs_require__(83);
  3426. __w_pdfjs_require__(84);
  3427. __w_pdfjs_require__(120);
  3428. __w_pdfjs_require__(121);
  3429. __w_pdfjs_require__(122);
  3430. module.exports = __w_pdfjs_require__(9).WeakSet;
  3431. /***/ }),
  3432. /* 120 */
  3433. /***/ (function(module, exports, __w_pdfjs_require__) {
  3434. "use strict";
  3435. var weak = __w_pdfjs_require__(109);
  3436. var validate = __w_pdfjs_require__(110);
  3437. var WEAK_SET = 'WeakSet';
  3438. __w_pdfjs_require__(111)(WEAK_SET, function (get) {
  3439. return function WeakSet() {
  3440. return get(this, arguments.length > 0 ? arguments[0] : undefined);
  3441. };
  3442. }, {
  3443. add: function add(value) {
  3444. return weak.def(validate(this, WEAK_SET), value, true);
  3445. }
  3446. }, weak, false, true);
  3447. /***/ }),
  3448. /* 121 */
  3449. /***/ (function(module, exports, __w_pdfjs_require__) {
  3450. "use strict";
  3451. __w_pdfjs_require__(116)('WeakSet');
  3452. /***/ }),
  3453. /* 122 */
  3454. /***/ (function(module, exports, __w_pdfjs_require__) {
  3455. "use strict";
  3456. __w_pdfjs_require__(118)('WeakSet');
  3457. /***/ }),
  3458. /* 123 */
  3459. /***/ (function(module, exports, __w_pdfjs_require__) {
  3460. "use strict";
  3461. __w_pdfjs_require__(124);
  3462. module.exports = __w_pdfjs_require__(9).String.codePointAt;
  3463. /***/ }),
  3464. /* 124 */
  3465. /***/ (function(module, exports, __w_pdfjs_require__) {
  3466. "use strict";
  3467. var $export = __w_pdfjs_require__(7);
  3468. var $at = __w_pdfjs_require__(49)(false);
  3469. $export($export.P, 'String', {
  3470. codePointAt: function codePointAt(pos) {
  3471. return $at(this, pos);
  3472. }
  3473. });
  3474. /***/ }),
  3475. /* 125 */
  3476. /***/ (function(module, exports, __w_pdfjs_require__) {
  3477. "use strict";
  3478. __w_pdfjs_require__(126);
  3479. module.exports = __w_pdfjs_require__(9).String.fromCodePoint;
  3480. /***/ }),
  3481. /* 126 */
  3482. /***/ (function(module, exports, __w_pdfjs_require__) {
  3483. "use strict";
  3484. var $export = __w_pdfjs_require__(7);
  3485. var toAbsoluteIndex = __w_pdfjs_require__(45);
  3486. var fromCharCode = String.fromCharCode;
  3487. var $fromCodePoint = String.fromCodePoint;
  3488. $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
  3489. fromCodePoint: function fromCodePoint(x) {
  3490. var res = [];
  3491. var aLen = arguments.length;
  3492. var i = 0;
  3493. var code;
  3494. while (aLen > i) {
  3495. code = +arguments[i++];
  3496. if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point');
  3497. res.push(code < 0x10000 ? fromCharCode(code) : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00));
  3498. }
  3499. return res.join('');
  3500. }
  3501. });
  3502. /***/ }),
  3503. /* 127 */
  3504. /***/ (function(module, exports, __w_pdfjs_require__) {
  3505. "use strict";
  3506. __w_pdfjs_require__(128);
  3507. __w_pdfjs_require__(83);
  3508. module.exports = __w_pdfjs_require__(9).Symbol;
  3509. /***/ }),
  3510. /* 128 */
  3511. /***/ (function(module, exports, __w_pdfjs_require__) {
  3512. "use strict";
  3513. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3514. var global = __w_pdfjs_require__(8);
  3515. var has = __w_pdfjs_require__(21);
  3516. var DESCRIPTORS = __w_pdfjs_require__(15);
  3517. var $export = __w_pdfjs_require__(7);
  3518. var redefine = __w_pdfjs_require__(20);
  3519. var META = __w_pdfjs_require__(108).KEY;
  3520. var $fails = __w_pdfjs_require__(16);
  3521. var shared = __w_pdfjs_require__(24);
  3522. var setToStringTag = __w_pdfjs_require__(60);
  3523. var uid = __w_pdfjs_require__(22);
  3524. var wks = __w_pdfjs_require__(33);
  3525. var wksExt = __w_pdfjs_require__(129);
  3526. var wksDefine = __w_pdfjs_require__(130);
  3527. var enumKeys = __w_pdfjs_require__(131);
  3528. var isArray = __w_pdfjs_require__(107);
  3529. var anObject = __w_pdfjs_require__(12);
  3530. var isObject = __w_pdfjs_require__(13);
  3531. var toObject = __w_pdfjs_require__(62);
  3532. var toIObject = __w_pdfjs_require__(43);
  3533. var toPrimitive = __w_pdfjs_require__(18);
  3534. var createDesc = __w_pdfjs_require__(19);
  3535. var _create = __w_pdfjs_require__(53);
  3536. var gOPNExt = __w_pdfjs_require__(132);
  3537. var $GOPD = __w_pdfjs_require__(114);
  3538. var $GOPS = __w_pdfjs_require__(73);
  3539. var $DP = __w_pdfjs_require__(11);
  3540. var $keys = __w_pdfjs_require__(55);
  3541. var gOPD = $GOPD.f;
  3542. var dP = $DP.f;
  3543. var gOPN = gOPNExt.f;
  3544. var $Symbol = global.Symbol;
  3545. var $JSON = global.JSON;
  3546. var _stringify = $JSON && $JSON.stringify;
  3547. var PROTOTYPE = 'prototype';
  3548. var HIDDEN = wks('_hidden');
  3549. var TO_PRIMITIVE = wks('toPrimitive');
  3550. var isEnum = {}.propertyIsEnumerable;
  3551. var SymbolRegistry = shared('symbol-registry');
  3552. var AllSymbols = shared('symbols');
  3553. var OPSymbols = shared('op-symbols');
  3554. var ObjectProto = Object[PROTOTYPE];
  3555. var USE_NATIVE = typeof $Symbol == 'function' && !!$GOPS.f;
  3556. var QObject = global.QObject;
  3557. var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  3558. var setSymbolDesc = DESCRIPTORS && $fails(function () {
  3559. return _create(dP({}, 'a', {
  3560. get: function get() {
  3561. return dP(this, 'a', {
  3562. value: 7
  3563. }).a;
  3564. }
  3565. })).a != 7;
  3566. }) ? function (it, key, D) {
  3567. var protoDesc = gOPD(ObjectProto, key);
  3568. if (protoDesc) delete ObjectProto[key];
  3569. dP(it, key, D);
  3570. if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);
  3571. } : dP;
  3572. var wrap = function wrap(tag) {
  3573. var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
  3574. sym._k = tag;
  3575. return sym;
  3576. };
  3577. var isSymbol = USE_NATIVE && _typeof($Symbol.iterator) == 'symbol' ? function (it) {
  3578. return _typeof(it) == 'symbol';
  3579. } : function (it) {
  3580. return it instanceof $Symbol;
  3581. };
  3582. var $defineProperty = function defineProperty(it, key, D) {
  3583. if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
  3584. anObject(it);
  3585. key = toPrimitive(key, true);
  3586. anObject(D);
  3587. if (has(AllSymbols, key)) {
  3588. if (!D.enumerable) {
  3589. if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));
  3590. it[HIDDEN][key] = true;
  3591. } else {
  3592. if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
  3593. D = _create(D, {
  3594. enumerable: createDesc(0, false)
  3595. });
  3596. }
  3597. return setSymbolDesc(it, key, D);
  3598. }
  3599. return dP(it, key, D);
  3600. };
  3601. var $defineProperties = function defineProperties(it, P) {
  3602. anObject(it);
  3603. var keys = enumKeys(P = toIObject(P));
  3604. var i = 0;
  3605. var l = keys.length;
  3606. var key;
  3607. while (l > i) {
  3608. $defineProperty(it, key = keys[i++], P[key]);
  3609. }
  3610. return it;
  3611. };
  3612. var $create = function create(it, P) {
  3613. return P === undefined ? _create(it) : $defineProperties(_create(it), P);
  3614. };
  3615. var $propertyIsEnumerable = function propertyIsEnumerable(key) {
  3616. var E = isEnum.call(this, key = toPrimitive(key, true));
  3617. if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;
  3618. return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
  3619. };
  3620. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
  3621. it = toIObject(it);
  3622. key = toPrimitive(key, true);
  3623. if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;
  3624. var D = gOPD(it, key);
  3625. if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
  3626. return D;
  3627. };
  3628. var $getOwnPropertyNames = function getOwnPropertyNames(it) {
  3629. var names = gOPN(toIObject(it));
  3630. var result = [];
  3631. var i = 0;
  3632. var key;
  3633. while (names.length > i) {
  3634. if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
  3635. }
  3636. return result;
  3637. };
  3638. var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
  3639. var IS_OP = it === ObjectProto;
  3640. var names = gOPN(IS_OP ? OPSymbols : toIObject(it));
  3641. var result = [];
  3642. var i = 0;
  3643. var key;
  3644. while (names.length > i) {
  3645. if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
  3646. }
  3647. return result;
  3648. };
  3649. if (!USE_NATIVE) {
  3650. $Symbol = function _Symbol() {
  3651. if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
  3652. var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
  3653. var $set = function $set(value) {
  3654. if (this === ObjectProto) $set.call(OPSymbols, value);
  3655. if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  3656. setSymbolDesc(this, tag, createDesc(1, value));
  3657. };
  3658. if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, {
  3659. configurable: true,
  3660. set: $set
  3661. });
  3662. return wrap(tag);
  3663. };
  3664. redefine($Symbol[PROTOTYPE], 'toString', function toString() {
  3665. return this._k;
  3666. });
  3667. $GOPD.f = $getOwnPropertyDescriptor;
  3668. $DP.f = $defineProperty;
  3669. __w_pdfjs_require__(133).f = gOPNExt.f = $getOwnPropertyNames;
  3670. __w_pdfjs_require__(74).f = $propertyIsEnumerable;
  3671. $GOPS.f = $getOwnPropertySymbols;
  3672. if (DESCRIPTORS && !__w_pdfjs_require__(25)) {
  3673. redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
  3674. }
  3675. wksExt.f = function (name) {
  3676. return wrap(wks(name));
  3677. };
  3678. }
  3679. $export($export.G + $export.W + $export.F * !USE_NATIVE, {
  3680. Symbol: $Symbol
  3681. });
  3682. for (var es6Symbols = 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'.split(','), j = 0; es6Symbols.length > j;) {
  3683. wks(es6Symbols[j++]);
  3684. }
  3685. for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) {
  3686. wksDefine(wellKnownSymbols[k++]);
  3687. }
  3688. $export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
  3689. 'for': function _for(key) {
  3690. return has(SymbolRegistry, key += '') ? SymbolRegistry[key] : SymbolRegistry[key] = $Symbol(key);
  3691. },
  3692. keyFor: function keyFor(sym) {
  3693. if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
  3694. for (var key in SymbolRegistry) {
  3695. if (SymbolRegistry[key] === sym) return key;
  3696. }
  3697. },
  3698. useSetter: function useSetter() {
  3699. setter = true;
  3700. },
  3701. useSimple: function useSimple() {
  3702. setter = false;
  3703. }
  3704. });
  3705. $export($export.S + $export.F * !USE_NATIVE, 'Object', {
  3706. create: $create,
  3707. defineProperty: $defineProperty,
  3708. defineProperties: $defineProperties,
  3709. getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
  3710. getOwnPropertyNames: $getOwnPropertyNames,
  3711. getOwnPropertySymbols: $getOwnPropertySymbols
  3712. });
  3713. var FAILS_ON_PRIMITIVES = $fails(function () {
  3714. $GOPS.f(1);
  3715. });
  3716. $export($export.S + $export.F * FAILS_ON_PRIMITIVES, 'Object', {
  3717. getOwnPropertySymbols: function getOwnPropertySymbols(it) {
  3718. return $GOPS.f(toObject(it));
  3719. }
  3720. });
  3721. $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
  3722. var S = $Symbol();
  3723. return _stringify([S]) != '[null]' || _stringify({
  3724. a: S
  3725. }) != '{}' || _stringify(Object(S)) != '{}';
  3726. })), 'JSON', {
  3727. stringify: function stringify(it) {
  3728. var args = [it];
  3729. var i = 1;
  3730. var replacer, $replacer;
  3731. while (arguments.length > i) {
  3732. args.push(arguments[i++]);
  3733. }
  3734. $replacer = replacer = args[1];
  3735. if (!isObject(replacer) && it === undefined || isSymbol(it)) return;
  3736. if (!isArray(replacer)) replacer = function replacer(key, value) {
  3737. if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
  3738. if (!isSymbol(value)) return value;
  3739. };
  3740. args[1] = replacer;
  3741. return _stringify.apply($JSON, args);
  3742. }
  3743. });
  3744. $Symbol[PROTOTYPE][TO_PRIMITIVE] || __w_pdfjs_require__(10)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
  3745. setToStringTag($Symbol, 'Symbol');
  3746. setToStringTag(Math, 'Math', true);
  3747. setToStringTag(global.JSON, 'JSON', true);
  3748. /***/ }),
  3749. /* 129 */
  3750. /***/ (function(module, exports, __w_pdfjs_require__) {
  3751. "use strict";
  3752. exports.f = __w_pdfjs_require__(33);
  3753. /***/ }),
  3754. /* 130 */
  3755. /***/ (function(module, exports, __w_pdfjs_require__) {
  3756. "use strict";
  3757. var global = __w_pdfjs_require__(8);
  3758. var core = __w_pdfjs_require__(9);
  3759. var LIBRARY = __w_pdfjs_require__(25);
  3760. var wksExt = __w_pdfjs_require__(129);
  3761. var defineProperty = __w_pdfjs_require__(11).f;
  3762. module.exports = function (name) {
  3763. var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
  3764. if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, {
  3765. value: wksExt.f(name)
  3766. });
  3767. };
  3768. /***/ }),
  3769. /* 131 */
  3770. /***/ (function(module, exports, __w_pdfjs_require__) {
  3771. "use strict";
  3772. var getKeys = __w_pdfjs_require__(55);
  3773. var gOPS = __w_pdfjs_require__(73);
  3774. var pIE = __w_pdfjs_require__(74);
  3775. module.exports = function (it) {
  3776. var result = getKeys(it);
  3777. var getSymbols = gOPS.f;
  3778. if (getSymbols) {
  3779. var symbols = getSymbols(it);
  3780. var isEnum = pIE.f;
  3781. var i = 0;
  3782. var key;
  3783. while (symbols.length > i) {
  3784. if (isEnum.call(it, key = symbols[i++])) result.push(key);
  3785. }
  3786. }
  3787. return result;
  3788. };
  3789. /***/ }),
  3790. /* 132 */
  3791. /***/ (function(module, exports, __w_pdfjs_require__) {
  3792. "use strict";
  3793. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3794. var toIObject = __w_pdfjs_require__(43);
  3795. var gOPN = __w_pdfjs_require__(133).f;
  3796. var toString = {}.toString;
  3797. var windowNames = (typeof window === "undefined" ? "undefined" : _typeof(window)) == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : [];
  3798. var getWindowNames = function getWindowNames(it) {
  3799. try {
  3800. return gOPN(it);
  3801. } catch (e) {
  3802. return windowNames.slice();
  3803. }
  3804. };
  3805. module.exports.f = function getOwnPropertyNames(it) {
  3806. return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
  3807. };
  3808. /***/ }),
  3809. /* 133 */
  3810. /***/ (function(module, exports, __w_pdfjs_require__) {
  3811. "use strict";
  3812. var $keys = __w_pdfjs_require__(56);
  3813. var hiddenKeys = __w_pdfjs_require__(58).concat('length', 'prototype');
  3814. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  3815. return $keys(O, hiddenKeys);
  3816. };
  3817. /***/ }),
  3818. /* 134 */
  3819. /***/ (function(module, exports, __w_pdfjs_require__) {
  3820. "use strict";
  3821. __w_pdfjs_require__(135);
  3822. module.exports = __w_pdfjs_require__(9).String.padStart;
  3823. /***/ }),
  3824. /* 135 */
  3825. /***/ (function(module, exports, __w_pdfjs_require__) {
  3826. "use strict";
  3827. var $export = __w_pdfjs_require__(7);
  3828. var $pad = __w_pdfjs_require__(136);
  3829. var userAgent = __w_pdfjs_require__(96);
  3830. var WEBKIT_BUG = /Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(userAgent);
  3831. $export($export.P + $export.F * WEBKIT_BUG, 'String', {
  3832. padStart: function padStart(maxLength) {
  3833. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true);
  3834. }
  3835. });
  3836. /***/ }),
  3837. /* 136 */
  3838. /***/ (function(module, exports, __w_pdfjs_require__) {
  3839. "use strict";
  3840. var toLength = __w_pdfjs_require__(28);
  3841. var repeat = __w_pdfjs_require__(137);
  3842. var defined = __w_pdfjs_require__(34);
  3843. module.exports = function (that, maxLength, fillString, left) {
  3844. var S = String(defined(that));
  3845. var stringLength = S.length;
  3846. var fillStr = fillString === undefined ? ' ' : String(fillString);
  3847. var intMaxLength = toLength(maxLength);
  3848. if (intMaxLength <= stringLength || fillStr == '') return S;
  3849. var fillLen = intMaxLength - stringLength;
  3850. var stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));
  3851. if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen);
  3852. return left ? stringFiller + S : S + stringFiller;
  3853. };
  3854. /***/ }),
  3855. /* 137 */
  3856. /***/ (function(module, exports, __w_pdfjs_require__) {
  3857. "use strict";
  3858. var toInteger = __w_pdfjs_require__(29);
  3859. var defined = __w_pdfjs_require__(34);
  3860. module.exports = function repeat(count) {
  3861. var str = String(defined(this));
  3862. var res = '';
  3863. var n = toInteger(count);
  3864. if (n < 0 || n == Infinity) throw RangeError("Count can't be negative");
  3865. for (; n > 0; (n >>>= 1) && (str += str)) {
  3866. if (n & 1) res += str;
  3867. }
  3868. return res;
  3869. };
  3870. /***/ }),
  3871. /* 138 */
  3872. /***/ (function(module, exports, __w_pdfjs_require__) {
  3873. "use strict";
  3874. __w_pdfjs_require__(139);
  3875. module.exports = __w_pdfjs_require__(9).String.padEnd;
  3876. /***/ }),
  3877. /* 139 */
  3878. /***/ (function(module, exports, __w_pdfjs_require__) {
  3879. "use strict";
  3880. var $export = __w_pdfjs_require__(7);
  3881. var $pad = __w_pdfjs_require__(136);
  3882. var userAgent = __w_pdfjs_require__(96);
  3883. var WEBKIT_BUG = /Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(userAgent);
  3884. $export($export.P + $export.F * WEBKIT_BUG, 'String', {
  3885. padEnd: function padEnd(maxLength) {
  3886. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false);
  3887. }
  3888. });
  3889. /***/ }),
  3890. /* 140 */
  3891. /***/ (function(module, exports, __w_pdfjs_require__) {
  3892. "use strict";
  3893. __w_pdfjs_require__(141);
  3894. module.exports = __w_pdfjs_require__(9).Object.values;
  3895. /***/ }),
  3896. /* 141 */
  3897. /***/ (function(module, exports, __w_pdfjs_require__) {
  3898. "use strict";
  3899. var $export = __w_pdfjs_require__(7);
  3900. var $values = __w_pdfjs_require__(142)(false);
  3901. $export($export.S, 'Object', {
  3902. values: function values(it) {
  3903. return $values(it);
  3904. }
  3905. });
  3906. /***/ }),
  3907. /* 142 */
  3908. /***/ (function(module, exports, __w_pdfjs_require__) {
  3909. "use strict";
  3910. var DESCRIPTORS = __w_pdfjs_require__(15);
  3911. var getKeys = __w_pdfjs_require__(55);
  3912. var toIObject = __w_pdfjs_require__(43);
  3913. var isEnum = __w_pdfjs_require__(74).f;
  3914. module.exports = function (isEntries) {
  3915. return function (it) {
  3916. var O = toIObject(it);
  3917. var keys = getKeys(O);
  3918. var length = keys.length;
  3919. var i = 0;
  3920. var result = [];
  3921. var key;
  3922. while (length > i) {
  3923. key = keys[i++];
  3924. if (!DESCRIPTORS || isEnum.call(O, key)) {
  3925. result.push(isEntries ? [key, O[key]] : O[key]);
  3926. }
  3927. }
  3928. return result;
  3929. };
  3930. };
  3931. /***/ }),
  3932. /* 143 */
  3933. /***/ (function(module, exports, __w_pdfjs_require__) {
  3934. "use strict";
  3935. {
  3936. var isReadableStreamSupported = false;
  3937. if (typeof ReadableStream !== 'undefined') {
  3938. try {
  3939. new ReadableStream({
  3940. start: function start(controller) {
  3941. controller.close();
  3942. }
  3943. });
  3944. isReadableStreamSupported = true;
  3945. } catch (e) {}
  3946. }
  3947. if (isReadableStreamSupported) {
  3948. exports.ReadableStream = ReadableStream;
  3949. } else {
  3950. exports.ReadableStream = __w_pdfjs_require__(144).ReadableStream;
  3951. }
  3952. }
  3953. /***/ }),
  3954. /* 144 */
  3955. /***/ (function(module, exports, __w_pdfjs_require__) {
  3956. "use strict";
  3957. function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); }
  3958. (function (e, a) {
  3959. for (var i in a) {
  3960. e[i] = a[i];
  3961. }
  3962. })(exports, function (modules) {
  3963. var installedModules = {};
  3964. function __w_pdfjs_require__(moduleId) {
  3965. if (installedModules[moduleId]) return installedModules[moduleId].exports;
  3966. var module = installedModules[moduleId] = {
  3967. i: moduleId,
  3968. l: false,
  3969. exports: {}
  3970. };
  3971. modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  3972. module.l = true;
  3973. return module.exports;
  3974. }
  3975. __w_pdfjs_require__.m = modules;
  3976. __w_pdfjs_require__.c = installedModules;
  3977. __w_pdfjs_require__.i = function (value) {
  3978. return value;
  3979. };
  3980. __w_pdfjs_require__.d = function (exports, name, getter) {
  3981. if (!__w_pdfjs_require__.o(exports, name)) {
  3982. Object.defineProperty(exports, name, {
  3983. configurable: false,
  3984. enumerable: true,
  3985. get: getter
  3986. });
  3987. }
  3988. };
  3989. __w_pdfjs_require__.n = function (module) {
  3990. var getter = module && module.__esModule ? function getDefault() {
  3991. return module['default'];
  3992. } : function getModuleExports() {
  3993. return module;
  3994. };
  3995. __w_pdfjs_require__.d(getter, 'a', getter);
  3996. return getter;
  3997. };
  3998. __w_pdfjs_require__.o = function (object, property) {
  3999. return Object.prototype.hasOwnProperty.call(object, property);
  4000. };
  4001. __w_pdfjs_require__.p = "";
  4002. return __w_pdfjs_require__(__w_pdfjs_require__.s = 7);
  4003. }([function (module, exports, __w_pdfjs_require__) {
  4004. "use strict";
  4005. var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
  4006. return _typeof2(obj);
  4007. } : function (obj) {
  4008. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
  4009. };
  4010. var _require = __w_pdfjs_require__(1),
  4011. assert = _require.assert;
  4012. function IsPropertyKey(argument) {
  4013. return typeof argument === 'string' || (typeof argument === 'undefined' ? 'undefined' : _typeof(argument)) === 'symbol';
  4014. }
  4015. exports.typeIsObject = function (x) {
  4016. return (typeof x === 'undefined' ? 'undefined' : _typeof(x)) === 'object' && x !== null || typeof x === 'function';
  4017. };
  4018. exports.createDataProperty = function (o, p, v) {
  4019. assert(exports.typeIsObject(o));
  4020. Object.defineProperty(o, p, {
  4021. value: v,
  4022. writable: true,
  4023. enumerable: true,
  4024. configurable: true
  4025. });
  4026. };
  4027. exports.createArrayFromList = function (elements) {
  4028. return elements.slice();
  4029. };
  4030. exports.ArrayBufferCopy = function (dest, destOffset, src, srcOffset, n) {
  4031. new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
  4032. };
  4033. exports.CreateIterResultObject = function (value, done) {
  4034. assert(typeof done === 'boolean');
  4035. var obj = {};
  4036. Object.defineProperty(obj, 'value', {
  4037. value: value,
  4038. enumerable: true,
  4039. writable: true,
  4040. configurable: true
  4041. });
  4042. Object.defineProperty(obj, 'done', {
  4043. value: done,
  4044. enumerable: true,
  4045. writable: true,
  4046. configurable: true
  4047. });
  4048. return obj;
  4049. };
  4050. exports.IsFiniteNonNegativeNumber = function (v) {
  4051. if (Number.isNaN(v)) {
  4052. return false;
  4053. }
  4054. if (v === Infinity) {
  4055. return false;
  4056. }
  4057. if (v < 0) {
  4058. return false;
  4059. }
  4060. return true;
  4061. };
  4062. function Call(F, V, args) {
  4063. if (typeof F !== 'function') {
  4064. throw new TypeError('Argument is not a function');
  4065. }
  4066. return Function.prototype.apply.call(F, V, args);
  4067. }
  4068. exports.InvokeOrNoop = function (O, P, args) {
  4069. assert(O !== undefined);
  4070. assert(IsPropertyKey(P));
  4071. assert(Array.isArray(args));
  4072. var method = O[P];
  4073. if (method === undefined) {
  4074. return undefined;
  4075. }
  4076. return Call(method, O, args);
  4077. };
  4078. exports.PromiseInvokeOrNoop = function (O, P, args) {
  4079. assert(O !== undefined);
  4080. assert(IsPropertyKey(P));
  4081. assert(Array.isArray(args));
  4082. try {
  4083. return Promise.resolve(exports.InvokeOrNoop(O, P, args));
  4084. } catch (returnValueE) {
  4085. return Promise.reject(returnValueE);
  4086. }
  4087. };
  4088. exports.PromiseInvokeOrPerformFallback = function (O, P, args, F, argsF) {
  4089. assert(O !== undefined);
  4090. assert(IsPropertyKey(P));
  4091. assert(Array.isArray(args));
  4092. assert(Array.isArray(argsF));
  4093. var method = void 0;
  4094. try {
  4095. method = O[P];
  4096. } catch (methodE) {
  4097. return Promise.reject(methodE);
  4098. }
  4099. if (method === undefined) {
  4100. return F.apply(null, argsF);
  4101. }
  4102. try {
  4103. return Promise.resolve(Call(method, O, args));
  4104. } catch (e) {
  4105. return Promise.reject(e);
  4106. }
  4107. };
  4108. exports.TransferArrayBuffer = function (O) {
  4109. return O.slice();
  4110. };
  4111. exports.ValidateAndNormalizeHighWaterMark = function (highWaterMark) {
  4112. highWaterMark = Number(highWaterMark);
  4113. if (Number.isNaN(highWaterMark) || highWaterMark < 0) {
  4114. throw new RangeError('highWaterMark property of a queuing strategy must be non-negative and non-NaN');
  4115. }
  4116. return highWaterMark;
  4117. };
  4118. exports.ValidateAndNormalizeQueuingStrategy = function (size, highWaterMark) {
  4119. if (size !== undefined && typeof size !== 'function') {
  4120. throw new TypeError('size property of a queuing strategy must be a function');
  4121. }
  4122. highWaterMark = exports.ValidateAndNormalizeHighWaterMark(highWaterMark);
  4123. return {
  4124. size: size,
  4125. highWaterMark: highWaterMark
  4126. };
  4127. };
  4128. }, function (module, exports, __w_pdfjs_require__) {
  4129. "use strict";
  4130. function rethrowAssertionErrorRejection(e) {
  4131. if (e && e.constructor === AssertionError) {
  4132. setTimeout(function () {
  4133. throw e;
  4134. }, 0);
  4135. }
  4136. }
  4137. function AssertionError(message) {
  4138. this.name = 'AssertionError';
  4139. this.message = message || '';
  4140. this.stack = new Error().stack;
  4141. }
  4142. AssertionError.prototype = Object.create(Error.prototype);
  4143. AssertionError.prototype.constructor = AssertionError;
  4144. function assert(value, message) {
  4145. if (!value) {
  4146. throw new AssertionError(message);
  4147. }
  4148. }
  4149. module.exports = {
  4150. rethrowAssertionErrorRejection: rethrowAssertionErrorRejection,
  4151. AssertionError: AssertionError,
  4152. assert: assert
  4153. };
  4154. }, function (module, exports, __w_pdfjs_require__) {
  4155. "use strict";
  4156. var _createClass = function () {
  4157. function defineProperties(target, props) {
  4158. for (var i = 0; i < props.length; i++) {
  4159. var descriptor = props[i];
  4160. descriptor.enumerable = descriptor.enumerable || false;
  4161. descriptor.configurable = true;
  4162. if ("value" in descriptor) descriptor.writable = true;
  4163. Object.defineProperty(target, descriptor.key, descriptor);
  4164. }
  4165. }
  4166. return function (Constructor, protoProps, staticProps) {
  4167. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  4168. if (staticProps) defineProperties(Constructor, staticProps);
  4169. return Constructor;
  4170. };
  4171. }();
  4172. function _classCallCheck(instance, Constructor) {
  4173. if (!(instance instanceof Constructor)) {
  4174. throw new TypeError("Cannot call a class as a function");
  4175. }
  4176. }
  4177. var _require = __w_pdfjs_require__(0),
  4178. InvokeOrNoop = _require.InvokeOrNoop,
  4179. PromiseInvokeOrNoop = _require.PromiseInvokeOrNoop,
  4180. ValidateAndNormalizeQueuingStrategy = _require.ValidateAndNormalizeQueuingStrategy,
  4181. typeIsObject = _require.typeIsObject;
  4182. var _require2 = __w_pdfjs_require__(1),
  4183. assert = _require2.assert,
  4184. rethrowAssertionErrorRejection = _require2.rethrowAssertionErrorRejection;
  4185. var _require3 = __w_pdfjs_require__(3),
  4186. DequeueValue = _require3.DequeueValue,
  4187. EnqueueValueWithSize = _require3.EnqueueValueWithSize,
  4188. PeekQueueValue = _require3.PeekQueueValue,
  4189. ResetQueue = _require3.ResetQueue;
  4190. var WritableStream = function () {
  4191. function WritableStream() {
  4192. var underlyingSink = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4193. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  4194. size = _ref.size,
  4195. _ref$highWaterMark = _ref.highWaterMark,
  4196. highWaterMark = _ref$highWaterMark === undefined ? 1 : _ref$highWaterMark;
  4197. _classCallCheck(this, WritableStream);
  4198. this._state = 'writable';
  4199. this._storedError = undefined;
  4200. this._writer = undefined;
  4201. this._writableStreamController = undefined;
  4202. this._writeRequests = [];
  4203. this._inFlightWriteRequest = undefined;
  4204. this._closeRequest = undefined;
  4205. this._inFlightCloseRequest = undefined;
  4206. this._pendingAbortRequest = undefined;
  4207. this._backpressure = false;
  4208. var type = underlyingSink.type;
  4209. if (type !== undefined) {
  4210. throw new RangeError('Invalid type is specified');
  4211. }
  4212. this._writableStreamController = new WritableStreamDefaultController(this, underlyingSink, size, highWaterMark);
  4213. this._writableStreamController.__startSteps();
  4214. }
  4215. _createClass(WritableStream, [{
  4216. key: 'abort',
  4217. value: function abort(reason) {
  4218. if (IsWritableStream(this) === false) {
  4219. return Promise.reject(streamBrandCheckException('abort'));
  4220. }
  4221. if (IsWritableStreamLocked(this) === true) {
  4222. return Promise.reject(new TypeError('Cannot abort a stream that already has a writer'));
  4223. }
  4224. return WritableStreamAbort(this, reason);
  4225. }
  4226. }, {
  4227. key: 'getWriter',
  4228. value: function getWriter() {
  4229. if (IsWritableStream(this) === false) {
  4230. throw streamBrandCheckException('getWriter');
  4231. }
  4232. return AcquireWritableStreamDefaultWriter(this);
  4233. }
  4234. }, {
  4235. key: 'locked',
  4236. get: function get() {
  4237. if (IsWritableStream(this) === false) {
  4238. throw streamBrandCheckException('locked');
  4239. }
  4240. return IsWritableStreamLocked(this);
  4241. }
  4242. }]);
  4243. return WritableStream;
  4244. }();
  4245. module.exports = {
  4246. AcquireWritableStreamDefaultWriter: AcquireWritableStreamDefaultWriter,
  4247. IsWritableStream: IsWritableStream,
  4248. IsWritableStreamLocked: IsWritableStreamLocked,
  4249. WritableStream: WritableStream,
  4250. WritableStreamAbort: WritableStreamAbort,
  4251. WritableStreamDefaultControllerError: WritableStreamDefaultControllerError,
  4252. WritableStreamDefaultWriterCloseWithErrorPropagation: WritableStreamDefaultWriterCloseWithErrorPropagation,
  4253. WritableStreamDefaultWriterRelease: WritableStreamDefaultWriterRelease,
  4254. WritableStreamDefaultWriterWrite: WritableStreamDefaultWriterWrite,
  4255. WritableStreamCloseQueuedOrInFlight: WritableStreamCloseQueuedOrInFlight
  4256. };
  4257. function AcquireWritableStreamDefaultWriter(stream) {
  4258. return new WritableStreamDefaultWriter(stream);
  4259. }
  4260. function IsWritableStream(x) {
  4261. if (!typeIsObject(x)) {
  4262. return false;
  4263. }
  4264. if (!Object.prototype.hasOwnProperty.call(x, '_writableStreamController')) {
  4265. return false;
  4266. }
  4267. return true;
  4268. }
  4269. function IsWritableStreamLocked(stream) {
  4270. assert(IsWritableStream(stream) === true, 'IsWritableStreamLocked should only be used on known writable streams');
  4271. if (stream._writer === undefined) {
  4272. return false;
  4273. }
  4274. return true;
  4275. }
  4276. function WritableStreamAbort(stream, reason) {
  4277. var state = stream._state;
  4278. if (state === 'closed') {
  4279. return Promise.resolve(undefined);
  4280. }
  4281. if (state === 'errored') {
  4282. return Promise.reject(stream._storedError);
  4283. }
  4284. var error = new TypeError('Requested to abort');
  4285. if (stream._pendingAbortRequest !== undefined) {
  4286. return Promise.reject(error);
  4287. }
  4288. assert(state === 'writable' || state === 'erroring', 'state must be writable or erroring');
  4289. var wasAlreadyErroring = false;
  4290. if (state === 'erroring') {
  4291. wasAlreadyErroring = true;
  4292. reason = undefined;
  4293. }
  4294. var promise = new Promise(function (resolve, reject) {
  4295. stream._pendingAbortRequest = {
  4296. _resolve: resolve,
  4297. _reject: reject,
  4298. _reason: reason,
  4299. _wasAlreadyErroring: wasAlreadyErroring
  4300. };
  4301. });
  4302. if (wasAlreadyErroring === false) {
  4303. WritableStreamStartErroring(stream, error);
  4304. }
  4305. return promise;
  4306. }
  4307. function WritableStreamAddWriteRequest(stream) {
  4308. assert(IsWritableStreamLocked(stream) === true);
  4309. assert(stream._state === 'writable');
  4310. var promise = new Promise(function (resolve, reject) {
  4311. var writeRequest = {
  4312. _resolve: resolve,
  4313. _reject: reject
  4314. };
  4315. stream._writeRequests.push(writeRequest);
  4316. });
  4317. return promise;
  4318. }
  4319. function WritableStreamDealWithRejection(stream, error) {
  4320. var state = stream._state;
  4321. if (state === 'writable') {
  4322. WritableStreamStartErroring(stream, error);
  4323. return;
  4324. }
  4325. assert(state === 'erroring');
  4326. WritableStreamFinishErroring(stream);
  4327. }
  4328. function WritableStreamStartErroring(stream, reason) {
  4329. assert(stream._storedError === undefined, 'stream._storedError === undefined');
  4330. assert(stream._state === 'writable', 'state must be writable');
  4331. var controller = stream._writableStreamController;
  4332. assert(controller !== undefined, 'controller must not be undefined');
  4333. stream._state = 'erroring';
  4334. stream._storedError = reason;
  4335. var writer = stream._writer;
  4336. if (writer !== undefined) {
  4337. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, reason);
  4338. }
  4339. if (WritableStreamHasOperationMarkedInFlight(stream) === false && controller._started === true) {
  4340. WritableStreamFinishErroring(stream);
  4341. }
  4342. }
  4343. function WritableStreamFinishErroring(stream) {
  4344. assert(stream._state === 'erroring', 'stream._state === erroring');
  4345. assert(WritableStreamHasOperationMarkedInFlight(stream) === false, 'WritableStreamHasOperationMarkedInFlight(stream) === false');
  4346. stream._state = 'errored';
  4347. stream._writableStreamController.__errorSteps();
  4348. var storedError = stream._storedError;
  4349. for (var i = 0; i < stream._writeRequests.length; i++) {
  4350. var writeRequest = stream._writeRequests[i];
  4351. writeRequest._reject(storedError);
  4352. }
  4353. stream._writeRequests = [];
  4354. if (stream._pendingAbortRequest === undefined) {
  4355. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  4356. return;
  4357. }
  4358. var abortRequest = stream._pendingAbortRequest;
  4359. stream._pendingAbortRequest = undefined;
  4360. if (abortRequest._wasAlreadyErroring === true) {
  4361. abortRequest._reject(storedError);
  4362. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  4363. return;
  4364. }
  4365. var promise = stream._writableStreamController.__abortSteps(abortRequest._reason);
  4366. promise.then(function () {
  4367. abortRequest._resolve();
  4368. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  4369. }, function (reason) {
  4370. abortRequest._reject(reason);
  4371. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  4372. });
  4373. }
  4374. function WritableStreamFinishInFlightWrite(stream) {
  4375. assert(stream._inFlightWriteRequest !== undefined);
  4376. stream._inFlightWriteRequest._resolve(undefined);
  4377. stream._inFlightWriteRequest = undefined;
  4378. }
  4379. function WritableStreamFinishInFlightWriteWithError(stream, error) {
  4380. assert(stream._inFlightWriteRequest !== undefined);
  4381. stream._inFlightWriteRequest._reject(error);
  4382. stream._inFlightWriteRequest = undefined;
  4383. assert(stream._state === 'writable' || stream._state === 'erroring');
  4384. WritableStreamDealWithRejection(stream, error);
  4385. }
  4386. function WritableStreamFinishInFlightClose(stream) {
  4387. assert(stream._inFlightCloseRequest !== undefined);
  4388. stream._inFlightCloseRequest._resolve(undefined);
  4389. stream._inFlightCloseRequest = undefined;
  4390. var state = stream._state;
  4391. assert(state === 'writable' || state === 'erroring');
  4392. if (state === 'erroring') {
  4393. stream._storedError = undefined;
  4394. if (stream._pendingAbortRequest !== undefined) {
  4395. stream._pendingAbortRequest._resolve();
  4396. stream._pendingAbortRequest = undefined;
  4397. }
  4398. }
  4399. stream._state = 'closed';
  4400. var writer = stream._writer;
  4401. if (writer !== undefined) {
  4402. defaultWriterClosedPromiseResolve(writer);
  4403. }
  4404. assert(stream._pendingAbortRequest === undefined, 'stream._pendingAbortRequest === undefined');
  4405. assert(stream._storedError === undefined, 'stream._storedError === undefined');
  4406. }
  4407. function WritableStreamFinishInFlightCloseWithError(stream, error) {
  4408. assert(stream._inFlightCloseRequest !== undefined);
  4409. stream._inFlightCloseRequest._reject(error);
  4410. stream._inFlightCloseRequest = undefined;
  4411. assert(stream._state === 'writable' || stream._state === 'erroring');
  4412. if (stream._pendingAbortRequest !== undefined) {
  4413. stream._pendingAbortRequest._reject(error);
  4414. stream._pendingAbortRequest = undefined;
  4415. }
  4416. WritableStreamDealWithRejection(stream, error);
  4417. }
  4418. function WritableStreamCloseQueuedOrInFlight(stream) {
  4419. if (stream._closeRequest === undefined && stream._inFlightCloseRequest === undefined) {
  4420. return false;
  4421. }
  4422. return true;
  4423. }
  4424. function WritableStreamHasOperationMarkedInFlight(stream) {
  4425. if (stream._inFlightWriteRequest === undefined && stream._inFlightCloseRequest === undefined) {
  4426. return false;
  4427. }
  4428. return true;
  4429. }
  4430. function WritableStreamMarkCloseRequestInFlight(stream) {
  4431. assert(stream._inFlightCloseRequest === undefined);
  4432. assert(stream._closeRequest !== undefined);
  4433. stream._inFlightCloseRequest = stream._closeRequest;
  4434. stream._closeRequest = undefined;
  4435. }
  4436. function WritableStreamMarkFirstWriteRequestInFlight(stream) {
  4437. assert(stream._inFlightWriteRequest === undefined, 'there must be no pending write request');
  4438. assert(stream._writeRequests.length !== 0, 'writeRequests must not be empty');
  4439. stream._inFlightWriteRequest = stream._writeRequests.shift();
  4440. }
  4441. function WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream) {
  4442. assert(stream._state === 'errored', '_stream_.[[state]] is `"errored"`');
  4443. if (stream._closeRequest !== undefined) {
  4444. assert(stream._inFlightCloseRequest === undefined);
  4445. stream._closeRequest._reject(stream._storedError);
  4446. stream._closeRequest = undefined;
  4447. }
  4448. var writer = stream._writer;
  4449. if (writer !== undefined) {
  4450. defaultWriterClosedPromiseReject(writer, stream._storedError);
  4451. writer._closedPromise["catch"](function () {});
  4452. }
  4453. }
  4454. function WritableStreamUpdateBackpressure(stream, backpressure) {
  4455. assert(stream._state === 'writable');
  4456. assert(WritableStreamCloseQueuedOrInFlight(stream) === false);
  4457. var writer = stream._writer;
  4458. if (writer !== undefined && backpressure !== stream._backpressure) {
  4459. if (backpressure === true) {
  4460. defaultWriterReadyPromiseReset(writer);
  4461. } else {
  4462. assert(backpressure === false);
  4463. defaultWriterReadyPromiseResolve(writer);
  4464. }
  4465. }
  4466. stream._backpressure = backpressure;
  4467. }
  4468. var WritableStreamDefaultWriter = function () {
  4469. function WritableStreamDefaultWriter(stream) {
  4470. _classCallCheck(this, WritableStreamDefaultWriter);
  4471. if (IsWritableStream(stream) === false) {
  4472. throw new TypeError('WritableStreamDefaultWriter can only be constructed with a WritableStream instance');
  4473. }
  4474. if (IsWritableStreamLocked(stream) === true) {
  4475. throw new TypeError('This stream has already been locked for exclusive writing by another writer');
  4476. }
  4477. this._ownerWritableStream = stream;
  4478. stream._writer = this;
  4479. var state = stream._state;
  4480. if (state === 'writable') {
  4481. if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._backpressure === true) {
  4482. defaultWriterReadyPromiseInitialize(this);
  4483. } else {
  4484. defaultWriterReadyPromiseInitializeAsResolved(this);
  4485. }
  4486. defaultWriterClosedPromiseInitialize(this);
  4487. } else if (state === 'erroring') {
  4488. defaultWriterReadyPromiseInitializeAsRejected(this, stream._storedError);
  4489. this._readyPromise["catch"](function () {});
  4490. defaultWriterClosedPromiseInitialize(this);
  4491. } else if (state === 'closed') {
  4492. defaultWriterReadyPromiseInitializeAsResolved(this);
  4493. defaultWriterClosedPromiseInitializeAsResolved(this);
  4494. } else {
  4495. assert(state === 'errored', 'state must be errored');
  4496. var storedError = stream._storedError;
  4497. defaultWriterReadyPromiseInitializeAsRejected(this, storedError);
  4498. this._readyPromise["catch"](function () {});
  4499. defaultWriterClosedPromiseInitializeAsRejected(this, storedError);
  4500. this._closedPromise["catch"](function () {});
  4501. }
  4502. }
  4503. _createClass(WritableStreamDefaultWriter, [{
  4504. key: 'abort',
  4505. value: function abort(reason) {
  4506. if (IsWritableStreamDefaultWriter(this) === false) {
  4507. return Promise.reject(defaultWriterBrandCheckException('abort'));
  4508. }
  4509. if (this._ownerWritableStream === undefined) {
  4510. return Promise.reject(defaultWriterLockException('abort'));
  4511. }
  4512. return WritableStreamDefaultWriterAbort(this, reason);
  4513. }
  4514. }, {
  4515. key: 'close',
  4516. value: function close() {
  4517. if (IsWritableStreamDefaultWriter(this) === false) {
  4518. return Promise.reject(defaultWriterBrandCheckException('close'));
  4519. }
  4520. var stream = this._ownerWritableStream;
  4521. if (stream === undefined) {
  4522. return Promise.reject(defaultWriterLockException('close'));
  4523. }
  4524. if (WritableStreamCloseQueuedOrInFlight(stream) === true) {
  4525. return Promise.reject(new TypeError('cannot close an already-closing stream'));
  4526. }
  4527. return WritableStreamDefaultWriterClose(this);
  4528. }
  4529. }, {
  4530. key: 'releaseLock',
  4531. value: function releaseLock() {
  4532. if (IsWritableStreamDefaultWriter(this) === false) {
  4533. throw defaultWriterBrandCheckException('releaseLock');
  4534. }
  4535. var stream = this._ownerWritableStream;
  4536. if (stream === undefined) {
  4537. return;
  4538. }
  4539. assert(stream._writer !== undefined);
  4540. WritableStreamDefaultWriterRelease(this);
  4541. }
  4542. }, {
  4543. key: 'write',
  4544. value: function write(chunk) {
  4545. if (IsWritableStreamDefaultWriter(this) === false) {
  4546. return Promise.reject(defaultWriterBrandCheckException('write'));
  4547. }
  4548. if (this._ownerWritableStream === undefined) {
  4549. return Promise.reject(defaultWriterLockException('write to'));
  4550. }
  4551. return WritableStreamDefaultWriterWrite(this, chunk);
  4552. }
  4553. }, {
  4554. key: 'closed',
  4555. get: function get() {
  4556. if (IsWritableStreamDefaultWriter(this) === false) {
  4557. return Promise.reject(defaultWriterBrandCheckException('closed'));
  4558. }
  4559. return this._closedPromise;
  4560. }
  4561. }, {
  4562. key: 'desiredSize',
  4563. get: function get() {
  4564. if (IsWritableStreamDefaultWriter(this) === false) {
  4565. throw defaultWriterBrandCheckException('desiredSize');
  4566. }
  4567. if (this._ownerWritableStream === undefined) {
  4568. throw defaultWriterLockException('desiredSize');
  4569. }
  4570. return WritableStreamDefaultWriterGetDesiredSize(this);
  4571. }
  4572. }, {
  4573. key: 'ready',
  4574. get: function get() {
  4575. if (IsWritableStreamDefaultWriter(this) === false) {
  4576. return Promise.reject(defaultWriterBrandCheckException('ready'));
  4577. }
  4578. return this._readyPromise;
  4579. }
  4580. }]);
  4581. return WritableStreamDefaultWriter;
  4582. }();
  4583. function IsWritableStreamDefaultWriter(x) {
  4584. if (!typeIsObject(x)) {
  4585. return false;
  4586. }
  4587. if (!Object.prototype.hasOwnProperty.call(x, '_ownerWritableStream')) {
  4588. return false;
  4589. }
  4590. return true;
  4591. }
  4592. function WritableStreamDefaultWriterAbort(writer, reason) {
  4593. var stream = writer._ownerWritableStream;
  4594. assert(stream !== undefined);
  4595. return WritableStreamAbort(stream, reason);
  4596. }
  4597. function WritableStreamDefaultWriterClose(writer) {
  4598. var stream = writer._ownerWritableStream;
  4599. assert(stream !== undefined);
  4600. var state = stream._state;
  4601. if (state === 'closed' || state === 'errored') {
  4602. return Promise.reject(new TypeError('The stream (in ' + state + ' state) is not in the writable state and cannot be closed'));
  4603. }
  4604. assert(state === 'writable' || state === 'erroring');
  4605. assert(WritableStreamCloseQueuedOrInFlight(stream) === false);
  4606. var promise = new Promise(function (resolve, reject) {
  4607. var closeRequest = {
  4608. _resolve: resolve,
  4609. _reject: reject
  4610. };
  4611. stream._closeRequest = closeRequest;
  4612. });
  4613. if (stream._backpressure === true && state === 'writable') {
  4614. defaultWriterReadyPromiseResolve(writer);
  4615. }
  4616. WritableStreamDefaultControllerClose(stream._writableStreamController);
  4617. return promise;
  4618. }
  4619. function WritableStreamDefaultWriterCloseWithErrorPropagation(writer) {
  4620. var stream = writer._ownerWritableStream;
  4621. assert(stream !== undefined);
  4622. var state = stream._state;
  4623. if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') {
  4624. return Promise.resolve();
  4625. }
  4626. if (state === 'errored') {
  4627. return Promise.reject(stream._storedError);
  4628. }
  4629. assert(state === 'writable' || state === 'erroring');
  4630. return WritableStreamDefaultWriterClose(writer);
  4631. }
  4632. function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error) {
  4633. if (writer._closedPromiseState === 'pending') {
  4634. defaultWriterClosedPromiseReject(writer, error);
  4635. } else {
  4636. defaultWriterClosedPromiseResetToRejected(writer, error);
  4637. }
  4638. writer._closedPromise["catch"](function () {});
  4639. }
  4640. function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error) {
  4641. if (writer._readyPromiseState === 'pending') {
  4642. defaultWriterReadyPromiseReject(writer, error);
  4643. } else {
  4644. defaultWriterReadyPromiseResetToRejected(writer, error);
  4645. }
  4646. writer._readyPromise["catch"](function () {});
  4647. }
  4648. function WritableStreamDefaultWriterGetDesiredSize(writer) {
  4649. var stream = writer._ownerWritableStream;
  4650. var state = stream._state;
  4651. if (state === 'errored' || state === 'erroring') {
  4652. return null;
  4653. }
  4654. if (state === 'closed') {
  4655. return 0;
  4656. }
  4657. return WritableStreamDefaultControllerGetDesiredSize(stream._writableStreamController);
  4658. }
  4659. function WritableStreamDefaultWriterRelease(writer) {
  4660. var stream = writer._ownerWritableStream;
  4661. assert(stream !== undefined);
  4662. assert(stream._writer === writer);
  4663. var releasedError = new TypeError('Writer was released and can no longer be used to monitor the stream\'s closedness');
  4664. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, releasedError);
  4665. WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, releasedError);
  4666. stream._writer = undefined;
  4667. writer._ownerWritableStream = undefined;
  4668. }
  4669. function WritableStreamDefaultWriterWrite(writer, chunk) {
  4670. var stream = writer._ownerWritableStream;
  4671. assert(stream !== undefined);
  4672. var controller = stream._writableStreamController;
  4673. var chunkSize = WritableStreamDefaultControllerGetChunkSize(controller, chunk);
  4674. if (stream !== writer._ownerWritableStream) {
  4675. return Promise.reject(defaultWriterLockException('write to'));
  4676. }
  4677. var state = stream._state;
  4678. if (state === 'errored') {
  4679. return Promise.reject(stream._storedError);
  4680. }
  4681. if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') {
  4682. return Promise.reject(new TypeError('The stream is closing or closed and cannot be written to'));
  4683. }
  4684. if (state === 'erroring') {
  4685. return Promise.reject(stream._storedError);
  4686. }
  4687. assert(state === 'writable');
  4688. var promise = WritableStreamAddWriteRequest(stream);
  4689. WritableStreamDefaultControllerWrite(controller, chunk, chunkSize);
  4690. return promise;
  4691. }
  4692. var WritableStreamDefaultController = function () {
  4693. function WritableStreamDefaultController(stream, underlyingSink, size, highWaterMark) {
  4694. _classCallCheck(this, WritableStreamDefaultController);
  4695. if (IsWritableStream(stream) === false) {
  4696. throw new TypeError('WritableStreamDefaultController can only be constructed with a WritableStream instance');
  4697. }
  4698. if (stream._writableStreamController !== undefined) {
  4699. throw new TypeError('WritableStreamDefaultController instances can only be created by the WritableStream constructor');
  4700. }
  4701. this._controlledWritableStream = stream;
  4702. this._underlyingSink = underlyingSink;
  4703. this._queue = undefined;
  4704. this._queueTotalSize = undefined;
  4705. ResetQueue(this);
  4706. this._started = false;
  4707. var normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark);
  4708. this._strategySize = normalizedStrategy.size;
  4709. this._strategyHWM = normalizedStrategy.highWaterMark;
  4710. var backpressure = WritableStreamDefaultControllerGetBackpressure(this);
  4711. WritableStreamUpdateBackpressure(stream, backpressure);
  4712. }
  4713. _createClass(WritableStreamDefaultController, [{
  4714. key: 'error',
  4715. value: function error(e) {
  4716. if (IsWritableStreamDefaultController(this) === false) {
  4717. throw new TypeError('WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController');
  4718. }
  4719. var state = this._controlledWritableStream._state;
  4720. if (state !== 'writable') {
  4721. return;
  4722. }
  4723. WritableStreamDefaultControllerError(this, e);
  4724. }
  4725. }, {
  4726. key: '__abortSteps',
  4727. value: function __abortSteps(reason) {
  4728. return PromiseInvokeOrNoop(this._underlyingSink, 'abort', [reason]);
  4729. }
  4730. }, {
  4731. key: '__errorSteps',
  4732. value: function __errorSteps() {
  4733. ResetQueue(this);
  4734. }
  4735. }, {
  4736. key: '__startSteps',
  4737. value: function __startSteps() {
  4738. var _this = this;
  4739. var startResult = InvokeOrNoop(this._underlyingSink, 'start', [this]);
  4740. var stream = this._controlledWritableStream;
  4741. Promise.resolve(startResult).then(function () {
  4742. assert(stream._state === 'writable' || stream._state === 'erroring');
  4743. _this._started = true;
  4744. WritableStreamDefaultControllerAdvanceQueueIfNeeded(_this);
  4745. }, function (r) {
  4746. assert(stream._state === 'writable' || stream._state === 'erroring');
  4747. _this._started = true;
  4748. WritableStreamDealWithRejection(stream, r);
  4749. })["catch"](rethrowAssertionErrorRejection);
  4750. }
  4751. }]);
  4752. return WritableStreamDefaultController;
  4753. }();
  4754. function WritableStreamDefaultControllerClose(controller) {
  4755. EnqueueValueWithSize(controller, 'close', 0);
  4756. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  4757. }
  4758. function WritableStreamDefaultControllerGetChunkSize(controller, chunk) {
  4759. var strategySize = controller._strategySize;
  4760. if (strategySize === undefined) {
  4761. return 1;
  4762. }
  4763. try {
  4764. return strategySize(chunk);
  4765. } catch (chunkSizeE) {
  4766. WritableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE);
  4767. return 1;
  4768. }
  4769. }
  4770. function WritableStreamDefaultControllerGetDesiredSize(controller) {
  4771. return controller._strategyHWM - controller._queueTotalSize;
  4772. }
  4773. function WritableStreamDefaultControllerWrite(controller, chunk, chunkSize) {
  4774. var writeRecord = {
  4775. chunk: chunk
  4776. };
  4777. try {
  4778. EnqueueValueWithSize(controller, writeRecord, chunkSize);
  4779. } catch (enqueueE) {
  4780. WritableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);
  4781. return;
  4782. }
  4783. var stream = controller._controlledWritableStream;
  4784. if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._state === 'writable') {
  4785. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  4786. WritableStreamUpdateBackpressure(stream, backpressure);
  4787. }
  4788. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  4789. }
  4790. function IsWritableStreamDefaultController(x) {
  4791. if (!typeIsObject(x)) {
  4792. return false;
  4793. }
  4794. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingSink')) {
  4795. return false;
  4796. }
  4797. return true;
  4798. }
  4799. function WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller) {
  4800. var stream = controller._controlledWritableStream;
  4801. if (controller._started === false) {
  4802. return;
  4803. }
  4804. if (stream._inFlightWriteRequest !== undefined) {
  4805. return;
  4806. }
  4807. var state = stream._state;
  4808. if (state === 'closed' || state === 'errored') {
  4809. return;
  4810. }
  4811. if (state === 'erroring') {
  4812. WritableStreamFinishErroring(stream);
  4813. return;
  4814. }
  4815. if (controller._queue.length === 0) {
  4816. return;
  4817. }
  4818. var writeRecord = PeekQueueValue(controller);
  4819. if (writeRecord === 'close') {
  4820. WritableStreamDefaultControllerProcessClose(controller);
  4821. } else {
  4822. WritableStreamDefaultControllerProcessWrite(controller, writeRecord.chunk);
  4823. }
  4824. }
  4825. function WritableStreamDefaultControllerErrorIfNeeded(controller, error) {
  4826. if (controller._controlledWritableStream._state === 'writable') {
  4827. WritableStreamDefaultControllerError(controller, error);
  4828. }
  4829. }
  4830. function WritableStreamDefaultControllerProcessClose(controller) {
  4831. var stream = controller._controlledWritableStream;
  4832. WritableStreamMarkCloseRequestInFlight(stream);
  4833. DequeueValue(controller);
  4834. assert(controller._queue.length === 0, 'queue must be empty once the final write record is dequeued');
  4835. var sinkClosePromise = PromiseInvokeOrNoop(controller._underlyingSink, 'close', []);
  4836. sinkClosePromise.then(function () {
  4837. WritableStreamFinishInFlightClose(stream);
  4838. }, function (reason) {
  4839. WritableStreamFinishInFlightCloseWithError(stream, reason);
  4840. })["catch"](rethrowAssertionErrorRejection);
  4841. }
  4842. function WritableStreamDefaultControllerProcessWrite(controller, chunk) {
  4843. var stream = controller._controlledWritableStream;
  4844. WritableStreamMarkFirstWriteRequestInFlight(stream);
  4845. var sinkWritePromise = PromiseInvokeOrNoop(controller._underlyingSink, 'write', [chunk, controller]);
  4846. sinkWritePromise.then(function () {
  4847. WritableStreamFinishInFlightWrite(stream);
  4848. var state = stream._state;
  4849. assert(state === 'writable' || state === 'erroring');
  4850. DequeueValue(controller);
  4851. if (WritableStreamCloseQueuedOrInFlight(stream) === false && state === 'writable') {
  4852. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  4853. WritableStreamUpdateBackpressure(stream, backpressure);
  4854. }
  4855. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  4856. }, function (reason) {
  4857. WritableStreamFinishInFlightWriteWithError(stream, reason);
  4858. })["catch"](rethrowAssertionErrorRejection);
  4859. }
  4860. function WritableStreamDefaultControllerGetBackpressure(controller) {
  4861. var desiredSize = WritableStreamDefaultControllerGetDesiredSize(controller);
  4862. return desiredSize <= 0;
  4863. }
  4864. function WritableStreamDefaultControllerError(controller, error) {
  4865. var stream = controller._controlledWritableStream;
  4866. assert(stream._state === 'writable');
  4867. WritableStreamStartErroring(stream, error);
  4868. }
  4869. function streamBrandCheckException(name) {
  4870. return new TypeError('WritableStream.prototype.' + name + ' can only be used on a WritableStream');
  4871. }
  4872. function defaultWriterBrandCheckException(name) {
  4873. return new TypeError('WritableStreamDefaultWriter.prototype.' + name + ' can only be used on a WritableStreamDefaultWriter');
  4874. }
  4875. function defaultWriterLockException(name) {
  4876. return new TypeError('Cannot ' + name + ' a stream using a released writer');
  4877. }
  4878. function defaultWriterClosedPromiseInitialize(writer) {
  4879. writer._closedPromise = new Promise(function (resolve, reject) {
  4880. writer._closedPromise_resolve = resolve;
  4881. writer._closedPromise_reject = reject;
  4882. writer._closedPromiseState = 'pending';
  4883. });
  4884. }
  4885. function defaultWriterClosedPromiseInitializeAsRejected(writer, reason) {
  4886. writer._closedPromise = Promise.reject(reason);
  4887. writer._closedPromise_resolve = undefined;
  4888. writer._closedPromise_reject = undefined;
  4889. writer._closedPromiseState = 'rejected';
  4890. }
  4891. function defaultWriterClosedPromiseInitializeAsResolved(writer) {
  4892. writer._closedPromise = Promise.resolve(undefined);
  4893. writer._closedPromise_resolve = undefined;
  4894. writer._closedPromise_reject = undefined;
  4895. writer._closedPromiseState = 'resolved';
  4896. }
  4897. function defaultWriterClosedPromiseReject(writer, reason) {
  4898. assert(writer._closedPromise_resolve !== undefined, 'writer._closedPromise_resolve !== undefined');
  4899. assert(writer._closedPromise_reject !== undefined, 'writer._closedPromise_reject !== undefined');
  4900. assert(writer._closedPromiseState === 'pending', 'writer._closedPromiseState is pending');
  4901. writer._closedPromise_reject(reason);
  4902. writer._closedPromise_resolve = undefined;
  4903. writer._closedPromise_reject = undefined;
  4904. writer._closedPromiseState = 'rejected';
  4905. }
  4906. function defaultWriterClosedPromiseResetToRejected(writer, reason) {
  4907. assert(writer._closedPromise_resolve === undefined, 'writer._closedPromise_resolve === undefined');
  4908. assert(writer._closedPromise_reject === undefined, 'writer._closedPromise_reject === undefined');
  4909. assert(writer._closedPromiseState !== 'pending', 'writer._closedPromiseState is not pending');
  4910. writer._closedPromise = Promise.reject(reason);
  4911. writer._closedPromiseState = 'rejected';
  4912. }
  4913. function defaultWriterClosedPromiseResolve(writer) {
  4914. assert(writer._closedPromise_resolve !== undefined, 'writer._closedPromise_resolve !== undefined');
  4915. assert(writer._closedPromise_reject !== undefined, 'writer._closedPromise_reject !== undefined');
  4916. assert(writer._closedPromiseState === 'pending', 'writer._closedPromiseState is pending');
  4917. writer._closedPromise_resolve(undefined);
  4918. writer._closedPromise_resolve = undefined;
  4919. writer._closedPromise_reject = undefined;
  4920. writer._closedPromiseState = 'resolved';
  4921. }
  4922. function defaultWriterReadyPromiseInitialize(writer) {
  4923. writer._readyPromise = new Promise(function (resolve, reject) {
  4924. writer._readyPromise_resolve = resolve;
  4925. writer._readyPromise_reject = reject;
  4926. });
  4927. writer._readyPromiseState = 'pending';
  4928. }
  4929. function defaultWriterReadyPromiseInitializeAsRejected(writer, reason) {
  4930. writer._readyPromise = Promise.reject(reason);
  4931. writer._readyPromise_resolve = undefined;
  4932. writer._readyPromise_reject = undefined;
  4933. writer._readyPromiseState = 'rejected';
  4934. }
  4935. function defaultWriterReadyPromiseInitializeAsResolved(writer) {
  4936. writer._readyPromise = Promise.resolve(undefined);
  4937. writer._readyPromise_resolve = undefined;
  4938. writer._readyPromise_reject = undefined;
  4939. writer._readyPromiseState = 'fulfilled';
  4940. }
  4941. function defaultWriterReadyPromiseReject(writer, reason) {
  4942. assert(writer._readyPromise_resolve !== undefined, 'writer._readyPromise_resolve !== undefined');
  4943. assert(writer._readyPromise_reject !== undefined, 'writer._readyPromise_reject !== undefined');
  4944. writer._readyPromise_reject(reason);
  4945. writer._readyPromise_resolve = undefined;
  4946. writer._readyPromise_reject = undefined;
  4947. writer._readyPromiseState = 'rejected';
  4948. }
  4949. function defaultWriterReadyPromiseReset(writer) {
  4950. assert(writer._readyPromise_resolve === undefined, 'writer._readyPromise_resolve === undefined');
  4951. assert(writer._readyPromise_reject === undefined, 'writer._readyPromise_reject === undefined');
  4952. writer._readyPromise = new Promise(function (resolve, reject) {
  4953. writer._readyPromise_resolve = resolve;
  4954. writer._readyPromise_reject = reject;
  4955. });
  4956. writer._readyPromiseState = 'pending';
  4957. }
  4958. function defaultWriterReadyPromiseResetToRejected(writer, reason) {
  4959. assert(writer._readyPromise_resolve === undefined, 'writer._readyPromise_resolve === undefined');
  4960. assert(writer._readyPromise_reject === undefined, 'writer._readyPromise_reject === undefined');
  4961. writer._readyPromise = Promise.reject(reason);
  4962. writer._readyPromiseState = 'rejected';
  4963. }
  4964. function defaultWriterReadyPromiseResolve(writer) {
  4965. assert(writer._readyPromise_resolve !== undefined, 'writer._readyPromise_resolve !== undefined');
  4966. assert(writer._readyPromise_reject !== undefined, 'writer._readyPromise_reject !== undefined');
  4967. writer._readyPromise_resolve(undefined);
  4968. writer._readyPromise_resolve = undefined;
  4969. writer._readyPromise_reject = undefined;
  4970. writer._readyPromiseState = 'fulfilled';
  4971. }
  4972. }, function (module, exports, __w_pdfjs_require__) {
  4973. "use strict";
  4974. var _require = __w_pdfjs_require__(0),
  4975. IsFiniteNonNegativeNumber = _require.IsFiniteNonNegativeNumber;
  4976. var _require2 = __w_pdfjs_require__(1),
  4977. assert = _require2.assert;
  4978. exports.DequeueValue = function (container) {
  4979. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: DequeueValue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  4980. assert(container._queue.length > 0, 'Spec-level failure: should never dequeue from an empty queue.');
  4981. var pair = container._queue.shift();
  4982. container._queueTotalSize -= pair.size;
  4983. if (container._queueTotalSize < 0) {
  4984. container._queueTotalSize = 0;
  4985. }
  4986. return pair.value;
  4987. };
  4988. exports.EnqueueValueWithSize = function (container, value, size) {
  4989. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: EnqueueValueWithSize should only be used on containers with [[queue]] and ' + '[[queueTotalSize]].');
  4990. size = Number(size);
  4991. if (!IsFiniteNonNegativeNumber(size)) {
  4992. throw new RangeError('Size must be a finite, non-NaN, non-negative number.');
  4993. }
  4994. container._queue.push({
  4995. value: value,
  4996. size: size
  4997. });
  4998. container._queueTotalSize += size;
  4999. };
  5000. exports.PeekQueueValue = function (container) {
  5001. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: PeekQueueValue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  5002. assert(container._queue.length > 0, 'Spec-level failure: should never peek at an empty queue.');
  5003. var pair = container._queue[0];
  5004. return pair.value;
  5005. };
  5006. exports.ResetQueue = function (container) {
  5007. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: ResetQueue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  5008. container._queue = [];
  5009. container._queueTotalSize = 0;
  5010. };
  5011. }, function (module, exports, __w_pdfjs_require__) {
  5012. "use strict";
  5013. var _createClass = function () {
  5014. function defineProperties(target, props) {
  5015. for (var i = 0; i < props.length; i++) {
  5016. var descriptor = props[i];
  5017. descriptor.enumerable = descriptor.enumerable || false;
  5018. descriptor.configurable = true;
  5019. if ("value" in descriptor) descriptor.writable = true;
  5020. Object.defineProperty(target, descriptor.key, descriptor);
  5021. }
  5022. }
  5023. return function (Constructor, protoProps, staticProps) {
  5024. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  5025. if (staticProps) defineProperties(Constructor, staticProps);
  5026. return Constructor;
  5027. };
  5028. }();
  5029. function _classCallCheck(instance, Constructor) {
  5030. if (!(instance instanceof Constructor)) {
  5031. throw new TypeError("Cannot call a class as a function");
  5032. }
  5033. }
  5034. var _require = __w_pdfjs_require__(0),
  5035. ArrayBufferCopy = _require.ArrayBufferCopy,
  5036. CreateIterResultObject = _require.CreateIterResultObject,
  5037. IsFiniteNonNegativeNumber = _require.IsFiniteNonNegativeNumber,
  5038. InvokeOrNoop = _require.InvokeOrNoop,
  5039. PromiseInvokeOrNoop = _require.PromiseInvokeOrNoop,
  5040. TransferArrayBuffer = _require.TransferArrayBuffer,
  5041. ValidateAndNormalizeQueuingStrategy = _require.ValidateAndNormalizeQueuingStrategy,
  5042. ValidateAndNormalizeHighWaterMark = _require.ValidateAndNormalizeHighWaterMark;
  5043. var _require2 = __w_pdfjs_require__(0),
  5044. createArrayFromList = _require2.createArrayFromList,
  5045. createDataProperty = _require2.createDataProperty,
  5046. typeIsObject = _require2.typeIsObject;
  5047. var _require3 = __w_pdfjs_require__(1),
  5048. assert = _require3.assert,
  5049. rethrowAssertionErrorRejection = _require3.rethrowAssertionErrorRejection;
  5050. var _require4 = __w_pdfjs_require__(3),
  5051. DequeueValue = _require4.DequeueValue,
  5052. EnqueueValueWithSize = _require4.EnqueueValueWithSize,
  5053. ResetQueue = _require4.ResetQueue;
  5054. var _require5 = __w_pdfjs_require__(2),
  5055. AcquireWritableStreamDefaultWriter = _require5.AcquireWritableStreamDefaultWriter,
  5056. IsWritableStream = _require5.IsWritableStream,
  5057. IsWritableStreamLocked = _require5.IsWritableStreamLocked,
  5058. WritableStreamAbort = _require5.WritableStreamAbort,
  5059. WritableStreamDefaultWriterCloseWithErrorPropagation = _require5.WritableStreamDefaultWriterCloseWithErrorPropagation,
  5060. WritableStreamDefaultWriterRelease = _require5.WritableStreamDefaultWriterRelease,
  5061. WritableStreamDefaultWriterWrite = _require5.WritableStreamDefaultWriterWrite,
  5062. WritableStreamCloseQueuedOrInFlight = _require5.WritableStreamCloseQueuedOrInFlight;
  5063. var ReadableStream = function () {
  5064. function ReadableStream() {
  5065. var underlyingSource = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5066. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  5067. size = _ref.size,
  5068. highWaterMark = _ref.highWaterMark;
  5069. _classCallCheck(this, ReadableStream);
  5070. this._state = 'readable';
  5071. this._reader = undefined;
  5072. this._storedError = undefined;
  5073. this._disturbed = false;
  5074. this._readableStreamController = undefined;
  5075. var type = underlyingSource.type;
  5076. var typeString = String(type);
  5077. if (typeString === 'bytes') {
  5078. if (highWaterMark === undefined) {
  5079. highWaterMark = 0;
  5080. }
  5081. this._readableStreamController = new ReadableByteStreamController(this, underlyingSource, highWaterMark);
  5082. } else if (type === undefined) {
  5083. if (highWaterMark === undefined) {
  5084. highWaterMark = 1;
  5085. }
  5086. this._readableStreamController = new ReadableStreamDefaultController(this, underlyingSource, size, highWaterMark);
  5087. } else {
  5088. throw new RangeError('Invalid type is specified');
  5089. }
  5090. }
  5091. _createClass(ReadableStream, [{
  5092. key: 'cancel',
  5093. value: function cancel(reason) {
  5094. if (IsReadableStream(this) === false) {
  5095. return Promise.reject(streamBrandCheckException('cancel'));
  5096. }
  5097. if (IsReadableStreamLocked(this) === true) {
  5098. return Promise.reject(new TypeError('Cannot cancel a stream that already has a reader'));
  5099. }
  5100. return ReadableStreamCancel(this, reason);
  5101. }
  5102. }, {
  5103. key: 'getReader',
  5104. value: function getReader() {
  5105. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  5106. mode = _ref2.mode;
  5107. if (IsReadableStream(this) === false) {
  5108. throw streamBrandCheckException('getReader');
  5109. }
  5110. if (mode === undefined) {
  5111. return AcquireReadableStreamDefaultReader(this);
  5112. }
  5113. mode = String(mode);
  5114. if (mode === 'byob') {
  5115. return AcquireReadableStreamBYOBReader(this);
  5116. }
  5117. throw new RangeError('Invalid mode is specified');
  5118. }
  5119. }, {
  5120. key: 'pipeThrough',
  5121. value: function pipeThrough(_ref3, options) {
  5122. var writable = _ref3.writable,
  5123. readable = _ref3.readable;
  5124. var promise = this.pipeTo(writable, options);
  5125. ifIsObjectAndHasAPromiseIsHandledInternalSlotSetPromiseIsHandledToTrue(promise);
  5126. return readable;
  5127. }
  5128. }, {
  5129. key: 'pipeTo',
  5130. value: function pipeTo(dest) {
  5131. var _this = this;
  5132. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  5133. preventClose = _ref4.preventClose,
  5134. preventAbort = _ref4.preventAbort,
  5135. preventCancel = _ref4.preventCancel;
  5136. if (IsReadableStream(this) === false) {
  5137. return Promise.reject(streamBrandCheckException('pipeTo'));
  5138. }
  5139. if (IsWritableStream(dest) === false) {
  5140. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo\'s first argument must be a WritableStream'));
  5141. }
  5142. preventClose = Boolean(preventClose);
  5143. preventAbort = Boolean(preventAbort);
  5144. preventCancel = Boolean(preventCancel);
  5145. if (IsReadableStreamLocked(this) === true) {
  5146. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream'));
  5147. }
  5148. if (IsWritableStreamLocked(dest) === true) {
  5149. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream'));
  5150. }
  5151. var reader = AcquireReadableStreamDefaultReader(this);
  5152. var writer = AcquireWritableStreamDefaultWriter(dest);
  5153. var shuttingDown = false;
  5154. var currentWrite = Promise.resolve();
  5155. return new Promise(function (resolve, reject) {
  5156. function pipeLoop() {
  5157. currentWrite = Promise.resolve();
  5158. if (shuttingDown === true) {
  5159. return Promise.resolve();
  5160. }
  5161. return writer._readyPromise.then(function () {
  5162. return ReadableStreamDefaultReaderRead(reader).then(function (_ref5) {
  5163. var value = _ref5.value,
  5164. done = _ref5.done;
  5165. if (done === true) {
  5166. return;
  5167. }
  5168. currentWrite = WritableStreamDefaultWriterWrite(writer, value)["catch"](function () {});
  5169. });
  5170. }).then(pipeLoop);
  5171. }
  5172. isOrBecomesErrored(_this, reader._closedPromise, function (storedError) {
  5173. if (preventAbort === false) {
  5174. shutdownWithAction(function () {
  5175. return WritableStreamAbort(dest, storedError);
  5176. }, true, storedError);
  5177. } else {
  5178. shutdown(true, storedError);
  5179. }
  5180. });
  5181. isOrBecomesErrored(dest, writer._closedPromise, function (storedError) {
  5182. if (preventCancel === false) {
  5183. shutdownWithAction(function () {
  5184. return ReadableStreamCancel(_this, storedError);
  5185. }, true, storedError);
  5186. } else {
  5187. shutdown(true, storedError);
  5188. }
  5189. });
  5190. isOrBecomesClosed(_this, reader._closedPromise, function () {
  5191. if (preventClose === false) {
  5192. shutdownWithAction(function () {
  5193. return WritableStreamDefaultWriterCloseWithErrorPropagation(writer);
  5194. });
  5195. } else {
  5196. shutdown();
  5197. }
  5198. });
  5199. if (WritableStreamCloseQueuedOrInFlight(dest) === true || dest._state === 'closed') {
  5200. var destClosed = new TypeError('the destination writable stream closed before all data could be piped to it');
  5201. if (preventCancel === false) {
  5202. shutdownWithAction(function () {
  5203. return ReadableStreamCancel(_this, destClosed);
  5204. }, true, destClosed);
  5205. } else {
  5206. shutdown(true, destClosed);
  5207. }
  5208. }
  5209. pipeLoop()["catch"](function (err) {
  5210. currentWrite = Promise.resolve();
  5211. rethrowAssertionErrorRejection(err);
  5212. });
  5213. function waitForWritesToFinish() {
  5214. var oldCurrentWrite = currentWrite;
  5215. return currentWrite.then(function () {
  5216. return oldCurrentWrite !== currentWrite ? waitForWritesToFinish() : undefined;
  5217. });
  5218. }
  5219. function isOrBecomesErrored(stream, promise, action) {
  5220. if (stream._state === 'errored') {
  5221. action(stream._storedError);
  5222. } else {
  5223. promise["catch"](action)["catch"](rethrowAssertionErrorRejection);
  5224. }
  5225. }
  5226. function isOrBecomesClosed(stream, promise, action) {
  5227. if (stream._state === 'closed') {
  5228. action();
  5229. } else {
  5230. promise.then(action)["catch"](rethrowAssertionErrorRejection);
  5231. }
  5232. }
  5233. function shutdownWithAction(action, originalIsError, originalError) {
  5234. if (shuttingDown === true) {
  5235. return;
  5236. }
  5237. shuttingDown = true;
  5238. if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
  5239. waitForWritesToFinish().then(doTheRest);
  5240. } else {
  5241. doTheRest();
  5242. }
  5243. function doTheRest() {
  5244. action().then(function () {
  5245. return finalize(originalIsError, originalError);
  5246. }, function (newError) {
  5247. return finalize(true, newError);
  5248. })["catch"](rethrowAssertionErrorRejection);
  5249. }
  5250. }
  5251. function shutdown(isError, error) {
  5252. if (shuttingDown === true) {
  5253. return;
  5254. }
  5255. shuttingDown = true;
  5256. if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
  5257. waitForWritesToFinish().then(function () {
  5258. return finalize(isError, error);
  5259. })["catch"](rethrowAssertionErrorRejection);
  5260. } else {
  5261. finalize(isError, error);
  5262. }
  5263. }
  5264. function finalize(isError, error) {
  5265. WritableStreamDefaultWriterRelease(writer);
  5266. ReadableStreamReaderGenericRelease(reader);
  5267. if (isError) {
  5268. reject(error);
  5269. } else {
  5270. resolve(undefined);
  5271. }
  5272. }
  5273. });
  5274. }
  5275. }, {
  5276. key: 'tee',
  5277. value: function tee() {
  5278. if (IsReadableStream(this) === false) {
  5279. throw streamBrandCheckException('tee');
  5280. }
  5281. var branches = ReadableStreamTee(this, false);
  5282. return createArrayFromList(branches);
  5283. }
  5284. }, {
  5285. key: 'locked',
  5286. get: function get() {
  5287. if (IsReadableStream(this) === false) {
  5288. throw streamBrandCheckException('locked');
  5289. }
  5290. return IsReadableStreamLocked(this);
  5291. }
  5292. }]);
  5293. return ReadableStream;
  5294. }();
  5295. module.exports = {
  5296. ReadableStream: ReadableStream,
  5297. IsReadableStreamDisturbed: IsReadableStreamDisturbed,
  5298. ReadableStreamDefaultControllerClose: ReadableStreamDefaultControllerClose,
  5299. ReadableStreamDefaultControllerEnqueue: ReadableStreamDefaultControllerEnqueue,
  5300. ReadableStreamDefaultControllerError: ReadableStreamDefaultControllerError,
  5301. ReadableStreamDefaultControllerGetDesiredSize: ReadableStreamDefaultControllerGetDesiredSize
  5302. };
  5303. function AcquireReadableStreamBYOBReader(stream) {
  5304. return new ReadableStreamBYOBReader(stream);
  5305. }
  5306. function AcquireReadableStreamDefaultReader(stream) {
  5307. return new ReadableStreamDefaultReader(stream);
  5308. }
  5309. function IsReadableStream(x) {
  5310. if (!typeIsObject(x)) {
  5311. return false;
  5312. }
  5313. if (!Object.prototype.hasOwnProperty.call(x, '_readableStreamController')) {
  5314. return false;
  5315. }
  5316. return true;
  5317. }
  5318. function IsReadableStreamDisturbed(stream) {
  5319. assert(IsReadableStream(stream) === true, 'IsReadableStreamDisturbed should only be used on known readable streams');
  5320. return stream._disturbed;
  5321. }
  5322. function IsReadableStreamLocked(stream) {
  5323. assert(IsReadableStream(stream) === true, 'IsReadableStreamLocked should only be used on known readable streams');
  5324. if (stream._reader === undefined) {
  5325. return false;
  5326. }
  5327. return true;
  5328. }
  5329. function ReadableStreamTee(stream, cloneForBranch2) {
  5330. assert(IsReadableStream(stream) === true);
  5331. assert(typeof cloneForBranch2 === 'boolean');
  5332. var reader = AcquireReadableStreamDefaultReader(stream);
  5333. var teeState = {
  5334. closedOrErrored: false,
  5335. canceled1: false,
  5336. canceled2: false,
  5337. reason1: undefined,
  5338. reason2: undefined
  5339. };
  5340. teeState.promise = new Promise(function (resolve) {
  5341. teeState._resolve = resolve;
  5342. });
  5343. var pull = create_ReadableStreamTeePullFunction();
  5344. pull._reader = reader;
  5345. pull._teeState = teeState;
  5346. pull._cloneForBranch2 = cloneForBranch2;
  5347. var cancel1 = create_ReadableStreamTeeBranch1CancelFunction();
  5348. cancel1._stream = stream;
  5349. cancel1._teeState = teeState;
  5350. var cancel2 = create_ReadableStreamTeeBranch2CancelFunction();
  5351. cancel2._stream = stream;
  5352. cancel2._teeState = teeState;
  5353. var underlyingSource1 = Object.create(Object.prototype);
  5354. createDataProperty(underlyingSource1, 'pull', pull);
  5355. createDataProperty(underlyingSource1, 'cancel', cancel1);
  5356. var branch1Stream = new ReadableStream(underlyingSource1);
  5357. var underlyingSource2 = Object.create(Object.prototype);
  5358. createDataProperty(underlyingSource2, 'pull', pull);
  5359. createDataProperty(underlyingSource2, 'cancel', cancel2);
  5360. var branch2Stream = new ReadableStream(underlyingSource2);
  5361. pull._branch1 = branch1Stream._readableStreamController;
  5362. pull._branch2 = branch2Stream._readableStreamController;
  5363. reader._closedPromise["catch"](function (r) {
  5364. if (teeState.closedOrErrored === true) {
  5365. return;
  5366. }
  5367. ReadableStreamDefaultControllerError(pull._branch1, r);
  5368. ReadableStreamDefaultControllerError(pull._branch2, r);
  5369. teeState.closedOrErrored = true;
  5370. });
  5371. return [branch1Stream, branch2Stream];
  5372. }
  5373. function create_ReadableStreamTeePullFunction() {
  5374. function f() {
  5375. var reader = f._reader,
  5376. branch1 = f._branch1,
  5377. branch2 = f._branch2,
  5378. teeState = f._teeState;
  5379. return ReadableStreamDefaultReaderRead(reader).then(function (result) {
  5380. assert(typeIsObject(result));
  5381. var value = result.value;
  5382. var done = result.done;
  5383. assert(typeof done === 'boolean');
  5384. if (done === true && teeState.closedOrErrored === false) {
  5385. if (teeState.canceled1 === false) {
  5386. ReadableStreamDefaultControllerClose(branch1);
  5387. }
  5388. if (teeState.canceled2 === false) {
  5389. ReadableStreamDefaultControllerClose(branch2);
  5390. }
  5391. teeState.closedOrErrored = true;
  5392. }
  5393. if (teeState.closedOrErrored === true) {
  5394. return;
  5395. }
  5396. var value1 = value;
  5397. var value2 = value;
  5398. if (teeState.canceled1 === false) {
  5399. ReadableStreamDefaultControllerEnqueue(branch1, value1);
  5400. }
  5401. if (teeState.canceled2 === false) {
  5402. ReadableStreamDefaultControllerEnqueue(branch2, value2);
  5403. }
  5404. });
  5405. }
  5406. return f;
  5407. }
  5408. function create_ReadableStreamTeeBranch1CancelFunction() {
  5409. function f(reason) {
  5410. var stream = f._stream,
  5411. teeState = f._teeState;
  5412. teeState.canceled1 = true;
  5413. teeState.reason1 = reason;
  5414. if (teeState.canceled2 === true) {
  5415. var compositeReason = createArrayFromList([teeState.reason1, teeState.reason2]);
  5416. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  5417. teeState._resolve(cancelResult);
  5418. }
  5419. return teeState.promise;
  5420. }
  5421. return f;
  5422. }
  5423. function create_ReadableStreamTeeBranch2CancelFunction() {
  5424. function f(reason) {
  5425. var stream = f._stream,
  5426. teeState = f._teeState;
  5427. teeState.canceled2 = true;
  5428. teeState.reason2 = reason;
  5429. if (teeState.canceled1 === true) {
  5430. var compositeReason = createArrayFromList([teeState.reason1, teeState.reason2]);
  5431. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  5432. teeState._resolve(cancelResult);
  5433. }
  5434. return teeState.promise;
  5435. }
  5436. return f;
  5437. }
  5438. function ReadableStreamAddReadIntoRequest(stream) {
  5439. assert(IsReadableStreamBYOBReader(stream._reader) === true);
  5440. assert(stream._state === 'readable' || stream._state === 'closed');
  5441. var promise = new Promise(function (resolve, reject) {
  5442. var readIntoRequest = {
  5443. _resolve: resolve,
  5444. _reject: reject
  5445. };
  5446. stream._reader._readIntoRequests.push(readIntoRequest);
  5447. });
  5448. return promise;
  5449. }
  5450. function ReadableStreamAddReadRequest(stream) {
  5451. assert(IsReadableStreamDefaultReader(stream._reader) === true);
  5452. assert(stream._state === 'readable');
  5453. var promise = new Promise(function (resolve, reject) {
  5454. var readRequest = {
  5455. _resolve: resolve,
  5456. _reject: reject
  5457. };
  5458. stream._reader._readRequests.push(readRequest);
  5459. });
  5460. return promise;
  5461. }
  5462. function ReadableStreamCancel(stream, reason) {
  5463. stream._disturbed = true;
  5464. if (stream._state === 'closed') {
  5465. return Promise.resolve(undefined);
  5466. }
  5467. if (stream._state === 'errored') {
  5468. return Promise.reject(stream._storedError);
  5469. }
  5470. ReadableStreamClose(stream);
  5471. var sourceCancelPromise = stream._readableStreamController.__cancelSteps(reason);
  5472. return sourceCancelPromise.then(function () {
  5473. return undefined;
  5474. });
  5475. }
  5476. function ReadableStreamClose(stream) {
  5477. assert(stream._state === 'readable');
  5478. stream._state = 'closed';
  5479. var reader = stream._reader;
  5480. if (reader === undefined) {
  5481. return undefined;
  5482. }
  5483. if (IsReadableStreamDefaultReader(reader) === true) {
  5484. for (var i = 0; i < reader._readRequests.length; i++) {
  5485. var _resolve = reader._readRequests[i]._resolve;
  5486. _resolve(CreateIterResultObject(undefined, true));
  5487. }
  5488. reader._readRequests = [];
  5489. }
  5490. defaultReaderClosedPromiseResolve(reader);
  5491. return undefined;
  5492. }
  5493. function ReadableStreamError(stream, e) {
  5494. assert(IsReadableStream(stream) === true, 'stream must be ReadableStream');
  5495. assert(stream._state === 'readable', 'state must be readable');
  5496. stream._state = 'errored';
  5497. stream._storedError = e;
  5498. var reader = stream._reader;
  5499. if (reader === undefined) {
  5500. return undefined;
  5501. }
  5502. if (IsReadableStreamDefaultReader(reader) === true) {
  5503. for (var i = 0; i < reader._readRequests.length; i++) {
  5504. var readRequest = reader._readRequests[i];
  5505. readRequest._reject(e);
  5506. }
  5507. reader._readRequests = [];
  5508. } else {
  5509. assert(IsReadableStreamBYOBReader(reader), 'reader must be ReadableStreamBYOBReader');
  5510. for (var _i = 0; _i < reader._readIntoRequests.length; _i++) {
  5511. var readIntoRequest = reader._readIntoRequests[_i];
  5512. readIntoRequest._reject(e);
  5513. }
  5514. reader._readIntoRequests = [];
  5515. }
  5516. defaultReaderClosedPromiseReject(reader, e);
  5517. reader._closedPromise["catch"](function () {});
  5518. }
  5519. function ReadableStreamFulfillReadIntoRequest(stream, chunk, done) {
  5520. var reader = stream._reader;
  5521. assert(reader._readIntoRequests.length > 0);
  5522. var readIntoRequest = reader._readIntoRequests.shift();
  5523. readIntoRequest._resolve(CreateIterResultObject(chunk, done));
  5524. }
  5525. function ReadableStreamFulfillReadRequest(stream, chunk, done) {
  5526. var reader = stream._reader;
  5527. assert(reader._readRequests.length > 0);
  5528. var readRequest = reader._readRequests.shift();
  5529. readRequest._resolve(CreateIterResultObject(chunk, done));
  5530. }
  5531. function ReadableStreamGetNumReadIntoRequests(stream) {
  5532. return stream._reader._readIntoRequests.length;
  5533. }
  5534. function ReadableStreamGetNumReadRequests(stream) {
  5535. return stream._reader._readRequests.length;
  5536. }
  5537. function ReadableStreamHasBYOBReader(stream) {
  5538. var reader = stream._reader;
  5539. if (reader === undefined) {
  5540. return false;
  5541. }
  5542. if (IsReadableStreamBYOBReader(reader) === false) {
  5543. return false;
  5544. }
  5545. return true;
  5546. }
  5547. function ReadableStreamHasDefaultReader(stream) {
  5548. var reader = stream._reader;
  5549. if (reader === undefined) {
  5550. return false;
  5551. }
  5552. if (IsReadableStreamDefaultReader(reader) === false) {
  5553. return false;
  5554. }
  5555. return true;
  5556. }
  5557. var ReadableStreamDefaultReader = function () {
  5558. function ReadableStreamDefaultReader(stream) {
  5559. _classCallCheck(this, ReadableStreamDefaultReader);
  5560. if (IsReadableStream(stream) === false) {
  5561. throw new TypeError('ReadableStreamDefaultReader can only be constructed with a ReadableStream instance');
  5562. }
  5563. if (IsReadableStreamLocked(stream) === true) {
  5564. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  5565. }
  5566. ReadableStreamReaderGenericInitialize(this, stream);
  5567. this._readRequests = [];
  5568. }
  5569. _createClass(ReadableStreamDefaultReader, [{
  5570. key: 'cancel',
  5571. value: function cancel(reason) {
  5572. if (IsReadableStreamDefaultReader(this) === false) {
  5573. return Promise.reject(defaultReaderBrandCheckException('cancel'));
  5574. }
  5575. if (this._ownerReadableStream === undefined) {
  5576. return Promise.reject(readerLockException('cancel'));
  5577. }
  5578. return ReadableStreamReaderGenericCancel(this, reason);
  5579. }
  5580. }, {
  5581. key: 'read',
  5582. value: function read() {
  5583. if (IsReadableStreamDefaultReader(this) === false) {
  5584. return Promise.reject(defaultReaderBrandCheckException('read'));
  5585. }
  5586. if (this._ownerReadableStream === undefined) {
  5587. return Promise.reject(readerLockException('read from'));
  5588. }
  5589. return ReadableStreamDefaultReaderRead(this);
  5590. }
  5591. }, {
  5592. key: 'releaseLock',
  5593. value: function releaseLock() {
  5594. if (IsReadableStreamDefaultReader(this) === false) {
  5595. throw defaultReaderBrandCheckException('releaseLock');
  5596. }
  5597. if (this._ownerReadableStream === undefined) {
  5598. return;
  5599. }
  5600. if (this._readRequests.length > 0) {
  5601. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  5602. }
  5603. ReadableStreamReaderGenericRelease(this);
  5604. }
  5605. }, {
  5606. key: 'closed',
  5607. get: function get() {
  5608. if (IsReadableStreamDefaultReader(this) === false) {
  5609. return Promise.reject(defaultReaderBrandCheckException('closed'));
  5610. }
  5611. return this._closedPromise;
  5612. }
  5613. }]);
  5614. return ReadableStreamDefaultReader;
  5615. }();
  5616. var ReadableStreamBYOBReader = function () {
  5617. function ReadableStreamBYOBReader(stream) {
  5618. _classCallCheck(this, ReadableStreamBYOBReader);
  5619. if (!IsReadableStream(stream)) {
  5620. throw new TypeError('ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a ' + 'byte source');
  5621. }
  5622. if (IsReadableByteStreamController(stream._readableStreamController) === false) {
  5623. throw new TypeError('Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte ' + 'source');
  5624. }
  5625. if (IsReadableStreamLocked(stream)) {
  5626. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  5627. }
  5628. ReadableStreamReaderGenericInitialize(this, stream);
  5629. this._readIntoRequests = [];
  5630. }
  5631. _createClass(ReadableStreamBYOBReader, [{
  5632. key: 'cancel',
  5633. value: function cancel(reason) {
  5634. if (!IsReadableStreamBYOBReader(this)) {
  5635. return Promise.reject(byobReaderBrandCheckException('cancel'));
  5636. }
  5637. if (this._ownerReadableStream === undefined) {
  5638. return Promise.reject(readerLockException('cancel'));
  5639. }
  5640. return ReadableStreamReaderGenericCancel(this, reason);
  5641. }
  5642. }, {
  5643. key: 'read',
  5644. value: function read(view) {
  5645. if (!IsReadableStreamBYOBReader(this)) {
  5646. return Promise.reject(byobReaderBrandCheckException('read'));
  5647. }
  5648. if (this._ownerReadableStream === undefined) {
  5649. return Promise.reject(readerLockException('read from'));
  5650. }
  5651. if (!ArrayBuffer.isView(view)) {
  5652. return Promise.reject(new TypeError('view must be an array buffer view'));
  5653. }
  5654. if (view.byteLength === 0) {
  5655. return Promise.reject(new TypeError('view must have non-zero byteLength'));
  5656. }
  5657. return ReadableStreamBYOBReaderRead(this, view);
  5658. }
  5659. }, {
  5660. key: 'releaseLock',
  5661. value: function releaseLock() {
  5662. if (!IsReadableStreamBYOBReader(this)) {
  5663. throw byobReaderBrandCheckException('releaseLock');
  5664. }
  5665. if (this._ownerReadableStream === undefined) {
  5666. return;
  5667. }
  5668. if (this._readIntoRequests.length > 0) {
  5669. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  5670. }
  5671. ReadableStreamReaderGenericRelease(this);
  5672. }
  5673. }, {
  5674. key: 'closed',
  5675. get: function get() {
  5676. if (!IsReadableStreamBYOBReader(this)) {
  5677. return Promise.reject(byobReaderBrandCheckException('closed'));
  5678. }
  5679. return this._closedPromise;
  5680. }
  5681. }]);
  5682. return ReadableStreamBYOBReader;
  5683. }();
  5684. function IsReadableStreamBYOBReader(x) {
  5685. if (!typeIsObject(x)) {
  5686. return false;
  5687. }
  5688. if (!Object.prototype.hasOwnProperty.call(x, '_readIntoRequests')) {
  5689. return false;
  5690. }
  5691. return true;
  5692. }
  5693. function IsReadableStreamDefaultReader(x) {
  5694. if (!typeIsObject(x)) {
  5695. return false;
  5696. }
  5697. if (!Object.prototype.hasOwnProperty.call(x, '_readRequests')) {
  5698. return false;
  5699. }
  5700. return true;
  5701. }
  5702. function ReadableStreamReaderGenericInitialize(reader, stream) {
  5703. reader._ownerReadableStream = stream;
  5704. stream._reader = reader;
  5705. if (stream._state === 'readable') {
  5706. defaultReaderClosedPromiseInitialize(reader);
  5707. } else if (stream._state === 'closed') {
  5708. defaultReaderClosedPromiseInitializeAsResolved(reader);
  5709. } else {
  5710. assert(stream._state === 'errored', 'state must be errored');
  5711. defaultReaderClosedPromiseInitializeAsRejected(reader, stream._storedError);
  5712. reader._closedPromise["catch"](function () {});
  5713. }
  5714. }
  5715. function ReadableStreamReaderGenericCancel(reader, reason) {
  5716. var stream = reader._ownerReadableStream;
  5717. assert(stream !== undefined);
  5718. return ReadableStreamCancel(stream, reason);
  5719. }
  5720. function ReadableStreamReaderGenericRelease(reader) {
  5721. assert(reader._ownerReadableStream !== undefined);
  5722. assert(reader._ownerReadableStream._reader === reader);
  5723. if (reader._ownerReadableStream._state === 'readable') {
  5724. defaultReaderClosedPromiseReject(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));
  5725. } else {
  5726. defaultReaderClosedPromiseResetToRejected(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));
  5727. }
  5728. reader._closedPromise["catch"](function () {});
  5729. reader._ownerReadableStream._reader = undefined;
  5730. reader._ownerReadableStream = undefined;
  5731. }
  5732. function ReadableStreamBYOBReaderRead(reader, view) {
  5733. var stream = reader._ownerReadableStream;
  5734. assert(stream !== undefined);
  5735. stream._disturbed = true;
  5736. if (stream._state === 'errored') {
  5737. return Promise.reject(stream._storedError);
  5738. }
  5739. return ReadableByteStreamControllerPullInto(stream._readableStreamController, view);
  5740. }
  5741. function ReadableStreamDefaultReaderRead(reader) {
  5742. var stream = reader._ownerReadableStream;
  5743. assert(stream !== undefined);
  5744. stream._disturbed = true;
  5745. if (stream._state === 'closed') {
  5746. return Promise.resolve(CreateIterResultObject(undefined, true));
  5747. }
  5748. if (stream._state === 'errored') {
  5749. return Promise.reject(stream._storedError);
  5750. }
  5751. assert(stream._state === 'readable');
  5752. return stream._readableStreamController.__pullSteps();
  5753. }
  5754. var ReadableStreamDefaultController = function () {
  5755. function ReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark) {
  5756. _classCallCheck(this, ReadableStreamDefaultController);
  5757. if (IsReadableStream(stream) === false) {
  5758. throw new TypeError('ReadableStreamDefaultController can only be constructed with a ReadableStream instance');
  5759. }
  5760. if (stream._readableStreamController !== undefined) {
  5761. throw new TypeError('ReadableStreamDefaultController instances can only be created by the ReadableStream constructor');
  5762. }
  5763. this._controlledReadableStream = stream;
  5764. this._underlyingSource = underlyingSource;
  5765. this._queue = undefined;
  5766. this._queueTotalSize = undefined;
  5767. ResetQueue(this);
  5768. this._started = false;
  5769. this._closeRequested = false;
  5770. this._pullAgain = false;
  5771. this._pulling = false;
  5772. var normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark);
  5773. this._strategySize = normalizedStrategy.size;
  5774. this._strategyHWM = normalizedStrategy.highWaterMark;
  5775. var controller = this;
  5776. var startResult = InvokeOrNoop(underlyingSource, 'start', [this]);
  5777. Promise.resolve(startResult).then(function () {
  5778. controller._started = true;
  5779. assert(controller._pulling === false);
  5780. assert(controller._pullAgain === false);
  5781. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  5782. }, function (r) {
  5783. ReadableStreamDefaultControllerErrorIfNeeded(controller, r);
  5784. })["catch"](rethrowAssertionErrorRejection);
  5785. }
  5786. _createClass(ReadableStreamDefaultController, [{
  5787. key: 'close',
  5788. value: function close() {
  5789. if (IsReadableStreamDefaultController(this) === false) {
  5790. throw defaultControllerBrandCheckException('close');
  5791. }
  5792. if (this._closeRequested === true) {
  5793. throw new TypeError('The stream has already been closed; do not close it again!');
  5794. }
  5795. var state = this._controlledReadableStream._state;
  5796. if (state !== 'readable') {
  5797. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be closed');
  5798. }
  5799. ReadableStreamDefaultControllerClose(this);
  5800. }
  5801. }, {
  5802. key: 'enqueue',
  5803. value: function enqueue(chunk) {
  5804. if (IsReadableStreamDefaultController(this) === false) {
  5805. throw defaultControllerBrandCheckException('enqueue');
  5806. }
  5807. if (this._closeRequested === true) {
  5808. throw new TypeError('stream is closed or draining');
  5809. }
  5810. var state = this._controlledReadableStream._state;
  5811. if (state !== 'readable') {
  5812. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be enqueued to');
  5813. }
  5814. return ReadableStreamDefaultControllerEnqueue(this, chunk);
  5815. }
  5816. }, {
  5817. key: 'error',
  5818. value: function error(e) {
  5819. if (IsReadableStreamDefaultController(this) === false) {
  5820. throw defaultControllerBrandCheckException('error');
  5821. }
  5822. var stream = this._controlledReadableStream;
  5823. if (stream._state !== 'readable') {
  5824. throw new TypeError('The stream is ' + stream._state + ' and so cannot be errored');
  5825. }
  5826. ReadableStreamDefaultControllerError(this, e);
  5827. }
  5828. }, {
  5829. key: '__cancelSteps',
  5830. value: function __cancelSteps(reason) {
  5831. ResetQueue(this);
  5832. return PromiseInvokeOrNoop(this._underlyingSource, 'cancel', [reason]);
  5833. }
  5834. }, {
  5835. key: '__pullSteps',
  5836. value: function __pullSteps() {
  5837. var stream = this._controlledReadableStream;
  5838. if (this._queue.length > 0) {
  5839. var chunk = DequeueValue(this);
  5840. if (this._closeRequested === true && this._queue.length === 0) {
  5841. ReadableStreamClose(stream);
  5842. } else {
  5843. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  5844. }
  5845. return Promise.resolve(CreateIterResultObject(chunk, false));
  5846. }
  5847. var pendingPromise = ReadableStreamAddReadRequest(stream);
  5848. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  5849. return pendingPromise;
  5850. }
  5851. }, {
  5852. key: 'desiredSize',
  5853. get: function get() {
  5854. if (IsReadableStreamDefaultController(this) === false) {
  5855. throw defaultControllerBrandCheckException('desiredSize');
  5856. }
  5857. return ReadableStreamDefaultControllerGetDesiredSize(this);
  5858. }
  5859. }]);
  5860. return ReadableStreamDefaultController;
  5861. }();
  5862. function IsReadableStreamDefaultController(x) {
  5863. if (!typeIsObject(x)) {
  5864. return false;
  5865. }
  5866. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingSource')) {
  5867. return false;
  5868. }
  5869. return true;
  5870. }
  5871. function ReadableStreamDefaultControllerCallPullIfNeeded(controller) {
  5872. var shouldPull = ReadableStreamDefaultControllerShouldCallPull(controller);
  5873. if (shouldPull === false) {
  5874. return undefined;
  5875. }
  5876. if (controller._pulling === true) {
  5877. controller._pullAgain = true;
  5878. return undefined;
  5879. }
  5880. assert(controller._pullAgain === false);
  5881. controller._pulling = true;
  5882. var pullPromise = PromiseInvokeOrNoop(controller._underlyingSource, 'pull', [controller]);
  5883. pullPromise.then(function () {
  5884. controller._pulling = false;
  5885. if (controller._pullAgain === true) {
  5886. controller._pullAgain = false;
  5887. return ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  5888. }
  5889. return undefined;
  5890. }, function (e) {
  5891. ReadableStreamDefaultControllerErrorIfNeeded(controller, e);
  5892. })["catch"](rethrowAssertionErrorRejection);
  5893. return undefined;
  5894. }
  5895. function ReadableStreamDefaultControllerShouldCallPull(controller) {
  5896. var stream = controller._controlledReadableStream;
  5897. if (stream._state === 'closed' || stream._state === 'errored') {
  5898. return false;
  5899. }
  5900. if (controller._closeRequested === true) {
  5901. return false;
  5902. }
  5903. if (controller._started === false) {
  5904. return false;
  5905. }
  5906. if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  5907. return true;
  5908. }
  5909. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);
  5910. if (desiredSize > 0) {
  5911. return true;
  5912. }
  5913. return false;
  5914. }
  5915. function ReadableStreamDefaultControllerClose(controller) {
  5916. var stream = controller._controlledReadableStream;
  5917. assert(controller._closeRequested === false);
  5918. assert(stream._state === 'readable');
  5919. controller._closeRequested = true;
  5920. if (controller._queue.length === 0) {
  5921. ReadableStreamClose(stream);
  5922. }
  5923. }
  5924. function ReadableStreamDefaultControllerEnqueue(controller, chunk) {
  5925. var stream = controller._controlledReadableStream;
  5926. assert(controller._closeRequested === false);
  5927. assert(stream._state === 'readable');
  5928. if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  5929. ReadableStreamFulfillReadRequest(stream, chunk, false);
  5930. } else {
  5931. var chunkSize = 1;
  5932. if (controller._strategySize !== undefined) {
  5933. var strategySize = controller._strategySize;
  5934. try {
  5935. chunkSize = strategySize(chunk);
  5936. } catch (chunkSizeE) {
  5937. ReadableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE);
  5938. throw chunkSizeE;
  5939. }
  5940. }
  5941. try {
  5942. EnqueueValueWithSize(controller, chunk, chunkSize);
  5943. } catch (enqueueE) {
  5944. ReadableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);
  5945. throw enqueueE;
  5946. }
  5947. }
  5948. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  5949. return undefined;
  5950. }
  5951. function ReadableStreamDefaultControllerError(controller, e) {
  5952. var stream = controller._controlledReadableStream;
  5953. assert(stream._state === 'readable');
  5954. ResetQueue(controller);
  5955. ReadableStreamError(stream, e);
  5956. }
  5957. function ReadableStreamDefaultControllerErrorIfNeeded(controller, e) {
  5958. if (controller._controlledReadableStream._state === 'readable') {
  5959. ReadableStreamDefaultControllerError(controller, e);
  5960. }
  5961. }
  5962. function ReadableStreamDefaultControllerGetDesiredSize(controller) {
  5963. var stream = controller._controlledReadableStream;
  5964. var state = stream._state;
  5965. if (state === 'errored') {
  5966. return null;
  5967. }
  5968. if (state === 'closed') {
  5969. return 0;
  5970. }
  5971. return controller._strategyHWM - controller._queueTotalSize;
  5972. }
  5973. var ReadableStreamBYOBRequest = function () {
  5974. function ReadableStreamBYOBRequest(controller, view) {
  5975. _classCallCheck(this, ReadableStreamBYOBRequest);
  5976. this._associatedReadableByteStreamController = controller;
  5977. this._view = view;
  5978. }
  5979. _createClass(ReadableStreamBYOBRequest, [{
  5980. key: 'respond',
  5981. value: function respond(bytesWritten) {
  5982. if (IsReadableStreamBYOBRequest(this) === false) {
  5983. throw byobRequestBrandCheckException('respond');
  5984. }
  5985. if (this._associatedReadableByteStreamController === undefined) {
  5986. throw new TypeError('This BYOB request has been invalidated');
  5987. }
  5988. ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten);
  5989. }
  5990. }, {
  5991. key: 'respondWithNewView',
  5992. value: function respondWithNewView(view) {
  5993. if (IsReadableStreamBYOBRequest(this) === false) {
  5994. throw byobRequestBrandCheckException('respond');
  5995. }
  5996. if (this._associatedReadableByteStreamController === undefined) {
  5997. throw new TypeError('This BYOB request has been invalidated');
  5998. }
  5999. if (!ArrayBuffer.isView(view)) {
  6000. throw new TypeError('You can only respond with array buffer views');
  6001. }
  6002. ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
  6003. }
  6004. }, {
  6005. key: 'view',
  6006. get: function get() {
  6007. return this._view;
  6008. }
  6009. }]);
  6010. return ReadableStreamBYOBRequest;
  6011. }();
  6012. var ReadableByteStreamController = function () {
  6013. function ReadableByteStreamController(stream, underlyingByteSource, highWaterMark) {
  6014. _classCallCheck(this, ReadableByteStreamController);
  6015. if (IsReadableStream(stream) === false) {
  6016. throw new TypeError('ReadableByteStreamController can only be constructed with a ReadableStream instance given ' + 'a byte source');
  6017. }
  6018. if (stream._readableStreamController !== undefined) {
  6019. throw new TypeError('ReadableByteStreamController instances can only be created by the ReadableStream constructor given a byte ' + 'source');
  6020. }
  6021. this._controlledReadableStream = stream;
  6022. this._underlyingByteSource = underlyingByteSource;
  6023. this._pullAgain = false;
  6024. this._pulling = false;
  6025. ReadableByteStreamControllerClearPendingPullIntos(this);
  6026. this._queue = this._queueTotalSize = undefined;
  6027. ResetQueue(this);
  6028. this._closeRequested = false;
  6029. this._started = false;
  6030. this._strategyHWM = ValidateAndNormalizeHighWaterMark(highWaterMark);
  6031. var autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
  6032. if (autoAllocateChunkSize !== undefined) {
  6033. if (Number.isInteger(autoAllocateChunkSize) === false || autoAllocateChunkSize <= 0) {
  6034. throw new RangeError('autoAllocateChunkSize must be a positive integer');
  6035. }
  6036. }
  6037. this._autoAllocateChunkSize = autoAllocateChunkSize;
  6038. this._pendingPullIntos = [];
  6039. var controller = this;
  6040. var startResult = InvokeOrNoop(underlyingByteSource, 'start', [this]);
  6041. Promise.resolve(startResult).then(function () {
  6042. controller._started = true;
  6043. assert(controller._pulling === false);
  6044. assert(controller._pullAgain === false);
  6045. ReadableByteStreamControllerCallPullIfNeeded(controller);
  6046. }, function (r) {
  6047. if (stream._state === 'readable') {
  6048. ReadableByteStreamControllerError(controller, r);
  6049. }
  6050. })["catch"](rethrowAssertionErrorRejection);
  6051. }
  6052. _createClass(ReadableByteStreamController, [{
  6053. key: 'close',
  6054. value: function close() {
  6055. if (IsReadableByteStreamController(this) === false) {
  6056. throw byteStreamControllerBrandCheckException('close');
  6057. }
  6058. if (this._closeRequested === true) {
  6059. throw new TypeError('The stream has already been closed; do not close it again!');
  6060. }
  6061. var state = this._controlledReadableStream._state;
  6062. if (state !== 'readable') {
  6063. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be closed');
  6064. }
  6065. ReadableByteStreamControllerClose(this);
  6066. }
  6067. }, {
  6068. key: 'enqueue',
  6069. value: function enqueue(chunk) {
  6070. if (IsReadableByteStreamController(this) === false) {
  6071. throw byteStreamControllerBrandCheckException('enqueue');
  6072. }
  6073. if (this._closeRequested === true) {
  6074. throw new TypeError('stream is closed or draining');
  6075. }
  6076. var state = this._controlledReadableStream._state;
  6077. if (state !== 'readable') {
  6078. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be enqueued to');
  6079. }
  6080. if (!ArrayBuffer.isView(chunk)) {
  6081. throw new TypeError('You can only enqueue array buffer views when using a ReadableByteStreamController');
  6082. }
  6083. ReadableByteStreamControllerEnqueue(this, chunk);
  6084. }
  6085. }, {
  6086. key: 'error',
  6087. value: function error(e) {
  6088. if (IsReadableByteStreamController(this) === false) {
  6089. throw byteStreamControllerBrandCheckException('error');
  6090. }
  6091. var stream = this._controlledReadableStream;
  6092. if (stream._state !== 'readable') {
  6093. throw new TypeError('The stream is ' + stream._state + ' and so cannot be errored');
  6094. }
  6095. ReadableByteStreamControllerError(this, e);
  6096. }
  6097. }, {
  6098. key: '__cancelSteps',
  6099. value: function __cancelSteps(reason) {
  6100. if (this._pendingPullIntos.length > 0) {
  6101. var firstDescriptor = this._pendingPullIntos[0];
  6102. firstDescriptor.bytesFilled = 0;
  6103. }
  6104. ResetQueue(this);
  6105. return PromiseInvokeOrNoop(this._underlyingByteSource, 'cancel', [reason]);
  6106. }
  6107. }, {
  6108. key: '__pullSteps',
  6109. value: function __pullSteps() {
  6110. var stream = this._controlledReadableStream;
  6111. assert(ReadableStreamHasDefaultReader(stream) === true);
  6112. if (this._queueTotalSize > 0) {
  6113. assert(ReadableStreamGetNumReadRequests(stream) === 0);
  6114. var entry = this._queue.shift();
  6115. this._queueTotalSize -= entry.byteLength;
  6116. ReadableByteStreamControllerHandleQueueDrain(this);
  6117. var view = void 0;
  6118. try {
  6119. view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
  6120. } catch (viewE) {
  6121. return Promise.reject(viewE);
  6122. }
  6123. return Promise.resolve(CreateIterResultObject(view, false));
  6124. }
  6125. var autoAllocateChunkSize = this._autoAllocateChunkSize;
  6126. if (autoAllocateChunkSize !== undefined) {
  6127. var buffer = void 0;
  6128. try {
  6129. buffer = new ArrayBuffer(autoAllocateChunkSize);
  6130. } catch (bufferE) {
  6131. return Promise.reject(bufferE);
  6132. }
  6133. var pullIntoDescriptor = {
  6134. buffer: buffer,
  6135. byteOffset: 0,
  6136. byteLength: autoAllocateChunkSize,
  6137. bytesFilled: 0,
  6138. elementSize: 1,
  6139. ctor: Uint8Array,
  6140. readerType: 'default'
  6141. };
  6142. this._pendingPullIntos.push(pullIntoDescriptor);
  6143. }
  6144. var promise = ReadableStreamAddReadRequest(stream);
  6145. ReadableByteStreamControllerCallPullIfNeeded(this);
  6146. return promise;
  6147. }
  6148. }, {
  6149. key: 'byobRequest',
  6150. get: function get() {
  6151. if (IsReadableByteStreamController(this) === false) {
  6152. throw byteStreamControllerBrandCheckException('byobRequest');
  6153. }
  6154. if (this._byobRequest === undefined && this._pendingPullIntos.length > 0) {
  6155. var firstDescriptor = this._pendingPullIntos[0];
  6156. var view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled);
  6157. this._byobRequest = new ReadableStreamBYOBRequest(this, view);
  6158. }
  6159. return this._byobRequest;
  6160. }
  6161. }, {
  6162. key: 'desiredSize',
  6163. get: function get() {
  6164. if (IsReadableByteStreamController(this) === false) {
  6165. throw byteStreamControllerBrandCheckException('desiredSize');
  6166. }
  6167. return ReadableByteStreamControllerGetDesiredSize(this);
  6168. }
  6169. }]);
  6170. return ReadableByteStreamController;
  6171. }();
  6172. function IsReadableByteStreamController(x) {
  6173. if (!typeIsObject(x)) {
  6174. return false;
  6175. }
  6176. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingByteSource')) {
  6177. return false;
  6178. }
  6179. return true;
  6180. }
  6181. function IsReadableStreamBYOBRequest(x) {
  6182. if (!typeIsObject(x)) {
  6183. return false;
  6184. }
  6185. if (!Object.prototype.hasOwnProperty.call(x, '_associatedReadableByteStreamController')) {
  6186. return false;
  6187. }
  6188. return true;
  6189. }
  6190. function ReadableByteStreamControllerCallPullIfNeeded(controller) {
  6191. var shouldPull = ReadableByteStreamControllerShouldCallPull(controller);
  6192. if (shouldPull === false) {
  6193. return undefined;
  6194. }
  6195. if (controller._pulling === true) {
  6196. controller._pullAgain = true;
  6197. return undefined;
  6198. }
  6199. assert(controller._pullAgain === false);
  6200. controller._pulling = true;
  6201. var pullPromise = PromiseInvokeOrNoop(controller._underlyingByteSource, 'pull', [controller]);
  6202. pullPromise.then(function () {
  6203. controller._pulling = false;
  6204. if (controller._pullAgain === true) {
  6205. controller._pullAgain = false;
  6206. ReadableByteStreamControllerCallPullIfNeeded(controller);
  6207. }
  6208. }, function (e) {
  6209. if (controller._controlledReadableStream._state === 'readable') {
  6210. ReadableByteStreamControllerError(controller, e);
  6211. }
  6212. })["catch"](rethrowAssertionErrorRejection);
  6213. return undefined;
  6214. }
  6215. function ReadableByteStreamControllerClearPendingPullIntos(controller) {
  6216. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  6217. controller._pendingPullIntos = [];
  6218. }
  6219. function ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor) {
  6220. assert(stream._state !== 'errored', 'state must not be errored');
  6221. var done = false;
  6222. if (stream._state === 'closed') {
  6223. assert(pullIntoDescriptor.bytesFilled === 0);
  6224. done = true;
  6225. }
  6226. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  6227. if (pullIntoDescriptor.readerType === 'default') {
  6228. ReadableStreamFulfillReadRequest(stream, filledView, done);
  6229. } else {
  6230. assert(pullIntoDescriptor.readerType === 'byob');
  6231. ReadableStreamFulfillReadIntoRequest(stream, filledView, done);
  6232. }
  6233. }
  6234. function ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor) {
  6235. var bytesFilled = pullIntoDescriptor.bytesFilled;
  6236. var elementSize = pullIntoDescriptor.elementSize;
  6237. assert(bytesFilled <= pullIntoDescriptor.byteLength);
  6238. assert(bytesFilled % elementSize === 0);
  6239. return new pullIntoDescriptor.ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, bytesFilled / elementSize);
  6240. }
  6241. function ReadableByteStreamControllerEnqueueChunkToQueue(controller, buffer, byteOffset, byteLength) {
  6242. controller._queue.push({
  6243. buffer: buffer,
  6244. byteOffset: byteOffset,
  6245. byteLength: byteLength
  6246. });
  6247. controller._queueTotalSize += byteLength;
  6248. }
  6249. function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) {
  6250. var elementSize = pullIntoDescriptor.elementSize;
  6251. var currentAlignedBytes = pullIntoDescriptor.bytesFilled - pullIntoDescriptor.bytesFilled % elementSize;
  6252. var maxBytesToCopy = Math.min(controller._queueTotalSize, pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled);
  6253. var maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;
  6254. var maxAlignedBytes = maxBytesFilled - maxBytesFilled % elementSize;
  6255. var totalBytesToCopyRemaining = maxBytesToCopy;
  6256. var ready = false;
  6257. if (maxAlignedBytes > currentAlignedBytes) {
  6258. totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;
  6259. ready = true;
  6260. }
  6261. var queue = controller._queue;
  6262. while (totalBytesToCopyRemaining > 0) {
  6263. var headOfQueue = queue[0];
  6264. var bytesToCopy = Math.min(totalBytesToCopyRemaining, headOfQueue.byteLength);
  6265. var destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  6266. ArrayBufferCopy(pullIntoDescriptor.buffer, destStart, headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy);
  6267. if (headOfQueue.byteLength === bytesToCopy) {
  6268. queue.shift();
  6269. } else {
  6270. headOfQueue.byteOffset += bytesToCopy;
  6271. headOfQueue.byteLength -= bytesToCopy;
  6272. }
  6273. controller._queueTotalSize -= bytesToCopy;
  6274. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesToCopy, pullIntoDescriptor);
  6275. totalBytesToCopyRemaining -= bytesToCopy;
  6276. }
  6277. if (ready === false) {
  6278. assert(controller._queueTotalSize === 0, 'queue must be empty');
  6279. assert(pullIntoDescriptor.bytesFilled > 0);
  6280. assert(pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize);
  6281. }
  6282. return ready;
  6283. }
  6284. function ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, size, pullIntoDescriptor) {
  6285. assert(controller._pendingPullIntos.length === 0 || controller._pendingPullIntos[0] === pullIntoDescriptor);
  6286. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  6287. pullIntoDescriptor.bytesFilled += size;
  6288. }
  6289. function ReadableByteStreamControllerHandleQueueDrain(controller) {
  6290. assert(controller._controlledReadableStream._state === 'readable');
  6291. if (controller._queueTotalSize === 0 && controller._closeRequested === true) {
  6292. ReadableStreamClose(controller._controlledReadableStream);
  6293. } else {
  6294. ReadableByteStreamControllerCallPullIfNeeded(controller);
  6295. }
  6296. }
  6297. function ReadableByteStreamControllerInvalidateBYOBRequest(controller) {
  6298. if (controller._byobRequest === undefined) {
  6299. return;
  6300. }
  6301. controller._byobRequest._associatedReadableByteStreamController = undefined;
  6302. controller._byobRequest._view = undefined;
  6303. controller._byobRequest = undefined;
  6304. }
  6305. function ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller) {
  6306. assert(controller._closeRequested === false);
  6307. while (controller._pendingPullIntos.length > 0) {
  6308. if (controller._queueTotalSize === 0) {
  6309. return;
  6310. }
  6311. var pullIntoDescriptor = controller._pendingPullIntos[0];
  6312. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {
  6313. ReadableByteStreamControllerShiftPendingPullInto(controller);
  6314. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream, pullIntoDescriptor);
  6315. }
  6316. }
  6317. }
  6318. function ReadableByteStreamControllerPullInto(controller, view) {
  6319. var stream = controller._controlledReadableStream;
  6320. var elementSize = 1;
  6321. if (view.constructor !== DataView) {
  6322. elementSize = view.constructor.BYTES_PER_ELEMENT;
  6323. }
  6324. var ctor = view.constructor;
  6325. var pullIntoDescriptor = {
  6326. buffer: view.buffer,
  6327. byteOffset: view.byteOffset,
  6328. byteLength: view.byteLength,
  6329. bytesFilled: 0,
  6330. elementSize: elementSize,
  6331. ctor: ctor,
  6332. readerType: 'byob'
  6333. };
  6334. if (controller._pendingPullIntos.length > 0) {
  6335. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  6336. controller._pendingPullIntos.push(pullIntoDescriptor);
  6337. return ReadableStreamAddReadIntoRequest(stream);
  6338. }
  6339. if (stream._state === 'closed') {
  6340. var emptyView = new view.constructor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);
  6341. return Promise.resolve(CreateIterResultObject(emptyView, true));
  6342. }
  6343. if (controller._queueTotalSize > 0) {
  6344. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {
  6345. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  6346. ReadableByteStreamControllerHandleQueueDrain(controller);
  6347. return Promise.resolve(CreateIterResultObject(filledView, false));
  6348. }
  6349. if (controller._closeRequested === true) {
  6350. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  6351. ReadableByteStreamControllerError(controller, e);
  6352. return Promise.reject(e);
  6353. }
  6354. }
  6355. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  6356. controller._pendingPullIntos.push(pullIntoDescriptor);
  6357. var promise = ReadableStreamAddReadIntoRequest(stream);
  6358. ReadableByteStreamControllerCallPullIfNeeded(controller);
  6359. return promise;
  6360. }
  6361. function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
  6362. firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer);
  6363. assert(firstDescriptor.bytesFilled === 0, 'bytesFilled must be 0');
  6364. var stream = controller._controlledReadableStream;
  6365. if (ReadableStreamHasBYOBReader(stream) === true) {
  6366. while (ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  6367. var pullIntoDescriptor = ReadableByteStreamControllerShiftPendingPullInto(controller);
  6368. ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor);
  6369. }
  6370. }
  6371. }
  6372. function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {
  6373. if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength) {
  6374. throw new RangeError('bytesWritten out of range');
  6375. }
  6376. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor);
  6377. if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) {
  6378. return;
  6379. }
  6380. ReadableByteStreamControllerShiftPendingPullInto(controller);
  6381. var remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
  6382. if (remainderSize > 0) {
  6383. var end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  6384. var remainder = pullIntoDescriptor.buffer.slice(end - remainderSize, end);
  6385. ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength);
  6386. }
  6387. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  6388. pullIntoDescriptor.bytesFilled -= remainderSize;
  6389. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream, pullIntoDescriptor);
  6390. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  6391. }
  6392. function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) {
  6393. var firstDescriptor = controller._pendingPullIntos[0];
  6394. var stream = controller._controlledReadableStream;
  6395. if (stream._state === 'closed') {
  6396. if (bytesWritten !== 0) {
  6397. throw new TypeError('bytesWritten must be 0 when calling respond() on a closed stream');
  6398. }
  6399. ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
  6400. } else {
  6401. assert(stream._state === 'readable');
  6402. ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
  6403. }
  6404. }
  6405. function ReadableByteStreamControllerShiftPendingPullInto(controller) {
  6406. var descriptor = controller._pendingPullIntos.shift();
  6407. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  6408. return descriptor;
  6409. }
  6410. function ReadableByteStreamControllerShouldCallPull(controller) {
  6411. var stream = controller._controlledReadableStream;
  6412. if (stream._state !== 'readable') {
  6413. return false;
  6414. }
  6415. if (controller._closeRequested === true) {
  6416. return false;
  6417. }
  6418. if (controller._started === false) {
  6419. return false;
  6420. }
  6421. if (ReadableStreamHasDefaultReader(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  6422. return true;
  6423. }
  6424. if (ReadableStreamHasBYOBReader(stream) === true && ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  6425. return true;
  6426. }
  6427. if (ReadableByteStreamControllerGetDesiredSize(controller) > 0) {
  6428. return true;
  6429. }
  6430. return false;
  6431. }
  6432. function ReadableByteStreamControllerClose(controller) {
  6433. var stream = controller._controlledReadableStream;
  6434. assert(controller._closeRequested === false);
  6435. assert(stream._state === 'readable');
  6436. if (controller._queueTotalSize > 0) {
  6437. controller._closeRequested = true;
  6438. return;
  6439. }
  6440. if (controller._pendingPullIntos.length > 0) {
  6441. var firstPendingPullInto = controller._pendingPullIntos[0];
  6442. if (firstPendingPullInto.bytesFilled > 0) {
  6443. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  6444. ReadableByteStreamControllerError(controller, e);
  6445. throw e;
  6446. }
  6447. }
  6448. ReadableStreamClose(stream);
  6449. }
  6450. function ReadableByteStreamControllerEnqueue(controller, chunk) {
  6451. var stream = controller._controlledReadableStream;
  6452. assert(controller._closeRequested === false);
  6453. assert(stream._state === 'readable');
  6454. var buffer = chunk.buffer;
  6455. var byteOffset = chunk.byteOffset;
  6456. var byteLength = chunk.byteLength;
  6457. var transferredBuffer = TransferArrayBuffer(buffer);
  6458. if (ReadableStreamHasDefaultReader(stream) === true) {
  6459. if (ReadableStreamGetNumReadRequests(stream) === 0) {
  6460. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  6461. } else {
  6462. assert(controller._queue.length === 0);
  6463. var transferredView = new Uint8Array(transferredBuffer, byteOffset, byteLength);
  6464. ReadableStreamFulfillReadRequest(stream, transferredView, false);
  6465. }
  6466. } else if (ReadableStreamHasBYOBReader(stream) === true) {
  6467. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  6468. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  6469. } else {
  6470. assert(IsReadableStreamLocked(stream) === false, 'stream must not be locked');
  6471. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  6472. }
  6473. }
  6474. function ReadableByteStreamControllerError(controller, e) {
  6475. var stream = controller._controlledReadableStream;
  6476. assert(stream._state === 'readable');
  6477. ReadableByteStreamControllerClearPendingPullIntos(controller);
  6478. ResetQueue(controller);
  6479. ReadableStreamError(stream, e);
  6480. }
  6481. function ReadableByteStreamControllerGetDesiredSize(controller) {
  6482. var stream = controller._controlledReadableStream;
  6483. var state = stream._state;
  6484. if (state === 'errored') {
  6485. return null;
  6486. }
  6487. if (state === 'closed') {
  6488. return 0;
  6489. }
  6490. return controller._strategyHWM - controller._queueTotalSize;
  6491. }
  6492. function ReadableByteStreamControllerRespond(controller, bytesWritten) {
  6493. bytesWritten = Number(bytesWritten);
  6494. if (IsFiniteNonNegativeNumber(bytesWritten) === false) {
  6495. throw new RangeError('bytesWritten must be a finite');
  6496. }
  6497. assert(controller._pendingPullIntos.length > 0);
  6498. ReadableByteStreamControllerRespondInternal(controller, bytesWritten);
  6499. }
  6500. function ReadableByteStreamControllerRespondWithNewView(controller, view) {
  6501. assert(controller._pendingPullIntos.length > 0);
  6502. var firstDescriptor = controller._pendingPullIntos[0];
  6503. if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset) {
  6504. throw new RangeError('The region specified by view does not match byobRequest');
  6505. }
  6506. if (firstDescriptor.byteLength !== view.byteLength) {
  6507. throw new RangeError('The buffer of view has different capacity than byobRequest');
  6508. }
  6509. firstDescriptor.buffer = view.buffer;
  6510. ReadableByteStreamControllerRespondInternal(controller, view.byteLength);
  6511. }
  6512. function streamBrandCheckException(name) {
  6513. return new TypeError('ReadableStream.prototype.' + name + ' can only be used on a ReadableStream');
  6514. }
  6515. function readerLockException(name) {
  6516. return new TypeError('Cannot ' + name + ' a stream using a released reader');
  6517. }
  6518. function defaultReaderBrandCheckException(name) {
  6519. return new TypeError('ReadableStreamDefaultReader.prototype.' + name + ' can only be used on a ReadableStreamDefaultReader');
  6520. }
  6521. function defaultReaderClosedPromiseInitialize(reader) {
  6522. reader._closedPromise = new Promise(function (resolve, reject) {
  6523. reader._closedPromise_resolve = resolve;
  6524. reader._closedPromise_reject = reject;
  6525. });
  6526. }
  6527. function defaultReaderClosedPromiseInitializeAsRejected(reader, reason) {
  6528. reader._closedPromise = Promise.reject(reason);
  6529. reader._closedPromise_resolve = undefined;
  6530. reader._closedPromise_reject = undefined;
  6531. }
  6532. function defaultReaderClosedPromiseInitializeAsResolved(reader) {
  6533. reader._closedPromise = Promise.resolve(undefined);
  6534. reader._closedPromise_resolve = undefined;
  6535. reader._closedPromise_reject = undefined;
  6536. }
  6537. function defaultReaderClosedPromiseReject(reader, reason) {
  6538. assert(reader._closedPromise_resolve !== undefined);
  6539. assert(reader._closedPromise_reject !== undefined);
  6540. reader._closedPromise_reject(reason);
  6541. reader._closedPromise_resolve = undefined;
  6542. reader._closedPromise_reject = undefined;
  6543. }
  6544. function defaultReaderClosedPromiseResetToRejected(reader, reason) {
  6545. assert(reader._closedPromise_resolve === undefined);
  6546. assert(reader._closedPromise_reject === undefined);
  6547. reader._closedPromise = Promise.reject(reason);
  6548. }
  6549. function defaultReaderClosedPromiseResolve(reader) {
  6550. assert(reader._closedPromise_resolve !== undefined);
  6551. assert(reader._closedPromise_reject !== undefined);
  6552. reader._closedPromise_resolve(undefined);
  6553. reader._closedPromise_resolve = undefined;
  6554. reader._closedPromise_reject = undefined;
  6555. }
  6556. function byobReaderBrandCheckException(name) {
  6557. return new TypeError('ReadableStreamBYOBReader.prototype.' + name + ' can only be used on a ReadableStreamBYOBReader');
  6558. }
  6559. function defaultControllerBrandCheckException(name) {
  6560. return new TypeError('ReadableStreamDefaultController.prototype.' + name + ' can only be used on a ReadableStreamDefaultController');
  6561. }
  6562. function byobRequestBrandCheckException(name) {
  6563. return new TypeError('ReadableStreamBYOBRequest.prototype.' + name + ' can only be used on a ReadableStreamBYOBRequest');
  6564. }
  6565. function byteStreamControllerBrandCheckException(name) {
  6566. return new TypeError('ReadableByteStreamController.prototype.' + name + ' can only be used on a ReadableByteStreamController');
  6567. }
  6568. function ifIsObjectAndHasAPromiseIsHandledInternalSlotSetPromiseIsHandledToTrue(promise) {
  6569. try {
  6570. Promise.prototype.then.call(promise, undefined, function () {});
  6571. } catch (e) {}
  6572. }
  6573. }, function (module, exports, __w_pdfjs_require__) {
  6574. "use strict";
  6575. var transformStream = __w_pdfjs_require__(6);
  6576. var readableStream = __w_pdfjs_require__(4);
  6577. var writableStream = __w_pdfjs_require__(2);
  6578. exports.TransformStream = transformStream.TransformStream;
  6579. exports.ReadableStream = readableStream.ReadableStream;
  6580. exports.IsReadableStreamDisturbed = readableStream.IsReadableStreamDisturbed;
  6581. exports.ReadableStreamDefaultControllerClose = readableStream.ReadableStreamDefaultControllerClose;
  6582. exports.ReadableStreamDefaultControllerEnqueue = readableStream.ReadableStreamDefaultControllerEnqueue;
  6583. exports.ReadableStreamDefaultControllerError = readableStream.ReadableStreamDefaultControllerError;
  6584. exports.ReadableStreamDefaultControllerGetDesiredSize = readableStream.ReadableStreamDefaultControllerGetDesiredSize;
  6585. exports.AcquireWritableStreamDefaultWriter = writableStream.AcquireWritableStreamDefaultWriter;
  6586. exports.IsWritableStream = writableStream.IsWritableStream;
  6587. exports.IsWritableStreamLocked = writableStream.IsWritableStreamLocked;
  6588. exports.WritableStream = writableStream.WritableStream;
  6589. exports.WritableStreamAbort = writableStream.WritableStreamAbort;
  6590. exports.WritableStreamDefaultControllerError = writableStream.WritableStreamDefaultControllerError;
  6591. exports.WritableStreamDefaultWriterCloseWithErrorPropagation = writableStream.WritableStreamDefaultWriterCloseWithErrorPropagation;
  6592. exports.WritableStreamDefaultWriterRelease = writableStream.WritableStreamDefaultWriterRelease;
  6593. exports.WritableStreamDefaultWriterWrite = writableStream.WritableStreamDefaultWriterWrite;
  6594. }, function (module, exports, __w_pdfjs_require__) {
  6595. "use strict";
  6596. var _createClass = function () {
  6597. function defineProperties(target, props) {
  6598. for (var i = 0; i < props.length; i++) {
  6599. var descriptor = props[i];
  6600. descriptor.enumerable = descriptor.enumerable || false;
  6601. descriptor.configurable = true;
  6602. if ("value" in descriptor) descriptor.writable = true;
  6603. Object.defineProperty(target, descriptor.key, descriptor);
  6604. }
  6605. }
  6606. return function (Constructor, protoProps, staticProps) {
  6607. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  6608. if (staticProps) defineProperties(Constructor, staticProps);
  6609. return Constructor;
  6610. };
  6611. }();
  6612. function _classCallCheck(instance, Constructor) {
  6613. if (!(instance instanceof Constructor)) {
  6614. throw new TypeError("Cannot call a class as a function");
  6615. }
  6616. }
  6617. var _require = __w_pdfjs_require__(1),
  6618. assert = _require.assert;
  6619. var _require2 = __w_pdfjs_require__(0),
  6620. InvokeOrNoop = _require2.InvokeOrNoop,
  6621. PromiseInvokeOrPerformFallback = _require2.PromiseInvokeOrPerformFallback,
  6622. PromiseInvokeOrNoop = _require2.PromiseInvokeOrNoop,
  6623. typeIsObject = _require2.typeIsObject;
  6624. var _require3 = __w_pdfjs_require__(4),
  6625. ReadableStream = _require3.ReadableStream,
  6626. ReadableStreamDefaultControllerClose = _require3.ReadableStreamDefaultControllerClose,
  6627. ReadableStreamDefaultControllerEnqueue = _require3.ReadableStreamDefaultControllerEnqueue,
  6628. ReadableStreamDefaultControllerError = _require3.ReadableStreamDefaultControllerError,
  6629. ReadableStreamDefaultControllerGetDesiredSize = _require3.ReadableStreamDefaultControllerGetDesiredSize;
  6630. var _require4 = __w_pdfjs_require__(2),
  6631. WritableStream = _require4.WritableStream,
  6632. WritableStreamDefaultControllerError = _require4.WritableStreamDefaultControllerError;
  6633. function TransformStreamCloseReadable(transformStream) {
  6634. if (transformStream._errored === true) {
  6635. throw new TypeError('TransformStream is already errored');
  6636. }
  6637. if (transformStream._readableClosed === true) {
  6638. throw new TypeError('Readable side is already closed');
  6639. }
  6640. TransformStreamCloseReadableInternal(transformStream);
  6641. }
  6642. function TransformStreamEnqueueToReadable(transformStream, chunk) {
  6643. if (transformStream._errored === true) {
  6644. throw new TypeError('TransformStream is already errored');
  6645. }
  6646. if (transformStream._readableClosed === true) {
  6647. throw new TypeError('Readable side is already closed');
  6648. }
  6649. var controller = transformStream._readableController;
  6650. try {
  6651. ReadableStreamDefaultControllerEnqueue(controller, chunk);
  6652. } catch (e) {
  6653. transformStream._readableClosed = true;
  6654. TransformStreamErrorIfNeeded(transformStream, e);
  6655. throw transformStream._storedError;
  6656. }
  6657. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);
  6658. var maybeBackpressure = desiredSize <= 0;
  6659. if (maybeBackpressure === true && transformStream._backpressure === false) {
  6660. TransformStreamSetBackpressure(transformStream, true);
  6661. }
  6662. }
  6663. function TransformStreamError(transformStream, e) {
  6664. if (transformStream._errored === true) {
  6665. throw new TypeError('TransformStream is already errored');
  6666. }
  6667. TransformStreamErrorInternal(transformStream, e);
  6668. }
  6669. function TransformStreamCloseReadableInternal(transformStream) {
  6670. assert(transformStream._errored === false);
  6671. assert(transformStream._readableClosed === false);
  6672. try {
  6673. ReadableStreamDefaultControllerClose(transformStream._readableController);
  6674. } catch (e) {
  6675. assert(false);
  6676. }
  6677. transformStream._readableClosed = true;
  6678. }
  6679. function TransformStreamErrorIfNeeded(transformStream, e) {
  6680. if (transformStream._errored === false) {
  6681. TransformStreamErrorInternal(transformStream, e);
  6682. }
  6683. }
  6684. function TransformStreamErrorInternal(transformStream, e) {
  6685. assert(transformStream._errored === false);
  6686. transformStream._errored = true;
  6687. transformStream._storedError = e;
  6688. if (transformStream._writableDone === false) {
  6689. WritableStreamDefaultControllerError(transformStream._writableController, e);
  6690. }
  6691. if (transformStream._readableClosed === false) {
  6692. ReadableStreamDefaultControllerError(transformStream._readableController, e);
  6693. }
  6694. }
  6695. function TransformStreamReadableReadyPromise(transformStream) {
  6696. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  6697. if (transformStream._backpressure === false) {
  6698. return Promise.resolve();
  6699. }
  6700. assert(transformStream._backpressure === true, '_backpressure should have been initialized');
  6701. return transformStream._backpressureChangePromise;
  6702. }
  6703. function TransformStreamSetBackpressure(transformStream, backpressure) {
  6704. assert(transformStream._backpressure !== backpressure, 'TransformStreamSetBackpressure() should be called only when backpressure is changed');
  6705. if (transformStream._backpressureChangePromise !== undefined) {
  6706. transformStream._backpressureChangePromise_resolve(backpressure);
  6707. }
  6708. transformStream._backpressureChangePromise = new Promise(function (resolve) {
  6709. transformStream._backpressureChangePromise_resolve = resolve;
  6710. });
  6711. transformStream._backpressureChangePromise.then(function (resolution) {
  6712. assert(resolution !== backpressure, '_backpressureChangePromise should be fulfilled only when backpressure is changed');
  6713. });
  6714. transformStream._backpressure = backpressure;
  6715. }
  6716. function TransformStreamDefaultTransform(chunk, transformStreamController) {
  6717. var transformStream = transformStreamController._controlledTransformStream;
  6718. TransformStreamEnqueueToReadable(transformStream, chunk);
  6719. return Promise.resolve();
  6720. }
  6721. function TransformStreamTransform(transformStream, chunk) {
  6722. assert(transformStream._errored === false);
  6723. assert(transformStream._transforming === false);
  6724. assert(transformStream._backpressure === false);
  6725. transformStream._transforming = true;
  6726. var transformer = transformStream._transformer;
  6727. var controller = transformStream._transformStreamController;
  6728. var transformPromise = PromiseInvokeOrPerformFallback(transformer, 'transform', [chunk, controller], TransformStreamDefaultTransform, [chunk, controller]);
  6729. return transformPromise.then(function () {
  6730. transformStream._transforming = false;
  6731. return TransformStreamReadableReadyPromise(transformStream);
  6732. }, function (e) {
  6733. TransformStreamErrorIfNeeded(transformStream, e);
  6734. return Promise.reject(e);
  6735. });
  6736. }
  6737. function IsTransformStreamDefaultController(x) {
  6738. if (!typeIsObject(x)) {
  6739. return false;
  6740. }
  6741. if (!Object.prototype.hasOwnProperty.call(x, '_controlledTransformStream')) {
  6742. return false;
  6743. }
  6744. return true;
  6745. }
  6746. function IsTransformStream(x) {
  6747. if (!typeIsObject(x)) {
  6748. return false;
  6749. }
  6750. if (!Object.prototype.hasOwnProperty.call(x, '_transformStreamController')) {
  6751. return false;
  6752. }
  6753. return true;
  6754. }
  6755. var TransformStreamSink = function () {
  6756. function TransformStreamSink(transformStream, startPromise) {
  6757. _classCallCheck(this, TransformStreamSink);
  6758. this._transformStream = transformStream;
  6759. this._startPromise = startPromise;
  6760. }
  6761. _createClass(TransformStreamSink, [{
  6762. key: 'start',
  6763. value: function start(c) {
  6764. var transformStream = this._transformStream;
  6765. transformStream._writableController = c;
  6766. return this._startPromise.then(function () {
  6767. return TransformStreamReadableReadyPromise(transformStream);
  6768. });
  6769. }
  6770. }, {
  6771. key: 'write',
  6772. value: function write(chunk) {
  6773. var transformStream = this._transformStream;
  6774. return TransformStreamTransform(transformStream, chunk);
  6775. }
  6776. }, {
  6777. key: 'abort',
  6778. value: function abort() {
  6779. var transformStream = this._transformStream;
  6780. transformStream._writableDone = true;
  6781. TransformStreamErrorInternal(transformStream, new TypeError('Writable side aborted'));
  6782. }
  6783. }, {
  6784. key: 'close',
  6785. value: function close() {
  6786. var transformStream = this._transformStream;
  6787. assert(transformStream._transforming === false);
  6788. transformStream._writableDone = true;
  6789. var flushPromise = PromiseInvokeOrNoop(transformStream._transformer, 'flush', [transformStream._transformStreamController]);
  6790. return flushPromise.then(function () {
  6791. if (transformStream._errored === true) {
  6792. return Promise.reject(transformStream._storedError);
  6793. }
  6794. if (transformStream._readableClosed === false) {
  6795. TransformStreamCloseReadableInternal(transformStream);
  6796. }
  6797. return Promise.resolve();
  6798. })["catch"](function (r) {
  6799. TransformStreamErrorIfNeeded(transformStream, r);
  6800. return Promise.reject(transformStream._storedError);
  6801. });
  6802. }
  6803. }]);
  6804. return TransformStreamSink;
  6805. }();
  6806. var TransformStreamSource = function () {
  6807. function TransformStreamSource(transformStream, startPromise) {
  6808. _classCallCheck(this, TransformStreamSource);
  6809. this._transformStream = transformStream;
  6810. this._startPromise = startPromise;
  6811. }
  6812. _createClass(TransformStreamSource, [{
  6813. key: 'start',
  6814. value: function start(c) {
  6815. var transformStream = this._transformStream;
  6816. transformStream._readableController = c;
  6817. return this._startPromise.then(function () {
  6818. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  6819. if (transformStream._backpressure === true) {
  6820. return Promise.resolve();
  6821. }
  6822. assert(transformStream._backpressure === false, '_backpressure should have been initialized');
  6823. return transformStream._backpressureChangePromise;
  6824. });
  6825. }
  6826. }, {
  6827. key: 'pull',
  6828. value: function pull() {
  6829. var transformStream = this._transformStream;
  6830. assert(transformStream._backpressure === true, 'pull() should be never called while _backpressure is false');
  6831. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  6832. TransformStreamSetBackpressure(transformStream, false);
  6833. return transformStream._backpressureChangePromise;
  6834. }
  6835. }, {
  6836. key: 'cancel',
  6837. value: function cancel() {
  6838. var transformStream = this._transformStream;
  6839. transformStream._readableClosed = true;
  6840. TransformStreamErrorInternal(transformStream, new TypeError('Readable side canceled'));
  6841. }
  6842. }]);
  6843. return TransformStreamSource;
  6844. }();
  6845. var TransformStreamDefaultController = function () {
  6846. function TransformStreamDefaultController(transformStream) {
  6847. _classCallCheck(this, TransformStreamDefaultController);
  6848. if (IsTransformStream(transformStream) === false) {
  6849. throw new TypeError('TransformStreamDefaultController can only be ' + 'constructed with a TransformStream instance');
  6850. }
  6851. if (transformStream._transformStreamController !== undefined) {
  6852. throw new TypeError('TransformStreamDefaultController instances can ' + 'only be created by the TransformStream constructor');
  6853. }
  6854. this._controlledTransformStream = transformStream;
  6855. }
  6856. _createClass(TransformStreamDefaultController, [{
  6857. key: 'enqueue',
  6858. value: function enqueue(chunk) {
  6859. if (IsTransformStreamDefaultController(this) === false) {
  6860. throw defaultControllerBrandCheckException('enqueue');
  6861. }
  6862. TransformStreamEnqueueToReadable(this._controlledTransformStream, chunk);
  6863. }
  6864. }, {
  6865. key: 'close',
  6866. value: function close() {
  6867. if (IsTransformStreamDefaultController(this) === false) {
  6868. throw defaultControllerBrandCheckException('close');
  6869. }
  6870. TransformStreamCloseReadable(this._controlledTransformStream);
  6871. }
  6872. }, {
  6873. key: 'error',
  6874. value: function error(reason) {
  6875. if (IsTransformStreamDefaultController(this) === false) {
  6876. throw defaultControllerBrandCheckException('error');
  6877. }
  6878. TransformStreamError(this._controlledTransformStream, reason);
  6879. }
  6880. }, {
  6881. key: 'desiredSize',
  6882. get: function get() {
  6883. if (IsTransformStreamDefaultController(this) === false) {
  6884. throw defaultControllerBrandCheckException('desiredSize');
  6885. }
  6886. var transformStream = this._controlledTransformStream;
  6887. var readableController = transformStream._readableController;
  6888. return ReadableStreamDefaultControllerGetDesiredSize(readableController);
  6889. }
  6890. }]);
  6891. return TransformStreamDefaultController;
  6892. }();
  6893. var TransformStream = function () {
  6894. function TransformStream() {
  6895. var transformer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  6896. _classCallCheck(this, TransformStream);
  6897. this._transformer = transformer;
  6898. var readableStrategy = transformer.readableStrategy,
  6899. writableStrategy = transformer.writableStrategy;
  6900. this._transforming = false;
  6901. this._errored = false;
  6902. this._storedError = undefined;
  6903. this._writableController = undefined;
  6904. this._readableController = undefined;
  6905. this._transformStreamController = undefined;
  6906. this._writableDone = false;
  6907. this._readableClosed = false;
  6908. this._backpressure = undefined;
  6909. this._backpressureChangePromise = undefined;
  6910. this._backpressureChangePromise_resolve = undefined;
  6911. this._transformStreamController = new TransformStreamDefaultController(this);
  6912. var startPromise_resolve = void 0;
  6913. var startPromise = new Promise(function (resolve) {
  6914. startPromise_resolve = resolve;
  6915. });
  6916. var source = new TransformStreamSource(this, startPromise);
  6917. this._readable = new ReadableStream(source, readableStrategy);
  6918. var sink = new TransformStreamSink(this, startPromise);
  6919. this._writable = new WritableStream(sink, writableStrategy);
  6920. assert(this._writableController !== undefined);
  6921. assert(this._readableController !== undefined);
  6922. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(this._readableController);
  6923. TransformStreamSetBackpressure(this, desiredSize <= 0);
  6924. var transformStream = this;
  6925. var startResult = InvokeOrNoop(transformer, 'start', [transformStream._transformStreamController]);
  6926. startPromise_resolve(startResult);
  6927. startPromise["catch"](function (e) {
  6928. if (transformStream._errored === false) {
  6929. transformStream._errored = true;
  6930. transformStream._storedError = e;
  6931. }
  6932. });
  6933. }
  6934. _createClass(TransformStream, [{
  6935. key: 'readable',
  6936. get: function get() {
  6937. if (IsTransformStream(this) === false) {
  6938. throw streamBrandCheckException('readable');
  6939. }
  6940. return this._readable;
  6941. }
  6942. }, {
  6943. key: 'writable',
  6944. get: function get() {
  6945. if (IsTransformStream(this) === false) {
  6946. throw streamBrandCheckException('writable');
  6947. }
  6948. return this._writable;
  6949. }
  6950. }]);
  6951. return TransformStream;
  6952. }();
  6953. module.exports = {
  6954. TransformStream: TransformStream
  6955. };
  6956. function defaultControllerBrandCheckException(name) {
  6957. return new TypeError('TransformStreamDefaultController.prototype.' + name + ' can only be used on a TransformStreamDefaultController');
  6958. }
  6959. function streamBrandCheckException(name) {
  6960. return new TypeError('TransformStream.prototype.' + name + ' can only be used on a TransformStream');
  6961. }
  6962. }, function (module, exports, __w_pdfjs_require__) {
  6963. module.exports = __w_pdfjs_require__(5);
  6964. }]));
  6965. /***/ }),
  6966. /* 145 */
  6967. /***/ (function(module, exports, __w_pdfjs_require__) {
  6968. "use strict";
  6969. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  6970. {
  6971. var isURLSupported = false;
  6972. try {
  6973. if (typeof URL === 'function' && _typeof(URL.prototype) === 'object' && 'origin' in URL.prototype) {
  6974. var u = new URL('b', 'http://a');
  6975. u.pathname = 'c%20d';
  6976. isURLSupported = u.href === 'http://a/c%20d';
  6977. }
  6978. } catch (ex) {}
  6979. if (isURLSupported) {
  6980. exports.URL = URL;
  6981. } else {
  6982. var PolyfillURL = __w_pdfjs_require__(146).URL;
  6983. var OriginalURL = __w_pdfjs_require__(3).URL;
  6984. if (OriginalURL) {
  6985. PolyfillURL.createObjectURL = function (blob) {
  6986. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  6987. };
  6988. PolyfillURL.revokeObjectURL = function (url) {
  6989. OriginalURL.revokeObjectURL(url);
  6990. };
  6991. }
  6992. exports.URL = PolyfillURL;
  6993. }
  6994. }
  6995. /***/ }),
  6996. /* 146 */
  6997. /***/ (function(module, exports, __w_pdfjs_require__) {
  6998. "use strict";
  6999. (function URLConstructorClosure() {
  7000. 'use strict';
  7001. var relative = Object.create(null);
  7002. relative['ftp'] = 21;
  7003. relative['file'] = 0;
  7004. relative['gopher'] = 70;
  7005. relative['http'] = 80;
  7006. relative['https'] = 443;
  7007. relative['ws'] = 80;
  7008. relative['wss'] = 443;
  7009. var relativePathDotMapping = Object.create(null);
  7010. relativePathDotMapping['%2e'] = '.';
  7011. relativePathDotMapping['.%2e'] = '..';
  7012. relativePathDotMapping['%2e.'] = '..';
  7013. relativePathDotMapping['%2e%2e'] = '..';
  7014. function isRelativeScheme(scheme) {
  7015. return relative[scheme] !== undefined;
  7016. }
  7017. function invalid() {
  7018. clear.call(this);
  7019. this._isInvalid = true;
  7020. }
  7021. function IDNAToASCII(h) {
  7022. if (h === '') {
  7023. invalid.call(this);
  7024. }
  7025. return h.toLowerCase();
  7026. }
  7027. function percentEscape(c) {
  7028. var unicode = c.charCodeAt(0);
  7029. if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) === -1) {
  7030. return c;
  7031. }
  7032. return encodeURIComponent(c);
  7033. }
  7034. function percentEscapeQuery(c) {
  7035. var unicode = c.charCodeAt(0);
  7036. if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) === -1) {
  7037. return c;
  7038. }
  7039. return encodeURIComponent(c);
  7040. }
  7041. var EOF,
  7042. ALPHA = /[a-zA-Z]/,
  7043. ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  7044. function parse(input, stateOverride, base) {
  7045. function err(message) {
  7046. errors.push(message);
  7047. }
  7048. var state = stateOverride || 'scheme start',
  7049. cursor = 0,
  7050. buffer = '',
  7051. seenAt = false,
  7052. seenBracket = false,
  7053. errors = [];
  7054. loop: while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  7055. var c = input[cursor];
  7056. switch (state) {
  7057. case 'scheme start':
  7058. if (c && ALPHA.test(c)) {
  7059. buffer += c.toLowerCase();
  7060. state = 'scheme';
  7061. } else if (!stateOverride) {
  7062. buffer = '';
  7063. state = 'no scheme';
  7064. continue;
  7065. } else {
  7066. err('Invalid scheme.');
  7067. break loop;
  7068. }
  7069. break;
  7070. case 'scheme':
  7071. if (c && ALPHANUMERIC.test(c)) {
  7072. buffer += c.toLowerCase();
  7073. } else if (c === ':') {
  7074. this._scheme = buffer;
  7075. buffer = '';
  7076. if (stateOverride) {
  7077. break loop;
  7078. }
  7079. if (isRelativeScheme(this._scheme)) {
  7080. this._isRelative = true;
  7081. }
  7082. if (this._scheme === 'file') {
  7083. state = 'relative';
  7084. } else if (this._isRelative && base && base._scheme === this._scheme) {
  7085. state = 'relative or authority';
  7086. } else if (this._isRelative) {
  7087. state = 'authority first slash';
  7088. } else {
  7089. state = 'scheme data';
  7090. }
  7091. } else if (!stateOverride) {
  7092. buffer = '';
  7093. cursor = 0;
  7094. state = 'no scheme';
  7095. continue;
  7096. } else if (c === EOF) {
  7097. break loop;
  7098. } else {
  7099. err('Code point not allowed in scheme: ' + c);
  7100. break loop;
  7101. }
  7102. break;
  7103. case 'scheme data':
  7104. if (c === '?') {
  7105. this._query = '?';
  7106. state = 'query';
  7107. } else if (c === '#') {
  7108. this._fragment = '#';
  7109. state = 'fragment';
  7110. } else {
  7111. if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  7112. this._schemeData += percentEscape(c);
  7113. }
  7114. }
  7115. break;
  7116. case 'no scheme':
  7117. if (!base || !isRelativeScheme(base._scheme)) {
  7118. err('Missing scheme.');
  7119. invalid.call(this);
  7120. } else {
  7121. state = 'relative';
  7122. continue;
  7123. }
  7124. break;
  7125. case 'relative or authority':
  7126. if (c === '/' && input[cursor + 1] === '/') {
  7127. state = 'authority ignore slashes';
  7128. } else {
  7129. err('Expected /, got: ' + c);
  7130. state = 'relative';
  7131. continue;
  7132. }
  7133. break;
  7134. case 'relative':
  7135. this._isRelative = true;
  7136. if (this._scheme !== 'file') {
  7137. this._scheme = base._scheme;
  7138. }
  7139. if (c === EOF) {
  7140. this._host = base._host;
  7141. this._port = base._port;
  7142. this._path = base._path.slice();
  7143. this._query = base._query;
  7144. this._username = base._username;
  7145. this._password = base._password;
  7146. break loop;
  7147. } else if (c === '/' || c === '\\') {
  7148. if (c === '\\') {
  7149. err('\\ is an invalid code point.');
  7150. }
  7151. state = 'relative slash';
  7152. } else if (c === '?') {
  7153. this._host = base._host;
  7154. this._port = base._port;
  7155. this._path = base._path.slice();
  7156. this._query = '?';
  7157. this._username = base._username;
  7158. this._password = base._password;
  7159. state = 'query';
  7160. } else if (c === '#') {
  7161. this._host = base._host;
  7162. this._port = base._port;
  7163. this._path = base._path.slice();
  7164. this._query = base._query;
  7165. this._fragment = '#';
  7166. this._username = base._username;
  7167. this._password = base._password;
  7168. state = 'fragment';
  7169. } else {
  7170. var nextC = input[cursor + 1];
  7171. var nextNextC = input[cursor + 2];
  7172. if (this._scheme !== 'file' || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || nextNextC !== EOF && nextNextC !== '/' && nextNextC !== '\\' && nextNextC !== '?' && nextNextC !== '#') {
  7173. this._host = base._host;
  7174. this._port = base._port;
  7175. this._username = base._username;
  7176. this._password = base._password;
  7177. this._path = base._path.slice();
  7178. this._path.pop();
  7179. }
  7180. state = 'relative path';
  7181. continue;
  7182. }
  7183. break;
  7184. case 'relative slash':
  7185. if (c === '/' || c === '\\') {
  7186. if (c === '\\') {
  7187. err('\\ is an invalid code point.');
  7188. }
  7189. if (this._scheme === 'file') {
  7190. state = 'file host';
  7191. } else {
  7192. state = 'authority ignore slashes';
  7193. }
  7194. } else {
  7195. if (this._scheme !== 'file') {
  7196. this._host = base._host;
  7197. this._port = base._port;
  7198. this._username = base._username;
  7199. this._password = base._password;
  7200. }
  7201. state = 'relative path';
  7202. continue;
  7203. }
  7204. break;
  7205. case 'authority first slash':
  7206. if (c === '/') {
  7207. state = 'authority second slash';
  7208. } else {
  7209. err('Expected \'/\', got: ' + c);
  7210. state = 'authority ignore slashes';
  7211. continue;
  7212. }
  7213. break;
  7214. case 'authority second slash':
  7215. state = 'authority ignore slashes';
  7216. if (c !== '/') {
  7217. err('Expected \'/\', got: ' + c);
  7218. continue;
  7219. }
  7220. break;
  7221. case 'authority ignore slashes':
  7222. if (c !== '/' && c !== '\\') {
  7223. state = 'authority';
  7224. continue;
  7225. } else {
  7226. err('Expected authority, got: ' + c);
  7227. }
  7228. break;
  7229. case 'authority':
  7230. if (c === '@') {
  7231. if (seenAt) {
  7232. err('@ already seen.');
  7233. buffer += '%40';
  7234. }
  7235. seenAt = true;
  7236. for (var i = 0; i < buffer.length; i++) {
  7237. var cp = buffer[i];
  7238. if (cp === '\t' || cp === '\n' || cp === '\r') {
  7239. err('Invalid whitespace in authority.');
  7240. continue;
  7241. }
  7242. if (cp === ':' && this._password === null) {
  7243. this._password = '';
  7244. continue;
  7245. }
  7246. var tempC = percentEscape(cp);
  7247. if (this._password !== null) {
  7248. this._password += tempC;
  7249. } else {
  7250. this._username += tempC;
  7251. }
  7252. }
  7253. buffer = '';
  7254. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  7255. cursor -= buffer.length;
  7256. buffer = '';
  7257. state = 'host';
  7258. continue;
  7259. } else {
  7260. buffer += c;
  7261. }
  7262. break;
  7263. case 'file host':
  7264. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  7265. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  7266. state = 'relative path';
  7267. } else if (buffer.length === 0) {
  7268. state = 'relative path start';
  7269. } else {
  7270. this._host = IDNAToASCII.call(this, buffer);
  7271. buffer = '';
  7272. state = 'relative path start';
  7273. }
  7274. continue;
  7275. } else if (c === '\t' || c === '\n' || c === '\r') {
  7276. err('Invalid whitespace in file host.');
  7277. } else {
  7278. buffer += c;
  7279. }
  7280. break;
  7281. case 'host':
  7282. case 'hostname':
  7283. if (c === ':' && !seenBracket) {
  7284. this._host = IDNAToASCII.call(this, buffer);
  7285. buffer = '';
  7286. state = 'port';
  7287. if (stateOverride === 'hostname') {
  7288. break loop;
  7289. }
  7290. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  7291. this._host = IDNAToASCII.call(this, buffer);
  7292. buffer = '';
  7293. state = 'relative path start';
  7294. if (stateOverride) {
  7295. break loop;
  7296. }
  7297. continue;
  7298. } else if (c !== '\t' && c !== '\n' && c !== '\r') {
  7299. if (c === '[') {
  7300. seenBracket = true;
  7301. } else if (c === ']') {
  7302. seenBracket = false;
  7303. }
  7304. buffer += c;
  7305. } else {
  7306. err('Invalid code point in host/hostname: ' + c);
  7307. }
  7308. break;
  7309. case 'port':
  7310. if (/[0-9]/.test(c)) {
  7311. buffer += c;
  7312. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  7313. if (buffer !== '') {
  7314. var temp = parseInt(buffer, 10);
  7315. if (temp !== relative[this._scheme]) {
  7316. this._port = temp + '';
  7317. }
  7318. buffer = '';
  7319. }
  7320. if (stateOverride) {
  7321. break loop;
  7322. }
  7323. state = 'relative path start';
  7324. continue;
  7325. } else if (c === '\t' || c === '\n' || c === '\r') {
  7326. err('Invalid code point in port: ' + c);
  7327. } else {
  7328. invalid.call(this);
  7329. }
  7330. break;
  7331. case 'relative path start':
  7332. if (c === '\\') {
  7333. err('\'\\\' not allowed in path.');
  7334. }
  7335. state = 'relative path';
  7336. if (c !== '/' && c !== '\\') {
  7337. continue;
  7338. }
  7339. break;
  7340. case 'relative path':
  7341. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  7342. if (c === '\\') {
  7343. err('\\ not allowed in relative path.');
  7344. }
  7345. var tmp;
  7346. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  7347. buffer = tmp;
  7348. }
  7349. if (buffer === '..') {
  7350. this._path.pop();
  7351. if (c !== '/' && c !== '\\') {
  7352. this._path.push('');
  7353. }
  7354. } else if (buffer === '.' && c !== '/' && c !== '\\') {
  7355. this._path.push('');
  7356. } else if (buffer !== '.') {
  7357. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  7358. buffer = buffer[0] + ':';
  7359. }
  7360. this._path.push(buffer);
  7361. }
  7362. buffer = '';
  7363. if (c === '?') {
  7364. this._query = '?';
  7365. state = 'query';
  7366. } else if (c === '#') {
  7367. this._fragment = '#';
  7368. state = 'fragment';
  7369. }
  7370. } else if (c !== '\t' && c !== '\n' && c !== '\r') {
  7371. buffer += percentEscape(c);
  7372. }
  7373. break;
  7374. case 'query':
  7375. if (!stateOverride && c === '#') {
  7376. this._fragment = '#';
  7377. state = 'fragment';
  7378. } else if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  7379. this._query += percentEscapeQuery(c);
  7380. }
  7381. break;
  7382. case 'fragment':
  7383. if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  7384. this._fragment += c;
  7385. }
  7386. break;
  7387. }
  7388. cursor++;
  7389. }
  7390. }
  7391. function clear() {
  7392. this._scheme = '';
  7393. this._schemeData = '';
  7394. this._username = '';
  7395. this._password = null;
  7396. this._host = '';
  7397. this._port = '';
  7398. this._path = [];
  7399. this._query = '';
  7400. this._fragment = '';
  7401. this._isInvalid = false;
  7402. this._isRelative = false;
  7403. }
  7404. function JURL(url, base) {
  7405. if (base !== undefined && !(base instanceof JURL)) {
  7406. base = new JURL(String(base));
  7407. }
  7408. this._url = url;
  7409. clear.call(this);
  7410. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  7411. parse.call(this, input, null, base);
  7412. }
  7413. JURL.prototype = {
  7414. toString: function toString() {
  7415. return this.href;
  7416. },
  7417. get href() {
  7418. if (this._isInvalid) {
  7419. return this._url;
  7420. }
  7421. var authority = '';
  7422. if (this._username !== '' || this._password !== null) {
  7423. authority = this._username + (this._password !== null ? ':' + this._password : '') + '@';
  7424. }
  7425. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  7426. },
  7427. set href(value) {
  7428. clear.call(this);
  7429. parse.call(this, value);
  7430. },
  7431. get protocol() {
  7432. return this._scheme + ':';
  7433. },
  7434. set protocol(value) {
  7435. if (this._isInvalid) {
  7436. return;
  7437. }
  7438. parse.call(this, value + ':', 'scheme start');
  7439. },
  7440. get host() {
  7441. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  7442. },
  7443. set host(value) {
  7444. if (this._isInvalid || !this._isRelative) {
  7445. return;
  7446. }
  7447. parse.call(this, value, 'host');
  7448. },
  7449. get hostname() {
  7450. return this._host;
  7451. },
  7452. set hostname(value) {
  7453. if (this._isInvalid || !this._isRelative) {
  7454. return;
  7455. }
  7456. parse.call(this, value, 'hostname');
  7457. },
  7458. get port() {
  7459. return this._port;
  7460. },
  7461. set port(value) {
  7462. if (this._isInvalid || !this._isRelative) {
  7463. return;
  7464. }
  7465. parse.call(this, value, 'port');
  7466. },
  7467. get pathname() {
  7468. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  7469. },
  7470. set pathname(value) {
  7471. if (this._isInvalid || !this._isRelative) {
  7472. return;
  7473. }
  7474. this._path = [];
  7475. parse.call(this, value, 'relative path start');
  7476. },
  7477. get search() {
  7478. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  7479. },
  7480. set search(value) {
  7481. if (this._isInvalid || !this._isRelative) {
  7482. return;
  7483. }
  7484. this._query = '?';
  7485. if (value[0] === '?') {
  7486. value = value.slice(1);
  7487. }
  7488. parse.call(this, value, 'query');
  7489. },
  7490. get hash() {
  7491. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  7492. },
  7493. set hash(value) {
  7494. if (this._isInvalid) {
  7495. return;
  7496. }
  7497. this._fragment = '#';
  7498. if (value[0] === '#') {
  7499. value = value.slice(1);
  7500. }
  7501. parse.call(this, value, 'fragment');
  7502. },
  7503. get origin() {
  7504. var host;
  7505. if (this._isInvalid || !this._scheme) {
  7506. return '';
  7507. }
  7508. switch (this._scheme) {
  7509. case 'data':
  7510. case 'file':
  7511. case 'javascript':
  7512. case 'mailto':
  7513. return 'null';
  7514. case 'blob':
  7515. try {
  7516. return new JURL(this._schemeData).origin || 'null';
  7517. } catch (_) {}
  7518. return 'null';
  7519. }
  7520. host = this.host;
  7521. if (!host) {
  7522. return '';
  7523. }
  7524. return this._scheme + '://' + host;
  7525. }
  7526. };
  7527. exports.URL = JURL;
  7528. })();
  7529. /***/ }),
  7530. /* 147 */
  7531. /***/ (function(module, exports, __w_pdfjs_require__) {
  7532. "use strict";
  7533. Object.defineProperty(exports, "__esModule", {
  7534. value: true
  7535. });
  7536. exports.getDocument = getDocument;
  7537. exports.setPDFNetworkStreamFactory = setPDFNetworkStreamFactory;
  7538. exports.build = exports.version = exports.PDFPageProxy = exports.PDFDocumentProxy = exports.PDFWorker = exports.PDFDataRangeTransport = exports.LoopbackPort = void 0;
  7539. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(148));
  7540. var _util = __w_pdfjs_require__(1);
  7541. var _display_utils = __w_pdfjs_require__(151);
  7542. var _font_loader = __w_pdfjs_require__(152);
  7543. var _api_compatibility = __w_pdfjs_require__(153);
  7544. var _canvas = __w_pdfjs_require__(154);
  7545. var _global_scope = _interopRequireDefault(__w_pdfjs_require__(3));
  7546. var _worker_options = __w_pdfjs_require__(156);
  7547. var _message_handler = __w_pdfjs_require__(157);
  7548. var _metadata = __w_pdfjs_require__(158);
  7549. var _transport_stream = __w_pdfjs_require__(160);
  7550. var _webgl = __w_pdfjs_require__(161);
  7551. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7552. 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); } }
  7553. 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); }); }; }
  7554. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  7555. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  7556. function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  7557. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  7558. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
  7559. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
  7560. function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
  7561. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
  7562. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7563. 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); } }
  7564. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7565. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7566. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  7567. var isWorkerDisabled = false;
  7568. var fallbackWorkerSrc;
  7569. var fakeWorkerFilesLoader = null;
  7570. {
  7571. var useRequireEnsure = false;
  7572. if (typeof window === 'undefined') {
  7573. isWorkerDisabled = true;
  7574. if (typeof require.ensure === 'undefined') {
  7575. require.ensure = require('node-ensure');
  7576. }
  7577. useRequireEnsure = true;
  7578. } else if (typeof require !== 'undefined' && typeof require.ensure === 'function') {
  7579. useRequireEnsure = true;
  7580. }
  7581. if (typeof requirejs !== 'undefined' && requirejs.toUrl) {
  7582. fallbackWorkerSrc = requirejs.toUrl('pdfjs-dist/build/pdf.worker.js');
  7583. }
  7584. var dynamicLoaderSupported = typeof requirejs !== 'undefined' && requirejs.load;
  7585. fakeWorkerFilesLoader = useRequireEnsure ? function () {
  7586. return new Promise(function (resolve, reject) {
  7587. require.ensure([], function () {
  7588. try {
  7589. var worker;
  7590. worker = require('./pdf.worker.js');
  7591. resolve(worker.WorkerMessageHandler);
  7592. } catch (ex) {
  7593. reject(ex);
  7594. }
  7595. }, reject, 'pdfjsWorker');
  7596. });
  7597. } : dynamicLoaderSupported ? function () {
  7598. return new Promise(function (resolve, reject) {
  7599. requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) {
  7600. try {
  7601. resolve(worker.WorkerMessageHandler);
  7602. } catch (ex) {
  7603. reject(ex);
  7604. }
  7605. }, reject);
  7606. });
  7607. } : null;
  7608. if (!fallbackWorkerSrc && (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object' && 'currentScript' in document) {
  7609. var pdfjsFilePath = document.currentScript && document.currentScript.src;
  7610. if (pdfjsFilePath) {
  7611. fallbackWorkerSrc = pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, '.worker$1$2');
  7612. }
  7613. }
  7614. }
  7615. var createPDFNetworkStream;
  7616. function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
  7617. createPDFNetworkStream = pdfNetworkStreamFactory;
  7618. }
  7619. function getDocument(src) {
  7620. var task = new PDFDocumentLoadingTask();
  7621. var source;
  7622. if (typeof src === 'string') {
  7623. source = {
  7624. url: src
  7625. };
  7626. } else if ((0, _util.isArrayBuffer)(src)) {
  7627. source = {
  7628. data: src
  7629. };
  7630. } else if (src instanceof PDFDataRangeTransport) {
  7631. source = {
  7632. range: src
  7633. };
  7634. } else {
  7635. if (_typeof(src) !== 'object') {
  7636. throw new Error('Invalid parameter in getDocument, ' + 'need either Uint8Array, string or a parameter object');
  7637. }
  7638. if (!src.url && !src.data && !src.range) {
  7639. throw new Error('Invalid parameter object: need either .data, .range or .url');
  7640. }
  7641. source = src;
  7642. }
  7643. var params = Object.create(null);
  7644. var rangeTransport = null,
  7645. worker = null;
  7646. for (var key in source) {
  7647. if (key === 'url' && typeof window !== 'undefined') {
  7648. params[key] = new _util.URL(source[key], window.location).href;
  7649. continue;
  7650. } else if (key === 'range') {
  7651. rangeTransport = source[key];
  7652. continue;
  7653. } else if (key === 'worker') {
  7654. worker = source[key];
  7655. continue;
  7656. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  7657. var pdfBytes = source[key];
  7658. if (typeof pdfBytes === 'string') {
  7659. params[key] = (0, _util.stringToBytes)(pdfBytes);
  7660. } else if (_typeof(pdfBytes) === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  7661. params[key] = new Uint8Array(pdfBytes);
  7662. } else if ((0, _util.isArrayBuffer)(pdfBytes)) {
  7663. params[key] = new Uint8Array(pdfBytes);
  7664. } else {
  7665. throw new Error('Invalid PDF binary data: either typed array, ' + 'string or array-like object is expected in the ' + 'data property.');
  7666. }
  7667. continue;
  7668. }
  7669. params[key] = source[key];
  7670. }
  7671. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  7672. params.CMapReaderFactory = params.CMapReaderFactory || _display_utils.DOMCMapReaderFactory;
  7673. params.ignoreErrors = params.stopAtErrors !== true;
  7674. params.pdfBug = params.pdfBug === true;
  7675. var NativeImageDecoderValues = Object.values(_util.NativeImageDecoding);
  7676. if (params.nativeImageDecoderSupport === undefined || !NativeImageDecoderValues.includes(params.nativeImageDecoderSupport)) {
  7677. params.nativeImageDecoderSupport = _api_compatibility.apiCompatibilityParams.nativeImageDecoderSupport || _util.NativeImageDecoding.DECODE;
  7678. }
  7679. if (!Number.isInteger(params.maxImageSize)) {
  7680. params.maxImageSize = -1;
  7681. }
  7682. if (typeof params.isEvalSupported !== 'boolean') {
  7683. params.isEvalSupported = true;
  7684. }
  7685. if (typeof params.disableFontFace !== 'boolean') {
  7686. params.disableFontFace = _api_compatibility.apiCompatibilityParams.disableFontFace || false;
  7687. }
  7688. if (typeof params.disableRange !== 'boolean') {
  7689. params.disableRange = false;
  7690. }
  7691. if (typeof params.disableStream !== 'boolean') {
  7692. params.disableStream = false;
  7693. }
  7694. if (typeof params.disableAutoFetch !== 'boolean') {
  7695. params.disableAutoFetch = false;
  7696. }
  7697. if (typeof params.disableCreateObjectURL !== 'boolean') {
  7698. params.disableCreateObjectURL = _api_compatibility.apiCompatibilityParams.disableCreateObjectURL || false;
  7699. }
  7700. (0, _util.setVerbosityLevel)(params.verbosity);
  7701. if (!worker) {
  7702. var workerParams = {
  7703. postMessageTransfers: params.postMessageTransfers,
  7704. verbosity: params.verbosity,
  7705. port: _worker_options.GlobalWorkerOptions.workerPort
  7706. };
  7707. worker = workerParams.port ? PDFWorker.fromPort(workerParams) : new PDFWorker(workerParams);
  7708. task._worker = worker;
  7709. }
  7710. var docId = task.docId;
  7711. worker.promise.then(function () {
  7712. if (task.destroyed) {
  7713. throw new Error('Loading aborted');
  7714. }
  7715. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  7716. if (task.destroyed) {
  7717. throw new Error('Loading aborted');
  7718. }
  7719. var networkStream;
  7720. if (rangeTransport) {
  7721. networkStream = new _transport_stream.PDFDataTransportStream({
  7722. length: params.length,
  7723. initialData: params.initialData,
  7724. progressiveDone: params.progressiveDone,
  7725. disableRange: params.disableRange,
  7726. disableStream: params.disableStream
  7727. }, rangeTransport);
  7728. } else if (!params.data) {
  7729. networkStream = createPDFNetworkStream({
  7730. url: params.url,
  7731. length: params.length,
  7732. httpHeaders: params.httpHeaders,
  7733. withCredentials: params.withCredentials,
  7734. rangeChunkSize: params.rangeChunkSize,
  7735. disableRange: params.disableRange,
  7736. disableStream: params.disableStream
  7737. });
  7738. }
  7739. var messageHandler = new _message_handler.MessageHandler(docId, workerId, worker.port);
  7740. messageHandler.postMessageTransfers = worker.postMessageTransfers;
  7741. var transport = new WorkerTransport(messageHandler, task, networkStream, params);
  7742. task._transport = transport;
  7743. messageHandler.send('Ready', null);
  7744. });
  7745. })["catch"](task._capability.reject);
  7746. return task;
  7747. }
  7748. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  7749. if (worker.destroyed) {
  7750. return Promise.reject(new Error('Worker was destroyed'));
  7751. }
  7752. if (pdfDataRangeTransport) {
  7753. source.length = pdfDataRangeTransport.length;
  7754. source.initialData = pdfDataRangeTransport.initialData;
  7755. source.progressiveDone = pdfDataRangeTransport.progressiveDone;
  7756. }
  7757. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  7758. docId: docId,
  7759. apiVersion: '2.2.228',
  7760. source: {
  7761. data: source.data,
  7762. url: source.url,
  7763. password: source.password,
  7764. disableAutoFetch: source.disableAutoFetch,
  7765. rangeChunkSize: source.rangeChunkSize,
  7766. length: source.length
  7767. },
  7768. maxImageSize: source.maxImageSize,
  7769. disableFontFace: source.disableFontFace,
  7770. disableCreateObjectURL: source.disableCreateObjectURL,
  7771. postMessageTransfers: worker.postMessageTransfers,
  7772. docBaseUrl: source.docBaseUrl,
  7773. nativeImageDecoderSupport: source.nativeImageDecoderSupport,
  7774. ignoreErrors: source.ignoreErrors,
  7775. isEvalSupported: source.isEvalSupported
  7776. }).then(function (workerId) {
  7777. if (worker.destroyed) {
  7778. throw new Error('Worker was destroyed');
  7779. }
  7780. return workerId;
  7781. });
  7782. }
  7783. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  7784. var nextDocumentId = 0;
  7785. var PDFDocumentLoadingTask =
  7786. /*#__PURE__*/
  7787. function () {
  7788. function PDFDocumentLoadingTask() {
  7789. _classCallCheck(this, PDFDocumentLoadingTask);
  7790. this._capability = (0, _util.createPromiseCapability)();
  7791. this._transport = null;
  7792. this._worker = null;
  7793. this.docId = 'd' + nextDocumentId++;
  7794. this.destroyed = false;
  7795. this.onPassword = null;
  7796. this.onProgress = null;
  7797. this.onUnsupportedFeature = null;
  7798. }
  7799. _createClass(PDFDocumentLoadingTask, [{
  7800. key: "destroy",
  7801. value: function destroy() {
  7802. var _this = this;
  7803. this.destroyed = true;
  7804. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  7805. return transportDestroyed.then(function () {
  7806. _this._transport = null;
  7807. if (_this._worker) {
  7808. _this._worker.destroy();
  7809. _this._worker = null;
  7810. }
  7811. });
  7812. }
  7813. }, {
  7814. key: "then",
  7815. value: function then(onFulfilled, onRejected) {
  7816. (0, _display_utils.deprecated)('PDFDocumentLoadingTask.then method, ' + 'use the `promise` getter instead.');
  7817. return this.promise.then.apply(this.promise, arguments);
  7818. }
  7819. }, {
  7820. key: "promise",
  7821. get: function get() {
  7822. return this._capability.promise;
  7823. }
  7824. }]);
  7825. return PDFDocumentLoadingTask;
  7826. }();
  7827. return PDFDocumentLoadingTask;
  7828. }();
  7829. var PDFDataRangeTransport =
  7830. /*#__PURE__*/
  7831. function () {
  7832. function PDFDataRangeTransport(length, initialData) {
  7833. var progressiveDone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7834. _classCallCheck(this, PDFDataRangeTransport);
  7835. this.length = length;
  7836. this.initialData = initialData;
  7837. this.progressiveDone = progressiveDone;
  7838. this._rangeListeners = [];
  7839. this._progressListeners = [];
  7840. this._progressiveReadListeners = [];
  7841. this._progressiveDoneListeners = [];
  7842. this._readyCapability = (0, _util.createPromiseCapability)();
  7843. }
  7844. _createClass(PDFDataRangeTransport, [{
  7845. key: "addRangeListener",
  7846. value: function addRangeListener(listener) {
  7847. this._rangeListeners.push(listener);
  7848. }
  7849. }, {
  7850. key: "addProgressListener",
  7851. value: function addProgressListener(listener) {
  7852. this._progressListeners.push(listener);
  7853. }
  7854. }, {
  7855. key: "addProgressiveReadListener",
  7856. value: function addProgressiveReadListener(listener) {
  7857. this._progressiveReadListeners.push(listener);
  7858. }
  7859. }, {
  7860. key: "addProgressiveDoneListener",
  7861. value: function addProgressiveDoneListener(listener) {
  7862. this._progressiveDoneListeners.push(listener);
  7863. }
  7864. }, {
  7865. key: "onDataRange",
  7866. value: function onDataRange(begin, chunk) {
  7867. var _iteratorNormalCompletion = true;
  7868. var _didIteratorError = false;
  7869. var _iteratorError = undefined;
  7870. try {
  7871. for (var _iterator = this._rangeListeners[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7872. var listener = _step.value;
  7873. listener(begin, chunk);
  7874. }
  7875. } catch (err) {
  7876. _didIteratorError = true;
  7877. _iteratorError = err;
  7878. } finally {
  7879. try {
  7880. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  7881. _iterator["return"]();
  7882. }
  7883. } finally {
  7884. if (_didIteratorError) {
  7885. throw _iteratorError;
  7886. }
  7887. }
  7888. }
  7889. }
  7890. }, {
  7891. key: "onDataProgress",
  7892. value: function onDataProgress(loaded, total) {
  7893. var _this2 = this;
  7894. this._readyCapability.promise.then(function () {
  7895. var _iteratorNormalCompletion2 = true;
  7896. var _didIteratorError2 = false;
  7897. var _iteratorError2 = undefined;
  7898. try {
  7899. for (var _iterator2 = _this2._progressListeners[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  7900. var listener = _step2.value;
  7901. listener(loaded, total);
  7902. }
  7903. } catch (err) {
  7904. _didIteratorError2 = true;
  7905. _iteratorError2 = err;
  7906. } finally {
  7907. try {
  7908. if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
  7909. _iterator2["return"]();
  7910. }
  7911. } finally {
  7912. if (_didIteratorError2) {
  7913. throw _iteratorError2;
  7914. }
  7915. }
  7916. }
  7917. });
  7918. }
  7919. }, {
  7920. key: "onDataProgressiveRead",
  7921. value: function onDataProgressiveRead(chunk) {
  7922. var _this3 = this;
  7923. this._readyCapability.promise.then(function () {
  7924. var _iteratorNormalCompletion3 = true;
  7925. var _didIteratorError3 = false;
  7926. var _iteratorError3 = undefined;
  7927. try {
  7928. for (var _iterator3 = _this3._progressiveReadListeners[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  7929. var listener = _step3.value;
  7930. listener(chunk);
  7931. }
  7932. } catch (err) {
  7933. _didIteratorError3 = true;
  7934. _iteratorError3 = err;
  7935. } finally {
  7936. try {
  7937. if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
  7938. _iterator3["return"]();
  7939. }
  7940. } finally {
  7941. if (_didIteratorError3) {
  7942. throw _iteratorError3;
  7943. }
  7944. }
  7945. }
  7946. });
  7947. }
  7948. }, {
  7949. key: "onDataProgressiveDone",
  7950. value: function onDataProgressiveDone() {
  7951. var _this4 = this;
  7952. this._readyCapability.promise.then(function () {
  7953. var _iteratorNormalCompletion4 = true;
  7954. var _didIteratorError4 = false;
  7955. var _iteratorError4 = undefined;
  7956. try {
  7957. for (var _iterator4 = _this4._progressiveDoneListeners[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  7958. var listener = _step4.value;
  7959. listener();
  7960. }
  7961. } catch (err) {
  7962. _didIteratorError4 = true;
  7963. _iteratorError4 = err;
  7964. } finally {
  7965. try {
  7966. if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) {
  7967. _iterator4["return"]();
  7968. }
  7969. } finally {
  7970. if (_didIteratorError4) {
  7971. throw _iteratorError4;
  7972. }
  7973. }
  7974. }
  7975. });
  7976. }
  7977. }, {
  7978. key: "transportReady",
  7979. value: function transportReady() {
  7980. this._readyCapability.resolve();
  7981. }
  7982. }, {
  7983. key: "requestDataRange",
  7984. value: function requestDataRange(begin, end) {
  7985. (0, _util.unreachable)('Abstract method PDFDataRangeTransport.requestDataRange');
  7986. }
  7987. }, {
  7988. key: "abort",
  7989. value: function abort() {}
  7990. }]);
  7991. return PDFDataRangeTransport;
  7992. }();
  7993. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  7994. var PDFDocumentProxy =
  7995. /*#__PURE__*/
  7996. function () {
  7997. function PDFDocumentProxy(pdfInfo, transport) {
  7998. _classCallCheck(this, PDFDocumentProxy);
  7999. this._pdfInfo = pdfInfo;
  8000. this._transport = transport;
  8001. }
  8002. _createClass(PDFDocumentProxy, [{
  8003. key: "getPage",
  8004. value: function getPage(pageNumber) {
  8005. return this._transport.getPage(pageNumber);
  8006. }
  8007. }, {
  8008. key: "getPageIndex",
  8009. value: function getPageIndex(ref) {
  8010. return this._transport.getPageIndex(ref);
  8011. }
  8012. }, {
  8013. key: "getDestinations",
  8014. value: function getDestinations() {
  8015. return this._transport.getDestinations();
  8016. }
  8017. }, {
  8018. key: "getDestination",
  8019. value: function getDestination(id) {
  8020. return this._transport.getDestination(id);
  8021. }
  8022. }, {
  8023. key: "getPageLabels",
  8024. value: function getPageLabels() {
  8025. return this._transport.getPageLabels();
  8026. }
  8027. }, {
  8028. key: "getPageLayout",
  8029. value: function getPageLayout() {
  8030. return this._transport.getPageLayout();
  8031. }
  8032. }, {
  8033. key: "getPageMode",
  8034. value: function getPageMode() {
  8035. return this._transport.getPageMode();
  8036. }
  8037. }, {
  8038. key: "getViewerPreferences",
  8039. value: function getViewerPreferences() {
  8040. return this._transport.getViewerPreferences();
  8041. }
  8042. }, {
  8043. key: "getOpenActionDestination",
  8044. value: function getOpenActionDestination() {
  8045. return this._transport.getOpenActionDestination();
  8046. }
  8047. }, {
  8048. key: "getAttachments",
  8049. value: function getAttachments() {
  8050. return this._transport.getAttachments();
  8051. }
  8052. }, {
  8053. key: "getJavaScript",
  8054. value: function getJavaScript() {
  8055. return this._transport.getJavaScript();
  8056. }
  8057. }, {
  8058. key: "getOutline",
  8059. value: function getOutline() {
  8060. return this._transport.getOutline();
  8061. }
  8062. }, {
  8063. key: "getPermissions",
  8064. value: function getPermissions() {
  8065. return this._transport.getPermissions();
  8066. }
  8067. }, {
  8068. key: "getMetadata",
  8069. value: function getMetadata() {
  8070. return this._transport.getMetadata();
  8071. }
  8072. }, {
  8073. key: "getData",
  8074. value: function getData() {
  8075. return this._transport.getData();
  8076. }
  8077. }, {
  8078. key: "getDownloadInfo",
  8079. value: function getDownloadInfo() {
  8080. return this._transport.downloadInfoCapability.promise;
  8081. }
  8082. }, {
  8083. key: "getStats",
  8084. value: function getStats() {
  8085. return this._transport.getStats();
  8086. }
  8087. }, {
  8088. key: "cleanup",
  8089. value: function cleanup() {
  8090. this._transport.startCleanup();
  8091. }
  8092. }, {
  8093. key: "destroy",
  8094. value: function destroy() {
  8095. return this.loadingTask.destroy();
  8096. }
  8097. }, {
  8098. key: "numPages",
  8099. get: function get() {
  8100. return this._pdfInfo.numPages;
  8101. }
  8102. }, {
  8103. key: "fingerprint",
  8104. get: function get() {
  8105. return this._pdfInfo.fingerprint;
  8106. }
  8107. }, {
  8108. key: "loadingParams",
  8109. get: function get() {
  8110. return this._transport.loadingParams;
  8111. }
  8112. }, {
  8113. key: "loadingTask",
  8114. get: function get() {
  8115. return this._transport.loadingTask;
  8116. }
  8117. }]);
  8118. return PDFDocumentProxy;
  8119. }();
  8120. exports.PDFDocumentProxy = PDFDocumentProxy;
  8121. var PDFPageProxy =
  8122. /*#__PURE__*/
  8123. function () {
  8124. function PDFPageProxy(pageIndex, pageInfo, transport) {
  8125. var pdfBug = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  8126. _classCallCheck(this, PDFPageProxy);
  8127. this.pageIndex = pageIndex;
  8128. this._pageInfo = pageInfo;
  8129. this._transport = transport;
  8130. this._stats = pdfBug ? new _display_utils.StatTimer() : _display_utils.DummyStatTimer;
  8131. this._pdfBug = pdfBug;
  8132. this.commonObjs = transport.commonObjs;
  8133. this.objs = new PDFObjects();
  8134. this.cleanupAfterRender = false;
  8135. this.pendingCleanup = false;
  8136. this.intentStates = Object.create(null);
  8137. this.destroyed = false;
  8138. }
  8139. _createClass(PDFPageProxy, [{
  8140. key: "getViewport",
  8141. value: function getViewport() {
  8142. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  8143. scale = _ref.scale,
  8144. _ref$rotation = _ref.rotation,
  8145. rotation = _ref$rotation === void 0 ? this.rotate : _ref$rotation,
  8146. _ref$dontFlip = _ref.dontFlip,
  8147. dontFlip = _ref$dontFlip === void 0 ? false : _ref$dontFlip;
  8148. if (arguments.length > 1 || typeof arguments[0] === 'number') {
  8149. /*(0, _display_utils.deprecated)('getViewport is called with obsolete arguments.');*/
  8150. scale = arguments[0];
  8151. rotation = typeof arguments[1] === 'number' ? arguments[1] : this.rotate;
  8152. dontFlip = typeof arguments[2] === 'boolean' ? arguments[2] : false;
  8153. }
  8154. return new _display_utils.PageViewport({
  8155. viewBox: this.view,
  8156. scale: scale,
  8157. rotation: rotation,
  8158. dontFlip: dontFlip
  8159. });
  8160. }
  8161. }, {
  8162. key: "getAnnotations",
  8163. value: function getAnnotations() {
  8164. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  8165. _ref2$intent = _ref2.intent,
  8166. intent = _ref2$intent === void 0 ? null : _ref2$intent;
  8167. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  8168. this.annotationsPromise = this._transport.getAnnotations(this.pageIndex, intent);
  8169. this.annotationsIntent = intent;
  8170. }
  8171. return this.annotationsPromise;
  8172. }
  8173. }, {
  8174. key: "render",
  8175. value: function render(_ref3) {
  8176. var _this5 = this;
  8177. var canvasContext = _ref3.canvasContext,
  8178. viewport = _ref3.viewport,
  8179. _ref3$intent = _ref3.intent,
  8180. intent = _ref3$intent === void 0 ? 'display' : _ref3$intent,
  8181. _ref3$enableWebGL = _ref3.enableWebGL,
  8182. enableWebGL = _ref3$enableWebGL === void 0 ? false : _ref3$enableWebGL,
  8183. _ref3$renderInteracti = _ref3.renderInteractiveForms,
  8184. renderInteractiveForms = _ref3$renderInteracti === void 0 ? false : _ref3$renderInteracti,
  8185. _ref3$transform = _ref3.transform,
  8186. transform = _ref3$transform === void 0 ? null : _ref3$transform,
  8187. _ref3$imageLayer = _ref3.imageLayer,
  8188. imageLayer = _ref3$imageLayer === void 0 ? null : _ref3$imageLayer,
  8189. _ref3$canvasFactory = _ref3.canvasFactory,
  8190. canvasFactory = _ref3$canvasFactory === void 0 ? null : _ref3$canvasFactory,
  8191. _ref3$background = _ref3.background,
  8192. background = _ref3$background === void 0 ? null : _ref3$background;
  8193. var stats = this._stats;
  8194. stats.time('Overall');
  8195. this.pendingCleanup = false;
  8196. var renderingIntent = intent === 'print' ? 'print' : 'display';
  8197. var canvasFactoryInstance = canvasFactory || new _display_utils.DOMCanvasFactory();
  8198. var webGLContext = new _webgl.WebGLContext({
  8199. enable: enableWebGL
  8200. });
  8201. if (!this.intentStates[renderingIntent]) {
  8202. this.intentStates[renderingIntent] = Object.create(null);
  8203. }
  8204. var intentState = this.intentStates[renderingIntent];
  8205. if (!intentState.displayReadyCapability) {
  8206. intentState.receivingOperatorList = true;
  8207. intentState.displayReadyCapability = (0, _util.createPromiseCapability)();
  8208. intentState.operatorList = {
  8209. fnArray: [],
  8210. argsArray: [],
  8211. lastChunk: false
  8212. };
  8213. stats.time('Page Request');
  8214. this._transport.messageHandler.send('RenderPageRequest', {
  8215. pageIndex: this.pageNumber - 1,
  8216. intent: renderingIntent,
  8217. renderInteractiveForms: renderInteractiveForms === true
  8218. });
  8219. }
  8220. var complete = function complete(error) {
  8221. var i = intentState.renderTasks.indexOf(internalRenderTask);
  8222. if (i >= 0) {
  8223. intentState.renderTasks.splice(i, 1);
  8224. }
  8225. if (_this5.cleanupAfterRender || renderingIntent === 'print') {
  8226. _this5.pendingCleanup = true;
  8227. }
  8228. _this5._tryCleanup();
  8229. if (error) {
  8230. internalRenderTask.capability.reject(error);
  8231. } else {
  8232. internalRenderTask.capability.resolve();
  8233. }
  8234. stats.timeEnd('Rendering');
  8235. stats.timeEnd('Overall');
  8236. };
  8237. var internalRenderTask = new InternalRenderTask({
  8238. callback: complete,
  8239. params: {
  8240. canvasContext: canvasContext,
  8241. viewport: viewport,
  8242. transform: transform,
  8243. imageLayer: imageLayer,
  8244. background: background
  8245. },
  8246. objs: this.objs,
  8247. commonObjs: this.commonObjs,
  8248. operatorList: intentState.operatorList,
  8249. pageNumber: this.pageNumber,
  8250. canvasFactory: canvasFactoryInstance,
  8251. webGLContext: webGLContext,
  8252. useRequestAnimationFrame: renderingIntent !== 'print',
  8253. pdfBug: this._pdfBug
  8254. });
  8255. if (!intentState.renderTasks) {
  8256. intentState.renderTasks = [];
  8257. }
  8258. intentState.renderTasks.push(internalRenderTask);
  8259. var renderTask = internalRenderTask.task;
  8260. intentState.displayReadyCapability.promise.then(function (transparency) {
  8261. if (_this5.pendingCleanup) {
  8262. complete();
  8263. return;
  8264. }
  8265. stats.time('Rendering');
  8266. internalRenderTask.initializeGraphics(transparency);
  8267. internalRenderTask.operatorListChanged();
  8268. })["catch"](complete);
  8269. return renderTask;
  8270. }
  8271. }, {
  8272. key: "getOperatorList",
  8273. value: function getOperatorList() {
  8274. function operatorListChanged() {
  8275. if (intentState.operatorList.lastChunk) {
  8276. intentState.opListReadCapability.resolve(intentState.operatorList);
  8277. var i = intentState.renderTasks.indexOf(opListTask);
  8278. if (i >= 0) {
  8279. intentState.renderTasks.splice(i, 1);
  8280. }
  8281. }
  8282. }
  8283. var renderingIntent = 'oplist';
  8284. if (!this.intentStates[renderingIntent]) {
  8285. this.intentStates[renderingIntent] = Object.create(null);
  8286. }
  8287. var intentState = this.intentStates[renderingIntent];
  8288. var opListTask;
  8289. if (!intentState.opListReadCapability) {
  8290. opListTask = {};
  8291. opListTask.operatorListChanged = operatorListChanged;
  8292. intentState.receivingOperatorList = true;
  8293. intentState.opListReadCapability = (0, _util.createPromiseCapability)();
  8294. intentState.renderTasks = [];
  8295. intentState.renderTasks.push(opListTask);
  8296. intentState.operatorList = {
  8297. fnArray: [],
  8298. argsArray: [],
  8299. lastChunk: false
  8300. };
  8301. this._stats.time('Page Request');
  8302. this._transport.messageHandler.send('RenderPageRequest', {
  8303. pageIndex: this.pageIndex,
  8304. intent: renderingIntent
  8305. });
  8306. }
  8307. return intentState.opListReadCapability.promise;
  8308. }
  8309. }, {
  8310. key: "streamTextContent",
  8311. value: function streamTextContent() {
  8312. var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  8313. _ref4$normalizeWhites = _ref4.normalizeWhitespace,
  8314. normalizeWhitespace = _ref4$normalizeWhites === void 0 ? false : _ref4$normalizeWhites,
  8315. _ref4$disableCombineT = _ref4.disableCombineTextItems,
  8316. disableCombineTextItems = _ref4$disableCombineT === void 0 ? false : _ref4$disableCombineT;
  8317. var TEXT_CONTENT_CHUNK_SIZE = 100;
  8318. return this._transport.messageHandler.sendWithStream('GetTextContent', {
  8319. pageIndex: this.pageNumber - 1,
  8320. normalizeWhitespace: normalizeWhitespace === true,
  8321. combineTextItems: disableCombineTextItems !== true
  8322. }, {
  8323. highWaterMark: TEXT_CONTENT_CHUNK_SIZE,
  8324. size: function size(textContent) {
  8325. return textContent.items.length;
  8326. }
  8327. });
  8328. }
  8329. }, {
  8330. key: "getTextContent",
  8331. value: function getTextContent() {
  8332. var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  8333. var readableStream = this.streamTextContent(params);
  8334. return new Promise(function (resolve, reject) {
  8335. function pump() {
  8336. reader.read().then(function (_ref5) {
  8337. var _textContent$items;
  8338. var value = _ref5.value,
  8339. done = _ref5.done;
  8340. if (done) {
  8341. resolve(textContent);
  8342. return;
  8343. }
  8344. Object.assign(textContent.styles, value.styles);
  8345. (_textContent$items = textContent.items).push.apply(_textContent$items, _toConsumableArray(value.items));
  8346. pump();
  8347. }, reject);
  8348. }
  8349. var reader = readableStream.getReader();
  8350. var textContent = {
  8351. items: [],
  8352. styles: Object.create(null)
  8353. };
  8354. pump();
  8355. });
  8356. }
  8357. }, {
  8358. key: "_destroy",
  8359. value: function _destroy() {
  8360. this.destroyed = true;
  8361. this._transport.pageCache[this.pageIndex] = null;
  8362. var waitOn = [];
  8363. Object.keys(this.intentStates).forEach(function (intent) {
  8364. if (intent === 'oplist') {
  8365. return;
  8366. }
  8367. var intentState = this.intentStates[intent];
  8368. intentState.renderTasks.forEach(function (renderTask) {
  8369. var renderCompleted = renderTask.capability.promise["catch"](function () {});
  8370. waitOn.push(renderCompleted);
  8371. renderTask.cancel();
  8372. });
  8373. }, this);
  8374. this.objs.clear();
  8375. this.annotationsPromise = null;
  8376. this.pendingCleanup = false;
  8377. return Promise.all(waitOn);
  8378. }
  8379. }, {
  8380. key: "cleanup",
  8381. value: function cleanup() {
  8382. var resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8383. this.pendingCleanup = true;
  8384. this._tryCleanup(resetStats);
  8385. }
  8386. }, {
  8387. key: "_tryCleanup",
  8388. value: function _tryCleanup() {
  8389. var resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8390. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  8391. var intentState = this.intentStates[intent];
  8392. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  8393. }, this)) {
  8394. return;
  8395. }
  8396. Object.keys(this.intentStates).forEach(function (intent) {
  8397. delete this.intentStates[intent];
  8398. }, this);
  8399. this.objs.clear();
  8400. this.annotationsPromise = null;
  8401. if (resetStats && this._stats instanceof _display_utils.StatTimer) {
  8402. this._stats = new _display_utils.StatTimer();
  8403. }
  8404. this.pendingCleanup = false;
  8405. }
  8406. }, {
  8407. key: "_startRenderPage",
  8408. value: function _startRenderPage(transparency, intent) {
  8409. var intentState = this.intentStates[intent];
  8410. if (intentState.displayReadyCapability) {
  8411. intentState.displayReadyCapability.resolve(transparency);
  8412. }
  8413. }
  8414. }, {
  8415. key: "_renderPageChunk",
  8416. value: function _renderPageChunk(operatorListChunk, intent) {
  8417. var intentState = this.intentStates[intent];
  8418. for (var i = 0, ii = operatorListChunk.length; i < ii; i++) {
  8419. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  8420. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  8421. }
  8422. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  8423. for (var _i = 0; _i < intentState.renderTasks.length; _i++) {
  8424. intentState.renderTasks[_i].operatorListChanged();
  8425. }
  8426. if (operatorListChunk.lastChunk) {
  8427. intentState.receivingOperatorList = false;
  8428. this._tryCleanup();
  8429. }
  8430. }
  8431. }, {
  8432. key: "pageNumber",
  8433. get: function get() {
  8434. return this.pageIndex + 1;
  8435. }
  8436. }, {
  8437. key: "rotate",
  8438. get: function get() {
  8439. return this._pageInfo.rotate;
  8440. }
  8441. }, {
  8442. key: "ref",
  8443. get: function get() {
  8444. return this._pageInfo.ref;
  8445. }
  8446. }, {
  8447. key: "userUnit",
  8448. get: function get() {
  8449. return this._pageInfo.userUnit;
  8450. }
  8451. }, {
  8452. key: "view",
  8453. get: function get() {
  8454. return this._pageInfo.view;
  8455. }
  8456. }, {
  8457. key: "stats",
  8458. get: function get() {
  8459. return this._stats instanceof _display_utils.StatTimer ? this._stats : null;
  8460. }
  8461. }]);
  8462. return PDFPageProxy;
  8463. }();
  8464. exports.PDFPageProxy = PDFPageProxy;
  8465. var LoopbackPort =
  8466. /*#__PURE__*/
  8467. function () {
  8468. function LoopbackPort() {
  8469. var defer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  8470. _classCallCheck(this, LoopbackPort);
  8471. this._listeners = [];
  8472. this._defer = defer;
  8473. this._deferred = Promise.resolve(undefined);
  8474. }
  8475. _createClass(LoopbackPort, [{
  8476. key: "postMessage",
  8477. value: function postMessage(obj, transfers) {
  8478. var _this6 = this;
  8479. function cloneValue(value) {
  8480. if (_typeof(value) !== 'object' || value === null) {
  8481. return value;
  8482. }
  8483. if (cloned.has(value)) {
  8484. return cloned.get(value);
  8485. }
  8486. var buffer, result;
  8487. if ((buffer = value.buffer) && (0, _util.isArrayBuffer)(buffer)) {
  8488. var transferable = transfers && transfers.includes(buffer);
  8489. if (value === buffer) {
  8490. result = value;
  8491. } else if (transferable) {
  8492. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  8493. } else {
  8494. result = new value.constructor(value);
  8495. }
  8496. cloned.set(value, result);
  8497. return result;
  8498. }
  8499. result = Array.isArray(value) ? [] : {};
  8500. cloned.set(value, result);
  8501. for (var i in value) {
  8502. var desc = void 0,
  8503. p = value;
  8504. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  8505. p = Object.getPrototypeOf(p);
  8506. }
  8507. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  8508. continue;
  8509. }
  8510. result[i] = cloneValue(desc.value);
  8511. }
  8512. return result;
  8513. }
  8514. if (!this._defer) {
  8515. this._listeners.forEach(function (listener) {
  8516. listener.call(this, {
  8517. data: obj
  8518. });
  8519. }, this);
  8520. return;
  8521. }
  8522. var cloned = new WeakMap();
  8523. var e = {
  8524. data: cloneValue(obj)
  8525. };
  8526. this._deferred.then(function () {
  8527. _this6._listeners.forEach(function (listener) {
  8528. listener.call(this, e);
  8529. }, _this6);
  8530. });
  8531. }
  8532. }, {
  8533. key: "addEventListener",
  8534. value: function addEventListener(name, listener) {
  8535. this._listeners.push(listener);
  8536. }
  8537. }, {
  8538. key: "removeEventListener",
  8539. value: function removeEventListener(name, listener) {
  8540. var i = this._listeners.indexOf(listener);
  8541. this._listeners.splice(i, 1);
  8542. }
  8543. }, {
  8544. key: "terminate",
  8545. value: function terminate() {
  8546. this._listeners.length = 0;
  8547. }
  8548. }]);
  8549. return LoopbackPort;
  8550. }();
  8551. exports.LoopbackPort = LoopbackPort;
  8552. var PDFWorker = function PDFWorkerClosure() {
  8553. var pdfWorkerPorts = new WeakMap();
  8554. var nextFakeWorkerId = 0;
  8555. var fakeWorkerFilesLoadedCapability;
  8556. function _getWorkerSrc() {
  8557. if (_worker_options.GlobalWorkerOptions.workerSrc) {
  8558. return _worker_options.GlobalWorkerOptions.workerSrc;
  8559. }
  8560. if (typeof fallbackWorkerSrc !== 'undefined') {
  8561. return fallbackWorkerSrc;
  8562. }
  8563. throw new Error('No "GlobalWorkerOptions.workerSrc" specified.');
  8564. }
  8565. function getMainThreadWorkerMessageHandler() {
  8566. try {
  8567. if (typeof window !== 'undefined') {
  8568. return window.pdfjsWorker && window.pdfjsWorker.WorkerMessageHandler;
  8569. }
  8570. } catch (ex) {}
  8571. return null;
  8572. }
  8573. function setupFakeWorkerGlobal() {
  8574. if (fakeWorkerFilesLoadedCapability) {
  8575. return fakeWorkerFilesLoadedCapability.promise;
  8576. }
  8577. fakeWorkerFilesLoadedCapability = (0, _util.createPromiseCapability)();
  8578. var mainWorkerMessageHandler = getMainThreadWorkerMessageHandler();
  8579. if (mainWorkerMessageHandler) {
  8580. fakeWorkerFilesLoadedCapability.resolve(mainWorkerMessageHandler);
  8581. return fakeWorkerFilesLoadedCapability.promise;
  8582. }
  8583. var loader = fakeWorkerFilesLoader || function () {
  8584. return (0, _display_utils.loadScript)(_getWorkerSrc()).then(function () {
  8585. return window.pdfjsWorker.WorkerMessageHandler;
  8586. });
  8587. };
  8588. loader().then(fakeWorkerFilesLoadedCapability.resolve, fakeWorkerFilesLoadedCapability.reject);
  8589. return fakeWorkerFilesLoadedCapability.promise;
  8590. }
  8591. function createCDNWrapper(url) {
  8592. var wrapper = 'importScripts(\'' + url + '\');';
  8593. return _util.URL.createObjectURL(new Blob([wrapper]));
  8594. }
  8595. var PDFWorker =
  8596. /*#__PURE__*/
  8597. function () {
  8598. function PDFWorker() {
  8599. var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  8600. _ref6$name = _ref6.name,
  8601. name = _ref6$name === void 0 ? null : _ref6$name,
  8602. _ref6$port = _ref6.port,
  8603. port = _ref6$port === void 0 ? null : _ref6$port,
  8604. _ref6$postMessageTran = _ref6.postMessageTransfers,
  8605. postMessageTransfers = _ref6$postMessageTran === void 0 ? true : _ref6$postMessageTran,
  8606. _ref6$verbosity = _ref6.verbosity,
  8607. verbosity = _ref6$verbosity === void 0 ? (0, _util.getVerbosityLevel)() : _ref6$verbosity;
  8608. _classCallCheck(this, PDFWorker);
  8609. if (port && pdfWorkerPorts.has(port)) {
  8610. throw new Error('Cannot use more than one PDFWorker per port');
  8611. }
  8612. this.name = name;
  8613. this.destroyed = false;
  8614. this.postMessageTransfers = postMessageTransfers !== false;
  8615. this.verbosity = verbosity;
  8616. this._readyCapability = (0, _util.createPromiseCapability)();
  8617. this._port = null;
  8618. this._webWorker = null;
  8619. this._messageHandler = null;
  8620. if (port) {
  8621. pdfWorkerPorts.set(port, this);
  8622. this._initializeFromPort(port);
  8623. return;
  8624. }
  8625. this._initialize();
  8626. }
  8627. _createClass(PDFWorker, [{
  8628. key: "_initializeFromPort",
  8629. value: function _initializeFromPort(port) {
  8630. this._port = port;
  8631. this._messageHandler = new _message_handler.MessageHandler('main', 'worker', port);
  8632. this._messageHandler.on('ready', function () {});
  8633. this._readyCapability.resolve();
  8634. }
  8635. }, {
  8636. key: "_initialize",
  8637. value: function _initialize() {
  8638. var _this7 = this;
  8639. if (typeof Worker !== 'undefined' && !isWorkerDisabled && !getMainThreadWorkerMessageHandler()) {
  8640. var workerSrc = _getWorkerSrc();
  8641. try {
  8642. if (!(0, _util.isSameOrigin)(window.location.href, workerSrc)) {
  8643. workerSrc = createCDNWrapper(new _util.URL(workerSrc, window.location).href);
  8644. }
  8645. var worker = new Worker(workerSrc);
  8646. var messageHandler = new _message_handler.MessageHandler('main', 'worker', worker);
  8647. var terminateEarly = function terminateEarly() {
  8648. worker.removeEventListener('error', onWorkerError);
  8649. messageHandler.destroy();
  8650. worker.terminate();
  8651. if (_this7.destroyed) {
  8652. _this7._readyCapability.reject(new Error('Worker was destroyed'));
  8653. } else {
  8654. _this7._setupFakeWorker();
  8655. }
  8656. };
  8657. var onWorkerError = function onWorkerError() {
  8658. if (!_this7._webWorker) {
  8659. terminateEarly();
  8660. }
  8661. };
  8662. worker.addEventListener('error', onWorkerError);
  8663. messageHandler.on('test', function (data) {
  8664. worker.removeEventListener('error', onWorkerError);
  8665. if (_this7.destroyed) {
  8666. terminateEarly();
  8667. return;
  8668. }
  8669. if (data && data.supportTypedArray) {
  8670. _this7._messageHandler = messageHandler;
  8671. _this7._port = worker;
  8672. _this7._webWorker = worker;
  8673. if (!data.supportTransfers) {
  8674. _this7.postMessageTransfers = false;
  8675. }
  8676. _this7._readyCapability.resolve();
  8677. messageHandler.send('configure', {
  8678. verbosity: _this7.verbosity
  8679. });
  8680. } else {
  8681. _this7._setupFakeWorker();
  8682. messageHandler.destroy();
  8683. worker.terminate();
  8684. }
  8685. });
  8686. messageHandler.on('ready', function (data) {
  8687. worker.removeEventListener('error', onWorkerError);
  8688. if (_this7.destroyed) {
  8689. terminateEarly();
  8690. return;
  8691. }
  8692. try {
  8693. sendTest();
  8694. } catch (e) {
  8695. _this7._setupFakeWorker();
  8696. }
  8697. });
  8698. var sendTest = function sendTest() {
  8699. var testObj = new Uint8Array([_this7.postMessageTransfers ? 255 : 0]);
  8700. try {
  8701. messageHandler.send('test', testObj, [testObj.buffer]);
  8702. } catch (ex) {
  8703. (0, _util.info)('Cannot use postMessage transfers');
  8704. testObj[0] = 0;
  8705. messageHandler.send('test', testObj);
  8706. }
  8707. };
  8708. sendTest();
  8709. return;
  8710. } catch (e) {
  8711. (0, _util.info)('The worker has been disabled.');
  8712. }
  8713. }
  8714. this._setupFakeWorker();
  8715. }
  8716. }, {
  8717. key: "_setupFakeWorker",
  8718. value: function _setupFakeWorker() {
  8719. var _this8 = this;
  8720. if (!isWorkerDisabled) {
  8721. (0, _util.warn)('Setting up fake worker.');
  8722. isWorkerDisabled = true;
  8723. }
  8724. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  8725. if (_this8.destroyed) {
  8726. _this8._readyCapability.reject(new Error('Worker was destroyed'));
  8727. return;
  8728. }
  8729. var port = new LoopbackPort();
  8730. _this8._port = port;
  8731. var id = 'fake' + nextFakeWorkerId++;
  8732. var workerHandler = new _message_handler.MessageHandler(id + '_worker', id, port);
  8733. WorkerMessageHandler.setup(workerHandler, port);
  8734. var messageHandler = new _message_handler.MessageHandler(id, id + '_worker', port);
  8735. _this8._messageHandler = messageHandler;
  8736. _this8._readyCapability.resolve();
  8737. })["catch"](function (reason) {
  8738. _this8._readyCapability.reject(new Error("Setting up fake worker failed: \"".concat(reason.message, "\".")));
  8739. });
  8740. }
  8741. }, {
  8742. key: "destroy",
  8743. value: function destroy() {
  8744. this.destroyed = true;
  8745. if (this._webWorker) {
  8746. this._webWorker.terminate();
  8747. this._webWorker = null;
  8748. }
  8749. pdfWorkerPorts["delete"](this._port);
  8750. this._port = null;
  8751. if (this._messageHandler) {
  8752. this._messageHandler.destroy();
  8753. this._messageHandler = null;
  8754. }
  8755. }
  8756. }, {
  8757. key: "promise",
  8758. get: function get() {
  8759. return this._readyCapability.promise;
  8760. }
  8761. }, {
  8762. key: "port",
  8763. get: function get() {
  8764. return this._port;
  8765. }
  8766. }, {
  8767. key: "messageHandler",
  8768. get: function get() {
  8769. return this._messageHandler;
  8770. }
  8771. }], [{
  8772. key: "fromPort",
  8773. value: function fromPort(params) {
  8774. if (!params || !params.port) {
  8775. throw new Error('PDFWorker.fromPort - invalid method signature.');
  8776. }
  8777. if (pdfWorkerPorts.has(params.port)) {
  8778. return pdfWorkerPorts.get(params.port);
  8779. }
  8780. return new PDFWorker(params);
  8781. }
  8782. }, {
  8783. key: "getWorkerSrc",
  8784. value: function getWorkerSrc() {
  8785. return _getWorkerSrc();
  8786. }
  8787. }]);
  8788. return PDFWorker;
  8789. }();
  8790. return PDFWorker;
  8791. }();
  8792. exports.PDFWorker = PDFWorker;
  8793. var WorkerTransport =
  8794. /*#__PURE__*/
  8795. function () {
  8796. function WorkerTransport(messageHandler, loadingTask, networkStream, params) {
  8797. _classCallCheck(this, WorkerTransport);
  8798. this.messageHandler = messageHandler;
  8799. this.loadingTask = loadingTask;
  8800. this.commonObjs = new PDFObjects();
  8801. this.fontLoader = new _font_loader.FontLoader({
  8802. docId: loadingTask.docId,
  8803. onUnsupportedFeature: this._onUnsupportedFeature.bind(this)
  8804. });
  8805. this._params = params;
  8806. this.CMapReaderFactory = new params.CMapReaderFactory({
  8807. baseUrl: params.cMapUrl,
  8808. isCompressed: params.cMapPacked
  8809. });
  8810. this.destroyed = false;
  8811. this.destroyCapability = null;
  8812. this._passwordCapability = null;
  8813. this._networkStream = networkStream;
  8814. this._fullReader = null;
  8815. this._lastProgress = null;
  8816. this.pageCache = [];
  8817. this.pagePromises = [];
  8818. this.downloadInfoCapability = (0, _util.createPromiseCapability)();
  8819. this.setupMessageHandler();
  8820. }
  8821. _createClass(WorkerTransport, [{
  8822. key: "destroy",
  8823. value: function destroy() {
  8824. var _this9 = this;
  8825. if (this.destroyCapability) {
  8826. return this.destroyCapability.promise;
  8827. }
  8828. this.destroyed = true;
  8829. this.destroyCapability = (0, _util.createPromiseCapability)();
  8830. if (this._passwordCapability) {
  8831. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  8832. }
  8833. var waitOn = [];
  8834. this.pageCache.forEach(function (page) {
  8835. if (page) {
  8836. waitOn.push(page._destroy());
  8837. }
  8838. });
  8839. this.pageCache.length = 0;
  8840. this.pagePromises.length = 0;
  8841. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  8842. waitOn.push(terminated);
  8843. Promise.all(waitOn).then(function () {
  8844. _this9.fontLoader.clear();
  8845. if (_this9._networkStream) {
  8846. _this9._networkStream.cancelAllRequests();
  8847. }
  8848. if (_this9.messageHandler) {
  8849. _this9.messageHandler.destroy();
  8850. _this9.messageHandler = null;
  8851. }
  8852. _this9.destroyCapability.resolve();
  8853. }, this.destroyCapability.reject);
  8854. return this.destroyCapability.promise;
  8855. }
  8856. }, {
  8857. key: "setupMessageHandler",
  8858. value: function setupMessageHandler() {
  8859. var messageHandler = this.messageHandler,
  8860. loadingTask = this.loadingTask;
  8861. messageHandler.on('GetReader', function (data, sink) {
  8862. var _this10 = this;
  8863. (0, _util.assert)(this._networkStream);
  8864. this._fullReader = this._networkStream.getFullReader();
  8865. this._fullReader.onProgress = function (evt) {
  8866. _this10._lastProgress = {
  8867. loaded: evt.loaded,
  8868. total: evt.total
  8869. };
  8870. };
  8871. sink.onPull = function () {
  8872. _this10._fullReader.read().then(function (_ref7) {
  8873. var value = _ref7.value,
  8874. done = _ref7.done;
  8875. if (done) {
  8876. sink.close();
  8877. return;
  8878. }
  8879. (0, _util.assert)((0, _util.isArrayBuffer)(value));
  8880. sink.enqueue(new Uint8Array(value), 1, [value]);
  8881. })["catch"](function (reason) {
  8882. sink.error(reason);
  8883. });
  8884. };
  8885. sink.onCancel = function (reason) {
  8886. _this10._fullReader.cancel(reason);
  8887. };
  8888. }, this);
  8889. messageHandler.on('ReaderHeadersReady', function (data) {
  8890. var _this11 = this;
  8891. var headersCapability = (0, _util.createPromiseCapability)();
  8892. var fullReader = this._fullReader;
  8893. fullReader.headersReady.then(function () {
  8894. if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) {
  8895. if (_this11._lastProgress && loadingTask.onProgress) {
  8896. loadingTask.onProgress(_this11._lastProgress);
  8897. }
  8898. fullReader.onProgress = function (evt) {
  8899. if (loadingTask.onProgress) {
  8900. loadingTask.onProgress({
  8901. loaded: evt.loaded,
  8902. total: evt.total
  8903. });
  8904. }
  8905. };
  8906. }
  8907. headersCapability.resolve({
  8908. isStreamingSupported: fullReader.isStreamingSupported,
  8909. isRangeSupported: fullReader.isRangeSupported,
  8910. contentLength: fullReader.contentLength
  8911. });
  8912. }, headersCapability.reject);
  8913. return headersCapability.promise;
  8914. }, this);
  8915. messageHandler.on('GetRangeReader', function (data, sink) {
  8916. (0, _util.assert)(this._networkStream);
  8917. var rangeReader = this._networkStream.getRangeReader(data.begin, data.end);
  8918. if (!rangeReader) {
  8919. sink.close();
  8920. return;
  8921. }
  8922. sink.onPull = function () {
  8923. rangeReader.read().then(function (_ref8) {
  8924. var value = _ref8.value,
  8925. done = _ref8.done;
  8926. if (done) {
  8927. sink.close();
  8928. return;
  8929. }
  8930. (0, _util.assert)((0, _util.isArrayBuffer)(value));
  8931. sink.enqueue(new Uint8Array(value), 1, [value]);
  8932. })["catch"](function (reason) {
  8933. sink.error(reason);
  8934. });
  8935. };
  8936. sink.onCancel = function (reason) {
  8937. rangeReader.cancel(reason);
  8938. };
  8939. }, this);
  8940. messageHandler.on('GetDoc', function (_ref9) {
  8941. var pdfInfo = _ref9.pdfInfo;
  8942. this._numPages = pdfInfo.numPages;
  8943. loadingTask._capability.resolve(new PDFDocumentProxy(pdfInfo, this));
  8944. }, this);
  8945. messageHandler.on('PasswordRequest', function (exception) {
  8946. var _this12 = this;
  8947. this._passwordCapability = (0, _util.createPromiseCapability)();
  8948. if (loadingTask.onPassword) {
  8949. var updatePassword = function updatePassword(password) {
  8950. _this12._passwordCapability.resolve({
  8951. password: password
  8952. });
  8953. };
  8954. try {
  8955. loadingTask.onPassword(updatePassword, exception.code);
  8956. } catch (ex) {
  8957. this._passwordCapability.reject(ex);
  8958. }
  8959. } else {
  8960. this._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
  8961. }
  8962. return this._passwordCapability.promise;
  8963. }, this);
  8964. messageHandler.on('PasswordException', function (exception) {
  8965. loadingTask._capability.reject(new _util.PasswordException(exception.message, exception.code));
  8966. }, this);
  8967. messageHandler.on('InvalidPDF', function (exception) {
  8968. loadingTask._capability.reject(new _util.InvalidPDFException(exception.message));
  8969. }, this);
  8970. messageHandler.on('MissingPDF', function (exception) {
  8971. loadingTask._capability.reject(new _util.MissingPDFException(exception.message));
  8972. }, this);
  8973. messageHandler.on('UnexpectedResponse', function (exception) {
  8974. loadingTask._capability.reject(new _util.UnexpectedResponseException(exception.message, exception.status));
  8975. }, this);
  8976. messageHandler.on('UnknownError', function (exception) {
  8977. loadingTask._capability.reject(new _util.UnknownErrorException(exception.message, exception.details));
  8978. }, this);
  8979. messageHandler.on('DataLoaded', function (data) {
  8980. if (loadingTask.onProgress) {
  8981. loadingTask.onProgress({
  8982. loaded: data.length,
  8983. total: data.length
  8984. });
  8985. }
  8986. this.downloadInfoCapability.resolve(data);
  8987. }, this);
  8988. messageHandler.on('StartRenderPage', function (data) {
  8989. if (this.destroyed) {
  8990. return;
  8991. }
  8992. var page = this.pageCache[data.pageIndex];
  8993. page._stats.timeEnd('Page Request');
  8994. page._startRenderPage(data.transparency, data.intent);
  8995. }, this);
  8996. messageHandler.on('RenderPageChunk', function (data) {
  8997. if (this.destroyed) {
  8998. return;
  8999. }
  9000. var page = this.pageCache[data.pageIndex];
  9001. page._renderPageChunk(data.operatorList, data.intent);
  9002. }, this);
  9003. messageHandler.on('commonobj', function (data) {
  9004. var _this13 = this;
  9005. if (this.destroyed) {
  9006. return;
  9007. }
  9008. var _data = _slicedToArray(data, 3),
  9009. id = _data[0],
  9010. type = _data[1],
  9011. exportedData = _data[2];
  9012. if (this.commonObjs.has(id)) {
  9013. return;
  9014. }
  9015. switch (type) {
  9016. case 'Font':
  9017. var params = this._params;
  9018. if ('error' in exportedData) {
  9019. var exportedError = exportedData.error;
  9020. (0, _util.warn)("Error during font loading: ".concat(exportedError));
  9021. this.commonObjs.resolve(id, exportedError);
  9022. break;
  9023. }
  9024. var fontRegistry = null;
  9025. if (params.pdfBug && _global_scope["default"].FontInspector && _global_scope["default"].FontInspector.enabled) {
  9026. fontRegistry = {
  9027. registerFont: function registerFont(font, url) {
  9028. _global_scope["default"]['FontInspector'].fontAdded(font, url);
  9029. }
  9030. };
  9031. }
  9032. var font = new _font_loader.FontFaceObject(exportedData, {
  9033. isEvalSupported: params.isEvalSupported,
  9034. disableFontFace: params.disableFontFace,
  9035. ignoreErrors: params.ignoreErrors,
  9036. onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
  9037. fontRegistry: fontRegistry
  9038. });
  9039. this.fontLoader.bind(font).then(function () {
  9040. _this13.commonObjs.resolve(id, font);
  9041. }, function (reason) {
  9042. messageHandler.sendWithPromise('FontFallback', {
  9043. id: id
  9044. })["finally"](function () {
  9045. _this13.commonObjs.resolve(id, font);
  9046. });
  9047. });
  9048. break;
  9049. case 'FontPath':
  9050. case 'FontType3Res':
  9051. this.commonObjs.resolve(id, exportedData);
  9052. break;
  9053. default:
  9054. throw new Error("Got unknown common object type ".concat(type));
  9055. }
  9056. }, this);
  9057. messageHandler.on('obj', function (data) {
  9058. if (this.destroyed) {
  9059. return undefined;
  9060. }
  9061. var _data2 = _slicedToArray(data, 4),
  9062. id = _data2[0],
  9063. pageIndex = _data2[1],
  9064. type = _data2[2],
  9065. imageData = _data2[3];
  9066. var pageProxy = this.pageCache[pageIndex];
  9067. if (pageProxy.objs.has(id)) {
  9068. return undefined;
  9069. }
  9070. switch (type) {
  9071. case 'JpegStream':
  9072. return new Promise(function (resolve, reject) {
  9073. var img = new Image();
  9074. img.onload = function () {
  9075. resolve(img);
  9076. };
  9077. img.onerror = function () {
  9078. reject(new Error('Error during JPEG image loading'));
  9079. (0, _display_utils.releaseImageResources)(img);
  9080. };
  9081. img.src = imageData;
  9082. }).then(function (img) {
  9083. pageProxy.objs.resolve(id, img);
  9084. });
  9085. case 'Image':
  9086. pageProxy.objs.resolve(id, imageData);
  9087. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  9088. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  9089. pageProxy.cleanupAfterRender = true;
  9090. }
  9091. break;
  9092. default:
  9093. throw new Error("Got unknown object type ".concat(type));
  9094. }
  9095. return undefined;
  9096. }, this);
  9097. messageHandler.on('DocProgress', function (data) {
  9098. if (this.destroyed) {
  9099. return;
  9100. }
  9101. if (loadingTask.onProgress) {
  9102. loadingTask.onProgress({
  9103. loaded: data.loaded,
  9104. total: data.total
  9105. });
  9106. }
  9107. }, this);
  9108. messageHandler.on('PageError', function (data) {
  9109. if (this.destroyed) {
  9110. return;
  9111. }
  9112. var page = this.pageCache[data.pageIndex];
  9113. var intentState = page.intentStates[data.intent];
  9114. if (intentState.displayReadyCapability) {
  9115. intentState.displayReadyCapability.reject(new Error(data.error));
  9116. } else {
  9117. throw new Error(data.error);
  9118. }
  9119. if (intentState.operatorList) {
  9120. intentState.operatorList.lastChunk = true;
  9121. for (var i = 0; i < intentState.renderTasks.length; i++) {
  9122. intentState.renderTasks[i].operatorListChanged();
  9123. }
  9124. }
  9125. }, this);
  9126. messageHandler.on('UnsupportedFeature', this._onUnsupportedFeature, this);
  9127. messageHandler.on('JpegDecode', function (data) {
  9128. if (this.destroyed) {
  9129. return Promise.reject(new Error('Worker was destroyed'));
  9130. }
  9131. if (typeof document === 'undefined') {
  9132. return Promise.reject(new Error('"document" is not defined.'));
  9133. }
  9134. var _data3 = _slicedToArray(data, 2),
  9135. imageUrl = _data3[0],
  9136. components = _data3[1];
  9137. if (components !== 3 && components !== 1) {
  9138. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  9139. }
  9140. return new Promise(function (resolve, reject) {
  9141. var img = new Image();
  9142. img.onload = function () {
  9143. var width = img.width,
  9144. height = img.height;
  9145. var size = width * height;
  9146. var rgbaLength = size * 4;
  9147. var buf = new Uint8ClampedArray(size * components);
  9148. var tmpCanvas = document.createElement('canvas');
  9149. tmpCanvas.width = width;
  9150. tmpCanvas.height = height;
  9151. var tmpCtx = tmpCanvas.getContext('2d');
  9152. tmpCtx.drawImage(img, 0, 0);
  9153. var data = tmpCtx.getImageData(0, 0, width, height).data;
  9154. if (components === 3) {
  9155. for (var i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  9156. buf[j] = data[i];
  9157. buf[j + 1] = data[i + 1];
  9158. buf[j + 2] = data[i + 2];
  9159. }
  9160. } else if (components === 1) {
  9161. for (var _i2 = 0, _j = 0; _i2 < rgbaLength; _i2 += 4, _j++) {
  9162. buf[_j] = data[_i2];
  9163. }
  9164. }
  9165. resolve({
  9166. data: buf,
  9167. width: width,
  9168. height: height
  9169. });
  9170. (0, _display_utils.releaseImageResources)(img);
  9171. tmpCanvas.width = 0;
  9172. tmpCanvas.height = 0;
  9173. tmpCanvas = null;
  9174. tmpCtx = null;
  9175. };
  9176. img.onerror = function () {
  9177. reject(new Error('JpegDecode failed to load image'));
  9178. (0, _display_utils.releaseImageResources)(img);
  9179. };
  9180. img.src = imageUrl;
  9181. });
  9182. }, this);
  9183. messageHandler.on('FetchBuiltInCMap', function (data) {
  9184. if (this.destroyed) {
  9185. return Promise.reject(new Error('Worker was destroyed'));
  9186. }
  9187. return this.CMapReaderFactory.fetch({
  9188. name: data.name
  9189. });
  9190. }, this);
  9191. }
  9192. }, {
  9193. key: "_onUnsupportedFeature",
  9194. value: function _onUnsupportedFeature(_ref10) {
  9195. var featureId = _ref10.featureId;
  9196. if (this.destroyed) {
  9197. return;
  9198. }
  9199. if (this.loadingTask.onUnsupportedFeature) {
  9200. this.loadingTask.onUnsupportedFeature(featureId);
  9201. }
  9202. }
  9203. }, {
  9204. key: "getData",
  9205. value: function getData() {
  9206. return this.messageHandler.sendWithPromise('GetData', null);
  9207. }
  9208. }, {
  9209. key: "getPage",
  9210. value: function getPage(pageNumber) {
  9211. var _this14 = this;
  9212. if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this._numPages) {
  9213. return Promise.reject(new Error('Invalid page request'));
  9214. }
  9215. var pageIndex = pageNumber - 1;
  9216. if (pageIndex in this.pagePromises) {
  9217. return this.pagePromises[pageIndex];
  9218. }
  9219. var promise = this.messageHandler.sendWithPromise('GetPage', {
  9220. pageIndex: pageIndex
  9221. }).then(function (pageInfo) {
  9222. if (_this14.destroyed) {
  9223. throw new Error('Transport destroyed');
  9224. }
  9225. var page = new PDFPageProxy(pageIndex, pageInfo, _this14, _this14._params.pdfBug);
  9226. _this14.pageCache[pageIndex] = page;
  9227. return page;
  9228. });
  9229. this.pagePromises[pageIndex] = promise;
  9230. return promise;
  9231. }
  9232. }, {
  9233. key: "getPageIndex",
  9234. value: function getPageIndex(ref) {
  9235. return this.messageHandler.sendWithPromise('GetPageIndex', {
  9236. ref: ref
  9237. })["catch"](function (reason) {
  9238. return Promise.reject(new Error(reason));
  9239. });
  9240. }
  9241. }, {
  9242. key: "getAnnotations",
  9243. value: function getAnnotations(pageIndex, intent) {
  9244. return this.messageHandler.sendWithPromise('GetAnnotations', {
  9245. pageIndex: pageIndex,
  9246. intent: intent
  9247. });
  9248. }
  9249. }, {
  9250. key: "getDestinations",
  9251. value: function getDestinations() {
  9252. return this.messageHandler.sendWithPromise('GetDestinations', null);
  9253. }
  9254. }, {
  9255. key: "getDestination",
  9256. value: function getDestination(id) {
  9257. if (typeof id !== 'string') {
  9258. return Promise.reject(new Error('Invalid destination request.'));
  9259. }
  9260. return this.messageHandler.sendWithPromise('GetDestination', {
  9261. id: id
  9262. });
  9263. }
  9264. }, {
  9265. key: "getPageLabels",
  9266. value: function getPageLabels() {
  9267. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  9268. }
  9269. }, {
  9270. key: "getPageLayout",
  9271. value: function getPageLayout() {
  9272. return this.messageHandler.sendWithPromise('GetPageLayout', null);
  9273. }
  9274. }, {
  9275. key: "getPageMode",
  9276. value: function getPageMode() {
  9277. return this.messageHandler.sendWithPromise('GetPageMode', null);
  9278. }
  9279. }, {
  9280. key: "getViewerPreferences",
  9281. value: function getViewerPreferences() {
  9282. return this.messageHandler.sendWithPromise('GetViewerPreferences', null);
  9283. }
  9284. }, {
  9285. key: "getOpenActionDestination",
  9286. value: function getOpenActionDestination() {
  9287. return this.messageHandler.sendWithPromise('GetOpenActionDestination', null);
  9288. }
  9289. }, {
  9290. key: "getAttachments",
  9291. value: function getAttachments() {
  9292. return this.messageHandler.sendWithPromise('GetAttachments', null);
  9293. }
  9294. }, {
  9295. key: "getJavaScript",
  9296. value: function getJavaScript() {
  9297. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  9298. }
  9299. }, {
  9300. key: "getOutline",
  9301. value: function getOutline() {
  9302. return this.messageHandler.sendWithPromise('GetOutline', null);
  9303. }
  9304. }, {
  9305. key: "getPermissions",
  9306. value: function getPermissions() {
  9307. return this.messageHandler.sendWithPromise('GetPermissions', null);
  9308. }
  9309. }, {
  9310. key: "getMetadata",
  9311. value: function getMetadata() {
  9312. var _this15 = this;
  9313. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function (results) {
  9314. return {
  9315. info: results[0],
  9316. metadata: results[1] ? new _metadata.Metadata(results[1]) : null,
  9317. contentDispositionFilename: _this15._fullReader ? _this15._fullReader.filename : null
  9318. };
  9319. });
  9320. }
  9321. }, {
  9322. key: "getStats",
  9323. value: function getStats() {
  9324. return this.messageHandler.sendWithPromise('GetStats', null);
  9325. }
  9326. }, {
  9327. key: "startCleanup",
  9328. value: function startCleanup() {
  9329. var _this16 = this;
  9330. this.messageHandler.sendWithPromise('Cleanup', null).then(function () {
  9331. for (var i = 0, ii = _this16.pageCache.length; i < ii; i++) {
  9332. var page = _this16.pageCache[i];
  9333. if (page) {
  9334. page.cleanup();
  9335. }
  9336. }
  9337. _this16.commonObjs.clear();
  9338. _this16.fontLoader.clear();
  9339. });
  9340. }
  9341. }, {
  9342. key: "loadingParams",
  9343. get: function get() {
  9344. var params = this._params;
  9345. return (0, _util.shadow)(this, 'loadingParams', {
  9346. disableAutoFetch: params.disableAutoFetch,
  9347. disableCreateObjectURL: params.disableCreateObjectURL,
  9348. disableFontFace: params.disableFontFace,
  9349. nativeImageDecoderSupport: params.nativeImageDecoderSupport
  9350. });
  9351. }
  9352. }]);
  9353. return WorkerTransport;
  9354. }();
  9355. var PDFObjects =
  9356. /*#__PURE__*/
  9357. function () {
  9358. function PDFObjects() {
  9359. _classCallCheck(this, PDFObjects);
  9360. this._objs = Object.create(null);
  9361. }
  9362. _createClass(PDFObjects, [{
  9363. key: "_ensureObj",
  9364. value: function _ensureObj(objId) {
  9365. if (this._objs[objId]) {
  9366. return this._objs[objId];
  9367. }
  9368. return this._objs[objId] = {
  9369. capability: (0, _util.createPromiseCapability)(),
  9370. data: null,
  9371. resolved: false
  9372. };
  9373. }
  9374. }, {
  9375. key: "get",
  9376. value: function get(objId) {
  9377. var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  9378. if (callback) {
  9379. this._ensureObj(objId).capability.promise.then(callback);
  9380. return null;
  9381. }
  9382. var obj = this._objs[objId];
  9383. if (!obj || !obj.resolved) {
  9384. throw new Error("Requesting object that isn't resolved yet ".concat(objId, "."));
  9385. }
  9386. return obj.data;
  9387. }
  9388. }, {
  9389. key: "has",
  9390. value: function has(objId) {
  9391. var obj = this._objs[objId];
  9392. return obj ? obj.resolved : false;
  9393. }
  9394. }, {
  9395. key: "resolve",
  9396. value: function resolve(objId, data) {
  9397. var obj = this._ensureObj(objId);
  9398. obj.resolved = true;
  9399. obj.data = data;
  9400. obj.capability.resolve(data);
  9401. }
  9402. }, {
  9403. key: "clear",
  9404. value: function clear() {
  9405. for (var objId in this._objs) {
  9406. var data = this._objs[objId].data;
  9407. if (typeof Image !== 'undefined' && data instanceof Image) {
  9408. (0, _display_utils.releaseImageResources)(data);
  9409. }
  9410. }
  9411. this._objs = Object.create(null);
  9412. }
  9413. }]);
  9414. return PDFObjects;
  9415. }();
  9416. var RenderTask =
  9417. /*#__PURE__*/
  9418. function () {
  9419. function RenderTask(internalRenderTask) {
  9420. _classCallCheck(this, RenderTask);
  9421. this._internalRenderTask = internalRenderTask;
  9422. this.onContinue = null;
  9423. }
  9424. _createClass(RenderTask, [{
  9425. key: "cancel",
  9426. value: function cancel() {
  9427. this._internalRenderTask.cancel();
  9428. }
  9429. }, {
  9430. key: "then",
  9431. value: function then(onFulfilled, onRejected) {
  9432. (0, _display_utils.deprecated)('RenderTask.then method, use the `promise` getter instead.');
  9433. return this.promise.then.apply(this.promise, arguments);
  9434. }
  9435. }, {
  9436. key: "promise",
  9437. get: function get() {
  9438. return this._internalRenderTask.capability.promise;
  9439. }
  9440. }]);
  9441. return RenderTask;
  9442. }();
  9443. var InternalRenderTask = function InternalRenderTaskClosure() {
  9444. var canvasInRendering = new WeakSet();
  9445. var InternalRenderTask =
  9446. /*#__PURE__*/
  9447. function () {
  9448. function InternalRenderTask(_ref11) {
  9449. var callback = _ref11.callback,
  9450. params = _ref11.params,
  9451. objs = _ref11.objs,
  9452. commonObjs = _ref11.commonObjs,
  9453. operatorList = _ref11.operatorList,
  9454. pageNumber = _ref11.pageNumber,
  9455. canvasFactory = _ref11.canvasFactory,
  9456. webGLContext = _ref11.webGLContext,
  9457. _ref11$useRequestAnim = _ref11.useRequestAnimationFrame,
  9458. useRequestAnimationFrame = _ref11$useRequestAnim === void 0 ? false : _ref11$useRequestAnim,
  9459. _ref11$pdfBug = _ref11.pdfBug,
  9460. pdfBug = _ref11$pdfBug === void 0 ? false : _ref11$pdfBug;
  9461. _classCallCheck(this, InternalRenderTask);
  9462. this.callback = callback;
  9463. this.params = params;
  9464. this.objs = objs;
  9465. this.commonObjs = commonObjs;
  9466. this.operatorListIdx = null;
  9467. this.operatorList = operatorList;
  9468. this.pageNumber = pageNumber;
  9469. this.canvasFactory = canvasFactory;
  9470. this.webGLContext = webGLContext;
  9471. this._pdfBug = pdfBug;
  9472. this.running = false;
  9473. this.graphicsReadyCallback = null;
  9474. this.graphicsReady = false;
  9475. this._useRequestAnimationFrame = useRequestAnimationFrame === true && typeof window !== 'undefined';
  9476. this.cancelled = false;
  9477. this.capability = (0, _util.createPromiseCapability)();
  9478. this.task = new RenderTask(this);
  9479. this._continueBound = this._continue.bind(this);
  9480. this._scheduleNextBound = this._scheduleNext.bind(this);
  9481. this._nextBound = this._next.bind(this);
  9482. this._canvas = params.canvasContext.canvas;
  9483. }
  9484. _createClass(InternalRenderTask, [{
  9485. key: "initializeGraphics",
  9486. value: function initializeGraphics() {
  9487. var transparency = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9488. if (this.cancelled) {
  9489. return;
  9490. }
  9491. if (this._canvas) {
  9492. if (canvasInRendering.has(this._canvas)) {
  9493. throw new Error('Cannot use the same canvas during multiple render() operations. ' + 'Use different canvas or ensure previous operations were ' + 'cancelled or completed.');
  9494. }
  9495. canvasInRendering.add(this._canvas);
  9496. }
  9497. if (this._pdfBug && _global_scope["default"].StepperManager && _global_scope["default"].StepperManager.enabled) {
  9498. this.stepper = _global_scope["default"].StepperManager.create(this.pageNumber - 1);
  9499. this.stepper.init(this.operatorList);
  9500. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  9501. }
  9502. var _this$params = this.params,
  9503. canvasContext = _this$params.canvasContext,
  9504. viewport = _this$params.viewport,
  9505. transform = _this$params.transform,
  9506. imageLayer = _this$params.imageLayer,
  9507. background = _this$params.background;
  9508. this.gfx = new _canvas.CanvasGraphics(canvasContext, this.commonObjs, this.objs, this.canvasFactory, this.webGLContext, imageLayer);
  9509. this.gfx.beginDrawing({
  9510. transform: transform,
  9511. viewport: viewport,
  9512. transparency: transparency,
  9513. background: background
  9514. });
  9515. this.operatorListIdx = 0;
  9516. this.graphicsReady = true;
  9517. if (this.graphicsReadyCallback) {
  9518. this.graphicsReadyCallback();
  9519. }
  9520. }
  9521. }, {
  9522. key: "cancel",
  9523. value: function cancel() {
  9524. var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9525. this.running = false;
  9526. this.cancelled = true;
  9527. if (this.gfx) {
  9528. this.gfx.endDrawing();
  9529. }
  9530. if (this._canvas) {
  9531. canvasInRendering["delete"](this._canvas);
  9532. }
  9533. this.callback(error || new _display_utils.RenderingCancelledException("Rendering cancelled, page ".concat(this.pageNumber), 'canvas'));
  9534. }
  9535. }, {
  9536. key: "operatorListChanged",
  9537. value: function operatorListChanged() {
  9538. if (!this.graphicsReady) {
  9539. if (!this.graphicsReadyCallback) {
  9540. this.graphicsReadyCallback = this._continueBound;
  9541. }
  9542. return;
  9543. }
  9544. if (this.stepper) {
  9545. this.stepper.updateOperatorList(this.operatorList);
  9546. }
  9547. if (this.running) {
  9548. return;
  9549. }
  9550. this._continue();
  9551. }
  9552. }, {
  9553. key: "_continue",
  9554. value: function _continue() {
  9555. this.running = true;
  9556. if (this.cancelled) {
  9557. return;
  9558. }
  9559. if (this.task.onContinue) {
  9560. this.task.onContinue(this._scheduleNextBound);
  9561. } else {
  9562. this._scheduleNext();
  9563. }
  9564. }
  9565. }, {
  9566. key: "_scheduleNext",
  9567. value: function _scheduleNext() {
  9568. var _this17 = this;
  9569. if (this._useRequestAnimationFrame) {
  9570. window.requestAnimationFrame(function () {
  9571. _this17._nextBound()["catch"](_this17.cancel.bind(_this17));
  9572. });
  9573. } else {
  9574. Promise.resolve().then(this._nextBound)["catch"](this.cancel.bind(this));
  9575. }
  9576. }
  9577. }, {
  9578. key: "_next",
  9579. value: function () {
  9580. var _next2 = _asyncToGenerator(
  9581. /*#__PURE__*/
  9582. _regenerator["default"].mark(function _callee() {
  9583. return _regenerator["default"].wrap(function _callee$(_context) {
  9584. while (1) {
  9585. switch (_context.prev = _context.next) {
  9586. case 0:
  9587. if (!this.cancelled) {
  9588. _context.next = 2;
  9589. break;
  9590. }
  9591. return _context.abrupt("return");
  9592. case 2:
  9593. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  9594. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  9595. this.running = false;
  9596. if (this.operatorList.lastChunk) {
  9597. this.gfx.endDrawing();
  9598. if (this._canvas) {
  9599. canvasInRendering["delete"](this._canvas);
  9600. }
  9601. this.callback();
  9602. }
  9603. }
  9604. case 4:
  9605. case "end":
  9606. return _context.stop();
  9607. }
  9608. }
  9609. }, _callee, this);
  9610. }));
  9611. function _next() {
  9612. return _next2.apply(this, arguments);
  9613. }
  9614. return _next;
  9615. }()
  9616. }]);
  9617. return InternalRenderTask;
  9618. }();
  9619. return InternalRenderTask;
  9620. }();
  9621. var version = '2.2.228';
  9622. exports.version = version;
  9623. var build = 'd7afb74a';
  9624. exports.build = build;
  9625. /***/ }),
  9626. /* 148 */
  9627. /***/ (function(module, exports, __w_pdfjs_require__) {
  9628. "use strict";
  9629. module.exports = __w_pdfjs_require__(149);
  9630. /***/ }),
  9631. /* 149 */
  9632. /***/ (function(module, exports, __w_pdfjs_require__) {
  9633. "use strict";
  9634. /* WEBPACK VAR INJECTION */(function(module) {
  9635. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  9636. var runtime = function (exports) {
  9637. "use strict";
  9638. var Op = Object.prototype;
  9639. var hasOwn = Op.hasOwnProperty;
  9640. var undefined;
  9641. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  9642. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  9643. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  9644. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  9645. function wrap(innerFn, outerFn, self, tryLocsList) {
  9646. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  9647. var generator = Object.create(protoGenerator.prototype);
  9648. var context = new Context(tryLocsList || []);
  9649. generator._invoke = makeInvokeMethod(innerFn, self, context);
  9650. return generator;
  9651. }
  9652. exports.wrap = wrap;
  9653. function tryCatch(fn, obj, arg) {
  9654. try {
  9655. return {
  9656. type: "normal",
  9657. arg: fn.call(obj, arg)
  9658. };
  9659. } catch (err) {
  9660. return {
  9661. type: "throw",
  9662. arg: err
  9663. };
  9664. }
  9665. }
  9666. var GenStateSuspendedStart = "suspendedStart";
  9667. var GenStateSuspendedYield = "suspendedYield";
  9668. var GenStateExecuting = "executing";
  9669. var GenStateCompleted = "completed";
  9670. var ContinueSentinel = {};
  9671. function Generator() {}
  9672. function GeneratorFunction() {}
  9673. function GeneratorFunctionPrototype() {}
  9674. var IteratorPrototype = {};
  9675. IteratorPrototype[iteratorSymbol] = function () {
  9676. return this;
  9677. };
  9678. var getProto = Object.getPrototypeOf;
  9679. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  9680. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  9681. IteratorPrototype = NativeIteratorPrototype;
  9682. }
  9683. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  9684. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  9685. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  9686. GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
  9687. function defineIteratorMethods(prototype) {
  9688. ["next", "throw", "return"].forEach(function (method) {
  9689. prototype[method] = function (arg) {
  9690. return this._invoke(method, arg);
  9691. };
  9692. });
  9693. }
  9694. exports.isGeneratorFunction = function (genFun) {
  9695. var ctor = typeof genFun === "function" && genFun.constructor;
  9696. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  9697. };
  9698. exports.mark = function (genFun) {
  9699. if (Object.setPrototypeOf) {
  9700. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  9701. } else {
  9702. genFun.__proto__ = GeneratorFunctionPrototype;
  9703. if (!(toStringTagSymbol in genFun)) {
  9704. genFun[toStringTagSymbol] = "GeneratorFunction";
  9705. }
  9706. }
  9707. genFun.prototype = Object.create(Gp);
  9708. return genFun;
  9709. };
  9710. exports.awrap = function (arg) {
  9711. return {
  9712. __await: arg
  9713. };
  9714. };
  9715. function AsyncIterator(generator) {
  9716. function invoke(method, arg, resolve, reject) {
  9717. var record = tryCatch(generator[method], generator, arg);
  9718. if (record.type === "throw") {
  9719. reject(record.arg);
  9720. } else {
  9721. var result = record.arg;
  9722. var value = result.value;
  9723. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  9724. return Promise.resolve(value.__await).then(function (value) {
  9725. invoke("next", value, resolve, reject);
  9726. }, function (err) {
  9727. invoke("throw", err, resolve, reject);
  9728. });
  9729. }
  9730. return Promise.resolve(value).then(function (unwrapped) {
  9731. result.value = unwrapped;
  9732. resolve(result);
  9733. }, function (error) {
  9734. return invoke("throw", error, resolve, reject);
  9735. });
  9736. }
  9737. }
  9738. var previousPromise;
  9739. function enqueue(method, arg) {
  9740. function callInvokeWithMethodAndArg() {
  9741. return new Promise(function (resolve, reject) {
  9742. invoke(method, arg, resolve, reject);
  9743. });
  9744. }
  9745. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  9746. }
  9747. this._invoke = enqueue;
  9748. }
  9749. defineIteratorMethods(AsyncIterator.prototype);
  9750. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  9751. return this;
  9752. };
  9753. exports.AsyncIterator = AsyncIterator;
  9754. exports.async = function (innerFn, outerFn, self, tryLocsList) {
  9755. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
  9756. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  9757. return result.done ? result.value : iter.next();
  9758. });
  9759. };
  9760. function makeInvokeMethod(innerFn, self, context) {
  9761. var state = GenStateSuspendedStart;
  9762. return function invoke(method, arg) {
  9763. if (state === GenStateExecuting) {
  9764. throw new Error("Generator is already running");
  9765. }
  9766. if (state === GenStateCompleted) {
  9767. if (method === "throw") {
  9768. throw arg;
  9769. }
  9770. return doneResult();
  9771. }
  9772. context.method = method;
  9773. context.arg = arg;
  9774. while (true) {
  9775. var delegate = context.delegate;
  9776. if (delegate) {
  9777. var delegateResult = maybeInvokeDelegate(delegate, context);
  9778. if (delegateResult) {
  9779. if (delegateResult === ContinueSentinel) continue;
  9780. return delegateResult;
  9781. }
  9782. }
  9783. if (context.method === "next") {
  9784. context.sent = context._sent = context.arg;
  9785. } else if (context.method === "throw") {
  9786. if (state === GenStateSuspendedStart) {
  9787. state = GenStateCompleted;
  9788. throw context.arg;
  9789. }
  9790. context.dispatchException(context.arg);
  9791. } else if (context.method === "return") {
  9792. context.abrupt("return", context.arg);
  9793. }
  9794. state = GenStateExecuting;
  9795. var record = tryCatch(innerFn, self, context);
  9796. if (record.type === "normal") {
  9797. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  9798. if (record.arg === ContinueSentinel) {
  9799. continue;
  9800. }
  9801. return {
  9802. value: record.arg,
  9803. done: context.done
  9804. };
  9805. } else if (record.type === "throw") {
  9806. state = GenStateCompleted;
  9807. context.method = "throw";
  9808. context.arg = record.arg;
  9809. }
  9810. }
  9811. };
  9812. }
  9813. function maybeInvokeDelegate(delegate, context) {
  9814. var method = delegate.iterator[context.method];
  9815. if (method === undefined) {
  9816. context.delegate = null;
  9817. if (context.method === "throw") {
  9818. if (delegate.iterator["return"]) {
  9819. context.method = "return";
  9820. context.arg = undefined;
  9821. maybeInvokeDelegate(delegate, context);
  9822. if (context.method === "throw") {
  9823. return ContinueSentinel;
  9824. }
  9825. }
  9826. context.method = "throw";
  9827. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  9828. }
  9829. return ContinueSentinel;
  9830. }
  9831. var record = tryCatch(method, delegate.iterator, context.arg);
  9832. if (record.type === "throw") {
  9833. context.method = "throw";
  9834. context.arg = record.arg;
  9835. context.delegate = null;
  9836. return ContinueSentinel;
  9837. }
  9838. var info = record.arg;
  9839. if (!info) {
  9840. context.method = "throw";
  9841. context.arg = new TypeError("iterator result is not an object");
  9842. context.delegate = null;
  9843. return ContinueSentinel;
  9844. }
  9845. if (info.done) {
  9846. context[delegate.resultName] = info.value;
  9847. context.next = delegate.nextLoc;
  9848. if (context.method !== "return") {
  9849. context.method = "next";
  9850. context.arg = undefined;
  9851. }
  9852. } else {
  9853. return info;
  9854. }
  9855. context.delegate = null;
  9856. return ContinueSentinel;
  9857. }
  9858. defineIteratorMethods(Gp);
  9859. Gp[toStringTagSymbol] = "Generator";
  9860. Gp[iteratorSymbol] = function () {
  9861. return this;
  9862. };
  9863. Gp.toString = function () {
  9864. return "[object Generator]";
  9865. };
  9866. function pushTryEntry(locs) {
  9867. var entry = {
  9868. tryLoc: locs[0]
  9869. };
  9870. if (1 in locs) {
  9871. entry.catchLoc = locs[1];
  9872. }
  9873. if (2 in locs) {
  9874. entry.finallyLoc = locs[2];
  9875. entry.afterLoc = locs[3];
  9876. }
  9877. this.tryEntries.push(entry);
  9878. }
  9879. function resetTryEntry(entry) {
  9880. var record = entry.completion || {};
  9881. record.type = "normal";
  9882. delete record.arg;
  9883. entry.completion = record;
  9884. }
  9885. function Context(tryLocsList) {
  9886. this.tryEntries = [{
  9887. tryLoc: "root"
  9888. }];
  9889. tryLocsList.forEach(pushTryEntry, this);
  9890. this.reset(true);
  9891. }
  9892. exports.keys = function (object) {
  9893. var keys = [];
  9894. for (var key in object) {
  9895. keys.push(key);
  9896. }
  9897. keys.reverse();
  9898. return function next() {
  9899. while (keys.length) {
  9900. var key = keys.pop();
  9901. if (key in object) {
  9902. next.value = key;
  9903. next.done = false;
  9904. return next;
  9905. }
  9906. }
  9907. next.done = true;
  9908. return next;
  9909. };
  9910. };
  9911. function values(iterable) {
  9912. if (iterable) {
  9913. var iteratorMethod = iterable[iteratorSymbol];
  9914. if (iteratorMethod) {
  9915. return iteratorMethod.call(iterable);
  9916. }
  9917. if (typeof iterable.next === "function") {
  9918. return iterable;
  9919. }
  9920. if (!isNaN(iterable.length)) {
  9921. var i = -1,
  9922. next = function next() {
  9923. while (++i < iterable.length) {
  9924. if (hasOwn.call(iterable, i)) {
  9925. next.value = iterable[i];
  9926. next.done = false;
  9927. return next;
  9928. }
  9929. }
  9930. next.value = undefined;
  9931. next.done = true;
  9932. return next;
  9933. };
  9934. return next.next = next;
  9935. }
  9936. }
  9937. return {
  9938. next: doneResult
  9939. };
  9940. }
  9941. exports.values = values;
  9942. function doneResult() {
  9943. return {
  9944. value: undefined,
  9945. done: true
  9946. };
  9947. }
  9948. Context.prototype = {
  9949. constructor: Context,
  9950. reset: function reset(skipTempReset) {
  9951. this.prev = 0;
  9952. this.next = 0;
  9953. this.sent = this._sent = undefined;
  9954. this.done = false;
  9955. this.delegate = null;
  9956. this.method = "next";
  9957. this.arg = undefined;
  9958. this.tryEntries.forEach(resetTryEntry);
  9959. if (!skipTempReset) {
  9960. for (var name in this) {
  9961. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  9962. this[name] = undefined;
  9963. }
  9964. }
  9965. }
  9966. },
  9967. stop: function stop() {
  9968. this.done = true;
  9969. var rootEntry = this.tryEntries[0];
  9970. var rootRecord = rootEntry.completion;
  9971. if (rootRecord.type === "throw") {
  9972. throw rootRecord.arg;
  9973. }
  9974. return this.rval;
  9975. },
  9976. dispatchException: function dispatchException(exception) {
  9977. if (this.done) {
  9978. throw exception;
  9979. }
  9980. var context = this;
  9981. function handle(loc, caught) {
  9982. record.type = "throw";
  9983. record.arg = exception;
  9984. context.next = loc;
  9985. if (caught) {
  9986. context.method = "next";
  9987. context.arg = undefined;
  9988. }
  9989. return !!caught;
  9990. }
  9991. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  9992. var entry = this.tryEntries[i];
  9993. var record = entry.completion;
  9994. if (entry.tryLoc === "root") {
  9995. return handle("end");
  9996. }
  9997. if (entry.tryLoc <= this.prev) {
  9998. var hasCatch = hasOwn.call(entry, "catchLoc");
  9999. var hasFinally = hasOwn.call(entry, "finallyLoc");
  10000. if (hasCatch && hasFinally) {
  10001. if (this.prev < entry.catchLoc) {
  10002. return handle(entry.catchLoc, true);
  10003. } else if (this.prev < entry.finallyLoc) {
  10004. return handle(entry.finallyLoc);
  10005. }
  10006. } else if (hasCatch) {
  10007. if (this.prev < entry.catchLoc) {
  10008. return handle(entry.catchLoc, true);
  10009. }
  10010. } else if (hasFinally) {
  10011. if (this.prev < entry.finallyLoc) {
  10012. return handle(entry.finallyLoc);
  10013. }
  10014. } else {
  10015. throw new Error("try statement without catch or finally");
  10016. }
  10017. }
  10018. }
  10019. },
  10020. abrupt: function abrupt(type, arg) {
  10021. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  10022. var entry = this.tryEntries[i];
  10023. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  10024. var finallyEntry = entry;
  10025. break;
  10026. }
  10027. }
  10028. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  10029. finallyEntry = null;
  10030. }
  10031. var record = finallyEntry ? finallyEntry.completion : {};
  10032. record.type = type;
  10033. record.arg = arg;
  10034. if (finallyEntry) {
  10035. this.method = "next";
  10036. this.next = finallyEntry.finallyLoc;
  10037. return ContinueSentinel;
  10038. }
  10039. return this.complete(record);
  10040. },
  10041. complete: function complete(record, afterLoc) {
  10042. if (record.type === "throw") {
  10043. throw record.arg;
  10044. }
  10045. if (record.type === "break" || record.type === "continue") {
  10046. this.next = record.arg;
  10047. } else if (record.type === "return") {
  10048. this.rval = this.arg = record.arg;
  10049. this.method = "return";
  10050. this.next = "end";
  10051. } else if (record.type === "normal" && afterLoc) {
  10052. this.next = afterLoc;
  10053. }
  10054. return ContinueSentinel;
  10055. },
  10056. finish: function finish(finallyLoc) {
  10057. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  10058. var entry = this.tryEntries[i];
  10059. if (entry.finallyLoc === finallyLoc) {
  10060. this.complete(entry.completion, entry.afterLoc);
  10061. resetTryEntry(entry);
  10062. return ContinueSentinel;
  10063. }
  10064. }
  10065. },
  10066. "catch": function _catch(tryLoc) {
  10067. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  10068. var entry = this.tryEntries[i];
  10069. if (entry.tryLoc === tryLoc) {
  10070. var record = entry.completion;
  10071. if (record.type === "throw") {
  10072. var thrown = record.arg;
  10073. resetTryEntry(entry);
  10074. }
  10075. return thrown;
  10076. }
  10077. }
  10078. throw new Error("illegal catch attempt");
  10079. },
  10080. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  10081. this.delegate = {
  10082. iterator: values(iterable),
  10083. resultName: resultName,
  10084. nextLoc: nextLoc
  10085. };
  10086. if (this.method === "next") {
  10087. this.arg = undefined;
  10088. }
  10089. return ContinueSentinel;
  10090. }
  10091. };
  10092. return exports;
  10093. }(( false ? undefined : _typeof(module)) === "object" ? module.exports : {});
  10094. try {
  10095. regeneratorRuntime = runtime;
  10096. } catch (accidentalStrictMode) {
  10097. Function("r", "regeneratorRuntime = r")(runtime);
  10098. }
  10099. /* WEBPACK VAR INJECTION */}.call(this, __w_pdfjs_require__(150)(module)))
  10100. /***/ }),
  10101. /* 150 */
  10102. /***/ (function(module, exports, __w_pdfjs_require__) {
  10103. "use strict";
  10104. module.exports = function (module) {
  10105. if (!module.webpackPolyfill) {
  10106. module.deprecate = function () {};
  10107. module.paths = [];
  10108. if (!module.children) module.children = [];
  10109. Object.defineProperty(module, "loaded", {
  10110. enumerable: true,
  10111. get: function get() {
  10112. return module.l;
  10113. }
  10114. });
  10115. Object.defineProperty(module, "id", {
  10116. enumerable: true,
  10117. get: function get() {
  10118. return module.i;
  10119. }
  10120. });
  10121. module.webpackPolyfill = 1;
  10122. }
  10123. return module;
  10124. };
  10125. /***/ }),
  10126. /* 151 */
  10127. /***/ (function(module, exports, __w_pdfjs_require__) {
  10128. "use strict";
  10129. Object.defineProperty(exports, "__esModule", {
  10130. value: true
  10131. });
  10132. exports.addLinkAttributes = addLinkAttributes;
  10133. exports.getFilenameFromUrl = getFilenameFromUrl;
  10134. exports.isFetchSupported = isFetchSupported;
  10135. exports.isValidFetchUrl = isValidFetchUrl;
  10136. exports.loadScript = loadScript;
  10137. exports.deprecated = deprecated;
  10138. exports.releaseImageResources = releaseImageResources;
  10139. exports.PDFDateString = exports.DummyStatTimer = exports.StatTimer = exports.DOMSVGFactory = exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = exports.DEFAULT_LINK_REL = exports.LinkTarget = exports.RenderingCancelledException = exports.PageViewport = void 0;
  10140. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(148));
  10141. var _util = __w_pdfjs_require__(1);
  10142. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10143. 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); } }
  10144. 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); }); }; }
  10145. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10146. 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); } }
  10147. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10148. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  10149. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  10150. var SVG_NS = 'http://www.w3.org/2000/svg';
  10151. var DOMCanvasFactory =
  10152. /*#__PURE__*/
  10153. function () {
  10154. function DOMCanvasFactory() {
  10155. _classCallCheck(this, DOMCanvasFactory);
  10156. }
  10157. _createClass(DOMCanvasFactory, [{
  10158. key: "create",
  10159. value: function create(width, height) {
  10160. if (width <= 0 || height <= 0) {
  10161. throw new Error('Invalid canvas size');
  10162. }
  10163. var canvas = document.createElement('canvas');
  10164. var context = canvas.getContext('2d');
  10165. canvas.width = width;
  10166. canvas.height = height;
  10167. return {
  10168. canvas: canvas,
  10169. context: context
  10170. };
  10171. }
  10172. }, {
  10173. key: "reset",
  10174. value: function reset(canvasAndContext, width, height) {
  10175. if (!canvasAndContext.canvas) {
  10176. throw new Error('Canvas is not specified');
  10177. }
  10178. if (width <= 0 || height <= 0) {
  10179. throw new Error('Invalid canvas size');
  10180. }
  10181. canvasAndContext.canvas.width = width;
  10182. canvasAndContext.canvas.height = height;
  10183. }
  10184. }, {
  10185. key: "destroy",
  10186. value: function destroy(canvasAndContext) {
  10187. if (!canvasAndContext.canvas) {
  10188. throw new Error('Canvas is not specified');
  10189. }
  10190. canvasAndContext.canvas.width = 0;
  10191. canvasAndContext.canvas.height = 0;
  10192. canvasAndContext.canvas = null;
  10193. canvasAndContext.context = null;
  10194. }
  10195. }]);
  10196. return DOMCanvasFactory;
  10197. }();
  10198. exports.DOMCanvasFactory = DOMCanvasFactory;
  10199. var DOMCMapReaderFactory =
  10200. /*#__PURE__*/
  10201. function () {
  10202. function DOMCMapReaderFactory(_ref) {
  10203. var _ref$baseUrl = _ref.baseUrl,
  10204. baseUrl = _ref$baseUrl === void 0 ? null : _ref$baseUrl,
  10205. _ref$isCompressed = _ref.isCompressed,
  10206. isCompressed = _ref$isCompressed === void 0 ? false : _ref$isCompressed;
  10207. _classCallCheck(this, DOMCMapReaderFactory);
  10208. this.baseUrl = baseUrl;
  10209. this.isCompressed = isCompressed;
  10210. }
  10211. _createClass(DOMCMapReaderFactory, [{
  10212. key: "fetch",
  10213. value: function (_fetch) {
  10214. function fetch(_x) {
  10215. return _fetch.apply(this, arguments);
  10216. }
  10217. fetch.toString = function () {
  10218. return _fetch.toString();
  10219. };
  10220. return fetch;
  10221. }(
  10222. /*#__PURE__*/
  10223. function () {
  10224. var _ref3 = _asyncToGenerator(
  10225. /*#__PURE__*/
  10226. _regenerator["default"].mark(function _callee2(_ref2) {
  10227. var _this = this;
  10228. var name, url, compressionType;
  10229. return _regenerator["default"].wrap(function _callee2$(_context2) {
  10230. while (1) {
  10231. switch (_context2.prev = _context2.next) {
  10232. case 0:
  10233. name = _ref2.name;
  10234. if (this.baseUrl) {
  10235. _context2.next = 3;
  10236. break;
  10237. }
  10238. throw new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.');
  10239. case 3:
  10240. if (name) {
  10241. _context2.next = 5;
  10242. break;
  10243. }
  10244. throw new Error('CMap name must be specified.');
  10245. case 5:
  10246. url = this.baseUrl + name + (this.isCompressed ? '.bcmap' : '');
  10247. compressionType = this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE;
  10248. if (!(isFetchSupported() && isValidFetchUrl(url, document.baseURI))) {
  10249. _context2.next = 9;
  10250. break;
  10251. }
  10252. return _context2.abrupt("return", fetch(url).then(
  10253. /*#__PURE__*/
  10254. function () {
  10255. var _ref4 = _asyncToGenerator(
  10256. /*#__PURE__*/
  10257. _regenerator["default"].mark(function _callee(response) {
  10258. var cMapData;
  10259. return _regenerator["default"].wrap(function _callee$(_context) {
  10260. while (1) {
  10261. switch (_context.prev = _context.next) {
  10262. case 0:
  10263. if (response.ok) {
  10264. _context.next = 2;
  10265. break;
  10266. }
  10267. throw new Error(response.statusText);
  10268. case 2:
  10269. if (!_this.isCompressed) {
  10270. _context.next = 10;
  10271. break;
  10272. }
  10273. _context.t0 = Uint8Array;
  10274. _context.next = 6;
  10275. return response.arrayBuffer();
  10276. case 6:
  10277. _context.t1 = _context.sent;
  10278. cMapData = new _context.t0(_context.t1);
  10279. _context.next = 15;
  10280. break;
  10281. case 10:
  10282. _context.t2 = _util.stringToBytes;
  10283. _context.next = 13;
  10284. return response.text();
  10285. case 13:
  10286. _context.t3 = _context.sent;
  10287. cMapData = (0, _context.t2)(_context.t3);
  10288. case 15:
  10289. return _context.abrupt("return", {
  10290. cMapData: cMapData,
  10291. compressionType: compressionType
  10292. });
  10293. case 16:
  10294. case "end":
  10295. return _context.stop();
  10296. }
  10297. }
  10298. }, _callee);
  10299. }));
  10300. return function (_x3) {
  10301. return _ref4.apply(this, arguments);
  10302. };
  10303. }())["catch"](function (reason) {
  10304. throw new Error("Unable to load ".concat(_this.isCompressed ? 'binary ' : '') + "CMap at: ".concat(url));
  10305. }));
  10306. case 9:
  10307. return _context2.abrupt("return", new Promise(function (resolve, reject) {
  10308. var request = new XMLHttpRequest();
  10309. request.open('GET', url, true);
  10310. if (_this.isCompressed) {
  10311. request.responseType = 'arraybuffer';
  10312. }
  10313. request.onreadystatechange = function () {
  10314. if (request.readyState !== XMLHttpRequest.DONE) {
  10315. return;
  10316. }
  10317. if (request.status === 200 || request.status === 0) {
  10318. var cMapData;
  10319. if (_this.isCompressed && request.response) {
  10320. cMapData = new Uint8Array(request.response);
  10321. } else if (!_this.isCompressed && request.responseText) {
  10322. cMapData = (0, _util.stringToBytes)(request.responseText);
  10323. }
  10324. if (cMapData) {
  10325. resolve({
  10326. cMapData: cMapData,
  10327. compressionType: compressionType
  10328. });
  10329. return;
  10330. }
  10331. }
  10332. reject(new Error(request.statusText));
  10333. };
  10334. request.send(null);
  10335. })["catch"](function (reason) {
  10336. throw new Error("Unable to load ".concat(_this.isCompressed ? 'binary ' : '') + "CMap at: ".concat(url));
  10337. }));
  10338. case 10:
  10339. case "end":
  10340. return _context2.stop();
  10341. }
  10342. }
  10343. }, _callee2, this);
  10344. }));
  10345. return function (_x2) {
  10346. return _ref3.apply(this, arguments);
  10347. };
  10348. }())
  10349. }]);
  10350. return DOMCMapReaderFactory;
  10351. }();
  10352. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  10353. var DOMSVGFactory =
  10354. /*#__PURE__*/
  10355. function () {
  10356. function DOMSVGFactory() {
  10357. _classCallCheck(this, DOMSVGFactory);
  10358. }
  10359. _createClass(DOMSVGFactory, [{
  10360. key: "create",
  10361. value: function create(width, height) {
  10362. (0, _util.assert)(width > 0 && height > 0, 'Invalid SVG dimensions');
  10363. var svg = document.createElementNS(SVG_NS, 'svg:svg');
  10364. svg.setAttribute('version', '1.1');
  10365. svg.setAttribute('width', width + 'px');
  10366. svg.setAttribute('height', height + 'px');
  10367. svg.setAttribute('preserveAspectRatio', 'none');
  10368. svg.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
  10369. return svg;
  10370. }
  10371. }, {
  10372. key: "createElement",
  10373. value: function createElement(type) {
  10374. (0, _util.assert)(typeof type === 'string', 'Invalid SVG element type');
  10375. return document.createElementNS(SVG_NS, type);
  10376. }
  10377. }]);
  10378. return DOMSVGFactory;
  10379. }();
  10380. exports.DOMSVGFactory = DOMSVGFactory;
  10381. var PageViewport =
  10382. /*#__PURE__*/
  10383. function () {
  10384. function PageViewport(_ref5) {
  10385. var viewBox = _ref5.viewBox,
  10386. scale = _ref5.scale,
  10387. rotation = _ref5.rotation,
  10388. _ref5$offsetX = _ref5.offsetX,
  10389. offsetX = _ref5$offsetX === void 0 ? 0 : _ref5$offsetX,
  10390. _ref5$offsetY = _ref5.offsetY,
  10391. offsetY = _ref5$offsetY === void 0 ? 0 : _ref5$offsetY,
  10392. _ref5$dontFlip = _ref5.dontFlip,
  10393. dontFlip = _ref5$dontFlip === void 0 ? false : _ref5$dontFlip;
  10394. _classCallCheck(this, PageViewport);
  10395. this.viewBox = viewBox;
  10396. this.scale = scale;
  10397. this.rotation = rotation;
  10398. this.offsetX = offsetX;
  10399. this.offsetY = offsetY;
  10400. var centerX = (viewBox[2] + viewBox[0]) / 2;
  10401. var centerY = (viewBox[3] + viewBox[1]) / 2;
  10402. var rotateA, rotateB, rotateC, rotateD;
  10403. rotation = rotation % 360;
  10404. rotation = rotation < 0 ? rotation + 360 : rotation;
  10405. switch (rotation) {
  10406. case 180:
  10407. rotateA = -1;
  10408. rotateB = 0;
  10409. rotateC = 0;
  10410. rotateD = 1;
  10411. break;
  10412. case 90:
  10413. rotateA = 0;
  10414. rotateB = 1;
  10415. rotateC = 1;
  10416. rotateD = 0;
  10417. break;
  10418. case 270:
  10419. rotateA = 0;
  10420. rotateB = -1;
  10421. rotateC = -1;
  10422. rotateD = 0;
  10423. break;
  10424. default:
  10425. rotateA = 1;
  10426. rotateB = 0;
  10427. rotateC = 0;
  10428. rotateD = -1;
  10429. break;
  10430. }
  10431. if (dontFlip) {
  10432. rotateC = -rotateC;
  10433. rotateD = -rotateD;
  10434. }
  10435. var offsetCanvasX, offsetCanvasY;
  10436. var width, height;
  10437. if (rotateA === 0) {
  10438. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  10439. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  10440. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  10441. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  10442. } else {
  10443. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  10444. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  10445. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  10446. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  10447. }
  10448. this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
  10449. this.width = width;
  10450. this.height = height;
  10451. }
  10452. _createClass(PageViewport, [{
  10453. key: "clone",
  10454. value: function clone() {
  10455. var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  10456. _ref6$scale = _ref6.scale,
  10457. scale = _ref6$scale === void 0 ? this.scale : _ref6$scale,
  10458. _ref6$rotation = _ref6.rotation,
  10459. rotation = _ref6$rotation === void 0 ? this.rotation : _ref6$rotation,
  10460. _ref6$dontFlip = _ref6.dontFlip,
  10461. dontFlip = _ref6$dontFlip === void 0 ? false : _ref6$dontFlip;
  10462. return new PageViewport({
  10463. viewBox: this.viewBox.slice(),
  10464. scale: scale,
  10465. rotation: rotation,
  10466. offsetX: this.offsetX,
  10467. offsetY: this.offsetY,
  10468. dontFlip: dontFlip
  10469. });
  10470. }
  10471. }, {
  10472. key: "convertToViewportPoint",
  10473. value: function convertToViewportPoint(x, y) {
  10474. return _util.Util.applyTransform([x, y], this.transform);
  10475. }
  10476. }, {
  10477. key: "convertToViewportRectangle",
  10478. value: function convertToViewportRectangle(rect) {
  10479. var topLeft = _util.Util.applyTransform([rect[0], rect[1]], this.transform);
  10480. var bottomRight = _util.Util.applyTransform([rect[2], rect[3]], this.transform);
  10481. return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];
  10482. }
  10483. }, {
  10484. key: "convertToPdfPoint",
  10485. value: function convertToPdfPoint(x, y) {
  10486. return _util.Util.applyInverseTransform([x, y], this.transform);
  10487. }
  10488. }]);
  10489. return PageViewport;
  10490. }();
  10491. exports.PageViewport = PageViewport;
  10492. var RenderingCancelledException = function RenderingCancelledException() {
  10493. function RenderingCancelledException(msg, type) {
  10494. this.message = msg;
  10495. this.type = type;
  10496. }
  10497. RenderingCancelledException.prototype = new Error();
  10498. RenderingCancelledException.prototype.name = 'RenderingCancelledException';
  10499. RenderingCancelledException.constructor = RenderingCancelledException;
  10500. return RenderingCancelledException;
  10501. }();
  10502. exports.RenderingCancelledException = RenderingCancelledException;
  10503. var LinkTarget = {
  10504. NONE: 0,
  10505. SELF: 1,
  10506. BLANK: 2,
  10507. PARENT: 3,
  10508. TOP: 4
  10509. };
  10510. exports.LinkTarget = LinkTarget;
  10511. var LinkTargetStringMap = ['', '_self', '_blank', '_parent', '_top'];
  10512. function addLinkAttributes(link) {
  10513. var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  10514. url = _ref7.url,
  10515. target = _ref7.target,
  10516. rel = _ref7.rel;
  10517. link.href = link.title = url ? (0, _util.removeNullCharacters)(url) : '';
  10518. if (url) {
  10519. var LinkTargetValues = Object.values(LinkTarget);
  10520. var targetIndex = LinkTargetValues.includes(target) ? target : LinkTarget.NONE;
  10521. link.target = LinkTargetStringMap[targetIndex];
  10522. link.rel = typeof rel === 'string' ? rel : DEFAULT_LINK_REL;
  10523. }
  10524. }
  10525. function getFilenameFromUrl(url) {
  10526. var anchor = url.indexOf('#');
  10527. var query = url.indexOf('?');
  10528. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  10529. return url.substring(url.lastIndexOf('/', end) + 1, end);
  10530. }
  10531. var StatTimer =
  10532. /*#__PURE__*/
  10533. function () {
  10534. function StatTimer() {
  10535. var enable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  10536. _classCallCheck(this, StatTimer);
  10537. this.enabled = !!enable;
  10538. this.started = Object.create(null);
  10539. this.times = [];
  10540. }
  10541. _createClass(StatTimer, [{
  10542. key: "time",
  10543. value: function time(name) {
  10544. if (!this.enabled) {
  10545. return;
  10546. }
  10547. if (name in this.started) {
  10548. (0, _util.warn)('Timer is already running for ' + name);
  10549. }
  10550. this.started[name] = Date.now();
  10551. }
  10552. }, {
  10553. key: "timeEnd",
  10554. value: function timeEnd(name) {
  10555. if (!this.enabled) {
  10556. return;
  10557. }
  10558. if (!(name in this.started)) {
  10559. (0, _util.warn)('Timer has not been started for ' + name);
  10560. }
  10561. this.times.push({
  10562. 'name': name,
  10563. 'start': this.started[name],
  10564. 'end': Date.now()
  10565. });
  10566. delete this.started[name];
  10567. }
  10568. }, {
  10569. key: "toString",
  10570. value: function toString() {
  10571. var out = '',
  10572. longest = 0;
  10573. var _iteratorNormalCompletion = true;
  10574. var _didIteratorError = false;
  10575. var _iteratorError = undefined;
  10576. try {
  10577. for (var _iterator = this.times[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  10578. var time = _step.value;
  10579. var name = time.name;
  10580. if (name.length > longest) {
  10581. longest = name.length;
  10582. }
  10583. }
  10584. } catch (err) {
  10585. _didIteratorError = true;
  10586. _iteratorError = err;
  10587. } finally {
  10588. try {
  10589. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  10590. _iterator["return"]();
  10591. }
  10592. } finally {
  10593. if (_didIteratorError) {
  10594. throw _iteratorError;
  10595. }
  10596. }
  10597. }
  10598. var _iteratorNormalCompletion2 = true;
  10599. var _didIteratorError2 = false;
  10600. var _iteratorError2 = undefined;
  10601. try {
  10602. for (var _iterator2 = this.times[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  10603. var _time = _step2.value;
  10604. var duration = _time.end - _time.start;
  10605. out += "".concat(_time.name.padEnd(longest), " ").concat(duration, "ms\n");
  10606. }
  10607. } catch (err) {
  10608. _didIteratorError2 = true;
  10609. _iteratorError2 = err;
  10610. } finally {
  10611. try {
  10612. if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
  10613. _iterator2["return"]();
  10614. }
  10615. } finally {
  10616. if (_didIteratorError2) {
  10617. throw _iteratorError2;
  10618. }
  10619. }
  10620. }
  10621. return out;
  10622. }
  10623. }]);
  10624. return StatTimer;
  10625. }();
  10626. exports.StatTimer = StatTimer;
  10627. var DummyStatTimer =
  10628. /*#__PURE__*/
  10629. function () {
  10630. function DummyStatTimer() {
  10631. _classCallCheck(this, DummyStatTimer);
  10632. (0, _util.unreachable)('Cannot initialize DummyStatTimer.');
  10633. }
  10634. _createClass(DummyStatTimer, null, [{
  10635. key: "time",
  10636. value: function time(name) {}
  10637. }, {
  10638. key: "timeEnd",
  10639. value: function timeEnd(name) {}
  10640. }, {
  10641. key: "toString",
  10642. value: function toString() {
  10643. return '';
  10644. }
  10645. }]);
  10646. return DummyStatTimer;
  10647. }();
  10648. exports.DummyStatTimer = DummyStatTimer;
  10649. function isFetchSupported() {
  10650. return typeof fetch !== 'undefined' && typeof Response !== 'undefined' && 'body' in Response.prototype && typeof ReadableStream !== 'undefined';
  10651. }
  10652. function isValidFetchUrl(url, baseUrl) {
  10653. try {
  10654. var _ref8 = baseUrl ? new _util.URL(url, baseUrl) : new _util.URL(url),
  10655. protocol = _ref8.protocol;
  10656. return protocol === 'http:' || protocol === 'https:';
  10657. } catch (ex) {
  10658. return false;
  10659. }
  10660. }
  10661. function loadScript(src) {
  10662. return new Promise(function (resolve, reject) {
  10663. var script = document.createElement('script');
  10664. script.src = src;
  10665. script.onload = resolve;
  10666. script.onerror = function () {
  10667. reject(new Error("Cannot load script at: ".concat(script.src)));
  10668. };
  10669. (document.head || document.documentElement).appendChild(script);
  10670. });
  10671. }
  10672. function deprecated(details) {
  10673. console.log('Deprecated API usage: ' + details);
  10674. }
  10675. function releaseImageResources(img) {
  10676. (0, _util.assert)(img instanceof Image, 'Invalid `img` parameter.');
  10677. var url = img.src;
  10678. if (typeof url === 'string' && url.startsWith('blob:') && _util.URL.revokeObjectURL) {
  10679. _util.URL.revokeObjectURL(url);
  10680. }
  10681. img.removeAttribute('src');
  10682. }
  10683. var pdfDateStringRegex;
  10684. var PDFDateString =
  10685. /*#__PURE__*/
  10686. function () {
  10687. function PDFDateString() {
  10688. _classCallCheck(this, PDFDateString);
  10689. }
  10690. _createClass(PDFDateString, null, [{
  10691. key: "toDateObject",
  10692. value: function toDateObject(input) {
  10693. if (!input || !(0, _util.isString)(input)) {
  10694. return null;
  10695. }
  10696. if (!pdfDateStringRegex) {
  10697. pdfDateStringRegex = new RegExp('^D:' + '(\\d{4})' + '(\\d{2})?' + '(\\d{2})?' + '(\\d{2})?' + '(\\d{2})?' + '(\\d{2})?' + '([Z|+|-])?' + '(\\d{2})?' + '\'?' + '(\\d{2})?' + '\'?');
  10698. }
  10699. var matches = pdfDateStringRegex.exec(input);
  10700. if (!matches) {
  10701. return null;
  10702. }
  10703. var year = parseInt(matches[1], 10);
  10704. var month = parseInt(matches[2], 10);
  10705. month = month >= 1 && month <= 12 ? month - 1 : 0;
  10706. var day = parseInt(matches[3], 10);
  10707. day = day >= 1 && day <= 31 ? day : 1;
  10708. var hour = parseInt(matches[4], 10);
  10709. hour = hour >= 0 && hour <= 23 ? hour : 0;
  10710. var minute = parseInt(matches[5], 10);
  10711. minute = minute >= 0 && minute <= 59 ? minute : 0;
  10712. var second = parseInt(matches[6], 10);
  10713. second = second >= 0 && second <= 59 ? second : 0;
  10714. var universalTimeRelation = matches[7] || 'Z';
  10715. var offsetHour = parseInt(matches[8], 10);
  10716. offsetHour = offsetHour >= 0 && offsetHour <= 23 ? offsetHour : 0;
  10717. var offsetMinute = parseInt(matches[9], 10) || 0;
  10718. offsetMinute = offsetMinute >= 0 && offsetMinute <= 59 ? offsetMinute : 0;
  10719. if (universalTimeRelation === '-') {
  10720. hour += offsetHour;
  10721. minute += offsetMinute;
  10722. } else if (universalTimeRelation === '+') {
  10723. hour -= offsetHour;
  10724. minute -= offsetMinute;
  10725. }
  10726. return new Date(Date.UTC(year, month, day, hour, minute, second));
  10727. }
  10728. }]);
  10729. return PDFDateString;
  10730. }();
  10731. exports.PDFDateString = PDFDateString;
  10732. /***/ }),
  10733. /* 152 */
  10734. /***/ (function(module, exports, __w_pdfjs_require__) {
  10735. "use strict";
  10736. Object.defineProperty(exports, "__esModule", {
  10737. value: true
  10738. });
  10739. exports.FontLoader = exports.FontFaceObject = void 0;
  10740. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(148));
  10741. var _util = __w_pdfjs_require__(1);
  10742. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  10743. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  10744. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10745. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10746. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10747. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  10748. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10749. 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); } }
  10750. 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); }); }; }
  10751. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10752. 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); } }
  10753. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10754. var BaseFontLoader =
  10755. /*#__PURE__*/
  10756. function () {
  10757. function BaseFontLoader(_ref) {
  10758. var docId = _ref.docId,
  10759. onUnsupportedFeature = _ref.onUnsupportedFeature;
  10760. _classCallCheck(this, BaseFontLoader);
  10761. if (this.constructor === BaseFontLoader) {
  10762. (0, _util.unreachable)('Cannot initialize BaseFontLoader.');
  10763. }
  10764. this.docId = docId;
  10765. this._onUnsupportedFeature = onUnsupportedFeature;
  10766. this.nativeFontFaces = [];
  10767. this.styleElement = null;
  10768. }
  10769. _createClass(BaseFontLoader, [{
  10770. key: "addNativeFontFace",
  10771. value: function addNativeFontFace(nativeFontFace) {
  10772. this.nativeFontFaces.push(nativeFontFace);
  10773. document.fonts.add(nativeFontFace);
  10774. }
  10775. }, {
  10776. key: "insertRule",
  10777. value: function insertRule(rule) {
  10778. var styleElement = this.styleElement;
  10779. if (!styleElement) {
  10780. styleElement = this.styleElement = document.createElement('style');
  10781. styleElement.id = "PDFJS_FONT_STYLE_TAG_".concat(this.docId);
  10782. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  10783. }
  10784. var styleSheet = styleElement.sheet;
  10785. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  10786. }
  10787. }, {
  10788. key: "clear",
  10789. value: function clear() {
  10790. this.nativeFontFaces.forEach(function (nativeFontFace) {
  10791. document.fonts["delete"](nativeFontFace);
  10792. });
  10793. this.nativeFontFaces.length = 0;
  10794. if (this.styleElement) {
  10795. this.styleElement.remove();
  10796. this.styleElement = null;
  10797. }
  10798. }
  10799. }, {
  10800. key: "bind",
  10801. value: function () {
  10802. var _bind = _asyncToGenerator(
  10803. /*#__PURE__*/
  10804. _regenerator["default"].mark(function _callee(font) {
  10805. var _this = this;
  10806. var nativeFontFace, rule;
  10807. return _regenerator["default"].wrap(function _callee$(_context) {
  10808. while (1) {
  10809. switch (_context.prev = _context.next) {
  10810. case 0:
  10811. if (!(font.attached || font.missingFile)) {
  10812. _context.next = 2;
  10813. break;
  10814. }
  10815. return _context.abrupt("return", undefined);
  10816. case 2:
  10817. font.attached = true;
  10818. if (!this.isFontLoadingAPISupported) {
  10819. _context.next = 19;
  10820. break;
  10821. }
  10822. nativeFontFace = font.createNativeFontFace();
  10823. if (!nativeFontFace) {
  10824. _context.next = 18;
  10825. break;
  10826. }
  10827. this.addNativeFontFace(nativeFontFace);
  10828. _context.prev = 7;
  10829. _context.next = 10;
  10830. return nativeFontFace.loaded;
  10831. case 10:
  10832. _context.next = 18;
  10833. break;
  10834. case 12:
  10835. _context.prev = 12;
  10836. _context.t0 = _context["catch"](7);
  10837. this._onUnsupportedFeature({
  10838. featureId: _util.UNSUPPORTED_FEATURES.font
  10839. });
  10840. (0, _util.warn)("Failed to load font '".concat(nativeFontFace.family, "': '").concat(_context.t0, "'."));
  10841. font.disableFontFace = true;
  10842. throw _context.t0;
  10843. case 18:
  10844. return _context.abrupt("return", undefined);
  10845. case 19:
  10846. rule = font.createFontFaceRule();
  10847. if (!rule) {
  10848. _context.next = 25;
  10849. break;
  10850. }
  10851. this.insertRule(rule);
  10852. if (!this.isSyncFontLoadingSupported) {
  10853. _context.next = 24;
  10854. break;
  10855. }
  10856. return _context.abrupt("return", undefined);
  10857. case 24:
  10858. return _context.abrupt("return", new Promise(function (resolve) {
  10859. var request = _this._queueLoadingCallback(resolve);
  10860. _this._prepareFontLoadEvent([rule], [font], request);
  10861. }));
  10862. case 25:
  10863. return _context.abrupt("return", undefined);
  10864. case 26:
  10865. case "end":
  10866. return _context.stop();
  10867. }
  10868. }
  10869. }, _callee, this, [[7, 12]]);
  10870. }));
  10871. function bind(_x) {
  10872. return _bind.apply(this, arguments);
  10873. }
  10874. return bind;
  10875. }()
  10876. }, {
  10877. key: "_queueLoadingCallback",
  10878. value: function _queueLoadingCallback(callback) {
  10879. (0, _util.unreachable)('Abstract method `_queueLoadingCallback`.');
  10880. }
  10881. }, {
  10882. key: "_prepareFontLoadEvent",
  10883. value: function _prepareFontLoadEvent(rules, fontsToLoad, request) {
  10884. (0, _util.unreachable)('Abstract method `_prepareFontLoadEvent`.');
  10885. }
  10886. }, {
  10887. key: "isFontLoadingAPISupported",
  10888. get: function get() {
  10889. (0, _util.unreachable)('Abstract method `isFontLoadingAPISupported`.');
  10890. }
  10891. }, {
  10892. key: "isSyncFontLoadingSupported",
  10893. get: function get() {
  10894. (0, _util.unreachable)('Abstract method `isSyncFontLoadingSupported`.');
  10895. }
  10896. }, {
  10897. key: "_loadTestFont",
  10898. get: function get() {
  10899. (0, _util.unreachable)('Abstract method `_loadTestFont`.');
  10900. }
  10901. }]);
  10902. return BaseFontLoader;
  10903. }();
  10904. var FontLoader;
  10905. exports.FontLoader = FontLoader;
  10906. {
  10907. exports.FontLoader = FontLoader =
  10908. /*#__PURE__*/
  10909. function (_BaseFontLoader) {
  10910. _inherits(GenericFontLoader, _BaseFontLoader);
  10911. function GenericFontLoader(docId) {
  10912. var _this2;
  10913. _classCallCheck(this, GenericFontLoader);
  10914. _this2 = _possibleConstructorReturn(this, _getPrototypeOf(GenericFontLoader).call(this, docId));
  10915. _this2.loadingContext = {
  10916. requests: [],
  10917. nextRequestId: 0
  10918. };
  10919. _this2.loadTestFontId = 0;
  10920. return _this2;
  10921. }
  10922. _createClass(GenericFontLoader, [{
  10923. key: "_queueLoadingCallback",
  10924. value: function _queueLoadingCallback(callback) {
  10925. function completeRequest() {
  10926. (0, _util.assert)(!request.done, 'completeRequest() cannot be called twice.');
  10927. request.done = true;
  10928. while (context.requests.length > 0 && context.requests[0].done) {
  10929. var otherRequest = context.requests.shift();
  10930. setTimeout(otherRequest.callback, 0);
  10931. }
  10932. }
  10933. var context = this.loadingContext;
  10934. var request = {
  10935. id: "pdfjs-font-loading-".concat(context.nextRequestId++),
  10936. done: false,
  10937. complete: completeRequest,
  10938. callback: callback
  10939. };
  10940. context.requests.push(request);
  10941. return request;
  10942. }
  10943. }, {
  10944. key: "_prepareFontLoadEvent",
  10945. value: function _prepareFontLoadEvent(rules, fonts, request) {
  10946. function int32(data, offset) {
  10947. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  10948. }
  10949. function spliceString(s, offset, remove, insert) {
  10950. var chunk1 = s.substring(0, offset);
  10951. var chunk2 = s.substring(offset + remove);
  10952. return chunk1 + insert + chunk2;
  10953. }
  10954. var i, ii;
  10955. var canvas = document.createElement('canvas');
  10956. canvas.width = 1;
  10957. canvas.height = 1;
  10958. var ctx = canvas.getContext('2d');
  10959. var called = 0;
  10960. function isFontReady(name, callback) {
  10961. called++;
  10962. if (called > 30) {
  10963. (0, _util.warn)('Load test font never loaded.');
  10964. callback();
  10965. return;
  10966. }
  10967. ctx.font = '30px ' + name;
  10968. ctx.fillText('.', 0, 20);
  10969. var imageData = ctx.getImageData(0, 0, 1, 1);
  10970. if (imageData.data[3] > 0) {
  10971. callback();
  10972. return;
  10973. }
  10974. setTimeout(isFontReady.bind(null, name, callback));
  10975. }
  10976. var loadTestFontId = "lt".concat(Date.now()).concat(this.loadTestFontId++);
  10977. var data = this._loadTestFont;
  10978. var COMMENT_OFFSET = 976;
  10979. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  10980. var CFF_CHECKSUM_OFFSET = 16;
  10981. var XXXX_VALUE = 0x58585858;
  10982. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  10983. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  10984. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  10985. }
  10986. if (i < loadTestFontId.length) {
  10987. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  10988. }
  10989. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, (0, _util.string32)(checksum));
  10990. var url = "url(data:font/opentype;base64,".concat(btoa(data), ");");
  10991. var rule = "@font-face {font-family:\"".concat(loadTestFontId, "\";src:").concat(url, "}");
  10992. this.insertRule(rule);
  10993. var names = [];
  10994. for (i = 0, ii = fonts.length; i < ii; i++) {
  10995. names.push(fonts[i].loadedName);
  10996. }
  10997. names.push(loadTestFontId);
  10998. var div = document.createElement('div');
  10999. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  11000. for (i = 0, ii = names.length; i < ii; ++i) {
  11001. var span = document.createElement('span');
  11002. span.textContent = 'Hi';
  11003. span.style.fontFamily = names[i];
  11004. div.appendChild(span);
  11005. }
  11006. document.body.appendChild(div);
  11007. isFontReady(loadTestFontId, function () {
  11008. document.body.removeChild(div);
  11009. request.complete();
  11010. });
  11011. }
  11012. }, {
  11013. key: "isFontLoadingAPISupported",
  11014. get: function get() {
  11015. var supported = typeof document !== 'undefined' && !!document.fonts;
  11016. if (supported && typeof navigator !== 'undefined') {
  11017. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  11018. if (m && m[1] < 63) {
  11019. supported = false;
  11020. }
  11021. }
  11022. return (0, _util.shadow)(this, 'isFontLoadingAPISupported', supported);
  11023. }
  11024. }, {
  11025. key: "isSyncFontLoadingSupported",
  11026. get: function get() {
  11027. var supported = false;
  11028. if (typeof navigator === 'undefined') {
  11029. supported = true;
  11030. } else {
  11031. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  11032. if (m && m[1] >= 14) {
  11033. supported = true;
  11034. }
  11035. }
  11036. return (0, _util.shadow)(this, 'isSyncFontLoadingSupported', supported);
  11037. }
  11038. }, {
  11039. key: "_loadTestFont",
  11040. get: function get() {
  11041. var getLoadTestFont = function getLoadTestFont() {
  11042. return atob('T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQA' + 'FQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAA' + 'ALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgA' + 'AAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1' + 'AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD' + '6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACM' + 'AooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4D' + 'IP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAA' + 'AAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUA' + 'AQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgAB' + 'AAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABY' + 'AAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAA' + 'AC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAA' + 'AAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQAC' + 'AQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3' + 'Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTj' + 'FQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==');
  11043. };
  11044. return (0, _util.shadow)(this, '_loadTestFont', getLoadTestFont());
  11045. }
  11046. }]);
  11047. return GenericFontLoader;
  11048. }(BaseFontLoader);
  11049. }
  11050. var IsEvalSupportedCached = {
  11051. get value() {
  11052. return (0, _util.shadow)(this, 'value', (0, _util.isEvalSupported)());
  11053. }
  11054. };
  11055. var FontFaceObject =
  11056. /*#__PURE__*/
  11057. function () {
  11058. function FontFaceObject(translatedData, _ref2) {
  11059. var _ref2$isEvalSupported = _ref2.isEvalSupported,
  11060. isEvalSupported = _ref2$isEvalSupported === void 0 ? true : _ref2$isEvalSupported,
  11061. _ref2$disableFontFace = _ref2.disableFontFace,
  11062. disableFontFace = _ref2$disableFontFace === void 0 ? false : _ref2$disableFontFace,
  11063. _ref2$ignoreErrors = _ref2.ignoreErrors,
  11064. ignoreErrors = _ref2$ignoreErrors === void 0 ? false : _ref2$ignoreErrors,
  11065. _ref2$onUnsupportedFe = _ref2.onUnsupportedFeature,
  11066. onUnsupportedFeature = _ref2$onUnsupportedFe === void 0 ? null : _ref2$onUnsupportedFe,
  11067. _ref2$fontRegistry = _ref2.fontRegistry,
  11068. fontRegistry = _ref2$fontRegistry === void 0 ? null : _ref2$fontRegistry;
  11069. _classCallCheck(this, FontFaceObject);
  11070. this.compiledGlyphs = Object.create(null);
  11071. for (var i in translatedData) {
  11072. this[i] = translatedData[i];
  11073. }
  11074. this.isEvalSupported = isEvalSupported !== false;
  11075. this.disableFontFace = disableFontFace === true;
  11076. this.ignoreErrors = ignoreErrors === true;
  11077. this._onUnsupportedFeature = onUnsupportedFeature;
  11078. this.fontRegistry = fontRegistry;
  11079. }
  11080. _createClass(FontFaceObject, [{
  11081. key: "createNativeFontFace",
  11082. value: function createNativeFontFace() {
  11083. if (!this.data || this.disableFontFace) {
  11084. return null;
  11085. }
  11086. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  11087. if (this.fontRegistry) {
  11088. this.fontRegistry.registerFont(this);
  11089. }
  11090. return nativeFontFace;
  11091. }
  11092. }, {
  11093. key: "createFontFaceRule",
  11094. value: function createFontFaceRule() {
  11095. if (!this.data || this.disableFontFace) {
  11096. return null;
  11097. }
  11098. var data = (0, _util.bytesToString)(new Uint8Array(this.data));
  11099. var url = "url(data:".concat(this.mimetype, ";base64,").concat(btoa(data), ");");
  11100. var rule = "@font-face {font-family:\"".concat(this.loadedName, "\";src:").concat(url, "}");
  11101. if (this.fontRegistry) {
  11102. this.fontRegistry.registerFont(this, url);
  11103. }
  11104. return rule;
  11105. }
  11106. }, {
  11107. key: "getPathGenerator",
  11108. value: function getPathGenerator(objs, character) {
  11109. if (this.compiledGlyphs[character] !== undefined) {
  11110. return this.compiledGlyphs[character];
  11111. }
  11112. var cmds, current;
  11113. try {
  11114. cmds = objs.get(this.loadedName + '_path_' + character);
  11115. } catch (ex) {
  11116. if (!this.ignoreErrors) {
  11117. throw ex;
  11118. }
  11119. if (this._onUnsupportedFeature) {
  11120. this._onUnsupportedFeature({
  11121. featureId: _util.UNSUPPORTED_FEATURES.font
  11122. });
  11123. }
  11124. (0, _util.warn)("getPathGenerator - ignoring character: \"".concat(ex, "\"."));
  11125. return this.compiledGlyphs[character] = function (c, size) {};
  11126. }
  11127. if (this.isEvalSupported && IsEvalSupportedCached.value) {
  11128. var args,
  11129. js = '';
  11130. for (var i = 0, ii = cmds.length; i < ii; i++) {
  11131. current = cmds[i];
  11132. if (current.args !== undefined) {
  11133. args = current.args.join(',');
  11134. } else {
  11135. args = '';
  11136. }
  11137. js += 'c.' + current.cmd + '(' + args + ');\n';
  11138. }
  11139. return this.compiledGlyphs[character] = new Function('c', 'size', js);
  11140. }
  11141. return this.compiledGlyphs[character] = function (c, size) {
  11142. for (var _i = 0, _ii = cmds.length; _i < _ii; _i++) {
  11143. current = cmds[_i];
  11144. if (current.cmd === 'scale') {
  11145. current.args = [size, -size];
  11146. }
  11147. c[current.cmd].apply(c, current.args);
  11148. }
  11149. };
  11150. }
  11151. }]);
  11152. return FontFaceObject;
  11153. }();
  11154. exports.FontFaceObject = FontFaceObject;
  11155. /***/ }),
  11156. /* 153 */
  11157. /***/ (function(module, exports, __w_pdfjs_require__) {
  11158. "use strict";
  11159. var compatibilityParams = Object.create(null);
  11160. {
  11161. var isNodeJS = __w_pdfjs_require__(4);
  11162. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  11163. var isIE = /Trident/.test(userAgent);
  11164. var isIOSChrome = /CriOS/.test(userAgent);
  11165. (function checkOnBlobSupport() {
  11166. if (isIE || isIOSChrome) {
  11167. compatibilityParams.disableCreateObjectURL = true;
  11168. }
  11169. })();
  11170. (function checkFontFaceAndImage() {
  11171. if (isNodeJS()) {
  11172. compatibilityParams.disableFontFace = true;
  11173. compatibilityParams.nativeImageDecoderSupport = 'none';
  11174. }
  11175. })();
  11176. }
  11177. exports.apiCompatibilityParams = Object.freeze(compatibilityParams);
  11178. /***/ }),
  11179. /* 154 */
  11180. /***/ (function(module, exports, __w_pdfjs_require__) {
  11181. "use strict";
  11182. Object.defineProperty(exports, "__esModule", {
  11183. value: true
  11184. });
  11185. exports.CanvasGraphics = void 0;
  11186. var _util = __w_pdfjs_require__(1);
  11187. var _pattern_helper = __w_pdfjs_require__(155);
  11188. var MIN_FONT_SIZE = 16;
  11189. var MAX_FONT_SIZE = 100;
  11190. var MAX_GROUP_SIZE = 4096;
  11191. var MIN_WIDTH_FACTOR = 0.65;
  11192. var COMPILE_TYPE3_GLYPHS = true;
  11193. var MAX_SIZE_TO_COMPILE = 1000;
  11194. var FULL_CHUNK_HEIGHT = 16;
  11195. var IsLittleEndianCached = {
  11196. get value() {
  11197. return (0, _util.shadow)(IsLittleEndianCached, 'value', (0, _util.isLittleEndian)());
  11198. }
  11199. };
  11200. function addContextCurrentTransform(ctx) {
  11201. if (!ctx.mozCurrentTransform) {
  11202. ctx._originalSave = ctx.save;
  11203. ctx._originalRestore = ctx.restore;
  11204. ctx._originalRotate = ctx.rotate;
  11205. ctx._originalScale = ctx.scale;
  11206. ctx._originalTranslate = ctx.translate;
  11207. ctx._originalTransform = ctx.transform;
  11208. ctx._originalSetTransform = ctx.setTransform;
  11209. ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0];
  11210. ctx._transformStack = [];
  11211. Object.defineProperty(ctx, 'mozCurrentTransform', {
  11212. get: function getCurrentTransform() {
  11213. return this._transformMatrix;
  11214. }
  11215. });
  11216. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  11217. get: function getCurrentTransformInverse() {
  11218. var m = this._transformMatrix;
  11219. var a = m[0],
  11220. b = m[1],
  11221. c = m[2],
  11222. d = m[3],
  11223. e = m[4],
  11224. f = m[5];
  11225. var ad_bc = a * d - b * c;
  11226. var bc_ad = b * c - a * d;
  11227. return [d / ad_bc, b / bc_ad, c / bc_ad, a / ad_bc, (d * e - c * f) / bc_ad, (b * e - a * f) / ad_bc];
  11228. }
  11229. });
  11230. ctx.save = function ctxSave() {
  11231. var old = this._transformMatrix;
  11232. this._transformStack.push(old);
  11233. this._transformMatrix = old.slice(0, 6);
  11234. this._originalSave();
  11235. };
  11236. ctx.restore = function ctxRestore() {
  11237. var prev = this._transformStack.pop();
  11238. if (prev) {
  11239. this._transformMatrix = prev;
  11240. this._originalRestore();
  11241. }
  11242. };
  11243. ctx.translate = function ctxTranslate(x, y) {
  11244. var m = this._transformMatrix;
  11245. m[4] = m[0] * x + m[2] * y + m[4];
  11246. m[5] = m[1] * x + m[3] * y + m[5];
  11247. this._originalTranslate(x, y);
  11248. };
  11249. ctx.scale = function ctxScale(x, y) {
  11250. var m = this._transformMatrix;
  11251. m[0] = m[0] * x;
  11252. m[1] = m[1] * x;
  11253. m[2] = m[2] * y;
  11254. m[3] = m[3] * y;
  11255. this._originalScale(x, y);
  11256. };
  11257. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  11258. var m = this._transformMatrix;
  11259. this._transformMatrix = [m[0] * a + m[2] * b, m[1] * a + m[3] * b, m[0] * c + m[2] * d, m[1] * c + m[3] * d, m[0] * e + m[2] * f + m[4], m[1] * e + m[3] * f + m[5]];
  11260. ctx._originalTransform(a, b, c, d, e, f);
  11261. };
  11262. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  11263. this._transformMatrix = [a, b, c, d, e, f];
  11264. ctx._originalSetTransform(a, b, c, d, e, f);
  11265. };
  11266. ctx.rotate = function ctxRotate(angle) {
  11267. var cosValue = Math.cos(angle);
  11268. var sinValue = Math.sin(angle);
  11269. var m = this._transformMatrix;
  11270. this._transformMatrix = [m[0] * cosValue + m[2] * sinValue, m[1] * cosValue + m[3] * sinValue, m[0] * -sinValue + m[2] * cosValue, m[1] * -sinValue + m[3] * cosValue, m[4], m[5]];
  11271. this._originalRotate(angle);
  11272. };
  11273. }
  11274. }
  11275. var CachedCanvases = function CachedCanvasesClosure() {
  11276. function CachedCanvases(canvasFactory) {
  11277. this.canvasFactory = canvasFactory;
  11278. this.cache = Object.create(null);
  11279. }
  11280. CachedCanvases.prototype = {
  11281. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  11282. var canvasEntry;
  11283. if (this.cache[id] !== undefined) {
  11284. canvasEntry = this.cache[id];
  11285. this.canvasFactory.reset(canvasEntry, width, height);
  11286. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  11287. } else {
  11288. canvasEntry = this.canvasFactory.create(width, height);
  11289. this.cache[id] = canvasEntry;
  11290. }
  11291. if (trackTransform) {
  11292. addContextCurrentTransform(canvasEntry.context);
  11293. }
  11294. return canvasEntry;
  11295. },
  11296. clear: function clear() {
  11297. for (var id in this.cache) {
  11298. var canvasEntry = this.cache[id];
  11299. this.canvasFactory.destroy(canvasEntry);
  11300. delete this.cache[id];
  11301. }
  11302. }
  11303. };
  11304. return CachedCanvases;
  11305. }();
  11306. function compileType3Glyph(imgData) {
  11307. var POINT_TO_PROCESS_LIMIT = 1000;
  11308. var width = imgData.width,
  11309. height = imgData.height;
  11310. var i,
  11311. j,
  11312. j0,
  11313. width1 = width + 1;
  11314. var points = new Uint8Array(width1 * (height + 1));
  11315. var POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]);
  11316. var lineSize = width + 7 & ~7,
  11317. data0 = imgData.data;
  11318. var data = new Uint8Array(lineSize * height),
  11319. pos = 0,
  11320. ii;
  11321. for (i = 0, ii = data0.length; i < ii; i++) {
  11322. var mask = 128,
  11323. elem = data0[i];
  11324. while (mask > 0) {
  11325. data[pos++] = elem & mask ? 0 : 255;
  11326. mask >>= 1;
  11327. }
  11328. }
  11329. var count = 0;
  11330. pos = 0;
  11331. if (data[pos] !== 0) {
  11332. points[0] = 1;
  11333. ++count;
  11334. }
  11335. for (j = 1; j < width; j++) {
  11336. if (data[pos] !== data[pos + 1]) {
  11337. points[j] = data[pos] ? 2 : 1;
  11338. ++count;
  11339. }
  11340. pos++;
  11341. }
  11342. if (data[pos] !== 0) {
  11343. points[j] = 2;
  11344. ++count;
  11345. }
  11346. for (i = 1; i < height; i++) {
  11347. pos = i * lineSize;
  11348. j0 = i * width1;
  11349. if (data[pos - lineSize] !== data[pos]) {
  11350. points[j0] = data[pos] ? 1 : 8;
  11351. ++count;
  11352. }
  11353. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  11354. for (j = 1; j < width; j++) {
  11355. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  11356. if (POINT_TYPES[sum]) {
  11357. points[j0 + j] = POINT_TYPES[sum];
  11358. ++count;
  11359. }
  11360. pos++;
  11361. }
  11362. if (data[pos - lineSize] !== data[pos]) {
  11363. points[j0 + j] = data[pos] ? 2 : 4;
  11364. ++count;
  11365. }
  11366. if (count > POINT_TO_PROCESS_LIMIT) {
  11367. return null;
  11368. }
  11369. }
  11370. pos = lineSize * (height - 1);
  11371. j0 = i * width1;
  11372. if (data[pos] !== 0) {
  11373. points[j0] = 8;
  11374. ++count;
  11375. }
  11376. for (j = 1; j < width; j++) {
  11377. if (data[pos] !== data[pos + 1]) {
  11378. points[j0 + j] = data[pos] ? 4 : 8;
  11379. ++count;
  11380. }
  11381. pos++;
  11382. }
  11383. if (data[pos] !== 0) {
  11384. points[j0 + j] = 4;
  11385. ++count;
  11386. }
  11387. if (count > POINT_TO_PROCESS_LIMIT) {
  11388. return null;
  11389. }
  11390. var steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
  11391. var outlines = [];
  11392. for (i = 0; count && i <= height; i++) {
  11393. var p = i * width1;
  11394. var end = p + width;
  11395. while (p < end && !points[p]) {
  11396. p++;
  11397. }
  11398. if (p === end) {
  11399. continue;
  11400. }
  11401. var coords = [p % width1, i];
  11402. var type = points[p],
  11403. p0 = p,
  11404. pp;
  11405. do {
  11406. var step = steps[type];
  11407. do {
  11408. p += step;
  11409. } while (!points[p]);
  11410. pp = points[p];
  11411. if (pp !== 5 && pp !== 10) {
  11412. type = pp;
  11413. points[p] = 0;
  11414. } else {
  11415. type = pp & 0x33 * type >> 4;
  11416. points[p] &= type >> 2 | type << 2;
  11417. }
  11418. coords.push(p % width1);
  11419. coords.push(p / width1 | 0);
  11420. if (!points[p]) {
  11421. --count;
  11422. }
  11423. } while (p0 !== p);
  11424. outlines.push(coords);
  11425. --i;
  11426. }
  11427. var drawOutline = function drawOutline(c) {
  11428. c.save();
  11429. c.scale(1 / width, -1 / height);
  11430. c.translate(0, -height);
  11431. c.beginPath();
  11432. for (var i = 0, ii = outlines.length; i < ii; i++) {
  11433. var o = outlines[i];
  11434. c.moveTo(o[0], o[1]);
  11435. for (var j = 2, jj = o.length; j < jj; j += 2) {
  11436. c.lineTo(o[j], o[j + 1]);
  11437. }
  11438. }
  11439. c.fill();
  11440. c.beginPath();
  11441. c.restore();
  11442. };
  11443. return drawOutline;
  11444. }
  11445. var CanvasExtraState = function CanvasExtraStateClosure() {
  11446. function CanvasExtraState() {
  11447. this.alphaIsShape = false;
  11448. this.fontSize = 0;
  11449. this.fontSizeScale = 1;
  11450. this.textMatrix = _util.IDENTITY_MATRIX;
  11451. this.textMatrixScale = 1;
  11452. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  11453. this.leading = 0;
  11454. this.x = 0;
  11455. this.y = 0;
  11456. this.lineX = 0;
  11457. this.lineY = 0;
  11458. this.charSpacing = 0;
  11459. this.wordSpacing = 0;
  11460. this.textHScale = 1;
  11461. this.textRenderingMode = _util.TextRenderingMode.FILL;
  11462. this.textRise = 0;
  11463. this.fillColor = '#000000';
  11464. this.strokeColor = '#000000';
  11465. this.patternFill = false;
  11466. this.fillAlpha = 1;
  11467. this.strokeAlpha = 1;
  11468. this.lineWidth = 1;
  11469. this.activeSMask = null;
  11470. this.resumeSMaskCtx = null;
  11471. }
  11472. CanvasExtraState.prototype = {
  11473. clone: function CanvasExtraState_clone() {
  11474. return Object.create(this);
  11475. },
  11476. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  11477. this.x = x;
  11478. this.y = y;
  11479. }
  11480. };
  11481. return CanvasExtraState;
  11482. }();
  11483. var CanvasGraphics = function CanvasGraphicsClosure() {
  11484. var EXECUTION_TIME = 15;
  11485. var EXECUTION_STEPS = 10;
  11486. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, webGLContext, imageLayer) {
  11487. this.ctx = canvasCtx;
  11488. this.current = new CanvasExtraState();
  11489. this.stateStack = [];
  11490. this.pendingClip = null;
  11491. this.pendingEOFill = false;
  11492. this.res = null;
  11493. this.xobjs = null;
  11494. this.commonObjs = commonObjs;
  11495. this.objs = objs;
  11496. this.canvasFactory = canvasFactory;
  11497. this.webGLContext = webGLContext;
  11498. this.imageLayer = imageLayer;
  11499. this.groupStack = [];
  11500. this.processingType3 = null;
  11501. this.baseTransform = null;
  11502. this.baseTransformStack = [];
  11503. this.groupLevel = 0;
  11504. this.smaskStack = [];
  11505. this.smaskCounter = 0;
  11506. this.tempSMask = null;
  11507. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  11508. if (canvasCtx) {
  11509. addContextCurrentTransform(canvasCtx);
  11510. }
  11511. this._cachedGetSinglePixelWidth = null;
  11512. }
  11513. function putBinaryImageData(ctx, imgData) {
  11514. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  11515. ctx.putImageData(imgData, 0, 0);
  11516. return;
  11517. }
  11518. var height = imgData.height,
  11519. width = imgData.width;
  11520. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  11521. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  11522. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  11523. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  11524. var srcPos = 0,
  11525. destPos;
  11526. var src = imgData.data;
  11527. var dest = chunkImgData.data;
  11528. var i, j, thisChunkHeight, elemsInThisChunk;
  11529. if (imgData.kind === _util.ImageKind.GRAYSCALE_1BPP) {
  11530. var srcLength = src.byteLength;
  11531. var dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
  11532. var dest32DataLength = dest32.length;
  11533. var fullSrcDiff = width + 7 >> 3;
  11534. var white = 0xFFFFFFFF;
  11535. var black = IsLittleEndianCached.value ? 0xFF000000 : 0x000000FF;
  11536. for (i = 0; i < totalChunks; i++) {
  11537. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  11538. destPos = 0;
  11539. for (j = 0; j < thisChunkHeight; j++) {
  11540. var srcDiff = srcLength - srcPos;
  11541. var k = 0;
  11542. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  11543. var kEndUnrolled = kEnd & ~7;
  11544. var mask = 0;
  11545. var srcByte = 0;
  11546. for (; k < kEndUnrolled; k += 8) {
  11547. srcByte = src[srcPos++];
  11548. dest32[destPos++] = srcByte & 128 ? white : black;
  11549. dest32[destPos++] = srcByte & 64 ? white : black;
  11550. dest32[destPos++] = srcByte & 32 ? white : black;
  11551. dest32[destPos++] = srcByte & 16 ? white : black;
  11552. dest32[destPos++] = srcByte & 8 ? white : black;
  11553. dest32[destPos++] = srcByte & 4 ? white : black;
  11554. dest32[destPos++] = srcByte & 2 ? white : black;
  11555. dest32[destPos++] = srcByte & 1 ? white : black;
  11556. }
  11557. for (; k < kEnd; k++) {
  11558. if (mask === 0) {
  11559. srcByte = src[srcPos++];
  11560. mask = 128;
  11561. }
  11562. dest32[destPos++] = srcByte & mask ? white : black;
  11563. mask >>= 1;
  11564. }
  11565. }
  11566. while (destPos < dest32DataLength) {
  11567. dest32[destPos++] = 0;
  11568. }
  11569. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  11570. }
  11571. } else if (imgData.kind === _util.ImageKind.RGBA_32BPP) {
  11572. j = 0;
  11573. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  11574. for (i = 0; i < fullChunks; i++) {
  11575. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  11576. srcPos += elemsInThisChunk;
  11577. ctx.putImageData(chunkImgData, 0, j);
  11578. j += FULL_CHUNK_HEIGHT;
  11579. }
  11580. if (i < totalChunks) {
  11581. elemsInThisChunk = width * partialChunkHeight * 4;
  11582. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  11583. ctx.putImageData(chunkImgData, 0, j);
  11584. }
  11585. } else if (imgData.kind === _util.ImageKind.RGB_24BPP) {
  11586. thisChunkHeight = FULL_CHUNK_HEIGHT;
  11587. elemsInThisChunk = width * thisChunkHeight;
  11588. for (i = 0; i < totalChunks; i++) {
  11589. if (i >= fullChunks) {
  11590. thisChunkHeight = partialChunkHeight;
  11591. elemsInThisChunk = width * thisChunkHeight;
  11592. }
  11593. destPos = 0;
  11594. for (j = elemsInThisChunk; j--;) {
  11595. dest[destPos++] = src[srcPos++];
  11596. dest[destPos++] = src[srcPos++];
  11597. dest[destPos++] = src[srcPos++];
  11598. dest[destPos++] = 255;
  11599. }
  11600. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  11601. }
  11602. } else {
  11603. throw new Error("bad image kind: ".concat(imgData.kind));
  11604. }
  11605. }
  11606. function putBinaryImageMask(ctx, imgData) {
  11607. var height = imgData.height,
  11608. width = imgData.width;
  11609. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  11610. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  11611. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  11612. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  11613. var srcPos = 0;
  11614. var src = imgData.data;
  11615. var dest = chunkImgData.data;
  11616. for (var i = 0; i < totalChunks; i++) {
  11617. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  11618. var destPos = 3;
  11619. for (var j = 0; j < thisChunkHeight; j++) {
  11620. var mask = 0;
  11621. for (var k = 0; k < width; k++) {
  11622. if (!mask) {
  11623. var elem = src[srcPos++];
  11624. mask = 128;
  11625. }
  11626. dest[destPos] = elem & mask ? 0 : 255;
  11627. destPos += 4;
  11628. mask >>= 1;
  11629. }
  11630. }
  11631. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  11632. }
  11633. }
  11634. function copyCtxState(sourceCtx, destCtx) {
  11635. var properties = ['strokeStyle', 'fillStyle', 'fillRule', 'globalAlpha', 'lineWidth', 'lineCap', 'lineJoin', 'miterLimit', 'globalCompositeOperation', 'font'];
  11636. for (var i = 0, ii = properties.length; i < ii; i++) {
  11637. var property = properties[i];
  11638. if (sourceCtx[property] !== undefined) {
  11639. destCtx[property] = sourceCtx[property];
  11640. }
  11641. }
  11642. if (sourceCtx.setLineDash !== undefined) {
  11643. destCtx.setLineDash(sourceCtx.getLineDash());
  11644. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  11645. }
  11646. }
  11647. function resetCtxToDefault(ctx) {
  11648. ctx.strokeStyle = '#000000';
  11649. ctx.fillStyle = '#000000';
  11650. ctx.fillRule = 'nonzero';
  11651. ctx.globalAlpha = 1;
  11652. ctx.lineWidth = 1;
  11653. ctx.lineCap = 'butt';
  11654. ctx.lineJoin = 'miter';
  11655. ctx.miterLimit = 10;
  11656. ctx.globalCompositeOperation = 'source-over';
  11657. ctx.font = '10px sans-serif';
  11658. if (ctx.setLineDash !== undefined) {
  11659. ctx.setLineDash([]);
  11660. ctx.lineDashOffset = 0;
  11661. }
  11662. }
  11663. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  11664. var length = bytes.length;
  11665. for (var i = 3; i < length; i += 4) {
  11666. var alpha = bytes[i];
  11667. if (alpha === 0) {
  11668. bytes[i - 3] = r0;
  11669. bytes[i - 2] = g0;
  11670. bytes[i - 1] = b0;
  11671. } else if (alpha < 255) {
  11672. var alpha_ = 255 - alpha;
  11673. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  11674. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  11675. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  11676. }
  11677. }
  11678. }
  11679. function composeSMaskAlpha(maskData, layerData, transferMap) {
  11680. var length = maskData.length;
  11681. var scale = 1 / 255;
  11682. for (var i = 3; i < length; i += 4) {
  11683. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  11684. layerData[i] = layerData[i] * alpha * scale | 0;
  11685. }
  11686. }
  11687. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  11688. var length = maskData.length;
  11689. for (var i = 3; i < length; i += 4) {
  11690. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  11691. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  11692. }
  11693. }
  11694. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  11695. var hasBackdrop = !!backdrop;
  11696. var r0 = hasBackdrop ? backdrop[0] : 0;
  11697. var g0 = hasBackdrop ? backdrop[1] : 0;
  11698. var b0 = hasBackdrop ? backdrop[2] : 0;
  11699. var composeFn;
  11700. if (subtype === 'Luminosity') {
  11701. composeFn = composeSMaskLuminosity;
  11702. } else {
  11703. composeFn = composeSMaskAlpha;
  11704. }
  11705. var PIXELS_TO_PROCESS = 1048576;
  11706. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  11707. for (var row = 0; row < height; row += chunkSize) {
  11708. var chunkHeight = Math.min(chunkSize, height - row);
  11709. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  11710. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  11711. if (hasBackdrop) {
  11712. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  11713. }
  11714. composeFn(maskData.data, layerData.data, transferMap);
  11715. maskCtx.putImageData(layerData, 0, row);
  11716. }
  11717. }
  11718. function composeSMask(ctx, smask, layerCtx, webGLContext) {
  11719. var mask = smask.canvas;
  11720. var maskCtx = smask.context;
  11721. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  11722. var backdrop = smask.backdrop || null;
  11723. if (!smask.transferMap && webGLContext.isEnabled) {
  11724. var composed = webGLContext.composeSMask({
  11725. layer: layerCtx.canvas,
  11726. mask: mask,
  11727. properties: {
  11728. subtype: smask.subtype,
  11729. backdrop: backdrop
  11730. }
  11731. });
  11732. ctx.setTransform(1, 0, 0, 1, 0, 0);
  11733. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  11734. return;
  11735. }
  11736. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  11737. ctx.drawImage(mask, 0, 0);
  11738. }
  11739. var LINE_CAP_STYLES = ['butt', 'round', 'square'];
  11740. var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
  11741. var NORMAL_CLIP = {};
  11742. var EO_CLIP = {};
  11743. CanvasGraphics.prototype = {
  11744. beginDrawing: function beginDrawing(_ref) {
  11745. var transform = _ref.transform,
  11746. viewport = _ref.viewport,
  11747. _ref$transparency = _ref.transparency,
  11748. transparency = _ref$transparency === void 0 ? false : _ref$transparency,
  11749. _ref$background = _ref.background,
  11750. background = _ref$background === void 0 ? null : _ref$background;
  11751. var width = this.ctx.canvas.width;
  11752. var height = this.ctx.canvas.height;
  11753. this.ctx.save();
  11754. this.ctx.fillStyle = background || 'rgb(255, 255, 255)';
  11755. this.ctx.fillRect(0, 0, width, height);
  11756. this.ctx.restore();
  11757. if (transparency) {
  11758. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  11759. this.compositeCtx = this.ctx;
  11760. this.transparentCanvas = transparentCanvas.canvas;
  11761. this.ctx = transparentCanvas.context;
  11762. this.ctx.save();
  11763. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  11764. }
  11765. this.ctx.save();
  11766. resetCtxToDefault(this.ctx);
  11767. if (transform) {
  11768. this.ctx.transform.apply(this.ctx, transform);
  11769. }
  11770. this.ctx.transform.apply(this.ctx, viewport.transform);
  11771. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  11772. if (this.imageLayer) {
  11773. this.imageLayer.beginLayout();
  11774. }
  11775. },
  11776. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  11777. var argsArray = operatorList.argsArray;
  11778. var fnArray = operatorList.fnArray;
  11779. var i = executionStartIdx || 0;
  11780. var argsArrayLen = argsArray.length;
  11781. if (argsArrayLen === i) {
  11782. return i;
  11783. }
  11784. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  11785. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  11786. var steps = 0;
  11787. var commonObjs = this.commonObjs;
  11788. var objs = this.objs;
  11789. var fnId;
  11790. while (true) {
  11791. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  11792. stepper.breakIt(i, continueCallback);
  11793. return i;
  11794. }
  11795. fnId = fnArray[i];
  11796. if (fnId !== _util.OPS.dependency) {
  11797. this[fnId].apply(this, argsArray[i]);
  11798. } else {
  11799. var _iteratorNormalCompletion = true;
  11800. var _didIteratorError = false;
  11801. var _iteratorError = undefined;
  11802. try {
  11803. for (var _iterator = argsArray[i][Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  11804. var depObjId = _step.value;
  11805. var objsPool = depObjId.startsWith('g_') ? commonObjs : objs;
  11806. if (!objsPool.has(depObjId)) {
  11807. objsPool.get(depObjId, continueCallback);
  11808. return i;
  11809. }
  11810. }
  11811. } catch (err) {
  11812. _didIteratorError = true;
  11813. _iteratorError = err;
  11814. } finally {
  11815. try {
  11816. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  11817. _iterator["return"]();
  11818. }
  11819. } finally {
  11820. if (_didIteratorError) {
  11821. throw _iteratorError;
  11822. }
  11823. }
  11824. }
  11825. }
  11826. i++;
  11827. if (i === argsArrayLen) {
  11828. return i;
  11829. }
  11830. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  11831. if (Date.now() > endTime) {
  11832. continueCallback();
  11833. return i;
  11834. }
  11835. steps = 0;
  11836. }
  11837. }
  11838. },
  11839. endDrawing: function CanvasGraphics_endDrawing() {
  11840. if (this.current.activeSMask !== null) {
  11841. this.endSMaskGroup();
  11842. }
  11843. this.ctx.restore();
  11844. if (this.transparentCanvas) {
  11845. this.ctx = this.compositeCtx;
  11846. this.ctx.save();
  11847. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  11848. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  11849. this.ctx.restore();
  11850. this.transparentCanvas = null;
  11851. }
  11852. this.cachedCanvases.clear();
  11853. this.webGLContext.clear();
  11854. if (this.imageLayer) {
  11855. this.imageLayer.endLayout();
  11856. }
  11857. },
  11858. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  11859. this.current.lineWidth = width;
  11860. this.ctx.lineWidth = width;
  11861. },
  11862. setLineCap: function CanvasGraphics_setLineCap(style) {
  11863. this.ctx.lineCap = LINE_CAP_STYLES[style];
  11864. },
  11865. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  11866. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  11867. },
  11868. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  11869. this.ctx.miterLimit = limit;
  11870. },
  11871. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  11872. var ctx = this.ctx;
  11873. if (ctx.setLineDash !== undefined) {
  11874. ctx.setLineDash(dashArray);
  11875. ctx.lineDashOffset = dashPhase;
  11876. }
  11877. },
  11878. setRenderingIntent: function setRenderingIntent(intent) {},
  11879. setFlatness: function setFlatness(flatness) {},
  11880. setGState: function CanvasGraphics_setGState(states) {
  11881. for (var i = 0, ii = states.length; i < ii; i++) {
  11882. var state = states[i];
  11883. var key = state[0];
  11884. var value = state[1];
  11885. switch (key) {
  11886. case 'LW':
  11887. this.setLineWidth(value);
  11888. break;
  11889. case 'LC':
  11890. this.setLineCap(value);
  11891. break;
  11892. case 'LJ':
  11893. this.setLineJoin(value);
  11894. break;
  11895. case 'ML':
  11896. this.setMiterLimit(value);
  11897. break;
  11898. case 'D':
  11899. this.setDash(value[0], value[1]);
  11900. break;
  11901. case 'RI':
  11902. this.setRenderingIntent(value);
  11903. break;
  11904. case 'FL':
  11905. this.setFlatness(value);
  11906. break;
  11907. case 'Font':
  11908. this.setFont(value[0], value[1]);
  11909. break;
  11910. case 'CA':
  11911. this.current.strokeAlpha = state[1];
  11912. break;
  11913. case 'ca':
  11914. this.current.fillAlpha = state[1];
  11915. this.ctx.globalAlpha = state[1];
  11916. break;
  11917. case 'BM':
  11918. this.ctx.globalCompositeOperation = value;
  11919. break;
  11920. case 'SMask':
  11921. if (this.current.activeSMask) {
  11922. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  11923. this.suspendSMaskGroup();
  11924. } else {
  11925. this.endSMaskGroup();
  11926. }
  11927. }
  11928. this.current.activeSMask = value ? this.tempSMask : null;
  11929. if (this.current.activeSMask) {
  11930. this.beginSMaskGroup();
  11931. }
  11932. this.tempSMask = null;
  11933. break;
  11934. }
  11935. }
  11936. },
  11937. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  11938. var activeSMask = this.current.activeSMask;
  11939. var drawnWidth = activeSMask.canvas.width;
  11940. var drawnHeight = activeSMask.canvas.height;
  11941. var cacheId = 'smaskGroupAt' + this.groupLevel;
  11942. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  11943. var currentCtx = this.ctx;
  11944. var currentTransform = currentCtx.mozCurrentTransform;
  11945. this.ctx.save();
  11946. var groupCtx = scratchCanvas.context;
  11947. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  11948. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  11949. groupCtx.transform.apply(groupCtx, currentTransform);
  11950. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  11951. copyCtxState(currentCtx, groupCtx);
  11952. this.ctx = groupCtx;
  11953. this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]);
  11954. this.groupStack.push(currentCtx);
  11955. this.groupLevel++;
  11956. },
  11957. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  11958. var groupCtx = this.ctx;
  11959. this.groupLevel--;
  11960. this.ctx = this.groupStack.pop();
  11961. composeSMask(this.ctx, this.current.activeSMask, groupCtx, this.webGLContext);
  11962. this.ctx.restore();
  11963. this.ctx.save();
  11964. copyCtxState(groupCtx, this.ctx);
  11965. this.current.resumeSMaskCtx = groupCtx;
  11966. var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  11967. this.ctx.transform.apply(this.ctx, deltaTransform);
  11968. groupCtx.save();
  11969. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  11970. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  11971. groupCtx.restore();
  11972. },
  11973. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  11974. var groupCtx = this.current.resumeSMaskCtx;
  11975. var currentCtx = this.ctx;
  11976. this.ctx = groupCtx;
  11977. this.groupStack.push(currentCtx);
  11978. this.groupLevel++;
  11979. },
  11980. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  11981. var groupCtx = this.ctx;
  11982. this.groupLevel--;
  11983. this.ctx = this.groupStack.pop();
  11984. composeSMask(this.ctx, this.current.activeSMask, groupCtx, this.webGLContext);
  11985. this.ctx.restore();
  11986. copyCtxState(groupCtx, this.ctx);
  11987. var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  11988. this.ctx.transform.apply(this.ctx, deltaTransform);
  11989. },
  11990. save: function CanvasGraphics_save() {
  11991. this.ctx.save();
  11992. var old = this.current;
  11993. this.stateStack.push(old);
  11994. this.current = old.clone();
  11995. this.current.resumeSMaskCtx = null;
  11996. },
  11997. restore: function CanvasGraphics_restore() {
  11998. if (this.current.resumeSMaskCtx) {
  11999. this.resumeSMaskGroup();
  12000. }
  12001. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  12002. this.endSMaskGroup();
  12003. }
  12004. if (this.stateStack.length !== 0) {
  12005. this.current = this.stateStack.pop();
  12006. this.ctx.restore();
  12007. this.pendingClip = null;
  12008. this._cachedGetSinglePixelWidth = null;
  12009. }
  12010. },
  12011. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  12012. this.ctx.transform(a, b, c, d, e, f);
  12013. this._cachedGetSinglePixelWidth = null;
  12014. },
  12015. constructPath: function CanvasGraphics_constructPath(ops, args) {
  12016. var ctx = this.ctx;
  12017. var current = this.current;
  12018. var x = current.x,
  12019. y = current.y;
  12020. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  12021. switch (ops[i] | 0) {
  12022. case _util.OPS.rectangle:
  12023. x = args[j++];
  12024. y = args[j++];
  12025. var width = args[j++];
  12026. var height = args[j++];
  12027. if (width === 0) {
  12028. width = this.getSinglePixelWidth();
  12029. }
  12030. if (height === 0) {
  12031. height = this.getSinglePixelWidth();
  12032. }
  12033. var xw = x + width;
  12034. var yh = y + height;
  12035. this.ctx.moveTo(x, y);
  12036. this.ctx.lineTo(xw, y);
  12037. this.ctx.lineTo(xw, yh);
  12038. this.ctx.lineTo(x, yh);
  12039. this.ctx.lineTo(x, y);
  12040. this.ctx.closePath();
  12041. break;
  12042. case _util.OPS.moveTo:
  12043. x = args[j++];
  12044. y = args[j++];
  12045. ctx.moveTo(x, y);
  12046. break;
  12047. case _util.OPS.lineTo:
  12048. x = args[j++];
  12049. y = args[j++];
  12050. ctx.lineTo(x, y);
  12051. break;
  12052. case _util.OPS.curveTo:
  12053. x = args[j + 4];
  12054. y = args[j + 5];
  12055. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  12056. j += 6;
  12057. break;
  12058. case _util.OPS.curveTo2:
  12059. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  12060. x = args[j + 2];
  12061. y = args[j + 3];
  12062. j += 4;
  12063. break;
  12064. case _util.OPS.curveTo3:
  12065. x = args[j + 2];
  12066. y = args[j + 3];
  12067. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  12068. j += 4;
  12069. break;
  12070. case _util.OPS.closePath:
  12071. ctx.closePath();
  12072. break;
  12073. }
  12074. }
  12075. current.setCurrentPoint(x, y);
  12076. },
  12077. closePath: function CanvasGraphics_closePath() {
  12078. this.ctx.closePath();
  12079. },
  12080. stroke: function CanvasGraphics_stroke(consumePath) {
  12081. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  12082. var ctx = this.ctx;
  12083. var strokeColor = this.current.strokeColor;
  12084. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  12085. ctx.globalAlpha = this.current.strokeAlpha;
  12086. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  12087. ctx.save();
  12088. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  12089. ctx.stroke();
  12090. ctx.restore();
  12091. } else {
  12092. ctx.stroke();
  12093. }
  12094. if (consumePath) {
  12095. this.consumePath();
  12096. }
  12097. ctx.globalAlpha = this.current.fillAlpha;
  12098. },
  12099. closeStroke: function CanvasGraphics_closeStroke() {
  12100. this.closePath();
  12101. this.stroke();
  12102. },
  12103. fill: function CanvasGraphics_fill(consumePath) {
  12104. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  12105. var ctx = this.ctx;
  12106. var fillColor = this.current.fillColor;
  12107. var isPatternFill = this.current.patternFill;
  12108. var needRestore = false;
  12109. if (isPatternFill) {
  12110. ctx.save();
  12111. if (this.baseTransform) {
  12112. ctx.setTransform.apply(ctx, this.baseTransform);
  12113. }
  12114. ctx.fillStyle = fillColor.getPattern(ctx, this);
  12115. needRestore = true;
  12116. }
  12117. if (this.pendingEOFill) {
  12118. ctx.fill('evenodd');
  12119. this.pendingEOFill = false;
  12120. } else {
  12121. ctx.fill();
  12122. }
  12123. if (needRestore) {
  12124. ctx.restore();
  12125. }
  12126. if (consumePath) {
  12127. this.consumePath();
  12128. }
  12129. },
  12130. eoFill: function CanvasGraphics_eoFill() {
  12131. this.pendingEOFill = true;
  12132. this.fill();
  12133. },
  12134. fillStroke: function CanvasGraphics_fillStroke() {
  12135. this.fill(false);
  12136. this.stroke(false);
  12137. this.consumePath();
  12138. },
  12139. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  12140. this.pendingEOFill = true;
  12141. this.fillStroke();
  12142. },
  12143. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  12144. this.closePath();
  12145. this.fillStroke();
  12146. },
  12147. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  12148. this.pendingEOFill = true;
  12149. this.closePath();
  12150. this.fillStroke();
  12151. },
  12152. endPath: function CanvasGraphics_endPath() {
  12153. this.consumePath();
  12154. },
  12155. clip: function CanvasGraphics_clip() {
  12156. this.pendingClip = NORMAL_CLIP;
  12157. },
  12158. eoClip: function CanvasGraphics_eoClip() {
  12159. this.pendingClip = EO_CLIP;
  12160. },
  12161. beginText: function CanvasGraphics_beginText() {
  12162. this.current.textMatrix = _util.IDENTITY_MATRIX;
  12163. this.current.textMatrixScale = 1;
  12164. this.current.x = this.current.lineX = 0;
  12165. this.current.y = this.current.lineY = 0;
  12166. },
  12167. endText: function CanvasGraphics_endText() {
  12168. var paths = this.pendingTextPaths;
  12169. var ctx = this.ctx;
  12170. if (paths === undefined) {
  12171. ctx.beginPath();
  12172. return;
  12173. }
  12174. ctx.save();
  12175. ctx.beginPath();
  12176. for (var i = 0; i < paths.length; i++) {
  12177. var path = paths[i];
  12178. ctx.setTransform.apply(ctx, path.transform);
  12179. ctx.translate(path.x, path.y);
  12180. path.addToPath(ctx, path.fontSize);
  12181. }
  12182. ctx.restore();
  12183. ctx.clip();
  12184. ctx.beginPath();
  12185. delete this.pendingTextPaths;
  12186. },
  12187. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  12188. this.current.charSpacing = spacing;
  12189. },
  12190. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  12191. this.current.wordSpacing = spacing;
  12192. },
  12193. setHScale: function CanvasGraphics_setHScale(scale) {
  12194. this.current.textHScale = scale / 100;
  12195. },
  12196. setLeading: function CanvasGraphics_setLeading(leading) {
  12197. this.current.leading = -leading;
  12198. },
  12199. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  12200. var fontObj = this.commonObjs.get(fontRefName);
  12201. var current = this.current;
  12202. if (!fontObj) {
  12203. throw new Error("Can't find font for ".concat(fontRefName));
  12204. }
  12205. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
  12206. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  12207. (0, _util.warn)('Invalid font matrix for font ' + fontRefName);
  12208. }
  12209. if (size < 0) {
  12210. size = -size;
  12211. current.fontDirection = -1;
  12212. } else {
  12213. current.fontDirection = 1;
  12214. }
  12215. this.current.font = fontObj;
  12216. this.current.fontSize = size;
  12217. if (fontObj.isType3Font) {
  12218. return;
  12219. }
  12220. var name = fontObj.loadedName || 'sans-serif';
  12221. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  12222. var italic = fontObj.italic ? 'italic' : 'normal';
  12223. var typeface = "\"".concat(name, "\", ").concat(fontObj.fallbackName);
  12224. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  12225. this.current.fontSizeScale = size / browserFontSize;
  12226. this.ctx.font = "".concat(italic, " ").concat(bold, " ").concat(browserFontSize, "px ").concat(typeface);
  12227. },
  12228. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  12229. this.current.textRenderingMode = mode;
  12230. },
  12231. setTextRise: function CanvasGraphics_setTextRise(rise) {
  12232. this.current.textRise = rise;
  12233. },
  12234. moveText: function CanvasGraphics_moveText(x, y) {
  12235. this.current.x = this.current.lineX += x;
  12236. this.current.y = this.current.lineY += y;
  12237. },
  12238. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  12239. this.setLeading(-y);
  12240. this.moveText(x, y);
  12241. },
  12242. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  12243. this.current.textMatrix = [a, b, c, d, e, f];
  12244. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  12245. this.current.x = this.current.lineX = 0;
  12246. this.current.y = this.current.lineY = 0;
  12247. },
  12248. nextLine: function CanvasGraphics_nextLine() {
  12249. this.moveText(0, this.current.leading);
  12250. },
  12251. paintChar: function paintChar(character, x, y, patternTransform) {
  12252. var ctx = this.ctx;
  12253. var current = this.current;
  12254. var font = current.font;
  12255. var textRenderingMode = current.textRenderingMode;
  12256. var fontSize = current.fontSize / current.fontSizeScale;
  12257. var fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  12258. var isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
  12259. var patternFill = current.patternFill && font.data;
  12260. var addToPath;
  12261. if (font.disableFontFace || isAddToPathSet || patternFill) {
  12262. addToPath = font.getPathGenerator(this.commonObjs, character);
  12263. }
  12264. if (font.disableFontFace || patternFill) {
  12265. ctx.save();
  12266. ctx.translate(x, y);
  12267. ctx.beginPath();
  12268. addToPath(ctx, fontSize);
  12269. if (patternTransform) {
  12270. ctx.setTransform.apply(ctx, patternTransform);
  12271. }
  12272. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  12273. ctx.fill();
  12274. }
  12275. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  12276. ctx.stroke();
  12277. }
  12278. ctx.restore();
  12279. } else {
  12280. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  12281. ctx.fillText(character, x, y);
  12282. }
  12283. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  12284. ctx.strokeText(character, x, y);
  12285. }
  12286. }
  12287. if (isAddToPathSet) {
  12288. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  12289. paths.push({
  12290. transform: ctx.mozCurrentTransform,
  12291. x: x,
  12292. y: y,
  12293. fontSize: fontSize,
  12294. addToPath: addToPath
  12295. });
  12296. }
  12297. },
  12298. get isFontSubpixelAAEnabled() {
  12299. var _this$cachedCanvases$ = this.cachedCanvases.getCanvas('isFontSubpixelAAEnabled', 10, 10),
  12300. ctx = _this$cachedCanvases$.context;
  12301. ctx.scale(1.5, 1);
  12302. ctx.fillText('I', 0, 10);
  12303. var data = ctx.getImageData(0, 0, 10, 10).data;
  12304. var enabled = false;
  12305. for (var i = 3; i < data.length; i += 4) {
  12306. if (data[i] > 0 && data[i] < 255) {
  12307. enabled = true;
  12308. break;
  12309. }
  12310. }
  12311. return (0, _util.shadow)(this, 'isFontSubpixelAAEnabled', enabled);
  12312. },
  12313. showText: function CanvasGraphics_showText(glyphs) {
  12314. var current = this.current;
  12315. var font = current.font;
  12316. if (font.isType3Font) {
  12317. return this.showType3Text(glyphs);
  12318. }
  12319. var fontSize = current.fontSize;
  12320. if (fontSize === 0) {
  12321. return undefined;
  12322. }
  12323. var ctx = this.ctx;
  12324. var fontSizeScale = current.fontSizeScale;
  12325. var charSpacing = current.charSpacing;
  12326. var wordSpacing = current.wordSpacing;
  12327. var fontDirection = current.fontDirection;
  12328. var textHScale = current.textHScale * fontDirection;
  12329. var glyphsLength = glyphs.length;
  12330. var vertical = font.vertical;
  12331. var spacingDir = vertical ? 1 : -1;
  12332. var defaultVMetrics = font.defaultVMetrics;
  12333. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  12334. var simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
  12335. ctx.save();
  12336. var patternTransform;
  12337. if (current.patternFill) {
  12338. ctx.save();
  12339. var pattern = current.fillColor.getPattern(ctx, this);
  12340. patternTransform = ctx.mozCurrentTransform;
  12341. ctx.restore();
  12342. ctx.fillStyle = pattern;
  12343. }
  12344. ctx.transform.apply(ctx, current.textMatrix);
  12345. ctx.translate(current.x, current.y + current.textRise);
  12346. if (fontDirection > 0) {
  12347. ctx.scale(textHScale, -1);
  12348. } else {
  12349. ctx.scale(textHScale, 1);
  12350. }
  12351. var lineWidth = current.lineWidth;
  12352. var scale = current.textMatrixScale;
  12353. if (scale === 0 || lineWidth === 0) {
  12354. var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  12355. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  12356. this._cachedGetSinglePixelWidth = null;
  12357. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  12358. }
  12359. } else {
  12360. lineWidth /= scale;
  12361. }
  12362. if (fontSizeScale !== 1.0) {
  12363. ctx.scale(fontSizeScale, fontSizeScale);
  12364. lineWidth /= fontSizeScale;
  12365. }
  12366. ctx.lineWidth = lineWidth;
  12367. var x = 0,
  12368. i;
  12369. for (i = 0; i < glyphsLength; ++i) {
  12370. var glyph = glyphs[i];
  12371. if ((0, _util.isNum)(glyph)) {
  12372. x += spacingDir * glyph * fontSize / 1000;
  12373. continue;
  12374. }
  12375. var restoreNeeded = false;
  12376. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  12377. var character = glyph.fontChar;
  12378. var accent = glyph.accent;
  12379. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  12380. var width = glyph.width;
  12381. if (vertical) {
  12382. var vmetric, vx, vy;
  12383. vmetric = glyph.vmetric || defaultVMetrics;
  12384. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  12385. vx = -vx * widthAdvanceScale;
  12386. vy = vmetric[2] * widthAdvanceScale;
  12387. width = vmetric ? -vmetric[0] : width;
  12388. scaledX = vx / fontSizeScale;
  12389. scaledY = (x + vy) / fontSizeScale;
  12390. } else {
  12391. scaledX = x / fontSizeScale;
  12392. scaledY = 0;
  12393. }
  12394. if (font.remeasure && width > 0) {
  12395. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  12396. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  12397. var characterScaleX = width / measuredWidth;
  12398. restoreNeeded = true;
  12399. ctx.save();
  12400. ctx.scale(characterScaleX, 1);
  12401. scaledX /= characterScaleX;
  12402. } else if (width !== measuredWidth) {
  12403. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  12404. }
  12405. }
  12406. if (glyph.isInFont || font.missingFile) {
  12407. if (simpleFillText && !accent) {
  12408. ctx.fillText(character, scaledX, scaledY);
  12409. } else {
  12410. this.paintChar(character, scaledX, scaledY, patternTransform);
  12411. if (accent) {
  12412. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  12413. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  12414. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY, patternTransform);
  12415. }
  12416. }
  12417. }
  12418. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  12419. x += charWidth;
  12420. if (restoreNeeded) {
  12421. ctx.restore();
  12422. }
  12423. }
  12424. if (vertical) {
  12425. current.y -= x * textHScale;
  12426. } else {
  12427. current.x += x * textHScale;
  12428. }
  12429. ctx.restore();
  12430. },
  12431. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  12432. var ctx = this.ctx;
  12433. var current = this.current;
  12434. var font = current.font;
  12435. var fontSize = current.fontSize;
  12436. var fontDirection = current.fontDirection;
  12437. var spacingDir = font.vertical ? 1 : -1;
  12438. var charSpacing = current.charSpacing;
  12439. var wordSpacing = current.wordSpacing;
  12440. var textHScale = current.textHScale * fontDirection;
  12441. var fontMatrix = current.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  12442. var glyphsLength = glyphs.length;
  12443. var isTextInvisible = current.textRenderingMode === _util.TextRenderingMode.INVISIBLE;
  12444. var i, glyph, width, spacingLength;
  12445. if (isTextInvisible || fontSize === 0) {
  12446. return;
  12447. }
  12448. this._cachedGetSinglePixelWidth = null;
  12449. ctx.save();
  12450. ctx.transform.apply(ctx, current.textMatrix);
  12451. ctx.translate(current.x, current.y);
  12452. ctx.scale(textHScale, fontDirection);
  12453. for (i = 0; i < glyphsLength; ++i) {
  12454. glyph = glyphs[i];
  12455. if ((0, _util.isNum)(glyph)) {
  12456. spacingLength = spacingDir * glyph * fontSize / 1000;
  12457. this.ctx.translate(spacingLength, 0);
  12458. current.x += spacingLength * textHScale;
  12459. continue;
  12460. }
  12461. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  12462. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  12463. if (!operatorList) {
  12464. (0, _util.warn)("Type3 character \"".concat(glyph.operatorListId, "\" is not available."));
  12465. continue;
  12466. }
  12467. this.processingType3 = glyph;
  12468. this.save();
  12469. ctx.scale(fontSize, fontSize);
  12470. ctx.transform.apply(ctx, fontMatrix);
  12471. this.executeOperatorList(operatorList);
  12472. this.restore();
  12473. var transformed = _util.Util.applyTransform([glyph.width, 0], fontMatrix);
  12474. width = transformed[0] * fontSize + spacing;
  12475. ctx.translate(width, 0);
  12476. current.x += width * textHScale;
  12477. }
  12478. ctx.restore();
  12479. this.processingType3 = null;
  12480. },
  12481. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {},
  12482. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  12483. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  12484. this.clip();
  12485. this.endPath();
  12486. },
  12487. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  12488. var _this = this;
  12489. var pattern;
  12490. if (IR[0] === 'TilingPattern') {
  12491. var color = IR[1];
  12492. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  12493. var canvasGraphicsFactory = {
  12494. createCanvasGraphics: function createCanvasGraphics(ctx) {
  12495. return new CanvasGraphics(ctx, _this.commonObjs, _this.objs, _this.canvasFactory, _this.webGLContext);
  12496. }
  12497. };
  12498. pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  12499. } else {
  12500. pattern = (0, _pattern_helper.getShadingPatternFromIR)(IR);
  12501. }
  12502. return pattern;
  12503. },
  12504. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  12505. this.current.strokeColor = this.getColorN_Pattern(arguments);
  12506. },
  12507. setFillColorN: function CanvasGraphics_setFillColorN() {
  12508. this.current.fillColor = this.getColorN_Pattern(arguments);
  12509. this.current.patternFill = true;
  12510. },
  12511. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  12512. var color = _util.Util.makeCssRgb(r, g, b);
  12513. this.ctx.strokeStyle = color;
  12514. this.current.strokeColor = color;
  12515. },
  12516. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  12517. var color = _util.Util.makeCssRgb(r, g, b);
  12518. this.ctx.fillStyle = color;
  12519. this.current.fillColor = color;
  12520. this.current.patternFill = false;
  12521. },
  12522. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  12523. var ctx = this.ctx;
  12524. this.save();
  12525. var pattern = (0, _pattern_helper.getShadingPatternFromIR)(patternIR);
  12526. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  12527. var inv = ctx.mozCurrentTransformInverse;
  12528. if (inv) {
  12529. var canvas = ctx.canvas;
  12530. var width = canvas.width;
  12531. var height = canvas.height;
  12532. var bl = _util.Util.applyTransform([0, 0], inv);
  12533. var br = _util.Util.applyTransform([0, height], inv);
  12534. var ul = _util.Util.applyTransform([width, 0], inv);
  12535. var ur = _util.Util.applyTransform([width, height], inv);
  12536. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  12537. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  12538. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  12539. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  12540. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  12541. } else {
  12542. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  12543. }
  12544. this.restore();
  12545. },
  12546. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  12547. (0, _util.unreachable)('Should not call beginInlineImage');
  12548. },
  12549. beginImageData: function CanvasGraphics_beginImageData() {
  12550. (0, _util.unreachable)('Should not call beginImageData');
  12551. },
  12552. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  12553. this.save();
  12554. this.baseTransformStack.push(this.baseTransform);
  12555. if (Array.isArray(matrix) && matrix.length === 6) {
  12556. this.transform.apply(this, matrix);
  12557. }
  12558. this.baseTransform = this.ctx.mozCurrentTransform;
  12559. if (bbox) {
  12560. var width = bbox[2] - bbox[0];
  12561. var height = bbox[3] - bbox[1];
  12562. this.ctx.rect(bbox[0], bbox[1], width, height);
  12563. this.clip();
  12564. this.endPath();
  12565. }
  12566. },
  12567. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  12568. this.restore();
  12569. this.baseTransform = this.baseTransformStack.pop();
  12570. },
  12571. beginGroup: function CanvasGraphics_beginGroup(group) {
  12572. this.save();
  12573. var currentCtx = this.ctx;
  12574. if (!group.isolated) {
  12575. (0, _util.info)('TODO: Support non-isolated groups.');
  12576. }
  12577. if (group.knockout) {
  12578. (0, _util.warn)('Knockout groups not supported.');
  12579. }
  12580. var currentTransform = currentCtx.mozCurrentTransform;
  12581. if (group.matrix) {
  12582. currentCtx.transform.apply(currentCtx, group.matrix);
  12583. }
  12584. if (!group.bbox) {
  12585. throw new Error('Bounding box is required.');
  12586. }
  12587. var bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  12588. var canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height];
  12589. bounds = _util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
  12590. var offsetX = Math.floor(bounds[0]);
  12591. var offsetY = Math.floor(bounds[1]);
  12592. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  12593. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  12594. var scaleX = 1,
  12595. scaleY = 1;
  12596. if (drawnWidth > MAX_GROUP_SIZE) {
  12597. scaleX = drawnWidth / MAX_GROUP_SIZE;
  12598. drawnWidth = MAX_GROUP_SIZE;
  12599. }
  12600. if (drawnHeight > MAX_GROUP_SIZE) {
  12601. scaleY = drawnHeight / MAX_GROUP_SIZE;
  12602. drawnHeight = MAX_GROUP_SIZE;
  12603. }
  12604. var cacheId = 'groupAt' + this.groupLevel;
  12605. if (group.smask) {
  12606. cacheId += '_smask_' + this.smaskCounter++ % 2;
  12607. }
  12608. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  12609. var groupCtx = scratchCanvas.context;
  12610. groupCtx.scale(1 / scaleX, 1 / scaleY);
  12611. groupCtx.translate(-offsetX, -offsetY);
  12612. groupCtx.transform.apply(groupCtx, currentTransform);
  12613. if (group.smask) {
  12614. this.smaskStack.push({
  12615. canvas: scratchCanvas.canvas,
  12616. context: groupCtx,
  12617. offsetX: offsetX,
  12618. offsetY: offsetY,
  12619. scaleX: scaleX,
  12620. scaleY: scaleY,
  12621. subtype: group.smask.subtype,
  12622. backdrop: group.smask.backdrop,
  12623. transferMap: group.smask.transferMap || null,
  12624. startTransformInverse: null
  12625. });
  12626. } else {
  12627. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  12628. currentCtx.translate(offsetX, offsetY);
  12629. currentCtx.scale(scaleX, scaleY);
  12630. }
  12631. copyCtxState(currentCtx, groupCtx);
  12632. this.ctx = groupCtx;
  12633. this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]);
  12634. this.groupStack.push(currentCtx);
  12635. this.groupLevel++;
  12636. this.current.activeSMask = null;
  12637. },
  12638. endGroup: function CanvasGraphics_endGroup(group) {
  12639. this.groupLevel--;
  12640. var groupCtx = this.ctx;
  12641. this.ctx = this.groupStack.pop();
  12642. if (this.ctx.imageSmoothingEnabled !== undefined) {
  12643. this.ctx.imageSmoothingEnabled = false;
  12644. } else {
  12645. this.ctx.mozImageSmoothingEnabled = false;
  12646. }
  12647. if (group.smask) {
  12648. this.tempSMask = this.smaskStack.pop();
  12649. } else {
  12650. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  12651. }
  12652. this.restore();
  12653. },
  12654. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  12655. this.save();
  12656. if (this.baseTransform) {
  12657. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  12658. }
  12659. },
  12660. endAnnotations: function CanvasGraphics_endAnnotations() {
  12661. this.restore();
  12662. },
  12663. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  12664. this.save();
  12665. resetCtxToDefault(this.ctx);
  12666. this.current = new CanvasExtraState();
  12667. if (Array.isArray(rect) && rect.length === 4) {
  12668. var width = rect[2] - rect[0];
  12669. var height = rect[3] - rect[1];
  12670. this.ctx.rect(rect[0], rect[1], width, height);
  12671. this.clip();
  12672. this.endPath();
  12673. }
  12674. this.transform.apply(this, transform);
  12675. this.transform.apply(this, matrix);
  12676. },
  12677. endAnnotation: function CanvasGraphics_endAnnotation() {
  12678. this.restore();
  12679. },
  12680. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  12681. var domImage = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
  12682. if (!domImage) {
  12683. (0, _util.warn)('Dependent image isn\'t ready yet');
  12684. return;
  12685. }
  12686. this.save();
  12687. var ctx = this.ctx;
  12688. ctx.scale(1 / w, -1 / h);
  12689. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  12690. if (this.imageLayer) {
  12691. var currentTransform = ctx.mozCurrentTransformInverse;
  12692. var position = this.getCanvasPosition(0, 0);
  12693. this.imageLayer.appendImage({
  12694. objId: objId,
  12695. left: position[0],
  12696. top: position[1],
  12697. width: w / currentTransform[0],
  12698. height: h / currentTransform[3]
  12699. });
  12700. }
  12701. this.restore();
  12702. },
  12703. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  12704. var ctx = this.ctx;
  12705. var width = img.width,
  12706. height = img.height;
  12707. var fillColor = this.current.fillColor;
  12708. var isPatternFill = this.current.patternFill;
  12709. var glyph = this.processingType3;
  12710. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  12711. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  12712. glyph.compiled = compileType3Glyph({
  12713. data: img.data,
  12714. width: width,
  12715. height: height
  12716. });
  12717. } else {
  12718. glyph.compiled = null;
  12719. }
  12720. }
  12721. if (glyph && glyph.compiled) {
  12722. glyph.compiled(ctx);
  12723. return;
  12724. }
  12725. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  12726. var maskCtx = maskCanvas.context;
  12727. maskCtx.save();
  12728. putBinaryImageMask(maskCtx, img);
  12729. maskCtx.globalCompositeOperation = 'source-in';
  12730. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  12731. maskCtx.fillRect(0, 0, width, height);
  12732. maskCtx.restore();
  12733. this.paintInlineImageXObject(maskCanvas.canvas);
  12734. },
  12735. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  12736. var width = imgData.width;
  12737. var height = imgData.height;
  12738. var fillColor = this.current.fillColor;
  12739. var isPatternFill = this.current.patternFill;
  12740. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  12741. var maskCtx = maskCanvas.context;
  12742. maskCtx.save();
  12743. putBinaryImageMask(maskCtx, imgData);
  12744. maskCtx.globalCompositeOperation = 'source-in';
  12745. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  12746. maskCtx.fillRect(0, 0, width, height);
  12747. maskCtx.restore();
  12748. var ctx = this.ctx;
  12749. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  12750. ctx.save();
  12751. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  12752. ctx.scale(1, -1);
  12753. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  12754. ctx.restore();
  12755. }
  12756. },
  12757. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  12758. var ctx = this.ctx;
  12759. var fillColor = this.current.fillColor;
  12760. var isPatternFill = this.current.patternFill;
  12761. for (var i = 0, ii = images.length; i < ii; i++) {
  12762. var image = images[i];
  12763. var width = image.width,
  12764. height = image.height;
  12765. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  12766. var maskCtx = maskCanvas.context;
  12767. maskCtx.save();
  12768. putBinaryImageMask(maskCtx, image);
  12769. maskCtx.globalCompositeOperation = 'source-in';
  12770. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  12771. maskCtx.fillRect(0, 0, width, height);
  12772. maskCtx.restore();
  12773. ctx.save();
  12774. ctx.transform.apply(ctx, image.transform);
  12775. ctx.scale(1, -1);
  12776. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  12777. ctx.restore();
  12778. }
  12779. },
  12780. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  12781. var imgData = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
  12782. if (!imgData) {
  12783. (0, _util.warn)('Dependent image isn\'t ready yet');
  12784. return;
  12785. }
  12786. this.paintInlineImageXObject(imgData);
  12787. },
  12788. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  12789. var imgData = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
  12790. if (!imgData) {
  12791. (0, _util.warn)('Dependent image isn\'t ready yet');
  12792. return;
  12793. }
  12794. var width = imgData.width;
  12795. var height = imgData.height;
  12796. var map = [];
  12797. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  12798. map.push({
  12799. transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]],
  12800. x: 0,
  12801. y: 0,
  12802. w: width,
  12803. h: height
  12804. });
  12805. }
  12806. this.paintInlineImageXObjectGroup(imgData, map);
  12807. },
  12808. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  12809. var width = imgData.width;
  12810. var height = imgData.height;
  12811. var ctx = this.ctx;
  12812. this.save();
  12813. ctx.scale(1 / width, -1 / height);
  12814. var currentTransform = ctx.mozCurrentTransformInverse;
  12815. var a = currentTransform[0],
  12816. b = currentTransform[1];
  12817. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  12818. var c = currentTransform[2],
  12819. d = currentTransform[3];
  12820. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  12821. var imgToPaint, tmpCanvas;
  12822. if (typeof HTMLElement === 'function' && imgData instanceof HTMLElement || !imgData.data) {
  12823. imgToPaint = imgData;
  12824. } else {
  12825. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  12826. var tmpCtx = tmpCanvas.context;
  12827. putBinaryImageData(tmpCtx, imgData);
  12828. imgToPaint = tmpCanvas.canvas;
  12829. }
  12830. var paintWidth = width,
  12831. paintHeight = height;
  12832. var tmpCanvasId = 'prescale1';
  12833. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  12834. var newWidth = paintWidth,
  12835. newHeight = paintHeight;
  12836. if (widthScale > 2 && paintWidth > 1) {
  12837. newWidth = Math.ceil(paintWidth / 2);
  12838. widthScale /= paintWidth / newWidth;
  12839. }
  12840. if (heightScale > 2 && paintHeight > 1) {
  12841. newHeight = Math.ceil(paintHeight / 2);
  12842. heightScale /= paintHeight / newHeight;
  12843. }
  12844. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  12845. tmpCtx = tmpCanvas.context;
  12846. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  12847. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  12848. imgToPaint = tmpCanvas.canvas;
  12849. paintWidth = newWidth;
  12850. paintHeight = newHeight;
  12851. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  12852. }
  12853. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  12854. if (this.imageLayer) {
  12855. var position = this.getCanvasPosition(0, -height);
  12856. this.imageLayer.appendImage({
  12857. imgData: imgData,
  12858. left: position[0],
  12859. top: position[1],
  12860. width: width / currentTransform[0],
  12861. height: height / currentTransform[3]
  12862. });
  12863. }
  12864. this.restore();
  12865. },
  12866. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  12867. var ctx = this.ctx;
  12868. var w = imgData.width;
  12869. var h = imgData.height;
  12870. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  12871. var tmpCtx = tmpCanvas.context;
  12872. putBinaryImageData(tmpCtx, imgData);
  12873. for (var i = 0, ii = map.length; i < ii; i++) {
  12874. var entry = map[i];
  12875. ctx.save();
  12876. ctx.transform.apply(ctx, entry.transform);
  12877. ctx.scale(1, -1);
  12878. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  12879. if (this.imageLayer) {
  12880. var position = this.getCanvasPosition(entry.x, entry.y);
  12881. this.imageLayer.appendImage({
  12882. imgData: imgData,
  12883. left: position[0],
  12884. top: position[1],
  12885. width: w,
  12886. height: h
  12887. });
  12888. }
  12889. ctx.restore();
  12890. }
  12891. },
  12892. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  12893. this.ctx.fillRect(0, 0, 1, 1);
  12894. },
  12895. paintXObject: function CanvasGraphics_paintXObject() {
  12896. (0, _util.warn)('Unsupported \'paintXObject\' command.');
  12897. },
  12898. markPoint: function CanvasGraphics_markPoint(tag) {},
  12899. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {},
  12900. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {},
  12901. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {},
  12902. endMarkedContent: function CanvasGraphics_endMarkedContent() {},
  12903. beginCompat: function CanvasGraphics_beginCompat() {},
  12904. endCompat: function CanvasGraphics_endCompat() {},
  12905. consumePath: function CanvasGraphics_consumePath() {
  12906. var ctx = this.ctx;
  12907. if (this.pendingClip) {
  12908. if (this.pendingClip === EO_CLIP) {
  12909. ctx.clip('evenodd');
  12910. } else {
  12911. ctx.clip();
  12912. }
  12913. this.pendingClip = null;
  12914. }
  12915. ctx.beginPath();
  12916. },
  12917. getSinglePixelWidth: function getSinglePixelWidth(scale) {
  12918. if (this._cachedGetSinglePixelWidth === null) {
  12919. var inverse = this.ctx.mozCurrentTransformInverse;
  12920. this._cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  12921. }
  12922. return this._cachedGetSinglePixelWidth;
  12923. },
  12924. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  12925. var transform = this.ctx.mozCurrentTransform;
  12926. return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]];
  12927. }
  12928. };
  12929. for (var op in _util.OPS) {
  12930. CanvasGraphics.prototype[_util.OPS[op]] = CanvasGraphics.prototype[op];
  12931. }
  12932. return CanvasGraphics;
  12933. }();
  12934. exports.CanvasGraphics = CanvasGraphics;
  12935. /***/ }),
  12936. /* 155 */
  12937. /***/ (function(module, exports, __w_pdfjs_require__) {
  12938. "use strict";
  12939. Object.defineProperty(exports, "__esModule", {
  12940. value: true
  12941. });
  12942. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  12943. exports.TilingPattern = void 0;
  12944. var _util = __w_pdfjs_require__(1);
  12945. var ShadingIRs = {};
  12946. ShadingIRs.RadialAxial = {
  12947. fromIR: function RadialAxial_fromIR(raw) {
  12948. var type = raw[1];
  12949. var colorStops = raw[2];
  12950. var p0 = raw[3];
  12951. var p1 = raw[4];
  12952. var r0 = raw[5];
  12953. var r1 = raw[6];
  12954. return {
  12955. type: 'Pattern',
  12956. getPattern: function RadialAxial_getPattern(ctx) {
  12957. var grad;
  12958. if (type === 'axial') {
  12959. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  12960. } else if (type === 'radial') {
  12961. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  12962. }
  12963. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  12964. var c = colorStops[i];
  12965. grad.addColorStop(c[0], c[1]);
  12966. }
  12967. return grad;
  12968. }
  12969. };
  12970. }
  12971. };
  12972. var createMeshCanvas = function createMeshCanvasClosure() {
  12973. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  12974. var coords = context.coords,
  12975. colors = context.colors;
  12976. var bytes = data.data,
  12977. rowSize = data.width * 4;
  12978. var tmp;
  12979. if (coords[p1 + 1] > coords[p2 + 1]) {
  12980. tmp = p1;
  12981. p1 = p2;
  12982. p2 = tmp;
  12983. tmp = c1;
  12984. c1 = c2;
  12985. c2 = tmp;
  12986. }
  12987. if (coords[p2 + 1] > coords[p3 + 1]) {
  12988. tmp = p2;
  12989. p2 = p3;
  12990. p3 = tmp;
  12991. tmp = c2;
  12992. c2 = c3;
  12993. c3 = tmp;
  12994. }
  12995. if (coords[p1 + 1] > coords[p2 + 1]) {
  12996. tmp = p1;
  12997. p1 = p2;
  12998. p2 = tmp;
  12999. tmp = c1;
  13000. c1 = c2;
  13001. c2 = tmp;
  13002. }
  13003. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  13004. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  13005. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  13006. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  13007. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  13008. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  13009. if (y1 >= y3) {
  13010. return;
  13011. }
  13012. var c1r = colors[c1],
  13013. c1g = colors[c1 + 1],
  13014. c1b = colors[c1 + 2];
  13015. var c2r = colors[c2],
  13016. c2g = colors[c2 + 1],
  13017. c2b = colors[c2 + 2];
  13018. var c3r = colors[c3],
  13019. c3g = colors[c3 + 1],
  13020. c3b = colors[c3 + 2];
  13021. var minY = Math.round(y1),
  13022. maxY = Math.round(y3);
  13023. var xa, car, cag, cab;
  13024. var xb, cbr, cbg, cbb;
  13025. var k;
  13026. for (var y = minY; y <= maxY; y++) {
  13027. if (y < y2) {
  13028. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  13029. xa = x1 - (x1 - x2) * k;
  13030. car = c1r - (c1r - c2r) * k;
  13031. cag = c1g - (c1g - c2g) * k;
  13032. cab = c1b - (c1b - c2b) * k;
  13033. } else {
  13034. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  13035. xa = x2 - (x2 - x3) * k;
  13036. car = c2r - (c2r - c3r) * k;
  13037. cag = c2g - (c2g - c3g) * k;
  13038. cab = c2b - (c2b - c3b) * k;
  13039. }
  13040. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  13041. xb = x1 - (x1 - x3) * k;
  13042. cbr = c1r - (c1r - c3r) * k;
  13043. cbg = c1g - (c1g - c3g) * k;
  13044. cbb = c1b - (c1b - c3b) * k;
  13045. var x1_ = Math.round(Math.min(xa, xb));
  13046. var x2_ = Math.round(Math.max(xa, xb));
  13047. var j = rowSize * y + x1_ * 4;
  13048. for (var x = x1_; x <= x2_; x++) {
  13049. k = (xa - x) / (xa - xb);
  13050. k = k < 0 ? 0 : k > 1 ? 1 : k;
  13051. bytes[j++] = car - (car - cbr) * k | 0;
  13052. bytes[j++] = cag - (cag - cbg) * k | 0;
  13053. bytes[j++] = cab - (cab - cbb) * k | 0;
  13054. bytes[j++] = 255;
  13055. }
  13056. }
  13057. }
  13058. function drawFigure(data, figure, context) {
  13059. var ps = figure.coords;
  13060. var cs = figure.colors;
  13061. var i, ii;
  13062. switch (figure.type) {
  13063. case 'lattice':
  13064. var verticesPerRow = figure.verticesPerRow;
  13065. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  13066. var cols = verticesPerRow - 1;
  13067. for (i = 0; i < rows; i++) {
  13068. var q = i * verticesPerRow;
  13069. for (var j = 0; j < cols; j++, q++) {
  13070. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  13071. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  13072. }
  13073. }
  13074. break;
  13075. case 'triangles':
  13076. for (i = 0, ii = ps.length; i < ii; i += 3) {
  13077. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  13078. }
  13079. break;
  13080. default:
  13081. throw new Error('illegal figure');
  13082. }
  13083. }
  13084. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases, webGLContext) {
  13085. var EXPECTED_SCALE = 1.1;
  13086. var MAX_PATTERN_SIZE = 3000;
  13087. var BORDER_SIZE = 2;
  13088. var offsetX = Math.floor(bounds[0]);
  13089. var offsetY = Math.floor(bounds[1]);
  13090. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  13091. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  13092. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  13093. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  13094. var scaleX = boundsWidth / width;
  13095. var scaleY = boundsHeight / height;
  13096. var context = {
  13097. coords: coords,
  13098. colors: colors,
  13099. offsetX: -offsetX,
  13100. offsetY: -offsetY,
  13101. scaleX: 1 / scaleX,
  13102. scaleY: 1 / scaleY
  13103. };
  13104. var paddedWidth = width + BORDER_SIZE * 2;
  13105. var paddedHeight = height + BORDER_SIZE * 2;
  13106. var canvas, tmpCanvas, i, ii;
  13107. if (webGLContext.isEnabled) {
  13108. canvas = webGLContext.drawFigures({
  13109. width: width,
  13110. height: height,
  13111. backgroundColor: backgroundColor,
  13112. figures: figures,
  13113. context: context
  13114. });
  13115. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  13116. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  13117. canvas = tmpCanvas.canvas;
  13118. } else {
  13119. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  13120. var tmpCtx = tmpCanvas.context;
  13121. var data = tmpCtx.createImageData(width, height);
  13122. if (backgroundColor) {
  13123. var bytes = data.data;
  13124. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  13125. bytes[i] = backgroundColor[0];
  13126. bytes[i + 1] = backgroundColor[1];
  13127. bytes[i + 2] = backgroundColor[2];
  13128. bytes[i + 3] = 255;
  13129. }
  13130. }
  13131. for (i = 0; i < figures.length; i++) {
  13132. drawFigure(data, figures[i], context);
  13133. }
  13134. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  13135. canvas = tmpCanvas.canvas;
  13136. }
  13137. return {
  13138. canvas: canvas,
  13139. offsetX: offsetX - BORDER_SIZE * scaleX,
  13140. offsetY: offsetY - BORDER_SIZE * scaleY,
  13141. scaleX: scaleX,
  13142. scaleY: scaleY
  13143. };
  13144. }
  13145. return createMeshCanvas;
  13146. }();
  13147. ShadingIRs.Mesh = {
  13148. fromIR: function Mesh_fromIR(raw) {
  13149. var coords = raw[2];
  13150. var colors = raw[3];
  13151. var figures = raw[4];
  13152. var bounds = raw[5];
  13153. var matrix = raw[6];
  13154. var background = raw[8];
  13155. return {
  13156. type: 'Pattern',
  13157. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  13158. var scale;
  13159. if (shadingFill) {
  13160. scale = _util.Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  13161. } else {
  13162. scale = _util.Util.singularValueDecompose2dScale(owner.baseTransform);
  13163. if (matrix) {
  13164. var matrixScale = _util.Util.singularValueDecompose2dScale(matrix);
  13165. scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
  13166. }
  13167. }
  13168. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases, owner.webGLContext);
  13169. if (!shadingFill) {
  13170. ctx.setTransform.apply(ctx, owner.baseTransform);
  13171. if (matrix) {
  13172. ctx.transform.apply(ctx, matrix);
  13173. }
  13174. }
  13175. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  13176. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  13177. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  13178. }
  13179. };
  13180. }
  13181. };
  13182. ShadingIRs.Dummy = {
  13183. fromIR: function Dummy_fromIR() {
  13184. return {
  13185. type: 'Pattern',
  13186. getPattern: function Dummy_fromIR_getPattern() {
  13187. return 'hotpink';
  13188. }
  13189. };
  13190. }
  13191. };
  13192. function getShadingPatternFromIR(raw) {
  13193. var shadingIR = ShadingIRs[raw[0]];
  13194. if (!shadingIR) {
  13195. throw new Error("Unknown IR type: ".concat(raw[0]));
  13196. }
  13197. return shadingIR.fromIR(raw);
  13198. }
  13199. var TilingPattern = function TilingPatternClosure() {
  13200. var PaintType = {
  13201. COLORED: 1,
  13202. UNCOLORED: 2
  13203. };
  13204. var MAX_PATTERN_SIZE = 3000;
  13205. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  13206. this.operatorList = IR[2];
  13207. this.matrix = IR[3] || [1, 0, 0, 1, 0, 0];
  13208. this.bbox = IR[4];
  13209. this.xstep = IR[5];
  13210. this.ystep = IR[6];
  13211. this.paintType = IR[7];
  13212. this.tilingType = IR[8];
  13213. this.color = color;
  13214. this.canvasGraphicsFactory = canvasGraphicsFactory;
  13215. this.baseTransform = baseTransform;
  13216. this.type = 'Pattern';
  13217. this.ctx = ctx;
  13218. }
  13219. TilingPattern.prototype = {
  13220. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  13221. var operatorList = this.operatorList;
  13222. var bbox = this.bbox;
  13223. var xstep = this.xstep;
  13224. var ystep = this.ystep;
  13225. var paintType = this.paintType;
  13226. var tilingType = this.tilingType;
  13227. var color = this.color;
  13228. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  13229. (0, _util.info)('TilingType: ' + tilingType);
  13230. var x0 = bbox[0],
  13231. y0 = bbox[1],
  13232. x1 = bbox[2],
  13233. y1 = bbox[3];
  13234. var matrixScale = _util.Util.singularValueDecompose2dScale(this.matrix);
  13235. var curMatrixScale = _util.Util.singularValueDecompose2dScale(this.baseTransform);
  13236. var combinedScale = [matrixScale[0] * curMatrixScale[0], matrixScale[1] * curMatrixScale[1]];
  13237. var dimx = this.getSizeAndScale(xstep, this.ctx.canvas.width, combinedScale[0]);
  13238. var dimy = this.getSizeAndScale(ystep, this.ctx.canvas.height, combinedScale[1]);
  13239. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', dimx.size, dimy.size, true);
  13240. var tmpCtx = tmpCanvas.context;
  13241. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  13242. graphics.groupLevel = owner.groupLevel;
  13243. this.setFillAndStrokeStyleToContext(graphics, paintType, color);
  13244. graphics.transform(dimx.scale, 0, 0, dimy.scale, 0, 0);
  13245. graphics.transform(1, 0, 0, 1, -x0, -y0);
  13246. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  13247. graphics.executeOperatorList(operatorList);
  13248. this.ctx.transform(1, 0, 0, 1, x0, y0);
  13249. this.ctx.scale(1 / dimx.scale, 1 / dimy.scale);
  13250. return tmpCanvas.canvas;
  13251. },
  13252. getSizeAndScale: function TilingPattern_getSizeAndScale(step, realOutputSize, scale) {
  13253. step = Math.abs(step);
  13254. var maxSize = Math.max(MAX_PATTERN_SIZE, realOutputSize);
  13255. var size = Math.ceil(step * scale);
  13256. if (size >= maxSize) {
  13257. size = maxSize;
  13258. } else {
  13259. scale = size / step;
  13260. }
  13261. return {
  13262. scale: scale,
  13263. size: size
  13264. };
  13265. },
  13266. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  13267. if (Array.isArray(bbox) && bbox.length === 4) {
  13268. var bboxWidth = x1 - x0;
  13269. var bboxHeight = y1 - y0;
  13270. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  13271. graphics.clip();
  13272. graphics.endPath();
  13273. }
  13274. },
  13275. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(graphics, paintType, color) {
  13276. var context = graphics.ctx,
  13277. current = graphics.current;
  13278. switch (paintType) {
  13279. case PaintType.COLORED:
  13280. var ctx = this.ctx;
  13281. context.fillStyle = ctx.fillStyle;
  13282. context.strokeStyle = ctx.strokeStyle;
  13283. current.fillColor = ctx.fillStyle;
  13284. current.strokeColor = ctx.strokeStyle;
  13285. break;
  13286. case PaintType.UNCOLORED:
  13287. var cssColor = _util.Util.makeCssRgb(color[0], color[1], color[2]);
  13288. context.fillStyle = cssColor;
  13289. context.strokeStyle = cssColor;
  13290. current.fillColor = cssColor;
  13291. current.strokeColor = cssColor;
  13292. break;
  13293. default:
  13294. throw new _util.FormatError("Unsupported paint type: ".concat(paintType));
  13295. }
  13296. },
  13297. getPattern: function TilingPattern_getPattern(ctx, owner) {
  13298. ctx = this.ctx;
  13299. ctx.setTransform.apply(ctx, this.baseTransform);
  13300. ctx.transform.apply(ctx, this.matrix);
  13301. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  13302. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  13303. }
  13304. };
  13305. return TilingPattern;
  13306. }();
  13307. exports.TilingPattern = TilingPattern;
  13308. /***/ }),
  13309. /* 156 */
  13310. /***/ (function(module, exports, __w_pdfjs_require__) {
  13311. "use strict";
  13312. Object.defineProperty(exports, "__esModule", {
  13313. value: true
  13314. });
  13315. exports.GlobalWorkerOptions = void 0;
  13316. var GlobalWorkerOptions = Object.create(null);
  13317. exports.GlobalWorkerOptions = GlobalWorkerOptions;
  13318. GlobalWorkerOptions.workerPort = GlobalWorkerOptions.workerPort === undefined ? null : GlobalWorkerOptions.workerPort;
  13319. GlobalWorkerOptions.workerSrc = GlobalWorkerOptions.workerSrc === undefined ? '' : GlobalWorkerOptions.workerSrc;
  13320. /***/ }),
  13321. /* 157 */
  13322. /***/ (function(module, exports, __w_pdfjs_require__) {
  13323. "use strict";
  13324. Object.defineProperty(exports, "__esModule", {
  13325. value: true
  13326. });
  13327. exports.MessageHandler = MessageHandler;
  13328. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(148));
  13329. var _util = __w_pdfjs_require__(1);
  13330. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13331. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13332. 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); } }
  13333. 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); }); }; }
  13334. function resolveCall(_x, _x2) {
  13335. return _resolveCall.apply(this, arguments);
  13336. }
  13337. function _resolveCall() {
  13338. _resolveCall = _asyncToGenerator(
  13339. /*#__PURE__*/
  13340. _regenerator["default"].mark(function _callee(fn, args) {
  13341. var thisArg,
  13342. _args = arguments;
  13343. return _regenerator["default"].wrap(function _callee$(_context) {
  13344. while (1) {
  13345. switch (_context.prev = _context.next) {
  13346. case 0:
  13347. thisArg = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
  13348. if (fn) {
  13349. _context.next = 3;
  13350. break;
  13351. }
  13352. return _context.abrupt("return", undefined);
  13353. case 3:
  13354. return _context.abrupt("return", fn.apply(thisArg, args));
  13355. case 4:
  13356. case "end":
  13357. return _context.stop();
  13358. }
  13359. }
  13360. }, _callee);
  13361. }));
  13362. return _resolveCall.apply(this, arguments);
  13363. }
  13364. function wrapReason(reason) {
  13365. if (_typeof(reason) !== 'object') {
  13366. return reason;
  13367. }
  13368. switch (reason.name) {
  13369. case 'AbortException':
  13370. return new _util.AbortException(reason.message);
  13371. case 'MissingPDFException':
  13372. return new _util.MissingPDFException(reason.message);
  13373. case 'UnexpectedResponseException':
  13374. return new _util.UnexpectedResponseException(reason.message, reason.status);
  13375. default:
  13376. return new _util.UnknownErrorException(reason.message, reason.details);
  13377. }
  13378. }
  13379. function makeReasonSerializable(reason) {
  13380. if (!(reason instanceof Error) || reason instanceof _util.AbortException || reason instanceof _util.MissingPDFException || reason instanceof _util.UnexpectedResponseException || reason instanceof _util.UnknownErrorException) {
  13381. return reason;
  13382. }
  13383. return new _util.UnknownErrorException(reason.message, reason.toString());
  13384. }
  13385. function resolveOrReject(capability, success, reason) {
  13386. if (success) {
  13387. capability.resolve();
  13388. } else {
  13389. capability.reject(reason);
  13390. }
  13391. }
  13392. function finalize(promise) {
  13393. return Promise.resolve(promise)["catch"](function () {});
  13394. }
  13395. function MessageHandler(sourceName, targetName, comObj) {
  13396. var _this = this;
  13397. this.sourceName = sourceName;
  13398. this.targetName = targetName;
  13399. this.comObj = comObj;
  13400. this.callbackId = 1;
  13401. this.streamId = 1;
  13402. this.postMessageTransfers = true;
  13403. this.streamSinks = Object.create(null);
  13404. this.streamControllers = Object.create(null);
  13405. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  13406. var ah = this.actionHandler = Object.create(null);
  13407. this._onComObjOnMessage = function (event) {
  13408. var data = event.data;
  13409. if (data.targetName !== _this.sourceName) {
  13410. return;
  13411. }
  13412. if (data.stream) {
  13413. _this._processStreamMessage(data);
  13414. } else if (data.isReply) {
  13415. var callbackId = data.callbackId;
  13416. if (data.callbackId in callbacksCapabilities) {
  13417. var callback = callbacksCapabilities[callbackId];
  13418. delete callbacksCapabilities[callbackId];
  13419. if ('error' in data) {
  13420. callback.reject(wrapReason(data.error));
  13421. } else {
  13422. callback.resolve(data.data);
  13423. }
  13424. } else {
  13425. throw new Error("Cannot resolve callback ".concat(callbackId));
  13426. }
  13427. } else if (data.action in ah) {
  13428. var action = ah[data.action];
  13429. if (data.callbackId) {
  13430. var _sourceName = _this.sourceName;
  13431. var _targetName = data.sourceName;
  13432. Promise.resolve().then(function () {
  13433. return action[0].call(action[1], data.data);
  13434. }).then(function (result) {
  13435. comObj.postMessage({
  13436. sourceName: _sourceName,
  13437. targetName: _targetName,
  13438. isReply: true,
  13439. callbackId: data.callbackId,
  13440. data: result
  13441. });
  13442. }, function (reason) {
  13443. comObj.postMessage({
  13444. sourceName: _sourceName,
  13445. targetName: _targetName,
  13446. isReply: true,
  13447. callbackId: data.callbackId,
  13448. error: makeReasonSerializable(reason)
  13449. });
  13450. });
  13451. } else if (data.streamId) {
  13452. _this._createStreamSink(data);
  13453. } else {
  13454. action[0].call(action[1], data.data);
  13455. }
  13456. } else {
  13457. throw new Error("Unknown action from worker: ".concat(data.action));
  13458. }
  13459. };
  13460. comObj.addEventListener('message', this._onComObjOnMessage);
  13461. }
  13462. MessageHandler.prototype = {
  13463. on: function on(actionName, handler, scope) {
  13464. var ah = this.actionHandler;
  13465. if (ah[actionName]) {
  13466. throw new Error("There is already an actionName called \"".concat(actionName, "\""));
  13467. }
  13468. ah[actionName] = [handler, scope];
  13469. },
  13470. send: function send(actionName, data, transfers) {
  13471. var message = {
  13472. sourceName: this.sourceName,
  13473. targetName: this.targetName,
  13474. action: actionName,
  13475. data: data
  13476. };
  13477. this.postMessage(message, transfers);
  13478. },
  13479. sendWithPromise: function sendWithPromise(actionName, data, transfers) {
  13480. var callbackId = this.callbackId++;
  13481. var message = {
  13482. sourceName: this.sourceName,
  13483. targetName: this.targetName,
  13484. action: actionName,
  13485. data: data,
  13486. callbackId: callbackId
  13487. };
  13488. var capability = (0, _util.createPromiseCapability)();
  13489. this.callbacksCapabilities[callbackId] = capability;
  13490. try {
  13491. this.postMessage(message, transfers);
  13492. } catch (e) {
  13493. capability.reject(e);
  13494. }
  13495. return capability.promise;
  13496. },
  13497. sendWithStream: function sendWithStream(actionName, data, queueingStrategy, transfers) {
  13498. var _this2 = this;
  13499. var streamId = this.streamId++;
  13500. var sourceName = this.sourceName;
  13501. var targetName = this.targetName;
  13502. return new _util.ReadableStream({
  13503. start: function start(controller) {
  13504. var startCapability = (0, _util.createPromiseCapability)();
  13505. _this2.streamControllers[streamId] = {
  13506. controller: controller,
  13507. startCall: startCapability,
  13508. isClosed: false
  13509. };
  13510. _this2.postMessage({
  13511. sourceName: sourceName,
  13512. targetName: targetName,
  13513. action: actionName,
  13514. streamId: streamId,
  13515. data: data,
  13516. desiredSize: controller.desiredSize
  13517. });
  13518. return startCapability.promise;
  13519. },
  13520. pull: function pull(controller) {
  13521. var pullCapability = (0, _util.createPromiseCapability)();
  13522. _this2.streamControllers[streamId].pullCall = pullCapability;
  13523. _this2.postMessage({
  13524. sourceName: sourceName,
  13525. targetName: targetName,
  13526. stream: 'pull',
  13527. streamId: streamId,
  13528. desiredSize: controller.desiredSize
  13529. });
  13530. return pullCapability.promise;
  13531. },
  13532. cancel: function cancel(reason) {
  13533. var cancelCapability = (0, _util.createPromiseCapability)();
  13534. _this2.streamControllers[streamId].cancelCall = cancelCapability;
  13535. _this2.streamControllers[streamId].isClosed = true;
  13536. _this2.postMessage({
  13537. sourceName: sourceName,
  13538. targetName: targetName,
  13539. stream: 'cancel',
  13540. reason: reason,
  13541. streamId: streamId
  13542. });
  13543. return cancelCapability.promise;
  13544. }
  13545. }, queueingStrategy);
  13546. },
  13547. _createStreamSink: function _createStreamSink(data) {
  13548. var _this3 = this;
  13549. var self = this;
  13550. var action = this.actionHandler[data.action];
  13551. var streamId = data.streamId;
  13552. var desiredSize = data.desiredSize;
  13553. var sourceName = this.sourceName;
  13554. var targetName = data.sourceName;
  13555. var capability = (0, _util.createPromiseCapability)();
  13556. var sendStreamRequest = function sendStreamRequest(_ref) {
  13557. var stream = _ref.stream,
  13558. chunk = _ref.chunk,
  13559. transfers = _ref.transfers,
  13560. success = _ref.success,
  13561. reason = _ref.reason;
  13562. _this3.postMessage({
  13563. sourceName: sourceName,
  13564. targetName: targetName,
  13565. stream: stream,
  13566. streamId: streamId,
  13567. chunk: chunk,
  13568. success: success,
  13569. reason: reason
  13570. }, transfers);
  13571. };
  13572. var streamSink = {
  13573. enqueue: function enqueue(chunk) {
  13574. var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  13575. var transfers = arguments.length > 2 ? arguments[2] : undefined;
  13576. if (this.isCancelled) {
  13577. return;
  13578. }
  13579. var lastDesiredSize = this.desiredSize;
  13580. this.desiredSize -= size;
  13581. if (lastDesiredSize > 0 && this.desiredSize <= 0) {
  13582. this.sinkCapability = (0, _util.createPromiseCapability)();
  13583. this.ready = this.sinkCapability.promise;
  13584. }
  13585. sendStreamRequest({
  13586. stream: 'enqueue',
  13587. chunk: chunk,
  13588. transfers: transfers
  13589. });
  13590. },
  13591. close: function close() {
  13592. if (this.isCancelled) {
  13593. return;
  13594. }
  13595. this.isCancelled = true;
  13596. sendStreamRequest({
  13597. stream: 'close'
  13598. });
  13599. delete self.streamSinks[streamId];
  13600. },
  13601. error: function error(reason) {
  13602. if (this.isCancelled) {
  13603. return;
  13604. }
  13605. this.isCancelled = true;
  13606. sendStreamRequest({
  13607. stream: 'error',
  13608. reason: reason
  13609. });
  13610. },
  13611. sinkCapability: capability,
  13612. onPull: null,
  13613. onCancel: null,
  13614. isCancelled: false,
  13615. desiredSize: desiredSize,
  13616. ready: null
  13617. };
  13618. streamSink.sinkCapability.resolve();
  13619. streamSink.ready = streamSink.sinkCapability.promise;
  13620. this.streamSinks[streamId] = streamSink;
  13621. resolveCall(action[0], [data.data, streamSink], action[1]).then(function () {
  13622. sendStreamRequest({
  13623. stream: 'start_complete',
  13624. success: true
  13625. });
  13626. }, function (reason) {
  13627. sendStreamRequest({
  13628. stream: 'start_complete',
  13629. success: false,
  13630. reason: reason
  13631. });
  13632. });
  13633. },
  13634. _processStreamMessage: function _processStreamMessage(data) {
  13635. var _this4 = this;
  13636. var sourceName = this.sourceName;
  13637. var targetName = data.sourceName;
  13638. var streamId = data.streamId;
  13639. var sendStreamResponse = function sendStreamResponse(_ref2) {
  13640. var stream = _ref2.stream,
  13641. success = _ref2.success,
  13642. reason = _ref2.reason;
  13643. _this4.comObj.postMessage({
  13644. sourceName: sourceName,
  13645. targetName: targetName,
  13646. stream: stream,
  13647. success: success,
  13648. streamId: streamId,
  13649. reason: reason
  13650. });
  13651. };
  13652. var deleteStreamController = function deleteStreamController() {
  13653. Promise.all([_this4.streamControllers[data.streamId].startCall, _this4.streamControllers[data.streamId].pullCall, _this4.streamControllers[data.streamId].cancelCall].map(function (capability) {
  13654. return capability && finalize(capability.promise);
  13655. })).then(function () {
  13656. delete _this4.streamControllers[data.streamId];
  13657. });
  13658. };
  13659. switch (data.stream) {
  13660. case 'start_complete':
  13661. resolveOrReject(this.streamControllers[data.streamId].startCall, data.success, wrapReason(data.reason));
  13662. break;
  13663. case 'pull_complete':
  13664. resolveOrReject(this.streamControllers[data.streamId].pullCall, data.success, wrapReason(data.reason));
  13665. break;
  13666. case 'pull':
  13667. if (!this.streamSinks[data.streamId]) {
  13668. sendStreamResponse({
  13669. stream: 'pull_complete',
  13670. success: true
  13671. });
  13672. break;
  13673. }
  13674. if (this.streamSinks[data.streamId].desiredSize <= 0 && data.desiredSize > 0) {
  13675. this.streamSinks[data.streamId].sinkCapability.resolve();
  13676. }
  13677. this.streamSinks[data.streamId].desiredSize = data.desiredSize;
  13678. resolveCall(this.streamSinks[data.streamId].onPull).then(function () {
  13679. sendStreamResponse({
  13680. stream: 'pull_complete',
  13681. success: true
  13682. });
  13683. }, function (reason) {
  13684. sendStreamResponse({
  13685. stream: 'pull_complete',
  13686. success: false,
  13687. reason: reason
  13688. });
  13689. });
  13690. break;
  13691. case 'enqueue':
  13692. (0, _util.assert)(this.streamControllers[data.streamId], 'enqueue should have stream controller');
  13693. if (!this.streamControllers[data.streamId].isClosed) {
  13694. this.streamControllers[data.streamId].controller.enqueue(data.chunk);
  13695. }
  13696. break;
  13697. case 'close':
  13698. (0, _util.assert)(this.streamControllers[data.streamId], 'close should have stream controller');
  13699. if (this.streamControllers[data.streamId].isClosed) {
  13700. break;
  13701. }
  13702. this.streamControllers[data.streamId].isClosed = true;
  13703. this.streamControllers[data.streamId].controller.close();
  13704. deleteStreamController();
  13705. break;
  13706. case 'error':
  13707. (0, _util.assert)(this.streamControllers[data.streamId], 'error should have stream controller');
  13708. this.streamControllers[data.streamId].controller.error(wrapReason(data.reason));
  13709. deleteStreamController();
  13710. break;
  13711. case 'cancel_complete':
  13712. resolveOrReject(this.streamControllers[data.streamId].cancelCall, data.success, wrapReason(data.reason));
  13713. deleteStreamController();
  13714. break;
  13715. case 'cancel':
  13716. if (!this.streamSinks[data.streamId]) {
  13717. break;
  13718. }
  13719. resolveCall(this.streamSinks[data.streamId].onCancel, [wrapReason(data.reason)]).then(function () {
  13720. sendStreamResponse({
  13721. stream: 'cancel_complete',
  13722. success: true
  13723. });
  13724. }, function (reason) {
  13725. sendStreamResponse({
  13726. stream: 'cancel_complete',
  13727. success: false,
  13728. reason: reason
  13729. });
  13730. });
  13731. this.streamSinks[data.streamId].sinkCapability.reject(wrapReason(data.reason));
  13732. this.streamSinks[data.streamId].isCancelled = true;
  13733. delete this.streamSinks[data.streamId];
  13734. break;
  13735. default:
  13736. throw new Error('Unexpected stream case');
  13737. }
  13738. },
  13739. postMessage: function postMessage(message, transfers) {
  13740. if (transfers && this.postMessageTransfers) {
  13741. this.comObj.postMessage(message, transfers);
  13742. } else {
  13743. this.comObj.postMessage(message);
  13744. }
  13745. },
  13746. destroy: function destroy() {
  13747. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  13748. }
  13749. };
  13750. /***/ }),
  13751. /* 158 */
  13752. /***/ (function(module, exports, __w_pdfjs_require__) {
  13753. "use strict";
  13754. Object.defineProperty(exports, "__esModule", {
  13755. value: true
  13756. });
  13757. exports.Metadata = void 0;
  13758. var _util = __w_pdfjs_require__(1);
  13759. var _xml_parser = __w_pdfjs_require__(159);
  13760. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13761. 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); } }
  13762. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13763. var Metadata =
  13764. /*#__PURE__*/
  13765. function () {
  13766. function Metadata(data) {
  13767. _classCallCheck(this, Metadata);
  13768. (0, _util.assert)(typeof data === 'string', 'Metadata: input is not a string');
  13769. data = this._repair(data);
  13770. var parser = new _xml_parser.SimpleXMLParser();
  13771. var xmlDocument = parser.parseFromString(data);
  13772. this._metadata = Object.create(null);
  13773. if (xmlDocument) {
  13774. this._parse(xmlDocument);
  13775. }
  13776. }
  13777. _createClass(Metadata, [{
  13778. key: "_repair",
  13779. value: function _repair(data) {
  13780. return data.replace(/^([^<]+)/, '').replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  13781. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  13782. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  13783. }).replace(/&(amp|apos|gt|lt|quot);/g, function (str, name) {
  13784. switch (name) {
  13785. case 'amp':
  13786. return '&';
  13787. case 'apos':
  13788. return '\'';
  13789. case 'gt':
  13790. return '>';
  13791. case 'lt':
  13792. return '<';
  13793. case 'quot':
  13794. return '\"';
  13795. }
  13796. throw new Error("_repair: ".concat(name, " isn't defined."));
  13797. });
  13798. var chars = '';
  13799. for (var i = 0, ii = bytes.length; i < ii; i += 2) {
  13800. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  13801. if (code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38) {
  13802. chars += String.fromCharCode(code);
  13803. } else {
  13804. chars += '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  13805. }
  13806. }
  13807. return '>' + chars;
  13808. });
  13809. }
  13810. }, {
  13811. key: "_parse",
  13812. value: function _parse(xmlDocument) {
  13813. var rdf = xmlDocument.documentElement;
  13814. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  13815. rdf = rdf.firstChild;
  13816. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  13817. rdf = rdf.nextSibling;
  13818. }
  13819. }
  13820. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  13821. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  13822. return;
  13823. }
  13824. var children = rdf.childNodes;
  13825. for (var i = 0, ii = children.length; i < ii; i++) {
  13826. var desc = children[i];
  13827. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  13828. continue;
  13829. }
  13830. for (var j = 0, jj = desc.childNodes.length; j < jj; j++) {
  13831. if (desc.childNodes[j].nodeName.toLowerCase() !== '#text') {
  13832. var entry = desc.childNodes[j];
  13833. var name = entry.nodeName.toLowerCase();
  13834. this._metadata[name] = entry.textContent.trim();
  13835. }
  13836. }
  13837. }
  13838. }
  13839. }, {
  13840. key: "get",
  13841. value: function get(name) {
  13842. var data = this._metadata[name];
  13843. return typeof data !== 'undefined' ? data : null;
  13844. }
  13845. }, {
  13846. key: "getAll",
  13847. value: function getAll() {
  13848. return this._metadata;
  13849. }
  13850. }, {
  13851. key: "has",
  13852. value: function has(name) {
  13853. return typeof this._metadata[name] !== 'undefined';
  13854. }
  13855. }]);
  13856. return Metadata;
  13857. }();
  13858. exports.Metadata = Metadata;
  13859. /***/ }),
  13860. /* 159 */
  13861. /***/ (function(module, exports, __w_pdfjs_require__) {
  13862. "use strict";
  13863. Object.defineProperty(exports, "__esModule", {
  13864. value: true
  13865. });
  13866. exports.SimpleXMLParser = void 0;
  13867. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13868. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  13869. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  13870. function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  13871. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  13872. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13873. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13874. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  13875. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  13876. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13877. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  13878. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13879. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13880. 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); } }
  13881. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13882. var XMLParserErrorCode = {
  13883. NoError: 0,
  13884. EndOfDocument: -1,
  13885. UnterminatedCdat: -2,
  13886. UnterminatedXmlDeclaration: -3,
  13887. UnterminatedDoctypeDeclaration: -4,
  13888. UnterminatedComment: -5,
  13889. MalformedElement: -6,
  13890. OutOfMemory: -7,
  13891. UnterminatedAttributeValue: -8,
  13892. UnterminatedElement: -9,
  13893. ElementNeverBegun: -10
  13894. };
  13895. function isWhitespace(s, index) {
  13896. var ch = s[index];
  13897. return ch === ' ' || ch === '\n' || ch === '\r' || ch === '\t';
  13898. }
  13899. function isWhitespaceString(s) {
  13900. for (var i = 0, ii = s.length; i < ii; i++) {
  13901. if (!isWhitespace(s, i)) {
  13902. return false;
  13903. }
  13904. }
  13905. return true;
  13906. }
  13907. var XMLParserBase =
  13908. /*#__PURE__*/
  13909. function () {
  13910. function XMLParserBase() {
  13911. _classCallCheck(this, XMLParserBase);
  13912. }
  13913. _createClass(XMLParserBase, [{
  13914. key: "_resolveEntities",
  13915. value: function _resolveEntities(s) {
  13916. var _this = this;
  13917. return s.replace(/&([^;]+);/g, function (all, entity) {
  13918. if (entity.substring(0, 2) === '#x') {
  13919. return String.fromCharCode(parseInt(entity.substring(2), 16));
  13920. } else if (entity.substring(0, 1) === '#') {
  13921. return String.fromCharCode(parseInt(entity.substring(1), 10));
  13922. }
  13923. switch (entity) {
  13924. case 'lt':
  13925. return '<';
  13926. case 'gt':
  13927. return '>';
  13928. case 'amp':
  13929. return '&';
  13930. case 'quot':
  13931. return '\"';
  13932. }
  13933. return _this.onResolveEntity(entity);
  13934. });
  13935. }
  13936. }, {
  13937. key: "_parseContent",
  13938. value: function _parseContent(s, start) {
  13939. var pos = start,
  13940. name,
  13941. attributes = [];
  13942. function skipWs() {
  13943. while (pos < s.length && isWhitespace(s, pos)) {
  13944. ++pos;
  13945. }
  13946. }
  13947. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== '>' && s[pos] !== '/') {
  13948. ++pos;
  13949. }
  13950. name = s.substring(start, pos);
  13951. skipWs();
  13952. while (pos < s.length && s[pos] !== '>' && s[pos] !== '/' && s[pos] !== '?') {
  13953. skipWs();
  13954. var attrName = '',
  13955. attrValue = '';
  13956. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== '=') {
  13957. attrName += s[pos];
  13958. ++pos;
  13959. }
  13960. skipWs();
  13961. if (s[pos] !== '=') {
  13962. return null;
  13963. }
  13964. ++pos;
  13965. skipWs();
  13966. var attrEndChar = s[pos];
  13967. if (attrEndChar !== '\"' && attrEndChar !== '\'') {
  13968. return null;
  13969. }
  13970. var attrEndIndex = s.indexOf(attrEndChar, ++pos);
  13971. if (attrEndIndex < 0) {
  13972. return null;
  13973. }
  13974. attrValue = s.substring(pos, attrEndIndex);
  13975. attributes.push({
  13976. name: attrName,
  13977. value: this._resolveEntities(attrValue)
  13978. });
  13979. pos = attrEndIndex + 1;
  13980. skipWs();
  13981. }
  13982. return {
  13983. name: name,
  13984. attributes: attributes,
  13985. parsed: pos - start
  13986. };
  13987. }
  13988. }, {
  13989. key: "_parseProcessingInstruction",
  13990. value: function _parseProcessingInstruction(s, start) {
  13991. var pos = start,
  13992. name,
  13993. value;
  13994. function skipWs() {
  13995. while (pos < s.length && isWhitespace(s, pos)) {
  13996. ++pos;
  13997. }
  13998. }
  13999. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== '>' && s[pos] !== '/') {
  14000. ++pos;
  14001. }
  14002. name = s.substring(start, pos);
  14003. skipWs();
  14004. var attrStart = pos;
  14005. while (pos < s.length && (s[pos] !== '?' || s[pos + 1] !== '>')) {
  14006. ++pos;
  14007. }
  14008. value = s.substring(attrStart, pos);
  14009. return {
  14010. name: name,
  14011. value: value,
  14012. parsed: pos - start
  14013. };
  14014. }
  14015. }, {
  14016. key: "parseXml",
  14017. value: function parseXml(s) {
  14018. var i = 0;
  14019. while (i < s.length) {
  14020. var ch = s[i];
  14021. var j = i;
  14022. if (ch === '<') {
  14023. ++j;
  14024. var ch2 = s[j];
  14025. var q = void 0;
  14026. switch (ch2) {
  14027. case '/':
  14028. ++j;
  14029. q = s.indexOf('>', j);
  14030. if (q < 0) {
  14031. this.onError(XMLParserErrorCode.UnterminatedElement);
  14032. return;
  14033. }
  14034. this.onEndElement(s.substring(j, q));
  14035. j = q + 1;
  14036. break;
  14037. case '?':
  14038. ++j;
  14039. var pi = this._parseProcessingInstruction(s, j);
  14040. if (s.substring(j + pi.parsed, j + pi.parsed + 2) !== '?>') {
  14041. this.onError(XMLParserErrorCode.UnterminatedXmlDeclaration);
  14042. return;
  14043. }
  14044. this.onPi(pi.name, pi.value);
  14045. j += pi.parsed + 2;
  14046. break;
  14047. case '!':
  14048. if (s.substring(j + 1, j + 3) === '--') {
  14049. q = s.indexOf('-->', j + 3);
  14050. if (q < 0) {
  14051. this.onError(XMLParserErrorCode.UnterminatedComment);
  14052. return;
  14053. }
  14054. this.onComment(s.substring(j + 3, q));
  14055. j = q + 3;
  14056. } else if (s.substring(j + 1, j + 8) === '[CDATA[') {
  14057. q = s.indexOf(']]>', j + 8);
  14058. if (q < 0) {
  14059. this.onError(XMLParserErrorCode.UnterminatedCdat);
  14060. return;
  14061. }
  14062. this.onCdata(s.substring(j + 8, q));
  14063. j = q + 3;
  14064. } else if (s.substring(j + 1, j + 8) === 'DOCTYPE') {
  14065. var q2 = s.indexOf('[', j + 8);
  14066. var complexDoctype = false;
  14067. q = s.indexOf('>', j + 8);
  14068. if (q < 0) {
  14069. this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
  14070. return;
  14071. }
  14072. if (q2 > 0 && q > q2) {
  14073. q = s.indexOf(']>', j + 8);
  14074. if (q < 0) {
  14075. this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
  14076. return;
  14077. }
  14078. complexDoctype = true;
  14079. }
  14080. var doctypeContent = s.substring(j + 8, q + (complexDoctype ? 1 : 0));
  14081. this.onDoctype(doctypeContent);
  14082. j = q + (complexDoctype ? 2 : 1);
  14083. } else {
  14084. this.onError(XMLParserErrorCode.MalformedElement);
  14085. return;
  14086. }
  14087. break;
  14088. default:
  14089. var content = this._parseContent(s, j);
  14090. if (content === null) {
  14091. this.onError(XMLParserErrorCode.MalformedElement);
  14092. return;
  14093. }
  14094. var isClosed = false;
  14095. if (s.substring(j + content.parsed, j + content.parsed + 2) === '/>') {
  14096. isClosed = true;
  14097. } else if (s.substring(j + content.parsed, j + content.parsed + 1) !== '>') {
  14098. this.onError(XMLParserErrorCode.UnterminatedElement);
  14099. return;
  14100. }
  14101. this.onBeginElement(content.name, content.attributes, isClosed);
  14102. j += content.parsed + (isClosed ? 2 : 1);
  14103. break;
  14104. }
  14105. } else {
  14106. while (j < s.length && s[j] !== '<') {
  14107. j++;
  14108. }
  14109. var text = s.substring(i, j);
  14110. this.onText(this._resolveEntities(text));
  14111. }
  14112. i = j;
  14113. }
  14114. }
  14115. }, {
  14116. key: "onResolveEntity",
  14117. value: function onResolveEntity(name) {
  14118. return "&".concat(name, ";");
  14119. }
  14120. }, {
  14121. key: "onPi",
  14122. value: function onPi(name, value) {}
  14123. }, {
  14124. key: "onComment",
  14125. value: function onComment(text) {}
  14126. }, {
  14127. key: "onCdata",
  14128. value: function onCdata(text) {}
  14129. }, {
  14130. key: "onDoctype",
  14131. value: function onDoctype(doctypeContent) {}
  14132. }, {
  14133. key: "onText",
  14134. value: function onText(text) {}
  14135. }, {
  14136. key: "onBeginElement",
  14137. value: function onBeginElement(name, attributes, isEmpty) {}
  14138. }, {
  14139. key: "onEndElement",
  14140. value: function onEndElement(name) {}
  14141. }, {
  14142. key: "onError",
  14143. value: function onError(code) {}
  14144. }]);
  14145. return XMLParserBase;
  14146. }();
  14147. var SimpleDOMNode =
  14148. /*#__PURE__*/
  14149. function () {
  14150. function SimpleDOMNode(nodeName, nodeValue) {
  14151. _classCallCheck(this, SimpleDOMNode);
  14152. this.nodeName = nodeName;
  14153. this.nodeValue = nodeValue;
  14154. Object.defineProperty(this, 'parentNode', {
  14155. value: null,
  14156. writable: true
  14157. });
  14158. }
  14159. _createClass(SimpleDOMNode, [{
  14160. key: "hasChildNodes",
  14161. value: function hasChildNodes() {
  14162. return this.childNodes && this.childNodes.length > 0;
  14163. }
  14164. }, {
  14165. key: "firstChild",
  14166. get: function get() {
  14167. return this.childNodes && this.childNodes[0];
  14168. }
  14169. }, {
  14170. key: "nextSibling",
  14171. get: function get() {
  14172. var childNodes = this.parentNode.childNodes;
  14173. if (!childNodes) {
  14174. return undefined;
  14175. }
  14176. var index = childNodes.indexOf(this);
  14177. if (index === -1) {
  14178. return undefined;
  14179. }
  14180. return childNodes[index + 1];
  14181. }
  14182. }, {
  14183. key: "textContent",
  14184. get: function get() {
  14185. if (!this.childNodes) {
  14186. return this.nodeValue || '';
  14187. }
  14188. return this.childNodes.map(function (child) {
  14189. return child.textContent;
  14190. }).join('');
  14191. }
  14192. }]);
  14193. return SimpleDOMNode;
  14194. }();
  14195. var SimpleXMLParser =
  14196. /*#__PURE__*/
  14197. function (_XMLParserBase) {
  14198. _inherits(SimpleXMLParser, _XMLParserBase);
  14199. function SimpleXMLParser() {
  14200. var _this2;
  14201. _classCallCheck(this, SimpleXMLParser);
  14202. _this2 = _possibleConstructorReturn(this, _getPrototypeOf(SimpleXMLParser).call(this));
  14203. _this2._currentFragment = null;
  14204. _this2._stack = null;
  14205. _this2._errorCode = XMLParserErrorCode.NoError;
  14206. return _this2;
  14207. }
  14208. _createClass(SimpleXMLParser, [{
  14209. key: "parseFromString",
  14210. value: function parseFromString(data) {
  14211. this._currentFragment = [];
  14212. this._stack = [];
  14213. this._errorCode = XMLParserErrorCode.NoError;
  14214. this.parseXml(data);
  14215. if (this._errorCode !== XMLParserErrorCode.NoError) {
  14216. return undefined;
  14217. }
  14218. var _this$_currentFragmen = _slicedToArray(this._currentFragment, 1),
  14219. documentElement = _this$_currentFragmen[0];
  14220. if (!documentElement) {
  14221. return undefined;
  14222. }
  14223. return {
  14224. documentElement: documentElement
  14225. };
  14226. }
  14227. }, {
  14228. key: "onResolveEntity",
  14229. value: function onResolveEntity(name) {
  14230. switch (name) {
  14231. case 'apos':
  14232. return '\'';
  14233. }
  14234. return _get(_getPrototypeOf(SimpleXMLParser.prototype), "onResolveEntity", this).call(this, name);
  14235. }
  14236. }, {
  14237. key: "onText",
  14238. value: function onText(text) {
  14239. if (isWhitespaceString(text)) {
  14240. return;
  14241. }
  14242. var node = new SimpleDOMNode('#text', text);
  14243. this._currentFragment.push(node);
  14244. }
  14245. }, {
  14246. key: "onCdata",
  14247. value: function onCdata(text) {
  14248. var node = new SimpleDOMNode('#text', text);
  14249. this._currentFragment.push(node);
  14250. }
  14251. }, {
  14252. key: "onBeginElement",
  14253. value: function onBeginElement(name, attributes, isEmpty) {
  14254. var node = new SimpleDOMNode(name);
  14255. node.childNodes = [];
  14256. this._currentFragment.push(node);
  14257. if (isEmpty) {
  14258. return;
  14259. }
  14260. this._stack.push(this._currentFragment);
  14261. this._currentFragment = node.childNodes;
  14262. }
  14263. }, {
  14264. key: "onEndElement",
  14265. value: function onEndElement(name) {
  14266. this._currentFragment = this._stack.pop() || [];
  14267. var lastElement = this._currentFragment[this._currentFragment.length - 1];
  14268. if (!lastElement) {
  14269. return;
  14270. }
  14271. for (var i = 0, ii = lastElement.childNodes.length; i < ii; i++) {
  14272. lastElement.childNodes[i].parentNode = lastElement;
  14273. }
  14274. }
  14275. }, {
  14276. key: "onError",
  14277. value: function onError(code) {
  14278. this._errorCode = code;
  14279. }
  14280. }]);
  14281. return SimpleXMLParser;
  14282. }(XMLParserBase);
  14283. exports.SimpleXMLParser = SimpleXMLParser;
  14284. /***/ }),
  14285. /* 160 */
  14286. /***/ (function(module, exports, __w_pdfjs_require__) {
  14287. "use strict";
  14288. Object.defineProperty(exports, "__esModule", {
  14289. value: true
  14290. });
  14291. exports.PDFDataTransportStream = void 0;
  14292. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(148));
  14293. var _util = __w_pdfjs_require__(1);
  14294. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14295. 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); } }
  14296. 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); }); }; }
  14297. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14298. 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); } }
  14299. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14300. var PDFDataTransportStream =
  14301. /*#__PURE__*/
  14302. function () {
  14303. function PDFDataTransportStream(params, pdfDataRangeTransport) {
  14304. var _this = this;
  14305. _classCallCheck(this, PDFDataTransportStream);
  14306. (0, _util.assert)(pdfDataRangeTransport);
  14307. this._queuedChunks = [];
  14308. this._progressiveDone = params.progressiveDone || false;
  14309. var initialData = params.initialData;
  14310. if (initialData && initialData.length > 0) {
  14311. var buffer = new Uint8Array(initialData).buffer;
  14312. this._queuedChunks.push(buffer);
  14313. }
  14314. this._pdfDataRangeTransport = pdfDataRangeTransport;
  14315. this._isStreamingSupported = !params.disableStream;
  14316. this._isRangeSupported = !params.disableRange;
  14317. this._contentLength = params.length;
  14318. this._fullRequestReader = null;
  14319. this._rangeReaders = [];
  14320. this._pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  14321. _this._onReceiveData({
  14322. begin: begin,
  14323. chunk: chunk
  14324. });
  14325. });
  14326. this._pdfDataRangeTransport.addProgressListener(function (loaded, total) {
  14327. _this._onProgress({
  14328. loaded: loaded,
  14329. total: total
  14330. });
  14331. });
  14332. this._pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  14333. _this._onReceiveData({
  14334. chunk: chunk
  14335. });
  14336. });
  14337. this._pdfDataRangeTransport.addProgressiveDoneListener(function () {
  14338. _this._onProgressiveDone();
  14339. });
  14340. this._pdfDataRangeTransport.transportReady();
  14341. }
  14342. _createClass(PDFDataTransportStream, [{
  14343. key: "_onReceiveData",
  14344. value: function _onReceiveData(args) {
  14345. var buffer = new Uint8Array(args.chunk).buffer;
  14346. if (args.begin === undefined) {
  14347. if (this._fullRequestReader) {
  14348. this._fullRequestReader._enqueue(buffer);
  14349. } else {
  14350. this._queuedChunks.push(buffer);
  14351. }
  14352. } else {
  14353. var found = this._rangeReaders.some(function (rangeReader) {
  14354. if (rangeReader._begin !== args.begin) {
  14355. return false;
  14356. }
  14357. rangeReader._enqueue(buffer);
  14358. return true;
  14359. });
  14360. (0, _util.assert)(found);
  14361. }
  14362. }
  14363. }, {
  14364. key: "_onProgress",
  14365. value: function _onProgress(evt) {
  14366. if (evt.total === undefined) {
  14367. var firstReader = this._rangeReaders[0];
  14368. if (firstReader && firstReader.onProgress) {
  14369. firstReader.onProgress({
  14370. loaded: evt.loaded
  14371. });
  14372. }
  14373. } else {
  14374. var fullReader = this._fullRequestReader;
  14375. if (fullReader && fullReader.onProgress) {
  14376. fullReader.onProgress({
  14377. loaded: evt.loaded,
  14378. total: evt.total
  14379. });
  14380. }
  14381. }
  14382. }
  14383. }, {
  14384. key: "_onProgressiveDone",
  14385. value: function _onProgressiveDone() {
  14386. if (this._fullRequestReader) {
  14387. this._fullRequestReader.progressiveDone();
  14388. }
  14389. this._progressiveDone = true;
  14390. }
  14391. }, {
  14392. key: "_removeRangeReader",
  14393. value: function _removeRangeReader(reader) {
  14394. var i = this._rangeReaders.indexOf(reader);
  14395. if (i >= 0) {
  14396. this._rangeReaders.splice(i, 1);
  14397. }
  14398. }
  14399. }, {
  14400. key: "getFullReader",
  14401. value: function getFullReader() {
  14402. (0, _util.assert)(!this._fullRequestReader);
  14403. var queuedChunks = this._queuedChunks;
  14404. this._queuedChunks = null;
  14405. return new PDFDataTransportStreamReader(this, queuedChunks, this._progressiveDone);
  14406. }
  14407. }, {
  14408. key: "getRangeReader",
  14409. value: function getRangeReader(begin, end) {
  14410. if (end <= this._progressiveDataLength) {
  14411. return null;
  14412. }
  14413. var reader = new PDFDataTransportStreamRangeReader(this, begin, end);
  14414. this._pdfDataRangeTransport.requestDataRange(begin, end);
  14415. this._rangeReaders.push(reader);
  14416. return reader;
  14417. }
  14418. }, {
  14419. key: "cancelAllRequests",
  14420. value: function cancelAllRequests(reason) {
  14421. if (this._fullRequestReader) {
  14422. this._fullRequestReader.cancel(reason);
  14423. }
  14424. var readers = this._rangeReaders.slice(0);
  14425. readers.forEach(function (rangeReader) {
  14426. rangeReader.cancel(reason);
  14427. });
  14428. this._pdfDataRangeTransport.abort();
  14429. }
  14430. }, {
  14431. key: "_progressiveDataLength",
  14432. get: function get() {
  14433. return this._fullRequestReader ? this._fullRequestReader._loaded : 0;
  14434. }
  14435. }]);
  14436. return PDFDataTransportStream;
  14437. }();
  14438. exports.PDFDataTransportStream = PDFDataTransportStream;
  14439. var PDFDataTransportStreamReader =
  14440. /*#__PURE__*/
  14441. function () {
  14442. function PDFDataTransportStreamReader(stream, queuedChunks) {
  14443. var progressiveDone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  14444. _classCallCheck(this, PDFDataTransportStreamReader);
  14445. this._stream = stream;
  14446. this._done = progressiveDone || false;
  14447. this._filename = null;
  14448. this._queuedChunks = queuedChunks || [];
  14449. this._loaded = 0;
  14450. var _iteratorNormalCompletion = true;
  14451. var _didIteratorError = false;
  14452. var _iteratorError = undefined;
  14453. try {
  14454. for (var _iterator = this._queuedChunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  14455. var chunk = _step.value;
  14456. this._loaded += chunk.byteLength;
  14457. }
  14458. } catch (err) {
  14459. _didIteratorError = true;
  14460. _iteratorError = err;
  14461. } finally {
  14462. try {
  14463. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  14464. _iterator["return"]();
  14465. }
  14466. } finally {
  14467. if (_didIteratorError) {
  14468. throw _iteratorError;
  14469. }
  14470. }
  14471. }
  14472. this._requests = [];
  14473. this._headersReady = Promise.resolve();
  14474. stream._fullRequestReader = this;
  14475. this.onProgress = null;
  14476. }
  14477. _createClass(PDFDataTransportStreamReader, [{
  14478. key: "_enqueue",
  14479. value: function _enqueue(chunk) {
  14480. if (this._done) {
  14481. return;
  14482. }
  14483. if (this._requests.length > 0) {
  14484. var requestCapability = this._requests.shift();
  14485. requestCapability.resolve({
  14486. value: chunk,
  14487. done: false
  14488. });
  14489. } else {
  14490. this._queuedChunks.push(chunk);
  14491. }
  14492. this._loaded += chunk.byteLength;
  14493. }
  14494. }, {
  14495. key: "read",
  14496. value: function () {
  14497. var _read = _asyncToGenerator(
  14498. /*#__PURE__*/
  14499. _regenerator["default"].mark(function _callee() {
  14500. var chunk, requestCapability;
  14501. return _regenerator["default"].wrap(function _callee$(_context) {
  14502. while (1) {
  14503. switch (_context.prev = _context.next) {
  14504. case 0:
  14505. if (!(this._queuedChunks.length > 0)) {
  14506. _context.next = 3;
  14507. break;
  14508. }
  14509. chunk = this._queuedChunks.shift();
  14510. return _context.abrupt("return", {
  14511. value: chunk,
  14512. done: false
  14513. });
  14514. case 3:
  14515. if (!this._done) {
  14516. _context.next = 5;
  14517. break;
  14518. }
  14519. return _context.abrupt("return", {
  14520. value: undefined,
  14521. done: true
  14522. });
  14523. case 5:
  14524. requestCapability = (0, _util.createPromiseCapability)();
  14525. this._requests.push(requestCapability);
  14526. return _context.abrupt("return", requestCapability.promise);
  14527. case 8:
  14528. case "end":
  14529. return _context.stop();
  14530. }
  14531. }
  14532. }, _callee, this);
  14533. }));
  14534. function read() {
  14535. return _read.apply(this, arguments);
  14536. }
  14537. return read;
  14538. }()
  14539. }, {
  14540. key: "cancel",
  14541. value: function cancel(reason) {
  14542. this._done = true;
  14543. this._requests.forEach(function (requestCapability) {
  14544. requestCapability.resolve({
  14545. value: undefined,
  14546. done: true
  14547. });
  14548. });
  14549. this._requests = [];
  14550. }
  14551. }, {
  14552. key: "progressiveDone",
  14553. value: function progressiveDone() {
  14554. if (this._done) {
  14555. return;
  14556. }
  14557. this._done = true;
  14558. }
  14559. }, {
  14560. key: "headersReady",
  14561. get: function get() {
  14562. return this._headersReady;
  14563. }
  14564. }, {
  14565. key: "filename",
  14566. get: function get() {
  14567. return this._filename;
  14568. }
  14569. }, {
  14570. key: "isRangeSupported",
  14571. get: function get() {
  14572. return this._stream._isRangeSupported;
  14573. }
  14574. }, {
  14575. key: "isStreamingSupported",
  14576. get: function get() {
  14577. return this._stream._isStreamingSupported;
  14578. }
  14579. }, {
  14580. key: "contentLength",
  14581. get: function get() {
  14582. return this._stream._contentLength;
  14583. }
  14584. }]);
  14585. return PDFDataTransportStreamReader;
  14586. }();
  14587. var PDFDataTransportStreamRangeReader =
  14588. /*#__PURE__*/
  14589. function () {
  14590. function PDFDataTransportStreamRangeReader(stream, begin, end) {
  14591. _classCallCheck(this, PDFDataTransportStreamRangeReader);
  14592. this._stream = stream;
  14593. this._begin = begin;
  14594. this._end = end;
  14595. this._queuedChunk = null;
  14596. this._requests = [];
  14597. this._done = false;
  14598. this.onProgress = null;
  14599. }
  14600. _createClass(PDFDataTransportStreamRangeReader, [{
  14601. key: "_enqueue",
  14602. value: function _enqueue(chunk) {
  14603. if (this._done) {
  14604. return;
  14605. }
  14606. if (this._requests.length === 0) {
  14607. this._queuedChunk = chunk;
  14608. } else {
  14609. var requestsCapability = this._requests.shift();
  14610. requestsCapability.resolve({
  14611. value: chunk,
  14612. done: false
  14613. });
  14614. this._requests.forEach(function (requestCapability) {
  14615. requestCapability.resolve({
  14616. value: undefined,
  14617. done: true
  14618. });
  14619. });
  14620. this._requests = [];
  14621. }
  14622. this._done = true;
  14623. this._stream._removeRangeReader(this);
  14624. }
  14625. }, {
  14626. key: "read",
  14627. value: function () {
  14628. var _read2 = _asyncToGenerator(
  14629. /*#__PURE__*/
  14630. _regenerator["default"].mark(function _callee2() {
  14631. var chunk, requestCapability;
  14632. return _regenerator["default"].wrap(function _callee2$(_context2) {
  14633. while (1) {
  14634. switch (_context2.prev = _context2.next) {
  14635. case 0:
  14636. if (!this._queuedChunk) {
  14637. _context2.next = 4;
  14638. break;
  14639. }
  14640. chunk = this._queuedChunk;
  14641. this._queuedChunk = null;
  14642. return _context2.abrupt("return", {
  14643. value: chunk,
  14644. done: false
  14645. });
  14646. case 4:
  14647. if (!this._done) {
  14648. _context2.next = 6;
  14649. break;
  14650. }
  14651. return _context2.abrupt("return", {
  14652. value: undefined,
  14653. done: true
  14654. });
  14655. case 6:
  14656. requestCapability = (0, _util.createPromiseCapability)();
  14657. this._requests.push(requestCapability);
  14658. return _context2.abrupt("return", requestCapability.promise);
  14659. case 9:
  14660. case "end":
  14661. return _context2.stop();
  14662. }
  14663. }
  14664. }, _callee2, this);
  14665. }));
  14666. function read() {
  14667. return _read2.apply(this, arguments);
  14668. }
  14669. return read;
  14670. }()
  14671. }, {
  14672. key: "cancel",
  14673. value: function cancel(reason) {
  14674. this._done = true;
  14675. this._requests.forEach(function (requestCapability) {
  14676. requestCapability.resolve({
  14677. value: undefined,
  14678. done: true
  14679. });
  14680. });
  14681. this._requests = [];
  14682. this._stream._removeRangeReader(this);
  14683. }
  14684. }, {
  14685. key: "isStreamingSupported",
  14686. get: function get() {
  14687. return false;
  14688. }
  14689. }]);
  14690. return PDFDataTransportStreamRangeReader;
  14691. }();
  14692. /***/ }),
  14693. /* 161 */
  14694. /***/ (function(module, exports, __w_pdfjs_require__) {
  14695. "use strict";
  14696. Object.defineProperty(exports, "__esModule", {
  14697. value: true
  14698. });
  14699. exports.WebGLContext = void 0;
  14700. var _util = __w_pdfjs_require__(1);
  14701. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14702. 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); } }
  14703. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14704. var WebGLContext =
  14705. /*#__PURE__*/
  14706. function () {
  14707. function WebGLContext(_ref) {
  14708. var _ref$enable = _ref.enable,
  14709. enable = _ref$enable === void 0 ? false : _ref$enable;
  14710. _classCallCheck(this, WebGLContext);
  14711. this._enabled = enable === true;
  14712. }
  14713. _createClass(WebGLContext, [{
  14714. key: "composeSMask",
  14715. value: function composeSMask(_ref2) {
  14716. var layer = _ref2.layer,
  14717. mask = _ref2.mask,
  14718. properties = _ref2.properties;
  14719. return WebGLUtils.composeSMask(layer, mask, properties);
  14720. }
  14721. }, {
  14722. key: "drawFigures",
  14723. value: function drawFigures(_ref3) {
  14724. var width = _ref3.width,
  14725. height = _ref3.height,
  14726. backgroundColor = _ref3.backgroundColor,
  14727. figures = _ref3.figures,
  14728. context = _ref3.context;
  14729. return WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  14730. }
  14731. }, {
  14732. key: "clear",
  14733. value: function clear() {
  14734. WebGLUtils.cleanup();
  14735. }
  14736. }, {
  14737. key: "isEnabled",
  14738. get: function get() {
  14739. var enabled = this._enabled;
  14740. if (enabled) {
  14741. enabled = WebGLUtils.tryInitGL();
  14742. }
  14743. return (0, _util.shadow)(this, 'isEnabled', enabled);
  14744. }
  14745. }]);
  14746. return WebGLContext;
  14747. }();
  14748. exports.WebGLContext = WebGLContext;
  14749. var WebGLUtils = function WebGLUtilsClosure() {
  14750. function loadShader(gl, code, shaderType) {
  14751. var shader = gl.createShader(shaderType);
  14752. gl.shaderSource(shader, code);
  14753. gl.compileShader(shader);
  14754. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  14755. if (!compiled) {
  14756. var errorMsg = gl.getShaderInfoLog(shader);
  14757. throw new Error('Error during shader compilation: ' + errorMsg);
  14758. }
  14759. return shader;
  14760. }
  14761. function createVertexShader(gl, code) {
  14762. return loadShader(gl, code, gl.VERTEX_SHADER);
  14763. }
  14764. function createFragmentShader(gl, code) {
  14765. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  14766. }
  14767. function createProgram(gl, shaders) {
  14768. var program = gl.createProgram();
  14769. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  14770. gl.attachShader(program, shaders[i]);
  14771. }
  14772. gl.linkProgram(program);
  14773. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  14774. if (!linked) {
  14775. var errorMsg = gl.getProgramInfoLog(program);
  14776. throw new Error('Error during program linking: ' + errorMsg);
  14777. }
  14778. return program;
  14779. }
  14780. function createTexture(gl, image, textureId) {
  14781. gl.activeTexture(textureId);
  14782. var texture = gl.createTexture();
  14783. gl.bindTexture(gl.TEXTURE_2D, texture);
  14784. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  14785. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  14786. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  14787. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  14788. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  14789. return texture;
  14790. }
  14791. var currentGL, currentCanvas;
  14792. function generateGL() {
  14793. if (currentGL) {
  14794. return;
  14795. }
  14796. currentCanvas = document.createElement('canvas');
  14797. currentGL = currentCanvas.getContext('webgl', {
  14798. premultipliedalpha: false
  14799. });
  14800. }
  14801. var smaskVertexShaderCode = '\
  14802. attribute vec2 a_position; \
  14803. attribute vec2 a_texCoord; \
  14804. \
  14805. uniform vec2 u_resolution; \
  14806. \
  14807. varying vec2 v_texCoord; \
  14808. \
  14809. void main() { \
  14810. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  14811. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  14812. \
  14813. v_texCoord = a_texCoord; \
  14814. } ';
  14815. var smaskFragmentShaderCode = '\
  14816. precision mediump float; \
  14817. \
  14818. uniform vec4 u_backdrop; \
  14819. uniform int u_subtype; \
  14820. uniform sampler2D u_image; \
  14821. uniform sampler2D u_mask; \
  14822. \
  14823. varying vec2 v_texCoord; \
  14824. \
  14825. void main() { \
  14826. vec4 imageColor = texture2D(u_image, v_texCoord); \
  14827. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  14828. if (u_backdrop.a > 0.0) { \
  14829. maskColor.rgb = maskColor.rgb * maskColor.a + \
  14830. u_backdrop.rgb * (1.0 - maskColor.a); \
  14831. } \
  14832. float lum; \
  14833. if (u_subtype == 0) { \
  14834. lum = maskColor.a; \
  14835. } else { \
  14836. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  14837. maskColor.b * 0.11; \
  14838. } \
  14839. imageColor.a *= lum; \
  14840. imageColor.rgb *= imageColor.a; \
  14841. gl_FragColor = imageColor; \
  14842. } ';
  14843. var smaskCache = null;
  14844. function initSmaskGL() {
  14845. var canvas, gl;
  14846. generateGL();
  14847. canvas = currentCanvas;
  14848. currentCanvas = null;
  14849. gl = currentGL;
  14850. currentGL = null;
  14851. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  14852. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  14853. var program = createProgram(gl, [vertexShader, fragmentShader]);
  14854. gl.useProgram(program);
  14855. var cache = {};
  14856. cache.gl = gl;
  14857. cache.canvas = canvas;
  14858. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  14859. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  14860. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  14861. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  14862. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  14863. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  14864. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  14865. var texCoordBuffer = gl.createBuffer();
  14866. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  14867. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0]), gl.STATIC_DRAW);
  14868. gl.enableVertexAttribArray(texCoordLocation);
  14869. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  14870. gl.uniform1i(texLayerLocation, 0);
  14871. gl.uniform1i(texMaskLocation, 1);
  14872. smaskCache = cache;
  14873. }
  14874. function composeSMask(layer, mask, properties) {
  14875. var width = layer.width,
  14876. height = layer.height;
  14877. if (!smaskCache) {
  14878. initSmaskGL();
  14879. }
  14880. var cache = smaskCache,
  14881. canvas = cache.canvas,
  14882. gl = cache.gl;
  14883. canvas.width = width;
  14884. canvas.height = height;
  14885. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  14886. gl.uniform2f(cache.resolutionLocation, width, height);
  14887. if (properties.backdrop) {
  14888. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  14889. } else {
  14890. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  14891. }
  14892. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  14893. var texture = createTexture(gl, layer, gl.TEXTURE0);
  14894. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  14895. var buffer = gl.createBuffer();
  14896. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  14897. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, width, 0, 0, height, 0, height, width, 0, width, height]), gl.STATIC_DRAW);
  14898. gl.enableVertexAttribArray(cache.positionLocation);
  14899. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  14900. gl.clearColor(0, 0, 0, 0);
  14901. gl.enable(gl.BLEND);
  14902. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  14903. gl.clear(gl.COLOR_BUFFER_BIT);
  14904. gl.drawArrays(gl.TRIANGLES, 0, 6);
  14905. gl.flush();
  14906. gl.deleteTexture(texture);
  14907. gl.deleteTexture(maskTexture);
  14908. gl.deleteBuffer(buffer);
  14909. return canvas;
  14910. }
  14911. var figuresVertexShaderCode = '\
  14912. attribute vec2 a_position; \
  14913. attribute vec3 a_color; \
  14914. \
  14915. uniform vec2 u_resolution; \
  14916. uniform vec2 u_scale; \
  14917. uniform vec2 u_offset; \
  14918. \
  14919. varying vec4 v_color; \
  14920. \
  14921. void main() { \
  14922. vec2 position = (a_position + u_offset) * u_scale; \
  14923. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  14924. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  14925. \
  14926. v_color = vec4(a_color / 255.0, 1.0); \
  14927. } ';
  14928. var figuresFragmentShaderCode = '\
  14929. precision mediump float; \
  14930. \
  14931. varying vec4 v_color; \
  14932. \
  14933. void main() { \
  14934. gl_FragColor = v_color; \
  14935. } ';
  14936. var figuresCache = null;
  14937. function initFiguresGL() {
  14938. var canvas, gl;
  14939. generateGL();
  14940. canvas = currentCanvas;
  14941. currentCanvas = null;
  14942. gl = currentGL;
  14943. currentGL = null;
  14944. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  14945. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  14946. var program = createProgram(gl, [vertexShader, fragmentShader]);
  14947. gl.useProgram(program);
  14948. var cache = {};
  14949. cache.gl = gl;
  14950. cache.canvas = canvas;
  14951. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  14952. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  14953. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  14954. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  14955. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  14956. figuresCache = cache;
  14957. }
  14958. function drawFigures(width, height, backgroundColor, figures, context) {
  14959. if (!figuresCache) {
  14960. initFiguresGL();
  14961. }
  14962. var cache = figuresCache,
  14963. canvas = cache.canvas,
  14964. gl = cache.gl;
  14965. canvas.width = width;
  14966. canvas.height = height;
  14967. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  14968. gl.uniform2f(cache.resolutionLocation, width, height);
  14969. var count = 0;
  14970. var i, ii, rows;
  14971. for (i = 0, ii = figures.length; i < ii; i++) {
  14972. switch (figures[i].type) {
  14973. case 'lattice':
  14974. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  14975. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  14976. break;
  14977. case 'triangles':
  14978. count += figures[i].coords.length;
  14979. break;
  14980. }
  14981. }
  14982. var coords = new Float32Array(count * 2);
  14983. var colors = new Uint8Array(count * 3);
  14984. var coordsMap = context.coords,
  14985. colorsMap = context.colors;
  14986. var pIndex = 0,
  14987. cIndex = 0;
  14988. for (i = 0, ii = figures.length; i < ii; i++) {
  14989. var figure = figures[i],
  14990. ps = figure.coords,
  14991. cs = figure.colors;
  14992. switch (figure.type) {
  14993. case 'lattice':
  14994. var cols = figure.verticesPerRow;
  14995. rows = ps.length / cols | 0;
  14996. for (var row = 1; row < rows; row++) {
  14997. var offset = row * cols + 1;
  14998. for (var col = 1; col < cols; col++, offset++) {
  14999. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  15000. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  15001. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  15002. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  15003. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  15004. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  15005. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  15006. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  15007. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  15008. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  15009. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  15010. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  15011. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  15012. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  15013. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  15014. coords[pIndex + 6] = coords[pIndex + 2];
  15015. coords[pIndex + 7] = coords[pIndex + 3];
  15016. coords[pIndex + 8] = coords[pIndex + 4];
  15017. coords[pIndex + 9] = coords[pIndex + 5];
  15018. coords[pIndex + 10] = coordsMap[ps[offset]];
  15019. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  15020. colors[cIndex + 9] = colors[cIndex + 3];
  15021. colors[cIndex + 10] = colors[cIndex + 4];
  15022. colors[cIndex + 11] = colors[cIndex + 5];
  15023. colors[cIndex + 12] = colors[cIndex + 6];
  15024. colors[cIndex + 13] = colors[cIndex + 7];
  15025. colors[cIndex + 14] = colors[cIndex + 8];
  15026. colors[cIndex + 15] = colorsMap[cs[offset]];
  15027. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  15028. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  15029. pIndex += 12;
  15030. cIndex += 18;
  15031. }
  15032. }
  15033. break;
  15034. case 'triangles':
  15035. for (var j = 0, jj = ps.length; j < jj; j++) {
  15036. coords[pIndex] = coordsMap[ps[j]];
  15037. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  15038. colors[cIndex] = colorsMap[cs[j]];
  15039. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  15040. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  15041. pIndex += 2;
  15042. cIndex += 3;
  15043. }
  15044. break;
  15045. }
  15046. }
  15047. if (backgroundColor) {
  15048. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  15049. } else {
  15050. gl.clearColor(0, 0, 0, 0);
  15051. }
  15052. gl.clear(gl.COLOR_BUFFER_BIT);
  15053. var coordsBuffer = gl.createBuffer();
  15054. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  15055. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  15056. gl.enableVertexAttribArray(cache.positionLocation);
  15057. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  15058. var colorsBuffer = gl.createBuffer();
  15059. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  15060. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  15061. gl.enableVertexAttribArray(cache.colorLocation);
  15062. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  15063. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  15064. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  15065. gl.drawArrays(gl.TRIANGLES, 0, count);
  15066. gl.flush();
  15067. gl.deleteBuffer(coordsBuffer);
  15068. gl.deleteBuffer(colorsBuffer);
  15069. return canvas;
  15070. }
  15071. return {
  15072. tryInitGL: function tryInitGL() {
  15073. try {
  15074. generateGL();
  15075. return !!currentGL;
  15076. } catch (ex) {}
  15077. return false;
  15078. },
  15079. composeSMask: composeSMask,
  15080. drawFigures: drawFigures,
  15081. cleanup: function cleanup() {
  15082. if (smaskCache && smaskCache.canvas) {
  15083. smaskCache.canvas.width = 0;
  15084. smaskCache.canvas.height = 0;
  15085. }
  15086. if (figuresCache && figuresCache.canvas) {
  15087. figuresCache.canvas.width = 0;
  15088. figuresCache.canvas.height = 0;
  15089. }
  15090. smaskCache = null;
  15091. figuresCache = null;
  15092. }
  15093. };
  15094. }();
  15095. /***/ }),
  15096. /* 162 */
  15097. /***/ (function(module, exports, __w_pdfjs_require__) {
  15098. "use strict";
  15099. Object.defineProperty(exports, "__esModule", {
  15100. value: true
  15101. });
  15102. exports.renderTextLayer = void 0;
  15103. var _util = __w_pdfjs_require__(1);
  15104. var _global_scope = _interopRequireDefault(__w_pdfjs_require__(3));
  15105. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15106. var renderTextLayer = function renderTextLayerClosure() {
  15107. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  15108. var NonWhitespaceRegexp = /\S/;
  15109. function isAllWhitespace(str) {
  15110. return !NonWhitespaceRegexp.test(str);
  15111. }
  15112. var styleBuf = ['left: ', 0, 'px; top: ', 0, 'px; font-size: ', 0, 'px; font-family: ', '', ';'];
  15113. function appendText(task, geom, styles) {
  15114. var textDiv = document.createElement('span');
  15115. var textDivProperties = {
  15116. style: null,
  15117. angle: 0,
  15118. canvasWidth: 0,
  15119. isWhitespace: false,
  15120. originalTransform: null,
  15121. paddingBottom: 0,
  15122. paddingLeft: 0,
  15123. paddingRight: 0,
  15124. paddingTop: 0,
  15125. scale: 1
  15126. };
  15127. task._textDivs.push(textDiv);
  15128. if (isAllWhitespace(geom.str)) {
  15129. textDivProperties.isWhitespace = true;
  15130. task._textDivProperties.set(textDiv, textDivProperties);
  15131. return;
  15132. }
  15133. var tx = _util.Util.transform(task._viewport.transform, geom.transform);
  15134. var angle = Math.atan2(tx[1], tx[0]);
  15135. var style = styles[geom.fontName];
  15136. if (style.vertical) {
  15137. angle += Math.PI / 2;
  15138. }
  15139. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  15140. var fontAscent = fontHeight;
  15141. if (style.ascent) {
  15142. fontAscent = style.ascent * fontAscent;
  15143. } else if (style.descent) {
  15144. fontAscent = (1 + style.descent) * fontAscent;
  15145. }
  15146. var left;
  15147. var top;
  15148. if (angle === 0) {
  15149. left = tx[4];
  15150. top = tx[5] - fontAscent;
  15151. } else {
  15152. left = tx[4] + fontAscent * Math.sin(angle);
  15153. top = tx[5] - fontAscent * Math.cos(angle);
  15154. }
  15155. styleBuf[1] = left;
  15156. styleBuf[3] = top;
  15157. styleBuf[5] = fontHeight;
  15158. styleBuf[7] = style.fontFamily;
  15159. textDivProperties.style = styleBuf.join('');
  15160. textDiv.setAttribute('style', textDivProperties.style);
  15161. textDiv.textContent = geom.str;
  15162. if (task._fontInspectorEnabled) {
  15163. textDiv.dataset.fontName = geom.fontName;
  15164. }
  15165. if (angle !== 0) {
  15166. textDivProperties.angle = angle * (180 / Math.PI);
  15167. }
  15168. if (geom.str.length > 1) {
  15169. if (style.vertical) {
  15170. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  15171. } else {
  15172. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  15173. }
  15174. }
  15175. task._textDivProperties.set(textDiv, textDivProperties);
  15176. if (task._textContentStream) {
  15177. task._layoutText(textDiv);
  15178. }
  15179. if (task._enhanceTextSelection) {
  15180. var angleCos = 1,
  15181. angleSin = 0;
  15182. if (angle !== 0) {
  15183. angleCos = Math.cos(angle);
  15184. angleSin = Math.sin(angle);
  15185. }
  15186. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  15187. var divHeight = fontHeight;
  15188. var m, b;
  15189. if (angle !== 0) {
  15190. m = [angleCos, angleSin, -angleSin, angleCos, left, top];
  15191. b = _util.Util.getAxialAlignedBoundingBox([0, 0, divWidth, divHeight], m);
  15192. } else {
  15193. b = [left, top, left + divWidth, top + divHeight];
  15194. }
  15195. task._bounds.push({
  15196. left: b[0],
  15197. top: b[1],
  15198. right: b[2],
  15199. bottom: b[3],
  15200. div: textDiv,
  15201. size: [divWidth, divHeight],
  15202. m: m
  15203. });
  15204. }
  15205. }
  15206. function render(task) {
  15207. if (task._canceled) {
  15208. return;
  15209. }
  15210. var textDivs = task._textDivs;
  15211. var capability = task._capability;
  15212. var textDivsLength = textDivs.length;
  15213. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  15214. task._renderingDone = true;
  15215. capability.resolve();
  15216. return;
  15217. }
  15218. if (!task._textContentStream) {
  15219. for (var i = 0; i < textDivsLength; i++) {
  15220. task._layoutText(textDivs[i]);
  15221. }
  15222. }
  15223. task._renderingDone = true;
  15224. capability.resolve();
  15225. }
  15226. function expand(task) {
  15227. var bounds = task._bounds;
  15228. var viewport = task._viewport;
  15229. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  15230. for (var i = 0; i < expanded.length; i++) {
  15231. var div = bounds[i].div;
  15232. var divProperties = task._textDivProperties.get(div);
  15233. if (divProperties.angle === 0) {
  15234. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  15235. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  15236. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  15237. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  15238. task._textDivProperties.set(div, divProperties);
  15239. continue;
  15240. }
  15241. var e = expanded[i],
  15242. b = bounds[i];
  15243. var m = b.m,
  15244. c = m[0],
  15245. s = m[1];
  15246. var points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size];
  15247. var ts = new Float64Array(64);
  15248. points.forEach(function (p, i) {
  15249. var t = _util.Util.applyTransform(p, m);
  15250. ts[i + 0] = c && (e.left - t[0]) / c;
  15251. ts[i + 4] = s && (e.top - t[1]) / s;
  15252. ts[i + 8] = c && (e.right - t[0]) / c;
  15253. ts[i + 12] = s && (e.bottom - t[1]) / s;
  15254. ts[i + 16] = s && (e.left - t[0]) / -s;
  15255. ts[i + 20] = c && (e.top - t[1]) / c;
  15256. ts[i + 24] = s && (e.right - t[0]) / -s;
  15257. ts[i + 28] = c && (e.bottom - t[1]) / c;
  15258. ts[i + 32] = c && (e.left - t[0]) / -c;
  15259. ts[i + 36] = s && (e.top - t[1]) / -s;
  15260. ts[i + 40] = c && (e.right - t[0]) / -c;
  15261. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  15262. ts[i + 48] = s && (e.left - t[0]) / s;
  15263. ts[i + 52] = c && (e.top - t[1]) / -c;
  15264. ts[i + 56] = s && (e.right - t[0]) / s;
  15265. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  15266. });
  15267. var findPositiveMin = function findPositiveMin(ts, offset, count) {
  15268. var result = 0;
  15269. for (var i = 0; i < count; i++) {
  15270. var t = ts[offset++];
  15271. if (t > 0) {
  15272. result = result ? Math.min(t, result) : t;
  15273. }
  15274. }
  15275. return result;
  15276. };
  15277. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  15278. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  15279. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  15280. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  15281. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  15282. task._textDivProperties.set(div, divProperties);
  15283. }
  15284. }
  15285. function expandBounds(width, height, boxes) {
  15286. var bounds = boxes.map(function (box, i) {
  15287. return {
  15288. x1: box.left,
  15289. y1: box.top,
  15290. x2: box.right,
  15291. y2: box.bottom,
  15292. index: i,
  15293. x1New: undefined,
  15294. x2New: undefined
  15295. };
  15296. });
  15297. expandBoundsLTR(width, bounds);
  15298. var expanded = new Array(boxes.length);
  15299. bounds.forEach(function (b) {
  15300. var i = b.index;
  15301. expanded[i] = {
  15302. left: b.x1New,
  15303. top: 0,
  15304. right: b.x2New,
  15305. bottom: 0
  15306. };
  15307. });
  15308. boxes.map(function (box, i) {
  15309. var e = expanded[i],
  15310. b = bounds[i];
  15311. b.x1 = box.top;
  15312. b.y1 = width - e.right;
  15313. b.x2 = box.bottom;
  15314. b.y2 = width - e.left;
  15315. b.index = i;
  15316. b.x1New = undefined;
  15317. b.x2New = undefined;
  15318. });
  15319. expandBoundsLTR(height, bounds);
  15320. bounds.forEach(function (b) {
  15321. var i = b.index;
  15322. expanded[i].top = b.x1New;
  15323. expanded[i].bottom = b.x2New;
  15324. });
  15325. return expanded;
  15326. }
  15327. function expandBoundsLTR(width, bounds) {
  15328. bounds.sort(function (a, b) {
  15329. return a.x1 - b.x1 || a.index - b.index;
  15330. });
  15331. var fakeBoundary = {
  15332. x1: -Infinity,
  15333. y1: -Infinity,
  15334. x2: 0,
  15335. y2: Infinity,
  15336. index: -1,
  15337. x1New: 0,
  15338. x2New: 0
  15339. };
  15340. var horizon = [{
  15341. start: -Infinity,
  15342. end: Infinity,
  15343. boundary: fakeBoundary
  15344. }];
  15345. bounds.forEach(function (boundary) {
  15346. var i = 0;
  15347. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  15348. i++;
  15349. }
  15350. var j = horizon.length - 1;
  15351. while (j >= 0 && horizon[j].start >= boundary.y2) {
  15352. j--;
  15353. }
  15354. var horizonPart, affectedBoundary;
  15355. var q,
  15356. k,
  15357. maxXNew = -Infinity;
  15358. for (q = i; q <= j; q++) {
  15359. horizonPart = horizon[q];
  15360. affectedBoundary = horizonPart.boundary;
  15361. var xNew;
  15362. if (affectedBoundary.x2 > boundary.x1) {
  15363. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  15364. } else if (affectedBoundary.x2New === undefined) {
  15365. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  15366. } else {
  15367. xNew = affectedBoundary.x2New;
  15368. }
  15369. if (xNew > maxXNew) {
  15370. maxXNew = xNew;
  15371. }
  15372. }
  15373. boundary.x1New = maxXNew;
  15374. for (q = i; q <= j; q++) {
  15375. horizonPart = horizon[q];
  15376. affectedBoundary = horizonPart.boundary;
  15377. if (affectedBoundary.x2New === undefined) {
  15378. if (affectedBoundary.x2 > boundary.x1) {
  15379. if (affectedBoundary.index > boundary.index) {
  15380. affectedBoundary.x2New = affectedBoundary.x2;
  15381. }
  15382. } else {
  15383. affectedBoundary.x2New = maxXNew;
  15384. }
  15385. } else if (affectedBoundary.x2New > maxXNew) {
  15386. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  15387. }
  15388. }
  15389. var changedHorizon = [],
  15390. lastBoundary = null;
  15391. for (q = i; q <= j; q++) {
  15392. horizonPart = horizon[q];
  15393. affectedBoundary = horizonPart.boundary;
  15394. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  15395. if (lastBoundary === useBoundary) {
  15396. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  15397. } else {
  15398. changedHorizon.push({
  15399. start: horizonPart.start,
  15400. end: horizonPart.end,
  15401. boundary: useBoundary
  15402. });
  15403. lastBoundary = useBoundary;
  15404. }
  15405. }
  15406. if (horizon[i].start < boundary.y1) {
  15407. changedHorizon[0].start = boundary.y1;
  15408. changedHorizon.unshift({
  15409. start: horizon[i].start,
  15410. end: boundary.y1,
  15411. boundary: horizon[i].boundary
  15412. });
  15413. }
  15414. if (boundary.y2 < horizon[j].end) {
  15415. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  15416. changedHorizon.push({
  15417. start: boundary.y2,
  15418. end: horizon[j].end,
  15419. boundary: horizon[j].boundary
  15420. });
  15421. }
  15422. for (q = i; q <= j; q++) {
  15423. horizonPart = horizon[q];
  15424. affectedBoundary = horizonPart.boundary;
  15425. if (affectedBoundary.x2New !== undefined) {
  15426. continue;
  15427. }
  15428. var used = false;
  15429. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  15430. used = horizon[k].boundary === affectedBoundary;
  15431. }
  15432. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  15433. used = horizon[k].boundary === affectedBoundary;
  15434. }
  15435. for (k = 0; !used && k < changedHorizon.length; k++) {
  15436. used = changedHorizon[k].boundary === affectedBoundary;
  15437. }
  15438. if (!used) {
  15439. affectedBoundary.x2New = maxXNew;
  15440. }
  15441. }
  15442. Array.prototype.splice.apply(horizon, [i, j - i + 1].concat(changedHorizon));
  15443. });
  15444. horizon.forEach(function (horizonPart) {
  15445. var affectedBoundary = horizonPart.boundary;
  15446. if (affectedBoundary.x2New === undefined) {
  15447. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  15448. }
  15449. });
  15450. }
  15451. function TextLayerRenderTask(_ref) {
  15452. var _this = this;
  15453. var textContent = _ref.textContent,
  15454. textContentStream = _ref.textContentStream,
  15455. container = _ref.container,
  15456. viewport = _ref.viewport,
  15457. textDivs = _ref.textDivs,
  15458. textContentItemsStr = _ref.textContentItemsStr,
  15459. enhanceTextSelection = _ref.enhanceTextSelection;
  15460. this._textContent = textContent;
  15461. this._textContentStream = textContentStream;
  15462. this._container = container;
  15463. this._viewport = viewport;
  15464. this._textDivs = textDivs || [];
  15465. this._textContentItemsStr = textContentItemsStr || [];
  15466. this._enhanceTextSelection = !!enhanceTextSelection;
  15467. this._fontInspectorEnabled = !!(_global_scope["default"].FontInspector && _global_scope["default"].FontInspector.enabled);
  15468. this._reader = null;
  15469. this._layoutTextLastFontSize = null;
  15470. this._layoutTextLastFontFamily = null;
  15471. this._layoutTextCtx = null;
  15472. this._textDivProperties = new WeakMap();
  15473. this._renderingDone = false;
  15474. this._canceled = false;
  15475. this._capability = (0, _util.createPromiseCapability)();
  15476. this._renderTimer = null;
  15477. this._bounds = [];
  15478. this._capability.promise["finally"](function () {
  15479. if (_this._layoutTextCtx) {
  15480. _this._layoutTextCtx.canvas.width = 0;
  15481. _this._layoutTextCtx.canvas.height = 0;
  15482. _this._layoutTextCtx = null;
  15483. }
  15484. });
  15485. }
  15486. TextLayerRenderTask.prototype = {
  15487. get promise() {
  15488. return this._capability.promise;
  15489. },
  15490. cancel: function TextLayer_cancel() {
  15491. this._canceled = true;
  15492. if (this._reader) {
  15493. this._reader.cancel(new _util.AbortException('TextLayer task cancelled.'));
  15494. this._reader = null;
  15495. }
  15496. if (this._renderTimer !== null) {
  15497. clearTimeout(this._renderTimer);
  15498. this._renderTimer = null;
  15499. }
  15500. this._capability.reject(new Error('TextLayer task cancelled.'));
  15501. },
  15502. _processItems: function _processItems(items, styleCache) {
  15503. for (var i = 0, len = items.length; i < len; i++) {
  15504. this._textContentItemsStr.push(items[i].str);
  15505. appendText(this, items[i], styleCache);
  15506. }
  15507. },
  15508. _layoutText: function _layoutText(textDiv) {
  15509. var textLayerFrag = this._container;
  15510. var textDivProperties = this._textDivProperties.get(textDiv);
  15511. if (textDivProperties.isWhitespace) {
  15512. return;
  15513. }
  15514. var fontSize = textDiv.style.fontSize;
  15515. var fontFamily = textDiv.style.fontFamily;
  15516. if (fontSize !== this._layoutTextLastFontSize || fontFamily !== this._layoutTextLastFontFamily) {
  15517. this._layoutTextCtx.font = fontSize + ' ' + fontFamily;
  15518. this._layoutTextLastFontSize = fontSize;
  15519. this._layoutTextLastFontFamily = fontFamily;
  15520. }
  15521. var width = this._layoutTextCtx.measureText(textDiv.textContent).width;
  15522. var transform = '';
  15523. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  15524. textDivProperties.scale = textDivProperties.canvasWidth / width;
  15525. transform = "scaleX(".concat(textDivProperties.scale, ")");
  15526. }
  15527. if (textDivProperties.angle !== 0) {
  15528. transform = "rotate(".concat(textDivProperties.angle, "deg) ").concat(transform);
  15529. }
  15530. if (transform.length > 0) {
  15531. textDivProperties.originalTransform = transform;
  15532. textDiv.style.transform = transform;
  15533. }
  15534. this._textDivProperties.set(textDiv, textDivProperties);
  15535. textLayerFrag.appendChild(textDiv);
  15536. },
  15537. _render: function TextLayer_render(timeout) {
  15538. var _this2 = this;
  15539. var capability = (0, _util.createPromiseCapability)();
  15540. var styleCache = Object.create(null);
  15541. var canvas = document.createElement('canvas');
  15542. canvas.mozOpaque = true;
  15543. this._layoutTextCtx = canvas.getContext('2d', {
  15544. alpha: false
  15545. });
  15546. if (this._textContent) {
  15547. var textItems = this._textContent.items;
  15548. var textStyles = this._textContent.styles;
  15549. this._processItems(textItems, textStyles);
  15550. capability.resolve();
  15551. } else if (this._textContentStream) {
  15552. var pump = function pump() {
  15553. _this2._reader.read().then(function (_ref2) {
  15554. var value = _ref2.value,
  15555. done = _ref2.done;
  15556. if (done) {
  15557. capability.resolve();
  15558. return;
  15559. }
  15560. Object.assign(styleCache, value.styles);
  15561. _this2._processItems(value.items, styleCache);
  15562. pump();
  15563. }, capability.reject);
  15564. };
  15565. this._reader = this._textContentStream.getReader();
  15566. pump();
  15567. } else {
  15568. throw new Error('Neither "textContent" nor "textContentStream"' + ' parameters specified.');
  15569. }
  15570. capability.promise.then(function () {
  15571. styleCache = null;
  15572. if (!timeout) {
  15573. render(_this2);
  15574. } else {
  15575. _this2._renderTimer = setTimeout(function () {
  15576. render(_this2);
  15577. _this2._renderTimer = null;
  15578. }, timeout);
  15579. }
  15580. }, this._capability.reject);
  15581. },
  15582. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  15583. if (!this._enhanceTextSelection || !this._renderingDone) {
  15584. return;
  15585. }
  15586. if (this._bounds !== null) {
  15587. expand(this);
  15588. this._bounds = null;
  15589. }
  15590. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  15591. var div = this._textDivs[i];
  15592. var divProperties = this._textDivProperties.get(div);
  15593. if (divProperties.isWhitespace) {
  15594. continue;
  15595. }
  15596. if (expandDivs) {
  15597. var transform = '',
  15598. padding = '';
  15599. if (divProperties.scale !== 1) {
  15600. transform = 'scaleX(' + divProperties.scale + ')';
  15601. }
  15602. if (divProperties.angle !== 0) {
  15603. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  15604. }
  15605. if (divProperties.paddingLeft !== 0) {
  15606. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  15607. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  15608. }
  15609. if (divProperties.paddingTop !== 0) {
  15610. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  15611. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  15612. }
  15613. if (divProperties.paddingRight !== 0) {
  15614. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  15615. }
  15616. if (divProperties.paddingBottom !== 0) {
  15617. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  15618. }
  15619. if (padding !== '') {
  15620. div.setAttribute('style', divProperties.style + padding);
  15621. }
  15622. if (transform !== '') {
  15623. div.style.transform = transform;
  15624. }
  15625. } else {
  15626. div.style.padding = 0;
  15627. div.style.transform = divProperties.originalTransform || '';
  15628. }
  15629. }
  15630. }
  15631. };
  15632. function renderTextLayer(renderParameters) {
  15633. var task = new TextLayerRenderTask({
  15634. textContent: renderParameters.textContent,
  15635. textContentStream: renderParameters.textContentStream,
  15636. container: renderParameters.container,
  15637. viewport: renderParameters.viewport,
  15638. textDivs: renderParameters.textDivs,
  15639. textContentItemsStr: renderParameters.textContentItemsStr,
  15640. enhanceTextSelection: renderParameters.enhanceTextSelection
  15641. });
  15642. task._render(renderParameters.timeout);
  15643. return task;
  15644. }
  15645. return renderTextLayer;
  15646. }();
  15647. exports.renderTextLayer = renderTextLayer;
  15648. /***/ }),
  15649. /* 163 */
  15650. /***/ (function(module, exports, __w_pdfjs_require__) {
  15651. "use strict";
  15652. Object.defineProperty(exports, "__esModule", {
  15653. value: true
  15654. });
  15655. exports.AnnotationLayer = void 0;
  15656. var _display_utils = __w_pdfjs_require__(151);
  15657. var _util = __w_pdfjs_require__(1);
  15658. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  15659. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  15660. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  15661. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  15662. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  15663. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  15664. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  15665. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  15666. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15667. 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); } }
  15668. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15669. var AnnotationElementFactory =
  15670. /*#__PURE__*/
  15671. function () {
  15672. function AnnotationElementFactory() {
  15673. _classCallCheck(this, AnnotationElementFactory);
  15674. }
  15675. _createClass(AnnotationElementFactory, null, [{
  15676. key: "create",
  15677. value: function create(parameters) {
  15678. var subtype = parameters.data.annotationType;
  15679. switch (subtype) {
  15680. case _util.AnnotationType.LINK:
  15681. return new LinkAnnotationElement(parameters);
  15682. case _util.AnnotationType.TEXT:
  15683. return new TextAnnotationElement(parameters);
  15684. case _util.AnnotationType.WIDGET:
  15685. var fieldType = parameters.data.fieldType;
  15686. switch (fieldType) {
  15687. case 'Tx':
  15688. return new TextWidgetAnnotationElement(parameters);
  15689. case 'Btn':
  15690. if (parameters.data.radioButton) {
  15691. return new RadioButtonWidgetAnnotationElement(parameters);
  15692. } else if (parameters.data.checkBox) {
  15693. return new CheckboxWidgetAnnotationElement(parameters);
  15694. }
  15695. return new PushButtonWidgetAnnotationElement(parameters);
  15696. case 'Ch':
  15697. return new ChoiceWidgetAnnotationElement(parameters);
  15698. }
  15699. return new WidgetAnnotationElement(parameters);
  15700. case _util.AnnotationType.POPUP:
  15701. return new PopupAnnotationElement(parameters);
  15702. case _util.AnnotationType.FREETEXT:
  15703. return new FreeTextAnnotationElement(parameters);
  15704. case _util.AnnotationType.LINE:
  15705. return new LineAnnotationElement(parameters);
  15706. case _util.AnnotationType.SQUARE:
  15707. return new SquareAnnotationElement(parameters);
  15708. case _util.AnnotationType.CIRCLE:
  15709. return new CircleAnnotationElement(parameters);
  15710. case _util.AnnotationType.POLYLINE:
  15711. return new PolylineAnnotationElement(parameters);
  15712. case _util.AnnotationType.CARET:
  15713. return new CaretAnnotationElement(parameters);
  15714. case _util.AnnotationType.INK:
  15715. return new InkAnnotationElement(parameters);
  15716. case _util.AnnotationType.POLYGON:
  15717. return new PolygonAnnotationElement(parameters);
  15718. case _util.AnnotationType.HIGHLIGHT:
  15719. return new HighlightAnnotationElement(parameters);
  15720. case _util.AnnotationType.UNDERLINE:
  15721. return new UnderlineAnnotationElement(parameters);
  15722. case _util.AnnotationType.SQUIGGLY:
  15723. return new SquigglyAnnotationElement(parameters);
  15724. case _util.AnnotationType.STRIKEOUT:
  15725. return new StrikeOutAnnotationElement(parameters);
  15726. case _util.AnnotationType.STAMP:
  15727. return new StampAnnotationElement(parameters);
  15728. case _util.AnnotationType.FILEATTACHMENT:
  15729. return new FileAttachmentAnnotationElement(parameters);
  15730. default:
  15731. return new AnnotationElement(parameters);
  15732. }
  15733. }
  15734. }]);
  15735. return AnnotationElementFactory;
  15736. }();
  15737. var AnnotationElement =
  15738. /*#__PURE__*/
  15739. function () {
  15740. function AnnotationElement(parameters) {
  15741. var isRenderable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  15742. var ignoreBorder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  15743. _classCallCheck(this, AnnotationElement);
  15744. this.isRenderable = isRenderable;
  15745. this.data = parameters.data;
  15746. this.layer = parameters.layer;
  15747. this.page = parameters.page;
  15748. this.viewport = parameters.viewport;
  15749. this.linkService = parameters.linkService;
  15750. this.downloadManager = parameters.downloadManager;
  15751. this.imageResourcesPath = parameters.imageResourcesPath;
  15752. this.renderInteractiveForms = parameters.renderInteractiveForms;
  15753. this.svgFactory = parameters.svgFactory;
  15754. if (isRenderable) {
  15755. this.container = this._createContainer(ignoreBorder);
  15756. }
  15757. }
  15758. _createClass(AnnotationElement, [{
  15759. key: "_createContainer",
  15760. value: function _createContainer() {
  15761. var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  15762. var data = this.data,
  15763. page = this.page,
  15764. viewport = this.viewport;
  15765. var container = document.createElement('section');
  15766. var width = data.rect[2] - data.rect[0];
  15767. var height = data.rect[3] - data.rect[1];
  15768. container.setAttribute('data-annotation-id', data.id);
  15769. var rect = _util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
  15770. container.style.transform = 'matrix(' + viewport.transform.join(',') + ')';
  15771. container.style.transformOrigin = -rect[0] + 'px ' + -rect[1] + 'px';
  15772. if (!ignoreBorder && data.borderStyle.width > 0) {
  15773. container.style.borderWidth = data.borderStyle.width + 'px';
  15774. if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
  15775. width = width - 2 * data.borderStyle.width;
  15776. height = height - 2 * data.borderStyle.width;
  15777. }
  15778. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  15779. var verticalRadius = data.borderStyle.verticalCornerRadius;
  15780. if (horizontalRadius > 0 || verticalRadius > 0) {
  15781. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  15782. container.style.borderRadius = radius;
  15783. }
  15784. switch (data.borderStyle.style) {
  15785. case _util.AnnotationBorderStyleType.SOLID:
  15786. container.style.borderStyle = 'solid';
  15787. break;
  15788. case _util.AnnotationBorderStyleType.DASHED:
  15789. container.style.borderStyle = 'dashed';
  15790. break;
  15791. case _util.AnnotationBorderStyleType.BEVELED:
  15792. (0, _util.warn)('Unimplemented border style: beveled');
  15793. break;
  15794. case _util.AnnotationBorderStyleType.INSET:
  15795. (0, _util.warn)('Unimplemented border style: inset');
  15796. break;
  15797. case _util.AnnotationBorderStyleType.UNDERLINE:
  15798. container.style.borderBottomStyle = 'solid';
  15799. break;
  15800. default:
  15801. break;
  15802. }
  15803. if (data.color) {
  15804. container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  15805. } else {
  15806. container.style.borderWidth = 0;
  15807. }
  15808. }
  15809. container.style.left = rect[0] + 'px';
  15810. container.style.top = rect[1] + 'px';
  15811. container.style.width = width + 'px';
  15812. container.style.height = height + 'px';
  15813. return container;
  15814. }
  15815. }, {
  15816. key: "_createPopup",
  15817. value: function _createPopup(container, trigger, data) {
  15818. if (!trigger) {
  15819. trigger = document.createElement('div');
  15820. trigger.style.height = container.style.height;
  15821. trigger.style.width = container.style.width;
  15822. container.appendChild(trigger);
  15823. }
  15824. var popupElement = new PopupElement({
  15825. container: container,
  15826. trigger: trigger,
  15827. color: data.color,
  15828. title: data.title,
  15829. modificationDate: data.modificationDate,
  15830. contents: data.contents,
  15831. hideWrapper: true
  15832. });
  15833. var popup = popupElement.render();
  15834. popup.style.left = container.style.width;
  15835. container.appendChild(popup);
  15836. }
  15837. }, {
  15838. key: "render",
  15839. value: function render() {
  15840. (0, _util.unreachable)('Abstract method `AnnotationElement.render` called');
  15841. }
  15842. }]);
  15843. return AnnotationElement;
  15844. }();
  15845. var LinkAnnotationElement =
  15846. /*#__PURE__*/
  15847. function (_AnnotationElement) {
  15848. _inherits(LinkAnnotationElement, _AnnotationElement);
  15849. function LinkAnnotationElement(parameters) {
  15850. _classCallCheck(this, LinkAnnotationElement);
  15851. var isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);
  15852. return _possibleConstructorReturn(this, _getPrototypeOf(LinkAnnotationElement).call(this, parameters, isRenderable));
  15853. }
  15854. _createClass(LinkAnnotationElement, [{
  15855. key: "render",
  15856. value: function render() {
  15857. this.container.className = 'linkAnnotation';
  15858. var data = this.data,
  15859. linkService = this.linkService;
  15860. var link = document.createElement('a');
  15861. (0, _display_utils.addLinkAttributes)(link, {
  15862. url: data.url,
  15863. target: data.newWindow ? _display_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
  15864. rel: linkService.externalLinkRel
  15865. });
  15866. if (!data.url) {
  15867. if (data.action) {
  15868. this._bindNamedAction(link, data.action);
  15869. } else {
  15870. this._bindLink(link, data.dest);
  15871. }
  15872. }
  15873. this.container.appendChild(link);
  15874. return this.container;
  15875. }
  15876. }, {
  15877. key: "_bindLink",
  15878. value: function _bindLink(link, destination) {
  15879. var _this = this;
  15880. link.href = this.linkService.getDestinationHash(destination);
  15881. link.onclick = function () {
  15882. if (destination) {
  15883. _this.linkService.navigateTo(destination);
  15884. }
  15885. return false;
  15886. };
  15887. if (destination) {
  15888. link.className = 'internalLink';
  15889. }
  15890. }
  15891. }, {
  15892. key: "_bindNamedAction",
  15893. value: function _bindNamedAction(link, action) {
  15894. var _this2 = this;
  15895. link.href = this.linkService.getAnchorUrl('');
  15896. link.onclick = function () {
  15897. _this2.linkService.executeNamedAction(action);
  15898. return false;
  15899. };
  15900. link.className = 'internalLink';
  15901. }
  15902. }]);
  15903. return LinkAnnotationElement;
  15904. }(AnnotationElement);
  15905. var TextAnnotationElement =
  15906. /*#__PURE__*/
  15907. function (_AnnotationElement2) {
  15908. _inherits(TextAnnotationElement, _AnnotationElement2);
  15909. function TextAnnotationElement(parameters) {
  15910. _classCallCheck(this, TextAnnotationElement);
  15911. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  15912. return _possibleConstructorReturn(this, _getPrototypeOf(TextAnnotationElement).call(this, parameters, isRenderable));
  15913. }
  15914. _createClass(TextAnnotationElement, [{
  15915. key: "render",
  15916. value: function render() {
  15917. this.container.className = 'textAnnotation';
  15918. var image = document.createElement('img');
  15919. image.style.height = this.container.style.height;
  15920. image.style.width = this.container.style.width;
  15921. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  15922. image.alt = '[{{type}} Annotation]';
  15923. image.dataset.l10nId = 'text_annotation_type';
  15924. image.dataset.l10nArgs = JSON.stringify({
  15925. type: this.data.name
  15926. });
  15927. if (!this.data.hasPopup) {
  15928. this._createPopup(this.container, image, this.data);
  15929. }
  15930. this.container.appendChild(image);
  15931. return this.container;
  15932. }
  15933. }]);
  15934. return TextAnnotationElement;
  15935. }(AnnotationElement);
  15936. var WidgetAnnotationElement =
  15937. /*#__PURE__*/
  15938. function (_AnnotationElement3) {
  15939. _inherits(WidgetAnnotationElement, _AnnotationElement3);
  15940. function WidgetAnnotationElement() {
  15941. _classCallCheck(this, WidgetAnnotationElement);
  15942. return _possibleConstructorReturn(this, _getPrototypeOf(WidgetAnnotationElement).apply(this, arguments));
  15943. }
  15944. _createClass(WidgetAnnotationElement, [{
  15945. key: "render",
  15946. value: function render() {
  15947. return this.container;
  15948. }
  15949. }]);
  15950. return WidgetAnnotationElement;
  15951. }(AnnotationElement);
  15952. var TextWidgetAnnotationElement =
  15953. /*#__PURE__*/
  15954. function (_WidgetAnnotationElem) {
  15955. _inherits(TextWidgetAnnotationElement, _WidgetAnnotationElem);
  15956. function TextWidgetAnnotationElement(parameters) {
  15957. _classCallCheck(this, TextWidgetAnnotationElement);
  15958. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  15959. return _possibleConstructorReturn(this, _getPrototypeOf(TextWidgetAnnotationElement).call(this, parameters, isRenderable));
  15960. }
  15961. _createClass(TextWidgetAnnotationElement, [{
  15962. key: "render",
  15963. value: function render() {
  15964. var TEXT_ALIGNMENT = ['left', 'center', 'right'];
  15965. this.container.className = 'textWidgetAnnotation';
  15966. var element = null;
  15967. if (this.renderInteractiveForms) {
  15968. if (this.data.multiLine) {
  15969. element = document.createElement('textarea');
  15970. element.textContent = this.data.fieldValue;
  15971. } else {
  15972. element = document.createElement('input');
  15973. element.type = 'text';
  15974. element.setAttribute('value', this.data.fieldValue);
  15975. }
  15976. element.disabled = this.data.readOnly;
  15977. if (this.data.maxLen !== null) {
  15978. element.maxLength = this.data.maxLen;
  15979. }
  15980. if (this.data.comb) {
  15981. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  15982. var combWidth = fieldWidth / this.data.maxLen;
  15983. element.classList.add('comb');
  15984. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  15985. }
  15986. } else {
  15987. element = document.createElement('div');
  15988. element.textContent = this.data.fieldValue;
  15989. element.style.verticalAlign = 'middle';
  15990. element.style.display = 'table-cell';
  15991. var font = null;
  15992. if (this.data.fontRefName && this.page.commonObjs.has(this.data.fontRefName)) {
  15993. font = this.page.commonObjs.get(this.data.fontRefName);
  15994. }
  15995. this._setTextStyle(element, font);
  15996. }
  15997. if (this.data.textAlignment !== null) {
  15998. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  15999. }
  16000. this.container.appendChild(element);
  16001. return this.container;
  16002. }
  16003. }, {
  16004. key: "_setTextStyle",
  16005. value: function _setTextStyle(element, font) {
  16006. var style = element.style;
  16007. style.fontSize = this.data.fontSize + 'px';
  16008. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  16009. if (!font) {
  16010. return;
  16011. }
  16012. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  16013. style.fontStyle = font.italic ? 'italic' : 'normal';
  16014. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  16015. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  16016. style.fontFamily = fontFamily + fallbackName;
  16017. }
  16018. }]);
  16019. return TextWidgetAnnotationElement;
  16020. }(WidgetAnnotationElement);
  16021. var CheckboxWidgetAnnotationElement =
  16022. /*#__PURE__*/
  16023. function (_WidgetAnnotationElem2) {
  16024. _inherits(CheckboxWidgetAnnotationElement, _WidgetAnnotationElem2);
  16025. function CheckboxWidgetAnnotationElement(parameters) {
  16026. _classCallCheck(this, CheckboxWidgetAnnotationElement);
  16027. return _possibleConstructorReturn(this, _getPrototypeOf(CheckboxWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
  16028. }
  16029. _createClass(CheckboxWidgetAnnotationElement, [{
  16030. key: "render",
  16031. value: function render() {
  16032. this.container.className = 'buttonWidgetAnnotation checkBox';
  16033. var element = document.createElement('input');
  16034. element.disabled = this.data.readOnly;
  16035. element.type = 'checkbox';
  16036. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  16037. element.setAttribute('checked', true);
  16038. }
  16039. this.container.appendChild(element);
  16040. return this.container;
  16041. }
  16042. }]);
  16043. return CheckboxWidgetAnnotationElement;
  16044. }(WidgetAnnotationElement);
  16045. var RadioButtonWidgetAnnotationElement =
  16046. /*#__PURE__*/
  16047. function (_WidgetAnnotationElem3) {
  16048. _inherits(RadioButtonWidgetAnnotationElement, _WidgetAnnotationElem3);
  16049. function RadioButtonWidgetAnnotationElement(parameters) {
  16050. _classCallCheck(this, RadioButtonWidgetAnnotationElement);
  16051. return _possibleConstructorReturn(this, _getPrototypeOf(RadioButtonWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
  16052. }
  16053. _createClass(RadioButtonWidgetAnnotationElement, [{
  16054. key: "render",
  16055. value: function render() {
  16056. this.container.className = 'buttonWidgetAnnotation radioButton';
  16057. var element = document.createElement('input');
  16058. element.disabled = this.data.readOnly;
  16059. element.type = 'radio';
  16060. element.name = this.data.fieldName;
  16061. if (this.data.fieldValue === this.data.buttonValue) {
  16062. element.setAttribute('checked', true);
  16063. }
  16064. this.container.appendChild(element);
  16065. return this.container;
  16066. }
  16067. }]);
  16068. return RadioButtonWidgetAnnotationElement;
  16069. }(WidgetAnnotationElement);
  16070. var PushButtonWidgetAnnotationElement =
  16071. /*#__PURE__*/
  16072. function (_LinkAnnotationElemen) {
  16073. _inherits(PushButtonWidgetAnnotationElement, _LinkAnnotationElemen);
  16074. function PushButtonWidgetAnnotationElement() {
  16075. _classCallCheck(this, PushButtonWidgetAnnotationElement);
  16076. return _possibleConstructorReturn(this, _getPrototypeOf(PushButtonWidgetAnnotationElement).apply(this, arguments));
  16077. }
  16078. _createClass(PushButtonWidgetAnnotationElement, [{
  16079. key: "render",
  16080. value: function render() {
  16081. var container = _get(_getPrototypeOf(PushButtonWidgetAnnotationElement.prototype), "render", this).call(this);
  16082. container.className = 'buttonWidgetAnnotation pushButton';
  16083. return container;
  16084. }
  16085. }]);
  16086. return PushButtonWidgetAnnotationElement;
  16087. }(LinkAnnotationElement);
  16088. var ChoiceWidgetAnnotationElement =
  16089. /*#__PURE__*/
  16090. function (_WidgetAnnotationElem4) {
  16091. _inherits(ChoiceWidgetAnnotationElement, _WidgetAnnotationElem4);
  16092. function ChoiceWidgetAnnotationElement(parameters) {
  16093. _classCallCheck(this, ChoiceWidgetAnnotationElement);
  16094. return _possibleConstructorReturn(this, _getPrototypeOf(ChoiceWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
  16095. }
  16096. _createClass(ChoiceWidgetAnnotationElement, [{
  16097. key: "render",
  16098. value: function render() {
  16099. this.container.className = 'choiceWidgetAnnotation';
  16100. var selectElement = document.createElement('select');
  16101. selectElement.disabled = this.data.readOnly;
  16102. if (!this.data.combo) {
  16103. selectElement.size = this.data.options.length;
  16104. if (this.data.multiSelect) {
  16105. selectElement.multiple = true;
  16106. }
  16107. }
  16108. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  16109. var option = this.data.options[i];
  16110. var optionElement = document.createElement('option');
  16111. optionElement.textContent = option.displayValue;
  16112. optionElement.value = option.exportValue;
  16113. if (this.data.fieldValue.includes(option.displayValue)) {
  16114. optionElement.setAttribute('selected', true);
  16115. }
  16116. selectElement.appendChild(optionElement);
  16117. }
  16118. this.container.appendChild(selectElement);
  16119. return this.container;
  16120. }
  16121. }]);
  16122. return ChoiceWidgetAnnotationElement;
  16123. }(WidgetAnnotationElement);
  16124. var PopupAnnotationElement =
  16125. /*#__PURE__*/
  16126. function (_AnnotationElement4) {
  16127. _inherits(PopupAnnotationElement, _AnnotationElement4);
  16128. function PopupAnnotationElement(parameters) {
  16129. _classCallCheck(this, PopupAnnotationElement);
  16130. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  16131. return _possibleConstructorReturn(this, _getPrototypeOf(PopupAnnotationElement).call(this, parameters, isRenderable));
  16132. }
  16133. _createClass(PopupAnnotationElement, [{
  16134. key: "render",
  16135. value: function render() {
  16136. var IGNORE_TYPES = ['Line', 'Square', 'Circle', 'PolyLine', 'Polygon', 'Ink'];
  16137. this.container.className = 'popupAnnotation';
  16138. if (IGNORE_TYPES.includes(this.data.parentType)) {
  16139. return this.container;
  16140. }
  16141. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  16142. var parentElement = this.layer.querySelector(selector);
  16143. if (!parentElement) {
  16144. return this.container;
  16145. }
  16146. var popup = new PopupElement({
  16147. container: this.container,
  16148. trigger: parentElement,
  16149. color: this.data.color,
  16150. title: this.data.title,
  16151. modificationDate: this.data.modificationDate,
  16152. contents: this.data.contents
  16153. });
  16154. var parentLeft = parseFloat(parentElement.style.left);
  16155. var parentWidth = parseFloat(parentElement.style.width);
  16156. this.container.style.transformOrigin = -(parentLeft + parentWidth) + 'px -' + parentElement.style.top;
  16157. this.container.style.left = parentLeft + parentWidth + 'px';
  16158. this.container.appendChild(popup.render());
  16159. return this.container;
  16160. }
  16161. }]);
  16162. return PopupAnnotationElement;
  16163. }(AnnotationElement);
  16164. var PopupElement =
  16165. /*#__PURE__*/
  16166. function () {
  16167. function PopupElement(parameters) {
  16168. _classCallCheck(this, PopupElement);
  16169. this.container = parameters.container;
  16170. this.trigger = parameters.trigger;
  16171. this.color = parameters.color;
  16172. this.title = parameters.title;
  16173. this.modificationDate = parameters.modificationDate;
  16174. this.contents = parameters.contents;
  16175. this.hideWrapper = parameters.hideWrapper || false;
  16176. this.pinned = false;
  16177. }
  16178. _createClass(PopupElement, [{
  16179. key: "render",
  16180. value: function render() {
  16181. var BACKGROUND_ENLIGHT = 0.7;
  16182. var wrapper = document.createElement('div');
  16183. wrapper.className = 'popupWrapper';
  16184. this.hideElement = this.hideWrapper ? wrapper : this.container;
  16185. this.hideElement.setAttribute('hidden', true);
  16186. var popup = document.createElement('div');
  16187. popup.className = 'popup';
  16188. var color = this.color;
  16189. if (color) {
  16190. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  16191. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  16192. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  16193. popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
  16194. }
  16195. var title = document.createElement('h1');
  16196. title.textContent = this.title;
  16197. popup.appendChild(title);
  16198. var dateObject = _display_utils.PDFDateString.toDateObject(this.modificationDate);
  16199. if (dateObject) {
  16200. var modificationDate = document.createElement('span');
  16201. modificationDate.textContent = '{{date}}, {{time}}';
  16202. modificationDate.dataset.l10nId = 'annotation_date_string';
  16203. modificationDate.dataset.l10nArgs = JSON.stringify({
  16204. date: dateObject.toLocaleDateString(),
  16205. time: dateObject.toLocaleTimeString()
  16206. });
  16207. popup.appendChild(modificationDate);
  16208. }
  16209. var contents = this._formatContents(this.contents);
  16210. popup.appendChild(contents);
  16211. this.trigger.addEventListener('click', this._toggle.bind(this));
  16212. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  16213. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  16214. popup.addEventListener('click', this._hide.bind(this, true));
  16215. wrapper.appendChild(popup);
  16216. return wrapper;
  16217. }
  16218. }, {
  16219. key: "_formatContents",
  16220. value: function _formatContents(contents) {
  16221. var p = document.createElement('p');
  16222. var lines = contents.split(/(?:\r\n?|\n)/);
  16223. for (var i = 0, ii = lines.length; i < ii; ++i) {
  16224. var line = lines[i];
  16225. p.appendChild(document.createTextNode(line));
  16226. if (i < ii - 1) {
  16227. p.appendChild(document.createElement('br'));
  16228. }
  16229. }
  16230. return p;
  16231. }
  16232. }, {
  16233. key: "_toggle",
  16234. value: function _toggle() {
  16235. if (this.pinned) {
  16236. this._hide(true);
  16237. } else {
  16238. this._show(true);
  16239. }
  16240. }
  16241. }, {
  16242. key: "_show",
  16243. value: function _show() {
  16244. var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  16245. if (pin) {
  16246. this.pinned = true;
  16247. }
  16248. if (this.hideElement.hasAttribute('hidden')) {
  16249. this.hideElement.removeAttribute('hidden');
  16250. this.container.style.zIndex += 1;
  16251. }
  16252. }
  16253. }, {
  16254. key: "_hide",
  16255. value: function _hide() {
  16256. var unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  16257. if (unpin) {
  16258. this.pinned = false;
  16259. }
  16260. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  16261. this.hideElement.setAttribute('hidden', true);
  16262. this.container.style.zIndex -= 1;
  16263. }
  16264. }
  16265. }]);
  16266. return PopupElement;
  16267. }();
  16268. var FreeTextAnnotationElement =
  16269. /*#__PURE__*/
  16270. function (_AnnotationElement5) {
  16271. _inherits(FreeTextAnnotationElement, _AnnotationElement5);
  16272. function FreeTextAnnotationElement(parameters) {
  16273. _classCallCheck(this, FreeTextAnnotationElement);
  16274. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16275. return _possibleConstructorReturn(this, _getPrototypeOf(FreeTextAnnotationElement).call(this, parameters, isRenderable, true));
  16276. }
  16277. _createClass(FreeTextAnnotationElement, [{
  16278. key: "render",
  16279. value: function render() {
  16280. this.container.className = 'freeTextAnnotation';
  16281. if (!this.data.hasPopup) {
  16282. this._createPopup(this.container, null, this.data);
  16283. }
  16284. return this.container;
  16285. }
  16286. }]);
  16287. return FreeTextAnnotationElement;
  16288. }(AnnotationElement);
  16289. var LineAnnotationElement =
  16290. /*#__PURE__*/
  16291. function (_AnnotationElement6) {
  16292. _inherits(LineAnnotationElement, _AnnotationElement6);
  16293. function LineAnnotationElement(parameters) {
  16294. _classCallCheck(this, LineAnnotationElement);
  16295. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16296. return _possibleConstructorReturn(this, _getPrototypeOf(LineAnnotationElement).call(this, parameters, isRenderable, true));
  16297. }
  16298. _createClass(LineAnnotationElement, [{
  16299. key: "render",
  16300. value: function render() {
  16301. this.container.className = 'lineAnnotation';
  16302. var data = this.data;
  16303. var width = data.rect[2] - data.rect[0];
  16304. var height = data.rect[3] - data.rect[1];
  16305. var svg = this.svgFactory.create(width, height);
  16306. var line = this.svgFactory.createElement('svg:line');
  16307. line.setAttribute('x1', data.rect[2] - data.lineCoordinates[0]);
  16308. line.setAttribute('y1', data.rect[3] - data.lineCoordinates[1]);
  16309. line.setAttribute('x2', data.rect[2] - data.lineCoordinates[2]);
  16310. line.setAttribute('y2', data.rect[3] - data.lineCoordinates[3]);
  16311. line.setAttribute('stroke-width', data.borderStyle.width);
  16312. line.setAttribute('stroke', 'transparent');
  16313. svg.appendChild(line);
  16314. this.container.append(svg);
  16315. this._createPopup(this.container, line, data);
  16316. return this.container;
  16317. }
  16318. }]);
  16319. return LineAnnotationElement;
  16320. }(AnnotationElement);
  16321. var SquareAnnotationElement =
  16322. /*#__PURE__*/
  16323. function (_AnnotationElement7) {
  16324. _inherits(SquareAnnotationElement, _AnnotationElement7);
  16325. function SquareAnnotationElement(parameters) {
  16326. _classCallCheck(this, SquareAnnotationElement);
  16327. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16328. return _possibleConstructorReturn(this, _getPrototypeOf(SquareAnnotationElement).call(this, parameters, isRenderable, true));
  16329. }
  16330. _createClass(SquareAnnotationElement, [{
  16331. key: "render",
  16332. value: function render() {
  16333. this.container.className = 'squareAnnotation';
  16334. var data = this.data;
  16335. var width = data.rect[2] - data.rect[0];
  16336. var height = data.rect[3] - data.rect[1];
  16337. var svg = this.svgFactory.create(width, height);
  16338. var borderWidth = data.borderStyle.width;
  16339. var square = this.svgFactory.createElement('svg:rect');
  16340. square.setAttribute('x', borderWidth / 2);
  16341. square.setAttribute('y', borderWidth / 2);
  16342. square.setAttribute('width', width - borderWidth);
  16343. square.setAttribute('height', height - borderWidth);
  16344. square.setAttribute('stroke-width', borderWidth);
  16345. square.setAttribute('stroke', 'transparent');
  16346. square.setAttribute('fill', 'none');
  16347. svg.appendChild(square);
  16348. this.container.append(svg);
  16349. this._createPopup(this.container, square, data);
  16350. return this.container;
  16351. }
  16352. }]);
  16353. return SquareAnnotationElement;
  16354. }(AnnotationElement);
  16355. var CircleAnnotationElement =
  16356. /*#__PURE__*/
  16357. function (_AnnotationElement8) {
  16358. _inherits(CircleAnnotationElement, _AnnotationElement8);
  16359. function CircleAnnotationElement(parameters) {
  16360. _classCallCheck(this, CircleAnnotationElement);
  16361. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16362. return _possibleConstructorReturn(this, _getPrototypeOf(CircleAnnotationElement).call(this, parameters, isRenderable, true));
  16363. }
  16364. _createClass(CircleAnnotationElement, [{
  16365. key: "render",
  16366. value: function render() {
  16367. this.container.className = 'circleAnnotation';
  16368. var data = this.data;
  16369. var width = data.rect[2] - data.rect[0];
  16370. var height = data.rect[3] - data.rect[1];
  16371. var svg = this.svgFactory.create(width, height);
  16372. var borderWidth = data.borderStyle.width;
  16373. var circle = this.svgFactory.createElement('svg:ellipse');
  16374. circle.setAttribute('cx', width / 2);
  16375. circle.setAttribute('cy', height / 2);
  16376. circle.setAttribute('rx', width / 2 - borderWidth / 2);
  16377. circle.setAttribute('ry', height / 2 - borderWidth / 2);
  16378. circle.setAttribute('stroke-width', borderWidth);
  16379. circle.setAttribute('stroke', 'transparent');
  16380. circle.setAttribute('fill', 'none');
  16381. svg.appendChild(circle);
  16382. this.container.append(svg);
  16383. this._createPopup(this.container, circle, data);
  16384. return this.container;
  16385. }
  16386. }]);
  16387. return CircleAnnotationElement;
  16388. }(AnnotationElement);
  16389. var PolylineAnnotationElement =
  16390. /*#__PURE__*/
  16391. function (_AnnotationElement9) {
  16392. _inherits(PolylineAnnotationElement, _AnnotationElement9);
  16393. function PolylineAnnotationElement(parameters) {
  16394. var _this3;
  16395. _classCallCheck(this, PolylineAnnotationElement);
  16396. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16397. _this3 = _possibleConstructorReturn(this, _getPrototypeOf(PolylineAnnotationElement).call(this, parameters, isRenderable, true));
  16398. _this3.containerClassName = 'polylineAnnotation';
  16399. _this3.svgElementName = 'svg:polyline';
  16400. return _this3;
  16401. }
  16402. _createClass(PolylineAnnotationElement, [{
  16403. key: "render",
  16404. value: function render() {
  16405. this.container.className = this.containerClassName;
  16406. var data = this.data;
  16407. var width = data.rect[2] - data.rect[0];
  16408. var height = data.rect[3] - data.rect[1];
  16409. var svg = this.svgFactory.create(width, height);
  16410. var vertices = data.vertices;
  16411. var points = [];
  16412. for (var i = 0, ii = vertices.length; i < ii; i++) {
  16413. var x = vertices[i].x - data.rect[0];
  16414. var y = data.rect[3] - vertices[i].y;
  16415. points.push(x + ',' + y);
  16416. }
  16417. points = points.join(' ');
  16418. var borderWidth = data.borderStyle.width;
  16419. var polyline = this.svgFactory.createElement(this.svgElementName);
  16420. polyline.setAttribute('points', points);
  16421. polyline.setAttribute('stroke-width', borderWidth);
  16422. polyline.setAttribute('stroke', 'transparent');
  16423. polyline.setAttribute('fill', 'none');
  16424. svg.appendChild(polyline);
  16425. this.container.append(svg);
  16426. this._createPopup(this.container, polyline, data);
  16427. return this.container;
  16428. }
  16429. }]);
  16430. return PolylineAnnotationElement;
  16431. }(AnnotationElement);
  16432. var PolygonAnnotationElement =
  16433. /*#__PURE__*/
  16434. function (_PolylineAnnotationEl) {
  16435. _inherits(PolygonAnnotationElement, _PolylineAnnotationEl);
  16436. function PolygonAnnotationElement(parameters) {
  16437. var _this4;
  16438. _classCallCheck(this, PolygonAnnotationElement);
  16439. _this4 = _possibleConstructorReturn(this, _getPrototypeOf(PolygonAnnotationElement).call(this, parameters));
  16440. _this4.containerClassName = 'polygonAnnotation';
  16441. _this4.svgElementName = 'svg:polygon';
  16442. return _this4;
  16443. }
  16444. return PolygonAnnotationElement;
  16445. }(PolylineAnnotationElement);
  16446. var CaretAnnotationElement =
  16447. /*#__PURE__*/
  16448. function (_AnnotationElement10) {
  16449. _inherits(CaretAnnotationElement, _AnnotationElement10);
  16450. function CaretAnnotationElement(parameters) {
  16451. _classCallCheck(this, CaretAnnotationElement);
  16452. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16453. return _possibleConstructorReturn(this, _getPrototypeOf(CaretAnnotationElement).call(this, parameters, isRenderable, true));
  16454. }
  16455. _createClass(CaretAnnotationElement, [{
  16456. key: "render",
  16457. value: function render() {
  16458. this.container.className = 'caretAnnotation';
  16459. if (!this.data.hasPopup) {
  16460. this._createPopup(this.container, null, this.data);
  16461. }
  16462. return this.container;
  16463. }
  16464. }]);
  16465. return CaretAnnotationElement;
  16466. }(AnnotationElement);
  16467. var InkAnnotationElement =
  16468. /*#__PURE__*/
  16469. function (_AnnotationElement11) {
  16470. _inherits(InkAnnotationElement, _AnnotationElement11);
  16471. function InkAnnotationElement(parameters) {
  16472. var _this5;
  16473. _classCallCheck(this, InkAnnotationElement);
  16474. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16475. _this5 = _possibleConstructorReturn(this, _getPrototypeOf(InkAnnotationElement).call(this, parameters, isRenderable, true));
  16476. _this5.containerClassName = 'inkAnnotation';
  16477. _this5.svgElementName = 'svg:polyline';
  16478. return _this5;
  16479. }
  16480. _createClass(InkAnnotationElement, [{
  16481. key: "render",
  16482. value: function render() {
  16483. this.container.className = this.containerClassName;
  16484. var data = this.data;
  16485. var width = data.rect[2] - data.rect[0];
  16486. var height = data.rect[3] - data.rect[1];
  16487. var svg = this.svgFactory.create(width, height);
  16488. var inkLists = data.inkLists;
  16489. for (var i = 0, ii = inkLists.length; i < ii; i++) {
  16490. var inkList = inkLists[i];
  16491. var points = [];
  16492. for (var j = 0, jj = inkList.length; j < jj; j++) {
  16493. var x = inkList[j].x - data.rect[0];
  16494. var y = data.rect[3] - inkList[j].y;
  16495. points.push(x + ',' + y);
  16496. }
  16497. points = points.join(' ');
  16498. var borderWidth = data.borderStyle.width;
  16499. var polyline = this.svgFactory.createElement(this.svgElementName);
  16500. polyline.setAttribute('points', points);
  16501. polyline.setAttribute('stroke-width', borderWidth);
  16502. polyline.setAttribute('stroke', 'transparent');
  16503. polyline.setAttribute('fill', 'none');
  16504. this._createPopup(this.container, polyline, data);
  16505. svg.appendChild(polyline);
  16506. }
  16507. this.container.append(svg);
  16508. return this.container;
  16509. }
  16510. }]);
  16511. return InkAnnotationElement;
  16512. }(AnnotationElement);
  16513. var HighlightAnnotationElement =
  16514. /*#__PURE__*/
  16515. function (_AnnotationElement12) {
  16516. _inherits(HighlightAnnotationElement, _AnnotationElement12);
  16517. function HighlightAnnotationElement(parameters) {
  16518. _classCallCheck(this, HighlightAnnotationElement);
  16519. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16520. return _possibleConstructorReturn(this, _getPrototypeOf(HighlightAnnotationElement).call(this, parameters, isRenderable, true));
  16521. }
  16522. _createClass(HighlightAnnotationElement, [{
  16523. key: "render",
  16524. value: function render() {
  16525. this.container.className = 'highlightAnnotation';
  16526. if (!this.data.hasPopup) {
  16527. this._createPopup(this.container, null, this.data);
  16528. }
  16529. return this.container;
  16530. }
  16531. }]);
  16532. return HighlightAnnotationElement;
  16533. }(AnnotationElement);
  16534. var UnderlineAnnotationElement =
  16535. /*#__PURE__*/
  16536. function (_AnnotationElement13) {
  16537. _inherits(UnderlineAnnotationElement, _AnnotationElement13);
  16538. function UnderlineAnnotationElement(parameters) {
  16539. _classCallCheck(this, UnderlineAnnotationElement);
  16540. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16541. return _possibleConstructorReturn(this, _getPrototypeOf(UnderlineAnnotationElement).call(this, parameters, isRenderable, true));
  16542. }
  16543. _createClass(UnderlineAnnotationElement, [{
  16544. key: "render",
  16545. value: function render() {
  16546. this.container.className = 'underlineAnnotation';
  16547. if (!this.data.hasPopup) {
  16548. this._createPopup(this.container, null, this.data);
  16549. }
  16550. return this.container;
  16551. }
  16552. }]);
  16553. return UnderlineAnnotationElement;
  16554. }(AnnotationElement);
  16555. var SquigglyAnnotationElement =
  16556. /*#__PURE__*/
  16557. function (_AnnotationElement14) {
  16558. _inherits(SquigglyAnnotationElement, _AnnotationElement14);
  16559. function SquigglyAnnotationElement(parameters) {
  16560. _classCallCheck(this, SquigglyAnnotationElement);
  16561. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16562. return _possibleConstructorReturn(this, _getPrototypeOf(SquigglyAnnotationElement).call(this, parameters, isRenderable, true));
  16563. }
  16564. _createClass(SquigglyAnnotationElement, [{
  16565. key: "render",
  16566. value: function render() {
  16567. this.container.className = 'squigglyAnnotation';
  16568. if (!this.data.hasPopup) {
  16569. this._createPopup(this.container, null, this.data);
  16570. }
  16571. return this.container;
  16572. }
  16573. }]);
  16574. return SquigglyAnnotationElement;
  16575. }(AnnotationElement);
  16576. var StrikeOutAnnotationElement =
  16577. /*#__PURE__*/
  16578. function (_AnnotationElement15) {
  16579. _inherits(StrikeOutAnnotationElement, _AnnotationElement15);
  16580. function StrikeOutAnnotationElement(parameters) {
  16581. _classCallCheck(this, StrikeOutAnnotationElement);
  16582. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16583. return _possibleConstructorReturn(this, _getPrototypeOf(StrikeOutAnnotationElement).call(this, parameters, isRenderable, true));
  16584. }
  16585. _createClass(StrikeOutAnnotationElement, [{
  16586. key: "render",
  16587. value: function render() {
  16588. this.container.className = 'strikeoutAnnotation';
  16589. if (!this.data.hasPopup) {
  16590. this._createPopup(this.container, null, this.data);
  16591. }
  16592. return this.container;
  16593. }
  16594. }]);
  16595. return StrikeOutAnnotationElement;
  16596. }(AnnotationElement);
  16597. var StampAnnotationElement =
  16598. /*#__PURE__*/
  16599. function (_AnnotationElement16) {
  16600. _inherits(StampAnnotationElement, _AnnotationElement16);
  16601. function StampAnnotationElement(parameters) {
  16602. _classCallCheck(this, StampAnnotationElement);
  16603. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16604. return _possibleConstructorReturn(this, _getPrototypeOf(StampAnnotationElement).call(this, parameters, isRenderable, true));
  16605. }
  16606. _createClass(StampAnnotationElement, [{
  16607. key: "render",
  16608. value: function render() {
  16609. this.container.className = 'stampAnnotation';
  16610. if (!this.data.hasPopup) {
  16611. this._createPopup(this.container, null, this.data);
  16612. }
  16613. return this.container;
  16614. }
  16615. }]);
  16616. return StampAnnotationElement;
  16617. }(AnnotationElement);
  16618. var FileAttachmentAnnotationElement =
  16619. /*#__PURE__*/
  16620. function (_AnnotationElement17) {
  16621. _inherits(FileAttachmentAnnotationElement, _AnnotationElement17);
  16622. function FileAttachmentAnnotationElement(parameters) {
  16623. var _this6;
  16624. _classCallCheck(this, FileAttachmentAnnotationElement);
  16625. _this6 = _possibleConstructorReturn(this, _getPrototypeOf(FileAttachmentAnnotationElement).call(this, parameters, true));
  16626. var _this6$data$file = _this6.data.file,
  16627. filename = _this6$data$file.filename,
  16628. content = _this6$data$file.content;
  16629. _this6.filename = (0, _display_utils.getFilenameFromUrl)(filename);
  16630. _this6.content = content;
  16631. if (_this6.linkService.eventBus) {
  16632. _this6.linkService.eventBus.dispatch('fileattachmentannotation', {
  16633. source: _assertThisInitialized(_this6),
  16634. id: (0, _util.stringToPDFString)(filename),
  16635. filename: filename,
  16636. content: content
  16637. });
  16638. }
  16639. return _this6;
  16640. }
  16641. _createClass(FileAttachmentAnnotationElement, [{
  16642. key: "render",
  16643. value: function render() {
  16644. this.container.className = 'fileAttachmentAnnotation';
  16645. var trigger = document.createElement('div');
  16646. trigger.style.height = this.container.style.height;
  16647. trigger.style.width = this.container.style.width;
  16648. trigger.addEventListener('dblclick', this._download.bind(this));
  16649. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  16650. this._createPopup(this.container, trigger, this.data);
  16651. }
  16652. this.container.appendChild(trigger);
  16653. return this.container;
  16654. }
  16655. }, {
  16656. key: "_download",
  16657. value: function _download() {
  16658. if (!this.downloadManager) {
  16659. (0, _util.warn)('Download cannot be started due to unavailable download manager');
  16660. return;
  16661. }
  16662. this.downloadManager.downloadData(this.content, this.filename, '');
  16663. }
  16664. }]);
  16665. return FileAttachmentAnnotationElement;
  16666. }(AnnotationElement);
  16667. var AnnotationLayer =
  16668. /*#__PURE__*/
  16669. function () {
  16670. function AnnotationLayer() {
  16671. _classCallCheck(this, AnnotationLayer);
  16672. }
  16673. _createClass(AnnotationLayer, null, [{
  16674. key: "render",
  16675. value: function render(parameters) {
  16676. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  16677. var data = parameters.annotations[i];
  16678. if (!data) {
  16679. continue;
  16680. }
  16681. var element = AnnotationElementFactory.create({
  16682. data: data,
  16683. layer: parameters.div,
  16684. page: parameters.page,
  16685. viewport: parameters.viewport,
  16686. linkService: parameters.linkService,
  16687. downloadManager: parameters.downloadManager,
  16688. imageResourcesPath: parameters.imageResourcesPath || '',
  16689. renderInteractiveForms: parameters.renderInteractiveForms || false,
  16690. svgFactory: new _display_utils.DOMSVGFactory()
  16691. });
  16692. if (element.isRenderable) {
  16693. parameters.div.appendChild(element.render());
  16694. }
  16695. }
  16696. }
  16697. }, {
  16698. key: "update",
  16699. value: function update(parameters) {
  16700. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  16701. var data = parameters.annotations[i];
  16702. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  16703. if (element) {
  16704. element.style.transform = 'matrix(' + parameters.viewport.transform.join(',') + ')';
  16705. }
  16706. }
  16707. parameters.div.removeAttribute('hidden');
  16708. }
  16709. }]);
  16710. return AnnotationLayer;
  16711. }();
  16712. exports.AnnotationLayer = AnnotationLayer;
  16713. /***/ }),
  16714. /* 164 */
  16715. /***/ (function(module, exports, __w_pdfjs_require__) {
  16716. "use strict";
  16717. Object.defineProperty(exports, "__esModule", {
  16718. value: true
  16719. });
  16720. exports.SVGGraphics = void 0;
  16721. var _util = __w_pdfjs_require__(1);
  16722. var _display_utils = __w_pdfjs_require__(151);
  16723. var _is_node = _interopRequireDefault(__w_pdfjs_require__(4));
  16724. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  16725. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
  16726. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
  16727. function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
  16728. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
  16729. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  16730. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  16731. function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  16732. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  16733. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16734. 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); } }
  16735. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16736. var SVGGraphics = function SVGGraphics() {
  16737. throw new Error('Not implemented: SVGGraphics');
  16738. };
  16739. exports.SVGGraphics = SVGGraphics;
  16740. {
  16741. var opListToTree = function opListToTree(opList) {
  16742. var opTree = [];
  16743. var tmp = [];
  16744. var _iteratorNormalCompletion = true;
  16745. var _didIteratorError = false;
  16746. var _iteratorError = undefined;
  16747. try {
  16748. for (var _iterator = opList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  16749. var opListElement = _step.value;
  16750. if (opListElement.fn === 'save') {
  16751. opTree.push({
  16752. 'fnId': 92,
  16753. 'fn': 'group',
  16754. 'items': []
  16755. });
  16756. tmp.push(opTree);
  16757. opTree = opTree[opTree.length - 1].items;
  16758. continue;
  16759. }
  16760. if (opListElement.fn === 'restore') {
  16761. opTree = tmp.pop();
  16762. } else {
  16763. opTree.push(opListElement);
  16764. }
  16765. }
  16766. } catch (err) {
  16767. _didIteratorError = true;
  16768. _iteratorError = err;
  16769. } finally {
  16770. try {
  16771. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  16772. _iterator["return"]();
  16773. }
  16774. } finally {
  16775. if (_didIteratorError) {
  16776. throw _iteratorError;
  16777. }
  16778. }
  16779. }
  16780. return opTree;
  16781. };
  16782. var pf = function pf(value) {
  16783. if (Number.isInteger(value)) {
  16784. return value.toString();
  16785. }
  16786. var s = value.toFixed(10);
  16787. var i = s.length - 1;
  16788. if (s[i] !== '0') {
  16789. return s;
  16790. }
  16791. do {
  16792. i--;
  16793. } while (s[i] === '0');
  16794. return s.substring(0, s[i] === '.' ? i : i + 1);
  16795. };
  16796. var pm = function pm(m) {
  16797. if (m[4] === 0 && m[5] === 0) {
  16798. if (m[1] === 0 && m[2] === 0) {
  16799. if (m[0] === 1 && m[3] === 1) {
  16800. return '';
  16801. }
  16802. return "scale(".concat(pf(m[0]), " ").concat(pf(m[3]), ")");
  16803. }
  16804. if (m[0] === m[3] && m[1] === -m[2]) {
  16805. var a = Math.acos(m[0]) * 180 / Math.PI;
  16806. return "rotate(".concat(pf(a), ")");
  16807. }
  16808. } else {
  16809. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  16810. return "translate(".concat(pf(m[4]), " ").concat(pf(m[5]), ")");
  16811. }
  16812. }
  16813. return "matrix(".concat(pf(m[0]), " ").concat(pf(m[1]), " ").concat(pf(m[2]), " ").concat(pf(m[3]), " ").concat(pf(m[4]), " ") + "".concat(pf(m[5]), ")");
  16814. };
  16815. var SVG_DEFAULTS = {
  16816. fontStyle: 'normal',
  16817. fontWeight: 'normal',
  16818. fillColor: '#000000'
  16819. };
  16820. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  16821. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  16822. var LINE_CAP_STYLES = ['butt', 'round', 'square'];
  16823. var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
  16824. var convertImgDataToPng = function () {
  16825. var PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
  16826. var CHUNK_WRAPPER_SIZE = 12;
  16827. var crcTable = new Int32Array(256);
  16828. for (var i = 0; i < 256; i++) {
  16829. var c = i;
  16830. for (var h = 0; h < 8; h++) {
  16831. if (c & 1) {
  16832. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  16833. } else {
  16834. c = c >> 1 & 0x7fffffff;
  16835. }
  16836. }
  16837. crcTable[i] = c;
  16838. }
  16839. function crc32(data, start, end) {
  16840. var crc = -1;
  16841. for (var _i = start; _i < end; _i++) {
  16842. var a = (crc ^ data[_i]) & 0xff;
  16843. var b = crcTable[a];
  16844. crc = crc >>> 8 ^ b;
  16845. }
  16846. return crc ^ -1;
  16847. }
  16848. function writePngChunk(type, body, data, offset) {
  16849. var p = offset;
  16850. var len = body.length;
  16851. data[p] = len >> 24 & 0xff;
  16852. data[p + 1] = len >> 16 & 0xff;
  16853. data[p + 2] = len >> 8 & 0xff;
  16854. data[p + 3] = len & 0xff;
  16855. p += 4;
  16856. data[p] = type.charCodeAt(0) & 0xff;
  16857. data[p + 1] = type.charCodeAt(1) & 0xff;
  16858. data[p + 2] = type.charCodeAt(2) & 0xff;
  16859. data[p + 3] = type.charCodeAt(3) & 0xff;
  16860. p += 4;
  16861. data.set(body, p);
  16862. p += body.length;
  16863. var crc = crc32(data, offset + 4, p);
  16864. data[p] = crc >> 24 & 0xff;
  16865. data[p + 1] = crc >> 16 & 0xff;
  16866. data[p + 2] = crc >> 8 & 0xff;
  16867. data[p + 3] = crc & 0xff;
  16868. }
  16869. function adler32(data, start, end) {
  16870. var a = 1;
  16871. var b = 0;
  16872. for (var _i2 = start; _i2 < end; ++_i2) {
  16873. a = (a + (data[_i2] & 0xff)) % 65521;
  16874. b = (b + a) % 65521;
  16875. }
  16876. return b << 16 | a;
  16877. }
  16878. function deflateSync(literals) {
  16879. if (!(0, _is_node["default"])()) {
  16880. return deflateSyncUncompressed(literals);
  16881. }
  16882. try {
  16883. var input;
  16884. if (parseInt(process.versions.node) >= 8) {
  16885. input = literals;
  16886. } else {
  16887. input = new Buffer(literals);
  16888. }
  16889. var output = require('zlib').deflateSync(input, {
  16890. level: 9
  16891. });
  16892. return output instanceof Uint8Array ? output : new Uint8Array(output);
  16893. } catch (e) {
  16894. (0, _util.warn)('Not compressing PNG because zlib.deflateSync is unavailable: ' + e);
  16895. }
  16896. return deflateSyncUncompressed(literals);
  16897. }
  16898. function deflateSyncUncompressed(literals) {
  16899. var len = literals.length;
  16900. var maxBlockLength = 0xFFFF;
  16901. var deflateBlocks = Math.ceil(len / maxBlockLength);
  16902. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  16903. var pi = 0;
  16904. idat[pi++] = 0x78;
  16905. idat[pi++] = 0x9c;
  16906. var pos = 0;
  16907. while (len > maxBlockLength) {
  16908. idat[pi++] = 0x00;
  16909. idat[pi++] = 0xff;
  16910. idat[pi++] = 0xff;
  16911. idat[pi++] = 0x00;
  16912. idat[pi++] = 0x00;
  16913. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  16914. pi += maxBlockLength;
  16915. pos += maxBlockLength;
  16916. len -= maxBlockLength;
  16917. }
  16918. idat[pi++] = 0x01;
  16919. idat[pi++] = len & 0xff;
  16920. idat[pi++] = len >> 8 & 0xff;
  16921. idat[pi++] = ~len & 0xffff & 0xff;
  16922. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  16923. idat.set(literals.subarray(pos), pi);
  16924. pi += literals.length - pos;
  16925. var adler = adler32(literals, 0, literals.length);
  16926. idat[pi++] = adler >> 24 & 0xff;
  16927. idat[pi++] = adler >> 16 & 0xff;
  16928. idat[pi++] = adler >> 8 & 0xff;
  16929. idat[pi++] = adler & 0xff;
  16930. return idat;
  16931. }
  16932. function encode(imgData, kind, forceDataSchema, isMask) {
  16933. var width = imgData.width;
  16934. var height = imgData.height;
  16935. var bitDepth, colorType, lineSize;
  16936. var bytes = imgData.data;
  16937. switch (kind) {
  16938. case _util.ImageKind.GRAYSCALE_1BPP:
  16939. colorType = 0;
  16940. bitDepth = 1;
  16941. lineSize = width + 7 >> 3;
  16942. break;
  16943. case _util.ImageKind.RGB_24BPP:
  16944. colorType = 2;
  16945. bitDepth = 8;
  16946. lineSize = width * 3;
  16947. break;
  16948. case _util.ImageKind.RGBA_32BPP:
  16949. colorType = 6;
  16950. bitDepth = 8;
  16951. lineSize = width * 4;
  16952. break;
  16953. default:
  16954. throw new Error('invalid format');
  16955. }
  16956. var literals = new Uint8Array((1 + lineSize) * height);
  16957. var offsetLiterals = 0,
  16958. offsetBytes = 0;
  16959. for (var y = 0; y < height; ++y) {
  16960. literals[offsetLiterals++] = 0;
  16961. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  16962. offsetBytes += lineSize;
  16963. offsetLiterals += lineSize;
  16964. }
  16965. if (kind === _util.ImageKind.GRAYSCALE_1BPP && isMask) {
  16966. offsetLiterals = 0;
  16967. for (var _y = 0; _y < height; _y++) {
  16968. offsetLiterals++;
  16969. for (var _i3 = 0; _i3 < lineSize; _i3++) {
  16970. literals[offsetLiterals++] ^= 0xFF;
  16971. }
  16972. }
  16973. }
  16974. var ihdr = new Uint8Array([width >> 24 & 0xff, width >> 16 & 0xff, width >> 8 & 0xff, width & 0xff, height >> 24 & 0xff, height >> 16 & 0xff, height >> 8 & 0xff, height & 0xff, bitDepth, colorType, 0x00, 0x00, 0x00]);
  16975. var idat = deflateSync(literals);
  16976. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  16977. var data = new Uint8Array(pngLength);
  16978. var offset = 0;
  16979. data.set(PNG_HEADER, offset);
  16980. offset += PNG_HEADER.length;
  16981. writePngChunk('IHDR', ihdr, data, offset);
  16982. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  16983. writePngChunk('IDATA', idat, data, offset);
  16984. offset += CHUNK_WRAPPER_SIZE + idat.length;
  16985. writePngChunk('IEND', new Uint8Array(0), data, offset);
  16986. return (0, _util.createObjectURL)(data, 'image/png', forceDataSchema);
  16987. }
  16988. return function convertImgDataToPng(imgData, forceDataSchema, isMask) {
  16989. var kind = imgData.kind === undefined ? _util.ImageKind.GRAYSCALE_1BPP : imgData.kind;
  16990. return encode(imgData, kind, forceDataSchema, isMask);
  16991. };
  16992. }();
  16993. var SVGExtraState =
  16994. /*#__PURE__*/
  16995. function () {
  16996. function SVGExtraState() {
  16997. _classCallCheck(this, SVGExtraState);
  16998. this.fontSizeScale = 1;
  16999. this.fontWeight = SVG_DEFAULTS.fontWeight;
  17000. this.fontSize = 0;
  17001. this.textMatrix = _util.IDENTITY_MATRIX;
  17002. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  17003. this.leading = 0;
  17004. this.textRenderingMode = _util.TextRenderingMode.FILL;
  17005. this.textMatrixScale = 1;
  17006. this.x = 0;
  17007. this.y = 0;
  17008. this.lineX = 0;
  17009. this.lineY = 0;
  17010. this.charSpacing = 0;
  17011. this.wordSpacing = 0;
  17012. this.textHScale = 1;
  17013. this.textRise = 0;
  17014. this.fillColor = SVG_DEFAULTS.fillColor;
  17015. this.strokeColor = '#000000';
  17016. this.fillAlpha = 1;
  17017. this.strokeAlpha = 1;
  17018. this.lineWidth = 1;
  17019. this.lineJoin = '';
  17020. this.lineCap = '';
  17021. this.miterLimit = 0;
  17022. this.dashArray = [];
  17023. this.dashPhase = 0;
  17024. this.dependencies = [];
  17025. this.activeClipUrl = null;
  17026. this.clipGroup = null;
  17027. this.maskId = '';
  17028. }
  17029. _createClass(SVGExtraState, [{
  17030. key: "clone",
  17031. value: function clone() {
  17032. return Object.create(this);
  17033. }
  17034. }, {
  17035. key: "setCurrentPoint",
  17036. value: function setCurrentPoint(x, y) {
  17037. this.x = x;
  17038. this.y = y;
  17039. }
  17040. }]);
  17041. return SVGExtraState;
  17042. }();
  17043. var clipCount = 0;
  17044. var maskCount = 0;
  17045. var shadingCount = 0;
  17046. exports.SVGGraphics = SVGGraphics =
  17047. /*#__PURE__*/
  17048. function () {
  17049. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  17050. _classCallCheck(this, SVGGraphics);
  17051. this.svgFactory = new _display_utils.DOMSVGFactory();
  17052. this.current = new SVGExtraState();
  17053. this.transformMatrix = _util.IDENTITY_MATRIX;
  17054. this.transformStack = [];
  17055. this.extraStack = [];
  17056. this.commonObjs = commonObjs;
  17057. this.objs = objs;
  17058. this.pendingClip = null;
  17059. this.pendingEOFill = false;
  17060. this.embedFonts = false;
  17061. this.embeddedFonts = Object.create(null);
  17062. this.cssStyle = null;
  17063. this.forceDataSchema = !!forceDataSchema;
  17064. this._operatorIdMapping = [];
  17065. for (var op in _util.OPS) {
  17066. this._operatorIdMapping[_util.OPS[op]] = op;
  17067. }
  17068. }
  17069. _createClass(SVGGraphics, [{
  17070. key: "save",
  17071. value: function save() {
  17072. this.transformStack.push(this.transformMatrix);
  17073. var old = this.current;
  17074. this.extraStack.push(old);
  17075. this.current = old.clone();
  17076. }
  17077. }, {
  17078. key: "restore",
  17079. value: function restore() {
  17080. this.transformMatrix = this.transformStack.pop();
  17081. this.current = this.extraStack.pop();
  17082. this.pendingClip = null;
  17083. this.tgrp = null;
  17084. }
  17085. }, {
  17086. key: "group",
  17087. value: function group(items) {
  17088. this.save();
  17089. this.executeOpTree(items);
  17090. this.restore();
  17091. }
  17092. }, {
  17093. key: "loadDependencies",
  17094. value: function loadDependencies(operatorList) {
  17095. var _this = this;
  17096. var fnArray = operatorList.fnArray;
  17097. var argsArray = operatorList.argsArray;
  17098. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  17099. if (fnArray[i] !== _util.OPS.dependency) {
  17100. continue;
  17101. }
  17102. var _iteratorNormalCompletion2 = true;
  17103. var _didIteratorError2 = false;
  17104. var _iteratorError2 = undefined;
  17105. try {
  17106. var _loop = function _loop() {
  17107. var obj = _step2.value;
  17108. var objsPool = obj.startsWith('g_') ? _this.commonObjs : _this.objs;
  17109. var promise = new Promise(function (resolve) {
  17110. objsPool.get(obj, resolve);
  17111. });
  17112. _this.current.dependencies.push(promise);
  17113. };
  17114. for (var _iterator2 = argsArray[i][Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  17115. _loop();
  17116. }
  17117. } catch (err) {
  17118. _didIteratorError2 = true;
  17119. _iteratorError2 = err;
  17120. } finally {
  17121. try {
  17122. if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
  17123. _iterator2["return"]();
  17124. }
  17125. } finally {
  17126. if (_didIteratorError2) {
  17127. throw _iteratorError2;
  17128. }
  17129. }
  17130. }
  17131. }
  17132. return Promise.all(this.current.dependencies);
  17133. }
  17134. }, {
  17135. key: "transform",
  17136. value: function transform(a, b, c, d, e, f) {
  17137. var transformMatrix = [a, b, c, d, e, f];
  17138. this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix);
  17139. this.tgrp = null;
  17140. }
  17141. }, {
  17142. key: "getSVG",
  17143. value: function getSVG(operatorList, viewport) {
  17144. var _this2 = this;
  17145. this.viewport = viewport;
  17146. var svgElement = this._initialize(viewport);
  17147. return this.loadDependencies(operatorList).then(function () {
  17148. _this2.transformMatrix = _util.IDENTITY_MATRIX;
  17149. _this2.executeOpTree(_this2.convertOpList(operatorList));
  17150. return svgElement;
  17151. });
  17152. }
  17153. }, {
  17154. key: "convertOpList",
  17155. value: function convertOpList(operatorList) {
  17156. var operatorIdMapping = this._operatorIdMapping;
  17157. var argsArray = operatorList.argsArray;
  17158. var fnArray = operatorList.fnArray;
  17159. var opList = [];
  17160. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  17161. var fnId = fnArray[i];
  17162. opList.push({
  17163. 'fnId': fnId,
  17164. 'fn': operatorIdMapping[fnId],
  17165. 'args': argsArray[i]
  17166. });
  17167. }
  17168. return opListToTree(opList);
  17169. }
  17170. }, {
  17171. key: "executeOpTree",
  17172. value: function executeOpTree(opTree) {
  17173. var _iteratorNormalCompletion3 = true;
  17174. var _didIteratorError3 = false;
  17175. var _iteratorError3 = undefined;
  17176. try {
  17177. for (var _iterator3 = opTree[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  17178. var opTreeElement = _step3.value;
  17179. var fn = opTreeElement.fn;
  17180. var fnId = opTreeElement.fnId;
  17181. var args = opTreeElement.args;
  17182. switch (fnId | 0) {
  17183. case _util.OPS.beginText:
  17184. this.beginText();
  17185. break;
  17186. case _util.OPS.dependency:
  17187. break;
  17188. case _util.OPS.setLeading:
  17189. this.setLeading(args);
  17190. break;
  17191. case _util.OPS.setLeadingMoveText:
  17192. this.setLeadingMoveText(args[0], args[1]);
  17193. break;
  17194. case _util.OPS.setFont:
  17195. this.setFont(args);
  17196. break;
  17197. case _util.OPS.showText:
  17198. this.showText(args[0]);
  17199. break;
  17200. case _util.OPS.showSpacedText:
  17201. this.showText(args[0]);
  17202. break;
  17203. case _util.OPS.endText:
  17204. this.endText();
  17205. break;
  17206. case _util.OPS.moveText:
  17207. this.moveText(args[0], args[1]);
  17208. break;
  17209. case _util.OPS.setCharSpacing:
  17210. this.setCharSpacing(args[0]);
  17211. break;
  17212. case _util.OPS.setWordSpacing:
  17213. this.setWordSpacing(args[0]);
  17214. break;
  17215. case _util.OPS.setHScale:
  17216. this.setHScale(args[0]);
  17217. break;
  17218. case _util.OPS.setTextMatrix:
  17219. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  17220. break;
  17221. case _util.OPS.setTextRise:
  17222. this.setTextRise(args[0]);
  17223. break;
  17224. case _util.OPS.setTextRenderingMode:
  17225. this.setTextRenderingMode(args[0]);
  17226. break;
  17227. case _util.OPS.setLineWidth:
  17228. this.setLineWidth(args[0]);
  17229. break;
  17230. case _util.OPS.setLineJoin:
  17231. this.setLineJoin(args[0]);
  17232. break;
  17233. case _util.OPS.setLineCap:
  17234. this.setLineCap(args[0]);
  17235. break;
  17236. case _util.OPS.setMiterLimit:
  17237. this.setMiterLimit(args[0]);
  17238. break;
  17239. case _util.OPS.setFillRGBColor:
  17240. this.setFillRGBColor(args[0], args[1], args[2]);
  17241. break;
  17242. case _util.OPS.setStrokeRGBColor:
  17243. this.setStrokeRGBColor(args[0], args[1], args[2]);
  17244. break;
  17245. case _util.OPS.setStrokeColorN:
  17246. this.setStrokeColorN(args);
  17247. break;
  17248. case _util.OPS.setFillColorN:
  17249. this.setFillColorN(args);
  17250. break;
  17251. case _util.OPS.shadingFill:
  17252. this.shadingFill(args[0]);
  17253. break;
  17254. case _util.OPS.setDash:
  17255. this.setDash(args[0], args[1]);
  17256. break;
  17257. case _util.OPS.setRenderingIntent:
  17258. this.setRenderingIntent(args[0]);
  17259. break;
  17260. case _util.OPS.setFlatness:
  17261. this.setFlatness(args[0]);
  17262. break;
  17263. case _util.OPS.setGState:
  17264. this.setGState(args[0]);
  17265. break;
  17266. case _util.OPS.fill:
  17267. this.fill();
  17268. break;
  17269. case _util.OPS.eoFill:
  17270. this.eoFill();
  17271. break;
  17272. case _util.OPS.stroke:
  17273. this.stroke();
  17274. break;
  17275. case _util.OPS.fillStroke:
  17276. this.fillStroke();
  17277. break;
  17278. case _util.OPS.eoFillStroke:
  17279. this.eoFillStroke();
  17280. break;
  17281. case _util.OPS.clip:
  17282. this.clip('nonzero');
  17283. break;
  17284. case _util.OPS.eoClip:
  17285. this.clip('evenodd');
  17286. break;
  17287. case _util.OPS.paintSolidColorImageMask:
  17288. this.paintSolidColorImageMask();
  17289. break;
  17290. case _util.OPS.paintJpegXObject:
  17291. this.paintJpegXObject(args[0], args[1], args[2]);
  17292. break;
  17293. case _util.OPS.paintImageXObject:
  17294. this.paintImageXObject(args[0]);
  17295. break;
  17296. case _util.OPS.paintInlineImageXObject:
  17297. this.paintInlineImageXObject(args[0]);
  17298. break;
  17299. case _util.OPS.paintImageMaskXObject:
  17300. this.paintImageMaskXObject(args[0]);
  17301. break;
  17302. case _util.OPS.paintFormXObjectBegin:
  17303. this.paintFormXObjectBegin(args[0], args[1]);
  17304. break;
  17305. case _util.OPS.paintFormXObjectEnd:
  17306. this.paintFormXObjectEnd();
  17307. break;
  17308. case _util.OPS.closePath:
  17309. this.closePath();
  17310. break;
  17311. case _util.OPS.closeStroke:
  17312. this.closeStroke();
  17313. break;
  17314. case _util.OPS.closeFillStroke:
  17315. this.closeFillStroke();
  17316. break;
  17317. case _util.OPS.closeEOFillStroke:
  17318. this.closeEOFillStroke();
  17319. break;
  17320. case _util.OPS.nextLine:
  17321. this.nextLine();
  17322. break;
  17323. case _util.OPS.transform:
  17324. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  17325. break;
  17326. case _util.OPS.constructPath:
  17327. this.constructPath(args[0], args[1]);
  17328. break;
  17329. case _util.OPS.endPath:
  17330. this.endPath();
  17331. break;
  17332. case 92:
  17333. this.group(opTreeElement.items);
  17334. break;
  17335. default:
  17336. (0, _util.warn)("Unimplemented operator ".concat(fn));
  17337. break;
  17338. }
  17339. }
  17340. } catch (err) {
  17341. _didIteratorError3 = true;
  17342. _iteratorError3 = err;
  17343. } finally {
  17344. try {
  17345. if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
  17346. _iterator3["return"]();
  17347. }
  17348. } finally {
  17349. if (_didIteratorError3) {
  17350. throw _iteratorError3;
  17351. }
  17352. }
  17353. }
  17354. }
  17355. }, {
  17356. key: "setWordSpacing",
  17357. value: function setWordSpacing(wordSpacing) {
  17358. this.current.wordSpacing = wordSpacing;
  17359. }
  17360. }, {
  17361. key: "setCharSpacing",
  17362. value: function setCharSpacing(charSpacing) {
  17363. this.current.charSpacing = charSpacing;
  17364. }
  17365. }, {
  17366. key: "nextLine",
  17367. value: function nextLine() {
  17368. this.moveText(0, this.current.leading);
  17369. }
  17370. }, {
  17371. key: "setTextMatrix",
  17372. value: function setTextMatrix(a, b, c, d, e, f) {
  17373. var current = this.current;
  17374. current.textMatrix = current.lineMatrix = [a, b, c, d, e, f];
  17375. current.textMatrixScale = Math.sqrt(a * a + b * b);
  17376. current.x = current.lineX = 0;
  17377. current.y = current.lineY = 0;
  17378. current.xcoords = [];
  17379. current.tspan = this.svgFactory.createElement('svg:tspan');
  17380. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  17381. current.tspan.setAttributeNS(null, 'font-size', "".concat(pf(current.fontSize), "px"));
  17382. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  17383. current.txtElement = this.svgFactory.createElement('svg:text');
  17384. current.txtElement.appendChild(current.tspan);
  17385. }
  17386. }, {
  17387. key: "beginText",
  17388. value: function beginText() {
  17389. var current = this.current;
  17390. current.x = current.lineX = 0;
  17391. current.y = current.lineY = 0;
  17392. current.textMatrix = _util.IDENTITY_MATRIX;
  17393. current.lineMatrix = _util.IDENTITY_MATRIX;
  17394. current.textMatrixScale = 1;
  17395. current.tspan = this.svgFactory.createElement('svg:tspan');
  17396. current.txtElement = this.svgFactory.createElement('svg:text');
  17397. current.txtgrp = this.svgFactory.createElement('svg:g');
  17398. current.xcoords = [];
  17399. }
  17400. }, {
  17401. key: "moveText",
  17402. value: function moveText(x, y) {
  17403. var current = this.current;
  17404. current.x = current.lineX += x;
  17405. current.y = current.lineY += y;
  17406. current.xcoords = [];
  17407. current.tspan = this.svgFactory.createElement('svg:tspan');
  17408. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  17409. current.tspan.setAttributeNS(null, 'font-size', "".concat(pf(current.fontSize), "px"));
  17410. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  17411. }
  17412. }, {
  17413. key: "showText",
  17414. value: function showText(glyphs) {
  17415. var current = this.current;
  17416. var font = current.font;
  17417. var fontSize = current.fontSize;
  17418. if (fontSize === 0) {
  17419. return;
  17420. }
  17421. var charSpacing = current.charSpacing;
  17422. var wordSpacing = current.wordSpacing;
  17423. var fontDirection = current.fontDirection;
  17424. var textHScale = current.textHScale * fontDirection;
  17425. var vertical = font.vertical;
  17426. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  17427. var x = 0;
  17428. var _iteratorNormalCompletion4 = true;
  17429. var _didIteratorError4 = false;
  17430. var _iteratorError4 = undefined;
  17431. try {
  17432. for (var _iterator4 = glyphs[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  17433. var glyph = _step4.value;
  17434. if (glyph === null) {
  17435. x += fontDirection * wordSpacing;
  17436. continue;
  17437. } else if ((0, _util.isNum)(glyph)) {
  17438. x += -glyph * fontSize * 0.001;
  17439. continue;
  17440. }
  17441. var width = glyph.width;
  17442. var character = glyph.fontChar;
  17443. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  17444. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  17445. if (!glyph.isInFont && !font.missingFile) {
  17446. x += charWidth;
  17447. continue;
  17448. }
  17449. current.xcoords.push(current.x + x * textHScale);
  17450. current.tspan.textContent += character;
  17451. x += charWidth;
  17452. }
  17453. } catch (err) {
  17454. _didIteratorError4 = true;
  17455. _iteratorError4 = err;
  17456. } finally {
  17457. try {
  17458. if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) {
  17459. _iterator4["return"]();
  17460. }
  17461. } finally {
  17462. if (_didIteratorError4) {
  17463. throw _iteratorError4;
  17464. }
  17465. }
  17466. }
  17467. if (vertical) {
  17468. current.y -= x * textHScale;
  17469. } else {
  17470. current.x += x * textHScale;
  17471. }
  17472. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  17473. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  17474. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  17475. current.tspan.setAttributeNS(null, 'font-size', "".concat(pf(current.fontSize), "px"));
  17476. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  17477. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  17478. }
  17479. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  17480. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  17481. }
  17482. var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  17483. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  17484. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  17485. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  17486. }
  17487. if (current.fillAlpha < 1) {
  17488. current.tspan.setAttributeNS(null, 'fill-opacity', current.fillAlpha);
  17489. }
  17490. } else if (current.textRenderingMode === _util.TextRenderingMode.ADD_TO_PATH) {
  17491. current.tspan.setAttributeNS(null, 'fill', 'transparent');
  17492. } else {
  17493. current.tspan.setAttributeNS(null, 'fill', 'none');
  17494. }
  17495. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  17496. var lineWidthScale = 1 / (current.textMatrixScale || 1);
  17497. this._setStrokeAttributes(current.tspan, lineWidthScale);
  17498. }
  17499. var textMatrix = current.textMatrix;
  17500. if (current.textRise !== 0) {
  17501. textMatrix = textMatrix.slice();
  17502. textMatrix[5] += current.textRise;
  17503. }
  17504. current.txtElement.setAttributeNS(null, 'transform', "".concat(pm(textMatrix), " scale(1, -1)"));
  17505. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  17506. current.txtElement.appendChild(current.tspan);
  17507. current.txtgrp.appendChild(current.txtElement);
  17508. this._ensureTransformGroup().appendChild(current.txtElement);
  17509. }
  17510. }, {
  17511. key: "setLeadingMoveText",
  17512. value: function setLeadingMoveText(x, y) {
  17513. this.setLeading(-y);
  17514. this.moveText(x, y);
  17515. }
  17516. }, {
  17517. key: "addFontStyle",
  17518. value: function addFontStyle(fontObj) {
  17519. if (!this.cssStyle) {
  17520. this.cssStyle = this.svgFactory.createElement('svg:style');
  17521. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  17522. this.defs.appendChild(this.cssStyle);
  17523. }
  17524. var url = (0, _util.createObjectURL)(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  17525. this.cssStyle.textContent += "@font-face { font-family: \"".concat(fontObj.loadedName, "\";") + " src: url(".concat(url, "); }\n");
  17526. }
  17527. }, {
  17528. key: "setFont",
  17529. value: function setFont(details) {
  17530. var current = this.current;
  17531. var fontObj = this.commonObjs.get(details[0]);
  17532. var size = details[1];
  17533. current.font = fontObj;
  17534. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  17535. this.addFontStyle(fontObj);
  17536. this.embeddedFonts[fontObj.loadedName] = fontObj;
  17537. }
  17538. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
  17539. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  17540. var italic = fontObj.italic ? 'italic' : 'normal';
  17541. if (size < 0) {
  17542. size = -size;
  17543. current.fontDirection = -1;
  17544. } else {
  17545. current.fontDirection = 1;
  17546. }
  17547. current.fontSize = size;
  17548. current.fontFamily = fontObj.loadedName;
  17549. current.fontWeight = bold;
  17550. current.fontStyle = italic;
  17551. current.tspan = this.svgFactory.createElement('svg:tspan');
  17552. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  17553. current.xcoords = [];
  17554. }
  17555. }, {
  17556. key: "endText",
  17557. value: function endText() {
  17558. var current = this.current;
  17559. if (current.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG && current.txtElement && current.txtElement.hasChildNodes()) {
  17560. current.element = current.txtElement;
  17561. this.clip('nonzero');
  17562. this.endPath();
  17563. }
  17564. }
  17565. }, {
  17566. key: "setLineWidth",
  17567. value: function setLineWidth(width) {
  17568. if (width > 0) {
  17569. this.current.lineWidth = width;
  17570. }
  17571. }
  17572. }, {
  17573. key: "setLineCap",
  17574. value: function setLineCap(style) {
  17575. this.current.lineCap = LINE_CAP_STYLES[style];
  17576. }
  17577. }, {
  17578. key: "setLineJoin",
  17579. value: function setLineJoin(style) {
  17580. this.current.lineJoin = LINE_JOIN_STYLES[style];
  17581. }
  17582. }, {
  17583. key: "setMiterLimit",
  17584. value: function setMiterLimit(limit) {
  17585. this.current.miterLimit = limit;
  17586. }
  17587. }, {
  17588. key: "setStrokeAlpha",
  17589. value: function setStrokeAlpha(strokeAlpha) {
  17590. this.current.strokeAlpha = strokeAlpha;
  17591. }
  17592. }, {
  17593. key: "setStrokeRGBColor",
  17594. value: function setStrokeRGBColor(r, g, b) {
  17595. this.current.strokeColor = _util.Util.makeCssRgb(r, g, b);
  17596. }
  17597. }, {
  17598. key: "setFillAlpha",
  17599. value: function setFillAlpha(fillAlpha) {
  17600. this.current.fillAlpha = fillAlpha;
  17601. }
  17602. }, {
  17603. key: "setFillRGBColor",
  17604. value: function setFillRGBColor(r, g, b) {
  17605. this.current.fillColor = _util.Util.makeCssRgb(r, g, b);
  17606. this.current.tspan = this.svgFactory.createElement('svg:tspan');
  17607. this.current.xcoords = [];
  17608. }
  17609. }, {
  17610. key: "setStrokeColorN",
  17611. value: function setStrokeColorN(args) {
  17612. this.current.strokeColor = this._makeColorN_Pattern(args);
  17613. }
  17614. }, {
  17615. key: "setFillColorN",
  17616. value: function setFillColorN(args) {
  17617. this.current.fillColor = this._makeColorN_Pattern(args);
  17618. }
  17619. }, {
  17620. key: "shadingFill",
  17621. value: function shadingFill(args) {
  17622. var width = this.viewport.width;
  17623. var height = this.viewport.height;
  17624. var inv = _util.Util.inverseTransform(this.transformMatrix);
  17625. var bl = _util.Util.applyTransform([0, 0], inv);
  17626. var br = _util.Util.applyTransform([0, height], inv);
  17627. var ul = _util.Util.applyTransform([width, 0], inv);
  17628. var ur = _util.Util.applyTransform([width, height], inv);
  17629. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  17630. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  17631. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  17632. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  17633. var rect = this.svgFactory.createElement('svg:rect');
  17634. rect.setAttributeNS(null, 'x', x0);
  17635. rect.setAttributeNS(null, 'y', y0);
  17636. rect.setAttributeNS(null, 'width', x1 - x0);
  17637. rect.setAttributeNS(null, 'height', y1 - y0);
  17638. rect.setAttributeNS(null, 'fill', this._makeShadingPattern(args));
  17639. this._ensureTransformGroup().appendChild(rect);
  17640. }
  17641. }, {
  17642. key: "_makeColorN_Pattern",
  17643. value: function _makeColorN_Pattern(args) {
  17644. if (args[0] === 'TilingPattern') {
  17645. return this._makeTilingPattern(args);
  17646. }
  17647. return this._makeShadingPattern(args);
  17648. }
  17649. }, {
  17650. key: "_makeTilingPattern",
  17651. value: function _makeTilingPattern(args) {
  17652. var color = args[1];
  17653. var operatorList = args[2];
  17654. var matrix = args[3] || _util.IDENTITY_MATRIX;
  17655. var _args$ = _slicedToArray(args[4], 4),
  17656. x0 = _args$[0],
  17657. y0 = _args$[1],
  17658. x1 = _args$[2],
  17659. y1 = _args$[3];
  17660. var xstep = args[5];
  17661. var ystep = args[6];
  17662. var paintType = args[7];
  17663. var tilingId = "shading".concat(shadingCount++);
  17664. var _Util$applyTransform = _util.Util.applyTransform([x0, y0], matrix),
  17665. _Util$applyTransform2 = _slicedToArray(_Util$applyTransform, 2),
  17666. tx0 = _Util$applyTransform2[0],
  17667. ty0 = _Util$applyTransform2[1];
  17668. var _Util$applyTransform3 = _util.Util.applyTransform([x1, y1], matrix),
  17669. _Util$applyTransform4 = _slicedToArray(_Util$applyTransform3, 2),
  17670. tx1 = _Util$applyTransform4[0],
  17671. ty1 = _Util$applyTransform4[1];
  17672. var _Util$singularValueDe = _util.Util.singularValueDecompose2dScale(matrix),
  17673. _Util$singularValueDe2 = _slicedToArray(_Util$singularValueDe, 2),
  17674. xscale = _Util$singularValueDe2[0],
  17675. yscale = _Util$singularValueDe2[1];
  17676. var txstep = xstep * xscale;
  17677. var tystep = ystep * yscale;
  17678. var tiling = this.svgFactory.createElement('svg:pattern');
  17679. tiling.setAttributeNS(null, 'id', tilingId);
  17680. tiling.setAttributeNS(null, 'patternUnits', 'userSpaceOnUse');
  17681. tiling.setAttributeNS(null, 'width', txstep);
  17682. tiling.setAttributeNS(null, 'height', tystep);
  17683. tiling.setAttributeNS(null, 'x', "".concat(tx0));
  17684. tiling.setAttributeNS(null, 'y', "".concat(ty0));
  17685. var svg = this.svg;
  17686. var transformMatrix = this.transformMatrix;
  17687. var fillColor = this.current.fillColor;
  17688. var strokeColor = this.current.strokeColor;
  17689. var bbox = this.svgFactory.create(tx1 - tx0, ty1 - ty0);
  17690. this.svg = bbox;
  17691. this.transformMatrix = matrix;
  17692. if (paintType === 2) {
  17693. var cssColor = _util.Util.makeCssRgb.apply(_util.Util, _toConsumableArray(color));
  17694. this.current.fillColor = cssColor;
  17695. this.current.strokeColor = cssColor;
  17696. }
  17697. this.executeOpTree(this.convertOpList(operatorList));
  17698. this.svg = svg;
  17699. this.transformMatrix = transformMatrix;
  17700. this.current.fillColor = fillColor;
  17701. this.current.strokeColor = strokeColor;
  17702. tiling.appendChild(bbox.childNodes[0]);
  17703. this.defs.appendChild(tiling);
  17704. return "url(#".concat(tilingId, ")");
  17705. }
  17706. }, {
  17707. key: "_makeShadingPattern",
  17708. value: function _makeShadingPattern(args) {
  17709. switch (args[0]) {
  17710. case 'RadialAxial':
  17711. var shadingId = "shading".concat(shadingCount++);
  17712. var colorStops = args[2];
  17713. var gradient;
  17714. switch (args[1]) {
  17715. case 'axial':
  17716. var point0 = args[3];
  17717. var point1 = args[4];
  17718. gradient = this.svgFactory.createElement('svg:linearGradient');
  17719. gradient.setAttributeNS(null, 'id', shadingId);
  17720. gradient.setAttributeNS(null, 'gradientUnits', 'userSpaceOnUse');
  17721. gradient.setAttributeNS(null, 'x1', point0[0]);
  17722. gradient.setAttributeNS(null, 'y1', point0[1]);
  17723. gradient.setAttributeNS(null, 'x2', point1[0]);
  17724. gradient.setAttributeNS(null, 'y2', point1[1]);
  17725. break;
  17726. case 'radial':
  17727. var focalPoint = args[3];
  17728. var circlePoint = args[4];
  17729. var focalRadius = args[5];
  17730. var circleRadius = args[6];
  17731. gradient = this.svgFactory.createElement('svg:radialGradient');
  17732. gradient.setAttributeNS(null, 'id', shadingId);
  17733. gradient.setAttributeNS(null, 'gradientUnits', 'userSpaceOnUse');
  17734. gradient.setAttributeNS(null, 'cx', circlePoint[0]);
  17735. gradient.setAttributeNS(null, 'cy', circlePoint[1]);
  17736. gradient.setAttributeNS(null, 'r', circleRadius);
  17737. gradient.setAttributeNS(null, 'fx', focalPoint[0]);
  17738. gradient.setAttributeNS(null, 'fy', focalPoint[1]);
  17739. gradient.setAttributeNS(null, 'fr', focalRadius);
  17740. break;
  17741. default:
  17742. throw new Error("Unknown RadialAxial type: ".concat(args[1]));
  17743. }
  17744. var _iteratorNormalCompletion5 = true;
  17745. var _didIteratorError5 = false;
  17746. var _iteratorError5 = undefined;
  17747. try {
  17748. for (var _iterator5 = colorStops[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
  17749. var colorStop = _step5.value;
  17750. var stop = this.svgFactory.createElement('svg:stop');
  17751. stop.setAttributeNS(null, 'offset', colorStop[0]);
  17752. stop.setAttributeNS(null, 'stop-color', colorStop[1]);
  17753. gradient.appendChild(stop);
  17754. }
  17755. } catch (err) {
  17756. _didIteratorError5 = true;
  17757. _iteratorError5 = err;
  17758. } finally {
  17759. try {
  17760. if (!_iteratorNormalCompletion5 && _iterator5["return"] != null) {
  17761. _iterator5["return"]();
  17762. }
  17763. } finally {
  17764. if (_didIteratorError5) {
  17765. throw _iteratorError5;
  17766. }
  17767. }
  17768. }
  17769. this.defs.appendChild(gradient);
  17770. return "url(#".concat(shadingId, ")");
  17771. case 'Mesh':
  17772. (0, _util.warn)('Unimplemented pattern Mesh');
  17773. return null;
  17774. case 'Dummy':
  17775. return 'hotpink';
  17776. default:
  17777. throw new Error("Unknown IR type: ".concat(args[0]));
  17778. }
  17779. }
  17780. }, {
  17781. key: "setDash",
  17782. value: function setDash(dashArray, dashPhase) {
  17783. this.current.dashArray = dashArray;
  17784. this.current.dashPhase = dashPhase;
  17785. }
  17786. }, {
  17787. key: "constructPath",
  17788. value: function constructPath(ops, args) {
  17789. var current = this.current;
  17790. var x = current.x,
  17791. y = current.y;
  17792. var d = [];
  17793. var j = 0;
  17794. var _iteratorNormalCompletion6 = true;
  17795. var _didIteratorError6 = false;
  17796. var _iteratorError6 = undefined;
  17797. try {
  17798. for (var _iterator6 = ops[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
  17799. var op = _step6.value;
  17800. switch (op | 0) {
  17801. case _util.OPS.rectangle:
  17802. x = args[j++];
  17803. y = args[j++];
  17804. var width = args[j++];
  17805. var height = args[j++];
  17806. var xw = x + width;
  17807. var yh = y + height;
  17808. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  17809. break;
  17810. case _util.OPS.moveTo:
  17811. x = args[j++];
  17812. y = args[j++];
  17813. d.push('M', pf(x), pf(y));
  17814. break;
  17815. case _util.OPS.lineTo:
  17816. x = args[j++];
  17817. y = args[j++];
  17818. d.push('L', pf(x), pf(y));
  17819. break;
  17820. case _util.OPS.curveTo:
  17821. x = args[j + 4];
  17822. y = args[j + 5];
  17823. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  17824. j += 6;
  17825. break;
  17826. case _util.OPS.curveTo2:
  17827. x = args[j + 2];
  17828. y = args[j + 3];
  17829. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  17830. j += 4;
  17831. break;
  17832. case _util.OPS.curveTo3:
  17833. x = args[j + 2];
  17834. y = args[j + 3];
  17835. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  17836. j += 4;
  17837. break;
  17838. case _util.OPS.closePath:
  17839. d.push('Z');
  17840. break;
  17841. }
  17842. }
  17843. } catch (err) {
  17844. _didIteratorError6 = true;
  17845. _iteratorError6 = err;
  17846. } finally {
  17847. try {
  17848. if (!_iteratorNormalCompletion6 && _iterator6["return"] != null) {
  17849. _iterator6["return"]();
  17850. }
  17851. } finally {
  17852. if (_didIteratorError6) {
  17853. throw _iteratorError6;
  17854. }
  17855. }
  17856. }
  17857. d = d.join(' ');
  17858. if (current.path && ops.length > 0 && ops[0] !== _util.OPS.rectangle && ops[0] !== _util.OPS.moveTo) {
  17859. d = current.path.getAttributeNS(null, 'd') + d;
  17860. } else {
  17861. current.path = this.svgFactory.createElement('svg:path');
  17862. this._ensureTransformGroup().appendChild(current.path);
  17863. }
  17864. current.path.setAttributeNS(null, 'd', d);
  17865. current.path.setAttributeNS(null, 'fill', 'none');
  17866. current.element = current.path;
  17867. current.setCurrentPoint(x, y);
  17868. }
  17869. }, {
  17870. key: "endPath",
  17871. value: function endPath() {
  17872. var current = this.current;
  17873. current.path = null;
  17874. if (!this.pendingClip) {
  17875. return;
  17876. }
  17877. if (!current.element) {
  17878. this.pendingClip = null;
  17879. return;
  17880. }
  17881. var clipId = "clippath".concat(clipCount++);
  17882. var clipPath = this.svgFactory.createElement('svg:clipPath');
  17883. clipPath.setAttributeNS(null, 'id', clipId);
  17884. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  17885. var clipElement = current.element.cloneNode(true);
  17886. if (this.pendingClip === 'evenodd') {
  17887. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  17888. } else {
  17889. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  17890. }
  17891. this.pendingClip = null;
  17892. clipPath.appendChild(clipElement);
  17893. this.defs.appendChild(clipPath);
  17894. if (current.activeClipUrl) {
  17895. current.clipGroup = null;
  17896. this.extraStack.forEach(function (prev) {
  17897. prev.clipGroup = null;
  17898. });
  17899. clipPath.setAttributeNS(null, 'clip-path', current.activeClipUrl);
  17900. }
  17901. current.activeClipUrl = "url(#".concat(clipId, ")");
  17902. this.tgrp = null;
  17903. }
  17904. }, {
  17905. key: "clip",
  17906. value: function clip(type) {
  17907. this.pendingClip = type;
  17908. }
  17909. }, {
  17910. key: "closePath",
  17911. value: function closePath() {
  17912. var current = this.current;
  17913. if (current.path) {
  17914. var d = "".concat(current.path.getAttributeNS(null, 'd'), "Z");
  17915. current.path.setAttributeNS(null, 'd', d);
  17916. }
  17917. }
  17918. }, {
  17919. key: "setLeading",
  17920. value: function setLeading(leading) {
  17921. this.current.leading = -leading;
  17922. }
  17923. }, {
  17924. key: "setTextRise",
  17925. value: function setTextRise(textRise) {
  17926. this.current.textRise = textRise;
  17927. }
  17928. }, {
  17929. key: "setTextRenderingMode",
  17930. value: function setTextRenderingMode(textRenderingMode) {
  17931. this.current.textRenderingMode = textRenderingMode;
  17932. }
  17933. }, {
  17934. key: "setHScale",
  17935. value: function setHScale(scale) {
  17936. this.current.textHScale = scale / 100;
  17937. }
  17938. }, {
  17939. key: "setRenderingIntent",
  17940. value: function setRenderingIntent(intent) {}
  17941. }, {
  17942. key: "setFlatness",
  17943. value: function setFlatness(flatness) {}
  17944. }, {
  17945. key: "setGState",
  17946. value: function setGState(states) {
  17947. var _iteratorNormalCompletion7 = true;
  17948. var _didIteratorError7 = false;
  17949. var _iteratorError7 = undefined;
  17950. try {
  17951. for (var _iterator7 = states[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
  17952. var _step7$value = _slicedToArray(_step7.value, 2),
  17953. key = _step7$value[0],
  17954. value = _step7$value[1];
  17955. switch (key) {
  17956. case 'LW':
  17957. this.setLineWidth(value);
  17958. break;
  17959. case 'LC':
  17960. this.setLineCap(value);
  17961. break;
  17962. case 'LJ':
  17963. this.setLineJoin(value);
  17964. break;
  17965. case 'ML':
  17966. this.setMiterLimit(value);
  17967. break;
  17968. case 'D':
  17969. this.setDash(value[0], value[1]);
  17970. break;
  17971. case 'RI':
  17972. this.setRenderingIntent(value);
  17973. break;
  17974. case 'FL':
  17975. this.setFlatness(value);
  17976. break;
  17977. case 'Font':
  17978. this.setFont(value);
  17979. break;
  17980. case 'CA':
  17981. this.setStrokeAlpha(value);
  17982. break;
  17983. case 'ca':
  17984. this.setFillAlpha(value);
  17985. break;
  17986. default:
  17987. (0, _util.warn)("Unimplemented graphic state operator ".concat(key));
  17988. break;
  17989. }
  17990. }
  17991. } catch (err) {
  17992. _didIteratorError7 = true;
  17993. _iteratorError7 = err;
  17994. } finally {
  17995. try {
  17996. if (!_iteratorNormalCompletion7 && _iterator7["return"] != null) {
  17997. _iterator7["return"]();
  17998. }
  17999. } finally {
  18000. if (_didIteratorError7) {
  18001. throw _iteratorError7;
  18002. }
  18003. }
  18004. }
  18005. }
  18006. }, {
  18007. key: "fill",
  18008. value: function fill() {
  18009. var current = this.current;
  18010. if (current.element) {
  18011. current.element.setAttributeNS(null, 'fill', current.fillColor);
  18012. current.element.setAttributeNS(null, 'fill-opacity', current.fillAlpha);
  18013. this.endPath();
  18014. }
  18015. }
  18016. }, {
  18017. key: "stroke",
  18018. value: function stroke() {
  18019. var current = this.current;
  18020. if (current.element) {
  18021. this._setStrokeAttributes(current.element);
  18022. current.element.setAttributeNS(null, 'fill', 'none');
  18023. this.endPath();
  18024. }
  18025. }
  18026. }, {
  18027. key: "_setStrokeAttributes",
  18028. value: function _setStrokeAttributes(element) {
  18029. var lineWidthScale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  18030. var current = this.current;
  18031. var dashArray = current.dashArray;
  18032. if (lineWidthScale !== 1 && dashArray.length > 0) {
  18033. dashArray = dashArray.map(function (value) {
  18034. return lineWidthScale * value;
  18035. });
  18036. }
  18037. element.setAttributeNS(null, 'stroke', current.strokeColor);
  18038. element.setAttributeNS(null, 'stroke-opacity', current.strokeAlpha);
  18039. element.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  18040. element.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  18041. element.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  18042. element.setAttributeNS(null, 'stroke-width', pf(lineWidthScale * current.lineWidth) + 'px');
  18043. element.setAttributeNS(null, 'stroke-dasharray', dashArray.map(pf).join(' '));
  18044. element.setAttributeNS(null, 'stroke-dashoffset', pf(lineWidthScale * current.dashPhase) + 'px');
  18045. }
  18046. }, {
  18047. key: "eoFill",
  18048. value: function eoFill() {
  18049. if (this.current.element) {
  18050. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  18051. }
  18052. this.fill();
  18053. }
  18054. }, {
  18055. key: "fillStroke",
  18056. value: function fillStroke() {
  18057. this.stroke();
  18058. this.fill();
  18059. }
  18060. }, {
  18061. key: "eoFillStroke",
  18062. value: function eoFillStroke() {
  18063. if (this.current.element) {
  18064. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  18065. }
  18066. this.fillStroke();
  18067. }
  18068. }, {
  18069. key: "closeStroke",
  18070. value: function closeStroke() {
  18071. this.closePath();
  18072. this.stroke();
  18073. }
  18074. }, {
  18075. key: "closeFillStroke",
  18076. value: function closeFillStroke() {
  18077. this.closePath();
  18078. this.fillStroke();
  18079. }
  18080. }, {
  18081. key: "closeEOFillStroke",
  18082. value: function closeEOFillStroke() {
  18083. this.closePath();
  18084. this.eoFillStroke();
  18085. }
  18086. }, {
  18087. key: "paintSolidColorImageMask",
  18088. value: function paintSolidColorImageMask() {
  18089. var rect = this.svgFactory.createElement('svg:rect');
  18090. rect.setAttributeNS(null, 'x', '0');
  18091. rect.setAttributeNS(null, 'y', '0');
  18092. rect.setAttributeNS(null, 'width', '1px');
  18093. rect.setAttributeNS(null, 'height', '1px');
  18094. rect.setAttributeNS(null, 'fill', this.current.fillColor);
  18095. this._ensureTransformGroup().appendChild(rect);
  18096. }
  18097. }, {
  18098. key: "paintJpegXObject",
  18099. value: function paintJpegXObject(objId, w, h) {
  18100. var imgObj = this.objs.get(objId);
  18101. var imgEl = this.svgFactory.createElement('svg:image');
  18102. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  18103. imgEl.setAttributeNS(null, 'width', pf(w));
  18104. imgEl.setAttributeNS(null, 'height', pf(h));
  18105. imgEl.setAttributeNS(null, 'x', '0');
  18106. imgEl.setAttributeNS(null, 'y', pf(-h));
  18107. imgEl.setAttributeNS(null, 'transform', "scale(".concat(pf(1 / w), " ").concat(pf(-1 / h), ")"));
  18108. this._ensureTransformGroup().appendChild(imgEl);
  18109. }
  18110. }, {
  18111. key: "paintImageXObject",
  18112. value: function paintImageXObject(objId) {
  18113. var imgData = this.objs.get(objId);
  18114. if (!imgData) {
  18115. (0, _util.warn)("Dependent image with object ID ".concat(objId, " is not ready yet"));
  18116. return;
  18117. }
  18118. this.paintInlineImageXObject(imgData);
  18119. }
  18120. }, {
  18121. key: "paintInlineImageXObject",
  18122. value: function paintInlineImageXObject(imgData, mask) {
  18123. var width = imgData.width;
  18124. var height = imgData.height;
  18125. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema, !!mask);
  18126. var cliprect = this.svgFactory.createElement('svg:rect');
  18127. cliprect.setAttributeNS(null, 'x', '0');
  18128. cliprect.setAttributeNS(null, 'y', '0');
  18129. cliprect.setAttributeNS(null, 'width', pf(width));
  18130. cliprect.setAttributeNS(null, 'height', pf(height));
  18131. this.current.element = cliprect;
  18132. this.clip('nonzero');
  18133. var imgEl = this.svgFactory.createElement('svg:image');
  18134. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  18135. imgEl.setAttributeNS(null, 'x', '0');
  18136. imgEl.setAttributeNS(null, 'y', pf(-height));
  18137. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  18138. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  18139. imgEl.setAttributeNS(null, 'transform', "scale(".concat(pf(1 / width), " ").concat(pf(-1 / height), ")"));
  18140. if (mask) {
  18141. mask.appendChild(imgEl);
  18142. } else {
  18143. this._ensureTransformGroup().appendChild(imgEl);
  18144. }
  18145. }
  18146. }, {
  18147. key: "paintImageMaskXObject",
  18148. value: function paintImageMaskXObject(imgData) {
  18149. var current = this.current;
  18150. var width = imgData.width;
  18151. var height = imgData.height;
  18152. var fillColor = current.fillColor;
  18153. current.maskId = "mask".concat(maskCount++);
  18154. var mask = this.svgFactory.createElement('svg:mask');
  18155. mask.setAttributeNS(null, 'id', current.maskId);
  18156. var rect = this.svgFactory.createElement('svg:rect');
  18157. rect.setAttributeNS(null, 'x', '0');
  18158. rect.setAttributeNS(null, 'y', '0');
  18159. rect.setAttributeNS(null, 'width', pf(width));
  18160. rect.setAttributeNS(null, 'height', pf(height));
  18161. rect.setAttributeNS(null, 'fill', fillColor);
  18162. rect.setAttributeNS(null, 'mask', "url(#".concat(current.maskId, ")"));
  18163. this.defs.appendChild(mask);
  18164. this._ensureTransformGroup().appendChild(rect);
  18165. this.paintInlineImageXObject(imgData, mask);
  18166. }
  18167. }, {
  18168. key: "paintFormXObjectBegin",
  18169. value: function paintFormXObjectBegin(matrix, bbox) {
  18170. if (Array.isArray(matrix) && matrix.length === 6) {
  18171. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  18172. }
  18173. if (bbox) {
  18174. var width = bbox[2] - bbox[0];
  18175. var height = bbox[3] - bbox[1];
  18176. var cliprect = this.svgFactory.createElement('svg:rect');
  18177. cliprect.setAttributeNS(null, 'x', bbox[0]);
  18178. cliprect.setAttributeNS(null, 'y', bbox[1]);
  18179. cliprect.setAttributeNS(null, 'width', pf(width));
  18180. cliprect.setAttributeNS(null, 'height', pf(height));
  18181. this.current.element = cliprect;
  18182. this.clip('nonzero');
  18183. this.endPath();
  18184. }
  18185. }
  18186. }, {
  18187. key: "paintFormXObjectEnd",
  18188. value: function paintFormXObjectEnd() {}
  18189. }, {
  18190. key: "_initialize",
  18191. value: function _initialize(viewport) {
  18192. var svg = this.svgFactory.create(viewport.width, viewport.height);
  18193. var definitions = this.svgFactory.createElement('svg:defs');
  18194. svg.appendChild(definitions);
  18195. this.defs = definitions;
  18196. var rootGroup = this.svgFactory.createElement('svg:g');
  18197. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  18198. svg.appendChild(rootGroup);
  18199. this.svg = rootGroup;
  18200. return svg;
  18201. }
  18202. }, {
  18203. key: "_ensureClipGroup",
  18204. value: function _ensureClipGroup() {
  18205. if (!this.current.clipGroup) {
  18206. var clipGroup = this.svgFactory.createElement('svg:g');
  18207. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  18208. this.svg.appendChild(clipGroup);
  18209. this.current.clipGroup = clipGroup;
  18210. }
  18211. return this.current.clipGroup;
  18212. }
  18213. }, {
  18214. key: "_ensureTransformGroup",
  18215. value: function _ensureTransformGroup() {
  18216. if (!this.tgrp) {
  18217. this.tgrp = this.svgFactory.createElement('svg:g');
  18218. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  18219. if (this.current.activeClipUrl) {
  18220. this._ensureClipGroup().appendChild(this.tgrp);
  18221. } else {
  18222. this.svg.appendChild(this.tgrp);
  18223. }
  18224. }
  18225. return this.tgrp;
  18226. }
  18227. }]);
  18228. return SVGGraphics;
  18229. }();
  18230. }
  18231. /***/ }),
  18232. /* 165 */
  18233. /***/ (function(module, exports, __w_pdfjs_require__) {
  18234. "use strict";
  18235. Object.defineProperty(exports, "__esModule", {
  18236. value: true
  18237. });
  18238. exports.PDFNodeStream = void 0;
  18239. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(148));
  18240. var _util = __w_pdfjs_require__(1);
  18241. var _network_utils = __w_pdfjs_require__(166);
  18242. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  18243. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  18244. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  18245. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  18246. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  18247. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  18248. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  18249. 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); } }
  18250. 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); }); }; }
  18251. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18252. 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); } }
  18253. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  18254. var fs = require('fs');
  18255. var http = require('http');
  18256. var https = require('https');
  18257. var url = require('url');
  18258. var fileUriRegex = /^file:\/\/\/[a-zA-Z]:\//;
  18259. function parseUrl(sourceUrl) {
  18260. var parsedUrl = url.parse(sourceUrl);
  18261. if (parsedUrl.protocol === 'file:' || parsedUrl.host) {
  18262. return parsedUrl;
  18263. }
  18264. if (/^[a-z]:[/\\]/i.test(sourceUrl)) {
  18265. return url.parse("file:///".concat(sourceUrl));
  18266. }
  18267. if (!parsedUrl.host) {
  18268. parsedUrl.protocol = 'file:';
  18269. }
  18270. return parsedUrl;
  18271. }
  18272. var PDFNodeStream =
  18273. /*#__PURE__*/
  18274. function () {
  18275. function PDFNodeStream(source) {
  18276. _classCallCheck(this, PDFNodeStream);
  18277. this.source = source;
  18278. this.url = parseUrl(source.url);
  18279. this.isHttp = this.url.protocol === 'http:' || this.url.protocol === 'https:';
  18280. this.isFsUrl = this.url.protocol === 'file:';
  18281. this.httpHeaders = this.isHttp && source.httpHeaders || {};
  18282. this._fullRequestReader = null;
  18283. this._rangeRequestReaders = [];
  18284. }
  18285. _createClass(PDFNodeStream, [{
  18286. key: "getFullReader",
  18287. value: function getFullReader() {
  18288. (0, _util.assert)(!this._fullRequestReader);
  18289. this._fullRequestReader = this.isFsUrl ? new PDFNodeStreamFsFullReader(this) : new PDFNodeStreamFullReader(this);
  18290. return this._fullRequestReader;
  18291. }
  18292. }, {
  18293. key: "getRangeReader",
  18294. value: function getRangeReader(start, end) {
  18295. if (end <= this._progressiveDataLength) {
  18296. return null;
  18297. }
  18298. var rangeReader = this.isFsUrl ? new PDFNodeStreamFsRangeReader(this, start, end) : new PDFNodeStreamRangeReader(this, start, end);
  18299. this._rangeRequestReaders.push(rangeReader);
  18300. return rangeReader;
  18301. }
  18302. }, {
  18303. key: "cancelAllRequests",
  18304. value: function cancelAllRequests(reason) {
  18305. if (this._fullRequestReader) {
  18306. this._fullRequestReader.cancel(reason);
  18307. }
  18308. var readers = this._rangeRequestReaders.slice(0);
  18309. readers.forEach(function (reader) {
  18310. reader.cancel(reason);
  18311. });
  18312. }
  18313. }, {
  18314. key: "_progressiveDataLength",
  18315. get: function get() {
  18316. return this._fullRequestReader ? this._fullRequestReader._loaded : 0;
  18317. }
  18318. }]);
  18319. return PDFNodeStream;
  18320. }();
  18321. exports.PDFNodeStream = PDFNodeStream;
  18322. var BaseFullReader =
  18323. /*#__PURE__*/
  18324. function () {
  18325. function BaseFullReader(stream) {
  18326. _classCallCheck(this, BaseFullReader);
  18327. this._url = stream.url;
  18328. this._done = false;
  18329. this._storedError = null;
  18330. this.onProgress = null;
  18331. var source = stream.source;
  18332. this._contentLength = source.length;
  18333. this._loaded = 0;
  18334. this._filename = null;
  18335. this._disableRange = source.disableRange || false;
  18336. this._rangeChunkSize = source.rangeChunkSize;
  18337. if (!this._rangeChunkSize && !this._disableRange) {
  18338. this._disableRange = true;
  18339. }
  18340. this._isStreamingSupported = !source.disableStream;
  18341. this._isRangeSupported = !source.disableRange;
  18342. this._readableStream = null;
  18343. this._readCapability = (0, _util.createPromiseCapability)();
  18344. this._headersCapability = (0, _util.createPromiseCapability)();
  18345. }
  18346. _createClass(BaseFullReader, [{
  18347. key: "read",
  18348. value: function () {
  18349. var _read = _asyncToGenerator(
  18350. /*#__PURE__*/
  18351. _regenerator["default"].mark(function _callee() {
  18352. var chunk, buffer;
  18353. return _regenerator["default"].wrap(function _callee$(_context) {
  18354. while (1) {
  18355. switch (_context.prev = _context.next) {
  18356. case 0:
  18357. _context.next = 2;
  18358. return this._readCapability.promise;
  18359. case 2:
  18360. if (!this._done) {
  18361. _context.next = 4;
  18362. break;
  18363. }
  18364. return _context.abrupt("return", {
  18365. value: undefined,
  18366. done: true
  18367. });
  18368. case 4:
  18369. if (!this._storedError) {
  18370. _context.next = 6;
  18371. break;
  18372. }
  18373. throw this._storedError;
  18374. case 6:
  18375. chunk = this._readableStream.read();
  18376. if (!(chunk === null)) {
  18377. _context.next = 10;
  18378. break;
  18379. }
  18380. this._readCapability = (0, _util.createPromiseCapability)();
  18381. return _context.abrupt("return", this.read());
  18382. case 10:
  18383. this._loaded += chunk.length;
  18384. if (this.onProgress) {
  18385. this.onProgress({
  18386. loaded: this._loaded,
  18387. total: this._contentLength
  18388. });
  18389. }
  18390. buffer = new Uint8Array(chunk).buffer;
  18391. return _context.abrupt("return", {
  18392. value: buffer,
  18393. done: false
  18394. });
  18395. case 14:
  18396. case "end":
  18397. return _context.stop();
  18398. }
  18399. }
  18400. }, _callee, this);
  18401. }));
  18402. function read() {
  18403. return _read.apply(this, arguments);
  18404. }
  18405. return read;
  18406. }()
  18407. }, {
  18408. key: "cancel",
  18409. value: function cancel(reason) {
  18410. if (!this._readableStream) {
  18411. this._error(reason);
  18412. return;
  18413. }
  18414. this._readableStream.destroy(reason);
  18415. }
  18416. }, {
  18417. key: "_error",
  18418. value: function _error(reason) {
  18419. this._storedError = reason;
  18420. this._readCapability.resolve();
  18421. }
  18422. }, {
  18423. key: "_setReadableStream",
  18424. value: function _setReadableStream(readableStream) {
  18425. var _this = this;
  18426. this._readableStream = readableStream;
  18427. readableStream.on('readable', function () {
  18428. _this._readCapability.resolve();
  18429. });
  18430. readableStream.on('end', function () {
  18431. readableStream.destroy();
  18432. _this._done = true;
  18433. _this._readCapability.resolve();
  18434. });
  18435. readableStream.on('error', function (reason) {
  18436. _this._error(reason);
  18437. });
  18438. if (!this._isStreamingSupported && this._isRangeSupported) {
  18439. this._error(new _util.AbortException('streaming is disabled'));
  18440. }
  18441. if (this._storedError) {
  18442. this._readableStream.destroy(this._storedError);
  18443. }
  18444. }
  18445. }, {
  18446. key: "headersReady",
  18447. get: function get() {
  18448. return this._headersCapability.promise;
  18449. }
  18450. }, {
  18451. key: "filename",
  18452. get: function get() {
  18453. return this._filename;
  18454. }
  18455. }, {
  18456. key: "contentLength",
  18457. get: function get() {
  18458. return this._contentLength;
  18459. }
  18460. }, {
  18461. key: "isRangeSupported",
  18462. get: function get() {
  18463. return this._isRangeSupported;
  18464. }
  18465. }, {
  18466. key: "isStreamingSupported",
  18467. get: function get() {
  18468. return this._isStreamingSupported;
  18469. }
  18470. }]);
  18471. return BaseFullReader;
  18472. }();
  18473. var BaseRangeReader =
  18474. /*#__PURE__*/
  18475. function () {
  18476. function BaseRangeReader(stream) {
  18477. _classCallCheck(this, BaseRangeReader);
  18478. this._url = stream.url;
  18479. this._done = false;
  18480. this._storedError = null;
  18481. this.onProgress = null;
  18482. this._loaded = 0;
  18483. this._readableStream = null;
  18484. this._readCapability = (0, _util.createPromiseCapability)();
  18485. var source = stream.source;
  18486. this._isStreamingSupported = !source.disableStream;
  18487. }
  18488. _createClass(BaseRangeReader, [{
  18489. key: "read",
  18490. value: function () {
  18491. var _read2 = _asyncToGenerator(
  18492. /*#__PURE__*/
  18493. _regenerator["default"].mark(function _callee2() {
  18494. var chunk, buffer;
  18495. return _regenerator["default"].wrap(function _callee2$(_context2) {
  18496. while (1) {
  18497. switch (_context2.prev = _context2.next) {
  18498. case 0:
  18499. _context2.next = 2;
  18500. return this._readCapability.promise;
  18501. case 2:
  18502. if (!this._done) {
  18503. _context2.next = 4;
  18504. break;
  18505. }
  18506. return _context2.abrupt("return", {
  18507. value: undefined,
  18508. done: true
  18509. });
  18510. case 4:
  18511. if (!this._storedError) {
  18512. _context2.next = 6;
  18513. break;
  18514. }
  18515. throw this._storedError;
  18516. case 6:
  18517. chunk = this._readableStream.read();
  18518. if (!(chunk === null)) {
  18519. _context2.next = 10;
  18520. break;
  18521. }
  18522. this._readCapability = (0, _util.createPromiseCapability)();
  18523. return _context2.abrupt("return", this.read());
  18524. case 10:
  18525. this._loaded += chunk.length;
  18526. if (this.onProgress) {
  18527. this.onProgress({
  18528. loaded: this._loaded
  18529. });
  18530. }
  18531. buffer = new Uint8Array(chunk).buffer;
  18532. return _context2.abrupt("return", {
  18533. value: buffer,
  18534. done: false
  18535. });
  18536. case 14:
  18537. case "end":
  18538. return _context2.stop();
  18539. }
  18540. }
  18541. }, _callee2, this);
  18542. }));
  18543. function read() {
  18544. return _read2.apply(this, arguments);
  18545. }
  18546. return read;
  18547. }()
  18548. }, {
  18549. key: "cancel",
  18550. value: function cancel(reason) {
  18551. if (!this._readableStream) {
  18552. this._error(reason);
  18553. return;
  18554. }
  18555. this._readableStream.destroy(reason);
  18556. }
  18557. }, {
  18558. key: "_error",
  18559. value: function _error(reason) {
  18560. this._storedError = reason;
  18561. this._readCapability.resolve();
  18562. }
  18563. }, {
  18564. key: "_setReadableStream",
  18565. value: function _setReadableStream(readableStream) {
  18566. var _this2 = this;
  18567. this._readableStream = readableStream;
  18568. readableStream.on('readable', function () {
  18569. _this2._readCapability.resolve();
  18570. });
  18571. readableStream.on('end', function () {
  18572. readableStream.destroy();
  18573. _this2._done = true;
  18574. _this2._readCapability.resolve();
  18575. });
  18576. readableStream.on('error', function (reason) {
  18577. _this2._error(reason);
  18578. });
  18579. if (this._storedError) {
  18580. this._readableStream.destroy(this._storedError);
  18581. }
  18582. }
  18583. }, {
  18584. key: "isStreamingSupported",
  18585. get: function get() {
  18586. return this._isStreamingSupported;
  18587. }
  18588. }]);
  18589. return BaseRangeReader;
  18590. }();
  18591. function createRequestOptions(url, headers) {
  18592. return {
  18593. protocol: url.protocol,
  18594. auth: url.auth,
  18595. host: url.hostname,
  18596. port: url.port,
  18597. path: url.path,
  18598. method: 'GET',
  18599. headers: headers
  18600. };
  18601. }
  18602. var PDFNodeStreamFullReader =
  18603. /*#__PURE__*/
  18604. function (_BaseFullReader) {
  18605. _inherits(PDFNodeStreamFullReader, _BaseFullReader);
  18606. function PDFNodeStreamFullReader(stream) {
  18607. var _this3;
  18608. _classCallCheck(this, PDFNodeStreamFullReader);
  18609. _this3 = _possibleConstructorReturn(this, _getPrototypeOf(PDFNodeStreamFullReader).call(this, stream));
  18610. var handleResponse = function handleResponse(response) {
  18611. if (response.statusCode === 404) {
  18612. var error = new _util.MissingPDFException("Missing PDF \"".concat(_this3._url, "\"."));
  18613. _this3._storedError = error;
  18614. _this3._headersCapability.reject(error);
  18615. return;
  18616. }
  18617. _this3._headersCapability.resolve();
  18618. _this3._setReadableStream(response);
  18619. var getResponseHeader = function getResponseHeader(name) {
  18620. return _this3._readableStream.headers[name.toLowerCase()];
  18621. };
  18622. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  18623. getResponseHeader: getResponseHeader,
  18624. isHttp: stream.isHttp,
  18625. rangeChunkSize: _this3._rangeChunkSize,
  18626. disableRange: _this3._disableRange
  18627. }),
  18628. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  18629. suggestedLength = _validateRangeRequest.suggestedLength;
  18630. _this3._isRangeSupported = allowRangeRequests;
  18631. _this3._contentLength = suggestedLength || _this3._contentLength;
  18632. _this3._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  18633. };
  18634. _this3._request = null;
  18635. if (_this3._url.protocol === 'http:') {
  18636. _this3._request = http.request(createRequestOptions(_this3._url, stream.httpHeaders), handleResponse);
  18637. } else {
  18638. _this3._request = https.request(createRequestOptions(_this3._url, stream.httpHeaders), handleResponse);
  18639. }
  18640. _this3._request.on('error', function (reason) {
  18641. _this3._storedError = reason;
  18642. _this3._headersCapability.reject(reason);
  18643. });
  18644. _this3._request.end();
  18645. return _this3;
  18646. }
  18647. return PDFNodeStreamFullReader;
  18648. }(BaseFullReader);
  18649. var PDFNodeStreamRangeReader =
  18650. /*#__PURE__*/
  18651. function (_BaseRangeReader) {
  18652. _inherits(PDFNodeStreamRangeReader, _BaseRangeReader);
  18653. function PDFNodeStreamRangeReader(stream, start, end) {
  18654. var _this4;
  18655. _classCallCheck(this, PDFNodeStreamRangeReader);
  18656. _this4 = _possibleConstructorReturn(this, _getPrototypeOf(PDFNodeStreamRangeReader).call(this, stream));
  18657. _this4._httpHeaders = {};
  18658. for (var property in stream.httpHeaders) {
  18659. var value = stream.httpHeaders[property];
  18660. if (typeof value === 'undefined') {
  18661. continue;
  18662. }
  18663. _this4._httpHeaders[property] = value;
  18664. }
  18665. _this4._httpHeaders['Range'] = "bytes=".concat(start, "-").concat(end - 1);
  18666. var handleResponse = function handleResponse(response) {
  18667. if (response.statusCode === 404) {
  18668. var error = new _util.MissingPDFException("Missing PDF \"".concat(_this4._url, "\"."));
  18669. _this4._storedError = error;
  18670. return;
  18671. }
  18672. _this4._setReadableStream(response);
  18673. };
  18674. _this4._request = null;
  18675. if (_this4._url.protocol === 'http:') {
  18676. _this4._request = http.request(createRequestOptions(_this4._url, _this4._httpHeaders), handleResponse);
  18677. } else {
  18678. _this4._request = https.request(createRequestOptions(_this4._url, _this4._httpHeaders), handleResponse);
  18679. }
  18680. _this4._request.on('error', function (reason) {
  18681. _this4._storedError = reason;
  18682. });
  18683. _this4._request.end();
  18684. return _this4;
  18685. }
  18686. return PDFNodeStreamRangeReader;
  18687. }(BaseRangeReader);
  18688. var PDFNodeStreamFsFullReader =
  18689. /*#__PURE__*/
  18690. function (_BaseFullReader2) {
  18691. _inherits(PDFNodeStreamFsFullReader, _BaseFullReader2);
  18692. function PDFNodeStreamFsFullReader(stream) {
  18693. var _this5;
  18694. _classCallCheck(this, PDFNodeStreamFsFullReader);
  18695. _this5 = _possibleConstructorReturn(this, _getPrototypeOf(PDFNodeStreamFsFullReader).call(this, stream));
  18696. var path = decodeURIComponent(_this5._url.path);
  18697. if (fileUriRegex.test(_this5._url.href)) {
  18698. path = path.replace(/^\//, '');
  18699. }
  18700. fs.lstat(path, function (error, stat) {
  18701. if (error) {
  18702. if (error.code === 'ENOENT') {
  18703. error = new _util.MissingPDFException("Missing PDF \"".concat(path, "\"."));
  18704. }
  18705. _this5._storedError = error;
  18706. _this5._headersCapability.reject(error);
  18707. return;
  18708. }
  18709. _this5._contentLength = stat.size;
  18710. _this5._setReadableStream(fs.createReadStream(path));
  18711. _this5._headersCapability.resolve();
  18712. });
  18713. return _this5;
  18714. }
  18715. return PDFNodeStreamFsFullReader;
  18716. }(BaseFullReader);
  18717. var PDFNodeStreamFsRangeReader =
  18718. /*#__PURE__*/
  18719. function (_BaseRangeReader2) {
  18720. _inherits(PDFNodeStreamFsRangeReader, _BaseRangeReader2);
  18721. function PDFNodeStreamFsRangeReader(stream, start, end) {
  18722. var _this6;
  18723. _classCallCheck(this, PDFNodeStreamFsRangeReader);
  18724. _this6 = _possibleConstructorReturn(this, _getPrototypeOf(PDFNodeStreamFsRangeReader).call(this, stream));
  18725. var path = decodeURIComponent(_this6._url.path);
  18726. if (fileUriRegex.test(_this6._url.href)) {
  18727. path = path.replace(/^\//, '');
  18728. }
  18729. _this6._setReadableStream(fs.createReadStream(path, {
  18730. start: start,
  18731. end: end - 1
  18732. }));
  18733. return _this6;
  18734. }
  18735. return PDFNodeStreamFsRangeReader;
  18736. }(BaseRangeReader);
  18737. /***/ }),
  18738. /* 166 */
  18739. /***/ (function(module, exports, __w_pdfjs_require__) {
  18740. "use strict";
  18741. Object.defineProperty(exports, "__esModule", {
  18742. value: true
  18743. });
  18744. exports.createResponseStatusError = createResponseStatusError;
  18745. exports.extractFilenameFromHeader = extractFilenameFromHeader;
  18746. exports.validateRangeRequestCapabilities = validateRangeRequestCapabilities;
  18747. exports.validateResponseStatus = validateResponseStatus;
  18748. var _util = __w_pdfjs_require__(1);
  18749. var _content_disposition = __w_pdfjs_require__(167);
  18750. function validateRangeRequestCapabilities(_ref) {
  18751. var getResponseHeader = _ref.getResponseHeader,
  18752. isHttp = _ref.isHttp,
  18753. rangeChunkSize = _ref.rangeChunkSize,
  18754. disableRange = _ref.disableRange;
  18755. (0, _util.assert)(rangeChunkSize > 0, 'Range chunk size must be larger than zero');
  18756. var returnValues = {
  18757. allowRangeRequests: false,
  18758. suggestedLength: undefined
  18759. };
  18760. var length = parseInt(getResponseHeader('Content-Length'), 10);
  18761. if (!Number.isInteger(length)) {
  18762. return returnValues;
  18763. }
  18764. returnValues.suggestedLength = length;
  18765. if (length <= 2 * rangeChunkSize) {
  18766. return returnValues;
  18767. }
  18768. if (disableRange || !isHttp) {
  18769. return returnValues;
  18770. }
  18771. if (getResponseHeader('Accept-Ranges') !== 'bytes') {
  18772. return returnValues;
  18773. }
  18774. var contentEncoding = getResponseHeader('Content-Encoding') || 'identity';
  18775. if (contentEncoding !== 'identity') {
  18776. return returnValues;
  18777. }
  18778. returnValues.allowRangeRequests = true;
  18779. return returnValues;
  18780. }
  18781. function extractFilenameFromHeader(getResponseHeader) {
  18782. var contentDisposition = getResponseHeader('Content-Disposition');
  18783. if (contentDisposition) {
  18784. var filename = (0, _content_disposition.getFilenameFromContentDispositionHeader)(contentDisposition);
  18785. if (/\.pdf$/i.test(filename)) {
  18786. return filename;
  18787. }
  18788. }
  18789. return null;
  18790. }
  18791. function createResponseStatusError(status, url) {
  18792. if (status === 404 || status === 0 && /^file:/.test(url)) {
  18793. return new _util.MissingPDFException('Missing PDF "' + url + '".');
  18794. }
  18795. return new _util.UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  18796. }
  18797. function validateResponseStatus(status) {
  18798. return status === 200 || status === 206;
  18799. }
  18800. /***/ }),
  18801. /* 167 */
  18802. /***/ (function(module, exports, __w_pdfjs_require__) {
  18803. "use strict";
  18804. Object.defineProperty(exports, "__esModule", {
  18805. value: true
  18806. });
  18807. exports.getFilenameFromContentDispositionHeader = getFilenameFromContentDispositionHeader;
  18808. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  18809. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  18810. function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  18811. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  18812. function getFilenameFromContentDispositionHeader(contentDisposition) {
  18813. var needsEncodingFixup = true;
  18814. var tmp = toParamRegExp('filename\\*', 'i').exec(contentDisposition);
  18815. if (tmp) {
  18816. tmp = tmp[1];
  18817. var filename = rfc2616unquote(tmp);
  18818. filename = unescape(filename);
  18819. filename = rfc5987decode(filename);
  18820. filename = rfc2047decode(filename);
  18821. return fixupEncoding(filename);
  18822. }
  18823. tmp = rfc2231getparam(contentDisposition);
  18824. if (tmp) {
  18825. var _filename = rfc2047decode(tmp);
  18826. return fixupEncoding(_filename);
  18827. }
  18828. tmp = toParamRegExp('filename', 'i').exec(contentDisposition);
  18829. if (tmp) {
  18830. tmp = tmp[1];
  18831. var _filename2 = rfc2616unquote(tmp);
  18832. _filename2 = rfc2047decode(_filename2);
  18833. return fixupEncoding(_filename2);
  18834. }
  18835. function toParamRegExp(attributePattern, flags) {
  18836. return new RegExp('(?:^|;)\\s*' + attributePattern + '\\s*=\\s*' + '(' + '[^";\\s][^;\\s]*' + '|' + '"(?:[^"\\\\]|\\\\"?)+"?' + ')', flags);
  18837. }
  18838. function textdecode(encoding, value) {
  18839. if (encoding) {
  18840. if (!/^[\x00-\xFF]+$/.test(value)) {
  18841. return value;
  18842. }
  18843. try {
  18844. var decoder = new TextDecoder(encoding, {
  18845. fatal: true
  18846. });
  18847. var bytes = Array.from(value, function (ch) {
  18848. return ch.charCodeAt(0) & 0xFF;
  18849. });
  18850. value = decoder.decode(new Uint8Array(bytes));
  18851. needsEncodingFixup = false;
  18852. } catch (e) {
  18853. if (/^utf-?8$/i.test(encoding)) {
  18854. try {
  18855. value = decodeURIComponent(escape(value));
  18856. needsEncodingFixup = false;
  18857. } catch (err) {}
  18858. }
  18859. }
  18860. }
  18861. return value;
  18862. }
  18863. function fixupEncoding(value) {
  18864. if (needsEncodingFixup && /[\x80-\xff]/.test(value)) {
  18865. value = textdecode('utf-8', value);
  18866. if (needsEncodingFixup) {
  18867. value = textdecode('iso-8859-1', value);
  18868. }
  18869. }
  18870. return value;
  18871. }
  18872. function rfc2231getparam(contentDisposition) {
  18873. var matches = [],
  18874. match;
  18875. var iter = toParamRegExp('filename\\*((?!0\\d)\\d+)(\\*?)', 'ig');
  18876. while ((match = iter.exec(contentDisposition)) !== null) {
  18877. var _match = match,
  18878. _match2 = _slicedToArray(_match, 4),
  18879. n = _match2[1],
  18880. quot = _match2[2],
  18881. part = _match2[3];
  18882. n = parseInt(n, 10);
  18883. if (n in matches) {
  18884. if (n === 0) {
  18885. break;
  18886. }
  18887. continue;
  18888. }
  18889. matches[n] = [quot, part];
  18890. }
  18891. var parts = [];
  18892. for (var n = 0; n < matches.length; ++n) {
  18893. if (!(n in matches)) {
  18894. break;
  18895. }
  18896. var _matches$n = _slicedToArray(matches[n], 2),
  18897. quot = _matches$n[0],
  18898. part = _matches$n[1];
  18899. part = rfc2616unquote(part);
  18900. if (quot) {
  18901. part = unescape(part);
  18902. if (n === 0) {
  18903. part = rfc5987decode(part);
  18904. }
  18905. }
  18906. parts.push(part);
  18907. }
  18908. return parts.join('');
  18909. }
  18910. function rfc2616unquote(value) {
  18911. if (value.startsWith('"')) {
  18912. var parts = value.slice(1).split('\\"');
  18913. for (var i = 0; i < parts.length; ++i) {
  18914. var quotindex = parts[i].indexOf('"');
  18915. if (quotindex !== -1) {
  18916. parts[i] = parts[i].slice(0, quotindex);
  18917. parts.length = i + 1;
  18918. }
  18919. parts[i] = parts[i].replace(/\\(.)/g, '$1');
  18920. }
  18921. value = parts.join('"');
  18922. }
  18923. return value;
  18924. }
  18925. function rfc5987decode(extvalue) {
  18926. var encodingend = extvalue.indexOf('\'');
  18927. if (encodingend === -1) {
  18928. return extvalue;
  18929. }
  18930. var encoding = extvalue.slice(0, encodingend);
  18931. var langvalue = extvalue.slice(encodingend + 1);
  18932. var value = langvalue.replace(/^[^']*'/, '');
  18933. return textdecode(encoding, value);
  18934. }
  18935. function rfc2047decode(value) {
  18936. if (!value.startsWith('=?') || /[\x00-\x19\x80-\xff]/.test(value)) {
  18937. return value;
  18938. }
  18939. return value.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g, function (_, charset, encoding, text) {
  18940. if (encoding === 'q' || encoding === 'Q') {
  18941. text = text.replace(/_/g, ' ');
  18942. text = text.replace(/=([0-9a-fA-F]{2})/g, function (_, hex) {
  18943. return String.fromCharCode(parseInt(hex, 16));
  18944. });
  18945. return textdecode(charset, text);
  18946. }
  18947. try {
  18948. text = atob(text);
  18949. } catch (e) {}
  18950. return textdecode(charset, text);
  18951. });
  18952. }
  18953. return '';
  18954. }
  18955. /***/ }),
  18956. /* 168 */
  18957. /***/ (function(module, exports, __w_pdfjs_require__) {
  18958. "use strict";
  18959. Object.defineProperty(exports, "__esModule", {
  18960. value: true
  18961. });
  18962. exports.PDFNetworkStream = void 0;
  18963. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(148));
  18964. var _util = __w_pdfjs_require__(1);
  18965. var _network_utils = __w_pdfjs_require__(166);
  18966. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18967. 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); } }
  18968. 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); }); }; }
  18969. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18970. 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); } }
  18971. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  18972. ;
  18973. var OK_RESPONSE = 200;
  18974. var PARTIAL_CONTENT_RESPONSE = 206;
  18975. function getArrayBuffer(xhr) {
  18976. var data = xhr.response;
  18977. if (typeof data !== 'string') {
  18978. return data;
  18979. }
  18980. var array = (0, _util.stringToBytes)(data);
  18981. return array.buffer;
  18982. }
  18983. var NetworkManager =
  18984. /*#__PURE__*/
  18985. function () {
  18986. function NetworkManager(url, args) {
  18987. _classCallCheck(this, NetworkManager);
  18988. this.url = url;
  18989. args = args || {};
  18990. this.isHttp = /^https?:/i.test(url);
  18991. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  18992. this.withCredentials = args.withCredentials || false;
  18993. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  18994. return new XMLHttpRequest();
  18995. };
  18996. this.currXhrId = 0;
  18997. this.pendingRequests = Object.create(null);
  18998. }
  18999. _createClass(NetworkManager, [{
  19000. key: "requestRange",
  19001. value: function requestRange(begin, end, listeners) {
  19002. var args = {
  19003. begin: begin,
  19004. end: end
  19005. };
  19006. for (var prop in listeners) {
  19007. args[prop] = listeners[prop];
  19008. }
  19009. return this.request(args);
  19010. }
  19011. }, {
  19012. key: "requestFull",
  19013. value: function requestFull(listeners) {
  19014. return this.request(listeners);
  19015. }
  19016. }, {
  19017. key: "request",
  19018. value: function request(args) {
  19019. var xhr = this.getXhr();
  19020. var xhrId = this.currXhrId++;
  19021. var pendingRequest = this.pendingRequests[xhrId] = {
  19022. xhr: xhr
  19023. };
  19024. xhr.open('GET', this.url);
  19025. xhr.withCredentials = this.withCredentials;
  19026. for (var property in this.httpHeaders) {
  19027. var value = this.httpHeaders[property];
  19028. if (typeof value === 'undefined') {
  19029. continue;
  19030. }
  19031. xhr.setRequestHeader(property, value);
  19032. }
  19033. if (this.isHttp && 'begin' in args && 'end' in args) {
  19034. xhr.setRequestHeader('Range', "bytes=".concat(args.begin, "-").concat(args.end - 1));
  19035. pendingRequest.expectedStatus = PARTIAL_CONTENT_RESPONSE;
  19036. } else {
  19037. pendingRequest.expectedStatus = OK_RESPONSE;
  19038. }
  19039. xhr.responseType = 'arraybuffer';
  19040. if (args.onError) {
  19041. xhr.onerror = function (evt) {
  19042. args.onError(xhr.status);
  19043. };
  19044. }
  19045. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  19046. xhr.onprogress = this.onProgress.bind(this, xhrId);
  19047. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  19048. pendingRequest.onDone = args.onDone;
  19049. pendingRequest.onError = args.onError;
  19050. pendingRequest.onProgress = args.onProgress;
  19051. xhr.send(null);
  19052. return xhrId;
  19053. }
  19054. }, {
  19055. key: "onProgress",
  19056. value: function onProgress(xhrId, evt) {
  19057. var pendingRequest = this.pendingRequests[xhrId];
  19058. if (!pendingRequest) {
  19059. return;
  19060. }
  19061. if (pendingRequest.onProgress) {
  19062. pendingRequest.onProgress(evt);
  19063. }
  19064. }
  19065. }, {
  19066. key: "onStateChange",
  19067. value: function onStateChange(xhrId, evt) {
  19068. var pendingRequest = this.pendingRequests[xhrId];
  19069. if (!pendingRequest) {
  19070. return;
  19071. }
  19072. var xhr = pendingRequest.xhr;
  19073. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  19074. pendingRequest.onHeadersReceived();
  19075. delete pendingRequest.onHeadersReceived;
  19076. }
  19077. if (xhr.readyState !== 4) {
  19078. return;
  19079. }
  19080. if (!(xhrId in this.pendingRequests)) {
  19081. return;
  19082. }
  19083. delete this.pendingRequests[xhrId];
  19084. if (xhr.status === 0 && this.isHttp) {
  19085. if (pendingRequest.onError) {
  19086. pendingRequest.onError(xhr.status);
  19087. }
  19088. return;
  19089. }
  19090. var xhrStatus = xhr.status || OK_RESPONSE;
  19091. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  19092. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  19093. if (pendingRequest.onError) {
  19094. pendingRequest.onError(xhr.status);
  19095. }
  19096. return;
  19097. }
  19098. var chunk = getArrayBuffer(xhr);
  19099. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  19100. var rangeHeader = xhr.getResponseHeader('Content-Range');
  19101. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  19102. pendingRequest.onDone({
  19103. begin: parseInt(matches[1], 10),
  19104. chunk: chunk
  19105. });
  19106. } else if (chunk) {
  19107. pendingRequest.onDone({
  19108. begin: 0,
  19109. chunk: chunk
  19110. });
  19111. } else if (pendingRequest.onError) {
  19112. pendingRequest.onError(xhr.status);
  19113. }
  19114. }
  19115. }, {
  19116. key: "hasPendingRequests",
  19117. value: function hasPendingRequests() {
  19118. for (var xhrId in this.pendingRequests) {
  19119. return true;
  19120. }
  19121. return false;
  19122. }
  19123. }, {
  19124. key: "getRequestXhr",
  19125. value: function getRequestXhr(xhrId) {
  19126. return this.pendingRequests[xhrId].xhr;
  19127. }
  19128. }, {
  19129. key: "isPendingRequest",
  19130. value: function isPendingRequest(xhrId) {
  19131. return xhrId in this.pendingRequests;
  19132. }
  19133. }, {
  19134. key: "abortAllRequests",
  19135. value: function abortAllRequests() {
  19136. for (var xhrId in this.pendingRequests) {
  19137. this.abortRequest(xhrId | 0);
  19138. }
  19139. }
  19140. }, {
  19141. key: "abortRequest",
  19142. value: function abortRequest(xhrId) {
  19143. var xhr = this.pendingRequests[xhrId].xhr;
  19144. delete this.pendingRequests[xhrId];
  19145. xhr.abort();
  19146. }
  19147. }]);
  19148. return NetworkManager;
  19149. }();
  19150. var PDFNetworkStream =
  19151. /*#__PURE__*/
  19152. function () {
  19153. function PDFNetworkStream(source) {
  19154. _classCallCheck(this, PDFNetworkStream);
  19155. this._source = source;
  19156. this._manager = new NetworkManager(source.url, {
  19157. httpHeaders: source.httpHeaders,
  19158. withCredentials: source.withCredentials
  19159. });
  19160. this._rangeChunkSize = source.rangeChunkSize;
  19161. this._fullRequestReader = null;
  19162. this._rangeRequestReaders = [];
  19163. }
  19164. _createClass(PDFNetworkStream, [{
  19165. key: "_onRangeRequestReaderClosed",
  19166. value: function _onRangeRequestReaderClosed(reader) {
  19167. var i = this._rangeRequestReaders.indexOf(reader);
  19168. if (i >= 0) {
  19169. this._rangeRequestReaders.splice(i, 1);
  19170. }
  19171. }
  19172. }, {
  19173. key: "getFullReader",
  19174. value: function getFullReader() {
  19175. (0, _util.assert)(!this._fullRequestReader);
  19176. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._source);
  19177. return this._fullRequestReader;
  19178. }
  19179. }, {
  19180. key: "getRangeReader",
  19181. value: function getRangeReader(begin, end) {
  19182. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  19183. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  19184. this._rangeRequestReaders.push(reader);
  19185. return reader;
  19186. }
  19187. }, {
  19188. key: "cancelAllRequests",
  19189. value: function cancelAllRequests(reason) {
  19190. if (this._fullRequestReader) {
  19191. this._fullRequestReader.cancel(reason);
  19192. }
  19193. var readers = this._rangeRequestReaders.slice(0);
  19194. readers.forEach(function (reader) {
  19195. reader.cancel(reason);
  19196. });
  19197. }
  19198. }]);
  19199. return PDFNetworkStream;
  19200. }();
  19201. exports.PDFNetworkStream = PDFNetworkStream;
  19202. var PDFNetworkStreamFullRequestReader =
  19203. /*#__PURE__*/
  19204. function () {
  19205. function PDFNetworkStreamFullRequestReader(manager, source) {
  19206. _classCallCheck(this, PDFNetworkStreamFullRequestReader);
  19207. this._manager = manager;
  19208. var args = {
  19209. onHeadersReceived: this._onHeadersReceived.bind(this),
  19210. onDone: this._onDone.bind(this),
  19211. onError: this._onError.bind(this),
  19212. onProgress: this._onProgress.bind(this)
  19213. };
  19214. this._url = source.url;
  19215. this._fullRequestId = manager.requestFull(args);
  19216. this._headersReceivedCapability = (0, _util.createPromiseCapability)();
  19217. this._disableRange = source.disableRange || false;
  19218. this._contentLength = source.length;
  19219. this._rangeChunkSize = source.rangeChunkSize;
  19220. if (!this._rangeChunkSize && !this._disableRange) {
  19221. this._disableRange = true;
  19222. }
  19223. this._isStreamingSupported = false;
  19224. this._isRangeSupported = false;
  19225. this._cachedChunks = [];
  19226. this._requests = [];
  19227. this._done = false;
  19228. this._storedError = undefined;
  19229. this._filename = null;
  19230. this.onProgress = null;
  19231. }
  19232. _createClass(PDFNetworkStreamFullRequestReader, [{
  19233. key: "_onHeadersReceived",
  19234. value: function _onHeadersReceived() {
  19235. var fullRequestXhrId = this._fullRequestId;
  19236. var fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);
  19237. var getResponseHeader = function getResponseHeader(name) {
  19238. return fullRequestXhr.getResponseHeader(name);
  19239. };
  19240. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  19241. getResponseHeader: getResponseHeader,
  19242. isHttp: this._manager.isHttp,
  19243. rangeChunkSize: this._rangeChunkSize,
  19244. disableRange: this._disableRange
  19245. }),
  19246. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  19247. suggestedLength = _validateRangeRequest.suggestedLength;
  19248. if (allowRangeRequests) {
  19249. this._isRangeSupported = true;
  19250. }
  19251. this._contentLength = suggestedLength || this._contentLength;
  19252. this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  19253. if (this._isRangeSupported) {
  19254. this._manager.abortRequest(fullRequestXhrId);
  19255. }
  19256. this._headersReceivedCapability.resolve();
  19257. }
  19258. }, {
  19259. key: "_onDone",
  19260. value: function _onDone(args) {
  19261. if (args) {
  19262. if (this._requests.length > 0) {
  19263. var requestCapability = this._requests.shift();
  19264. requestCapability.resolve({
  19265. value: args.chunk,
  19266. done: false
  19267. });
  19268. } else {
  19269. this._cachedChunks.push(args.chunk);
  19270. }
  19271. }
  19272. this._done = true;
  19273. if (this._cachedChunks.length > 0) {
  19274. return;
  19275. }
  19276. this._requests.forEach(function (requestCapability) {
  19277. requestCapability.resolve({
  19278. value: undefined,
  19279. done: true
  19280. });
  19281. });
  19282. this._requests = [];
  19283. }
  19284. }, {
  19285. key: "_onError",
  19286. value: function _onError(status) {
  19287. var url = this._url;
  19288. var exception = (0, _network_utils.createResponseStatusError)(status, url);
  19289. this._storedError = exception;
  19290. this._headersReceivedCapability.reject(exception);
  19291. this._requests.forEach(function (requestCapability) {
  19292. requestCapability.reject(exception);
  19293. });
  19294. this._requests = [];
  19295. this._cachedChunks = [];
  19296. }
  19297. }, {
  19298. key: "_onProgress",
  19299. value: function _onProgress(data) {
  19300. if (this.onProgress) {
  19301. this.onProgress({
  19302. loaded: data.loaded,
  19303. total: data.lengthComputable ? data.total : this._contentLength
  19304. });
  19305. }
  19306. }
  19307. }, {
  19308. key: "read",
  19309. value: function () {
  19310. var _read = _asyncToGenerator(
  19311. /*#__PURE__*/
  19312. _regenerator["default"].mark(function _callee() {
  19313. var chunk, requestCapability;
  19314. return _regenerator["default"].wrap(function _callee$(_context) {
  19315. while (1) {
  19316. switch (_context.prev = _context.next) {
  19317. case 0:
  19318. if (!this._storedError) {
  19319. _context.next = 2;
  19320. break;
  19321. }
  19322. throw this._storedError;
  19323. case 2:
  19324. if (!(this._cachedChunks.length > 0)) {
  19325. _context.next = 5;
  19326. break;
  19327. }
  19328. chunk = this._cachedChunks.shift();
  19329. return _context.abrupt("return", {
  19330. value: chunk,
  19331. done: false
  19332. });
  19333. case 5:
  19334. if (!this._done) {
  19335. _context.next = 7;
  19336. break;
  19337. }
  19338. return _context.abrupt("return", {
  19339. value: undefined,
  19340. done: true
  19341. });
  19342. case 7:
  19343. requestCapability = (0, _util.createPromiseCapability)();
  19344. this._requests.push(requestCapability);
  19345. return _context.abrupt("return", requestCapability.promise);
  19346. case 10:
  19347. case "end":
  19348. return _context.stop();
  19349. }
  19350. }
  19351. }, _callee, this);
  19352. }));
  19353. function read() {
  19354. return _read.apply(this, arguments);
  19355. }
  19356. return read;
  19357. }()
  19358. }, {
  19359. key: "cancel",
  19360. value: function cancel(reason) {
  19361. this._done = true;
  19362. this._headersReceivedCapability.reject(reason);
  19363. this._requests.forEach(function (requestCapability) {
  19364. requestCapability.resolve({
  19365. value: undefined,
  19366. done: true
  19367. });
  19368. });
  19369. this._requests = [];
  19370. if (this._manager.isPendingRequest(this._fullRequestId)) {
  19371. this._manager.abortRequest(this._fullRequestId);
  19372. }
  19373. this._fullRequestReader = null;
  19374. }
  19375. }, {
  19376. key: "filename",
  19377. get: function get() {
  19378. return this._filename;
  19379. }
  19380. }, {
  19381. key: "isRangeSupported",
  19382. get: function get() {
  19383. return this._isRangeSupported;
  19384. }
  19385. }, {
  19386. key: "isStreamingSupported",
  19387. get: function get() {
  19388. return this._isStreamingSupported;
  19389. }
  19390. }, {
  19391. key: "contentLength",
  19392. get: function get() {
  19393. return this._contentLength;
  19394. }
  19395. }, {
  19396. key: "headersReady",
  19397. get: function get() {
  19398. return this._headersReceivedCapability.promise;
  19399. }
  19400. }]);
  19401. return PDFNetworkStreamFullRequestReader;
  19402. }();
  19403. var PDFNetworkStreamRangeRequestReader =
  19404. /*#__PURE__*/
  19405. function () {
  19406. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  19407. _classCallCheck(this, PDFNetworkStreamRangeRequestReader);
  19408. this._manager = manager;
  19409. var args = {
  19410. onDone: this._onDone.bind(this),
  19411. onProgress: this._onProgress.bind(this)
  19412. };
  19413. this._requestId = manager.requestRange(begin, end, args);
  19414. this._requests = [];
  19415. this._queuedChunk = null;
  19416. this._done = false;
  19417. this.onProgress = null;
  19418. this.onClosed = null;
  19419. }
  19420. _createClass(PDFNetworkStreamRangeRequestReader, [{
  19421. key: "_close",
  19422. value: function _close() {
  19423. if (this.onClosed) {
  19424. this.onClosed(this);
  19425. }
  19426. }
  19427. }, {
  19428. key: "_onDone",
  19429. value: function _onDone(data) {
  19430. var chunk = data.chunk;
  19431. if (this._requests.length > 0) {
  19432. var requestCapability = this._requests.shift();
  19433. requestCapability.resolve({
  19434. value: chunk,
  19435. done: false
  19436. });
  19437. } else {
  19438. this._queuedChunk = chunk;
  19439. }
  19440. this._done = true;
  19441. this._requests.forEach(function (requestCapability) {
  19442. requestCapability.resolve({
  19443. value: undefined,
  19444. done: true
  19445. });
  19446. });
  19447. this._requests = [];
  19448. this._close();
  19449. }
  19450. }, {
  19451. key: "_onProgress",
  19452. value: function _onProgress(evt) {
  19453. if (!this.isStreamingSupported && this.onProgress) {
  19454. this.onProgress({
  19455. loaded: evt.loaded
  19456. });
  19457. }
  19458. }
  19459. }, {
  19460. key: "read",
  19461. value: function () {
  19462. var _read2 = _asyncToGenerator(
  19463. /*#__PURE__*/
  19464. _regenerator["default"].mark(function _callee2() {
  19465. var chunk, requestCapability;
  19466. return _regenerator["default"].wrap(function _callee2$(_context2) {
  19467. while (1) {
  19468. switch (_context2.prev = _context2.next) {
  19469. case 0:
  19470. if (!(this._queuedChunk !== null)) {
  19471. _context2.next = 4;
  19472. break;
  19473. }
  19474. chunk = this._queuedChunk;
  19475. this._queuedChunk = null;
  19476. return _context2.abrupt("return", {
  19477. value: chunk,
  19478. done: false
  19479. });
  19480. case 4:
  19481. if (!this._done) {
  19482. _context2.next = 6;
  19483. break;
  19484. }
  19485. return _context2.abrupt("return", {
  19486. value: undefined,
  19487. done: true
  19488. });
  19489. case 6:
  19490. requestCapability = (0, _util.createPromiseCapability)();
  19491. this._requests.push(requestCapability);
  19492. return _context2.abrupt("return", requestCapability.promise);
  19493. case 9:
  19494. case "end":
  19495. return _context2.stop();
  19496. }
  19497. }
  19498. }, _callee2, this);
  19499. }));
  19500. function read() {
  19501. return _read2.apply(this, arguments);
  19502. }
  19503. return read;
  19504. }()
  19505. }, {
  19506. key: "cancel",
  19507. value: function cancel(reason) {
  19508. this._done = true;
  19509. this._requests.forEach(function (requestCapability) {
  19510. requestCapability.resolve({
  19511. value: undefined,
  19512. done: true
  19513. });
  19514. });
  19515. this._requests = [];
  19516. if (this._manager.isPendingRequest(this._requestId)) {
  19517. this._manager.abortRequest(this._requestId);
  19518. }
  19519. this._close();
  19520. }
  19521. }, {
  19522. key: "isStreamingSupported",
  19523. get: function get() {
  19524. return false;
  19525. }
  19526. }]);
  19527. return PDFNetworkStreamRangeRequestReader;
  19528. }();
  19529. /***/ }),
  19530. /* 169 */
  19531. /***/ (function(module, exports, __w_pdfjs_require__) {
  19532. "use strict";
  19533. Object.defineProperty(exports, "__esModule", {
  19534. value: true
  19535. });
  19536. exports.PDFFetchStream = void 0;
  19537. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(148));
  19538. var _util = __w_pdfjs_require__(1);
  19539. var _network_utils = __w_pdfjs_require__(166);
  19540. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  19541. 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); } }
  19542. 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); }); }; }
  19543. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  19544. 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); } }
  19545. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  19546. function createFetchOptions(headers, withCredentials, abortController) {
  19547. return {
  19548. method: 'GET',
  19549. headers: headers,
  19550. signal: abortController && abortController.signal,
  19551. mode: 'cors',
  19552. credentials: withCredentials ? 'include' : 'same-origin',
  19553. redirect: 'follow'
  19554. };
  19555. }
  19556. var PDFFetchStream =
  19557. /*#__PURE__*/
  19558. function () {
  19559. function PDFFetchStream(source) {
  19560. _classCallCheck(this, PDFFetchStream);
  19561. this.source = source;
  19562. this.isHttp = /^https?:/i.test(source.url);
  19563. this.httpHeaders = this.isHttp && source.httpHeaders || {};
  19564. this._fullRequestReader = null;
  19565. this._rangeRequestReaders = [];
  19566. }
  19567. _createClass(PDFFetchStream, [{
  19568. key: "getFullReader",
  19569. value: function getFullReader() {
  19570. (0, _util.assert)(!this._fullRequestReader);
  19571. this._fullRequestReader = new PDFFetchStreamReader(this);
  19572. return this._fullRequestReader;
  19573. }
  19574. }, {
  19575. key: "getRangeReader",
  19576. value: function getRangeReader(begin, end) {
  19577. if (end <= this._progressiveDataLength) {
  19578. return null;
  19579. }
  19580. var reader = new PDFFetchStreamRangeReader(this, begin, end);
  19581. this._rangeRequestReaders.push(reader);
  19582. return reader;
  19583. }
  19584. }, {
  19585. key: "cancelAllRequests",
  19586. value: function cancelAllRequests(reason) {
  19587. if (this._fullRequestReader) {
  19588. this._fullRequestReader.cancel(reason);
  19589. }
  19590. var readers = this._rangeRequestReaders.slice(0);
  19591. readers.forEach(function (reader) {
  19592. reader.cancel(reason);
  19593. });
  19594. }
  19595. }, {
  19596. key: "_progressiveDataLength",
  19597. get: function get() {
  19598. return this._fullRequestReader ? this._fullRequestReader._loaded : 0;
  19599. }
  19600. }]);
  19601. return PDFFetchStream;
  19602. }();
  19603. exports.PDFFetchStream = PDFFetchStream;
  19604. var PDFFetchStreamReader =
  19605. /*#__PURE__*/
  19606. function () {
  19607. function PDFFetchStreamReader(stream) {
  19608. var _this = this;
  19609. _classCallCheck(this, PDFFetchStreamReader);
  19610. this._stream = stream;
  19611. this._reader = null;
  19612. this._loaded = 0;
  19613. this._filename = null;
  19614. var source = stream.source;
  19615. this._withCredentials = source.withCredentials || false;
  19616. this._contentLength = source.length;
  19617. this._headersCapability = (0, _util.createPromiseCapability)();
  19618. this._disableRange = source.disableRange || false;
  19619. this._rangeChunkSize = source.rangeChunkSize;
  19620. if (!this._rangeChunkSize && !this._disableRange) {
  19621. this._disableRange = true;
  19622. }
  19623. if (typeof AbortController !== 'undefined') {
  19624. this._abortController = new AbortController();
  19625. }
  19626. this._isStreamingSupported = !source.disableStream;
  19627. this._isRangeSupported = !source.disableRange;
  19628. this._headers = new Headers();
  19629. for (var property in this._stream.httpHeaders) {
  19630. var value = this._stream.httpHeaders[property];
  19631. if (typeof value === 'undefined') {
  19632. continue;
  19633. }
  19634. this._headers.append(property, value);
  19635. }
  19636. var url = source.url;
  19637. fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(function (response) {
  19638. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  19639. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  19640. }
  19641. _this._reader = response.body.getReader();
  19642. _this._headersCapability.resolve();
  19643. var getResponseHeader = function getResponseHeader(name) {
  19644. return response.headers.get(name);
  19645. };
  19646. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  19647. getResponseHeader: getResponseHeader,
  19648. isHttp: _this._stream.isHttp,
  19649. rangeChunkSize: _this._rangeChunkSize,
  19650. disableRange: _this._disableRange
  19651. }),
  19652. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  19653. suggestedLength = _validateRangeRequest.suggestedLength;
  19654. _this._isRangeSupported = allowRangeRequests;
  19655. _this._contentLength = suggestedLength || _this._contentLength;
  19656. _this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  19657. if (!_this._isStreamingSupported && _this._isRangeSupported) {
  19658. _this.cancel(new _util.AbortException('Streaming is disabled.'));
  19659. }
  19660. })["catch"](this._headersCapability.reject);
  19661. this.onProgress = null;
  19662. }
  19663. _createClass(PDFFetchStreamReader, [{
  19664. key: "read",
  19665. value: function () {
  19666. var _read = _asyncToGenerator(
  19667. /*#__PURE__*/
  19668. _regenerator["default"].mark(function _callee() {
  19669. var _ref, value, done, buffer;
  19670. return _regenerator["default"].wrap(function _callee$(_context) {
  19671. while (1) {
  19672. switch (_context.prev = _context.next) {
  19673. case 0:
  19674. _context.next = 2;
  19675. return this._headersCapability.promise;
  19676. case 2:
  19677. _context.next = 4;
  19678. return this._reader.read();
  19679. case 4:
  19680. _ref = _context.sent;
  19681. value = _ref.value;
  19682. done = _ref.done;
  19683. if (!done) {
  19684. _context.next = 9;
  19685. break;
  19686. }
  19687. return _context.abrupt("return", {
  19688. value: value,
  19689. done: done
  19690. });
  19691. case 9:
  19692. this._loaded += value.byteLength;
  19693. if (this.onProgress) {
  19694. this.onProgress({
  19695. loaded: this._loaded,
  19696. total: this._contentLength
  19697. });
  19698. }
  19699. buffer = new Uint8Array(value).buffer;
  19700. return _context.abrupt("return", {
  19701. value: buffer,
  19702. done: false
  19703. });
  19704. case 13:
  19705. case "end":
  19706. return _context.stop();
  19707. }
  19708. }
  19709. }, _callee, this);
  19710. }));
  19711. function read() {
  19712. return _read.apply(this, arguments);
  19713. }
  19714. return read;
  19715. }()
  19716. }, {
  19717. key: "cancel",
  19718. value: function cancel(reason) {
  19719. if (this._reader) {
  19720. this._reader.cancel(reason);
  19721. }
  19722. if (this._abortController) {
  19723. this._abortController.abort();
  19724. }
  19725. }
  19726. }, {
  19727. key: "headersReady",
  19728. get: function get() {
  19729. return this._headersCapability.promise;
  19730. }
  19731. }, {
  19732. key: "filename",
  19733. get: function get() {
  19734. return this._filename;
  19735. }
  19736. }, {
  19737. key: "contentLength",
  19738. get: function get() {
  19739. return this._contentLength;
  19740. }
  19741. }, {
  19742. key: "isRangeSupported",
  19743. get: function get() {
  19744. return this._isRangeSupported;
  19745. }
  19746. }, {
  19747. key: "isStreamingSupported",
  19748. get: function get() {
  19749. return this._isStreamingSupported;
  19750. }
  19751. }]);
  19752. return PDFFetchStreamReader;
  19753. }();
  19754. var PDFFetchStreamRangeReader =
  19755. /*#__PURE__*/
  19756. function () {
  19757. function PDFFetchStreamRangeReader(stream, begin, end) {
  19758. var _this2 = this;
  19759. _classCallCheck(this, PDFFetchStreamRangeReader);
  19760. this._stream = stream;
  19761. this._reader = null;
  19762. this._loaded = 0;
  19763. var source = stream.source;
  19764. this._withCredentials = source.withCredentials || false;
  19765. this._readCapability = (0, _util.createPromiseCapability)();
  19766. this._isStreamingSupported = !source.disableStream;
  19767. if (typeof AbortController !== 'undefined') {
  19768. this._abortController = new AbortController();
  19769. }
  19770. this._headers = new Headers();
  19771. for (var property in this._stream.httpHeaders) {
  19772. var value = this._stream.httpHeaders[property];
  19773. if (typeof value === 'undefined') {
  19774. continue;
  19775. }
  19776. this._headers.append(property, value);
  19777. }
  19778. this._headers.append('Range', "bytes=".concat(begin, "-").concat(end - 1));
  19779. var url = source.url;
  19780. fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(function (response) {
  19781. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  19782. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  19783. }
  19784. _this2._readCapability.resolve();
  19785. _this2._reader = response.body.getReader();
  19786. });
  19787. this.onProgress = null;
  19788. }
  19789. _createClass(PDFFetchStreamRangeReader, [{
  19790. key: "read",
  19791. value: function () {
  19792. var _read2 = _asyncToGenerator(
  19793. /*#__PURE__*/
  19794. _regenerator["default"].mark(function _callee2() {
  19795. var _ref2, value, done, buffer;
  19796. return _regenerator["default"].wrap(function _callee2$(_context2) {
  19797. while (1) {
  19798. switch (_context2.prev = _context2.next) {
  19799. case 0:
  19800. _context2.next = 2;
  19801. return this._readCapability.promise;
  19802. case 2:
  19803. _context2.next = 4;
  19804. return this._reader.read();
  19805. case 4:
  19806. _ref2 = _context2.sent;
  19807. value = _ref2.value;
  19808. done = _ref2.done;
  19809. if (!done) {
  19810. _context2.next = 9;
  19811. break;
  19812. }
  19813. return _context2.abrupt("return", {
  19814. value: value,
  19815. done: done
  19816. });
  19817. case 9:
  19818. this._loaded += value.byteLength;
  19819. if (this.onProgress) {
  19820. this.onProgress({
  19821. loaded: this._loaded
  19822. });
  19823. }
  19824. buffer = new Uint8Array(value).buffer;
  19825. return _context2.abrupt("return", {
  19826. value: buffer,
  19827. done: false
  19828. });
  19829. case 13:
  19830. case "end":
  19831. return _context2.stop();
  19832. }
  19833. }
  19834. }, _callee2, this);
  19835. }));
  19836. function read() {
  19837. return _read2.apply(this, arguments);
  19838. }
  19839. return read;
  19840. }()
  19841. }, {
  19842. key: "cancel",
  19843. value: function cancel(reason) {
  19844. if (this._reader) {
  19845. this._reader.cancel(reason);
  19846. }
  19847. if (this._abortController) {
  19848. this._abortController.abort();
  19849. }
  19850. }
  19851. }, {
  19852. key: "isStreamingSupported",
  19853. get: function get() {
  19854. return this._isStreamingSupported;
  19855. }
  19856. }]);
  19857. return PDFFetchStreamRangeReader;
  19858. }();
  19859. /***/ })
  19860. /******/ ]);
  19861. });
  19862. //# sourceMappingURL=pdf.js.map