pdf.js 816 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2020 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. (function 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. Object.defineProperty(exports, "__esModule", {
  123. value: true
  124. });
  125. Object.defineProperty(exports, "addLinkAttributes", {
  126. enumerable: true,
  127. get: function get() {
  128. return _display_utils.addLinkAttributes;
  129. }
  130. });
  131. Object.defineProperty(exports, "getFilenameFromUrl", {
  132. enumerable: true,
  133. get: function get() {
  134. return _display_utils.getFilenameFromUrl;
  135. }
  136. });
  137. Object.defineProperty(exports, "LinkTarget", {
  138. enumerable: true,
  139. get: function get() {
  140. return _display_utils.LinkTarget;
  141. }
  142. });
  143. Object.defineProperty(exports, "loadScript", {
  144. enumerable: true,
  145. get: function get() {
  146. return _display_utils.loadScript;
  147. }
  148. });
  149. Object.defineProperty(exports, "PDFDateString", {
  150. enumerable: true,
  151. get: function get() {
  152. return _display_utils.PDFDateString;
  153. }
  154. });
  155. Object.defineProperty(exports, "RenderingCancelledException", {
  156. enumerable: true,
  157. get: function get() {
  158. return _display_utils.RenderingCancelledException;
  159. }
  160. });
  161. Object.defineProperty(exports, "build", {
  162. enumerable: true,
  163. get: function get() {
  164. return _api.build;
  165. }
  166. });
  167. Object.defineProperty(exports, "getDocument", {
  168. enumerable: true,
  169. get: function get() {
  170. return _api.getDocument;
  171. }
  172. });
  173. Object.defineProperty(exports, "LoopbackPort", {
  174. enumerable: true,
  175. get: function get() {
  176. return _api.LoopbackPort;
  177. }
  178. });
  179. Object.defineProperty(exports, "PDFDataRangeTransport", {
  180. enumerable: true,
  181. get: function get() {
  182. return _api.PDFDataRangeTransport;
  183. }
  184. });
  185. Object.defineProperty(exports, "PDFWorker", {
  186. enumerable: true,
  187. get: function get() {
  188. return _api.PDFWorker;
  189. }
  190. });
  191. Object.defineProperty(exports, "version", {
  192. enumerable: true,
  193. get: function get() {
  194. return _api.version;
  195. }
  196. });
  197. Object.defineProperty(exports, "CMapCompressionType", {
  198. enumerable: true,
  199. get: function get() {
  200. return _util.CMapCompressionType;
  201. }
  202. });
  203. Object.defineProperty(exports, "createObjectURL", {
  204. enumerable: true,
  205. get: function get() {
  206. return _util.createObjectURL;
  207. }
  208. });
  209. Object.defineProperty(exports, "createPromiseCapability", {
  210. enumerable: true,
  211. get: function get() {
  212. return _util.createPromiseCapability;
  213. }
  214. });
  215. Object.defineProperty(exports, "createValidAbsoluteUrl", {
  216. enumerable: true,
  217. get: function get() {
  218. return _util.createValidAbsoluteUrl;
  219. }
  220. });
  221. Object.defineProperty(exports, "InvalidPDFException", {
  222. enumerable: true,
  223. get: function get() {
  224. return _util.InvalidPDFException;
  225. }
  226. });
  227. Object.defineProperty(exports, "MissingPDFException", {
  228. enumerable: true,
  229. get: function get() {
  230. return _util.MissingPDFException;
  231. }
  232. });
  233. Object.defineProperty(exports, "OPS", {
  234. enumerable: true,
  235. get: function get() {
  236. return _util.OPS;
  237. }
  238. });
  239. Object.defineProperty(exports, "PasswordResponses", {
  240. enumerable: true,
  241. get: function get() {
  242. return _util.PasswordResponses;
  243. }
  244. });
  245. Object.defineProperty(exports, "PermissionFlag", {
  246. enumerable: true,
  247. get: function get() {
  248. return _util.PermissionFlag;
  249. }
  250. });
  251. Object.defineProperty(exports, "removeNullCharacters", {
  252. enumerable: true,
  253. get: function get() {
  254. return _util.removeNullCharacters;
  255. }
  256. });
  257. Object.defineProperty(exports, "shadow", {
  258. enumerable: true,
  259. get: function get() {
  260. return _util.shadow;
  261. }
  262. });
  263. Object.defineProperty(exports, "UnexpectedResponseException", {
  264. enumerable: true,
  265. get: function get() {
  266. return _util.UnexpectedResponseException;
  267. }
  268. });
  269. Object.defineProperty(exports, "UNSUPPORTED_FEATURES", {
  270. enumerable: true,
  271. get: function get() {
  272. return _util.UNSUPPORTED_FEATURES;
  273. }
  274. });
  275. Object.defineProperty(exports, "Util", {
  276. enumerable: true,
  277. get: function get() {
  278. return _util.Util;
  279. }
  280. });
  281. Object.defineProperty(exports, "VerbosityLevel", {
  282. enumerable: true,
  283. get: function get() {
  284. return _util.VerbosityLevel;
  285. }
  286. });
  287. Object.defineProperty(exports, "AnnotationLayer", {
  288. enumerable: true,
  289. get: function get() {
  290. return _annotation_layer.AnnotationLayer;
  291. }
  292. });
  293. Object.defineProperty(exports, "apiCompatibilityParams", {
  294. enumerable: true,
  295. get: function get() {
  296. return _api_compatibility.apiCompatibilityParams;
  297. }
  298. });
  299. Object.defineProperty(exports, "GlobalWorkerOptions", {
  300. enumerable: true,
  301. get: function get() {
  302. return _worker_options.GlobalWorkerOptions;
  303. }
  304. });
  305. Object.defineProperty(exports, "renderTextLayer", {
  306. enumerable: true,
  307. get: function get() {
  308. return _text_layer.renderTextLayer;
  309. }
  310. });
  311. Object.defineProperty(exports, "SVGGraphics", {
  312. enumerable: true,
  313. get: function get() {
  314. return _svg.SVGGraphics;
  315. }
  316. });
  317. var _display_utils = __w_pdfjs_require__(1);
  318. var _api = __w_pdfjs_require__(202);
  319. var _util = __w_pdfjs_require__(5);
  320. var _annotation_layer = __w_pdfjs_require__(216);
  321. var _api_compatibility = __w_pdfjs_require__(206);
  322. var _worker_options = __w_pdfjs_require__(209);
  323. var _text_layer = __w_pdfjs_require__(217);
  324. var _svg = __w_pdfjs_require__(218);
  325. var pdfjsVersion = '2.6.347';
  326. var pdfjsBuild = '3be9c65f';
  327. {
  328. var _require = __w_pdfjs_require__(7),
  329. isNodeJS = _require.isNodeJS;
  330. if (isNodeJS) {
  331. var PDFNodeStream = __w_pdfjs_require__(219).PDFNodeStream;
  332. (0, _api.setPDFNetworkStreamFactory)(function (params) {
  333. return new PDFNodeStream(params);
  334. });
  335. } else {
  336. var PDFNetworkStream = __w_pdfjs_require__(222).PDFNetworkStream;
  337. var PDFFetchStream;
  338. if ((0, _display_utils.isFetchSupported)()) {
  339. PDFFetchStream = __w_pdfjs_require__(223).PDFFetchStream;
  340. }
  341. (0, _api.setPDFNetworkStreamFactory)(function (params) {
  342. if (PDFFetchStream && (0, _display_utils.isValidFetchUrl)(params.url)) {
  343. return new PDFFetchStream(params);
  344. }
  345. return new PDFNetworkStream(params);
  346. });
  347. }
  348. }
  349. /***/ }),
  350. /* 1 */
  351. /***/ (function(module, exports, __w_pdfjs_require__) {
  352. "use strict";
  353. Object.defineProperty(exports, "__esModule", {
  354. value: true
  355. });
  356. exports.addLinkAttributes = addLinkAttributes;
  357. exports.getFilenameFromUrl = getFilenameFromUrl;
  358. exports.isFetchSupported = isFetchSupported;
  359. exports.isValidFetchUrl = isValidFetchUrl;
  360. exports.loadScript = loadScript;
  361. exports.deprecated = deprecated;
  362. exports.PDFDateString = exports.StatTimer = exports.DOMSVGFactory = exports.DOMCMapReaderFactory = exports.BaseCMapReaderFactory = exports.DOMCanvasFactory = exports.BaseCanvasFactory = exports.DEFAULT_LINK_REL = exports.LinkTarget = exports.RenderingCancelledException = exports.PageViewport = void 0;
  363. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(2));
  364. var _util = __w_pdfjs_require__(5);
  365. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  366. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  367. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  368. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  369. 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); } }
  370. 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); }); }; }
  371. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  372. 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); }
  373. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  374. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  375. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  376. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  377. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  378. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  379. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  380. 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); } }
  381. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  382. var DEFAULT_LINK_REL = "noopener noreferrer nofollow";
  383. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  384. var SVG_NS = "http://www.w3.org/2000/svg";
  385. var BaseCanvasFactory = /*#__PURE__*/function () {
  386. function BaseCanvasFactory() {
  387. _classCallCheck(this, BaseCanvasFactory);
  388. if (this.constructor === BaseCanvasFactory) {
  389. (0, _util.unreachable)("Cannot initialize BaseCanvasFactory.");
  390. }
  391. }
  392. _createClass(BaseCanvasFactory, [{
  393. key: "create",
  394. value: function create(width, height) {
  395. (0, _util.unreachable)("Abstract method `create` called.");
  396. }
  397. }, {
  398. key: "reset",
  399. value: function reset(canvasAndContext, width, height) {
  400. if (!canvasAndContext.canvas) {
  401. throw new Error("Canvas is not specified");
  402. }
  403. if (width <= 0 || height <= 0) {
  404. throw new Error("Invalid canvas size");
  405. }
  406. canvasAndContext.canvas.width = width;
  407. canvasAndContext.canvas.height = height;
  408. }
  409. }, {
  410. key: "destroy",
  411. value: function destroy(canvasAndContext) {
  412. if (!canvasAndContext.canvas) {
  413. throw new Error("Canvas is not specified");
  414. }
  415. canvasAndContext.canvas.width = 0;
  416. canvasAndContext.canvas.height = 0;
  417. canvasAndContext.canvas = null;
  418. canvasAndContext.context = null;
  419. }
  420. }]);
  421. return BaseCanvasFactory;
  422. }();
  423. exports.BaseCanvasFactory = BaseCanvasFactory;
  424. var DOMCanvasFactory = /*#__PURE__*/function (_BaseCanvasFactory) {
  425. _inherits(DOMCanvasFactory, _BaseCanvasFactory);
  426. var _super = _createSuper(DOMCanvasFactory);
  427. function DOMCanvasFactory() {
  428. var _this;
  429. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  430. _ref$ownerDocument = _ref.ownerDocument,
  431. ownerDocument = _ref$ownerDocument === void 0 ? globalThis.document : _ref$ownerDocument;
  432. _classCallCheck(this, DOMCanvasFactory);
  433. _this = _super.call(this);
  434. _this._document = ownerDocument;
  435. return _this;
  436. }
  437. _createClass(DOMCanvasFactory, [{
  438. key: "create",
  439. value: function create(width, height) {
  440. if (width <= 0 || height <= 0) {
  441. throw new Error("Invalid canvas size");
  442. }
  443. var canvas = this._document.createElement("canvas");
  444. var context = canvas.getContext("2d");
  445. canvas.width = width;
  446. canvas.height = height;
  447. return {
  448. canvas: canvas,
  449. context: context
  450. };
  451. }
  452. }]);
  453. return DOMCanvasFactory;
  454. }(BaseCanvasFactory);
  455. exports.DOMCanvasFactory = DOMCanvasFactory;
  456. var BaseCMapReaderFactory = /*#__PURE__*/function () {
  457. function BaseCMapReaderFactory(_ref2) {
  458. var _ref2$baseUrl = _ref2.baseUrl,
  459. baseUrl = _ref2$baseUrl === void 0 ? null : _ref2$baseUrl,
  460. _ref2$isCompressed = _ref2.isCompressed,
  461. isCompressed = _ref2$isCompressed === void 0 ? false : _ref2$isCompressed;
  462. _classCallCheck(this, BaseCMapReaderFactory);
  463. if (this.constructor === BaseCMapReaderFactory) {
  464. (0, _util.unreachable)("Cannot initialize BaseCMapReaderFactory.");
  465. }
  466. this.baseUrl = baseUrl;
  467. this.isCompressed = isCompressed;
  468. }
  469. _createClass(BaseCMapReaderFactory, [{
  470. key: "fetch",
  471. value: function () {
  472. var _fetch = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(_ref3) {
  473. var _this2 = this;
  474. var name, url, compressionType;
  475. return _regenerator["default"].wrap(function _callee$(_context) {
  476. while (1) {
  477. switch (_context.prev = _context.next) {
  478. case 0:
  479. name = _ref3.name;
  480. if (this.baseUrl) {
  481. _context.next = 3;
  482. break;
  483. }
  484. throw new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.');
  485. case 3:
  486. if (name) {
  487. _context.next = 5;
  488. break;
  489. }
  490. throw new Error("CMap name must be specified.");
  491. case 5:
  492. url = this.baseUrl + name + (this.isCompressed ? ".bcmap" : "");
  493. compressionType = this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE;
  494. return _context.abrupt("return", this._fetchData(url, compressionType)["catch"](function (reason) {
  495. throw new Error("Unable to load ".concat(_this2.isCompressed ? "binary " : "", "CMap at: ").concat(url));
  496. }));
  497. case 8:
  498. case "end":
  499. return _context.stop();
  500. }
  501. }
  502. }, _callee, this);
  503. }));
  504. function fetch(_x) {
  505. return _fetch.apply(this, arguments);
  506. }
  507. return fetch;
  508. }()
  509. }, {
  510. key: "_fetchData",
  511. value: function _fetchData(url, compressionType) {
  512. (0, _util.unreachable)("Abstract method `_fetchData` called.");
  513. }
  514. }]);
  515. return BaseCMapReaderFactory;
  516. }();
  517. exports.BaseCMapReaderFactory = BaseCMapReaderFactory;
  518. var DOMCMapReaderFactory = /*#__PURE__*/function (_BaseCMapReaderFactor) {
  519. _inherits(DOMCMapReaderFactory, _BaseCMapReaderFactor);
  520. var _super2 = _createSuper(DOMCMapReaderFactory);
  521. function DOMCMapReaderFactory() {
  522. _classCallCheck(this, DOMCMapReaderFactory);
  523. return _super2.apply(this, arguments);
  524. }
  525. _createClass(DOMCMapReaderFactory, [{
  526. key: "_fetchData",
  527. value: function _fetchData(url, compressionType) {
  528. var _this3 = this;
  529. if (isFetchSupported() && isValidFetchUrl(url, document.baseURI)) {
  530. return fetch(url).then( /*#__PURE__*/function () {
  531. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(response) {
  532. var cMapData;
  533. return _regenerator["default"].wrap(function _callee2$(_context2) {
  534. while (1) {
  535. switch (_context2.prev = _context2.next) {
  536. case 0:
  537. if (response.ok) {
  538. _context2.next = 2;
  539. break;
  540. }
  541. throw new Error(response.statusText);
  542. case 2:
  543. if (!_this3.isCompressed) {
  544. _context2.next = 10;
  545. break;
  546. }
  547. _context2.t0 = Uint8Array;
  548. _context2.next = 6;
  549. return response.arrayBuffer();
  550. case 6:
  551. _context2.t1 = _context2.sent;
  552. cMapData = new _context2.t0(_context2.t1);
  553. _context2.next = 15;
  554. break;
  555. case 10:
  556. _context2.t2 = _util.stringToBytes;
  557. _context2.next = 13;
  558. return response.text();
  559. case 13:
  560. _context2.t3 = _context2.sent;
  561. cMapData = (0, _context2.t2)(_context2.t3);
  562. case 15:
  563. return _context2.abrupt("return", {
  564. cMapData: cMapData,
  565. compressionType: compressionType
  566. });
  567. case 16:
  568. case "end":
  569. return _context2.stop();
  570. }
  571. }
  572. }, _callee2);
  573. }));
  574. return function (_x2) {
  575. return _ref4.apply(this, arguments);
  576. };
  577. }());
  578. }
  579. return new Promise(function (resolve, reject) {
  580. var request = new XMLHttpRequest();
  581. request.open("GET", url, true);
  582. if (_this3.isCompressed) {
  583. request.responseType = "arraybuffer";
  584. }
  585. request.onreadystatechange = function () {
  586. if (request.readyState !== XMLHttpRequest.DONE) {
  587. return;
  588. }
  589. if (request.status === 200 || request.status === 0) {
  590. var cMapData;
  591. if (_this3.isCompressed && request.response) {
  592. cMapData = new Uint8Array(request.response);
  593. } else if (!_this3.isCompressed && request.responseText) {
  594. cMapData = (0, _util.stringToBytes)(request.responseText);
  595. }
  596. if (cMapData) {
  597. resolve({
  598. cMapData: cMapData,
  599. compressionType: compressionType
  600. });
  601. return;
  602. }
  603. }
  604. reject(new Error(request.statusText));
  605. };
  606. request.send(null);
  607. });
  608. }
  609. }]);
  610. return DOMCMapReaderFactory;
  611. }(BaseCMapReaderFactory);
  612. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  613. var DOMSVGFactory = /*#__PURE__*/function () {
  614. function DOMSVGFactory() {
  615. _classCallCheck(this, DOMSVGFactory);
  616. }
  617. _createClass(DOMSVGFactory, [{
  618. key: "create",
  619. value: function create(width, height) {
  620. (0, _util.assert)(width > 0 && height > 0, "Invalid SVG dimensions");
  621. var svg = document.createElementNS(SVG_NS, "svg:svg");
  622. svg.setAttribute("version", "1.1");
  623. svg.setAttribute("width", width + "px");
  624. svg.setAttribute("height", height + "px");
  625. svg.setAttribute("preserveAspectRatio", "none");
  626. svg.setAttribute("viewBox", "0 0 " + width + " " + height);
  627. return svg;
  628. }
  629. }, {
  630. key: "createElement",
  631. value: function createElement(type) {
  632. (0, _util.assert)(typeof type === "string", "Invalid SVG element type");
  633. return document.createElementNS(SVG_NS, type);
  634. }
  635. }]);
  636. return DOMSVGFactory;
  637. }();
  638. exports.DOMSVGFactory = DOMSVGFactory;
  639. var PageViewport = /*#__PURE__*/function () {
  640. function PageViewport(_ref5) {
  641. var viewBox = _ref5.viewBox,
  642. scale = _ref5.scale,
  643. rotation = _ref5.rotation,
  644. _ref5$offsetX = _ref5.offsetX,
  645. offsetX = _ref5$offsetX === void 0 ? 0 : _ref5$offsetX,
  646. _ref5$offsetY = _ref5.offsetY,
  647. offsetY = _ref5$offsetY === void 0 ? 0 : _ref5$offsetY,
  648. _ref5$dontFlip = _ref5.dontFlip,
  649. dontFlip = _ref5$dontFlip === void 0 ? false : _ref5$dontFlip;
  650. _classCallCheck(this, PageViewport);
  651. this.viewBox = viewBox;
  652. this.scale = scale;
  653. this.rotation = rotation;
  654. this.offsetX = offsetX;
  655. this.offsetY = offsetY;
  656. var centerX = (viewBox[2] + viewBox[0]) / 2;
  657. var centerY = (viewBox[3] + viewBox[1]) / 2;
  658. var rotateA, rotateB, rotateC, rotateD;
  659. rotation = rotation % 360;
  660. rotation = rotation < 0 ? rotation + 360 : rotation;
  661. switch (rotation) {
  662. case 180:
  663. rotateA = -1;
  664. rotateB = 0;
  665. rotateC = 0;
  666. rotateD = 1;
  667. break;
  668. case 90:
  669. rotateA = 0;
  670. rotateB = 1;
  671. rotateC = 1;
  672. rotateD = 0;
  673. break;
  674. case 270:
  675. rotateA = 0;
  676. rotateB = -1;
  677. rotateC = -1;
  678. rotateD = 0;
  679. break;
  680. case 0:
  681. rotateA = 1;
  682. rotateB = 0;
  683. rotateC = 0;
  684. rotateD = -1;
  685. break;
  686. default:
  687. throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.");
  688. }
  689. if (dontFlip) {
  690. rotateC = -rotateC;
  691. rotateD = -rotateD;
  692. }
  693. var offsetCanvasX, offsetCanvasY;
  694. var width, height;
  695. if (rotateA === 0) {
  696. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  697. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  698. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  699. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  700. } else {
  701. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  702. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  703. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  704. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  705. }
  706. this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
  707. this.width = width;
  708. this.height = height;
  709. }
  710. _createClass(PageViewport, [{
  711. key: "clone",
  712. value: function clone() {
  713. var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  714. _ref6$scale = _ref6.scale,
  715. scale = _ref6$scale === void 0 ? this.scale : _ref6$scale,
  716. _ref6$rotation = _ref6.rotation,
  717. rotation = _ref6$rotation === void 0 ? this.rotation : _ref6$rotation,
  718. _ref6$offsetX = _ref6.offsetX,
  719. offsetX = _ref6$offsetX === void 0 ? this.offsetX : _ref6$offsetX,
  720. _ref6$offsetY = _ref6.offsetY,
  721. offsetY = _ref6$offsetY === void 0 ? this.offsetY : _ref6$offsetY,
  722. _ref6$dontFlip = _ref6.dontFlip,
  723. dontFlip = _ref6$dontFlip === void 0 ? false : _ref6$dontFlip;
  724. return new PageViewport({
  725. viewBox: this.viewBox.slice(),
  726. scale: scale,
  727. rotation: rotation,
  728. offsetX: offsetX,
  729. offsetY: offsetY,
  730. dontFlip: dontFlip
  731. });
  732. }
  733. }, {
  734. key: "convertToViewportPoint",
  735. value: function convertToViewportPoint(x, y) {
  736. return _util.Util.applyTransform([x, y], this.transform);
  737. }
  738. }, {
  739. key: "convertToViewportRectangle",
  740. value: function convertToViewportRectangle(rect) {
  741. var topLeft = _util.Util.applyTransform([rect[0], rect[1]], this.transform);
  742. var bottomRight = _util.Util.applyTransform([rect[2], rect[3]], this.transform);
  743. return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];
  744. }
  745. }, {
  746. key: "convertToPdfPoint",
  747. value: function convertToPdfPoint(x, y) {
  748. return _util.Util.applyInverseTransform([x, y], this.transform);
  749. }
  750. }]);
  751. return PageViewport;
  752. }();
  753. exports.PageViewport = PageViewport;
  754. var RenderingCancelledException = /*#__PURE__*/function (_BaseException) {
  755. _inherits(RenderingCancelledException, _BaseException);
  756. var _super3 = _createSuper(RenderingCancelledException);
  757. function RenderingCancelledException(msg, type) {
  758. var _this4;
  759. _classCallCheck(this, RenderingCancelledException);
  760. _this4 = _super3.call(this, msg);
  761. _this4.type = type;
  762. return _this4;
  763. }
  764. return RenderingCancelledException;
  765. }(_util.BaseException);
  766. exports.RenderingCancelledException = RenderingCancelledException;
  767. var LinkTarget = {
  768. NONE: 0,
  769. SELF: 1,
  770. BLANK: 2,
  771. PARENT: 3,
  772. TOP: 4
  773. };
  774. exports.LinkTarget = LinkTarget;
  775. function addLinkAttributes(link) {
  776. var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  777. url = _ref7.url,
  778. target = _ref7.target,
  779. rel = _ref7.rel,
  780. _ref7$enabled = _ref7.enabled,
  781. enabled = _ref7$enabled === void 0 ? true : _ref7$enabled;
  782. (0, _util.assert)(url && typeof url === "string", 'addLinkAttributes: A valid "url" parameter must provided.');
  783. var urlNullRemoved = (0, _util.removeNullCharacters)(url);
  784. if (enabled) {
  785. link.href = link.title = urlNullRemoved;
  786. } else {
  787. link.href = "";
  788. link.title = "Disabled: ".concat(urlNullRemoved);
  789. link.onclick = function () {
  790. return false;
  791. };
  792. }
  793. var targetStr = "";
  794. switch (target) {
  795. case LinkTarget.NONE:
  796. break;
  797. case LinkTarget.SELF:
  798. targetStr = "_self";
  799. break;
  800. case LinkTarget.BLANK:
  801. targetStr = "_blank";
  802. break;
  803. case LinkTarget.PARENT:
  804. targetStr = "_parent";
  805. break;
  806. case LinkTarget.TOP:
  807. targetStr = "_top";
  808. break;
  809. }
  810. link.target = targetStr;
  811. link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
  812. }
  813. function getFilenameFromUrl(url) {
  814. var anchor = url.indexOf("#");
  815. var query = url.indexOf("?");
  816. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  817. return url.substring(url.lastIndexOf("/", end) + 1, end);
  818. }
  819. var StatTimer = /*#__PURE__*/function () {
  820. function StatTimer() {
  821. _classCallCheck(this, StatTimer);
  822. this.started = Object.create(null);
  823. this.times = [];
  824. }
  825. _createClass(StatTimer, [{
  826. key: "time",
  827. value: function time(name) {
  828. if (name in this.started) {
  829. (0, _util.warn)("Timer is already running for ".concat(name));
  830. }
  831. this.started[name] = Date.now();
  832. }
  833. }, {
  834. key: "timeEnd",
  835. value: function timeEnd(name) {
  836. if (!(name in this.started)) {
  837. (0, _util.warn)("Timer has not been started for ".concat(name));
  838. }
  839. this.times.push({
  840. name: name,
  841. start: this.started[name],
  842. end: Date.now()
  843. });
  844. delete this.started[name];
  845. }
  846. }, {
  847. key: "toString",
  848. value: function toString() {
  849. var outBuf = [];
  850. var longest = 0;
  851. var _iterator = _createForOfIteratorHelper(this.times),
  852. _step;
  853. try {
  854. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  855. var time = _step.value;
  856. var name = time.name;
  857. if (name.length > longest) {
  858. longest = name.length;
  859. }
  860. }
  861. } catch (err) {
  862. _iterator.e(err);
  863. } finally {
  864. _iterator.f();
  865. }
  866. var _iterator2 = _createForOfIteratorHelper(this.times),
  867. _step2;
  868. try {
  869. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  870. var _time = _step2.value;
  871. var duration = _time.end - _time.start;
  872. outBuf.push("".concat(_time.name.padEnd(longest), " ").concat(duration, "ms\n"));
  873. }
  874. } catch (err) {
  875. _iterator2.e(err);
  876. } finally {
  877. _iterator2.f();
  878. }
  879. return outBuf.join("");
  880. }
  881. }]);
  882. return StatTimer;
  883. }();
  884. exports.StatTimer = StatTimer;
  885. function isFetchSupported() {
  886. return typeof fetch !== "undefined" && typeof Response !== "undefined" && "body" in Response.prototype && typeof ReadableStream !== "undefined";
  887. }
  888. function isValidFetchUrl(url, baseUrl) {
  889. try {
  890. var _ref8 = baseUrl ? new URL(url, baseUrl) : new URL(url),
  891. protocol = _ref8.protocol;
  892. return protocol === "http:" || protocol === "https:";
  893. } catch (ex) {
  894. return false;
  895. }
  896. }
  897. function loadScript(src) {
  898. return new Promise(function (resolve, reject) {
  899. var script = document.createElement("script");
  900. script.src = src;
  901. script.onload = resolve;
  902. script.onerror = function () {
  903. reject(new Error("Cannot load script at: ".concat(script.src)));
  904. };
  905. (document.head || document.documentElement).appendChild(script);
  906. });
  907. }
  908. function deprecated(details) {
  909. console.log("Deprecated API usage: " + details);
  910. }
  911. var pdfDateStringRegex;
  912. var PDFDateString = /*#__PURE__*/function () {
  913. function PDFDateString() {
  914. _classCallCheck(this, PDFDateString);
  915. }
  916. _createClass(PDFDateString, null, [{
  917. key: "toDateObject",
  918. value: function toDateObject(input) {
  919. if (!input || !(0, _util.isString)(input)) {
  920. return null;
  921. }
  922. if (!pdfDateStringRegex) {
  923. pdfDateStringRegex = new RegExp("^D:" + "(\\d{4})" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "([Z|+|-])?" + "(\\d{2})?" + "'?" + "(\\d{2})?" + "'?");
  924. }
  925. var matches = pdfDateStringRegex.exec(input);
  926. if (!matches) {
  927. return null;
  928. }
  929. var year = parseInt(matches[1], 10);
  930. var month = parseInt(matches[2], 10);
  931. month = month >= 1 && month <= 12 ? month - 1 : 0;
  932. var day = parseInt(matches[3], 10);
  933. day = day >= 1 && day <= 31 ? day : 1;
  934. var hour = parseInt(matches[4], 10);
  935. hour = hour >= 0 && hour <= 23 ? hour : 0;
  936. var minute = parseInt(matches[5], 10);
  937. minute = minute >= 0 && minute <= 59 ? minute : 0;
  938. var second = parseInt(matches[6], 10);
  939. second = second >= 0 && second <= 59 ? second : 0;
  940. var universalTimeRelation = matches[7] || "Z";
  941. var offsetHour = parseInt(matches[8], 10);
  942. offsetHour = offsetHour >= 0 && offsetHour <= 23 ? offsetHour : 0;
  943. var offsetMinute = parseInt(matches[9], 10) || 0;
  944. offsetMinute = offsetMinute >= 0 && offsetMinute <= 59 ? offsetMinute : 0;
  945. if (universalTimeRelation === "-") {
  946. hour += offsetHour;
  947. minute += offsetMinute;
  948. } else if (universalTimeRelation === "+") {
  949. hour -= offsetHour;
  950. minute -= offsetMinute;
  951. }
  952. return new Date(Date.UTC(year, month, day, hour, minute, second));
  953. }
  954. }]);
  955. return PDFDateString;
  956. }();
  957. exports.PDFDateString = PDFDateString;
  958. /***/ }),
  959. /* 2 */
  960. /***/ (function(module, exports, __w_pdfjs_require__) {
  961. "use strict";
  962. module.exports = __w_pdfjs_require__(3);
  963. /***/ }),
  964. /* 3 */
  965. /***/ (function(module, exports, __w_pdfjs_require__) {
  966. "use strict";
  967. /* WEBPACK VAR INJECTION */(function(module) {
  968. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  969. var runtime = function (exports) {
  970. "use strict";
  971. var Op = Object.prototype;
  972. var hasOwn = Op.hasOwnProperty;
  973. var undefined;
  974. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  975. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  976. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  977. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  978. function define(obj, key, value) {
  979. Object.defineProperty(obj, key, {
  980. value: value,
  981. enumerable: true,
  982. configurable: true,
  983. writable: true
  984. });
  985. return obj[key];
  986. }
  987. try {
  988. define({}, "");
  989. } catch (err) {
  990. define = function define(obj, key, value) {
  991. return obj[key] = value;
  992. };
  993. }
  994. function wrap(innerFn, outerFn, self, tryLocsList) {
  995. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  996. var generator = Object.create(protoGenerator.prototype);
  997. var context = new Context(tryLocsList || []);
  998. generator._invoke = makeInvokeMethod(innerFn, self, context);
  999. return generator;
  1000. }
  1001. exports.wrap = wrap;
  1002. function tryCatch(fn, obj, arg) {
  1003. try {
  1004. return {
  1005. type: "normal",
  1006. arg: fn.call(obj, arg)
  1007. };
  1008. } catch (err) {
  1009. return {
  1010. type: "throw",
  1011. arg: err
  1012. };
  1013. }
  1014. }
  1015. var GenStateSuspendedStart = "suspendedStart";
  1016. var GenStateSuspendedYield = "suspendedYield";
  1017. var GenStateExecuting = "executing";
  1018. var GenStateCompleted = "completed";
  1019. var ContinueSentinel = {};
  1020. function Generator() {}
  1021. function GeneratorFunction() {}
  1022. function GeneratorFunctionPrototype() {}
  1023. var IteratorPrototype = {};
  1024. IteratorPrototype[iteratorSymbol] = function () {
  1025. return this;
  1026. };
  1027. var getProto = Object.getPrototypeOf;
  1028. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  1029. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  1030. IteratorPrototype = NativeIteratorPrototype;
  1031. }
  1032. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  1033. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  1034. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  1035. GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
  1036. function defineIteratorMethods(prototype) {
  1037. ["next", "throw", "return"].forEach(function (method) {
  1038. define(prototype, method, function (arg) {
  1039. return this._invoke(method, arg);
  1040. });
  1041. });
  1042. }
  1043. exports.isGeneratorFunction = function (genFun) {
  1044. var ctor = typeof genFun === "function" && genFun.constructor;
  1045. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  1046. };
  1047. exports.mark = function (genFun) {
  1048. if (Object.setPrototypeOf) {
  1049. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  1050. } else {
  1051. genFun.__proto__ = GeneratorFunctionPrototype;
  1052. define(genFun, toStringTagSymbol, "GeneratorFunction");
  1053. }
  1054. genFun.prototype = Object.create(Gp);
  1055. return genFun;
  1056. };
  1057. exports.awrap = function (arg) {
  1058. return {
  1059. __await: arg
  1060. };
  1061. };
  1062. function AsyncIterator(generator, PromiseImpl) {
  1063. function invoke(method, arg, resolve, reject) {
  1064. var record = tryCatch(generator[method], generator, arg);
  1065. if (record.type === "throw") {
  1066. reject(record.arg);
  1067. } else {
  1068. var result = record.arg;
  1069. var value = result.value;
  1070. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  1071. return PromiseImpl.resolve(value.__await).then(function (value) {
  1072. invoke("next", value, resolve, reject);
  1073. }, function (err) {
  1074. invoke("throw", err, resolve, reject);
  1075. });
  1076. }
  1077. return PromiseImpl.resolve(value).then(function (unwrapped) {
  1078. result.value = unwrapped;
  1079. resolve(result);
  1080. }, function (error) {
  1081. return invoke("throw", error, resolve, reject);
  1082. });
  1083. }
  1084. }
  1085. var previousPromise;
  1086. function enqueue(method, arg) {
  1087. function callInvokeWithMethodAndArg() {
  1088. return new PromiseImpl(function (resolve, reject) {
  1089. invoke(method, arg, resolve, reject);
  1090. });
  1091. }
  1092. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  1093. }
  1094. this._invoke = enqueue;
  1095. }
  1096. defineIteratorMethods(AsyncIterator.prototype);
  1097. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  1098. return this;
  1099. };
  1100. exports.AsyncIterator = AsyncIterator;
  1101. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  1102. if (PromiseImpl === void 0) PromiseImpl = Promise;
  1103. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  1104. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  1105. return result.done ? result.value : iter.next();
  1106. });
  1107. };
  1108. function makeInvokeMethod(innerFn, self, context) {
  1109. var state = GenStateSuspendedStart;
  1110. return function invoke(method, arg) {
  1111. if (state === GenStateExecuting) {
  1112. throw new Error("Generator is already running");
  1113. }
  1114. if (state === GenStateCompleted) {
  1115. if (method === "throw") {
  1116. throw arg;
  1117. }
  1118. return doneResult();
  1119. }
  1120. context.method = method;
  1121. context.arg = arg;
  1122. while (true) {
  1123. var delegate = context.delegate;
  1124. if (delegate) {
  1125. var delegateResult = maybeInvokeDelegate(delegate, context);
  1126. if (delegateResult) {
  1127. if (delegateResult === ContinueSentinel) continue;
  1128. return delegateResult;
  1129. }
  1130. }
  1131. if (context.method === "next") {
  1132. context.sent = context._sent = context.arg;
  1133. } else if (context.method === "throw") {
  1134. if (state === GenStateSuspendedStart) {
  1135. state = GenStateCompleted;
  1136. throw context.arg;
  1137. }
  1138. context.dispatchException(context.arg);
  1139. } else if (context.method === "return") {
  1140. context.abrupt("return", context.arg);
  1141. }
  1142. state = GenStateExecuting;
  1143. var record = tryCatch(innerFn, self, context);
  1144. if (record.type === "normal") {
  1145. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  1146. if (record.arg === ContinueSentinel) {
  1147. continue;
  1148. }
  1149. return {
  1150. value: record.arg,
  1151. done: context.done
  1152. };
  1153. } else if (record.type === "throw") {
  1154. state = GenStateCompleted;
  1155. context.method = "throw";
  1156. context.arg = record.arg;
  1157. }
  1158. }
  1159. };
  1160. }
  1161. function maybeInvokeDelegate(delegate, context) {
  1162. var method = delegate.iterator[context.method];
  1163. if (method === undefined) {
  1164. context.delegate = null;
  1165. if (context.method === "throw") {
  1166. if (delegate.iterator["return"]) {
  1167. context.method = "return";
  1168. context.arg = undefined;
  1169. maybeInvokeDelegate(delegate, context);
  1170. if (context.method === "throw") {
  1171. return ContinueSentinel;
  1172. }
  1173. }
  1174. context.method = "throw";
  1175. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  1176. }
  1177. return ContinueSentinel;
  1178. }
  1179. var record = tryCatch(method, delegate.iterator, context.arg);
  1180. if (record.type === "throw") {
  1181. context.method = "throw";
  1182. context.arg = record.arg;
  1183. context.delegate = null;
  1184. return ContinueSentinel;
  1185. }
  1186. var info = record.arg;
  1187. if (!info) {
  1188. context.method = "throw";
  1189. context.arg = new TypeError("iterator result is not an object");
  1190. context.delegate = null;
  1191. return ContinueSentinel;
  1192. }
  1193. if (info.done) {
  1194. context[delegate.resultName] = info.value;
  1195. context.next = delegate.nextLoc;
  1196. if (context.method !== "return") {
  1197. context.method = "next";
  1198. context.arg = undefined;
  1199. }
  1200. } else {
  1201. return info;
  1202. }
  1203. context.delegate = null;
  1204. return ContinueSentinel;
  1205. }
  1206. defineIteratorMethods(Gp);
  1207. define(Gp, toStringTagSymbol, "Generator");
  1208. Gp[iteratorSymbol] = function () {
  1209. return this;
  1210. };
  1211. Gp.toString = function () {
  1212. return "[object Generator]";
  1213. };
  1214. function pushTryEntry(locs) {
  1215. var entry = {
  1216. tryLoc: locs[0]
  1217. };
  1218. if (1 in locs) {
  1219. entry.catchLoc = locs[1];
  1220. }
  1221. if (2 in locs) {
  1222. entry.finallyLoc = locs[2];
  1223. entry.afterLoc = locs[3];
  1224. }
  1225. this.tryEntries.push(entry);
  1226. }
  1227. function resetTryEntry(entry) {
  1228. var record = entry.completion || {};
  1229. record.type = "normal";
  1230. delete record.arg;
  1231. entry.completion = record;
  1232. }
  1233. function Context(tryLocsList) {
  1234. this.tryEntries = [{
  1235. tryLoc: "root"
  1236. }];
  1237. tryLocsList.forEach(pushTryEntry, this);
  1238. this.reset(true);
  1239. }
  1240. exports.keys = function (object) {
  1241. var keys = [];
  1242. for (var key in object) {
  1243. keys.push(key);
  1244. }
  1245. keys.reverse();
  1246. return function next() {
  1247. while (keys.length) {
  1248. var key = keys.pop();
  1249. if (key in object) {
  1250. next.value = key;
  1251. next.done = false;
  1252. return next;
  1253. }
  1254. }
  1255. next.done = true;
  1256. return next;
  1257. };
  1258. };
  1259. function values(iterable) {
  1260. if (iterable) {
  1261. var iteratorMethod = iterable[iteratorSymbol];
  1262. if (iteratorMethod) {
  1263. return iteratorMethod.call(iterable);
  1264. }
  1265. if (typeof iterable.next === "function") {
  1266. return iterable;
  1267. }
  1268. if (!isNaN(iterable.length)) {
  1269. var i = -1,
  1270. next = function next() {
  1271. while (++i < iterable.length) {
  1272. if (hasOwn.call(iterable, i)) {
  1273. next.value = iterable[i];
  1274. next.done = false;
  1275. return next;
  1276. }
  1277. }
  1278. next.value = undefined;
  1279. next.done = true;
  1280. return next;
  1281. };
  1282. return next.next = next;
  1283. }
  1284. }
  1285. return {
  1286. next: doneResult
  1287. };
  1288. }
  1289. exports.values = values;
  1290. function doneResult() {
  1291. return {
  1292. value: undefined,
  1293. done: true
  1294. };
  1295. }
  1296. Context.prototype = {
  1297. constructor: Context,
  1298. reset: function reset(skipTempReset) {
  1299. this.prev = 0;
  1300. this.next = 0;
  1301. this.sent = this._sent = undefined;
  1302. this.done = false;
  1303. this.delegate = null;
  1304. this.method = "next";
  1305. this.arg = undefined;
  1306. this.tryEntries.forEach(resetTryEntry);
  1307. if (!skipTempReset) {
  1308. for (var name in this) {
  1309. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  1310. this[name] = undefined;
  1311. }
  1312. }
  1313. }
  1314. },
  1315. stop: function stop() {
  1316. this.done = true;
  1317. var rootEntry = this.tryEntries[0];
  1318. var rootRecord = rootEntry.completion;
  1319. if (rootRecord.type === "throw") {
  1320. throw rootRecord.arg;
  1321. }
  1322. return this.rval;
  1323. },
  1324. dispatchException: function dispatchException(exception) {
  1325. if (this.done) {
  1326. throw exception;
  1327. }
  1328. var context = this;
  1329. function handle(loc, caught) {
  1330. record.type = "throw";
  1331. record.arg = exception;
  1332. context.next = loc;
  1333. if (caught) {
  1334. context.method = "next";
  1335. context.arg = undefined;
  1336. }
  1337. return !!caught;
  1338. }
  1339. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1340. var entry = this.tryEntries[i];
  1341. var record = entry.completion;
  1342. if (entry.tryLoc === "root") {
  1343. return handle("end");
  1344. }
  1345. if (entry.tryLoc <= this.prev) {
  1346. var hasCatch = hasOwn.call(entry, "catchLoc");
  1347. var hasFinally = hasOwn.call(entry, "finallyLoc");
  1348. if (hasCatch && hasFinally) {
  1349. if (this.prev < entry.catchLoc) {
  1350. return handle(entry.catchLoc, true);
  1351. } else if (this.prev < entry.finallyLoc) {
  1352. return handle(entry.finallyLoc);
  1353. }
  1354. } else if (hasCatch) {
  1355. if (this.prev < entry.catchLoc) {
  1356. return handle(entry.catchLoc, true);
  1357. }
  1358. } else if (hasFinally) {
  1359. if (this.prev < entry.finallyLoc) {
  1360. return handle(entry.finallyLoc);
  1361. }
  1362. } else {
  1363. throw new Error("try statement without catch or finally");
  1364. }
  1365. }
  1366. }
  1367. },
  1368. abrupt: function abrupt(type, arg) {
  1369. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1370. var entry = this.tryEntries[i];
  1371. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  1372. var finallyEntry = entry;
  1373. break;
  1374. }
  1375. }
  1376. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  1377. finallyEntry = null;
  1378. }
  1379. var record = finallyEntry ? finallyEntry.completion : {};
  1380. record.type = type;
  1381. record.arg = arg;
  1382. if (finallyEntry) {
  1383. this.method = "next";
  1384. this.next = finallyEntry.finallyLoc;
  1385. return ContinueSentinel;
  1386. }
  1387. return this.complete(record);
  1388. },
  1389. complete: function complete(record, afterLoc) {
  1390. if (record.type === "throw") {
  1391. throw record.arg;
  1392. }
  1393. if (record.type === "break" || record.type === "continue") {
  1394. this.next = record.arg;
  1395. } else if (record.type === "return") {
  1396. this.rval = this.arg = record.arg;
  1397. this.method = "return";
  1398. this.next = "end";
  1399. } else if (record.type === "normal" && afterLoc) {
  1400. this.next = afterLoc;
  1401. }
  1402. return ContinueSentinel;
  1403. },
  1404. finish: function finish(finallyLoc) {
  1405. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1406. var entry = this.tryEntries[i];
  1407. if (entry.finallyLoc === finallyLoc) {
  1408. this.complete(entry.completion, entry.afterLoc);
  1409. resetTryEntry(entry);
  1410. return ContinueSentinel;
  1411. }
  1412. }
  1413. },
  1414. "catch": function _catch(tryLoc) {
  1415. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1416. var entry = this.tryEntries[i];
  1417. if (entry.tryLoc === tryLoc) {
  1418. var record = entry.completion;
  1419. if (record.type === "throw") {
  1420. var thrown = record.arg;
  1421. resetTryEntry(entry);
  1422. }
  1423. return thrown;
  1424. }
  1425. }
  1426. throw new Error("illegal catch attempt");
  1427. },
  1428. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  1429. this.delegate = {
  1430. iterator: values(iterable),
  1431. resultName: resultName,
  1432. nextLoc: nextLoc
  1433. };
  1434. if (this.method === "next") {
  1435. this.arg = undefined;
  1436. }
  1437. return ContinueSentinel;
  1438. }
  1439. };
  1440. return exports;
  1441. }(( false ? undefined : _typeof(module)) === "object" ? module.exports : {});
  1442. try {
  1443. regeneratorRuntime = runtime;
  1444. } catch (accidentalStrictMode) {
  1445. Function("r", "regeneratorRuntime = r")(runtime);
  1446. }
  1447. /* WEBPACK VAR INJECTION */}.call(this, __w_pdfjs_require__(4)(module)))
  1448. /***/ }),
  1449. /* 4 */
  1450. /***/ (function(module, exports, __w_pdfjs_require__) {
  1451. "use strict";
  1452. module.exports = function (module) {
  1453. if (!module.webpackPolyfill) {
  1454. module.deprecate = function () {};
  1455. module.paths = [];
  1456. if (!module.children) module.children = [];
  1457. Object.defineProperty(module, "loaded", {
  1458. enumerable: true,
  1459. get: function get() {
  1460. return module.l;
  1461. }
  1462. });
  1463. Object.defineProperty(module, "id", {
  1464. enumerable: true,
  1465. get: function get() {
  1466. return module.i;
  1467. }
  1468. });
  1469. module.webpackPolyfill = 1;
  1470. }
  1471. return module;
  1472. };
  1473. /***/ }),
  1474. /* 5 */
  1475. /***/ (function(module, exports, __w_pdfjs_require__) {
  1476. "use strict";
  1477. Object.defineProperty(exports, "__esModule", {
  1478. value: true
  1479. });
  1480. exports.arrayByteLength = arrayByteLength;
  1481. exports.arraysToBytes = arraysToBytes;
  1482. exports.assert = assert;
  1483. exports.bytesToString = bytesToString;
  1484. exports.createPromiseCapability = createPromiseCapability;
  1485. exports.escapeString = escapeString;
  1486. exports.getModificationDate = getModificationDate;
  1487. exports.getVerbosityLevel = getVerbosityLevel;
  1488. exports.info = info;
  1489. exports.isArrayBuffer = isArrayBuffer;
  1490. exports.isArrayEqual = isArrayEqual;
  1491. exports.isBool = isBool;
  1492. exports.isNum = isNum;
  1493. exports.isString = isString;
  1494. exports.isSameOrigin = isSameOrigin;
  1495. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  1496. exports.removeNullCharacters = removeNullCharacters;
  1497. exports.setVerbosityLevel = setVerbosityLevel;
  1498. exports.shadow = shadow;
  1499. exports.string32 = string32;
  1500. exports.stringToBytes = stringToBytes;
  1501. exports.stringToPDFString = stringToPDFString;
  1502. exports.stringToUTF8String = stringToUTF8String;
  1503. exports.utf8StringToString = utf8StringToString;
  1504. exports.warn = warn;
  1505. exports.unreachable = unreachable;
  1506. exports.IsEvalSupportedCached = exports.IsLittleEndianCached = exports.createObjectURL = exports.FormatError = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.MissingPDFException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationStateModelType = exports.AnnotationReviewState = exports.AnnotationReplyType = exports.AnnotationMarkedState = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = exports.BaseException = void 0;
  1507. __w_pdfjs_require__(6);
  1508. 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); } }
  1509. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  1510. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1511. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1512. 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); }
  1513. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  1514. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1515. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  1516. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  1517. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  1518. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  1519. var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  1520. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  1521. var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  1522. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  1523. var PermissionFlag = {
  1524. PRINT: 0x04,
  1525. MODIFY_CONTENTS: 0x08,
  1526. COPY: 0x10,
  1527. MODIFY_ANNOTATIONS: 0x20,
  1528. FILL_INTERACTIVE_FORMS: 0x100,
  1529. COPY_FOR_ACCESSIBILITY: 0x200,
  1530. ASSEMBLE: 0x400,
  1531. PRINT_HIGH_QUALITY: 0x800
  1532. };
  1533. exports.PermissionFlag = PermissionFlag;
  1534. var TextRenderingMode = {
  1535. FILL: 0,
  1536. STROKE: 1,
  1537. FILL_STROKE: 2,
  1538. INVISIBLE: 3,
  1539. FILL_ADD_TO_PATH: 4,
  1540. STROKE_ADD_TO_PATH: 5,
  1541. FILL_STROKE_ADD_TO_PATH: 6,
  1542. ADD_TO_PATH: 7,
  1543. FILL_STROKE_MASK: 3,
  1544. ADD_TO_PATH_FLAG: 4
  1545. };
  1546. exports.TextRenderingMode = TextRenderingMode;
  1547. var ImageKind = {
  1548. GRAYSCALE_1BPP: 1,
  1549. RGB_24BPP: 2,
  1550. RGBA_32BPP: 3
  1551. };
  1552. exports.ImageKind = ImageKind;
  1553. var AnnotationType = {
  1554. TEXT: 1,
  1555. LINK: 2,
  1556. FREETEXT: 3,
  1557. LINE: 4,
  1558. SQUARE: 5,
  1559. CIRCLE: 6,
  1560. POLYGON: 7,
  1561. POLYLINE: 8,
  1562. HIGHLIGHT: 9,
  1563. UNDERLINE: 10,
  1564. SQUIGGLY: 11,
  1565. STRIKEOUT: 12,
  1566. STAMP: 13,
  1567. CARET: 14,
  1568. INK: 15,
  1569. POPUP: 16,
  1570. FILEATTACHMENT: 17,
  1571. SOUND: 18,
  1572. MOVIE: 19,
  1573. WIDGET: 20,
  1574. SCREEN: 21,
  1575. PRINTERMARK: 22,
  1576. TRAPNET: 23,
  1577. WATERMARK: 24,
  1578. THREED: 25,
  1579. REDACT: 26
  1580. };
  1581. exports.AnnotationType = AnnotationType;
  1582. var AnnotationStateModelType = {
  1583. MARKED: "Marked",
  1584. REVIEW: "Review"
  1585. };
  1586. exports.AnnotationStateModelType = AnnotationStateModelType;
  1587. var AnnotationMarkedState = {
  1588. MARKED: "Marked",
  1589. UNMARKED: "Unmarked"
  1590. };
  1591. exports.AnnotationMarkedState = AnnotationMarkedState;
  1592. var AnnotationReviewState = {
  1593. ACCEPTED: "Accepted",
  1594. REJECTED: "Rejected",
  1595. CANCELLED: "Cancelled",
  1596. COMPLETED: "Completed",
  1597. NONE: "None"
  1598. };
  1599. exports.AnnotationReviewState = AnnotationReviewState;
  1600. var AnnotationReplyType = {
  1601. GROUP: "Group",
  1602. REPLY: "R"
  1603. };
  1604. exports.AnnotationReplyType = AnnotationReplyType;
  1605. var AnnotationFlag = {
  1606. INVISIBLE: 0x01,
  1607. HIDDEN: 0x02,
  1608. PRINT: 0x04,
  1609. NOZOOM: 0x08,
  1610. NOROTATE: 0x10,
  1611. NOVIEW: 0x20,
  1612. READONLY: 0x40,
  1613. LOCKED: 0x80,
  1614. TOGGLENOVIEW: 0x100,
  1615. LOCKEDCONTENTS: 0x200
  1616. };
  1617. exports.AnnotationFlag = AnnotationFlag;
  1618. var AnnotationFieldFlag = {
  1619. READONLY: 0x0000001,
  1620. REQUIRED: 0x0000002,
  1621. NOEXPORT: 0x0000004,
  1622. MULTILINE: 0x0001000,
  1623. PASSWORD: 0x0002000,
  1624. NOTOGGLETOOFF: 0x0004000,
  1625. RADIO: 0x0008000,
  1626. PUSHBUTTON: 0x0010000,
  1627. COMBO: 0x0020000,
  1628. EDIT: 0x0040000,
  1629. SORT: 0x0080000,
  1630. FILESELECT: 0x0100000,
  1631. MULTISELECT: 0x0200000,
  1632. DONOTSPELLCHECK: 0x0400000,
  1633. DONOTSCROLL: 0x0800000,
  1634. COMB: 0x1000000,
  1635. RICHTEXT: 0x2000000,
  1636. RADIOSINUNISON: 0x2000000,
  1637. COMMITONSELCHANGE: 0x4000000
  1638. };
  1639. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  1640. var AnnotationBorderStyleType = {
  1641. SOLID: 1,
  1642. DASHED: 2,
  1643. BEVELED: 3,
  1644. INSET: 4,
  1645. UNDERLINE: 5
  1646. };
  1647. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  1648. var StreamType = {
  1649. UNKNOWN: "UNKNOWN",
  1650. FLATE: "FLATE",
  1651. LZW: "LZW",
  1652. DCT: "DCT",
  1653. JPX: "JPX",
  1654. JBIG: "JBIG",
  1655. A85: "A85",
  1656. AHX: "AHX",
  1657. CCF: "CCF",
  1658. RLX: "RLX"
  1659. };
  1660. exports.StreamType = StreamType;
  1661. var FontType = {
  1662. UNKNOWN: "UNKNOWN",
  1663. TYPE1: "TYPE1",
  1664. TYPE1C: "TYPE1C",
  1665. CIDFONTTYPE0: "CIDFONTTYPE0",
  1666. CIDFONTTYPE0C: "CIDFONTTYPE0C",
  1667. TRUETYPE: "TRUETYPE",
  1668. CIDFONTTYPE2: "CIDFONTTYPE2",
  1669. TYPE3: "TYPE3",
  1670. OPENTYPE: "OPENTYPE",
  1671. TYPE0: "TYPE0",
  1672. MMTYPE1: "MMTYPE1"
  1673. };
  1674. exports.FontType = FontType;
  1675. var VerbosityLevel = {
  1676. ERRORS: 0,
  1677. WARNINGS: 1,
  1678. INFOS: 5
  1679. };
  1680. exports.VerbosityLevel = VerbosityLevel;
  1681. var CMapCompressionType = {
  1682. NONE: 0,
  1683. BINARY: 1,
  1684. STREAM: 2
  1685. };
  1686. exports.CMapCompressionType = CMapCompressionType;
  1687. var OPS = {
  1688. dependency: 1,
  1689. setLineWidth: 2,
  1690. setLineCap: 3,
  1691. setLineJoin: 4,
  1692. setMiterLimit: 5,
  1693. setDash: 6,
  1694. setRenderingIntent: 7,
  1695. setFlatness: 8,
  1696. setGState: 9,
  1697. save: 10,
  1698. restore: 11,
  1699. transform: 12,
  1700. moveTo: 13,
  1701. lineTo: 14,
  1702. curveTo: 15,
  1703. curveTo2: 16,
  1704. curveTo3: 17,
  1705. closePath: 18,
  1706. rectangle: 19,
  1707. stroke: 20,
  1708. closeStroke: 21,
  1709. fill: 22,
  1710. eoFill: 23,
  1711. fillStroke: 24,
  1712. eoFillStroke: 25,
  1713. closeFillStroke: 26,
  1714. closeEOFillStroke: 27,
  1715. endPath: 28,
  1716. clip: 29,
  1717. eoClip: 30,
  1718. beginText: 31,
  1719. endText: 32,
  1720. setCharSpacing: 33,
  1721. setWordSpacing: 34,
  1722. setHScale: 35,
  1723. setLeading: 36,
  1724. setFont: 37,
  1725. setTextRenderingMode: 38,
  1726. setTextRise: 39,
  1727. moveText: 40,
  1728. setLeadingMoveText: 41,
  1729. setTextMatrix: 42,
  1730. nextLine: 43,
  1731. showText: 44,
  1732. showSpacedText: 45,
  1733. nextLineShowText: 46,
  1734. nextLineSetSpacingShowText: 47,
  1735. setCharWidth: 48,
  1736. setCharWidthAndBounds: 49,
  1737. setStrokeColorSpace: 50,
  1738. setFillColorSpace: 51,
  1739. setStrokeColor: 52,
  1740. setStrokeColorN: 53,
  1741. setFillColor: 54,
  1742. setFillColorN: 55,
  1743. setStrokeGray: 56,
  1744. setFillGray: 57,
  1745. setStrokeRGBColor: 58,
  1746. setFillRGBColor: 59,
  1747. setStrokeCMYKColor: 60,
  1748. setFillCMYKColor: 61,
  1749. shadingFill: 62,
  1750. beginInlineImage: 63,
  1751. beginImageData: 64,
  1752. endInlineImage: 65,
  1753. paintXObject: 66,
  1754. markPoint: 67,
  1755. markPointProps: 68,
  1756. beginMarkedContent: 69,
  1757. beginMarkedContentProps: 70,
  1758. endMarkedContent: 71,
  1759. beginCompat: 72,
  1760. endCompat: 73,
  1761. paintFormXObjectBegin: 74,
  1762. paintFormXObjectEnd: 75,
  1763. beginGroup: 76,
  1764. endGroup: 77,
  1765. beginAnnotations: 78,
  1766. endAnnotations: 79,
  1767. beginAnnotation: 80,
  1768. endAnnotation: 81,
  1769. paintJpegXObject: 82,
  1770. paintImageMaskXObject: 83,
  1771. paintImageMaskXObjectGroup: 84,
  1772. paintImageXObject: 85,
  1773. paintInlineImageXObject: 86,
  1774. paintInlineImageXObjectGroup: 87,
  1775. paintImageXObjectRepeat: 88,
  1776. paintImageMaskXObjectRepeat: 89,
  1777. paintSolidColorImageMask: 90,
  1778. constructPath: 91
  1779. };
  1780. exports.OPS = OPS;
  1781. var UNSUPPORTED_FEATURES = {
  1782. unknown: "unknown",
  1783. forms: "forms",
  1784. javaScript: "javaScript",
  1785. smask: "smask",
  1786. shadingPattern: "shadingPattern",
  1787. font: "font",
  1788. errorTilingPattern: "errorTilingPattern",
  1789. errorExtGState: "errorExtGState",
  1790. errorXObject: "errorXObject",
  1791. errorFontLoadType3: "errorFontLoadType3",
  1792. errorFontState: "errorFontState",
  1793. errorFontMissing: "errorFontMissing",
  1794. errorFontTranslate: "errorFontTranslate",
  1795. errorColorSpace: "errorColorSpace",
  1796. errorOperatorList: "errorOperatorList",
  1797. errorFontToUnicode: "errorFontToUnicode",
  1798. errorFontLoadNative: "errorFontLoadNative",
  1799. errorFontGetPath: "errorFontGetPath",
  1800. errorMarkedContent: "errorMarkedContent"
  1801. };
  1802. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  1803. var PasswordResponses = {
  1804. NEED_PASSWORD: 1,
  1805. INCORRECT_PASSWORD: 2
  1806. };
  1807. exports.PasswordResponses = PasswordResponses;
  1808. var verbosity = VerbosityLevel.WARNINGS;
  1809. function setVerbosityLevel(level) {
  1810. if (Number.isInteger(level)) {
  1811. verbosity = level;
  1812. }
  1813. }
  1814. function getVerbosityLevel() {
  1815. return verbosity;
  1816. }
  1817. function info(msg) {
  1818. if (verbosity >= VerbosityLevel.INFOS) {
  1819. console.log("Info: ".concat(msg));
  1820. }
  1821. }
  1822. function warn(msg) {
  1823. if (verbosity >= VerbosityLevel.WARNINGS) {
  1824. console.log("Warning: ".concat(msg));
  1825. }
  1826. }
  1827. function unreachable(msg) {
  1828. throw new Error(msg);
  1829. }
  1830. function assert(cond, msg) {
  1831. if (!cond) {
  1832. unreachable(msg);
  1833. }
  1834. }
  1835. function isSameOrigin(baseUrl, otherUrl) {
  1836. var base;
  1837. try {
  1838. base = new URL(baseUrl);
  1839. if (!base.origin || base.origin === "null") {
  1840. return false;
  1841. }
  1842. } catch (e) {
  1843. return false;
  1844. }
  1845. var other = new URL(otherUrl, base);
  1846. return base.origin === other.origin;
  1847. }
  1848. function _isValidProtocol(url) {
  1849. if (!url) {
  1850. return false;
  1851. }
  1852. switch (url.protocol) {
  1853. case "http:":
  1854. case "https:":
  1855. case "ftp:":
  1856. case "mailto:":
  1857. case "tel:":
  1858. return true;
  1859. default:
  1860. return false;
  1861. }
  1862. }
  1863. function createValidAbsoluteUrl(url, baseUrl) {
  1864. if (!url) {
  1865. return null;
  1866. }
  1867. try {
  1868. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  1869. if (_isValidProtocol(absoluteUrl)) {
  1870. return absoluteUrl;
  1871. }
  1872. } catch (ex) {}
  1873. return null;
  1874. }
  1875. function shadow(obj, prop, value) {
  1876. Object.defineProperty(obj, prop, {
  1877. value: value,
  1878. enumerable: true,
  1879. configurable: true,
  1880. writable: false
  1881. });
  1882. return value;
  1883. }
  1884. var BaseException = function BaseExceptionClosure() {
  1885. function BaseException(message) {
  1886. if (this.constructor === BaseException) {
  1887. unreachable("Cannot initialize BaseException.");
  1888. }
  1889. this.message = message;
  1890. this.name = this.constructor.name;
  1891. }
  1892. BaseException.prototype = new Error();
  1893. BaseException.constructor = BaseException;
  1894. return BaseException;
  1895. }();
  1896. exports.BaseException = BaseException;
  1897. var PasswordException = /*#__PURE__*/function (_BaseException) {
  1898. _inherits(PasswordException, _BaseException);
  1899. var _super = _createSuper(PasswordException);
  1900. function PasswordException(msg, code) {
  1901. var _this;
  1902. _classCallCheck(this, PasswordException);
  1903. _this = _super.call(this, msg);
  1904. _this.code = code;
  1905. return _this;
  1906. }
  1907. return PasswordException;
  1908. }(BaseException);
  1909. exports.PasswordException = PasswordException;
  1910. var UnknownErrorException = /*#__PURE__*/function (_BaseException2) {
  1911. _inherits(UnknownErrorException, _BaseException2);
  1912. var _super2 = _createSuper(UnknownErrorException);
  1913. function UnknownErrorException(msg, details) {
  1914. var _this2;
  1915. _classCallCheck(this, UnknownErrorException);
  1916. _this2 = _super2.call(this, msg);
  1917. _this2.details = details;
  1918. return _this2;
  1919. }
  1920. return UnknownErrorException;
  1921. }(BaseException);
  1922. exports.UnknownErrorException = UnknownErrorException;
  1923. var InvalidPDFException = /*#__PURE__*/function (_BaseException3) {
  1924. _inherits(InvalidPDFException, _BaseException3);
  1925. var _super3 = _createSuper(InvalidPDFException);
  1926. function InvalidPDFException() {
  1927. _classCallCheck(this, InvalidPDFException);
  1928. return _super3.apply(this, arguments);
  1929. }
  1930. return InvalidPDFException;
  1931. }(BaseException);
  1932. exports.InvalidPDFException = InvalidPDFException;
  1933. var MissingPDFException = /*#__PURE__*/function (_BaseException4) {
  1934. _inherits(MissingPDFException, _BaseException4);
  1935. var _super4 = _createSuper(MissingPDFException);
  1936. function MissingPDFException() {
  1937. _classCallCheck(this, MissingPDFException);
  1938. return _super4.apply(this, arguments);
  1939. }
  1940. return MissingPDFException;
  1941. }(BaseException);
  1942. exports.MissingPDFException = MissingPDFException;
  1943. var UnexpectedResponseException = /*#__PURE__*/function (_BaseException5) {
  1944. _inherits(UnexpectedResponseException, _BaseException5);
  1945. var _super5 = _createSuper(UnexpectedResponseException);
  1946. function UnexpectedResponseException(msg, status) {
  1947. var _this3;
  1948. _classCallCheck(this, UnexpectedResponseException);
  1949. _this3 = _super5.call(this, msg);
  1950. _this3.status = status;
  1951. return _this3;
  1952. }
  1953. return UnexpectedResponseException;
  1954. }(BaseException);
  1955. exports.UnexpectedResponseException = UnexpectedResponseException;
  1956. var FormatError = /*#__PURE__*/function (_BaseException6) {
  1957. _inherits(FormatError, _BaseException6);
  1958. var _super6 = _createSuper(FormatError);
  1959. function FormatError() {
  1960. _classCallCheck(this, FormatError);
  1961. return _super6.apply(this, arguments);
  1962. }
  1963. return FormatError;
  1964. }(BaseException);
  1965. exports.FormatError = FormatError;
  1966. var AbortException = /*#__PURE__*/function (_BaseException7) {
  1967. _inherits(AbortException, _BaseException7);
  1968. var _super7 = _createSuper(AbortException);
  1969. function AbortException() {
  1970. _classCallCheck(this, AbortException);
  1971. return _super7.apply(this, arguments);
  1972. }
  1973. return AbortException;
  1974. }(BaseException);
  1975. exports.AbortException = AbortException;
  1976. var NullCharactersRegExp = /\x00/g;
  1977. function removeNullCharacters(str) {
  1978. if (typeof str !== "string") {
  1979. warn("The argument for removeNullCharacters must be a string.");
  1980. return str;
  1981. }
  1982. return str.replace(NullCharactersRegExp, "");
  1983. }
  1984. function bytesToString(bytes) {
  1985. assert(bytes !== null && _typeof(bytes) === "object" && bytes.length !== undefined, "Invalid argument for bytesToString");
  1986. var length = bytes.length;
  1987. var MAX_ARGUMENT_COUNT = 8192;
  1988. if (length < MAX_ARGUMENT_COUNT) {
  1989. return String.fromCharCode.apply(null, bytes);
  1990. }
  1991. var strBuf = [];
  1992. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  1993. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  1994. var chunk = bytes.subarray(i, chunkEnd);
  1995. strBuf.push(String.fromCharCode.apply(null, chunk));
  1996. }
  1997. return strBuf.join("");
  1998. }
  1999. function stringToBytes(str) {
  2000. assert(typeof str === "string", "Invalid argument for stringToBytes");
  2001. var length = str.length;
  2002. var bytes = new Uint8Array(length);
  2003. for (var i = 0; i < length; ++i) {
  2004. bytes[i] = str.charCodeAt(i) & 0xff;
  2005. }
  2006. return bytes;
  2007. }
  2008. function arrayByteLength(arr) {
  2009. if (arr.length !== undefined) {
  2010. return arr.length;
  2011. }
  2012. assert(arr.byteLength !== undefined, "arrayByteLength - invalid argument.");
  2013. return arr.byteLength;
  2014. }
  2015. function arraysToBytes(arr) {
  2016. var length = arr.length;
  2017. if (length === 1 && arr[0] instanceof Uint8Array) {
  2018. return arr[0];
  2019. }
  2020. var resultLength = 0;
  2021. for (var i = 0; i < length; i++) {
  2022. resultLength += arrayByteLength(arr[i]);
  2023. }
  2024. var pos = 0;
  2025. var data = new Uint8Array(resultLength);
  2026. for (var _i = 0; _i < length; _i++) {
  2027. var item = arr[_i];
  2028. if (!(item instanceof Uint8Array)) {
  2029. if (typeof item === "string") {
  2030. item = stringToBytes(item);
  2031. } else {
  2032. item = new Uint8Array(item);
  2033. }
  2034. }
  2035. var itemLength = item.byteLength;
  2036. data.set(item, pos);
  2037. pos += itemLength;
  2038. }
  2039. return data;
  2040. }
  2041. function string32(value) {
  2042. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  2043. }
  2044. function isLittleEndian() {
  2045. var buffer8 = new Uint8Array(4);
  2046. buffer8[0] = 1;
  2047. var view32 = new Uint32Array(buffer8.buffer, 0, 1);
  2048. return view32[0] === 1;
  2049. }
  2050. var IsLittleEndianCached = {
  2051. get value() {
  2052. return shadow(this, "value", isLittleEndian());
  2053. }
  2054. };
  2055. exports.IsLittleEndianCached = IsLittleEndianCached;
  2056. function isEvalSupported() {
  2057. try {
  2058. new Function("");
  2059. return true;
  2060. } catch (e) {
  2061. return false;
  2062. }
  2063. }
  2064. var IsEvalSupportedCached = {
  2065. get value() {
  2066. return shadow(this, "value", isEvalSupported());
  2067. }
  2068. };
  2069. exports.IsEvalSupportedCached = IsEvalSupportedCached;
  2070. var rgbBuf = ["rgb(", 0, ",", 0, ",", 0, ")"];
  2071. var Util = /*#__PURE__*/function () {
  2072. function Util() {
  2073. _classCallCheck(this, Util);
  2074. }
  2075. _createClass(Util, null, [{
  2076. key: "makeCssRgb",
  2077. value: function makeCssRgb(r, g, b) {
  2078. rgbBuf[1] = r;
  2079. rgbBuf[3] = g;
  2080. rgbBuf[5] = b;
  2081. return rgbBuf.join("");
  2082. }
  2083. }, {
  2084. key: "transform",
  2085. value: function transform(m1, m2) {
  2086. 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]];
  2087. }
  2088. }, {
  2089. key: "applyTransform",
  2090. value: function applyTransform(p, m) {
  2091. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  2092. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  2093. return [xt, yt];
  2094. }
  2095. }, {
  2096. key: "applyInverseTransform",
  2097. value: function applyInverseTransform(p, m) {
  2098. var d = m[0] * m[3] - m[1] * m[2];
  2099. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  2100. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  2101. return [xt, yt];
  2102. }
  2103. }, {
  2104. key: "getAxialAlignedBoundingBox",
  2105. value: function getAxialAlignedBoundingBox(r, m) {
  2106. var p1 = Util.applyTransform(r, m);
  2107. var p2 = Util.applyTransform(r.slice(2, 4), m);
  2108. var p3 = Util.applyTransform([r[0], r[3]], m);
  2109. var p4 = Util.applyTransform([r[2], r[1]], m);
  2110. 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])];
  2111. }
  2112. }, {
  2113. key: "inverseTransform",
  2114. value: function inverseTransform(m) {
  2115. var d = m[0] * m[3] - m[1] * m[2];
  2116. 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];
  2117. }
  2118. }, {
  2119. key: "apply3dTransform",
  2120. value: function apply3dTransform(m, v) {
  2121. 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]];
  2122. }
  2123. }, {
  2124. key: "singularValueDecompose2dScale",
  2125. value: function singularValueDecompose2dScale(m) {
  2126. var transpose = [m[0], m[2], m[1], m[3]];
  2127. var a = m[0] * transpose[0] + m[1] * transpose[2];
  2128. var b = m[0] * transpose[1] + m[1] * transpose[3];
  2129. var c = m[2] * transpose[0] + m[3] * transpose[2];
  2130. var d = m[2] * transpose[1] + m[3] * transpose[3];
  2131. var first = (a + d) / 2;
  2132. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  2133. var sx = first + second || 1;
  2134. var sy = first - second || 1;
  2135. return [Math.sqrt(sx), Math.sqrt(sy)];
  2136. }
  2137. }, {
  2138. key: "normalizeRect",
  2139. value: function normalizeRect(rect) {
  2140. var r = rect.slice(0);
  2141. if (rect[0] > rect[2]) {
  2142. r[0] = rect[2];
  2143. r[2] = rect[0];
  2144. }
  2145. if (rect[1] > rect[3]) {
  2146. r[1] = rect[3];
  2147. r[3] = rect[1];
  2148. }
  2149. return r;
  2150. }
  2151. }, {
  2152. key: "intersect",
  2153. value: function intersect(rect1, rect2) {
  2154. function compare(a, b) {
  2155. return a - b;
  2156. }
  2157. var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare);
  2158. var orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare);
  2159. var result = [];
  2160. rect1 = Util.normalizeRect(rect1);
  2161. rect2 = Util.normalizeRect(rect2);
  2162. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  2163. result[0] = orderedX[1];
  2164. result[2] = orderedX[2];
  2165. } else {
  2166. return null;
  2167. }
  2168. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  2169. result[1] = orderedY[1];
  2170. result[3] = orderedY[2];
  2171. } else {
  2172. return null;
  2173. }
  2174. return result;
  2175. }
  2176. }]);
  2177. return Util;
  2178. }();
  2179. exports.Util = Util;
  2180. 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];
  2181. function stringToPDFString(str) {
  2182. var length = str.length,
  2183. strBuf = [];
  2184. if (str[0] === "\xFE" && str[1] === "\xFF") {
  2185. for (var i = 2; i < length; i += 2) {
  2186. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  2187. }
  2188. } else if (str[0] === "\xFF" && str[1] === "\xFE") {
  2189. for (var _i2 = 2; _i2 < length; _i2 += 2) {
  2190. strBuf.push(String.fromCharCode(str.charCodeAt(_i2 + 1) << 8 | str.charCodeAt(_i2)));
  2191. }
  2192. } else {
  2193. for (var _i3 = 0; _i3 < length; ++_i3) {
  2194. var code = PDFStringTranslateTable[str.charCodeAt(_i3)];
  2195. strBuf.push(code ? String.fromCharCode(code) : str.charAt(_i3));
  2196. }
  2197. }
  2198. return strBuf.join("");
  2199. }
  2200. function escapeString(str) {
  2201. return str.replace(/([\(\)\\])/g, "\\$1");
  2202. }
  2203. function stringToUTF8String(str) {
  2204. return decodeURIComponent(escape(str));
  2205. }
  2206. function utf8StringToString(str) {
  2207. return unescape(encodeURIComponent(str));
  2208. }
  2209. function isBool(v) {
  2210. return typeof v === "boolean";
  2211. }
  2212. function isNum(v) {
  2213. return typeof v === "number";
  2214. }
  2215. function isString(v) {
  2216. return typeof v === "string";
  2217. }
  2218. function isArrayBuffer(v) {
  2219. return _typeof(v) === "object" && v !== null && v.byteLength !== undefined;
  2220. }
  2221. function isArrayEqual(arr1, arr2) {
  2222. if (arr1.length !== arr2.length) {
  2223. return false;
  2224. }
  2225. return arr1.every(function (element, index) {
  2226. return element === arr2[index];
  2227. });
  2228. }
  2229. function getModificationDate() {
  2230. var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date(Date.now());
  2231. var buffer = [date.getUTCFullYear().toString(), (date.getUTCMonth() + 1).toString().padStart(2, "0"), (date.getUTCDate() + 1).toString().padStart(2, "0"), date.getUTCHours().toString().padStart(2, "0"), date.getUTCMinutes().toString().padStart(2, "0"), date.getUTCSeconds().toString().padStart(2, "0")];
  2232. return buffer.join("");
  2233. }
  2234. function createPromiseCapability() {
  2235. var capability = Object.create(null);
  2236. var isSettled = false;
  2237. Object.defineProperty(capability, "settled", {
  2238. get: function get() {
  2239. return isSettled;
  2240. }
  2241. });
  2242. capability.promise = new Promise(function (resolve, reject) {
  2243. capability.resolve = function (data) {
  2244. isSettled = true;
  2245. resolve(data);
  2246. };
  2247. capability.reject = function (reason) {
  2248. isSettled = true;
  2249. reject(reason);
  2250. };
  2251. });
  2252. return capability;
  2253. }
  2254. var createObjectURL = function createObjectURLClosure() {
  2255. var digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  2256. return function createObjectURL(data, contentType) {
  2257. var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2258. if (!forceDataSchema && URL.createObjectURL) {
  2259. var blob = new Blob([data], {
  2260. type: contentType
  2261. });
  2262. return URL.createObjectURL(blob);
  2263. }
  2264. var buffer = "data:".concat(contentType, ";base64,");
  2265. for (var i = 0, ii = data.length; i < ii; i += 3) {
  2266. var b1 = data[i] & 0xff;
  2267. var b2 = data[i + 1] & 0xff;
  2268. var b3 = data[i + 2] & 0xff;
  2269. var d1 = b1 >> 2,
  2270. d2 = (b1 & 3) << 4 | b2 >> 4;
  2271. var d3 = i + 1 < ii ? (b2 & 0xf) << 2 | b3 >> 6 : 64;
  2272. var d4 = i + 2 < ii ? b3 & 0x3f : 64;
  2273. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  2274. }
  2275. return buffer;
  2276. };
  2277. }();
  2278. exports.createObjectURL = createObjectURL;
  2279. /***/ }),
  2280. /* 6 */
  2281. /***/ (function(module, exports, __w_pdfjs_require__) {
  2282. "use strict";
  2283. var _is_node = __w_pdfjs_require__(7);
  2284. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2285. if (typeof globalThis === "undefined" || !globalThis._pdfjsCompatibilityChecked) {
  2286. if (typeof globalThis === "undefined" || globalThis.Math !== Math) {
  2287. globalThis = __w_pdfjs_require__(8);
  2288. }
  2289. globalThis._pdfjsCompatibilityChecked = true;
  2290. var hasDOM = (typeof window === "undefined" ? "undefined" : _typeof(window)) === "object" && (typeof document === "undefined" ? "undefined" : _typeof(document)) === "object";
  2291. var userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
  2292. var isIE = /Trident/.test(userAgent);
  2293. (function checkNodeBtoa() {
  2294. if (globalThis.btoa || !_is_node.isNodeJS) {
  2295. return;
  2296. }
  2297. globalThis.btoa = function (chars) {
  2298. return Buffer.from(chars, "binary").toString("base64");
  2299. };
  2300. })();
  2301. (function checkNodeAtob() {
  2302. if (globalThis.atob || !_is_node.isNodeJS) {
  2303. return;
  2304. }
  2305. globalThis.atob = function (input) {
  2306. return Buffer.from(input, "base64").toString("binary");
  2307. };
  2308. })();
  2309. (function checkChildNodeRemove() {
  2310. if (!hasDOM) {
  2311. return;
  2312. }
  2313. if (typeof Element.prototype.remove !== "undefined") {
  2314. return;
  2315. }
  2316. Element.prototype.remove = function () {
  2317. if (this.parentNode) {
  2318. this.parentNode.removeChild(this);
  2319. }
  2320. };
  2321. })();
  2322. (function checkDOMTokenListAddRemove() {
  2323. if (!hasDOM || _is_node.isNodeJS) {
  2324. return;
  2325. }
  2326. var div = document.createElement("div");
  2327. div.classList.add("testOne", "testTwo");
  2328. if (div.classList.contains("testOne") === true && div.classList.contains("testTwo") === true) {
  2329. return;
  2330. }
  2331. var OriginalDOMTokenListAdd = DOMTokenList.prototype.add;
  2332. var OriginalDOMTokenListRemove = DOMTokenList.prototype.remove;
  2333. DOMTokenList.prototype.add = function () {
  2334. for (var _len = arguments.length, tokens = new Array(_len), _key = 0; _key < _len; _key++) {
  2335. tokens[_key] = arguments[_key];
  2336. }
  2337. for (var _i = 0, _tokens = tokens; _i < _tokens.length; _i++) {
  2338. var token = _tokens[_i];
  2339. OriginalDOMTokenListAdd.call(this, token);
  2340. }
  2341. };
  2342. DOMTokenList.prototype.remove = function () {
  2343. for (var _len2 = arguments.length, tokens = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  2344. tokens[_key2] = arguments[_key2];
  2345. }
  2346. for (var _i2 = 0, _tokens2 = tokens; _i2 < _tokens2.length; _i2++) {
  2347. var token = _tokens2[_i2];
  2348. OriginalDOMTokenListRemove.call(this, token);
  2349. }
  2350. };
  2351. })();
  2352. (function checkDOMTokenListToggle() {
  2353. if (!hasDOM || _is_node.isNodeJS) {
  2354. return;
  2355. }
  2356. var div = document.createElement("div");
  2357. if (div.classList.toggle("test", 0) === false) {
  2358. return;
  2359. }
  2360. DOMTokenList.prototype.toggle = function (token) {
  2361. var force = arguments.length > 1 ? !!arguments[1] : !this.contains(token);
  2362. return this[force ? "add" : "remove"](token), force;
  2363. };
  2364. })();
  2365. (function checkWindowHistoryPushStateReplaceState() {
  2366. if (!hasDOM || !isIE) {
  2367. return;
  2368. }
  2369. var OriginalPushState = window.history.pushState;
  2370. var OriginalReplaceState = window.history.replaceState;
  2371. window.history.pushState = function (state, title, url) {
  2372. var args = url === undefined ? [state, title] : [state, title, url];
  2373. OriginalPushState.apply(this, args);
  2374. };
  2375. window.history.replaceState = function (state, title, url) {
  2376. var args = url === undefined ? [state, title] : [state, title, url];
  2377. OriginalReplaceState.apply(this, args);
  2378. };
  2379. })();
  2380. (function checkStringStartsWith() {
  2381. if (String.prototype.startsWith) {
  2382. return;
  2383. }
  2384. __w_pdfjs_require__(53);
  2385. })();
  2386. (function checkStringEndsWith() {
  2387. if (String.prototype.endsWith) {
  2388. return;
  2389. }
  2390. __w_pdfjs_require__(64);
  2391. })();
  2392. (function checkStringIncludes() {
  2393. if (String.prototype.includes) {
  2394. return;
  2395. }
  2396. __w_pdfjs_require__(66);
  2397. })();
  2398. (function checkArrayIncludes() {
  2399. if (Array.prototype.includes) {
  2400. return;
  2401. }
  2402. __w_pdfjs_require__(68);
  2403. })();
  2404. (function checkArrayFrom() {
  2405. if (Array.from) {
  2406. return;
  2407. }
  2408. __w_pdfjs_require__(76);
  2409. })();
  2410. (function checkObjectAssign() {
  2411. if (Object.assign) {
  2412. return;
  2413. }
  2414. __w_pdfjs_require__(98);
  2415. })();
  2416. (function checkObjectFromEntries() {
  2417. if (Object.fromEntries) {
  2418. return;
  2419. }
  2420. __w_pdfjs_require__(101);
  2421. })();
  2422. (function checkMathLog2() {
  2423. if (Math.log2) {
  2424. return;
  2425. }
  2426. Math.log2 = __w_pdfjs_require__(105);
  2427. })();
  2428. (function checkNumberIsNaN() {
  2429. if (Number.isNaN) {
  2430. return;
  2431. }
  2432. Number.isNaN = __w_pdfjs_require__(107);
  2433. })();
  2434. (function checkNumberIsInteger() {
  2435. if (Number.isInteger) {
  2436. return;
  2437. }
  2438. Number.isInteger = __w_pdfjs_require__(109);
  2439. })();
  2440. (function checkTypedArraySlice() {
  2441. if (Uint8Array.prototype.slice) {
  2442. return;
  2443. }
  2444. __w_pdfjs_require__(112);
  2445. })();
  2446. (function checkPromise() {
  2447. if (globalThis.Promise && globalThis.Promise.allSettled) {
  2448. return;
  2449. }
  2450. globalThis.Promise = __w_pdfjs_require__(117);
  2451. })();
  2452. (function checkURL() {
  2453. globalThis.URL = __w_pdfjs_require__(138);
  2454. })();
  2455. (function checkReadableStream() {
  2456. var isReadableStreamSupported = false;
  2457. if (typeof ReadableStream !== "undefined") {
  2458. try {
  2459. new ReadableStream({
  2460. start: function start(controller) {
  2461. controller.close();
  2462. }
  2463. });
  2464. isReadableStreamSupported = true;
  2465. } catch (e) {}
  2466. }
  2467. if (isReadableStreamSupported) {
  2468. return;
  2469. }
  2470. globalThis.ReadableStream = __w_pdfjs_require__(145).ReadableStream;
  2471. })();
  2472. (function checkMapEntries() {
  2473. if (globalThis.Map && globalThis.Map.prototype.entries) {
  2474. return;
  2475. }
  2476. globalThis.Map = __w_pdfjs_require__(146);
  2477. })();
  2478. (function checkSetEntries() {
  2479. if (globalThis.Set && globalThis.Set.prototype.entries) {
  2480. return;
  2481. }
  2482. globalThis.Set = __w_pdfjs_require__(153);
  2483. })();
  2484. (function checkWeakMap() {
  2485. if (globalThis.WeakMap) {
  2486. return;
  2487. }
  2488. globalThis.WeakMap = __w_pdfjs_require__(155);
  2489. })();
  2490. (function checkWeakSet() {
  2491. if (globalThis.WeakSet) {
  2492. return;
  2493. }
  2494. globalThis.WeakSet = __w_pdfjs_require__(161);
  2495. })();
  2496. (function checkStringCodePointAt() {
  2497. if (String.prototype.codePointAt) {
  2498. return;
  2499. }
  2500. __w_pdfjs_require__(163);
  2501. })();
  2502. (function checkStringFromCodePoint() {
  2503. if (String.fromCodePoint) {
  2504. return;
  2505. }
  2506. String.fromCodePoint = __w_pdfjs_require__(165);
  2507. })();
  2508. (function checkSymbol() {
  2509. if (globalThis.Symbol) {
  2510. return;
  2511. }
  2512. __w_pdfjs_require__(167);
  2513. })();
  2514. (function checkStringPadStart() {
  2515. if (String.prototype.padStart) {
  2516. return;
  2517. }
  2518. __w_pdfjs_require__(190);
  2519. })();
  2520. (function checkStringPadEnd() {
  2521. if (String.prototype.padEnd) {
  2522. return;
  2523. }
  2524. __w_pdfjs_require__(195);
  2525. })();
  2526. (function checkObjectValues() {
  2527. if (Object.values) {
  2528. return;
  2529. }
  2530. Object.values = __w_pdfjs_require__(197);
  2531. })();
  2532. (function checkObjectEntries() {
  2533. if (Object.entries) {
  2534. return;
  2535. }
  2536. Object.entries = __w_pdfjs_require__(200);
  2537. })();
  2538. }
  2539. /***/ }),
  2540. /* 7 */
  2541. /***/ (function(module, exports, __w_pdfjs_require__) {
  2542. "use strict";
  2543. Object.defineProperty(exports, "__esModule", {
  2544. value: true
  2545. });
  2546. exports.isNodeJS = void 0;
  2547. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2548. var isNodeJS = (typeof process === "undefined" ? "undefined" : _typeof(process)) === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
  2549. exports.isNodeJS = isNodeJS;
  2550. /***/ }),
  2551. /* 8 */
  2552. /***/ (function(module, exports, __w_pdfjs_require__) {
  2553. __w_pdfjs_require__(9);
  2554. module.exports = __w_pdfjs_require__(11);
  2555. /***/ }),
  2556. /* 9 */
  2557. /***/ (function(module, exports, __w_pdfjs_require__) {
  2558. var $ = __w_pdfjs_require__(10);
  2559. var global = __w_pdfjs_require__(11);
  2560. $({ global: true }, { globalThis: global });
  2561. /***/ }),
  2562. /* 10 */
  2563. /***/ (function(module, exports, __w_pdfjs_require__) {
  2564. var global = __w_pdfjs_require__(11);
  2565. var getOwnPropertyDescriptor = __w_pdfjs_require__(12).f;
  2566. var createNonEnumerableProperty = __w_pdfjs_require__(26);
  2567. var redefine = __w_pdfjs_require__(29);
  2568. var setGlobal = __w_pdfjs_require__(30);
  2569. var copyConstructorProperties = __w_pdfjs_require__(40);
  2570. var isForced = __w_pdfjs_require__(52);
  2571. module.exports = function (options, source) {
  2572. var TARGET = options.target;
  2573. var GLOBAL = options.global;
  2574. var STATIC = options.stat;
  2575. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  2576. if (GLOBAL) {
  2577. target = global;
  2578. } else if (STATIC) {
  2579. target = global[TARGET] || setGlobal(TARGET, {});
  2580. } else {
  2581. target = (global[TARGET] || {}).prototype;
  2582. }
  2583. if (target)
  2584. for (key in source) {
  2585. sourceProperty = source[key];
  2586. if (options.noTargetGet) {
  2587. descriptor = getOwnPropertyDescriptor(target, key);
  2588. targetProperty = descriptor && descriptor.value;
  2589. } else
  2590. targetProperty = target[key];
  2591. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  2592. if (!FORCED && targetProperty !== undefined) {
  2593. if (typeof sourceProperty === typeof targetProperty)
  2594. continue;
  2595. copyConstructorProperties(sourceProperty, targetProperty);
  2596. }
  2597. if (options.sham || targetProperty && targetProperty.sham) {
  2598. createNonEnumerableProperty(sourceProperty, 'sham', true);
  2599. }
  2600. redefine(target, key, sourceProperty, options);
  2601. }
  2602. };
  2603. /***/ }),
  2604. /* 11 */
  2605. /***/ (function(module, exports) {
  2606. var check = function (it) {
  2607. return it && it.Math == Math && it;
  2608. };
  2609. module.exports = check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || check(typeof self == 'object' && self) || check(typeof global == 'object' && global) || Function('return this')();
  2610. /***/ }),
  2611. /* 12 */
  2612. /***/ (function(module, exports, __w_pdfjs_require__) {
  2613. var DESCRIPTORS = __w_pdfjs_require__(13);
  2614. var propertyIsEnumerableModule = __w_pdfjs_require__(15);
  2615. var createPropertyDescriptor = __w_pdfjs_require__(16);
  2616. var toIndexedObject = __w_pdfjs_require__(17);
  2617. var toPrimitive = __w_pdfjs_require__(21);
  2618. var has = __w_pdfjs_require__(23);
  2619. var IE8_DOM_DEFINE = __w_pdfjs_require__(24);
  2620. var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  2621. exports.f = DESCRIPTORS ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  2622. O = toIndexedObject(O);
  2623. P = toPrimitive(P, true);
  2624. if (IE8_DOM_DEFINE)
  2625. try {
  2626. return nativeGetOwnPropertyDescriptor(O, P);
  2627. } catch (error) {
  2628. }
  2629. if (has(O, P))
  2630. return createPropertyDescriptor(!propertyIsEnumerableModule.f.call(O, P), O[P]);
  2631. };
  2632. /***/ }),
  2633. /* 13 */
  2634. /***/ (function(module, exports, __w_pdfjs_require__) {
  2635. var fails = __w_pdfjs_require__(14);
  2636. module.exports = !fails(function () {
  2637. return Object.defineProperty({}, 1, {
  2638. get: function () {
  2639. return 7;
  2640. }
  2641. })[1] != 7;
  2642. });
  2643. /***/ }),
  2644. /* 14 */
  2645. /***/ (function(module, exports) {
  2646. module.exports = function (exec) {
  2647. try {
  2648. return !!exec();
  2649. } catch (error) {
  2650. return true;
  2651. }
  2652. };
  2653. /***/ }),
  2654. /* 15 */
  2655. /***/ (function(module, exports, __w_pdfjs_require__) {
  2656. "use strict";
  2657. var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
  2658. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  2659. var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
  2660. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  2661. var descriptor = getOwnPropertyDescriptor(this, V);
  2662. return !!descriptor && descriptor.enumerable;
  2663. } : nativePropertyIsEnumerable;
  2664. /***/ }),
  2665. /* 16 */
  2666. /***/ (function(module, exports) {
  2667. module.exports = function (bitmap, value) {
  2668. return {
  2669. enumerable: !(bitmap & 1),
  2670. configurable: !(bitmap & 2),
  2671. writable: !(bitmap & 4),
  2672. value: value
  2673. };
  2674. };
  2675. /***/ }),
  2676. /* 17 */
  2677. /***/ (function(module, exports, __w_pdfjs_require__) {
  2678. var IndexedObject = __w_pdfjs_require__(18);
  2679. var requireObjectCoercible = __w_pdfjs_require__(20);
  2680. module.exports = function (it) {
  2681. return IndexedObject(requireObjectCoercible(it));
  2682. };
  2683. /***/ }),
  2684. /* 18 */
  2685. /***/ (function(module, exports, __w_pdfjs_require__) {
  2686. var fails = __w_pdfjs_require__(14);
  2687. var classof = __w_pdfjs_require__(19);
  2688. var split = ''.split;
  2689. module.exports = fails(function () {
  2690. return !Object('z').propertyIsEnumerable(0);
  2691. }) ? function (it) {
  2692. return classof(it) == 'String' ? split.call(it, '') : Object(it);
  2693. } : Object;
  2694. /***/ }),
  2695. /* 19 */
  2696. /***/ (function(module, exports) {
  2697. var toString = {}.toString;
  2698. module.exports = function (it) {
  2699. return toString.call(it).slice(8, -1);
  2700. };
  2701. /***/ }),
  2702. /* 20 */
  2703. /***/ (function(module, exports) {
  2704. module.exports = function (it) {
  2705. if (it == undefined)
  2706. throw TypeError("Can't call method on " + it);
  2707. return it;
  2708. };
  2709. /***/ }),
  2710. /* 21 */
  2711. /***/ (function(module, exports, __w_pdfjs_require__) {
  2712. var isObject = __w_pdfjs_require__(22);
  2713. module.exports = function (input, PREFERRED_STRING) {
  2714. if (!isObject(input))
  2715. return input;
  2716. var fn, val;
  2717. if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input)))
  2718. return val;
  2719. if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input)))
  2720. return val;
  2721. if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input)))
  2722. return val;
  2723. throw TypeError("Can't convert object to primitive value");
  2724. };
  2725. /***/ }),
  2726. /* 22 */
  2727. /***/ (function(module, exports) {
  2728. module.exports = function (it) {
  2729. return typeof it === 'object' ? it !== null : typeof it === 'function';
  2730. };
  2731. /***/ }),
  2732. /* 23 */
  2733. /***/ (function(module, exports) {
  2734. var hasOwnProperty = {}.hasOwnProperty;
  2735. module.exports = function (it, key) {
  2736. return hasOwnProperty.call(it, key);
  2737. };
  2738. /***/ }),
  2739. /* 24 */
  2740. /***/ (function(module, exports, __w_pdfjs_require__) {
  2741. var DESCRIPTORS = __w_pdfjs_require__(13);
  2742. var fails = __w_pdfjs_require__(14);
  2743. var createElement = __w_pdfjs_require__(25);
  2744. module.exports = !DESCRIPTORS && !fails(function () {
  2745. return Object.defineProperty(createElement('div'), 'a', {
  2746. get: function () {
  2747. return 7;
  2748. }
  2749. }).a != 7;
  2750. });
  2751. /***/ }),
  2752. /* 25 */
  2753. /***/ (function(module, exports, __w_pdfjs_require__) {
  2754. var global = __w_pdfjs_require__(11);
  2755. var isObject = __w_pdfjs_require__(22);
  2756. var document = global.document;
  2757. var EXISTS = isObject(document) && isObject(document.createElement);
  2758. module.exports = function (it) {
  2759. return EXISTS ? document.createElement(it) : {};
  2760. };
  2761. /***/ }),
  2762. /* 26 */
  2763. /***/ (function(module, exports, __w_pdfjs_require__) {
  2764. var DESCRIPTORS = __w_pdfjs_require__(13);
  2765. var definePropertyModule = __w_pdfjs_require__(27);
  2766. var createPropertyDescriptor = __w_pdfjs_require__(16);
  2767. module.exports = DESCRIPTORS ? function (object, key, value) {
  2768. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  2769. } : function (object, key, value) {
  2770. object[key] = value;
  2771. return object;
  2772. };
  2773. /***/ }),
  2774. /* 27 */
  2775. /***/ (function(module, exports, __w_pdfjs_require__) {
  2776. var DESCRIPTORS = __w_pdfjs_require__(13);
  2777. var IE8_DOM_DEFINE = __w_pdfjs_require__(24);
  2778. var anObject = __w_pdfjs_require__(28);
  2779. var toPrimitive = __w_pdfjs_require__(21);
  2780. var nativeDefineProperty = Object.defineProperty;
  2781. exports.f = DESCRIPTORS ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
  2782. anObject(O);
  2783. P = toPrimitive(P, true);
  2784. anObject(Attributes);
  2785. if (IE8_DOM_DEFINE)
  2786. try {
  2787. return nativeDefineProperty(O, P, Attributes);
  2788. } catch (error) {
  2789. }
  2790. if ('get' in Attributes || 'set' in Attributes)
  2791. throw TypeError('Accessors not supported');
  2792. if ('value' in Attributes)
  2793. O[P] = Attributes.value;
  2794. return O;
  2795. };
  2796. /***/ }),
  2797. /* 28 */
  2798. /***/ (function(module, exports, __w_pdfjs_require__) {
  2799. var isObject = __w_pdfjs_require__(22);
  2800. module.exports = function (it) {
  2801. if (!isObject(it)) {
  2802. throw TypeError(String(it) + ' is not an object');
  2803. }
  2804. return it;
  2805. };
  2806. /***/ }),
  2807. /* 29 */
  2808. /***/ (function(module, exports, __w_pdfjs_require__) {
  2809. var global = __w_pdfjs_require__(11);
  2810. var createNonEnumerableProperty = __w_pdfjs_require__(26);
  2811. var has = __w_pdfjs_require__(23);
  2812. var setGlobal = __w_pdfjs_require__(30);
  2813. var inspectSource = __w_pdfjs_require__(31);
  2814. var InternalStateModule = __w_pdfjs_require__(33);
  2815. var getInternalState = InternalStateModule.get;
  2816. var enforceInternalState = InternalStateModule.enforce;
  2817. var TEMPLATE = String(String).split('String');
  2818. (module.exports = function (O, key, value, options) {
  2819. var unsafe = options ? !!options.unsafe : false;
  2820. var simple = options ? !!options.enumerable : false;
  2821. var noTargetGet = options ? !!options.noTargetGet : false;
  2822. if (typeof value == 'function') {
  2823. if (typeof key == 'string' && !has(value, 'name'))
  2824. createNonEnumerableProperty(value, 'name', key);
  2825. enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
  2826. }
  2827. if (O === global) {
  2828. if (simple)
  2829. O[key] = value;
  2830. else
  2831. setGlobal(key, value);
  2832. return;
  2833. } else if (!unsafe) {
  2834. delete O[key];
  2835. } else if (!noTargetGet && O[key]) {
  2836. simple = true;
  2837. }
  2838. if (simple)
  2839. O[key] = value;
  2840. else
  2841. createNonEnumerableProperty(O, key, value);
  2842. })(Function.prototype, 'toString', function toString() {
  2843. return typeof this == 'function' && getInternalState(this).source || inspectSource(this);
  2844. });
  2845. /***/ }),
  2846. /* 30 */
  2847. /***/ (function(module, exports, __w_pdfjs_require__) {
  2848. var global = __w_pdfjs_require__(11);
  2849. var createNonEnumerableProperty = __w_pdfjs_require__(26);
  2850. module.exports = function (key, value) {
  2851. try {
  2852. createNonEnumerableProperty(global, key, value);
  2853. } catch (error) {
  2854. global[key] = value;
  2855. }
  2856. return value;
  2857. };
  2858. /***/ }),
  2859. /* 31 */
  2860. /***/ (function(module, exports, __w_pdfjs_require__) {
  2861. var store = __w_pdfjs_require__(32);
  2862. var functionToString = Function.toString;
  2863. if (typeof store.inspectSource != 'function') {
  2864. store.inspectSource = function (it) {
  2865. return functionToString.call(it);
  2866. };
  2867. }
  2868. module.exports = store.inspectSource;
  2869. /***/ }),
  2870. /* 32 */
  2871. /***/ (function(module, exports, __w_pdfjs_require__) {
  2872. var global = __w_pdfjs_require__(11);
  2873. var setGlobal = __w_pdfjs_require__(30);
  2874. var SHARED = '__core-js_shared__';
  2875. var store = global[SHARED] || setGlobal(SHARED, {});
  2876. module.exports = store;
  2877. /***/ }),
  2878. /* 33 */
  2879. /***/ (function(module, exports, __w_pdfjs_require__) {
  2880. var NATIVE_WEAK_MAP = __w_pdfjs_require__(34);
  2881. var global = __w_pdfjs_require__(11);
  2882. var isObject = __w_pdfjs_require__(22);
  2883. var createNonEnumerableProperty = __w_pdfjs_require__(26);
  2884. var objectHas = __w_pdfjs_require__(23);
  2885. var sharedKey = __w_pdfjs_require__(35);
  2886. var hiddenKeys = __w_pdfjs_require__(39);
  2887. var WeakMap = global.WeakMap;
  2888. var set, get, has;
  2889. var enforce = function (it) {
  2890. return has(it) ? get(it) : set(it, {});
  2891. };
  2892. var getterFor = function (TYPE) {
  2893. return function (it) {
  2894. var state;
  2895. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  2896. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  2897. }
  2898. return state;
  2899. };
  2900. };
  2901. if (NATIVE_WEAK_MAP) {
  2902. var store = new WeakMap();
  2903. var wmget = store.get;
  2904. var wmhas = store.has;
  2905. var wmset = store.set;
  2906. set = function (it, metadata) {
  2907. wmset.call(store, it, metadata);
  2908. return metadata;
  2909. };
  2910. get = function (it) {
  2911. return wmget.call(store, it) || {};
  2912. };
  2913. has = function (it) {
  2914. return wmhas.call(store, it);
  2915. };
  2916. } else {
  2917. var STATE = sharedKey('state');
  2918. hiddenKeys[STATE] = true;
  2919. set = function (it, metadata) {
  2920. createNonEnumerableProperty(it, STATE, metadata);
  2921. return metadata;
  2922. };
  2923. get = function (it) {
  2924. return objectHas(it, STATE) ? it[STATE] : {};
  2925. };
  2926. has = function (it) {
  2927. return objectHas(it, STATE);
  2928. };
  2929. }
  2930. module.exports = {
  2931. set: set,
  2932. get: get,
  2933. has: has,
  2934. enforce: enforce,
  2935. getterFor: getterFor
  2936. };
  2937. /***/ }),
  2938. /* 34 */
  2939. /***/ (function(module, exports, __w_pdfjs_require__) {
  2940. var global = __w_pdfjs_require__(11);
  2941. var inspectSource = __w_pdfjs_require__(31);
  2942. var WeakMap = global.WeakMap;
  2943. module.exports = typeof WeakMap === 'function' && /native code/.test(inspectSource(WeakMap));
  2944. /***/ }),
  2945. /* 35 */
  2946. /***/ (function(module, exports, __w_pdfjs_require__) {
  2947. var shared = __w_pdfjs_require__(36);
  2948. var uid = __w_pdfjs_require__(38);
  2949. var keys = shared('keys');
  2950. module.exports = function (key) {
  2951. return keys[key] || (keys[key] = uid(key));
  2952. };
  2953. /***/ }),
  2954. /* 36 */
  2955. /***/ (function(module, exports, __w_pdfjs_require__) {
  2956. var IS_PURE = __w_pdfjs_require__(37);
  2957. var store = __w_pdfjs_require__(32);
  2958. (module.exports = function (key, value) {
  2959. return store[key] || (store[key] = value !== undefined ? value : {});
  2960. })('versions', []).push({
  2961. version: '3.6.5',
  2962. mode: IS_PURE ? 'pure' : 'global',
  2963. copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
  2964. });
  2965. /***/ }),
  2966. /* 37 */
  2967. /***/ (function(module, exports) {
  2968. module.exports = false;
  2969. /***/ }),
  2970. /* 38 */
  2971. /***/ (function(module, exports) {
  2972. var id = 0;
  2973. var postfix = Math.random();
  2974. module.exports = function (key) {
  2975. return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
  2976. };
  2977. /***/ }),
  2978. /* 39 */
  2979. /***/ (function(module, exports) {
  2980. module.exports = {};
  2981. /***/ }),
  2982. /* 40 */
  2983. /***/ (function(module, exports, __w_pdfjs_require__) {
  2984. var has = __w_pdfjs_require__(23);
  2985. var ownKeys = __w_pdfjs_require__(41);
  2986. var getOwnPropertyDescriptorModule = __w_pdfjs_require__(12);
  2987. var definePropertyModule = __w_pdfjs_require__(27);
  2988. module.exports = function (target, source) {
  2989. var keys = ownKeys(source);
  2990. var defineProperty = definePropertyModule.f;
  2991. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  2992. for (var i = 0; i < keys.length; i++) {
  2993. var key = keys[i];
  2994. if (!has(target, key))
  2995. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  2996. }
  2997. };
  2998. /***/ }),
  2999. /* 41 */
  3000. /***/ (function(module, exports, __w_pdfjs_require__) {
  3001. var getBuiltIn = __w_pdfjs_require__(42);
  3002. var getOwnPropertyNamesModule = __w_pdfjs_require__(44);
  3003. var getOwnPropertySymbolsModule = __w_pdfjs_require__(51);
  3004. var anObject = __w_pdfjs_require__(28);
  3005. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  3006. var keys = getOwnPropertyNamesModule.f(anObject(it));
  3007. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  3008. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  3009. };
  3010. /***/ }),
  3011. /* 42 */
  3012. /***/ (function(module, exports, __w_pdfjs_require__) {
  3013. var path = __w_pdfjs_require__(43);
  3014. var global = __w_pdfjs_require__(11);
  3015. var aFunction = function (variable) {
  3016. return typeof variable == 'function' ? variable : undefined;
  3017. };
  3018. module.exports = function (namespace, method) {
  3019. return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace]) : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];
  3020. };
  3021. /***/ }),
  3022. /* 43 */
  3023. /***/ (function(module, exports, __w_pdfjs_require__) {
  3024. var global = __w_pdfjs_require__(11);
  3025. module.exports = global;
  3026. /***/ }),
  3027. /* 44 */
  3028. /***/ (function(module, exports, __w_pdfjs_require__) {
  3029. var internalObjectKeys = __w_pdfjs_require__(45);
  3030. var enumBugKeys = __w_pdfjs_require__(50);
  3031. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  3032. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  3033. return internalObjectKeys(O, hiddenKeys);
  3034. };
  3035. /***/ }),
  3036. /* 45 */
  3037. /***/ (function(module, exports, __w_pdfjs_require__) {
  3038. var has = __w_pdfjs_require__(23);
  3039. var toIndexedObject = __w_pdfjs_require__(17);
  3040. var indexOf = __w_pdfjs_require__(46).indexOf;
  3041. var hiddenKeys = __w_pdfjs_require__(39);
  3042. module.exports = function (object, names) {
  3043. var O = toIndexedObject(object);
  3044. var i = 0;
  3045. var result = [];
  3046. var key;
  3047. for (key in O)
  3048. !has(hiddenKeys, key) && has(O, key) && result.push(key);
  3049. while (names.length > i)
  3050. if (has(O, key = names[i++])) {
  3051. ~indexOf(result, key) || result.push(key);
  3052. }
  3053. return result;
  3054. };
  3055. /***/ }),
  3056. /* 46 */
  3057. /***/ (function(module, exports, __w_pdfjs_require__) {
  3058. var toIndexedObject = __w_pdfjs_require__(17);
  3059. var toLength = __w_pdfjs_require__(47);
  3060. var toAbsoluteIndex = __w_pdfjs_require__(49);
  3061. var createMethod = function (IS_INCLUDES) {
  3062. return function ($this, el, fromIndex) {
  3063. var O = toIndexedObject($this);
  3064. var length = toLength(O.length);
  3065. var index = toAbsoluteIndex(fromIndex, length);
  3066. var value;
  3067. if (IS_INCLUDES && el != el)
  3068. while (length > index) {
  3069. value = O[index++];
  3070. if (value != value)
  3071. return true;
  3072. }
  3073. else
  3074. for (; length > index; index++) {
  3075. if ((IS_INCLUDES || index in O) && O[index] === el)
  3076. return IS_INCLUDES || index || 0;
  3077. }
  3078. return !IS_INCLUDES && -1;
  3079. };
  3080. };
  3081. module.exports = {
  3082. includes: createMethod(true),
  3083. indexOf: createMethod(false)
  3084. };
  3085. /***/ }),
  3086. /* 47 */
  3087. /***/ (function(module, exports, __w_pdfjs_require__) {
  3088. var toInteger = __w_pdfjs_require__(48);
  3089. var min = Math.min;
  3090. module.exports = function (argument) {
  3091. return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0;
  3092. };
  3093. /***/ }),
  3094. /* 48 */
  3095. /***/ (function(module, exports) {
  3096. var ceil = Math.ceil;
  3097. var floor = Math.floor;
  3098. module.exports = function (argument) {
  3099. return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
  3100. };
  3101. /***/ }),
  3102. /* 49 */
  3103. /***/ (function(module, exports, __w_pdfjs_require__) {
  3104. var toInteger = __w_pdfjs_require__(48);
  3105. var max = Math.max;
  3106. var min = Math.min;
  3107. module.exports = function (index, length) {
  3108. var integer = toInteger(index);
  3109. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  3110. };
  3111. /***/ }),
  3112. /* 50 */
  3113. /***/ (function(module, exports) {
  3114. module.exports = [
  3115. 'constructor',
  3116. 'hasOwnProperty',
  3117. 'isPrototypeOf',
  3118. 'propertyIsEnumerable',
  3119. 'toLocaleString',
  3120. 'toString',
  3121. 'valueOf'
  3122. ];
  3123. /***/ }),
  3124. /* 51 */
  3125. /***/ (function(module, exports) {
  3126. exports.f = Object.getOwnPropertySymbols;
  3127. /***/ }),
  3128. /* 52 */
  3129. /***/ (function(module, exports, __w_pdfjs_require__) {
  3130. var fails = __w_pdfjs_require__(14);
  3131. var replacement = /#|\.prototype\./;
  3132. var isForced = function (feature, detection) {
  3133. var value = data[normalize(feature)];
  3134. return value == POLYFILL ? true : value == NATIVE ? false : typeof detection == 'function' ? fails(detection) : !!detection;
  3135. };
  3136. var normalize = isForced.normalize = function (string) {
  3137. return String(string).replace(replacement, '.').toLowerCase();
  3138. };
  3139. var data = isForced.data = {};
  3140. var NATIVE = isForced.NATIVE = 'N';
  3141. var POLYFILL = isForced.POLYFILL = 'P';
  3142. module.exports = isForced;
  3143. /***/ }),
  3144. /* 53 */
  3145. /***/ (function(module, exports, __w_pdfjs_require__) {
  3146. __w_pdfjs_require__(54);
  3147. var entryUnbind = __w_pdfjs_require__(61);
  3148. module.exports = entryUnbind('String', 'startsWith');
  3149. /***/ }),
  3150. /* 54 */
  3151. /***/ (function(module, exports, __w_pdfjs_require__) {
  3152. "use strict";
  3153. var $ = __w_pdfjs_require__(10);
  3154. var getOwnPropertyDescriptor = __w_pdfjs_require__(12).f;
  3155. var toLength = __w_pdfjs_require__(47);
  3156. var notARegExp = __w_pdfjs_require__(55);
  3157. var requireObjectCoercible = __w_pdfjs_require__(20);
  3158. var correctIsRegExpLogic = __w_pdfjs_require__(60);
  3159. var IS_PURE = __w_pdfjs_require__(37);
  3160. var nativeStartsWith = ''.startsWith;
  3161. var min = Math.min;
  3162. var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith');
  3163. var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
  3164. var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith');
  3165. return descriptor && !descriptor.writable;
  3166. }();
  3167. $({
  3168. target: 'String',
  3169. proto: true,
  3170. forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC
  3171. }, {
  3172. startsWith: function startsWith(searchString) {
  3173. var that = String(requireObjectCoercible(this));
  3174. notARegExp(searchString);
  3175. var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length));
  3176. var search = String(searchString);
  3177. return nativeStartsWith ? nativeStartsWith.call(that, search, index) : that.slice(index, index + search.length) === search;
  3178. }
  3179. });
  3180. /***/ }),
  3181. /* 55 */
  3182. /***/ (function(module, exports, __w_pdfjs_require__) {
  3183. var isRegExp = __w_pdfjs_require__(56);
  3184. module.exports = function (it) {
  3185. if (isRegExp(it)) {
  3186. throw TypeError("The method doesn't accept regular expressions");
  3187. }
  3188. return it;
  3189. };
  3190. /***/ }),
  3191. /* 56 */
  3192. /***/ (function(module, exports, __w_pdfjs_require__) {
  3193. var isObject = __w_pdfjs_require__(22);
  3194. var classof = __w_pdfjs_require__(19);
  3195. var wellKnownSymbol = __w_pdfjs_require__(57);
  3196. var MATCH = wellKnownSymbol('match');
  3197. module.exports = function (it) {
  3198. var isRegExp;
  3199. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');
  3200. };
  3201. /***/ }),
  3202. /* 57 */
  3203. /***/ (function(module, exports, __w_pdfjs_require__) {
  3204. var global = __w_pdfjs_require__(11);
  3205. var shared = __w_pdfjs_require__(36);
  3206. var has = __w_pdfjs_require__(23);
  3207. var uid = __w_pdfjs_require__(38);
  3208. var NATIVE_SYMBOL = __w_pdfjs_require__(58);
  3209. var USE_SYMBOL_AS_UID = __w_pdfjs_require__(59);
  3210. var WellKnownSymbolsStore = shared('wks');
  3211. var Symbol = global.Symbol;
  3212. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;
  3213. module.exports = function (name) {
  3214. if (!has(WellKnownSymbolsStore, name)) {
  3215. if (NATIVE_SYMBOL && has(Symbol, name))
  3216. WellKnownSymbolsStore[name] = Symbol[name];
  3217. else
  3218. WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
  3219. }
  3220. return WellKnownSymbolsStore[name];
  3221. };
  3222. /***/ }),
  3223. /* 58 */
  3224. /***/ (function(module, exports, __w_pdfjs_require__) {
  3225. var fails = __w_pdfjs_require__(14);
  3226. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  3227. return !String(Symbol());
  3228. });
  3229. /***/ }),
  3230. /* 59 */
  3231. /***/ (function(module, exports, __w_pdfjs_require__) {
  3232. var NATIVE_SYMBOL = __w_pdfjs_require__(58);
  3233. module.exports = NATIVE_SYMBOL && !Symbol.sham && typeof Symbol.iterator == 'symbol';
  3234. /***/ }),
  3235. /* 60 */
  3236. /***/ (function(module, exports, __w_pdfjs_require__) {
  3237. var wellKnownSymbol = __w_pdfjs_require__(57);
  3238. var MATCH = wellKnownSymbol('match');
  3239. module.exports = function (METHOD_NAME) {
  3240. var regexp = /./;
  3241. try {
  3242. '/./'[METHOD_NAME](regexp);
  3243. } catch (e) {
  3244. try {
  3245. regexp[MATCH] = false;
  3246. return '/./'[METHOD_NAME](regexp);
  3247. } catch (f) {
  3248. }
  3249. }
  3250. return false;
  3251. };
  3252. /***/ }),
  3253. /* 61 */
  3254. /***/ (function(module, exports, __w_pdfjs_require__) {
  3255. var global = __w_pdfjs_require__(11);
  3256. var bind = __w_pdfjs_require__(62);
  3257. var call = Function.call;
  3258. module.exports = function (CONSTRUCTOR, METHOD, length) {
  3259. return bind(call, global[CONSTRUCTOR].prototype[METHOD], length);
  3260. };
  3261. /***/ }),
  3262. /* 62 */
  3263. /***/ (function(module, exports, __w_pdfjs_require__) {
  3264. var aFunction = __w_pdfjs_require__(63);
  3265. module.exports = function (fn, that, length) {
  3266. aFunction(fn);
  3267. if (that === undefined)
  3268. return fn;
  3269. switch (length) {
  3270. case 0:
  3271. return function () {
  3272. return fn.call(that);
  3273. };
  3274. case 1:
  3275. return function (a) {
  3276. return fn.call(that, a);
  3277. };
  3278. case 2:
  3279. return function (a, b) {
  3280. return fn.call(that, a, b);
  3281. };
  3282. case 3:
  3283. return function (a, b, c) {
  3284. return fn.call(that, a, b, c);
  3285. };
  3286. }
  3287. return function () {
  3288. return fn.apply(that, arguments);
  3289. };
  3290. };
  3291. /***/ }),
  3292. /* 63 */
  3293. /***/ (function(module, exports) {
  3294. module.exports = function (it) {
  3295. if (typeof it != 'function') {
  3296. throw TypeError(String(it) + ' is not a function');
  3297. }
  3298. return it;
  3299. };
  3300. /***/ }),
  3301. /* 64 */
  3302. /***/ (function(module, exports, __w_pdfjs_require__) {
  3303. __w_pdfjs_require__(65);
  3304. var entryUnbind = __w_pdfjs_require__(61);
  3305. module.exports = entryUnbind('String', 'endsWith');
  3306. /***/ }),
  3307. /* 65 */
  3308. /***/ (function(module, exports, __w_pdfjs_require__) {
  3309. "use strict";
  3310. var $ = __w_pdfjs_require__(10);
  3311. var getOwnPropertyDescriptor = __w_pdfjs_require__(12).f;
  3312. var toLength = __w_pdfjs_require__(47);
  3313. var notARegExp = __w_pdfjs_require__(55);
  3314. var requireObjectCoercible = __w_pdfjs_require__(20);
  3315. var correctIsRegExpLogic = __w_pdfjs_require__(60);
  3316. var IS_PURE = __w_pdfjs_require__(37);
  3317. var nativeEndsWith = ''.endsWith;
  3318. var min = Math.min;
  3319. var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('endsWith');
  3320. var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
  3321. var descriptor = getOwnPropertyDescriptor(String.prototype, 'endsWith');
  3322. return descriptor && !descriptor.writable;
  3323. }();
  3324. $({
  3325. target: 'String',
  3326. proto: true,
  3327. forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC
  3328. }, {
  3329. endsWith: function endsWith(searchString) {
  3330. var that = String(requireObjectCoercible(this));
  3331. notARegExp(searchString);
  3332. var endPosition = arguments.length > 1 ? arguments[1] : undefined;
  3333. var len = toLength(that.length);
  3334. var end = endPosition === undefined ? len : min(toLength(endPosition), len);
  3335. var search = String(searchString);
  3336. return nativeEndsWith ? nativeEndsWith.call(that, search, end) : that.slice(end - search.length, end) === search;
  3337. }
  3338. });
  3339. /***/ }),
  3340. /* 66 */
  3341. /***/ (function(module, exports, __w_pdfjs_require__) {
  3342. __w_pdfjs_require__(67);
  3343. var entryUnbind = __w_pdfjs_require__(61);
  3344. module.exports = entryUnbind('String', 'includes');
  3345. /***/ }),
  3346. /* 67 */
  3347. /***/ (function(module, exports, __w_pdfjs_require__) {
  3348. "use strict";
  3349. var $ = __w_pdfjs_require__(10);
  3350. var notARegExp = __w_pdfjs_require__(55);
  3351. var requireObjectCoercible = __w_pdfjs_require__(20);
  3352. var correctIsRegExpLogic = __w_pdfjs_require__(60);
  3353. $({
  3354. target: 'String',
  3355. proto: true,
  3356. forced: !correctIsRegExpLogic('includes')
  3357. }, {
  3358. includes: function includes(searchString) {
  3359. return !!~String(requireObjectCoercible(this)).indexOf(notARegExp(searchString), arguments.length > 1 ? arguments[1] : undefined);
  3360. }
  3361. });
  3362. /***/ }),
  3363. /* 68 */
  3364. /***/ (function(module, exports, __w_pdfjs_require__) {
  3365. __w_pdfjs_require__(69);
  3366. var entryUnbind = __w_pdfjs_require__(61);
  3367. module.exports = entryUnbind('Array', 'includes');
  3368. /***/ }),
  3369. /* 69 */
  3370. /***/ (function(module, exports, __w_pdfjs_require__) {
  3371. "use strict";
  3372. var $ = __w_pdfjs_require__(10);
  3373. var $includes = __w_pdfjs_require__(46).includes;
  3374. var addToUnscopables = __w_pdfjs_require__(70);
  3375. var arrayMethodUsesToLength = __w_pdfjs_require__(75);
  3376. var USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', {
  3377. ACCESSORS: true,
  3378. 1: 0
  3379. });
  3380. $({
  3381. target: 'Array',
  3382. proto: true,
  3383. forced: !USES_TO_LENGTH
  3384. }, {
  3385. includes: function includes(el) {
  3386. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  3387. }
  3388. });
  3389. addToUnscopables('includes');
  3390. /***/ }),
  3391. /* 70 */
  3392. /***/ (function(module, exports, __w_pdfjs_require__) {
  3393. var wellKnownSymbol = __w_pdfjs_require__(57);
  3394. var create = __w_pdfjs_require__(71);
  3395. var definePropertyModule = __w_pdfjs_require__(27);
  3396. var UNSCOPABLES = wellKnownSymbol('unscopables');
  3397. var ArrayPrototype = Array.prototype;
  3398. if (ArrayPrototype[UNSCOPABLES] == undefined) {
  3399. definePropertyModule.f(ArrayPrototype, UNSCOPABLES, {
  3400. configurable: true,
  3401. value: create(null)
  3402. });
  3403. }
  3404. module.exports = function (key) {
  3405. ArrayPrototype[UNSCOPABLES][key] = true;
  3406. };
  3407. /***/ }),
  3408. /* 71 */
  3409. /***/ (function(module, exports, __w_pdfjs_require__) {
  3410. var anObject = __w_pdfjs_require__(28);
  3411. var defineProperties = __w_pdfjs_require__(72);
  3412. var enumBugKeys = __w_pdfjs_require__(50);
  3413. var hiddenKeys = __w_pdfjs_require__(39);
  3414. var html = __w_pdfjs_require__(74);
  3415. var documentCreateElement = __w_pdfjs_require__(25);
  3416. var sharedKey = __w_pdfjs_require__(35);
  3417. var GT = '>';
  3418. var LT = '<';
  3419. var PROTOTYPE = 'prototype';
  3420. var SCRIPT = 'script';
  3421. var IE_PROTO = sharedKey('IE_PROTO');
  3422. var EmptyConstructor = function () {
  3423. };
  3424. var scriptTag = function (content) {
  3425. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  3426. };
  3427. var NullProtoObjectViaActiveX = function (activeXDocument) {
  3428. activeXDocument.write(scriptTag(''));
  3429. activeXDocument.close();
  3430. var temp = activeXDocument.parentWindow.Object;
  3431. activeXDocument = null;
  3432. return temp;
  3433. };
  3434. var NullProtoObjectViaIFrame = function () {
  3435. var iframe = documentCreateElement('iframe');
  3436. var JS = 'java' + SCRIPT + ':';
  3437. var iframeDocument;
  3438. iframe.style.display = 'none';
  3439. html.appendChild(iframe);
  3440. iframe.src = String(JS);
  3441. iframeDocument = iframe.contentWindow.document;
  3442. iframeDocument.open();
  3443. iframeDocument.write(scriptTag('document.F=Object'));
  3444. iframeDocument.close();
  3445. return iframeDocument.F;
  3446. };
  3447. var activeXDocument;
  3448. var NullProtoObject = function () {
  3449. try {
  3450. activeXDocument = document.domain && new ActiveXObject('htmlfile');
  3451. } catch (error) {
  3452. }
  3453. NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame();
  3454. var length = enumBugKeys.length;
  3455. while (length--)
  3456. delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  3457. return NullProtoObject();
  3458. };
  3459. hiddenKeys[IE_PROTO] = true;
  3460. module.exports = Object.create || function create(O, Properties) {
  3461. var result;
  3462. if (O !== null) {
  3463. EmptyConstructor[PROTOTYPE] = anObject(O);
  3464. result = new EmptyConstructor();
  3465. EmptyConstructor[PROTOTYPE] = null;
  3466. result[IE_PROTO] = O;
  3467. } else
  3468. result = NullProtoObject();
  3469. return Properties === undefined ? result : defineProperties(result, Properties);
  3470. };
  3471. /***/ }),
  3472. /* 72 */
  3473. /***/ (function(module, exports, __w_pdfjs_require__) {
  3474. var DESCRIPTORS = __w_pdfjs_require__(13);
  3475. var definePropertyModule = __w_pdfjs_require__(27);
  3476. var anObject = __w_pdfjs_require__(28);
  3477. var objectKeys = __w_pdfjs_require__(73);
  3478. module.exports = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
  3479. anObject(O);
  3480. var keys = objectKeys(Properties);
  3481. var length = keys.length;
  3482. var index = 0;
  3483. var key;
  3484. while (length > index)
  3485. definePropertyModule.f(O, key = keys[index++], Properties[key]);
  3486. return O;
  3487. };
  3488. /***/ }),
  3489. /* 73 */
  3490. /***/ (function(module, exports, __w_pdfjs_require__) {
  3491. var internalObjectKeys = __w_pdfjs_require__(45);
  3492. var enumBugKeys = __w_pdfjs_require__(50);
  3493. module.exports = Object.keys || function keys(O) {
  3494. return internalObjectKeys(O, enumBugKeys);
  3495. };
  3496. /***/ }),
  3497. /* 74 */
  3498. /***/ (function(module, exports, __w_pdfjs_require__) {
  3499. var getBuiltIn = __w_pdfjs_require__(42);
  3500. module.exports = getBuiltIn('document', 'documentElement');
  3501. /***/ }),
  3502. /* 75 */
  3503. /***/ (function(module, exports, __w_pdfjs_require__) {
  3504. var DESCRIPTORS = __w_pdfjs_require__(13);
  3505. var fails = __w_pdfjs_require__(14);
  3506. var has = __w_pdfjs_require__(23);
  3507. var defineProperty = Object.defineProperty;
  3508. var cache = {};
  3509. var thrower = function (it) {
  3510. throw it;
  3511. };
  3512. module.exports = function (METHOD_NAME, options) {
  3513. if (has(cache, METHOD_NAME))
  3514. return cache[METHOD_NAME];
  3515. if (!options)
  3516. options = {};
  3517. var method = [][METHOD_NAME];
  3518. var ACCESSORS = has(options, 'ACCESSORS') ? options.ACCESSORS : false;
  3519. var argument0 = has(options, 0) ? options[0] : thrower;
  3520. var argument1 = has(options, 1) ? options[1] : undefined;
  3521. return cache[METHOD_NAME] = !!method && !fails(function () {
  3522. if (ACCESSORS && !DESCRIPTORS)
  3523. return true;
  3524. var O = { length: -1 };
  3525. if (ACCESSORS)
  3526. defineProperty(O, 1, {
  3527. enumerable: true,
  3528. get: thrower
  3529. });
  3530. else
  3531. O[1] = 1;
  3532. method.call(O, argument0, argument1);
  3533. });
  3534. };
  3535. /***/ }),
  3536. /* 76 */
  3537. /***/ (function(module, exports, __w_pdfjs_require__) {
  3538. __w_pdfjs_require__(77);
  3539. __w_pdfjs_require__(89);
  3540. var path = __w_pdfjs_require__(43);
  3541. module.exports = path.Array.from;
  3542. /***/ }),
  3543. /* 77 */
  3544. /***/ (function(module, exports, __w_pdfjs_require__) {
  3545. "use strict";
  3546. var charAt = __w_pdfjs_require__(78).charAt;
  3547. var InternalStateModule = __w_pdfjs_require__(33);
  3548. var defineIterator = __w_pdfjs_require__(79);
  3549. var STRING_ITERATOR = 'String Iterator';
  3550. var setInternalState = InternalStateModule.set;
  3551. var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);
  3552. defineIterator(String, 'String', function (iterated) {
  3553. setInternalState(this, {
  3554. type: STRING_ITERATOR,
  3555. string: String(iterated),
  3556. index: 0
  3557. });
  3558. }, function next() {
  3559. var state = getInternalState(this);
  3560. var string = state.string;
  3561. var index = state.index;
  3562. var point;
  3563. if (index >= string.length)
  3564. return {
  3565. value: undefined,
  3566. done: true
  3567. };
  3568. point = charAt(string, index);
  3569. state.index += point.length;
  3570. return {
  3571. value: point,
  3572. done: false
  3573. };
  3574. });
  3575. /***/ }),
  3576. /* 78 */
  3577. /***/ (function(module, exports, __w_pdfjs_require__) {
  3578. var toInteger = __w_pdfjs_require__(48);
  3579. var requireObjectCoercible = __w_pdfjs_require__(20);
  3580. var createMethod = function (CONVERT_TO_STRING) {
  3581. return function ($this, pos) {
  3582. var S = String(requireObjectCoercible($this));
  3583. var position = toInteger(pos);
  3584. var size = S.length;
  3585. var first, second;
  3586. if (position < 0 || position >= size)
  3587. return CONVERT_TO_STRING ? '' : undefined;
  3588. first = S.charCodeAt(position);
  3589. return first < 0xD800 || first > 0xDBFF || position + 1 === size || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF ? CONVERT_TO_STRING ? S.charAt(position) : first : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  3590. };
  3591. };
  3592. module.exports = {
  3593. codeAt: createMethod(false),
  3594. charAt: createMethod(true)
  3595. };
  3596. /***/ }),
  3597. /* 79 */
  3598. /***/ (function(module, exports, __w_pdfjs_require__) {
  3599. "use strict";
  3600. var $ = __w_pdfjs_require__(10);
  3601. var createIteratorConstructor = __w_pdfjs_require__(80);
  3602. var getPrototypeOf = __w_pdfjs_require__(82);
  3603. var setPrototypeOf = __w_pdfjs_require__(87);
  3604. var setToStringTag = __w_pdfjs_require__(85);
  3605. var createNonEnumerableProperty = __w_pdfjs_require__(26);
  3606. var redefine = __w_pdfjs_require__(29);
  3607. var wellKnownSymbol = __w_pdfjs_require__(57);
  3608. var IS_PURE = __w_pdfjs_require__(37);
  3609. var Iterators = __w_pdfjs_require__(86);
  3610. var IteratorsCore = __w_pdfjs_require__(81);
  3611. var IteratorPrototype = IteratorsCore.IteratorPrototype;
  3612. var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
  3613. var ITERATOR = wellKnownSymbol('iterator');
  3614. var KEYS = 'keys';
  3615. var VALUES = 'values';
  3616. var ENTRIES = 'entries';
  3617. var returnThis = function () {
  3618. return this;
  3619. };
  3620. module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  3621. createIteratorConstructor(IteratorConstructor, NAME, next);
  3622. var getIterationMethod = function (KIND) {
  3623. if (KIND === DEFAULT && defaultIterator)
  3624. return defaultIterator;
  3625. if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype)
  3626. return IterablePrototype[KIND];
  3627. switch (KIND) {
  3628. case KEYS:
  3629. return function keys() {
  3630. return new IteratorConstructor(this, KIND);
  3631. };
  3632. case VALUES:
  3633. return function values() {
  3634. return new IteratorConstructor(this, KIND);
  3635. };
  3636. case ENTRIES:
  3637. return function entries() {
  3638. return new IteratorConstructor(this, KIND);
  3639. };
  3640. }
  3641. return function () {
  3642. return new IteratorConstructor(this);
  3643. };
  3644. };
  3645. var TO_STRING_TAG = NAME + ' Iterator';
  3646. var INCORRECT_VALUES_NAME = false;
  3647. var IterablePrototype = Iterable.prototype;
  3648. var nativeIterator = IterablePrototype[ITERATOR] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT];
  3649. var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
  3650. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  3651. var CurrentIteratorPrototype, methods, KEY;
  3652. if (anyNativeIterator) {
  3653. CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
  3654. if (IteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
  3655. if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
  3656. if (setPrototypeOf) {
  3657. setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
  3658. } else if (typeof CurrentIteratorPrototype[ITERATOR] != 'function') {
  3659. createNonEnumerableProperty(CurrentIteratorPrototype, ITERATOR, returnThis);
  3660. }
  3661. }
  3662. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
  3663. if (IS_PURE)
  3664. Iterators[TO_STRING_TAG] = returnThis;
  3665. }
  3666. }
  3667. if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  3668. INCORRECT_VALUES_NAME = true;
  3669. defaultIterator = function values() {
  3670. return nativeIterator.call(this);
  3671. };
  3672. }
  3673. if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
  3674. createNonEnumerableProperty(IterablePrototype, ITERATOR, defaultIterator);
  3675. }
  3676. Iterators[NAME] = defaultIterator;
  3677. if (DEFAULT) {
  3678. methods = {
  3679. values: getIterationMethod(VALUES),
  3680. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  3681. entries: getIterationMethod(ENTRIES)
  3682. };
  3683. if (FORCED)
  3684. for (KEY in methods) {
  3685. if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  3686. redefine(IterablePrototype, KEY, methods[KEY]);
  3687. }
  3688. }
  3689. else
  3690. $({
  3691. target: NAME,
  3692. proto: true,
  3693. forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME
  3694. }, methods);
  3695. }
  3696. return methods;
  3697. };
  3698. /***/ }),
  3699. /* 80 */
  3700. /***/ (function(module, exports, __w_pdfjs_require__) {
  3701. "use strict";
  3702. var IteratorPrototype = __w_pdfjs_require__(81).IteratorPrototype;
  3703. var create = __w_pdfjs_require__(71);
  3704. var createPropertyDescriptor = __w_pdfjs_require__(16);
  3705. var setToStringTag = __w_pdfjs_require__(85);
  3706. var Iterators = __w_pdfjs_require__(86);
  3707. var returnThis = function () {
  3708. return this;
  3709. };
  3710. module.exports = function (IteratorConstructor, NAME, next) {
  3711. var TO_STRING_TAG = NAME + ' Iterator';
  3712. IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(1, next) });
  3713. setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
  3714. Iterators[TO_STRING_TAG] = returnThis;
  3715. return IteratorConstructor;
  3716. };
  3717. /***/ }),
  3718. /* 81 */
  3719. /***/ (function(module, exports, __w_pdfjs_require__) {
  3720. "use strict";
  3721. var getPrototypeOf = __w_pdfjs_require__(82);
  3722. var createNonEnumerableProperty = __w_pdfjs_require__(26);
  3723. var has = __w_pdfjs_require__(23);
  3724. var wellKnownSymbol = __w_pdfjs_require__(57);
  3725. var IS_PURE = __w_pdfjs_require__(37);
  3726. var ITERATOR = wellKnownSymbol('iterator');
  3727. var BUGGY_SAFARI_ITERATORS = false;
  3728. var returnThis = function () {
  3729. return this;
  3730. };
  3731. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  3732. if ([].keys) {
  3733. arrayIterator = [].keys();
  3734. if (!('next' in arrayIterator))
  3735. BUGGY_SAFARI_ITERATORS = true;
  3736. else {
  3737. PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
  3738. if (PrototypeOfArrayIteratorPrototype !== Object.prototype)
  3739. IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  3740. }
  3741. }
  3742. if (IteratorPrototype == undefined)
  3743. IteratorPrototype = {};
  3744. if (!IS_PURE && !has(IteratorPrototype, ITERATOR)) {
  3745. createNonEnumerableProperty(IteratorPrototype, ITERATOR, returnThis);
  3746. }
  3747. module.exports = {
  3748. IteratorPrototype: IteratorPrototype,
  3749. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  3750. };
  3751. /***/ }),
  3752. /* 82 */
  3753. /***/ (function(module, exports, __w_pdfjs_require__) {
  3754. var has = __w_pdfjs_require__(23);
  3755. var toObject = __w_pdfjs_require__(83);
  3756. var sharedKey = __w_pdfjs_require__(35);
  3757. var CORRECT_PROTOTYPE_GETTER = __w_pdfjs_require__(84);
  3758. var IE_PROTO = sharedKey('IE_PROTO');
  3759. var ObjectPrototype = Object.prototype;
  3760. module.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {
  3761. O = toObject(O);
  3762. if (has(O, IE_PROTO))
  3763. return O[IE_PROTO];
  3764. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  3765. return O.constructor.prototype;
  3766. }
  3767. return O instanceof Object ? ObjectPrototype : null;
  3768. };
  3769. /***/ }),
  3770. /* 83 */
  3771. /***/ (function(module, exports, __w_pdfjs_require__) {
  3772. var requireObjectCoercible = __w_pdfjs_require__(20);
  3773. module.exports = function (argument) {
  3774. return Object(requireObjectCoercible(argument));
  3775. };
  3776. /***/ }),
  3777. /* 84 */
  3778. /***/ (function(module, exports, __w_pdfjs_require__) {
  3779. var fails = __w_pdfjs_require__(14);
  3780. module.exports = !fails(function () {
  3781. function F() {
  3782. }
  3783. F.prototype.constructor = null;
  3784. return Object.getPrototypeOf(new F()) !== F.prototype;
  3785. });
  3786. /***/ }),
  3787. /* 85 */
  3788. /***/ (function(module, exports, __w_pdfjs_require__) {
  3789. var defineProperty = __w_pdfjs_require__(27).f;
  3790. var has = __w_pdfjs_require__(23);
  3791. var wellKnownSymbol = __w_pdfjs_require__(57);
  3792. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  3793. module.exports = function (it, TAG, STATIC) {
  3794. if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {
  3795. defineProperty(it, TO_STRING_TAG, {
  3796. configurable: true,
  3797. value: TAG
  3798. });
  3799. }
  3800. };
  3801. /***/ }),
  3802. /* 86 */
  3803. /***/ (function(module, exports) {
  3804. module.exports = {};
  3805. /***/ }),
  3806. /* 87 */
  3807. /***/ (function(module, exports, __w_pdfjs_require__) {
  3808. var anObject = __w_pdfjs_require__(28);
  3809. var aPossiblePrototype = __w_pdfjs_require__(88);
  3810. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
  3811. var CORRECT_SETTER = false;
  3812. var test = {};
  3813. var setter;
  3814. try {
  3815. setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
  3816. setter.call(test, []);
  3817. CORRECT_SETTER = test instanceof Array;
  3818. } catch (error) {
  3819. }
  3820. return function setPrototypeOf(O, proto) {
  3821. anObject(O);
  3822. aPossiblePrototype(proto);
  3823. if (CORRECT_SETTER)
  3824. setter.call(O, proto);
  3825. else
  3826. O.__proto__ = proto;
  3827. return O;
  3828. };
  3829. }() : undefined);
  3830. /***/ }),
  3831. /* 88 */
  3832. /***/ (function(module, exports, __w_pdfjs_require__) {
  3833. var isObject = __w_pdfjs_require__(22);
  3834. module.exports = function (it) {
  3835. if (!isObject(it) && it !== null) {
  3836. throw TypeError("Can't set " + String(it) + ' as a prototype');
  3837. }
  3838. return it;
  3839. };
  3840. /***/ }),
  3841. /* 89 */
  3842. /***/ (function(module, exports, __w_pdfjs_require__) {
  3843. var $ = __w_pdfjs_require__(10);
  3844. var from = __w_pdfjs_require__(90);
  3845. var checkCorrectnessOfIteration = __w_pdfjs_require__(97);
  3846. var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
  3847. Array.from(iterable);
  3848. });
  3849. $({
  3850. target: 'Array',
  3851. stat: true,
  3852. forced: INCORRECT_ITERATION
  3853. }, { from: from });
  3854. /***/ }),
  3855. /* 90 */
  3856. /***/ (function(module, exports, __w_pdfjs_require__) {
  3857. "use strict";
  3858. var bind = __w_pdfjs_require__(62);
  3859. var toObject = __w_pdfjs_require__(83);
  3860. var callWithSafeIterationClosing = __w_pdfjs_require__(91);
  3861. var isArrayIteratorMethod = __w_pdfjs_require__(92);
  3862. var toLength = __w_pdfjs_require__(47);
  3863. var createProperty = __w_pdfjs_require__(93);
  3864. var getIteratorMethod = __w_pdfjs_require__(94);
  3865. module.exports = function from(arrayLike) {
  3866. var O = toObject(arrayLike);
  3867. var C = typeof this == 'function' ? this : Array;
  3868. var argumentsLength = arguments.length;
  3869. var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
  3870. var mapping = mapfn !== undefined;
  3871. var iteratorMethod = getIteratorMethod(O);
  3872. var index = 0;
  3873. var length, result, step, iterator, next, value;
  3874. if (mapping)
  3875. mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2);
  3876. if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod(iteratorMethod))) {
  3877. iterator = iteratorMethod.call(O);
  3878. next = iterator.next;
  3879. result = new C();
  3880. for (; !(step = next.call(iterator)).done; index++) {
  3881. value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [
  3882. step.value,
  3883. index
  3884. ], true) : step.value;
  3885. createProperty(result, index, value);
  3886. }
  3887. } else {
  3888. length = toLength(O.length);
  3889. result = new C(length);
  3890. for (; length > index; index++) {
  3891. value = mapping ? mapfn(O[index], index) : O[index];
  3892. createProperty(result, index, value);
  3893. }
  3894. }
  3895. result.length = index;
  3896. return result;
  3897. };
  3898. /***/ }),
  3899. /* 91 */
  3900. /***/ (function(module, exports, __w_pdfjs_require__) {
  3901. var anObject = __w_pdfjs_require__(28);
  3902. module.exports = function (iterator, fn, value, ENTRIES) {
  3903. try {
  3904. return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
  3905. } catch (error) {
  3906. var returnMethod = iterator['return'];
  3907. if (returnMethod !== undefined)
  3908. anObject(returnMethod.call(iterator));
  3909. throw error;
  3910. }
  3911. };
  3912. /***/ }),
  3913. /* 92 */
  3914. /***/ (function(module, exports, __w_pdfjs_require__) {
  3915. var wellKnownSymbol = __w_pdfjs_require__(57);
  3916. var Iterators = __w_pdfjs_require__(86);
  3917. var ITERATOR = wellKnownSymbol('iterator');
  3918. var ArrayPrototype = Array.prototype;
  3919. module.exports = function (it) {
  3920. return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
  3921. };
  3922. /***/ }),
  3923. /* 93 */
  3924. /***/ (function(module, exports, __w_pdfjs_require__) {
  3925. "use strict";
  3926. var toPrimitive = __w_pdfjs_require__(21);
  3927. var definePropertyModule = __w_pdfjs_require__(27);
  3928. var createPropertyDescriptor = __w_pdfjs_require__(16);
  3929. module.exports = function (object, key, value) {
  3930. var propertyKey = toPrimitive(key);
  3931. if (propertyKey in object)
  3932. definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
  3933. else
  3934. object[propertyKey] = value;
  3935. };
  3936. /***/ }),
  3937. /* 94 */
  3938. /***/ (function(module, exports, __w_pdfjs_require__) {
  3939. var classof = __w_pdfjs_require__(95);
  3940. var Iterators = __w_pdfjs_require__(86);
  3941. var wellKnownSymbol = __w_pdfjs_require__(57);
  3942. var ITERATOR = wellKnownSymbol('iterator');
  3943. module.exports = function (it) {
  3944. if (it != undefined)
  3945. return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)];
  3946. };
  3947. /***/ }),
  3948. /* 95 */
  3949. /***/ (function(module, exports, __w_pdfjs_require__) {
  3950. var TO_STRING_TAG_SUPPORT = __w_pdfjs_require__(96);
  3951. var classofRaw = __w_pdfjs_require__(19);
  3952. var wellKnownSymbol = __w_pdfjs_require__(57);
  3953. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  3954. var CORRECT_ARGUMENTS = classofRaw(function () {
  3955. return arguments;
  3956. }()) == 'Arguments';
  3957. var tryGet = function (it, key) {
  3958. try {
  3959. return it[key];
  3960. } catch (error) {
  3961. }
  3962. };
  3963. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  3964. var O, tag, result;
  3965. return it === undefined ? 'Undefined' : it === null ? 'Null' : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag : CORRECT_ARGUMENTS ? classofRaw(O) : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
  3966. };
  3967. /***/ }),
  3968. /* 96 */
  3969. /***/ (function(module, exports, __w_pdfjs_require__) {
  3970. var wellKnownSymbol = __w_pdfjs_require__(57);
  3971. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  3972. var test = {};
  3973. test[TO_STRING_TAG] = 'z';
  3974. module.exports = String(test) === '[object z]';
  3975. /***/ }),
  3976. /* 97 */
  3977. /***/ (function(module, exports, __w_pdfjs_require__) {
  3978. var wellKnownSymbol = __w_pdfjs_require__(57);
  3979. var ITERATOR = wellKnownSymbol('iterator');
  3980. var SAFE_CLOSING = false;
  3981. try {
  3982. var called = 0;
  3983. var iteratorWithReturn = {
  3984. next: function () {
  3985. return { done: !!called++ };
  3986. },
  3987. 'return': function () {
  3988. SAFE_CLOSING = true;
  3989. }
  3990. };
  3991. iteratorWithReturn[ITERATOR] = function () {
  3992. return this;
  3993. };
  3994. Array.from(iteratorWithReturn, function () {
  3995. throw 2;
  3996. });
  3997. } catch (error) {
  3998. }
  3999. module.exports = function (exec, SKIP_CLOSING) {
  4000. if (!SKIP_CLOSING && !SAFE_CLOSING)
  4001. return false;
  4002. var ITERATION_SUPPORT = false;
  4003. try {
  4004. var object = {};
  4005. object[ITERATOR] = function () {
  4006. return {
  4007. next: function () {
  4008. return { done: ITERATION_SUPPORT = true };
  4009. }
  4010. };
  4011. };
  4012. exec(object);
  4013. } catch (error) {
  4014. }
  4015. return ITERATION_SUPPORT;
  4016. };
  4017. /***/ }),
  4018. /* 98 */
  4019. /***/ (function(module, exports, __w_pdfjs_require__) {
  4020. __w_pdfjs_require__(99);
  4021. var path = __w_pdfjs_require__(43);
  4022. module.exports = path.Object.assign;
  4023. /***/ }),
  4024. /* 99 */
  4025. /***/ (function(module, exports, __w_pdfjs_require__) {
  4026. var $ = __w_pdfjs_require__(10);
  4027. var assign = __w_pdfjs_require__(100);
  4028. $({
  4029. target: 'Object',
  4030. stat: true,
  4031. forced: Object.assign !== assign
  4032. }, { assign: assign });
  4033. /***/ }),
  4034. /* 100 */
  4035. /***/ (function(module, exports, __w_pdfjs_require__) {
  4036. "use strict";
  4037. var DESCRIPTORS = __w_pdfjs_require__(13);
  4038. var fails = __w_pdfjs_require__(14);
  4039. var objectKeys = __w_pdfjs_require__(73);
  4040. var getOwnPropertySymbolsModule = __w_pdfjs_require__(51);
  4041. var propertyIsEnumerableModule = __w_pdfjs_require__(15);
  4042. var toObject = __w_pdfjs_require__(83);
  4043. var IndexedObject = __w_pdfjs_require__(18);
  4044. var nativeAssign = Object.assign;
  4045. var defineProperty = Object.defineProperty;
  4046. module.exports = !nativeAssign || fails(function () {
  4047. if (DESCRIPTORS && nativeAssign({ b: 1 }, nativeAssign(defineProperty({}, 'a', {
  4048. enumerable: true,
  4049. get: function () {
  4050. defineProperty(this, 'b', {
  4051. value: 3,
  4052. enumerable: false
  4053. });
  4054. }
  4055. }), { b: 2 })).b !== 1)
  4056. return true;
  4057. var A = {};
  4058. var B = {};
  4059. var symbol = Symbol();
  4060. var alphabet = 'abcdefghijklmnopqrst';
  4061. A[symbol] = 7;
  4062. alphabet.split('').forEach(function (chr) {
  4063. B[chr] = chr;
  4064. });
  4065. return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
  4066. }) ? function assign(target, source) {
  4067. var T = toObject(target);
  4068. var argumentsLength = arguments.length;
  4069. var index = 1;
  4070. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  4071. var propertyIsEnumerable = propertyIsEnumerableModule.f;
  4072. while (argumentsLength > index) {
  4073. var S = IndexedObject(arguments[index++]);
  4074. var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
  4075. var length = keys.length;
  4076. var j = 0;
  4077. var key;
  4078. while (length > j) {
  4079. key = keys[j++];
  4080. if (!DESCRIPTORS || propertyIsEnumerable.call(S, key))
  4081. T[key] = S[key];
  4082. }
  4083. }
  4084. return T;
  4085. } : nativeAssign;
  4086. /***/ }),
  4087. /* 101 */
  4088. /***/ (function(module, exports, __w_pdfjs_require__) {
  4089. __w_pdfjs_require__(102);
  4090. __w_pdfjs_require__(103);
  4091. var path = __w_pdfjs_require__(43);
  4092. module.exports = path.Object.fromEntries;
  4093. /***/ }),
  4094. /* 102 */
  4095. /***/ (function(module, exports, __w_pdfjs_require__) {
  4096. "use strict";
  4097. var toIndexedObject = __w_pdfjs_require__(17);
  4098. var addToUnscopables = __w_pdfjs_require__(70);
  4099. var Iterators = __w_pdfjs_require__(86);
  4100. var InternalStateModule = __w_pdfjs_require__(33);
  4101. var defineIterator = __w_pdfjs_require__(79);
  4102. var ARRAY_ITERATOR = 'Array Iterator';
  4103. var setInternalState = InternalStateModule.set;
  4104. var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);
  4105. module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
  4106. setInternalState(this, {
  4107. type: ARRAY_ITERATOR,
  4108. target: toIndexedObject(iterated),
  4109. index: 0,
  4110. kind: kind
  4111. });
  4112. }, function () {
  4113. var state = getInternalState(this);
  4114. var target = state.target;
  4115. var kind = state.kind;
  4116. var index = state.index++;
  4117. if (!target || index >= target.length) {
  4118. state.target = undefined;
  4119. return {
  4120. value: undefined,
  4121. done: true
  4122. };
  4123. }
  4124. if (kind == 'keys')
  4125. return {
  4126. value: index,
  4127. done: false
  4128. };
  4129. if (kind == 'values')
  4130. return {
  4131. value: target[index],
  4132. done: false
  4133. };
  4134. return {
  4135. value: [
  4136. index,
  4137. target[index]
  4138. ],
  4139. done: false
  4140. };
  4141. }, 'values');
  4142. Iterators.Arguments = Iterators.Array;
  4143. addToUnscopables('keys');
  4144. addToUnscopables('values');
  4145. addToUnscopables('entries');
  4146. /***/ }),
  4147. /* 103 */
  4148. /***/ (function(module, exports, __w_pdfjs_require__) {
  4149. var $ = __w_pdfjs_require__(10);
  4150. var iterate = __w_pdfjs_require__(104);
  4151. var createProperty = __w_pdfjs_require__(93);
  4152. $({
  4153. target: 'Object',
  4154. stat: true
  4155. }, {
  4156. fromEntries: function fromEntries(iterable) {
  4157. var obj = {};
  4158. iterate(iterable, function (k, v) {
  4159. createProperty(obj, k, v);
  4160. }, undefined, true);
  4161. return obj;
  4162. }
  4163. });
  4164. /***/ }),
  4165. /* 104 */
  4166. /***/ (function(module, exports, __w_pdfjs_require__) {
  4167. var anObject = __w_pdfjs_require__(28);
  4168. var isArrayIteratorMethod = __w_pdfjs_require__(92);
  4169. var toLength = __w_pdfjs_require__(47);
  4170. var bind = __w_pdfjs_require__(62);
  4171. var getIteratorMethod = __w_pdfjs_require__(94);
  4172. var callWithSafeIterationClosing = __w_pdfjs_require__(91);
  4173. var Result = function (stopped, result) {
  4174. this.stopped = stopped;
  4175. this.result = result;
  4176. };
  4177. var iterate = module.exports = function (iterable, fn, that, AS_ENTRIES, IS_ITERATOR) {
  4178. var boundFunction = bind(fn, that, AS_ENTRIES ? 2 : 1);
  4179. var iterator, iterFn, index, length, result, next, step;
  4180. if (IS_ITERATOR) {
  4181. iterator = iterable;
  4182. } else {
  4183. iterFn = getIteratorMethod(iterable);
  4184. if (typeof iterFn != 'function')
  4185. throw TypeError('Target is not iterable');
  4186. if (isArrayIteratorMethod(iterFn)) {
  4187. for (index = 0, length = toLength(iterable.length); length > index; index++) {
  4188. result = AS_ENTRIES ? boundFunction(anObject(step = iterable[index])[0], step[1]) : boundFunction(iterable[index]);
  4189. if (result && result instanceof Result)
  4190. return result;
  4191. }
  4192. return new Result(false);
  4193. }
  4194. iterator = iterFn.call(iterable);
  4195. }
  4196. next = iterator.next;
  4197. while (!(step = next.call(iterator)).done) {
  4198. result = callWithSafeIterationClosing(iterator, boundFunction, step.value, AS_ENTRIES);
  4199. if (typeof result == 'object' && result && result instanceof Result)
  4200. return result;
  4201. }
  4202. return new Result(false);
  4203. };
  4204. iterate.stop = function (result) {
  4205. return new Result(true, result);
  4206. };
  4207. /***/ }),
  4208. /* 105 */
  4209. /***/ (function(module, exports, __w_pdfjs_require__) {
  4210. __w_pdfjs_require__(106);
  4211. var path = __w_pdfjs_require__(43);
  4212. module.exports = path.Math.log2;
  4213. /***/ }),
  4214. /* 106 */
  4215. /***/ (function(module, exports, __w_pdfjs_require__) {
  4216. var $ = __w_pdfjs_require__(10);
  4217. var log = Math.log;
  4218. var LN2 = Math.LN2;
  4219. $({
  4220. target: 'Math',
  4221. stat: true
  4222. }, {
  4223. log2: function log2(x) {
  4224. return log(x) / LN2;
  4225. }
  4226. });
  4227. /***/ }),
  4228. /* 107 */
  4229. /***/ (function(module, exports, __w_pdfjs_require__) {
  4230. __w_pdfjs_require__(108);
  4231. var path = __w_pdfjs_require__(43);
  4232. module.exports = path.Number.isNaN;
  4233. /***/ }),
  4234. /* 108 */
  4235. /***/ (function(module, exports, __w_pdfjs_require__) {
  4236. var $ = __w_pdfjs_require__(10);
  4237. $({
  4238. target: 'Number',
  4239. stat: true
  4240. }, {
  4241. isNaN: function isNaN(number) {
  4242. return number != number;
  4243. }
  4244. });
  4245. /***/ }),
  4246. /* 109 */
  4247. /***/ (function(module, exports, __w_pdfjs_require__) {
  4248. __w_pdfjs_require__(110);
  4249. var path = __w_pdfjs_require__(43);
  4250. module.exports = path.Number.isInteger;
  4251. /***/ }),
  4252. /* 110 */
  4253. /***/ (function(module, exports, __w_pdfjs_require__) {
  4254. var $ = __w_pdfjs_require__(10);
  4255. var isInteger = __w_pdfjs_require__(111);
  4256. $({
  4257. target: 'Number',
  4258. stat: true
  4259. }, { isInteger: isInteger });
  4260. /***/ }),
  4261. /* 111 */
  4262. /***/ (function(module, exports, __w_pdfjs_require__) {
  4263. var isObject = __w_pdfjs_require__(22);
  4264. var floor = Math.floor;
  4265. module.exports = function isInteger(it) {
  4266. return !isObject(it) && isFinite(it) && floor(it) === it;
  4267. };
  4268. /***/ }),
  4269. /* 112 */
  4270. /***/ (function(module, exports, __w_pdfjs_require__) {
  4271. __w_pdfjs_require__(113);
  4272. /***/ }),
  4273. /* 113 */
  4274. /***/ (function(module, exports, __w_pdfjs_require__) {
  4275. "use strict";
  4276. var ArrayBufferViewCore = __w_pdfjs_require__(114);
  4277. var speciesConstructor = __w_pdfjs_require__(116);
  4278. var fails = __w_pdfjs_require__(14);
  4279. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  4280. var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;
  4281. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  4282. var $slice = [].slice;
  4283. var FORCED = fails(function () {
  4284. new Int8Array(1).slice();
  4285. });
  4286. exportTypedArrayMethod('slice', function slice(start, end) {
  4287. var list = $slice.call(aTypedArray(this), start, end);
  4288. var C = speciesConstructor(this, this.constructor);
  4289. var index = 0;
  4290. var length = list.length;
  4291. var result = new (aTypedArrayConstructor(C))(length);
  4292. while (length > index)
  4293. result[index] = list[index++];
  4294. return result;
  4295. }, FORCED);
  4296. /***/ }),
  4297. /* 114 */
  4298. /***/ (function(module, exports, __w_pdfjs_require__) {
  4299. "use strict";
  4300. var NATIVE_ARRAY_BUFFER = __w_pdfjs_require__(115);
  4301. var DESCRIPTORS = __w_pdfjs_require__(13);
  4302. var global = __w_pdfjs_require__(11);
  4303. var isObject = __w_pdfjs_require__(22);
  4304. var has = __w_pdfjs_require__(23);
  4305. var classof = __w_pdfjs_require__(95);
  4306. var createNonEnumerableProperty = __w_pdfjs_require__(26);
  4307. var redefine = __w_pdfjs_require__(29);
  4308. var defineProperty = __w_pdfjs_require__(27).f;
  4309. var getPrototypeOf = __w_pdfjs_require__(82);
  4310. var setPrototypeOf = __w_pdfjs_require__(87);
  4311. var wellKnownSymbol = __w_pdfjs_require__(57);
  4312. var uid = __w_pdfjs_require__(38);
  4313. var Int8Array = global.Int8Array;
  4314. var Int8ArrayPrototype = Int8Array && Int8Array.prototype;
  4315. var Uint8ClampedArray = global.Uint8ClampedArray;
  4316. var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype;
  4317. var TypedArray = Int8Array && getPrototypeOf(Int8Array);
  4318. var TypedArrayPrototype = Int8ArrayPrototype && getPrototypeOf(Int8ArrayPrototype);
  4319. var ObjectPrototype = Object.prototype;
  4320. var isPrototypeOf = ObjectPrototype.isPrototypeOf;
  4321. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  4322. var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG');
  4323. var NATIVE_ARRAY_BUFFER_VIEWS = NATIVE_ARRAY_BUFFER && !!setPrototypeOf && classof(global.opera) !== 'Opera';
  4324. var TYPED_ARRAY_TAG_REQIRED = false;
  4325. var NAME;
  4326. var TypedArrayConstructorsList = {
  4327. Int8Array: 1,
  4328. Uint8Array: 1,
  4329. Uint8ClampedArray: 1,
  4330. Int16Array: 2,
  4331. Uint16Array: 2,
  4332. Int32Array: 4,
  4333. Uint32Array: 4,
  4334. Float32Array: 4,
  4335. Float64Array: 8
  4336. };
  4337. var isView = function isView(it) {
  4338. var klass = classof(it);
  4339. return klass === 'DataView' || has(TypedArrayConstructorsList, klass);
  4340. };
  4341. var isTypedArray = function (it) {
  4342. return isObject(it) && has(TypedArrayConstructorsList, classof(it));
  4343. };
  4344. var aTypedArray = function (it) {
  4345. if (isTypedArray(it))
  4346. return it;
  4347. throw TypeError('Target is not a typed array');
  4348. };
  4349. var aTypedArrayConstructor = function (C) {
  4350. if (setPrototypeOf) {
  4351. if (isPrototypeOf.call(TypedArray, C))
  4352. return C;
  4353. } else
  4354. for (var ARRAY in TypedArrayConstructorsList)
  4355. if (has(TypedArrayConstructorsList, NAME)) {
  4356. var TypedArrayConstructor = global[ARRAY];
  4357. if (TypedArrayConstructor && (C === TypedArrayConstructor || isPrototypeOf.call(TypedArrayConstructor, C))) {
  4358. return C;
  4359. }
  4360. }
  4361. throw TypeError('Target is not a typed array constructor');
  4362. };
  4363. var exportTypedArrayMethod = function (KEY, property, forced) {
  4364. if (!DESCRIPTORS)
  4365. return;
  4366. if (forced)
  4367. for (var ARRAY in TypedArrayConstructorsList) {
  4368. var TypedArrayConstructor = global[ARRAY];
  4369. if (TypedArrayConstructor && has(TypedArrayConstructor.prototype, KEY)) {
  4370. delete TypedArrayConstructor.prototype[KEY];
  4371. }
  4372. }
  4373. if (!TypedArrayPrototype[KEY] || forced) {
  4374. redefine(TypedArrayPrototype, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property);
  4375. }
  4376. };
  4377. var exportTypedArrayStaticMethod = function (KEY, property, forced) {
  4378. var ARRAY, TypedArrayConstructor;
  4379. if (!DESCRIPTORS)
  4380. return;
  4381. if (setPrototypeOf) {
  4382. if (forced)
  4383. for (ARRAY in TypedArrayConstructorsList) {
  4384. TypedArrayConstructor = global[ARRAY];
  4385. if (TypedArrayConstructor && has(TypedArrayConstructor, KEY)) {
  4386. delete TypedArrayConstructor[KEY];
  4387. }
  4388. }
  4389. if (!TypedArray[KEY] || forced) {
  4390. try {
  4391. return redefine(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8Array[KEY] || property);
  4392. } catch (error) {
  4393. }
  4394. } else
  4395. return;
  4396. }
  4397. for (ARRAY in TypedArrayConstructorsList) {
  4398. TypedArrayConstructor = global[ARRAY];
  4399. if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) {
  4400. redefine(TypedArrayConstructor, KEY, property);
  4401. }
  4402. }
  4403. };
  4404. for (NAME in TypedArrayConstructorsList) {
  4405. if (!global[NAME])
  4406. NATIVE_ARRAY_BUFFER_VIEWS = false;
  4407. }
  4408. if (!NATIVE_ARRAY_BUFFER_VIEWS || typeof TypedArray != 'function' || TypedArray === Function.prototype) {
  4409. TypedArray = function TypedArray() {
  4410. throw TypeError('Incorrect invocation');
  4411. };
  4412. if (NATIVE_ARRAY_BUFFER_VIEWS)
  4413. for (NAME in TypedArrayConstructorsList) {
  4414. if (global[NAME])
  4415. setPrototypeOf(global[NAME], TypedArray);
  4416. }
  4417. }
  4418. if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype) {
  4419. TypedArrayPrototype = TypedArray.prototype;
  4420. if (NATIVE_ARRAY_BUFFER_VIEWS)
  4421. for (NAME in TypedArrayConstructorsList) {
  4422. if (global[NAME])
  4423. setPrototypeOf(global[NAME].prototype, TypedArrayPrototype);
  4424. }
  4425. }
  4426. if (NATIVE_ARRAY_BUFFER_VIEWS && getPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) {
  4427. setPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype);
  4428. }
  4429. if (DESCRIPTORS && !has(TypedArrayPrototype, TO_STRING_TAG)) {
  4430. TYPED_ARRAY_TAG_REQIRED = true;
  4431. defineProperty(TypedArrayPrototype, TO_STRING_TAG, {
  4432. get: function () {
  4433. return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined;
  4434. }
  4435. });
  4436. for (NAME in TypedArrayConstructorsList)
  4437. if (global[NAME]) {
  4438. createNonEnumerableProperty(global[NAME], TYPED_ARRAY_TAG, NAME);
  4439. }
  4440. }
  4441. module.exports = {
  4442. NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS,
  4443. TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQIRED && TYPED_ARRAY_TAG,
  4444. aTypedArray: aTypedArray,
  4445. aTypedArrayConstructor: aTypedArrayConstructor,
  4446. exportTypedArrayMethod: exportTypedArrayMethod,
  4447. exportTypedArrayStaticMethod: exportTypedArrayStaticMethod,
  4448. isView: isView,
  4449. isTypedArray: isTypedArray,
  4450. TypedArray: TypedArray,
  4451. TypedArrayPrototype: TypedArrayPrototype
  4452. };
  4453. /***/ }),
  4454. /* 115 */
  4455. /***/ (function(module, exports) {
  4456. module.exports = typeof ArrayBuffer !== 'undefined' && typeof DataView !== 'undefined';
  4457. /***/ }),
  4458. /* 116 */
  4459. /***/ (function(module, exports, __w_pdfjs_require__) {
  4460. var anObject = __w_pdfjs_require__(28);
  4461. var aFunction = __w_pdfjs_require__(63);
  4462. var wellKnownSymbol = __w_pdfjs_require__(57);
  4463. var SPECIES = wellKnownSymbol('species');
  4464. module.exports = function (O, defaultConstructor) {
  4465. var C = anObject(O).constructor;
  4466. var S;
  4467. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aFunction(S);
  4468. };
  4469. /***/ }),
  4470. /* 117 */
  4471. /***/ (function(module, exports, __w_pdfjs_require__) {
  4472. __w_pdfjs_require__(118);
  4473. __w_pdfjs_require__(77);
  4474. __w_pdfjs_require__(120);
  4475. __w_pdfjs_require__(122);
  4476. __w_pdfjs_require__(136);
  4477. __w_pdfjs_require__(137);
  4478. var path = __w_pdfjs_require__(43);
  4479. module.exports = path.Promise;
  4480. /***/ }),
  4481. /* 118 */
  4482. /***/ (function(module, exports, __w_pdfjs_require__) {
  4483. var TO_STRING_TAG_SUPPORT = __w_pdfjs_require__(96);
  4484. var redefine = __w_pdfjs_require__(29);
  4485. var toString = __w_pdfjs_require__(119);
  4486. if (!TO_STRING_TAG_SUPPORT) {
  4487. redefine(Object.prototype, 'toString', toString, { unsafe: true });
  4488. }
  4489. /***/ }),
  4490. /* 119 */
  4491. /***/ (function(module, exports, __w_pdfjs_require__) {
  4492. "use strict";
  4493. var TO_STRING_TAG_SUPPORT = __w_pdfjs_require__(96);
  4494. var classof = __w_pdfjs_require__(95);
  4495. module.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {
  4496. return '[object ' + classof(this) + ']';
  4497. };
  4498. /***/ }),
  4499. /* 120 */
  4500. /***/ (function(module, exports, __w_pdfjs_require__) {
  4501. var global = __w_pdfjs_require__(11);
  4502. var DOMIterables = __w_pdfjs_require__(121);
  4503. var ArrayIteratorMethods = __w_pdfjs_require__(102);
  4504. var createNonEnumerableProperty = __w_pdfjs_require__(26);
  4505. var wellKnownSymbol = __w_pdfjs_require__(57);
  4506. var ITERATOR = wellKnownSymbol('iterator');
  4507. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  4508. var ArrayValues = ArrayIteratorMethods.values;
  4509. for (var COLLECTION_NAME in DOMIterables) {
  4510. var Collection = global[COLLECTION_NAME];
  4511. var CollectionPrototype = Collection && Collection.prototype;
  4512. if (CollectionPrototype) {
  4513. if (CollectionPrototype[ITERATOR] !== ArrayValues)
  4514. try {
  4515. createNonEnumerableProperty(CollectionPrototype, ITERATOR, ArrayValues);
  4516. } catch (error) {
  4517. CollectionPrototype[ITERATOR] = ArrayValues;
  4518. }
  4519. if (!CollectionPrototype[TO_STRING_TAG]) {
  4520. createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
  4521. }
  4522. if (DOMIterables[COLLECTION_NAME])
  4523. for (var METHOD_NAME in ArrayIteratorMethods) {
  4524. if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME])
  4525. try {
  4526. createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, ArrayIteratorMethods[METHOD_NAME]);
  4527. } catch (error) {
  4528. CollectionPrototype[METHOD_NAME] = ArrayIteratorMethods[METHOD_NAME];
  4529. }
  4530. }
  4531. }
  4532. }
  4533. /***/ }),
  4534. /* 121 */
  4535. /***/ (function(module, exports) {
  4536. module.exports = {
  4537. CSSRuleList: 0,
  4538. CSSStyleDeclaration: 0,
  4539. CSSValueList: 0,
  4540. ClientRectList: 0,
  4541. DOMRectList: 0,
  4542. DOMStringList: 0,
  4543. DOMTokenList: 1,
  4544. DataTransferItemList: 0,
  4545. FileList: 0,
  4546. HTMLAllCollection: 0,
  4547. HTMLCollection: 0,
  4548. HTMLFormElement: 0,
  4549. HTMLSelectElement: 0,
  4550. MediaList: 0,
  4551. MimeTypeArray: 0,
  4552. NamedNodeMap: 0,
  4553. NodeList: 1,
  4554. PaintRequestList: 0,
  4555. Plugin: 0,
  4556. PluginArray: 0,
  4557. SVGLengthList: 0,
  4558. SVGNumberList: 0,
  4559. SVGPathSegList: 0,
  4560. SVGPointList: 0,
  4561. SVGStringList: 0,
  4562. SVGTransformList: 0,
  4563. SourceBufferList: 0,
  4564. StyleSheetList: 0,
  4565. TextTrackCueList: 0,
  4566. TextTrackList: 0,
  4567. TouchList: 0
  4568. };
  4569. /***/ }),
  4570. /* 122 */
  4571. /***/ (function(module, exports, __w_pdfjs_require__) {
  4572. "use strict";
  4573. var $ = __w_pdfjs_require__(10);
  4574. var IS_PURE = __w_pdfjs_require__(37);
  4575. var global = __w_pdfjs_require__(11);
  4576. var getBuiltIn = __w_pdfjs_require__(42);
  4577. var NativePromise = __w_pdfjs_require__(123);
  4578. var redefine = __w_pdfjs_require__(29);
  4579. var redefineAll = __w_pdfjs_require__(124);
  4580. var setToStringTag = __w_pdfjs_require__(85);
  4581. var setSpecies = __w_pdfjs_require__(125);
  4582. var isObject = __w_pdfjs_require__(22);
  4583. var aFunction = __w_pdfjs_require__(63);
  4584. var anInstance = __w_pdfjs_require__(126);
  4585. var classof = __w_pdfjs_require__(19);
  4586. var inspectSource = __w_pdfjs_require__(31);
  4587. var iterate = __w_pdfjs_require__(104);
  4588. var checkCorrectnessOfIteration = __w_pdfjs_require__(97);
  4589. var speciesConstructor = __w_pdfjs_require__(116);
  4590. var task = __w_pdfjs_require__(127).set;
  4591. var microtask = __w_pdfjs_require__(130);
  4592. var promiseResolve = __w_pdfjs_require__(131);
  4593. var hostReportErrors = __w_pdfjs_require__(133);
  4594. var newPromiseCapabilityModule = __w_pdfjs_require__(132);
  4595. var perform = __w_pdfjs_require__(134);
  4596. var InternalStateModule = __w_pdfjs_require__(33);
  4597. var isForced = __w_pdfjs_require__(52);
  4598. var wellKnownSymbol = __w_pdfjs_require__(57);
  4599. var V8_VERSION = __w_pdfjs_require__(135);
  4600. var SPECIES = wellKnownSymbol('species');
  4601. var PROMISE = 'Promise';
  4602. var getInternalState = InternalStateModule.get;
  4603. var setInternalState = InternalStateModule.set;
  4604. var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
  4605. var PromiseConstructor = NativePromise;
  4606. var TypeError = global.TypeError;
  4607. var document = global.document;
  4608. var process = global.process;
  4609. var $fetch = getBuiltIn('fetch');
  4610. var newPromiseCapability = newPromiseCapabilityModule.f;
  4611. var newGenericPromiseCapability = newPromiseCapability;
  4612. var IS_NODE = classof(process) == 'process';
  4613. var DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);
  4614. var UNHANDLED_REJECTION = 'unhandledrejection';
  4615. var REJECTION_HANDLED = 'rejectionhandled';
  4616. var PENDING = 0;
  4617. var FULFILLED = 1;
  4618. var REJECTED = 2;
  4619. var HANDLED = 1;
  4620. var UNHANDLED = 2;
  4621. var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
  4622. var FORCED = isForced(PROMISE, function () {
  4623. var GLOBAL_CORE_JS_PROMISE = inspectSource(PromiseConstructor) !== String(PromiseConstructor);
  4624. if (!GLOBAL_CORE_JS_PROMISE) {
  4625. if (V8_VERSION === 66)
  4626. return true;
  4627. if (!IS_NODE && typeof PromiseRejectionEvent != 'function')
  4628. return true;
  4629. }
  4630. if (IS_PURE && !PromiseConstructor.prototype['finally'])
  4631. return true;
  4632. if (V8_VERSION >= 51 && /native code/.test(PromiseConstructor))
  4633. return false;
  4634. var promise = PromiseConstructor.resolve(1);
  4635. var FakePromise = function (exec) {
  4636. exec(function () {
  4637. }, function () {
  4638. });
  4639. };
  4640. var constructor = promise.constructor = {};
  4641. constructor[SPECIES] = FakePromise;
  4642. return !(promise.then(function () {
  4643. }) instanceof FakePromise);
  4644. });
  4645. var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {
  4646. PromiseConstructor.all(iterable)['catch'](function () {
  4647. });
  4648. });
  4649. var isThenable = function (it) {
  4650. var then;
  4651. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  4652. };
  4653. var notify = function (promise, state, isReject) {
  4654. if (state.notified)
  4655. return;
  4656. state.notified = true;
  4657. var chain = state.reactions;
  4658. microtask(function () {
  4659. var value = state.value;
  4660. var ok = state.state == FULFILLED;
  4661. var index = 0;
  4662. while (chain.length > index) {
  4663. var reaction = chain[index++];
  4664. var handler = ok ? reaction.ok : reaction.fail;
  4665. var resolve = reaction.resolve;
  4666. var reject = reaction.reject;
  4667. var domain = reaction.domain;
  4668. var result, then, exited;
  4669. try {
  4670. if (handler) {
  4671. if (!ok) {
  4672. if (state.rejection === UNHANDLED)
  4673. onHandleUnhandled(promise, state);
  4674. state.rejection = HANDLED;
  4675. }
  4676. if (handler === true)
  4677. result = value;
  4678. else {
  4679. if (domain)
  4680. domain.enter();
  4681. result = handler(value);
  4682. if (domain) {
  4683. domain.exit();
  4684. exited = true;
  4685. }
  4686. }
  4687. if (result === reaction.promise) {
  4688. reject(TypeError('Promise-chain cycle'));
  4689. } else if (then = isThenable(result)) {
  4690. then.call(result, resolve, reject);
  4691. } else
  4692. resolve(result);
  4693. } else
  4694. reject(value);
  4695. } catch (error) {
  4696. if (domain && !exited)
  4697. domain.exit();
  4698. reject(error);
  4699. }
  4700. }
  4701. state.reactions = [];
  4702. state.notified = false;
  4703. if (isReject && !state.rejection)
  4704. onUnhandled(promise, state);
  4705. });
  4706. };
  4707. var dispatchEvent = function (name, promise, reason) {
  4708. var event, handler;
  4709. if (DISPATCH_EVENT) {
  4710. event = document.createEvent('Event');
  4711. event.promise = promise;
  4712. event.reason = reason;
  4713. event.initEvent(name, false, true);
  4714. global.dispatchEvent(event);
  4715. } else
  4716. event = {
  4717. promise: promise,
  4718. reason: reason
  4719. };
  4720. if (handler = global['on' + name])
  4721. handler(event);
  4722. else if (name === UNHANDLED_REJECTION)
  4723. hostReportErrors('Unhandled promise rejection', reason);
  4724. };
  4725. var onUnhandled = function (promise, state) {
  4726. task.call(global, function () {
  4727. var value = state.value;
  4728. var IS_UNHANDLED = isUnhandled(state);
  4729. var result;
  4730. if (IS_UNHANDLED) {
  4731. result = perform(function () {
  4732. if (IS_NODE) {
  4733. process.emit('unhandledRejection', value, promise);
  4734. } else
  4735. dispatchEvent(UNHANDLED_REJECTION, promise, value);
  4736. });
  4737. state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
  4738. if (result.error)
  4739. throw result.value;
  4740. }
  4741. });
  4742. };
  4743. var isUnhandled = function (state) {
  4744. return state.rejection !== HANDLED && !state.parent;
  4745. };
  4746. var onHandleUnhandled = function (promise, state) {
  4747. task.call(global, function () {
  4748. if (IS_NODE) {
  4749. process.emit('rejectionHandled', promise);
  4750. } else
  4751. dispatchEvent(REJECTION_HANDLED, promise, state.value);
  4752. });
  4753. };
  4754. var bind = function (fn, promise, state, unwrap) {
  4755. return function (value) {
  4756. fn(promise, state, value, unwrap);
  4757. };
  4758. };
  4759. var internalReject = function (promise, state, value, unwrap) {
  4760. if (state.done)
  4761. return;
  4762. state.done = true;
  4763. if (unwrap)
  4764. state = unwrap;
  4765. state.value = value;
  4766. state.state = REJECTED;
  4767. notify(promise, state, true);
  4768. };
  4769. var internalResolve = function (promise, state, value, unwrap) {
  4770. if (state.done)
  4771. return;
  4772. state.done = true;
  4773. if (unwrap)
  4774. state = unwrap;
  4775. try {
  4776. if (promise === value)
  4777. throw TypeError("Promise can't be resolved itself");
  4778. var then = isThenable(value);
  4779. if (then) {
  4780. microtask(function () {
  4781. var wrapper = { done: false };
  4782. try {
  4783. then.call(value, bind(internalResolve, promise, wrapper, state), bind(internalReject, promise, wrapper, state));
  4784. } catch (error) {
  4785. internalReject(promise, wrapper, error, state);
  4786. }
  4787. });
  4788. } else {
  4789. state.value = value;
  4790. state.state = FULFILLED;
  4791. notify(promise, state, false);
  4792. }
  4793. } catch (error) {
  4794. internalReject(promise, { done: false }, error, state);
  4795. }
  4796. };
  4797. if (FORCED) {
  4798. PromiseConstructor = function Promise(executor) {
  4799. anInstance(this, PromiseConstructor, PROMISE);
  4800. aFunction(executor);
  4801. Internal.call(this);
  4802. var state = getInternalState(this);
  4803. try {
  4804. executor(bind(internalResolve, this, state), bind(internalReject, this, state));
  4805. } catch (error) {
  4806. internalReject(this, state, error);
  4807. }
  4808. };
  4809. Internal = function Promise(executor) {
  4810. setInternalState(this, {
  4811. type: PROMISE,
  4812. done: false,
  4813. notified: false,
  4814. parent: false,
  4815. reactions: [],
  4816. rejection: false,
  4817. state: PENDING,
  4818. value: undefined
  4819. });
  4820. };
  4821. Internal.prototype = redefineAll(PromiseConstructor.prototype, {
  4822. then: function then(onFulfilled, onRejected) {
  4823. var state = getInternalPromiseState(this);
  4824. var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
  4825. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  4826. reaction.fail = typeof onRejected == 'function' && onRejected;
  4827. reaction.domain = IS_NODE ? process.domain : undefined;
  4828. state.parent = true;
  4829. state.reactions.push(reaction);
  4830. if (state.state != PENDING)
  4831. notify(this, state, false);
  4832. return reaction.promise;
  4833. },
  4834. 'catch': function (onRejected) {
  4835. return this.then(undefined, onRejected);
  4836. }
  4837. });
  4838. OwnPromiseCapability = function () {
  4839. var promise = new Internal();
  4840. var state = getInternalState(promise);
  4841. this.promise = promise;
  4842. this.resolve = bind(internalResolve, promise, state);
  4843. this.reject = bind(internalReject, promise, state);
  4844. };
  4845. newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
  4846. return C === PromiseConstructor || C === PromiseWrapper ? new OwnPromiseCapability(C) : newGenericPromiseCapability(C);
  4847. };
  4848. if (!IS_PURE && typeof NativePromise == 'function') {
  4849. nativeThen = NativePromise.prototype.then;
  4850. redefine(NativePromise.prototype, 'then', function then(onFulfilled, onRejected) {
  4851. var that = this;
  4852. return new PromiseConstructor(function (resolve, reject) {
  4853. nativeThen.call(that, resolve, reject);
  4854. }).then(onFulfilled, onRejected);
  4855. }, { unsafe: true });
  4856. if (typeof $fetch == 'function')
  4857. $({
  4858. global: true,
  4859. enumerable: true,
  4860. forced: true
  4861. }, {
  4862. fetch: function fetch(input) {
  4863. return promiseResolve(PromiseConstructor, $fetch.apply(global, arguments));
  4864. }
  4865. });
  4866. }
  4867. }
  4868. $({
  4869. global: true,
  4870. wrap: true,
  4871. forced: FORCED
  4872. }, { Promise: PromiseConstructor });
  4873. setToStringTag(PromiseConstructor, PROMISE, false, true);
  4874. setSpecies(PROMISE);
  4875. PromiseWrapper = getBuiltIn(PROMISE);
  4876. $({
  4877. target: PROMISE,
  4878. stat: true,
  4879. forced: FORCED
  4880. }, {
  4881. reject: function reject(r) {
  4882. var capability = newPromiseCapability(this);
  4883. capability.reject.call(undefined, r);
  4884. return capability.promise;
  4885. }
  4886. });
  4887. $({
  4888. target: PROMISE,
  4889. stat: true,
  4890. forced: IS_PURE || FORCED
  4891. }, {
  4892. resolve: function resolve(x) {
  4893. return promiseResolve(IS_PURE && this === PromiseWrapper ? PromiseConstructor : this, x);
  4894. }
  4895. });
  4896. $({
  4897. target: PROMISE,
  4898. stat: true,
  4899. forced: INCORRECT_ITERATION
  4900. }, {
  4901. all: function all(iterable) {
  4902. var C = this;
  4903. var capability = newPromiseCapability(C);
  4904. var resolve = capability.resolve;
  4905. var reject = capability.reject;
  4906. var result = perform(function () {
  4907. var $promiseResolve = aFunction(C.resolve);
  4908. var values = [];
  4909. var counter = 0;
  4910. var remaining = 1;
  4911. iterate(iterable, function (promise) {
  4912. var index = counter++;
  4913. var alreadyCalled = false;
  4914. values.push(undefined);
  4915. remaining++;
  4916. $promiseResolve.call(C, promise).then(function (value) {
  4917. if (alreadyCalled)
  4918. return;
  4919. alreadyCalled = true;
  4920. values[index] = value;
  4921. --remaining || resolve(values);
  4922. }, reject);
  4923. });
  4924. --remaining || resolve(values);
  4925. });
  4926. if (result.error)
  4927. reject(result.value);
  4928. return capability.promise;
  4929. },
  4930. race: function race(iterable) {
  4931. var C = this;
  4932. var capability = newPromiseCapability(C);
  4933. var reject = capability.reject;
  4934. var result = perform(function () {
  4935. var $promiseResolve = aFunction(C.resolve);
  4936. iterate(iterable, function (promise) {
  4937. $promiseResolve.call(C, promise).then(capability.resolve, reject);
  4938. });
  4939. });
  4940. if (result.error)
  4941. reject(result.value);
  4942. return capability.promise;
  4943. }
  4944. });
  4945. /***/ }),
  4946. /* 123 */
  4947. /***/ (function(module, exports, __w_pdfjs_require__) {
  4948. var global = __w_pdfjs_require__(11);
  4949. module.exports = global.Promise;
  4950. /***/ }),
  4951. /* 124 */
  4952. /***/ (function(module, exports, __w_pdfjs_require__) {
  4953. var redefine = __w_pdfjs_require__(29);
  4954. module.exports = function (target, src, options) {
  4955. for (var key in src)
  4956. redefine(target, key, src[key], options);
  4957. return target;
  4958. };
  4959. /***/ }),
  4960. /* 125 */
  4961. /***/ (function(module, exports, __w_pdfjs_require__) {
  4962. "use strict";
  4963. var getBuiltIn = __w_pdfjs_require__(42);
  4964. var definePropertyModule = __w_pdfjs_require__(27);
  4965. var wellKnownSymbol = __w_pdfjs_require__(57);
  4966. var DESCRIPTORS = __w_pdfjs_require__(13);
  4967. var SPECIES = wellKnownSymbol('species');
  4968. module.exports = function (CONSTRUCTOR_NAME) {
  4969. var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
  4970. var defineProperty = definePropertyModule.f;
  4971. if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
  4972. defineProperty(Constructor, SPECIES, {
  4973. configurable: true,
  4974. get: function () {
  4975. return this;
  4976. }
  4977. });
  4978. }
  4979. };
  4980. /***/ }),
  4981. /* 126 */
  4982. /***/ (function(module, exports) {
  4983. module.exports = function (it, Constructor, name) {
  4984. if (!(it instanceof Constructor)) {
  4985. throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');
  4986. }
  4987. return it;
  4988. };
  4989. /***/ }),
  4990. /* 127 */
  4991. /***/ (function(module, exports, __w_pdfjs_require__) {
  4992. var global = __w_pdfjs_require__(11);
  4993. var fails = __w_pdfjs_require__(14);
  4994. var classof = __w_pdfjs_require__(19);
  4995. var bind = __w_pdfjs_require__(62);
  4996. var html = __w_pdfjs_require__(74);
  4997. var createElement = __w_pdfjs_require__(25);
  4998. var IS_IOS = __w_pdfjs_require__(128);
  4999. var location = global.location;
  5000. var set = global.setImmediate;
  5001. var clear = global.clearImmediate;
  5002. var process = global.process;
  5003. var MessageChannel = global.MessageChannel;
  5004. var Dispatch = global.Dispatch;
  5005. var counter = 0;
  5006. var queue = {};
  5007. var ONREADYSTATECHANGE = 'onreadystatechange';
  5008. var defer, channel, port;
  5009. var run = function (id) {
  5010. if (queue.hasOwnProperty(id)) {
  5011. var fn = queue[id];
  5012. delete queue[id];
  5013. fn();
  5014. }
  5015. };
  5016. var runner = function (id) {
  5017. return function () {
  5018. run(id);
  5019. };
  5020. };
  5021. var listener = function (event) {
  5022. run(event.data);
  5023. };
  5024. var post = function (id) {
  5025. global.postMessage(id + '', location.protocol + '//' + location.host);
  5026. };
  5027. if (!set || !clear) {
  5028. set = function setImmediate(fn) {
  5029. var args = [];
  5030. var i = 1;
  5031. while (arguments.length > i)
  5032. args.push(arguments[i++]);
  5033. queue[++counter] = function () {
  5034. (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args);
  5035. };
  5036. defer(counter);
  5037. return counter;
  5038. };
  5039. clear = function clearImmediate(id) {
  5040. delete queue[id];
  5041. };
  5042. if (classof(process) == 'process') {
  5043. defer = function (id) {
  5044. process.nextTick(runner(id));
  5045. };
  5046. } else if (Dispatch && Dispatch.now) {
  5047. defer = function (id) {
  5048. Dispatch.now(runner(id));
  5049. };
  5050. } else if (MessageChannel && !IS_IOS) {
  5051. channel = new MessageChannel();
  5052. port = channel.port2;
  5053. channel.port1.onmessage = listener;
  5054. defer = bind(port.postMessage, port, 1);
  5055. } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts && !fails(post) && location.protocol !== 'file:') {
  5056. defer = post;
  5057. global.addEventListener('message', listener, false);
  5058. } else if (ONREADYSTATECHANGE in createElement('script')) {
  5059. defer = function (id) {
  5060. html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
  5061. html.removeChild(this);
  5062. run(id);
  5063. };
  5064. };
  5065. } else {
  5066. defer = function (id) {
  5067. setTimeout(runner(id), 0);
  5068. };
  5069. }
  5070. }
  5071. module.exports = {
  5072. set: set,
  5073. clear: clear
  5074. };
  5075. /***/ }),
  5076. /* 128 */
  5077. /***/ (function(module, exports, __w_pdfjs_require__) {
  5078. var userAgent = __w_pdfjs_require__(129);
  5079. module.exports = /(iphone|ipod|ipad).*applewebkit/i.test(userAgent);
  5080. /***/ }),
  5081. /* 129 */
  5082. /***/ (function(module, exports, __w_pdfjs_require__) {
  5083. var getBuiltIn = __w_pdfjs_require__(42);
  5084. module.exports = getBuiltIn('navigator', 'userAgent') || '';
  5085. /***/ }),
  5086. /* 130 */
  5087. /***/ (function(module, exports, __w_pdfjs_require__) {
  5088. var global = __w_pdfjs_require__(11);
  5089. var getOwnPropertyDescriptor = __w_pdfjs_require__(12).f;
  5090. var classof = __w_pdfjs_require__(19);
  5091. var macrotask = __w_pdfjs_require__(127).set;
  5092. var IS_IOS = __w_pdfjs_require__(128);
  5093. var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
  5094. var process = global.process;
  5095. var Promise = global.Promise;
  5096. var IS_NODE = classof(process) == 'process';
  5097. var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
  5098. var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
  5099. var flush, head, last, notify, toggle, node, promise, then;
  5100. if (!queueMicrotask) {
  5101. flush = function () {
  5102. var parent, fn;
  5103. if (IS_NODE && (parent = process.domain))
  5104. parent.exit();
  5105. while (head) {
  5106. fn = head.fn;
  5107. head = head.next;
  5108. try {
  5109. fn();
  5110. } catch (error) {
  5111. if (head)
  5112. notify();
  5113. else
  5114. last = undefined;
  5115. throw error;
  5116. }
  5117. }
  5118. last = undefined;
  5119. if (parent)
  5120. parent.enter();
  5121. };
  5122. if (IS_NODE) {
  5123. notify = function () {
  5124. process.nextTick(flush);
  5125. };
  5126. } else if (MutationObserver && !IS_IOS) {
  5127. toggle = true;
  5128. node = document.createTextNode('');
  5129. new MutationObserver(flush).observe(node, { characterData: true });
  5130. notify = function () {
  5131. node.data = toggle = !toggle;
  5132. };
  5133. } else if (Promise && Promise.resolve) {
  5134. promise = Promise.resolve(undefined);
  5135. then = promise.then;
  5136. notify = function () {
  5137. then.call(promise, flush);
  5138. };
  5139. } else {
  5140. notify = function () {
  5141. macrotask.call(global, flush);
  5142. };
  5143. }
  5144. }
  5145. module.exports = queueMicrotask || function (fn) {
  5146. var task = {
  5147. fn: fn,
  5148. next: undefined
  5149. };
  5150. if (last)
  5151. last.next = task;
  5152. if (!head) {
  5153. head = task;
  5154. notify();
  5155. }
  5156. last = task;
  5157. };
  5158. /***/ }),
  5159. /* 131 */
  5160. /***/ (function(module, exports, __w_pdfjs_require__) {
  5161. var anObject = __w_pdfjs_require__(28);
  5162. var isObject = __w_pdfjs_require__(22);
  5163. var newPromiseCapability = __w_pdfjs_require__(132);
  5164. module.exports = function (C, x) {
  5165. anObject(C);
  5166. if (isObject(x) && x.constructor === C)
  5167. return x;
  5168. var promiseCapability = newPromiseCapability.f(C);
  5169. var resolve = promiseCapability.resolve;
  5170. resolve(x);
  5171. return promiseCapability.promise;
  5172. };
  5173. /***/ }),
  5174. /* 132 */
  5175. /***/ (function(module, exports, __w_pdfjs_require__) {
  5176. "use strict";
  5177. var aFunction = __w_pdfjs_require__(63);
  5178. var PromiseCapability = function (C) {
  5179. var resolve, reject;
  5180. this.promise = new C(function ($$resolve, $$reject) {
  5181. if (resolve !== undefined || reject !== undefined)
  5182. throw TypeError('Bad Promise constructor');
  5183. resolve = $$resolve;
  5184. reject = $$reject;
  5185. });
  5186. this.resolve = aFunction(resolve);
  5187. this.reject = aFunction(reject);
  5188. };
  5189. module.exports.f = function (C) {
  5190. return new PromiseCapability(C);
  5191. };
  5192. /***/ }),
  5193. /* 133 */
  5194. /***/ (function(module, exports, __w_pdfjs_require__) {
  5195. var global = __w_pdfjs_require__(11);
  5196. module.exports = function (a, b) {
  5197. var console = global.console;
  5198. if (console && console.error) {
  5199. arguments.length === 1 ? console.error(a) : console.error(a, b);
  5200. }
  5201. };
  5202. /***/ }),
  5203. /* 134 */
  5204. /***/ (function(module, exports) {
  5205. module.exports = function (exec) {
  5206. try {
  5207. return {
  5208. error: false,
  5209. value: exec()
  5210. };
  5211. } catch (error) {
  5212. return {
  5213. error: true,
  5214. value: error
  5215. };
  5216. }
  5217. };
  5218. /***/ }),
  5219. /* 135 */
  5220. /***/ (function(module, exports, __w_pdfjs_require__) {
  5221. var global = __w_pdfjs_require__(11);
  5222. var userAgent = __w_pdfjs_require__(129);
  5223. var process = global.process;
  5224. var versions = process && process.versions;
  5225. var v8 = versions && versions.v8;
  5226. var match, version;
  5227. if (v8) {
  5228. match = v8.split('.');
  5229. version = match[0] + match[1];
  5230. } else if (userAgent) {
  5231. match = userAgent.match(/Edge\/(\d+)/);
  5232. if (!match || match[1] >= 74) {
  5233. match = userAgent.match(/Chrome\/(\d+)/);
  5234. if (match)
  5235. version = match[1];
  5236. }
  5237. }
  5238. module.exports = version && +version;
  5239. /***/ }),
  5240. /* 136 */
  5241. /***/ (function(module, exports, __w_pdfjs_require__) {
  5242. "use strict";
  5243. var $ = __w_pdfjs_require__(10);
  5244. var aFunction = __w_pdfjs_require__(63);
  5245. var newPromiseCapabilityModule = __w_pdfjs_require__(132);
  5246. var perform = __w_pdfjs_require__(134);
  5247. var iterate = __w_pdfjs_require__(104);
  5248. $({
  5249. target: 'Promise',
  5250. stat: true
  5251. }, {
  5252. allSettled: function allSettled(iterable) {
  5253. var C = this;
  5254. var capability = newPromiseCapabilityModule.f(C);
  5255. var resolve = capability.resolve;
  5256. var reject = capability.reject;
  5257. var result = perform(function () {
  5258. var promiseResolve = aFunction(C.resolve);
  5259. var values = [];
  5260. var counter = 0;
  5261. var remaining = 1;
  5262. iterate(iterable, function (promise) {
  5263. var index = counter++;
  5264. var alreadyCalled = false;
  5265. values.push(undefined);
  5266. remaining++;
  5267. promiseResolve.call(C, promise).then(function (value) {
  5268. if (alreadyCalled)
  5269. return;
  5270. alreadyCalled = true;
  5271. values[index] = {
  5272. status: 'fulfilled',
  5273. value: value
  5274. };
  5275. --remaining || resolve(values);
  5276. }, function (e) {
  5277. if (alreadyCalled)
  5278. return;
  5279. alreadyCalled = true;
  5280. values[index] = {
  5281. status: 'rejected',
  5282. reason: e
  5283. };
  5284. --remaining || resolve(values);
  5285. });
  5286. });
  5287. --remaining || resolve(values);
  5288. });
  5289. if (result.error)
  5290. reject(result.value);
  5291. return capability.promise;
  5292. }
  5293. });
  5294. /***/ }),
  5295. /* 137 */
  5296. /***/ (function(module, exports, __w_pdfjs_require__) {
  5297. "use strict";
  5298. var $ = __w_pdfjs_require__(10);
  5299. var IS_PURE = __w_pdfjs_require__(37);
  5300. var NativePromise = __w_pdfjs_require__(123);
  5301. var fails = __w_pdfjs_require__(14);
  5302. var getBuiltIn = __w_pdfjs_require__(42);
  5303. var speciesConstructor = __w_pdfjs_require__(116);
  5304. var promiseResolve = __w_pdfjs_require__(131);
  5305. var redefine = __w_pdfjs_require__(29);
  5306. var NON_GENERIC = !!NativePromise && fails(function () {
  5307. NativePromise.prototype['finally'].call({
  5308. then: function () {
  5309. }
  5310. }, function () {
  5311. });
  5312. });
  5313. $({
  5314. target: 'Promise',
  5315. proto: true,
  5316. real: true,
  5317. forced: NON_GENERIC
  5318. }, {
  5319. 'finally': function (onFinally) {
  5320. var C = speciesConstructor(this, getBuiltIn('Promise'));
  5321. var isFunction = typeof onFinally == 'function';
  5322. return this.then(isFunction ? function (x) {
  5323. return promiseResolve(C, onFinally()).then(function () {
  5324. return x;
  5325. });
  5326. } : onFinally, isFunction ? function (e) {
  5327. return promiseResolve(C, onFinally()).then(function () {
  5328. throw e;
  5329. });
  5330. } : onFinally);
  5331. }
  5332. });
  5333. if (!IS_PURE && typeof NativePromise == 'function' && !NativePromise.prototype['finally']) {
  5334. redefine(NativePromise.prototype, 'finally', getBuiltIn('Promise').prototype['finally']);
  5335. }
  5336. /***/ }),
  5337. /* 138 */
  5338. /***/ (function(module, exports, __w_pdfjs_require__) {
  5339. __w_pdfjs_require__(139);
  5340. __w_pdfjs_require__(144);
  5341. __w_pdfjs_require__(142);
  5342. var path = __w_pdfjs_require__(43);
  5343. module.exports = path.URL;
  5344. /***/ }),
  5345. /* 139 */
  5346. /***/ (function(module, exports, __w_pdfjs_require__) {
  5347. "use strict";
  5348. __w_pdfjs_require__(77);
  5349. var $ = __w_pdfjs_require__(10);
  5350. var DESCRIPTORS = __w_pdfjs_require__(13);
  5351. var USE_NATIVE_URL = __w_pdfjs_require__(140);
  5352. var global = __w_pdfjs_require__(11);
  5353. var defineProperties = __w_pdfjs_require__(72);
  5354. var redefine = __w_pdfjs_require__(29);
  5355. var anInstance = __w_pdfjs_require__(126);
  5356. var has = __w_pdfjs_require__(23);
  5357. var assign = __w_pdfjs_require__(100);
  5358. var arrayFrom = __w_pdfjs_require__(90);
  5359. var codeAt = __w_pdfjs_require__(78).codeAt;
  5360. var toASCII = __w_pdfjs_require__(141);
  5361. var setToStringTag = __w_pdfjs_require__(85);
  5362. var URLSearchParamsModule = __w_pdfjs_require__(142);
  5363. var InternalStateModule = __w_pdfjs_require__(33);
  5364. var NativeURL = global.URL;
  5365. var URLSearchParams = URLSearchParamsModule.URLSearchParams;
  5366. var getInternalSearchParamsState = URLSearchParamsModule.getState;
  5367. var setInternalState = InternalStateModule.set;
  5368. var getInternalURLState = InternalStateModule.getterFor('URL');
  5369. var floor = Math.floor;
  5370. var pow = Math.pow;
  5371. var INVALID_AUTHORITY = 'Invalid authority';
  5372. var INVALID_SCHEME = 'Invalid scheme';
  5373. var INVALID_HOST = 'Invalid host';
  5374. var INVALID_PORT = 'Invalid port';
  5375. var ALPHA = /[A-Za-z]/;
  5376. var ALPHANUMERIC = /[\d+-.A-Za-z]/;
  5377. var DIGIT = /\d/;
  5378. var HEX_START = /^(0x|0X)/;
  5379. var OCT = /^[0-7]+$/;
  5380. var DEC = /^\d+$/;
  5381. var HEX = /^[\dA-Fa-f]+$/;
  5382. var FORBIDDEN_HOST_CODE_POINT = /[\u0000\u0009\u000A\u000D #%/:?@[\\]]/;
  5383. var FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\u0000\u0009\u000A\u000D #/:?@[\\]]/;
  5384. var LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE = /^[\u0000-\u001F ]+|[\u0000-\u001F ]+$/g;
  5385. var TAB_AND_NEW_LINE = /[\u0009\u000A\u000D]/g;
  5386. var EOF;
  5387. var parseHost = function (url, input) {
  5388. var result, codePoints, index;
  5389. if (input.charAt(0) == '[') {
  5390. if (input.charAt(input.length - 1) != ']')
  5391. return INVALID_HOST;
  5392. result = parseIPv6(input.slice(1, -1));
  5393. if (!result)
  5394. return INVALID_HOST;
  5395. url.host = result;
  5396. } else if (!isSpecial(url)) {
  5397. if (FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT.test(input))
  5398. return INVALID_HOST;
  5399. result = '';
  5400. codePoints = arrayFrom(input);
  5401. for (index = 0; index < codePoints.length; index++) {
  5402. result += percentEncode(codePoints[index], C0ControlPercentEncodeSet);
  5403. }
  5404. url.host = result;
  5405. } else {
  5406. input = toASCII(input);
  5407. if (FORBIDDEN_HOST_CODE_POINT.test(input))
  5408. return INVALID_HOST;
  5409. result = parseIPv4(input);
  5410. if (result === null)
  5411. return INVALID_HOST;
  5412. url.host = result;
  5413. }
  5414. };
  5415. var parseIPv4 = function (input) {
  5416. var parts = input.split('.');
  5417. var partsLength, numbers, index, part, radix, number, ipv4;
  5418. if (parts.length && parts[parts.length - 1] == '') {
  5419. parts.pop();
  5420. }
  5421. partsLength = parts.length;
  5422. if (partsLength > 4)
  5423. return input;
  5424. numbers = [];
  5425. for (index = 0; index < partsLength; index++) {
  5426. part = parts[index];
  5427. if (part == '')
  5428. return input;
  5429. radix = 10;
  5430. if (part.length > 1 && part.charAt(0) == '0') {
  5431. radix = HEX_START.test(part) ? 16 : 8;
  5432. part = part.slice(radix == 8 ? 1 : 2);
  5433. }
  5434. if (part === '') {
  5435. number = 0;
  5436. } else {
  5437. if (!(radix == 10 ? DEC : radix == 8 ? OCT : HEX).test(part))
  5438. return input;
  5439. number = parseInt(part, radix);
  5440. }
  5441. numbers.push(number);
  5442. }
  5443. for (index = 0; index < partsLength; index++) {
  5444. number = numbers[index];
  5445. if (index == partsLength - 1) {
  5446. if (number >= pow(256, 5 - partsLength))
  5447. return null;
  5448. } else if (number > 255)
  5449. return null;
  5450. }
  5451. ipv4 = numbers.pop();
  5452. for (index = 0; index < numbers.length; index++) {
  5453. ipv4 += numbers[index] * pow(256, 3 - index);
  5454. }
  5455. return ipv4;
  5456. };
  5457. var parseIPv6 = function (input) {
  5458. var address = [
  5459. 0,
  5460. 0,
  5461. 0,
  5462. 0,
  5463. 0,
  5464. 0,
  5465. 0,
  5466. 0
  5467. ];
  5468. var pieceIndex = 0;
  5469. var compress = null;
  5470. var pointer = 0;
  5471. var value, length, numbersSeen, ipv4Piece, number, swaps, swap;
  5472. var char = function () {
  5473. return input.charAt(pointer);
  5474. };
  5475. if (char() == ':') {
  5476. if (input.charAt(1) != ':')
  5477. return;
  5478. pointer += 2;
  5479. pieceIndex++;
  5480. compress = pieceIndex;
  5481. }
  5482. while (char()) {
  5483. if (pieceIndex == 8)
  5484. return;
  5485. if (char() == ':') {
  5486. if (compress !== null)
  5487. return;
  5488. pointer++;
  5489. pieceIndex++;
  5490. compress = pieceIndex;
  5491. continue;
  5492. }
  5493. value = length = 0;
  5494. while (length < 4 && HEX.test(char())) {
  5495. value = value * 16 + parseInt(char(), 16);
  5496. pointer++;
  5497. length++;
  5498. }
  5499. if (char() == '.') {
  5500. if (length == 0)
  5501. return;
  5502. pointer -= length;
  5503. if (pieceIndex > 6)
  5504. return;
  5505. numbersSeen = 0;
  5506. while (char()) {
  5507. ipv4Piece = null;
  5508. if (numbersSeen > 0) {
  5509. if (char() == '.' && numbersSeen < 4)
  5510. pointer++;
  5511. else
  5512. return;
  5513. }
  5514. if (!DIGIT.test(char()))
  5515. return;
  5516. while (DIGIT.test(char())) {
  5517. number = parseInt(char(), 10);
  5518. if (ipv4Piece === null)
  5519. ipv4Piece = number;
  5520. else if (ipv4Piece == 0)
  5521. return;
  5522. else
  5523. ipv4Piece = ipv4Piece * 10 + number;
  5524. if (ipv4Piece > 255)
  5525. return;
  5526. pointer++;
  5527. }
  5528. address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece;
  5529. numbersSeen++;
  5530. if (numbersSeen == 2 || numbersSeen == 4)
  5531. pieceIndex++;
  5532. }
  5533. if (numbersSeen != 4)
  5534. return;
  5535. break;
  5536. } else if (char() == ':') {
  5537. pointer++;
  5538. if (!char())
  5539. return;
  5540. } else if (char())
  5541. return;
  5542. address[pieceIndex++] = value;
  5543. }
  5544. if (compress !== null) {
  5545. swaps = pieceIndex - compress;
  5546. pieceIndex = 7;
  5547. while (pieceIndex != 0 && swaps > 0) {
  5548. swap = address[pieceIndex];
  5549. address[pieceIndex--] = address[compress + swaps - 1];
  5550. address[compress + --swaps] = swap;
  5551. }
  5552. } else if (pieceIndex != 8)
  5553. return;
  5554. return address;
  5555. };
  5556. var findLongestZeroSequence = function (ipv6) {
  5557. var maxIndex = null;
  5558. var maxLength = 1;
  5559. var currStart = null;
  5560. var currLength = 0;
  5561. var index = 0;
  5562. for (; index < 8; index++) {
  5563. if (ipv6[index] !== 0) {
  5564. if (currLength > maxLength) {
  5565. maxIndex = currStart;
  5566. maxLength = currLength;
  5567. }
  5568. currStart = null;
  5569. currLength = 0;
  5570. } else {
  5571. if (currStart === null)
  5572. currStart = index;
  5573. ++currLength;
  5574. }
  5575. }
  5576. if (currLength > maxLength) {
  5577. maxIndex = currStart;
  5578. maxLength = currLength;
  5579. }
  5580. return maxIndex;
  5581. };
  5582. var serializeHost = function (host) {
  5583. var result, index, compress, ignore0;
  5584. if (typeof host == 'number') {
  5585. result = [];
  5586. for (index = 0; index < 4; index++) {
  5587. result.unshift(host % 256);
  5588. host = floor(host / 256);
  5589. }
  5590. return result.join('.');
  5591. } else if (typeof host == 'object') {
  5592. result = '';
  5593. compress = findLongestZeroSequence(host);
  5594. for (index = 0; index < 8; index++) {
  5595. if (ignore0 && host[index] === 0)
  5596. continue;
  5597. if (ignore0)
  5598. ignore0 = false;
  5599. if (compress === index) {
  5600. result += index ? ':' : '::';
  5601. ignore0 = true;
  5602. } else {
  5603. result += host[index].toString(16);
  5604. if (index < 7)
  5605. result += ':';
  5606. }
  5607. }
  5608. return '[' + result + ']';
  5609. }
  5610. return host;
  5611. };
  5612. var C0ControlPercentEncodeSet = {};
  5613. var fragmentPercentEncodeSet = assign({}, C0ControlPercentEncodeSet, {
  5614. ' ': 1,
  5615. '"': 1,
  5616. '<': 1,
  5617. '>': 1,
  5618. '`': 1
  5619. });
  5620. var pathPercentEncodeSet = assign({}, fragmentPercentEncodeSet, {
  5621. '#': 1,
  5622. '?': 1,
  5623. '{': 1,
  5624. '}': 1
  5625. });
  5626. var userinfoPercentEncodeSet = assign({}, pathPercentEncodeSet, {
  5627. '/': 1,
  5628. ':': 1,
  5629. ';': 1,
  5630. '=': 1,
  5631. '@': 1,
  5632. '[': 1,
  5633. '\\': 1,
  5634. ']': 1,
  5635. '^': 1,
  5636. '|': 1
  5637. });
  5638. var percentEncode = function (char, set) {
  5639. var code = codeAt(char, 0);
  5640. return code > 0x20 && code < 0x7F && !has(set, char) ? char : encodeURIComponent(char);
  5641. };
  5642. var specialSchemes = {
  5643. ftp: 21,
  5644. file: null,
  5645. http: 80,
  5646. https: 443,
  5647. ws: 80,
  5648. wss: 443
  5649. };
  5650. var isSpecial = function (url) {
  5651. return has(specialSchemes, url.scheme);
  5652. };
  5653. var includesCredentials = function (url) {
  5654. return url.username != '' || url.password != '';
  5655. };
  5656. var cannotHaveUsernamePasswordPort = function (url) {
  5657. return !url.host || url.cannotBeABaseURL || url.scheme == 'file';
  5658. };
  5659. var isWindowsDriveLetter = function (string, normalized) {
  5660. var second;
  5661. return string.length == 2 && ALPHA.test(string.charAt(0)) && ((second = string.charAt(1)) == ':' || !normalized && second == '|');
  5662. };
  5663. var startsWithWindowsDriveLetter = function (string) {
  5664. var third;
  5665. return string.length > 1 && isWindowsDriveLetter(string.slice(0, 2)) && (string.length == 2 || ((third = string.charAt(2)) === '/' || third === '\\' || third === '?' || third === '#'));
  5666. };
  5667. var shortenURLsPath = function (url) {
  5668. var path = url.path;
  5669. var pathSize = path.length;
  5670. if (pathSize && (url.scheme != 'file' || pathSize != 1 || !isWindowsDriveLetter(path[0], true))) {
  5671. path.pop();
  5672. }
  5673. };
  5674. var isSingleDot = function (segment) {
  5675. return segment === '.' || segment.toLowerCase() === '%2e';
  5676. };
  5677. var isDoubleDot = function (segment) {
  5678. segment = segment.toLowerCase();
  5679. return segment === '..' || segment === '%2e.' || segment === '.%2e' || segment === '%2e%2e';
  5680. };
  5681. var SCHEME_START = {};
  5682. var SCHEME = {};
  5683. var NO_SCHEME = {};
  5684. var SPECIAL_RELATIVE_OR_AUTHORITY = {};
  5685. var PATH_OR_AUTHORITY = {};
  5686. var RELATIVE = {};
  5687. var RELATIVE_SLASH = {};
  5688. var SPECIAL_AUTHORITY_SLASHES = {};
  5689. var SPECIAL_AUTHORITY_IGNORE_SLASHES = {};
  5690. var AUTHORITY = {};
  5691. var HOST = {};
  5692. var HOSTNAME = {};
  5693. var PORT = {};
  5694. var FILE = {};
  5695. var FILE_SLASH = {};
  5696. var FILE_HOST = {};
  5697. var PATH_START = {};
  5698. var PATH = {};
  5699. var CANNOT_BE_A_BASE_URL_PATH = {};
  5700. var QUERY = {};
  5701. var FRAGMENT = {};
  5702. var parseURL = function (url, input, stateOverride, base) {
  5703. var state = stateOverride || SCHEME_START;
  5704. var pointer = 0;
  5705. var buffer = '';
  5706. var seenAt = false;
  5707. var seenBracket = false;
  5708. var seenPasswordToken = false;
  5709. var codePoints, char, bufferCodePoints, failure;
  5710. if (!stateOverride) {
  5711. url.scheme = '';
  5712. url.username = '';
  5713. url.password = '';
  5714. url.host = null;
  5715. url.port = null;
  5716. url.path = [];
  5717. url.query = null;
  5718. url.fragment = null;
  5719. url.cannotBeABaseURL = false;
  5720. input = input.replace(LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE, '');
  5721. }
  5722. input = input.replace(TAB_AND_NEW_LINE, '');
  5723. codePoints = arrayFrom(input);
  5724. while (pointer <= codePoints.length) {
  5725. char = codePoints[pointer];
  5726. switch (state) {
  5727. case SCHEME_START:
  5728. if (char && ALPHA.test(char)) {
  5729. buffer += char.toLowerCase();
  5730. state = SCHEME;
  5731. } else if (!stateOverride) {
  5732. state = NO_SCHEME;
  5733. continue;
  5734. } else
  5735. return INVALID_SCHEME;
  5736. break;
  5737. case SCHEME:
  5738. if (char && (ALPHANUMERIC.test(char) || char == '+' || char == '-' || char == '.')) {
  5739. buffer += char.toLowerCase();
  5740. } else if (char == ':') {
  5741. if (stateOverride && (isSpecial(url) != has(specialSchemes, buffer) || buffer == 'file' && (includesCredentials(url) || url.port !== null) || url.scheme == 'file' && !url.host))
  5742. return;
  5743. url.scheme = buffer;
  5744. if (stateOverride) {
  5745. if (isSpecial(url) && specialSchemes[url.scheme] == url.port)
  5746. url.port = null;
  5747. return;
  5748. }
  5749. buffer = '';
  5750. if (url.scheme == 'file') {
  5751. state = FILE;
  5752. } else if (isSpecial(url) && base && base.scheme == url.scheme) {
  5753. state = SPECIAL_RELATIVE_OR_AUTHORITY;
  5754. } else if (isSpecial(url)) {
  5755. state = SPECIAL_AUTHORITY_SLASHES;
  5756. } else if (codePoints[pointer + 1] == '/') {
  5757. state = PATH_OR_AUTHORITY;
  5758. pointer++;
  5759. } else {
  5760. url.cannotBeABaseURL = true;
  5761. url.path.push('');
  5762. state = CANNOT_BE_A_BASE_URL_PATH;
  5763. }
  5764. } else if (!stateOverride) {
  5765. buffer = '';
  5766. state = NO_SCHEME;
  5767. pointer = 0;
  5768. continue;
  5769. } else
  5770. return INVALID_SCHEME;
  5771. break;
  5772. case NO_SCHEME:
  5773. if (!base || base.cannotBeABaseURL && char != '#')
  5774. return INVALID_SCHEME;
  5775. if (base.cannotBeABaseURL && char == '#') {
  5776. url.scheme = base.scheme;
  5777. url.path = base.path.slice();
  5778. url.query = base.query;
  5779. url.fragment = '';
  5780. url.cannotBeABaseURL = true;
  5781. state = FRAGMENT;
  5782. break;
  5783. }
  5784. state = base.scheme == 'file' ? FILE : RELATIVE;
  5785. continue;
  5786. case SPECIAL_RELATIVE_OR_AUTHORITY:
  5787. if (char == '/' && codePoints[pointer + 1] == '/') {
  5788. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  5789. pointer++;
  5790. } else {
  5791. state = RELATIVE;
  5792. continue;
  5793. }
  5794. break;
  5795. case PATH_OR_AUTHORITY:
  5796. if (char == '/') {
  5797. state = AUTHORITY;
  5798. break;
  5799. } else {
  5800. state = PATH;
  5801. continue;
  5802. }
  5803. case RELATIVE:
  5804. url.scheme = base.scheme;
  5805. if (char == EOF) {
  5806. url.username = base.username;
  5807. url.password = base.password;
  5808. url.host = base.host;
  5809. url.port = base.port;
  5810. url.path = base.path.slice();
  5811. url.query = base.query;
  5812. } else if (char == '/' || char == '\\' && isSpecial(url)) {
  5813. state = RELATIVE_SLASH;
  5814. } else if (char == '?') {
  5815. url.username = base.username;
  5816. url.password = base.password;
  5817. url.host = base.host;
  5818. url.port = base.port;
  5819. url.path = base.path.slice();
  5820. url.query = '';
  5821. state = QUERY;
  5822. } else if (char == '#') {
  5823. url.username = base.username;
  5824. url.password = base.password;
  5825. url.host = base.host;
  5826. url.port = base.port;
  5827. url.path = base.path.slice();
  5828. url.query = base.query;
  5829. url.fragment = '';
  5830. state = FRAGMENT;
  5831. } else {
  5832. url.username = base.username;
  5833. url.password = base.password;
  5834. url.host = base.host;
  5835. url.port = base.port;
  5836. url.path = base.path.slice();
  5837. url.path.pop();
  5838. state = PATH;
  5839. continue;
  5840. }
  5841. break;
  5842. case RELATIVE_SLASH:
  5843. if (isSpecial(url) && (char == '/' || char == '\\')) {
  5844. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  5845. } else if (char == '/') {
  5846. state = AUTHORITY;
  5847. } else {
  5848. url.username = base.username;
  5849. url.password = base.password;
  5850. url.host = base.host;
  5851. url.port = base.port;
  5852. state = PATH;
  5853. continue;
  5854. }
  5855. break;
  5856. case SPECIAL_AUTHORITY_SLASHES:
  5857. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  5858. if (char != '/' || buffer.charAt(pointer + 1) != '/')
  5859. continue;
  5860. pointer++;
  5861. break;
  5862. case SPECIAL_AUTHORITY_IGNORE_SLASHES:
  5863. if (char != '/' && char != '\\') {
  5864. state = AUTHORITY;
  5865. continue;
  5866. }
  5867. break;
  5868. case AUTHORITY:
  5869. if (char == '@') {
  5870. if (seenAt)
  5871. buffer = '%40' + buffer;
  5872. seenAt = true;
  5873. bufferCodePoints = arrayFrom(buffer);
  5874. for (var i = 0; i < bufferCodePoints.length; i++) {
  5875. var codePoint = bufferCodePoints[i];
  5876. if (codePoint == ':' && !seenPasswordToken) {
  5877. seenPasswordToken = true;
  5878. continue;
  5879. }
  5880. var encodedCodePoints = percentEncode(codePoint, userinfoPercentEncodeSet);
  5881. if (seenPasswordToken)
  5882. url.password += encodedCodePoints;
  5883. else
  5884. url.username += encodedCodePoints;
  5885. }
  5886. buffer = '';
  5887. } else if (char == EOF || char == '/' || char == '?' || char == '#' || char == '\\' && isSpecial(url)) {
  5888. if (seenAt && buffer == '')
  5889. return INVALID_AUTHORITY;
  5890. pointer -= arrayFrom(buffer).length + 1;
  5891. buffer = '';
  5892. state = HOST;
  5893. } else
  5894. buffer += char;
  5895. break;
  5896. case HOST:
  5897. case HOSTNAME:
  5898. if (stateOverride && url.scheme == 'file') {
  5899. state = FILE_HOST;
  5900. continue;
  5901. } else if (char == ':' && !seenBracket) {
  5902. if (buffer == '')
  5903. return INVALID_HOST;
  5904. failure = parseHost(url, buffer);
  5905. if (failure)
  5906. return failure;
  5907. buffer = '';
  5908. state = PORT;
  5909. if (stateOverride == HOSTNAME)
  5910. return;
  5911. } else if (char == EOF || char == '/' || char == '?' || char == '#' || char == '\\' && isSpecial(url)) {
  5912. if (isSpecial(url) && buffer == '')
  5913. return INVALID_HOST;
  5914. if (stateOverride && buffer == '' && (includesCredentials(url) || url.port !== null))
  5915. return;
  5916. failure = parseHost(url, buffer);
  5917. if (failure)
  5918. return failure;
  5919. buffer = '';
  5920. state = PATH_START;
  5921. if (stateOverride)
  5922. return;
  5923. continue;
  5924. } else {
  5925. if (char == '[')
  5926. seenBracket = true;
  5927. else if (char == ']')
  5928. seenBracket = false;
  5929. buffer += char;
  5930. }
  5931. break;
  5932. case PORT:
  5933. if (DIGIT.test(char)) {
  5934. buffer += char;
  5935. } else if (char == EOF || char == '/' || char == '?' || char == '#' || char == '\\' && isSpecial(url) || stateOverride) {
  5936. if (buffer != '') {
  5937. var port = parseInt(buffer, 10);
  5938. if (port > 0xFFFF)
  5939. return INVALID_PORT;
  5940. url.port = isSpecial(url) && port === specialSchemes[url.scheme] ? null : port;
  5941. buffer = '';
  5942. }
  5943. if (stateOverride)
  5944. return;
  5945. state = PATH_START;
  5946. continue;
  5947. } else
  5948. return INVALID_PORT;
  5949. break;
  5950. case FILE:
  5951. url.scheme = 'file';
  5952. if (char == '/' || char == '\\')
  5953. state = FILE_SLASH;
  5954. else if (base && base.scheme == 'file') {
  5955. if (char == EOF) {
  5956. url.host = base.host;
  5957. url.path = base.path.slice();
  5958. url.query = base.query;
  5959. } else if (char == '?') {
  5960. url.host = base.host;
  5961. url.path = base.path.slice();
  5962. url.query = '';
  5963. state = QUERY;
  5964. } else if (char == '#') {
  5965. url.host = base.host;
  5966. url.path = base.path.slice();
  5967. url.query = base.query;
  5968. url.fragment = '';
  5969. state = FRAGMENT;
  5970. } else {
  5971. if (!startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) {
  5972. url.host = base.host;
  5973. url.path = base.path.slice();
  5974. shortenURLsPath(url);
  5975. }
  5976. state = PATH;
  5977. continue;
  5978. }
  5979. } else {
  5980. state = PATH;
  5981. continue;
  5982. }
  5983. break;
  5984. case FILE_SLASH:
  5985. if (char == '/' || char == '\\') {
  5986. state = FILE_HOST;
  5987. break;
  5988. }
  5989. if (base && base.scheme == 'file' && !startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) {
  5990. if (isWindowsDriveLetter(base.path[0], true))
  5991. url.path.push(base.path[0]);
  5992. else
  5993. url.host = base.host;
  5994. }
  5995. state = PATH;
  5996. continue;
  5997. case FILE_HOST:
  5998. if (char == EOF || char == '/' || char == '\\' || char == '?' || char == '#') {
  5999. if (!stateOverride && isWindowsDriveLetter(buffer)) {
  6000. state = PATH;
  6001. } else if (buffer == '') {
  6002. url.host = '';
  6003. if (stateOverride)
  6004. return;
  6005. state = PATH_START;
  6006. } else {
  6007. failure = parseHost(url, buffer);
  6008. if (failure)
  6009. return failure;
  6010. if (url.host == 'localhost')
  6011. url.host = '';
  6012. if (stateOverride)
  6013. return;
  6014. buffer = '';
  6015. state = PATH_START;
  6016. }
  6017. continue;
  6018. } else
  6019. buffer += char;
  6020. break;
  6021. case PATH_START:
  6022. if (isSpecial(url)) {
  6023. state = PATH;
  6024. if (char != '/' && char != '\\')
  6025. continue;
  6026. } else if (!stateOverride && char == '?') {
  6027. url.query = '';
  6028. state = QUERY;
  6029. } else if (!stateOverride && char == '#') {
  6030. url.fragment = '';
  6031. state = FRAGMENT;
  6032. } else if (char != EOF) {
  6033. state = PATH;
  6034. if (char != '/')
  6035. continue;
  6036. }
  6037. break;
  6038. case PATH:
  6039. if (char == EOF || char == '/' || char == '\\' && isSpecial(url) || !stateOverride && (char == '?' || char == '#')) {
  6040. if (isDoubleDot(buffer)) {
  6041. shortenURLsPath(url);
  6042. if (char != '/' && !(char == '\\' && isSpecial(url))) {
  6043. url.path.push('');
  6044. }
  6045. } else if (isSingleDot(buffer)) {
  6046. if (char != '/' && !(char == '\\' && isSpecial(url))) {
  6047. url.path.push('');
  6048. }
  6049. } else {
  6050. if (url.scheme == 'file' && !url.path.length && isWindowsDriveLetter(buffer)) {
  6051. if (url.host)
  6052. url.host = '';
  6053. buffer = buffer.charAt(0) + ':';
  6054. }
  6055. url.path.push(buffer);
  6056. }
  6057. buffer = '';
  6058. if (url.scheme == 'file' && (char == EOF || char == '?' || char == '#')) {
  6059. while (url.path.length > 1 && url.path[0] === '') {
  6060. url.path.shift();
  6061. }
  6062. }
  6063. if (char == '?') {
  6064. url.query = '';
  6065. state = QUERY;
  6066. } else if (char == '#') {
  6067. url.fragment = '';
  6068. state = FRAGMENT;
  6069. }
  6070. } else {
  6071. buffer += percentEncode(char, pathPercentEncodeSet);
  6072. }
  6073. break;
  6074. case CANNOT_BE_A_BASE_URL_PATH:
  6075. if (char == '?') {
  6076. url.query = '';
  6077. state = QUERY;
  6078. } else if (char == '#') {
  6079. url.fragment = '';
  6080. state = FRAGMENT;
  6081. } else if (char != EOF) {
  6082. url.path[0] += percentEncode(char, C0ControlPercentEncodeSet);
  6083. }
  6084. break;
  6085. case QUERY:
  6086. if (!stateOverride && char == '#') {
  6087. url.fragment = '';
  6088. state = FRAGMENT;
  6089. } else if (char != EOF) {
  6090. if (char == "'" && isSpecial(url))
  6091. url.query += '%27';
  6092. else if (char == '#')
  6093. url.query += '%23';
  6094. else
  6095. url.query += percentEncode(char, C0ControlPercentEncodeSet);
  6096. }
  6097. break;
  6098. case FRAGMENT:
  6099. if (char != EOF)
  6100. url.fragment += percentEncode(char, fragmentPercentEncodeSet);
  6101. break;
  6102. }
  6103. pointer++;
  6104. }
  6105. };
  6106. var URLConstructor = function URL(url) {
  6107. var that = anInstance(this, URLConstructor, 'URL');
  6108. var base = arguments.length > 1 ? arguments[1] : undefined;
  6109. var urlString = String(url);
  6110. var state = setInternalState(that, { type: 'URL' });
  6111. var baseState, failure;
  6112. if (base !== undefined) {
  6113. if (base instanceof URLConstructor)
  6114. baseState = getInternalURLState(base);
  6115. else {
  6116. failure = parseURL(baseState = {}, String(base));
  6117. if (failure)
  6118. throw TypeError(failure);
  6119. }
  6120. }
  6121. failure = parseURL(state, urlString, null, baseState);
  6122. if (failure)
  6123. throw TypeError(failure);
  6124. var searchParams = state.searchParams = new URLSearchParams();
  6125. var searchParamsState = getInternalSearchParamsState(searchParams);
  6126. searchParamsState.updateSearchParams(state.query);
  6127. searchParamsState.updateURL = function () {
  6128. state.query = String(searchParams) || null;
  6129. };
  6130. if (!DESCRIPTORS) {
  6131. that.href = serializeURL.call(that);
  6132. that.origin = getOrigin.call(that);
  6133. that.protocol = getProtocol.call(that);
  6134. that.username = getUsername.call(that);
  6135. that.password = getPassword.call(that);
  6136. that.host = getHost.call(that);
  6137. that.hostname = getHostname.call(that);
  6138. that.port = getPort.call(that);
  6139. that.pathname = getPathname.call(that);
  6140. that.search = getSearch.call(that);
  6141. that.searchParams = getSearchParams.call(that);
  6142. that.hash = getHash.call(that);
  6143. }
  6144. };
  6145. var URLPrototype = URLConstructor.prototype;
  6146. var serializeURL = function () {
  6147. var url = getInternalURLState(this);
  6148. var scheme = url.scheme;
  6149. var username = url.username;
  6150. var password = url.password;
  6151. var host = url.host;
  6152. var port = url.port;
  6153. var path = url.path;
  6154. var query = url.query;
  6155. var fragment = url.fragment;
  6156. var output = scheme + ':';
  6157. if (host !== null) {
  6158. output += '//';
  6159. if (includesCredentials(url)) {
  6160. output += username + (password ? ':' + password : '') + '@';
  6161. }
  6162. output += serializeHost(host);
  6163. if (port !== null)
  6164. output += ':' + port;
  6165. } else if (scheme == 'file')
  6166. output += '//';
  6167. output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : '';
  6168. if (query !== null)
  6169. output += '?' + query;
  6170. if (fragment !== null)
  6171. output += '#' + fragment;
  6172. return output;
  6173. };
  6174. var getOrigin = function () {
  6175. var url = getInternalURLState(this);
  6176. var scheme = url.scheme;
  6177. var port = url.port;
  6178. if (scheme == 'blob')
  6179. try {
  6180. return new URL(scheme.path[0]).origin;
  6181. } catch (error) {
  6182. return 'null';
  6183. }
  6184. if (scheme == 'file' || !isSpecial(url))
  6185. return 'null';
  6186. return scheme + '://' + serializeHost(url.host) + (port !== null ? ':' + port : '');
  6187. };
  6188. var getProtocol = function () {
  6189. return getInternalURLState(this).scheme + ':';
  6190. };
  6191. var getUsername = function () {
  6192. return getInternalURLState(this).username;
  6193. };
  6194. var getPassword = function () {
  6195. return getInternalURLState(this).password;
  6196. };
  6197. var getHost = function () {
  6198. var url = getInternalURLState(this);
  6199. var host = url.host;
  6200. var port = url.port;
  6201. return host === null ? '' : port === null ? serializeHost(host) : serializeHost(host) + ':' + port;
  6202. };
  6203. var getHostname = function () {
  6204. var host = getInternalURLState(this).host;
  6205. return host === null ? '' : serializeHost(host);
  6206. };
  6207. var getPort = function () {
  6208. var port = getInternalURLState(this).port;
  6209. return port === null ? '' : String(port);
  6210. };
  6211. var getPathname = function () {
  6212. var url = getInternalURLState(this);
  6213. var path = url.path;
  6214. return url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : '';
  6215. };
  6216. var getSearch = function () {
  6217. var query = getInternalURLState(this).query;
  6218. return query ? '?' + query : '';
  6219. };
  6220. var getSearchParams = function () {
  6221. return getInternalURLState(this).searchParams;
  6222. };
  6223. var getHash = function () {
  6224. var fragment = getInternalURLState(this).fragment;
  6225. return fragment ? '#' + fragment : '';
  6226. };
  6227. var accessorDescriptor = function (getter, setter) {
  6228. return {
  6229. get: getter,
  6230. set: setter,
  6231. configurable: true,
  6232. enumerable: true
  6233. };
  6234. };
  6235. if (DESCRIPTORS) {
  6236. defineProperties(URLPrototype, {
  6237. href: accessorDescriptor(serializeURL, function (href) {
  6238. var url = getInternalURLState(this);
  6239. var urlString = String(href);
  6240. var failure = parseURL(url, urlString);
  6241. if (failure)
  6242. throw TypeError(failure);
  6243. getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query);
  6244. }),
  6245. origin: accessorDescriptor(getOrigin),
  6246. protocol: accessorDescriptor(getProtocol, function (protocol) {
  6247. var url = getInternalURLState(this);
  6248. parseURL(url, String(protocol) + ':', SCHEME_START);
  6249. }),
  6250. username: accessorDescriptor(getUsername, function (username) {
  6251. var url = getInternalURLState(this);
  6252. var codePoints = arrayFrom(String(username));
  6253. if (cannotHaveUsernamePasswordPort(url))
  6254. return;
  6255. url.username = '';
  6256. for (var i = 0; i < codePoints.length; i++) {
  6257. url.username += percentEncode(codePoints[i], userinfoPercentEncodeSet);
  6258. }
  6259. }),
  6260. password: accessorDescriptor(getPassword, function (password) {
  6261. var url = getInternalURLState(this);
  6262. var codePoints = arrayFrom(String(password));
  6263. if (cannotHaveUsernamePasswordPort(url))
  6264. return;
  6265. url.password = '';
  6266. for (var i = 0; i < codePoints.length; i++) {
  6267. url.password += percentEncode(codePoints[i], userinfoPercentEncodeSet);
  6268. }
  6269. }),
  6270. host: accessorDescriptor(getHost, function (host) {
  6271. var url = getInternalURLState(this);
  6272. if (url.cannotBeABaseURL)
  6273. return;
  6274. parseURL(url, String(host), HOST);
  6275. }),
  6276. hostname: accessorDescriptor(getHostname, function (hostname) {
  6277. var url = getInternalURLState(this);
  6278. if (url.cannotBeABaseURL)
  6279. return;
  6280. parseURL(url, String(hostname), HOSTNAME);
  6281. }),
  6282. port: accessorDescriptor(getPort, function (port) {
  6283. var url = getInternalURLState(this);
  6284. if (cannotHaveUsernamePasswordPort(url))
  6285. return;
  6286. port = String(port);
  6287. if (port == '')
  6288. url.port = null;
  6289. else
  6290. parseURL(url, port, PORT);
  6291. }),
  6292. pathname: accessorDescriptor(getPathname, function (pathname) {
  6293. var url = getInternalURLState(this);
  6294. if (url.cannotBeABaseURL)
  6295. return;
  6296. url.path = [];
  6297. parseURL(url, pathname + '', PATH_START);
  6298. }),
  6299. search: accessorDescriptor(getSearch, function (search) {
  6300. var url = getInternalURLState(this);
  6301. search = String(search);
  6302. if (search == '') {
  6303. url.query = null;
  6304. } else {
  6305. if ('?' == search.charAt(0))
  6306. search = search.slice(1);
  6307. url.query = '';
  6308. parseURL(url, search, QUERY);
  6309. }
  6310. getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query);
  6311. }),
  6312. searchParams: accessorDescriptor(getSearchParams),
  6313. hash: accessorDescriptor(getHash, function (hash) {
  6314. var url = getInternalURLState(this);
  6315. hash = String(hash);
  6316. if (hash == '') {
  6317. url.fragment = null;
  6318. return;
  6319. }
  6320. if ('#' == hash.charAt(0))
  6321. hash = hash.slice(1);
  6322. url.fragment = '';
  6323. parseURL(url, hash, FRAGMENT);
  6324. })
  6325. });
  6326. }
  6327. redefine(URLPrototype, 'toJSON', function toJSON() {
  6328. return serializeURL.call(this);
  6329. }, { enumerable: true });
  6330. redefine(URLPrototype, 'toString', function toString() {
  6331. return serializeURL.call(this);
  6332. }, { enumerable: true });
  6333. if (NativeURL) {
  6334. var nativeCreateObjectURL = NativeURL.createObjectURL;
  6335. var nativeRevokeObjectURL = NativeURL.revokeObjectURL;
  6336. if (nativeCreateObjectURL)
  6337. redefine(URLConstructor, 'createObjectURL', function createObjectURL(blob) {
  6338. return nativeCreateObjectURL.apply(NativeURL, arguments);
  6339. });
  6340. if (nativeRevokeObjectURL)
  6341. redefine(URLConstructor, 'revokeObjectURL', function revokeObjectURL(url) {
  6342. return nativeRevokeObjectURL.apply(NativeURL, arguments);
  6343. });
  6344. }
  6345. setToStringTag(URLConstructor, 'URL');
  6346. $({
  6347. global: true,
  6348. forced: !USE_NATIVE_URL,
  6349. sham: !DESCRIPTORS
  6350. }, { URL: URLConstructor });
  6351. /***/ }),
  6352. /* 140 */
  6353. /***/ (function(module, exports, __w_pdfjs_require__) {
  6354. var fails = __w_pdfjs_require__(14);
  6355. var wellKnownSymbol = __w_pdfjs_require__(57);
  6356. var IS_PURE = __w_pdfjs_require__(37);
  6357. var ITERATOR = wellKnownSymbol('iterator');
  6358. module.exports = !fails(function () {
  6359. var url = new URL('b?a=1&b=2&c=3', 'http://a');
  6360. var searchParams = url.searchParams;
  6361. var result = '';
  6362. url.pathname = 'c%20d';
  6363. searchParams.forEach(function (value, key) {
  6364. searchParams['delete']('b');
  6365. result += key + value;
  6366. });
  6367. return IS_PURE && !url.toJSON || !searchParams.sort || url.href !== 'http://a/c%20d?a=1&c=3' || searchParams.get('c') !== '3' || String(new URLSearchParams('?a=1')) !== 'a=1' || !searchParams[ITERATOR] || new URL('https://a@b').username !== 'a' || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b' || new URL('http://тест').host !== 'xn--e1aybc' || new URL('http://a#б').hash !== '#%D0%B1' || result !== 'a1c3' || new URL('http://x', undefined).host !== 'x';
  6368. });
  6369. /***/ }),
  6370. /* 141 */
  6371. /***/ (function(module, exports, __w_pdfjs_require__) {
  6372. "use strict";
  6373. var maxInt = 2147483647;
  6374. var base = 36;
  6375. var tMin = 1;
  6376. var tMax = 26;
  6377. var skew = 38;
  6378. var damp = 700;
  6379. var initialBias = 72;
  6380. var initialN = 128;
  6381. var delimiter = '-';
  6382. var regexNonASCII = /[^\0-\u007E]/;
  6383. var regexSeparators = /[.\u3002\uFF0E\uFF61]/g;
  6384. var OVERFLOW_ERROR = 'Overflow: input needs wider integers to process';
  6385. var baseMinusTMin = base - tMin;
  6386. var floor = Math.floor;
  6387. var stringFromCharCode = String.fromCharCode;
  6388. var ucs2decode = function (string) {
  6389. var output = [];
  6390. var counter = 0;
  6391. var length = string.length;
  6392. while (counter < length) {
  6393. var value = string.charCodeAt(counter++);
  6394. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  6395. var extra = string.charCodeAt(counter++);
  6396. if ((extra & 0xFC00) == 0xDC00) {
  6397. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  6398. } else {
  6399. output.push(value);
  6400. counter--;
  6401. }
  6402. } else {
  6403. output.push(value);
  6404. }
  6405. }
  6406. return output;
  6407. };
  6408. var digitToBasic = function (digit) {
  6409. return digit + 22 + 75 * (digit < 26);
  6410. };
  6411. var adapt = function (delta, numPoints, firstTime) {
  6412. var k = 0;
  6413. delta = firstTime ? floor(delta / damp) : delta >> 1;
  6414. delta += floor(delta / numPoints);
  6415. for (; delta > baseMinusTMin * tMax >> 1; k += base) {
  6416. delta = floor(delta / baseMinusTMin);
  6417. }
  6418. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  6419. };
  6420. var encode = function (input) {
  6421. var output = [];
  6422. input = ucs2decode(input);
  6423. var inputLength = input.length;
  6424. var n = initialN;
  6425. var delta = 0;
  6426. var bias = initialBias;
  6427. var i, currentValue;
  6428. for (i = 0; i < input.length; i++) {
  6429. currentValue = input[i];
  6430. if (currentValue < 0x80) {
  6431. output.push(stringFromCharCode(currentValue));
  6432. }
  6433. }
  6434. var basicLength = output.length;
  6435. var handledCPCount = basicLength;
  6436. if (basicLength) {
  6437. output.push(delimiter);
  6438. }
  6439. while (handledCPCount < inputLength) {
  6440. var m = maxInt;
  6441. for (i = 0; i < input.length; i++) {
  6442. currentValue = input[i];
  6443. if (currentValue >= n && currentValue < m) {
  6444. m = currentValue;
  6445. }
  6446. }
  6447. var handledCPCountPlusOne = handledCPCount + 1;
  6448. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  6449. throw RangeError(OVERFLOW_ERROR);
  6450. }
  6451. delta += (m - n) * handledCPCountPlusOne;
  6452. n = m;
  6453. for (i = 0; i < input.length; i++) {
  6454. currentValue = input[i];
  6455. if (currentValue < n && ++delta > maxInt) {
  6456. throw RangeError(OVERFLOW_ERROR);
  6457. }
  6458. if (currentValue == n) {
  6459. var q = delta;
  6460. for (var k = base;; k += base) {
  6461. var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
  6462. if (q < t)
  6463. break;
  6464. var qMinusT = q - t;
  6465. var baseMinusT = base - t;
  6466. output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT)));
  6467. q = floor(qMinusT / baseMinusT);
  6468. }
  6469. output.push(stringFromCharCode(digitToBasic(q)));
  6470. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  6471. delta = 0;
  6472. ++handledCPCount;
  6473. }
  6474. }
  6475. ++delta;
  6476. ++n;
  6477. }
  6478. return output.join('');
  6479. };
  6480. module.exports = function (input) {
  6481. var encoded = [];
  6482. var labels = input.toLowerCase().replace(regexSeparators, '\u002E').split('.');
  6483. var i, label;
  6484. for (i = 0; i < labels.length; i++) {
  6485. label = labels[i];
  6486. encoded.push(regexNonASCII.test(label) ? 'xn--' + encode(label) : label);
  6487. }
  6488. return encoded.join('.');
  6489. };
  6490. /***/ }),
  6491. /* 142 */
  6492. /***/ (function(module, exports, __w_pdfjs_require__) {
  6493. "use strict";
  6494. __w_pdfjs_require__(102);
  6495. var $ = __w_pdfjs_require__(10);
  6496. var getBuiltIn = __w_pdfjs_require__(42);
  6497. var USE_NATIVE_URL = __w_pdfjs_require__(140);
  6498. var redefine = __w_pdfjs_require__(29);
  6499. var redefineAll = __w_pdfjs_require__(124);
  6500. var setToStringTag = __w_pdfjs_require__(85);
  6501. var createIteratorConstructor = __w_pdfjs_require__(80);
  6502. var InternalStateModule = __w_pdfjs_require__(33);
  6503. var anInstance = __w_pdfjs_require__(126);
  6504. var hasOwn = __w_pdfjs_require__(23);
  6505. var bind = __w_pdfjs_require__(62);
  6506. var classof = __w_pdfjs_require__(95);
  6507. var anObject = __w_pdfjs_require__(28);
  6508. var isObject = __w_pdfjs_require__(22);
  6509. var create = __w_pdfjs_require__(71);
  6510. var createPropertyDescriptor = __w_pdfjs_require__(16);
  6511. var getIterator = __w_pdfjs_require__(143);
  6512. var getIteratorMethod = __w_pdfjs_require__(94);
  6513. var wellKnownSymbol = __w_pdfjs_require__(57);
  6514. var $fetch = getBuiltIn('fetch');
  6515. var Headers = getBuiltIn('Headers');
  6516. var ITERATOR = wellKnownSymbol('iterator');
  6517. var URL_SEARCH_PARAMS = 'URLSearchParams';
  6518. var URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator';
  6519. var setInternalState = InternalStateModule.set;
  6520. var getInternalParamsState = InternalStateModule.getterFor(URL_SEARCH_PARAMS);
  6521. var getInternalIteratorState = InternalStateModule.getterFor(URL_SEARCH_PARAMS_ITERATOR);
  6522. var plus = /\+/g;
  6523. var sequences = Array(4);
  6524. var percentSequence = function (bytes) {
  6525. return sequences[bytes - 1] || (sequences[bytes - 1] = RegExp('((?:%[\\da-f]{2}){' + bytes + '})', 'gi'));
  6526. };
  6527. var percentDecode = function (sequence) {
  6528. try {
  6529. return decodeURIComponent(sequence);
  6530. } catch (error) {
  6531. return sequence;
  6532. }
  6533. };
  6534. var deserialize = function (it) {
  6535. var result = it.replace(plus, ' ');
  6536. var bytes = 4;
  6537. try {
  6538. return decodeURIComponent(result);
  6539. } catch (error) {
  6540. while (bytes) {
  6541. result = result.replace(percentSequence(bytes--), percentDecode);
  6542. }
  6543. return result;
  6544. }
  6545. };
  6546. var find = /[!'()~]|%20/g;
  6547. var replace = {
  6548. '!': '%21',
  6549. "'": '%27',
  6550. '(': '%28',
  6551. ')': '%29',
  6552. '~': '%7E',
  6553. '%20': '+'
  6554. };
  6555. var replacer = function (match) {
  6556. return replace[match];
  6557. };
  6558. var serialize = function (it) {
  6559. return encodeURIComponent(it).replace(find, replacer);
  6560. };
  6561. var parseSearchParams = function (result, query) {
  6562. if (query) {
  6563. var attributes = query.split('&');
  6564. var index = 0;
  6565. var attribute, entry;
  6566. while (index < attributes.length) {
  6567. attribute = attributes[index++];
  6568. if (attribute.length) {
  6569. entry = attribute.split('=');
  6570. result.push({
  6571. key: deserialize(entry.shift()),
  6572. value: deserialize(entry.join('='))
  6573. });
  6574. }
  6575. }
  6576. }
  6577. };
  6578. var updateSearchParams = function (query) {
  6579. this.entries.length = 0;
  6580. parseSearchParams(this.entries, query);
  6581. };
  6582. var validateArgumentsLength = function (passed, required) {
  6583. if (passed < required)
  6584. throw TypeError('Not enough arguments');
  6585. };
  6586. var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) {
  6587. setInternalState(this, {
  6588. type: URL_SEARCH_PARAMS_ITERATOR,
  6589. iterator: getIterator(getInternalParamsState(params).entries),
  6590. kind: kind
  6591. });
  6592. }, 'Iterator', function next() {
  6593. var state = getInternalIteratorState(this);
  6594. var kind = state.kind;
  6595. var step = state.iterator.next();
  6596. var entry = step.value;
  6597. if (!step.done) {
  6598. step.value = kind === 'keys' ? entry.key : kind === 'values' ? entry.value : [
  6599. entry.key,
  6600. entry.value
  6601. ];
  6602. }
  6603. return step;
  6604. });
  6605. var URLSearchParamsConstructor = function URLSearchParams() {
  6606. anInstance(this, URLSearchParamsConstructor, URL_SEARCH_PARAMS);
  6607. var init = arguments.length > 0 ? arguments[0] : undefined;
  6608. var that = this;
  6609. var entries = [];
  6610. var iteratorMethod, iterator, next, step, entryIterator, entryNext, first, second, key;
  6611. setInternalState(that, {
  6612. type: URL_SEARCH_PARAMS,
  6613. entries: entries,
  6614. updateURL: function () {
  6615. },
  6616. updateSearchParams: updateSearchParams
  6617. });
  6618. if (init !== undefined) {
  6619. if (isObject(init)) {
  6620. iteratorMethod = getIteratorMethod(init);
  6621. if (typeof iteratorMethod === 'function') {
  6622. iterator = iteratorMethod.call(init);
  6623. next = iterator.next;
  6624. while (!(step = next.call(iterator)).done) {
  6625. entryIterator = getIterator(anObject(step.value));
  6626. entryNext = entryIterator.next;
  6627. if ((first = entryNext.call(entryIterator)).done || (second = entryNext.call(entryIterator)).done || !entryNext.call(entryIterator).done)
  6628. throw TypeError('Expected sequence with length 2');
  6629. entries.push({
  6630. key: first.value + '',
  6631. value: second.value + ''
  6632. });
  6633. }
  6634. } else
  6635. for (key in init)
  6636. if (hasOwn(init, key))
  6637. entries.push({
  6638. key: key,
  6639. value: init[key] + ''
  6640. });
  6641. } else {
  6642. parseSearchParams(entries, typeof init === 'string' ? init.charAt(0) === '?' ? init.slice(1) : init : init + '');
  6643. }
  6644. }
  6645. };
  6646. var URLSearchParamsPrototype = URLSearchParamsConstructor.prototype;
  6647. redefineAll(URLSearchParamsPrototype, {
  6648. append: function append(name, value) {
  6649. validateArgumentsLength(arguments.length, 2);
  6650. var state = getInternalParamsState(this);
  6651. state.entries.push({
  6652. key: name + '',
  6653. value: value + ''
  6654. });
  6655. state.updateURL();
  6656. },
  6657. 'delete': function (name) {
  6658. validateArgumentsLength(arguments.length, 1);
  6659. var state = getInternalParamsState(this);
  6660. var entries = state.entries;
  6661. var key = name + '';
  6662. var index = 0;
  6663. while (index < entries.length) {
  6664. if (entries[index].key === key)
  6665. entries.splice(index, 1);
  6666. else
  6667. index++;
  6668. }
  6669. state.updateURL();
  6670. },
  6671. get: function get(name) {
  6672. validateArgumentsLength(arguments.length, 1);
  6673. var entries = getInternalParamsState(this).entries;
  6674. var key = name + '';
  6675. var index = 0;
  6676. for (; index < entries.length; index++) {
  6677. if (entries[index].key === key)
  6678. return entries[index].value;
  6679. }
  6680. return null;
  6681. },
  6682. getAll: function getAll(name) {
  6683. validateArgumentsLength(arguments.length, 1);
  6684. var entries = getInternalParamsState(this).entries;
  6685. var key = name + '';
  6686. var result = [];
  6687. var index = 0;
  6688. for (; index < entries.length; index++) {
  6689. if (entries[index].key === key)
  6690. result.push(entries[index].value);
  6691. }
  6692. return result;
  6693. },
  6694. has: function has(name) {
  6695. validateArgumentsLength(arguments.length, 1);
  6696. var entries = getInternalParamsState(this).entries;
  6697. var key = name + '';
  6698. var index = 0;
  6699. while (index < entries.length) {
  6700. if (entries[index++].key === key)
  6701. return true;
  6702. }
  6703. return false;
  6704. },
  6705. set: function set(name, value) {
  6706. validateArgumentsLength(arguments.length, 1);
  6707. var state = getInternalParamsState(this);
  6708. var entries = state.entries;
  6709. var found = false;
  6710. var key = name + '';
  6711. var val = value + '';
  6712. var index = 0;
  6713. var entry;
  6714. for (; index < entries.length; index++) {
  6715. entry = entries[index];
  6716. if (entry.key === key) {
  6717. if (found)
  6718. entries.splice(index--, 1);
  6719. else {
  6720. found = true;
  6721. entry.value = val;
  6722. }
  6723. }
  6724. }
  6725. if (!found)
  6726. entries.push({
  6727. key: key,
  6728. value: val
  6729. });
  6730. state.updateURL();
  6731. },
  6732. sort: function sort() {
  6733. var state = getInternalParamsState(this);
  6734. var entries = state.entries;
  6735. var slice = entries.slice();
  6736. var entry, entriesIndex, sliceIndex;
  6737. entries.length = 0;
  6738. for (sliceIndex = 0; sliceIndex < slice.length; sliceIndex++) {
  6739. entry = slice[sliceIndex];
  6740. for (entriesIndex = 0; entriesIndex < sliceIndex; entriesIndex++) {
  6741. if (entries[entriesIndex].key > entry.key) {
  6742. entries.splice(entriesIndex, 0, entry);
  6743. break;
  6744. }
  6745. }
  6746. if (entriesIndex === sliceIndex)
  6747. entries.push(entry);
  6748. }
  6749. state.updateURL();
  6750. },
  6751. forEach: function forEach(callback) {
  6752. var entries = getInternalParamsState(this).entries;
  6753. var boundFunction = bind(callback, arguments.length > 1 ? arguments[1] : undefined, 3);
  6754. var index = 0;
  6755. var entry;
  6756. while (index < entries.length) {
  6757. entry = entries[index++];
  6758. boundFunction(entry.value, entry.key, this);
  6759. }
  6760. },
  6761. keys: function keys() {
  6762. return new URLSearchParamsIterator(this, 'keys');
  6763. },
  6764. values: function values() {
  6765. return new URLSearchParamsIterator(this, 'values');
  6766. },
  6767. entries: function entries() {
  6768. return new URLSearchParamsIterator(this, 'entries');
  6769. }
  6770. }, { enumerable: true });
  6771. redefine(URLSearchParamsPrototype, ITERATOR, URLSearchParamsPrototype.entries);
  6772. redefine(URLSearchParamsPrototype, 'toString', function toString() {
  6773. var entries = getInternalParamsState(this).entries;
  6774. var result = [];
  6775. var index = 0;
  6776. var entry;
  6777. while (index < entries.length) {
  6778. entry = entries[index++];
  6779. result.push(serialize(entry.key) + '=' + serialize(entry.value));
  6780. }
  6781. return result.join('&');
  6782. }, { enumerable: true });
  6783. setToStringTag(URLSearchParamsConstructor, URL_SEARCH_PARAMS);
  6784. $({
  6785. global: true,
  6786. forced: !USE_NATIVE_URL
  6787. }, { URLSearchParams: URLSearchParamsConstructor });
  6788. if (!USE_NATIVE_URL && typeof $fetch == 'function' && typeof Headers == 'function') {
  6789. $({
  6790. global: true,
  6791. enumerable: true,
  6792. forced: true
  6793. }, {
  6794. fetch: function fetch(input) {
  6795. var args = [input];
  6796. var init, body, headers;
  6797. if (arguments.length > 1) {
  6798. init = arguments[1];
  6799. if (isObject(init)) {
  6800. body = init.body;
  6801. if (classof(body) === URL_SEARCH_PARAMS) {
  6802. headers = init.headers ? new Headers(init.headers) : new Headers();
  6803. if (!headers.has('content-type')) {
  6804. headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
  6805. }
  6806. init = create(init, {
  6807. body: createPropertyDescriptor(0, String(body)),
  6808. headers: createPropertyDescriptor(0, headers)
  6809. });
  6810. }
  6811. }
  6812. args.push(init);
  6813. }
  6814. return $fetch.apply(this, args);
  6815. }
  6816. });
  6817. }
  6818. module.exports = {
  6819. URLSearchParams: URLSearchParamsConstructor,
  6820. getState: getInternalParamsState
  6821. };
  6822. /***/ }),
  6823. /* 143 */
  6824. /***/ (function(module, exports, __w_pdfjs_require__) {
  6825. var anObject = __w_pdfjs_require__(28);
  6826. var getIteratorMethod = __w_pdfjs_require__(94);
  6827. module.exports = function (it) {
  6828. var iteratorMethod = getIteratorMethod(it);
  6829. if (typeof iteratorMethod != 'function') {
  6830. throw TypeError(String(it) + ' is not iterable');
  6831. }
  6832. return anObject(iteratorMethod.call(it));
  6833. };
  6834. /***/ }),
  6835. /* 144 */
  6836. /***/ (function(module, exports, __w_pdfjs_require__) {
  6837. "use strict";
  6838. var $ = __w_pdfjs_require__(10);
  6839. $({
  6840. target: 'URL',
  6841. proto: true,
  6842. enumerable: true
  6843. }, {
  6844. toJSON: function toJSON() {
  6845. return URL.prototype.toString.call(this);
  6846. }
  6847. });
  6848. /***/ }),
  6849. /* 145 */
  6850. /***/ (function(module, exports, __w_pdfjs_require__) {
  6851. (function (global, factory) {
  6852. true ? factory(exports) : undefined;
  6853. }(this, function (exports) {
  6854. 'use strict';
  6855. var SymbolPolyfill = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol : function (description) {
  6856. return "Symbol(" + description + ")";
  6857. };
  6858. function noop() {
  6859. }
  6860. var NumberIsNaN = Number.isNaN || function (x) {
  6861. return x !== x;
  6862. };
  6863. var rethrowAssertionErrorRejection = noop;
  6864. function typeIsObject(x) {
  6865. return typeof x === 'object' && x !== null || typeof x === 'function';
  6866. }
  6867. function createArrayFromList(elements) {
  6868. return elements.slice();
  6869. }
  6870. function ArrayBufferCopy(dest, destOffset, src, srcOffset, n) {
  6871. new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
  6872. }
  6873. function IsFiniteNonNegativeNumber(v) {
  6874. if (IsNonNegativeNumber(v) === false) {
  6875. return false;
  6876. }
  6877. if (v === Infinity) {
  6878. return false;
  6879. }
  6880. return true;
  6881. }
  6882. function IsNonNegativeNumber(v) {
  6883. if (typeof v !== 'number') {
  6884. return false;
  6885. }
  6886. if (NumberIsNaN(v)) {
  6887. return false;
  6888. }
  6889. if (v < 0) {
  6890. return false;
  6891. }
  6892. return true;
  6893. }
  6894. function Call(F, V, args) {
  6895. if (typeof F !== 'function') {
  6896. throw new TypeError('Argument is not a function');
  6897. }
  6898. return Function.prototype.apply.call(F, V, args);
  6899. }
  6900. function CreateAlgorithmFromUnderlyingMethod(underlyingObject, methodName, algoArgCount, extraArgs) {
  6901. var method = underlyingObject[methodName];
  6902. if (method !== undefined) {
  6903. if (typeof method !== 'function') {
  6904. throw new TypeError(method + " is not a method");
  6905. }
  6906. switch (algoArgCount) {
  6907. case 0: {
  6908. return function () {
  6909. return PromiseCall(method, underlyingObject, extraArgs);
  6910. };
  6911. }
  6912. case 1: {
  6913. return function (arg) {
  6914. var fullArgs = [arg].concat(extraArgs);
  6915. return PromiseCall(method, underlyingObject, fullArgs);
  6916. };
  6917. }
  6918. }
  6919. }
  6920. return function () {
  6921. return promiseResolvedWith(undefined);
  6922. };
  6923. }
  6924. function InvokeOrNoop(O, P, args) {
  6925. var method = O[P];
  6926. if (method === undefined) {
  6927. return undefined;
  6928. }
  6929. return Call(method, O, args);
  6930. }
  6931. function PromiseCall(F, V, args) {
  6932. try {
  6933. return promiseResolvedWith(Call(F, V, args));
  6934. } catch (value) {
  6935. return promiseRejectedWith(value);
  6936. }
  6937. }
  6938. function TransferArrayBuffer(O) {
  6939. return O;
  6940. }
  6941. function IsDetachedBuffer(O) {
  6942. return false;
  6943. }
  6944. function ValidateAndNormalizeHighWaterMark(highWaterMark) {
  6945. highWaterMark = Number(highWaterMark);
  6946. if (NumberIsNaN(highWaterMark) || highWaterMark < 0) {
  6947. throw new RangeError('highWaterMark property of a queuing strategy must be non-negative and non-NaN');
  6948. }
  6949. return highWaterMark;
  6950. }
  6951. function MakeSizeAlgorithmFromSizeFunction(size) {
  6952. if (size === undefined) {
  6953. return function () {
  6954. return 1;
  6955. };
  6956. }
  6957. if (typeof size !== 'function') {
  6958. throw new TypeError('size property of a queuing strategy must be a function');
  6959. }
  6960. return function (chunk) {
  6961. return size(chunk);
  6962. };
  6963. }
  6964. var originalPromise = Promise;
  6965. var originalPromiseThen = Promise.prototype.then;
  6966. var originalPromiseResolve = Promise.resolve.bind(originalPromise);
  6967. var originalPromiseReject = Promise.reject.bind(originalPromise);
  6968. function newPromise(executor) {
  6969. return new originalPromise(executor);
  6970. }
  6971. function promiseResolvedWith(value) {
  6972. return originalPromiseResolve(value);
  6973. }
  6974. function promiseRejectedWith(reason) {
  6975. return originalPromiseReject(reason);
  6976. }
  6977. function PerformPromiseThen(promise, onFulfilled, onRejected) {
  6978. return originalPromiseThen.call(promise, onFulfilled, onRejected);
  6979. }
  6980. function uponPromise(promise, onFulfilled, onRejected) {
  6981. PerformPromiseThen(PerformPromiseThen(promise, onFulfilled, onRejected), undefined, rethrowAssertionErrorRejection);
  6982. }
  6983. function uponFulfillment(promise, onFulfilled) {
  6984. uponPromise(promise, onFulfilled);
  6985. }
  6986. function uponRejection(promise, onRejected) {
  6987. uponPromise(promise, undefined, onRejected);
  6988. }
  6989. function transformPromiseWith(promise, fulfillmentHandler, rejectionHandler) {
  6990. return PerformPromiseThen(promise, fulfillmentHandler, rejectionHandler);
  6991. }
  6992. function setPromiseIsHandledToTrue(promise) {
  6993. PerformPromiseThen(promise, undefined, rethrowAssertionErrorRejection);
  6994. }
  6995. var QUEUE_MAX_ARRAY_SIZE = 16384;
  6996. var SimpleQueue = function () {
  6997. function SimpleQueue() {
  6998. this._cursor = 0;
  6999. this._size = 0;
  7000. this._front = {
  7001. _elements: [],
  7002. _next: undefined
  7003. };
  7004. this._back = this._front;
  7005. this._cursor = 0;
  7006. this._size = 0;
  7007. }
  7008. Object.defineProperty(SimpleQueue.prototype, "length", {
  7009. get: function () {
  7010. return this._size;
  7011. },
  7012. enumerable: true,
  7013. configurable: true
  7014. });
  7015. SimpleQueue.prototype.push = function (element) {
  7016. var oldBack = this._back;
  7017. var newBack = oldBack;
  7018. if (oldBack._elements.length === QUEUE_MAX_ARRAY_SIZE - 1) {
  7019. newBack = {
  7020. _elements: [],
  7021. _next: undefined
  7022. };
  7023. }
  7024. oldBack._elements.push(element);
  7025. if (newBack !== oldBack) {
  7026. this._back = newBack;
  7027. oldBack._next = newBack;
  7028. }
  7029. ++this._size;
  7030. };
  7031. SimpleQueue.prototype.shift = function () {
  7032. var oldFront = this._front;
  7033. var newFront = oldFront;
  7034. var oldCursor = this._cursor;
  7035. var newCursor = oldCursor + 1;
  7036. var elements = oldFront._elements;
  7037. var element = elements[oldCursor];
  7038. if (newCursor === QUEUE_MAX_ARRAY_SIZE) {
  7039. newFront = oldFront._next;
  7040. newCursor = 0;
  7041. }
  7042. --this._size;
  7043. this._cursor = newCursor;
  7044. if (oldFront !== newFront) {
  7045. this._front = newFront;
  7046. }
  7047. elements[oldCursor] = undefined;
  7048. return element;
  7049. };
  7050. SimpleQueue.prototype.forEach = function (callback) {
  7051. var i = this._cursor;
  7052. var node = this._front;
  7053. var elements = node._elements;
  7054. while (i !== elements.length || node._next !== undefined) {
  7055. if (i === elements.length) {
  7056. node = node._next;
  7057. elements = node._elements;
  7058. i = 0;
  7059. if (elements.length === 0) {
  7060. break;
  7061. }
  7062. }
  7063. callback(elements[i]);
  7064. ++i;
  7065. }
  7066. };
  7067. SimpleQueue.prototype.peek = function () {
  7068. var front = this._front;
  7069. var cursor = this._cursor;
  7070. return front._elements[cursor];
  7071. };
  7072. return SimpleQueue;
  7073. }();
  7074. function ReadableStreamCreateReadResult(value, done, forAuthorCode) {
  7075. var prototype = null;
  7076. if (forAuthorCode === true) {
  7077. prototype = Object.prototype;
  7078. }
  7079. var obj = Object.create(prototype);
  7080. obj.value = value;
  7081. obj.done = done;
  7082. return obj;
  7083. }
  7084. function ReadableStreamReaderGenericInitialize(reader, stream) {
  7085. reader._forAuthorCode = true;
  7086. reader._ownerReadableStream = stream;
  7087. stream._reader = reader;
  7088. if (stream._state === 'readable') {
  7089. defaultReaderClosedPromiseInitialize(reader);
  7090. } else if (stream._state === 'closed') {
  7091. defaultReaderClosedPromiseInitializeAsResolved(reader);
  7092. } else {
  7093. defaultReaderClosedPromiseInitializeAsRejected(reader, stream._storedError);
  7094. }
  7095. }
  7096. function ReadableStreamReaderGenericCancel(reader, reason) {
  7097. var stream = reader._ownerReadableStream;
  7098. return ReadableStreamCancel(stream, reason);
  7099. }
  7100. function ReadableStreamReaderGenericRelease(reader) {
  7101. if (reader._ownerReadableStream._state === 'readable') {
  7102. defaultReaderClosedPromiseReject(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));
  7103. } else {
  7104. defaultReaderClosedPromiseResetToRejected(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));
  7105. }
  7106. reader._ownerReadableStream._reader = undefined;
  7107. reader._ownerReadableStream = undefined;
  7108. }
  7109. function readerLockException(name) {
  7110. return new TypeError('Cannot ' + name + ' a stream using a released reader');
  7111. }
  7112. function defaultReaderClosedPromiseInitialize(reader) {
  7113. reader._closedPromise = newPromise(function (resolve, reject) {
  7114. reader._closedPromise_resolve = resolve;
  7115. reader._closedPromise_reject = reject;
  7116. });
  7117. }
  7118. function defaultReaderClosedPromiseInitializeAsRejected(reader, reason) {
  7119. defaultReaderClosedPromiseInitialize(reader);
  7120. defaultReaderClosedPromiseReject(reader, reason);
  7121. }
  7122. function defaultReaderClosedPromiseInitializeAsResolved(reader) {
  7123. defaultReaderClosedPromiseInitialize(reader);
  7124. defaultReaderClosedPromiseResolve(reader);
  7125. }
  7126. function defaultReaderClosedPromiseReject(reader, reason) {
  7127. setPromiseIsHandledToTrue(reader._closedPromise);
  7128. reader._closedPromise_reject(reason);
  7129. reader._closedPromise_resolve = undefined;
  7130. reader._closedPromise_reject = undefined;
  7131. }
  7132. function defaultReaderClosedPromiseResetToRejected(reader, reason) {
  7133. defaultReaderClosedPromiseInitializeAsRejected(reader, reason);
  7134. }
  7135. function defaultReaderClosedPromiseResolve(reader) {
  7136. reader._closedPromise_resolve(undefined);
  7137. reader._closedPromise_resolve = undefined;
  7138. reader._closedPromise_reject = undefined;
  7139. }
  7140. var CancelSteps = SymbolPolyfill('[[CancelSteps]]');
  7141. var PullSteps = SymbolPolyfill('[[PullSteps]]');
  7142. function AcquireReadableStreamDefaultReader(stream, forAuthorCode) {
  7143. if (forAuthorCode === void 0) {
  7144. forAuthorCode = false;
  7145. }
  7146. var reader = new ReadableStreamDefaultReader(stream);
  7147. reader._forAuthorCode = forAuthorCode;
  7148. return reader;
  7149. }
  7150. function ReadableStreamAddReadRequest(stream) {
  7151. var promise = newPromise(function (resolve, reject) {
  7152. var readRequest = {
  7153. _resolve: resolve,
  7154. _reject: reject
  7155. };
  7156. stream._reader._readRequests.push(readRequest);
  7157. });
  7158. return promise;
  7159. }
  7160. function ReadableStreamFulfillReadRequest(stream, chunk, done) {
  7161. var reader = stream._reader;
  7162. var readRequest = reader._readRequests.shift();
  7163. readRequest._resolve(ReadableStreamCreateReadResult(chunk, done, reader._forAuthorCode));
  7164. }
  7165. function ReadableStreamGetNumReadRequests(stream) {
  7166. return stream._reader._readRequests.length;
  7167. }
  7168. function ReadableStreamHasDefaultReader(stream) {
  7169. var reader = stream._reader;
  7170. if (reader === undefined) {
  7171. return false;
  7172. }
  7173. if (!IsReadableStreamDefaultReader(reader)) {
  7174. return false;
  7175. }
  7176. return true;
  7177. }
  7178. var ReadableStreamDefaultReader = function () {
  7179. function ReadableStreamDefaultReader(stream) {
  7180. if (IsReadableStream(stream) === false) {
  7181. throw new TypeError('ReadableStreamDefaultReader can only be constructed with a ReadableStream instance');
  7182. }
  7183. if (IsReadableStreamLocked(stream) === true) {
  7184. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  7185. }
  7186. ReadableStreamReaderGenericInitialize(this, stream);
  7187. this._readRequests = new SimpleQueue();
  7188. }
  7189. Object.defineProperty(ReadableStreamDefaultReader.prototype, "closed", {
  7190. get: function () {
  7191. if (!IsReadableStreamDefaultReader(this)) {
  7192. return promiseRejectedWith(defaultReaderBrandCheckException('closed'));
  7193. }
  7194. return this._closedPromise;
  7195. },
  7196. enumerable: true,
  7197. configurable: true
  7198. });
  7199. ReadableStreamDefaultReader.prototype.cancel = function (reason) {
  7200. if (!IsReadableStreamDefaultReader(this)) {
  7201. return promiseRejectedWith(defaultReaderBrandCheckException('cancel'));
  7202. }
  7203. if (this._ownerReadableStream === undefined) {
  7204. return promiseRejectedWith(readerLockException('cancel'));
  7205. }
  7206. return ReadableStreamReaderGenericCancel(this, reason);
  7207. };
  7208. ReadableStreamDefaultReader.prototype.read = function () {
  7209. if (!IsReadableStreamDefaultReader(this)) {
  7210. return promiseRejectedWith(defaultReaderBrandCheckException('read'));
  7211. }
  7212. if (this._ownerReadableStream === undefined) {
  7213. return promiseRejectedWith(readerLockException('read from'));
  7214. }
  7215. return ReadableStreamDefaultReaderRead(this);
  7216. };
  7217. ReadableStreamDefaultReader.prototype.releaseLock = function () {
  7218. if (!IsReadableStreamDefaultReader(this)) {
  7219. throw defaultReaderBrandCheckException('releaseLock');
  7220. }
  7221. if (this._ownerReadableStream === undefined) {
  7222. return;
  7223. }
  7224. if (this._readRequests.length > 0) {
  7225. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  7226. }
  7227. ReadableStreamReaderGenericRelease(this);
  7228. };
  7229. return ReadableStreamDefaultReader;
  7230. }();
  7231. function IsReadableStreamDefaultReader(x) {
  7232. if (!typeIsObject(x)) {
  7233. return false;
  7234. }
  7235. if (!Object.prototype.hasOwnProperty.call(x, '_readRequests')) {
  7236. return false;
  7237. }
  7238. return true;
  7239. }
  7240. function ReadableStreamDefaultReaderRead(reader) {
  7241. var stream = reader._ownerReadableStream;
  7242. stream._disturbed = true;
  7243. if (stream._state === 'closed') {
  7244. return promiseResolvedWith(ReadableStreamCreateReadResult(undefined, true, reader._forAuthorCode));
  7245. }
  7246. if (stream._state === 'errored') {
  7247. return promiseRejectedWith(stream._storedError);
  7248. }
  7249. return stream._readableStreamController[PullSteps]();
  7250. }
  7251. function defaultReaderBrandCheckException(name) {
  7252. return new TypeError("ReadableStreamDefaultReader.prototype." + name + " can only be used on a ReadableStreamDefaultReader");
  7253. }
  7254. var _a;
  7255. var AsyncIteratorPrototype;
  7256. if (typeof SymbolPolyfill.asyncIterator === 'symbol') {
  7257. AsyncIteratorPrototype = (_a = {}, _a[SymbolPolyfill.asyncIterator] = function () {
  7258. return this;
  7259. }, _a);
  7260. Object.defineProperty(AsyncIteratorPrototype, SymbolPolyfill.asyncIterator, { enumerable: false });
  7261. }
  7262. var ReadableStreamAsyncIteratorPrototype = {
  7263. next: function () {
  7264. if (IsReadableStreamAsyncIterator(this) === false) {
  7265. return promiseRejectedWith(streamAsyncIteratorBrandCheckException('next'));
  7266. }
  7267. var reader = this._asyncIteratorReader;
  7268. if (reader._ownerReadableStream === undefined) {
  7269. return promiseRejectedWith(readerLockException('iterate'));
  7270. }
  7271. return transformPromiseWith(ReadableStreamDefaultReaderRead(reader), function (result) {
  7272. var done = result.done;
  7273. if (done) {
  7274. ReadableStreamReaderGenericRelease(reader);
  7275. }
  7276. var value = result.value;
  7277. return ReadableStreamCreateReadResult(value, done, true);
  7278. });
  7279. },
  7280. return: function (value) {
  7281. if (IsReadableStreamAsyncIterator(this) === false) {
  7282. return promiseRejectedWith(streamAsyncIteratorBrandCheckException('next'));
  7283. }
  7284. var reader = this._asyncIteratorReader;
  7285. if (reader._ownerReadableStream === undefined) {
  7286. return promiseRejectedWith(readerLockException('finish iterating'));
  7287. }
  7288. if (reader._readRequests.length > 0) {
  7289. return promiseRejectedWith(new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled'));
  7290. }
  7291. if (this._preventCancel === false) {
  7292. var result = ReadableStreamReaderGenericCancel(reader, value);
  7293. ReadableStreamReaderGenericRelease(reader);
  7294. return transformPromiseWith(result, function () {
  7295. return ReadableStreamCreateReadResult(value, true, true);
  7296. });
  7297. }
  7298. ReadableStreamReaderGenericRelease(reader);
  7299. return promiseResolvedWith(ReadableStreamCreateReadResult(value, true, true));
  7300. }
  7301. };
  7302. if (AsyncIteratorPrototype !== undefined) {
  7303. Object.setPrototypeOf(ReadableStreamAsyncIteratorPrototype, AsyncIteratorPrototype);
  7304. }
  7305. Object.defineProperty(ReadableStreamAsyncIteratorPrototype, 'next', { enumerable: false });
  7306. Object.defineProperty(ReadableStreamAsyncIteratorPrototype, 'return', { enumerable: false });
  7307. function AcquireReadableStreamAsyncIterator(stream, preventCancel) {
  7308. if (preventCancel === void 0) {
  7309. preventCancel = false;
  7310. }
  7311. var reader = AcquireReadableStreamDefaultReader(stream);
  7312. var iterator = Object.create(ReadableStreamAsyncIteratorPrototype);
  7313. iterator._asyncIteratorReader = reader;
  7314. iterator._preventCancel = Boolean(preventCancel);
  7315. return iterator;
  7316. }
  7317. function IsReadableStreamAsyncIterator(x) {
  7318. if (!typeIsObject(x)) {
  7319. return false;
  7320. }
  7321. if (!Object.prototype.hasOwnProperty.call(x, '_asyncIteratorReader')) {
  7322. return false;
  7323. }
  7324. return true;
  7325. }
  7326. function streamAsyncIteratorBrandCheckException(name) {
  7327. return new TypeError("ReadableStreamAsyncIterator." + name + " can only be used on a ReadableSteamAsyncIterator");
  7328. }
  7329. function DequeueValue(container) {
  7330. var pair = container._queue.shift();
  7331. container._queueTotalSize -= pair.size;
  7332. if (container._queueTotalSize < 0) {
  7333. container._queueTotalSize = 0;
  7334. }
  7335. return pair.value;
  7336. }
  7337. function EnqueueValueWithSize(container, value, size) {
  7338. size = Number(size);
  7339. if (!IsFiniteNonNegativeNumber(size)) {
  7340. throw new RangeError('Size must be a finite, non-NaN, non-negative number.');
  7341. }
  7342. container._queue.push({
  7343. value: value,
  7344. size: size
  7345. });
  7346. container._queueTotalSize += size;
  7347. }
  7348. function PeekQueueValue(container) {
  7349. var pair = container._queue.peek();
  7350. return pair.value;
  7351. }
  7352. function ResetQueue(container) {
  7353. container._queue = new SimpleQueue();
  7354. container._queueTotalSize = 0;
  7355. }
  7356. var AbortSteps = SymbolPolyfill('[[AbortSteps]]');
  7357. var ErrorSteps = SymbolPolyfill('[[ErrorSteps]]');
  7358. var WritableStream = function () {
  7359. function WritableStream(underlyingSink, strategy) {
  7360. if (underlyingSink === void 0) {
  7361. underlyingSink = {};
  7362. }
  7363. if (strategy === void 0) {
  7364. strategy = {};
  7365. }
  7366. InitializeWritableStream(this);
  7367. var size = strategy.size;
  7368. var highWaterMark = strategy.highWaterMark;
  7369. var type = underlyingSink.type;
  7370. if (type !== undefined) {
  7371. throw new RangeError('Invalid type is specified');
  7372. }
  7373. var sizeAlgorithm = MakeSizeAlgorithmFromSizeFunction(size);
  7374. if (highWaterMark === undefined) {
  7375. highWaterMark = 1;
  7376. }
  7377. highWaterMark = ValidateAndNormalizeHighWaterMark(highWaterMark);
  7378. SetUpWritableStreamDefaultControllerFromUnderlyingSink(this, underlyingSink, highWaterMark, sizeAlgorithm);
  7379. }
  7380. Object.defineProperty(WritableStream.prototype, "locked", {
  7381. get: function () {
  7382. if (IsWritableStream(this) === false) {
  7383. throw streamBrandCheckException('locked');
  7384. }
  7385. return IsWritableStreamLocked(this);
  7386. },
  7387. enumerable: true,
  7388. configurable: true
  7389. });
  7390. WritableStream.prototype.abort = function (reason) {
  7391. if (IsWritableStream(this) === false) {
  7392. return promiseRejectedWith(streamBrandCheckException('abort'));
  7393. }
  7394. if (IsWritableStreamLocked(this) === true) {
  7395. return promiseRejectedWith(new TypeError('Cannot abort a stream that already has a writer'));
  7396. }
  7397. return WritableStreamAbort(this, reason);
  7398. };
  7399. WritableStream.prototype.close = function () {
  7400. if (IsWritableStream(this) === false) {
  7401. return promiseRejectedWith(streamBrandCheckException('close'));
  7402. }
  7403. if (IsWritableStreamLocked(this) === true) {
  7404. return promiseRejectedWith(new TypeError('Cannot close a stream that already has a writer'));
  7405. }
  7406. if (WritableStreamCloseQueuedOrInFlight(this) === true) {
  7407. return promiseRejectedWith(new TypeError('Cannot close an already-closing stream'));
  7408. }
  7409. return WritableStreamClose(this);
  7410. };
  7411. WritableStream.prototype.getWriter = function () {
  7412. if (IsWritableStream(this) === false) {
  7413. throw streamBrandCheckException('getWriter');
  7414. }
  7415. return AcquireWritableStreamDefaultWriter(this);
  7416. };
  7417. return WritableStream;
  7418. }();
  7419. function AcquireWritableStreamDefaultWriter(stream) {
  7420. return new WritableStreamDefaultWriter(stream);
  7421. }
  7422. function CreateWritableStream(startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm) {
  7423. if (highWaterMark === void 0) {
  7424. highWaterMark = 1;
  7425. }
  7426. if (sizeAlgorithm === void 0) {
  7427. sizeAlgorithm = function () {
  7428. return 1;
  7429. };
  7430. }
  7431. var stream = Object.create(WritableStream.prototype);
  7432. InitializeWritableStream(stream);
  7433. var controller = Object.create(WritableStreamDefaultController.prototype);
  7434. SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm);
  7435. return stream;
  7436. }
  7437. function InitializeWritableStream(stream) {
  7438. stream._state = 'writable';
  7439. stream._storedError = undefined;
  7440. stream._writer = undefined;
  7441. stream._writableStreamController = undefined;
  7442. stream._writeRequests = new SimpleQueue();
  7443. stream._inFlightWriteRequest = undefined;
  7444. stream._closeRequest = undefined;
  7445. stream._inFlightCloseRequest = undefined;
  7446. stream._pendingAbortRequest = undefined;
  7447. stream._backpressure = false;
  7448. }
  7449. function IsWritableStream(x) {
  7450. if (!typeIsObject(x)) {
  7451. return false;
  7452. }
  7453. if (!Object.prototype.hasOwnProperty.call(x, '_writableStreamController')) {
  7454. return false;
  7455. }
  7456. return true;
  7457. }
  7458. function IsWritableStreamLocked(stream) {
  7459. if (stream._writer === undefined) {
  7460. return false;
  7461. }
  7462. return true;
  7463. }
  7464. function WritableStreamAbort(stream, reason) {
  7465. var state = stream._state;
  7466. if (state === 'closed' || state === 'errored') {
  7467. return promiseResolvedWith(undefined);
  7468. }
  7469. if (stream._pendingAbortRequest !== undefined) {
  7470. return stream._pendingAbortRequest._promise;
  7471. }
  7472. var wasAlreadyErroring = false;
  7473. if (state === 'erroring') {
  7474. wasAlreadyErroring = true;
  7475. reason = undefined;
  7476. }
  7477. var promise = newPromise(function (resolve, reject) {
  7478. stream._pendingAbortRequest = {
  7479. _promise: undefined,
  7480. _resolve: resolve,
  7481. _reject: reject,
  7482. _reason: reason,
  7483. _wasAlreadyErroring: wasAlreadyErroring
  7484. };
  7485. });
  7486. stream._pendingAbortRequest._promise = promise;
  7487. if (wasAlreadyErroring === false) {
  7488. WritableStreamStartErroring(stream, reason);
  7489. }
  7490. return promise;
  7491. }
  7492. function WritableStreamClose(stream) {
  7493. var state = stream._state;
  7494. if (state === 'closed' || state === 'errored') {
  7495. return promiseRejectedWith(new TypeError("The stream (in " + state + " state) is not in the writable state and cannot be closed"));
  7496. }
  7497. var promise = newPromise(function (resolve, reject) {
  7498. var closeRequest = {
  7499. _resolve: resolve,
  7500. _reject: reject
  7501. };
  7502. stream._closeRequest = closeRequest;
  7503. });
  7504. var writer = stream._writer;
  7505. if (writer !== undefined && stream._backpressure === true && state === 'writable') {
  7506. defaultWriterReadyPromiseResolve(writer);
  7507. }
  7508. WritableStreamDefaultControllerClose(stream._writableStreamController);
  7509. return promise;
  7510. }
  7511. function WritableStreamAddWriteRequest(stream) {
  7512. var promise = newPromise(function (resolve, reject) {
  7513. var writeRequest = {
  7514. _resolve: resolve,
  7515. _reject: reject
  7516. };
  7517. stream._writeRequests.push(writeRequest);
  7518. });
  7519. return promise;
  7520. }
  7521. function WritableStreamDealWithRejection(stream, error) {
  7522. var state = stream._state;
  7523. if (state === 'writable') {
  7524. WritableStreamStartErroring(stream, error);
  7525. return;
  7526. }
  7527. WritableStreamFinishErroring(stream);
  7528. }
  7529. function WritableStreamStartErroring(stream, reason) {
  7530. var controller = stream._writableStreamController;
  7531. stream._state = 'erroring';
  7532. stream._storedError = reason;
  7533. var writer = stream._writer;
  7534. if (writer !== undefined) {
  7535. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, reason);
  7536. }
  7537. if (WritableStreamHasOperationMarkedInFlight(stream) === false && controller._started === true) {
  7538. WritableStreamFinishErroring(stream);
  7539. }
  7540. }
  7541. function WritableStreamFinishErroring(stream) {
  7542. stream._state = 'errored';
  7543. stream._writableStreamController[ErrorSteps]();
  7544. var storedError = stream._storedError;
  7545. stream._writeRequests.forEach(function (writeRequest) {
  7546. writeRequest._reject(storedError);
  7547. });
  7548. stream._writeRequests = new SimpleQueue();
  7549. if (stream._pendingAbortRequest === undefined) {
  7550. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  7551. return;
  7552. }
  7553. var abortRequest = stream._pendingAbortRequest;
  7554. stream._pendingAbortRequest = undefined;
  7555. if (abortRequest._wasAlreadyErroring === true) {
  7556. abortRequest._reject(storedError);
  7557. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  7558. return;
  7559. }
  7560. var promise = stream._writableStreamController[AbortSteps](abortRequest._reason);
  7561. uponPromise(promise, function () {
  7562. abortRequest._resolve();
  7563. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  7564. }, function (reason) {
  7565. abortRequest._reject(reason);
  7566. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  7567. });
  7568. }
  7569. function WritableStreamFinishInFlightWrite(stream) {
  7570. stream._inFlightWriteRequest._resolve(undefined);
  7571. stream._inFlightWriteRequest = undefined;
  7572. }
  7573. function WritableStreamFinishInFlightWriteWithError(stream, error) {
  7574. stream._inFlightWriteRequest._reject(error);
  7575. stream._inFlightWriteRequest = undefined;
  7576. WritableStreamDealWithRejection(stream, error);
  7577. }
  7578. function WritableStreamFinishInFlightClose(stream) {
  7579. stream._inFlightCloseRequest._resolve(undefined);
  7580. stream._inFlightCloseRequest = undefined;
  7581. var state = stream._state;
  7582. if (state === 'erroring') {
  7583. stream._storedError = undefined;
  7584. if (stream._pendingAbortRequest !== undefined) {
  7585. stream._pendingAbortRequest._resolve();
  7586. stream._pendingAbortRequest = undefined;
  7587. }
  7588. }
  7589. stream._state = 'closed';
  7590. var writer = stream._writer;
  7591. if (writer !== undefined) {
  7592. defaultWriterClosedPromiseResolve(writer);
  7593. }
  7594. }
  7595. function WritableStreamFinishInFlightCloseWithError(stream, error) {
  7596. stream._inFlightCloseRequest._reject(error);
  7597. stream._inFlightCloseRequest = undefined;
  7598. if (stream._pendingAbortRequest !== undefined) {
  7599. stream._pendingAbortRequest._reject(error);
  7600. stream._pendingAbortRequest = undefined;
  7601. }
  7602. WritableStreamDealWithRejection(stream, error);
  7603. }
  7604. function WritableStreamCloseQueuedOrInFlight(stream) {
  7605. if (stream._closeRequest === undefined && stream._inFlightCloseRequest === undefined) {
  7606. return false;
  7607. }
  7608. return true;
  7609. }
  7610. function WritableStreamHasOperationMarkedInFlight(stream) {
  7611. if (stream._inFlightWriteRequest === undefined && stream._inFlightCloseRequest === undefined) {
  7612. return false;
  7613. }
  7614. return true;
  7615. }
  7616. function WritableStreamMarkCloseRequestInFlight(stream) {
  7617. stream._inFlightCloseRequest = stream._closeRequest;
  7618. stream._closeRequest = undefined;
  7619. }
  7620. function WritableStreamMarkFirstWriteRequestInFlight(stream) {
  7621. stream._inFlightWriteRequest = stream._writeRequests.shift();
  7622. }
  7623. function WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream) {
  7624. if (stream._closeRequest !== undefined) {
  7625. stream._closeRequest._reject(stream._storedError);
  7626. stream._closeRequest = undefined;
  7627. }
  7628. var writer = stream._writer;
  7629. if (writer !== undefined) {
  7630. defaultWriterClosedPromiseReject(writer, stream._storedError);
  7631. }
  7632. }
  7633. function WritableStreamUpdateBackpressure(stream, backpressure) {
  7634. var writer = stream._writer;
  7635. if (writer !== undefined && backpressure !== stream._backpressure) {
  7636. if (backpressure === true) {
  7637. defaultWriterReadyPromiseReset(writer);
  7638. } else {
  7639. defaultWriterReadyPromiseResolve(writer);
  7640. }
  7641. }
  7642. stream._backpressure = backpressure;
  7643. }
  7644. var WritableStreamDefaultWriter = function () {
  7645. function WritableStreamDefaultWriter(stream) {
  7646. if (IsWritableStream(stream) === false) {
  7647. throw new TypeError('WritableStreamDefaultWriter can only be constructed with a WritableStream instance');
  7648. }
  7649. if (IsWritableStreamLocked(stream) === true) {
  7650. throw new TypeError('This stream has already been locked for exclusive writing by another writer');
  7651. }
  7652. this._ownerWritableStream = stream;
  7653. stream._writer = this;
  7654. var state = stream._state;
  7655. if (state === 'writable') {
  7656. if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._backpressure === true) {
  7657. defaultWriterReadyPromiseInitialize(this);
  7658. } else {
  7659. defaultWriterReadyPromiseInitializeAsResolved(this);
  7660. }
  7661. defaultWriterClosedPromiseInitialize(this);
  7662. } else if (state === 'erroring') {
  7663. defaultWriterReadyPromiseInitializeAsRejected(this, stream._storedError);
  7664. defaultWriterClosedPromiseInitialize(this);
  7665. } else if (state === 'closed') {
  7666. defaultWriterReadyPromiseInitializeAsResolved(this);
  7667. defaultWriterClosedPromiseInitializeAsResolved(this);
  7668. } else {
  7669. var storedError = stream._storedError;
  7670. defaultWriterReadyPromiseInitializeAsRejected(this, storedError);
  7671. defaultWriterClosedPromiseInitializeAsRejected(this, storedError);
  7672. }
  7673. }
  7674. Object.defineProperty(WritableStreamDefaultWriter.prototype, "closed", {
  7675. get: function () {
  7676. if (IsWritableStreamDefaultWriter(this) === false) {
  7677. return promiseRejectedWith(defaultWriterBrandCheckException('closed'));
  7678. }
  7679. return this._closedPromise;
  7680. },
  7681. enumerable: true,
  7682. configurable: true
  7683. });
  7684. Object.defineProperty(WritableStreamDefaultWriter.prototype, "desiredSize", {
  7685. get: function () {
  7686. if (IsWritableStreamDefaultWriter(this) === false) {
  7687. throw defaultWriterBrandCheckException('desiredSize');
  7688. }
  7689. if (this._ownerWritableStream === undefined) {
  7690. throw defaultWriterLockException('desiredSize');
  7691. }
  7692. return WritableStreamDefaultWriterGetDesiredSize(this);
  7693. },
  7694. enumerable: true,
  7695. configurable: true
  7696. });
  7697. Object.defineProperty(WritableStreamDefaultWriter.prototype, "ready", {
  7698. get: function () {
  7699. if (IsWritableStreamDefaultWriter(this) === false) {
  7700. return promiseRejectedWith(defaultWriterBrandCheckException('ready'));
  7701. }
  7702. return this._readyPromise;
  7703. },
  7704. enumerable: true,
  7705. configurable: true
  7706. });
  7707. WritableStreamDefaultWriter.prototype.abort = function (reason) {
  7708. if (IsWritableStreamDefaultWriter(this) === false) {
  7709. return promiseRejectedWith(defaultWriterBrandCheckException('abort'));
  7710. }
  7711. if (this._ownerWritableStream === undefined) {
  7712. return promiseRejectedWith(defaultWriterLockException('abort'));
  7713. }
  7714. return WritableStreamDefaultWriterAbort(this, reason);
  7715. };
  7716. WritableStreamDefaultWriter.prototype.close = function () {
  7717. if (IsWritableStreamDefaultWriter(this) === false) {
  7718. return promiseRejectedWith(defaultWriterBrandCheckException('close'));
  7719. }
  7720. var stream = this._ownerWritableStream;
  7721. if (stream === undefined) {
  7722. return promiseRejectedWith(defaultWriterLockException('close'));
  7723. }
  7724. if (WritableStreamCloseQueuedOrInFlight(stream) === true) {
  7725. return promiseRejectedWith(new TypeError('Cannot close an already-closing stream'));
  7726. }
  7727. return WritableStreamDefaultWriterClose(this);
  7728. };
  7729. WritableStreamDefaultWriter.prototype.releaseLock = function () {
  7730. if (IsWritableStreamDefaultWriter(this) === false) {
  7731. throw defaultWriterBrandCheckException('releaseLock');
  7732. }
  7733. var stream = this._ownerWritableStream;
  7734. if (stream === undefined) {
  7735. return;
  7736. }
  7737. WritableStreamDefaultWriterRelease(this);
  7738. };
  7739. WritableStreamDefaultWriter.prototype.write = function (chunk) {
  7740. if (IsWritableStreamDefaultWriter(this) === false) {
  7741. return promiseRejectedWith(defaultWriterBrandCheckException('write'));
  7742. }
  7743. if (this._ownerWritableStream === undefined) {
  7744. return promiseRejectedWith(defaultWriterLockException('write to'));
  7745. }
  7746. return WritableStreamDefaultWriterWrite(this, chunk);
  7747. };
  7748. return WritableStreamDefaultWriter;
  7749. }();
  7750. function IsWritableStreamDefaultWriter(x) {
  7751. if (!typeIsObject(x)) {
  7752. return false;
  7753. }
  7754. if (!Object.prototype.hasOwnProperty.call(x, '_ownerWritableStream')) {
  7755. return false;
  7756. }
  7757. return true;
  7758. }
  7759. function WritableStreamDefaultWriterAbort(writer, reason) {
  7760. var stream = writer._ownerWritableStream;
  7761. return WritableStreamAbort(stream, reason);
  7762. }
  7763. function WritableStreamDefaultWriterClose(writer) {
  7764. var stream = writer._ownerWritableStream;
  7765. return WritableStreamClose(stream);
  7766. }
  7767. function WritableStreamDefaultWriterCloseWithErrorPropagation(writer) {
  7768. var stream = writer._ownerWritableStream;
  7769. var state = stream._state;
  7770. if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') {
  7771. return promiseResolvedWith(undefined);
  7772. }
  7773. if (state === 'errored') {
  7774. return promiseRejectedWith(stream._storedError);
  7775. }
  7776. return WritableStreamDefaultWriterClose(writer);
  7777. }
  7778. function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error) {
  7779. if (writer._closedPromiseState === 'pending') {
  7780. defaultWriterClosedPromiseReject(writer, error);
  7781. } else {
  7782. defaultWriterClosedPromiseResetToRejected(writer, error);
  7783. }
  7784. }
  7785. function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error) {
  7786. if (writer._readyPromiseState === 'pending') {
  7787. defaultWriterReadyPromiseReject(writer, error);
  7788. } else {
  7789. defaultWriterReadyPromiseResetToRejected(writer, error);
  7790. }
  7791. }
  7792. function WritableStreamDefaultWriterGetDesiredSize(writer) {
  7793. var stream = writer._ownerWritableStream;
  7794. var state = stream._state;
  7795. if (state === 'errored' || state === 'erroring') {
  7796. return null;
  7797. }
  7798. if (state === 'closed') {
  7799. return 0;
  7800. }
  7801. return WritableStreamDefaultControllerGetDesiredSize(stream._writableStreamController);
  7802. }
  7803. function WritableStreamDefaultWriterRelease(writer) {
  7804. var stream = writer._ownerWritableStream;
  7805. var releasedError = new TypeError('Writer was released and can no longer be used to monitor the stream\'s closedness');
  7806. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, releasedError);
  7807. WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, releasedError);
  7808. stream._writer = undefined;
  7809. writer._ownerWritableStream = undefined;
  7810. }
  7811. function WritableStreamDefaultWriterWrite(writer, chunk) {
  7812. var stream = writer._ownerWritableStream;
  7813. var controller = stream._writableStreamController;
  7814. var chunkSize = WritableStreamDefaultControllerGetChunkSize(controller, chunk);
  7815. if (stream !== writer._ownerWritableStream) {
  7816. return promiseRejectedWith(defaultWriterLockException('write to'));
  7817. }
  7818. var state = stream._state;
  7819. if (state === 'errored') {
  7820. return promiseRejectedWith(stream._storedError);
  7821. }
  7822. if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') {
  7823. return promiseRejectedWith(new TypeError('The stream is closing or closed and cannot be written to'));
  7824. }
  7825. if (state === 'erroring') {
  7826. return promiseRejectedWith(stream._storedError);
  7827. }
  7828. var promise = WritableStreamAddWriteRequest(stream);
  7829. WritableStreamDefaultControllerWrite(controller, chunk, chunkSize);
  7830. return promise;
  7831. }
  7832. var WritableStreamDefaultController = function () {
  7833. function WritableStreamDefaultController() {
  7834. throw new TypeError('WritableStreamDefaultController cannot be constructed explicitly');
  7835. }
  7836. WritableStreamDefaultController.prototype.error = function (e) {
  7837. if (IsWritableStreamDefaultController(this) === false) {
  7838. throw new TypeError('WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController');
  7839. }
  7840. var state = this._controlledWritableStream._state;
  7841. if (state !== 'writable') {
  7842. return;
  7843. }
  7844. WritableStreamDefaultControllerError(this, e);
  7845. };
  7846. WritableStreamDefaultController.prototype[AbortSteps] = function (reason) {
  7847. var result = this._abortAlgorithm(reason);
  7848. WritableStreamDefaultControllerClearAlgorithms(this);
  7849. return result;
  7850. };
  7851. WritableStreamDefaultController.prototype[ErrorSteps] = function () {
  7852. ResetQueue(this);
  7853. };
  7854. return WritableStreamDefaultController;
  7855. }();
  7856. function IsWritableStreamDefaultController(x) {
  7857. if (!typeIsObject(x)) {
  7858. return false;
  7859. }
  7860. if (!Object.prototype.hasOwnProperty.call(x, '_controlledWritableStream')) {
  7861. return false;
  7862. }
  7863. return true;
  7864. }
  7865. function SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm) {
  7866. controller._controlledWritableStream = stream;
  7867. stream._writableStreamController = controller;
  7868. controller._queue = undefined;
  7869. controller._queueTotalSize = undefined;
  7870. ResetQueue(controller);
  7871. controller._started = false;
  7872. controller._strategySizeAlgorithm = sizeAlgorithm;
  7873. controller._strategyHWM = highWaterMark;
  7874. controller._writeAlgorithm = writeAlgorithm;
  7875. controller._closeAlgorithm = closeAlgorithm;
  7876. controller._abortAlgorithm = abortAlgorithm;
  7877. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  7878. WritableStreamUpdateBackpressure(stream, backpressure);
  7879. var startResult = startAlgorithm();
  7880. var startPromise = promiseResolvedWith(startResult);
  7881. uponPromise(startPromise, function () {
  7882. controller._started = true;
  7883. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  7884. }, function (r) {
  7885. controller._started = true;
  7886. WritableStreamDealWithRejection(stream, r);
  7887. });
  7888. }
  7889. function SetUpWritableStreamDefaultControllerFromUnderlyingSink(stream, underlyingSink, highWaterMark, sizeAlgorithm) {
  7890. var controller = Object.create(WritableStreamDefaultController.prototype);
  7891. function startAlgorithm() {
  7892. return InvokeOrNoop(underlyingSink, 'start', [controller]);
  7893. }
  7894. var writeAlgorithm = CreateAlgorithmFromUnderlyingMethod(underlyingSink, 'write', 1, [controller]);
  7895. var closeAlgorithm = CreateAlgorithmFromUnderlyingMethod(underlyingSink, 'close', 0, []);
  7896. var abortAlgorithm = CreateAlgorithmFromUnderlyingMethod(underlyingSink, 'abort', 1, []);
  7897. SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm);
  7898. }
  7899. function WritableStreamDefaultControllerClearAlgorithms(controller) {
  7900. controller._writeAlgorithm = undefined;
  7901. controller._closeAlgorithm = undefined;
  7902. controller._abortAlgorithm = undefined;
  7903. controller._strategySizeAlgorithm = undefined;
  7904. }
  7905. function WritableStreamDefaultControllerClose(controller) {
  7906. EnqueueValueWithSize(controller, 'close', 0);
  7907. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  7908. }
  7909. function WritableStreamDefaultControllerGetChunkSize(controller, chunk) {
  7910. try {
  7911. return controller._strategySizeAlgorithm(chunk);
  7912. } catch (chunkSizeE) {
  7913. WritableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE);
  7914. return 1;
  7915. }
  7916. }
  7917. function WritableStreamDefaultControllerGetDesiredSize(controller) {
  7918. return controller._strategyHWM - controller._queueTotalSize;
  7919. }
  7920. function WritableStreamDefaultControllerWrite(controller, chunk, chunkSize) {
  7921. var writeRecord = { chunk: chunk };
  7922. try {
  7923. EnqueueValueWithSize(controller, writeRecord, chunkSize);
  7924. } catch (enqueueE) {
  7925. WritableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);
  7926. return;
  7927. }
  7928. var stream = controller._controlledWritableStream;
  7929. if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._state === 'writable') {
  7930. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  7931. WritableStreamUpdateBackpressure(stream, backpressure);
  7932. }
  7933. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  7934. }
  7935. function WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller) {
  7936. var stream = controller._controlledWritableStream;
  7937. if (controller._started === false) {
  7938. return;
  7939. }
  7940. if (stream._inFlightWriteRequest !== undefined) {
  7941. return;
  7942. }
  7943. var state = stream._state;
  7944. if (state === 'erroring') {
  7945. WritableStreamFinishErroring(stream);
  7946. return;
  7947. }
  7948. if (controller._queue.length === 0) {
  7949. return;
  7950. }
  7951. var writeRecord = PeekQueueValue(controller);
  7952. if (writeRecord === 'close') {
  7953. WritableStreamDefaultControllerProcessClose(controller);
  7954. } else {
  7955. WritableStreamDefaultControllerProcessWrite(controller, writeRecord.chunk);
  7956. }
  7957. }
  7958. function WritableStreamDefaultControllerErrorIfNeeded(controller, error) {
  7959. if (controller._controlledWritableStream._state === 'writable') {
  7960. WritableStreamDefaultControllerError(controller, error);
  7961. }
  7962. }
  7963. function WritableStreamDefaultControllerProcessClose(controller) {
  7964. var stream = controller._controlledWritableStream;
  7965. WritableStreamMarkCloseRequestInFlight(stream);
  7966. DequeueValue(controller);
  7967. var sinkClosePromise = controller._closeAlgorithm();
  7968. WritableStreamDefaultControllerClearAlgorithms(controller);
  7969. uponPromise(sinkClosePromise, function () {
  7970. WritableStreamFinishInFlightClose(stream);
  7971. }, function (reason) {
  7972. WritableStreamFinishInFlightCloseWithError(stream, reason);
  7973. });
  7974. }
  7975. function WritableStreamDefaultControllerProcessWrite(controller, chunk) {
  7976. var stream = controller._controlledWritableStream;
  7977. WritableStreamMarkFirstWriteRequestInFlight(stream);
  7978. var sinkWritePromise = controller._writeAlgorithm(chunk);
  7979. uponPromise(sinkWritePromise, function () {
  7980. WritableStreamFinishInFlightWrite(stream);
  7981. var state = stream._state;
  7982. DequeueValue(controller);
  7983. if (WritableStreamCloseQueuedOrInFlight(stream) === false && state === 'writable') {
  7984. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  7985. WritableStreamUpdateBackpressure(stream, backpressure);
  7986. }
  7987. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  7988. }, function (reason) {
  7989. if (stream._state === 'writable') {
  7990. WritableStreamDefaultControllerClearAlgorithms(controller);
  7991. }
  7992. WritableStreamFinishInFlightWriteWithError(stream, reason);
  7993. });
  7994. }
  7995. function WritableStreamDefaultControllerGetBackpressure(controller) {
  7996. var desiredSize = WritableStreamDefaultControllerGetDesiredSize(controller);
  7997. return desiredSize <= 0;
  7998. }
  7999. function WritableStreamDefaultControllerError(controller, error) {
  8000. var stream = controller._controlledWritableStream;
  8001. WritableStreamDefaultControllerClearAlgorithms(controller);
  8002. WritableStreamStartErroring(stream, error);
  8003. }
  8004. function streamBrandCheckException(name) {
  8005. return new TypeError("WritableStream.prototype." + name + " can only be used on a WritableStream");
  8006. }
  8007. function defaultWriterBrandCheckException(name) {
  8008. return new TypeError("WritableStreamDefaultWriter.prototype." + name + " can only be used on a WritableStreamDefaultWriter");
  8009. }
  8010. function defaultWriterLockException(name) {
  8011. return new TypeError('Cannot ' + name + ' a stream using a released writer');
  8012. }
  8013. function defaultWriterClosedPromiseInitialize(writer) {
  8014. writer._closedPromise = newPromise(function (resolve, reject) {
  8015. writer._closedPromise_resolve = resolve;
  8016. writer._closedPromise_reject = reject;
  8017. writer._closedPromiseState = 'pending';
  8018. });
  8019. }
  8020. function defaultWriterClosedPromiseInitializeAsRejected(writer, reason) {
  8021. defaultWriterClosedPromiseInitialize(writer);
  8022. defaultWriterClosedPromiseReject(writer, reason);
  8023. }
  8024. function defaultWriterClosedPromiseInitializeAsResolved(writer) {
  8025. defaultWriterClosedPromiseInitialize(writer);
  8026. defaultWriterClosedPromiseResolve(writer);
  8027. }
  8028. function defaultWriterClosedPromiseReject(writer, reason) {
  8029. setPromiseIsHandledToTrue(writer._closedPromise);
  8030. writer._closedPromise_reject(reason);
  8031. writer._closedPromise_resolve = undefined;
  8032. writer._closedPromise_reject = undefined;
  8033. writer._closedPromiseState = 'rejected';
  8034. }
  8035. function defaultWriterClosedPromiseResetToRejected(writer, reason) {
  8036. defaultWriterClosedPromiseInitializeAsRejected(writer, reason);
  8037. }
  8038. function defaultWriterClosedPromiseResolve(writer) {
  8039. writer._closedPromise_resolve(undefined);
  8040. writer._closedPromise_resolve = undefined;
  8041. writer._closedPromise_reject = undefined;
  8042. writer._closedPromiseState = 'resolved';
  8043. }
  8044. function defaultWriterReadyPromiseInitialize(writer) {
  8045. writer._readyPromise = newPromise(function (resolve, reject) {
  8046. writer._readyPromise_resolve = resolve;
  8047. writer._readyPromise_reject = reject;
  8048. });
  8049. writer._readyPromiseState = 'pending';
  8050. }
  8051. function defaultWriterReadyPromiseInitializeAsRejected(writer, reason) {
  8052. defaultWriterReadyPromiseInitialize(writer);
  8053. defaultWriterReadyPromiseReject(writer, reason);
  8054. }
  8055. function defaultWriterReadyPromiseInitializeAsResolved(writer) {
  8056. defaultWriterReadyPromiseInitialize(writer);
  8057. defaultWriterReadyPromiseResolve(writer);
  8058. }
  8059. function defaultWriterReadyPromiseReject(writer, reason) {
  8060. setPromiseIsHandledToTrue(writer._readyPromise);
  8061. writer._readyPromise_reject(reason);
  8062. writer._readyPromise_resolve = undefined;
  8063. writer._readyPromise_reject = undefined;
  8064. writer._readyPromiseState = 'rejected';
  8065. }
  8066. function defaultWriterReadyPromiseReset(writer) {
  8067. defaultWriterReadyPromiseInitialize(writer);
  8068. }
  8069. function defaultWriterReadyPromiseResetToRejected(writer, reason) {
  8070. defaultWriterReadyPromiseInitializeAsRejected(writer, reason);
  8071. }
  8072. function defaultWriterReadyPromiseResolve(writer) {
  8073. writer._readyPromise_resolve(undefined);
  8074. writer._readyPromise_resolve = undefined;
  8075. writer._readyPromise_reject = undefined;
  8076. writer._readyPromiseState = 'fulfilled';
  8077. }
  8078. function isAbortSignal(value) {
  8079. if (typeof value !== 'object' || value === null) {
  8080. return false;
  8081. }
  8082. try {
  8083. return typeof value.aborted === 'boolean';
  8084. } catch (_a) {
  8085. return false;
  8086. }
  8087. }
  8088. var NativeDOMException = typeof DOMException !== 'undefined' ? DOMException : undefined;
  8089. function isDOMExceptionConstructor(ctor) {
  8090. if (!(typeof ctor === 'function' || typeof ctor === 'object')) {
  8091. return false;
  8092. }
  8093. try {
  8094. new ctor();
  8095. return true;
  8096. } catch (_a) {
  8097. return false;
  8098. }
  8099. }
  8100. function createDOMExceptionPolyfill() {
  8101. var ctor = function DOMException(message, name) {
  8102. this.message = message || '';
  8103. this.name = name || 'Error';
  8104. if (Error.captureStackTrace) {
  8105. Error.captureStackTrace(this, this.constructor);
  8106. }
  8107. };
  8108. ctor.prototype = Object.create(Error.prototype);
  8109. Object.defineProperty(ctor.prototype, 'constructor', {
  8110. value: ctor,
  8111. writable: true,
  8112. configurable: true
  8113. });
  8114. return ctor;
  8115. }
  8116. var DOMException$1 = isDOMExceptionConstructor(NativeDOMException) ? NativeDOMException : createDOMExceptionPolyfill();
  8117. function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventCancel, signal) {
  8118. var reader = AcquireReadableStreamDefaultReader(source);
  8119. var writer = AcquireWritableStreamDefaultWriter(dest);
  8120. source._disturbed = true;
  8121. var shuttingDown = false;
  8122. var currentWrite = promiseResolvedWith(undefined);
  8123. return newPromise(function (resolve, reject) {
  8124. var abortAlgorithm;
  8125. if (signal !== undefined) {
  8126. abortAlgorithm = function () {
  8127. var error = new DOMException$1('Aborted', 'AbortError');
  8128. var actions = [];
  8129. if (preventAbort === false) {
  8130. actions.push(function () {
  8131. if (dest._state === 'writable') {
  8132. return WritableStreamAbort(dest, error);
  8133. }
  8134. return promiseResolvedWith(undefined);
  8135. });
  8136. }
  8137. if (preventCancel === false) {
  8138. actions.push(function () {
  8139. if (source._state === 'readable') {
  8140. return ReadableStreamCancel(source, error);
  8141. }
  8142. return promiseResolvedWith(undefined);
  8143. });
  8144. }
  8145. shutdownWithAction(function () {
  8146. return Promise.all(actions.map(function (action) {
  8147. return action();
  8148. }));
  8149. }, true, error);
  8150. };
  8151. if (signal.aborted === true) {
  8152. abortAlgorithm();
  8153. return;
  8154. }
  8155. signal.addEventListener('abort', abortAlgorithm);
  8156. }
  8157. function pipeLoop() {
  8158. return newPromise(function (resolveLoop, rejectLoop) {
  8159. function next(done) {
  8160. if (done) {
  8161. resolveLoop();
  8162. } else {
  8163. PerformPromiseThen(pipeStep(), next, rejectLoop);
  8164. }
  8165. }
  8166. next(false);
  8167. });
  8168. }
  8169. function pipeStep() {
  8170. if (shuttingDown === true) {
  8171. return promiseResolvedWith(true);
  8172. }
  8173. return PerformPromiseThen(writer._readyPromise, function () {
  8174. return PerformPromiseThen(ReadableStreamDefaultReaderRead(reader), function (result) {
  8175. if (result.done === true) {
  8176. return true;
  8177. }
  8178. currentWrite = PerformPromiseThen(WritableStreamDefaultWriterWrite(writer, result.value), undefined, noop);
  8179. return false;
  8180. });
  8181. });
  8182. }
  8183. isOrBecomesErrored(source, reader._closedPromise, function (storedError) {
  8184. if (preventAbort === false) {
  8185. shutdownWithAction(function () {
  8186. return WritableStreamAbort(dest, storedError);
  8187. }, true, storedError);
  8188. } else {
  8189. shutdown(true, storedError);
  8190. }
  8191. });
  8192. isOrBecomesErrored(dest, writer._closedPromise, function (storedError) {
  8193. if (preventCancel === false) {
  8194. shutdownWithAction(function () {
  8195. return ReadableStreamCancel(source, storedError);
  8196. }, true, storedError);
  8197. } else {
  8198. shutdown(true, storedError);
  8199. }
  8200. });
  8201. isOrBecomesClosed(source, reader._closedPromise, function () {
  8202. if (preventClose === false) {
  8203. shutdownWithAction(function () {
  8204. return WritableStreamDefaultWriterCloseWithErrorPropagation(writer);
  8205. });
  8206. } else {
  8207. shutdown();
  8208. }
  8209. });
  8210. if (WritableStreamCloseQueuedOrInFlight(dest) === true || dest._state === 'closed') {
  8211. var destClosed_1 = new TypeError('the destination writable stream closed before all data could be piped to it');
  8212. if (preventCancel === false) {
  8213. shutdownWithAction(function () {
  8214. return ReadableStreamCancel(source, destClosed_1);
  8215. }, true, destClosed_1);
  8216. } else {
  8217. shutdown(true, destClosed_1);
  8218. }
  8219. }
  8220. setPromiseIsHandledToTrue(pipeLoop());
  8221. function waitForWritesToFinish() {
  8222. var oldCurrentWrite = currentWrite;
  8223. return PerformPromiseThen(currentWrite, function () {
  8224. return oldCurrentWrite !== currentWrite ? waitForWritesToFinish() : undefined;
  8225. });
  8226. }
  8227. function isOrBecomesErrored(stream, promise, action) {
  8228. if (stream._state === 'errored') {
  8229. action(stream._storedError);
  8230. } else {
  8231. uponRejection(promise, action);
  8232. }
  8233. }
  8234. function isOrBecomesClosed(stream, promise, action) {
  8235. if (stream._state === 'closed') {
  8236. action();
  8237. } else {
  8238. uponFulfillment(promise, action);
  8239. }
  8240. }
  8241. function shutdownWithAction(action, originalIsError, originalError) {
  8242. if (shuttingDown === true) {
  8243. return;
  8244. }
  8245. shuttingDown = true;
  8246. if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
  8247. uponFulfillment(waitForWritesToFinish(), doTheRest);
  8248. } else {
  8249. doTheRest();
  8250. }
  8251. function doTheRest() {
  8252. uponPromise(action(), function () {
  8253. return finalize(originalIsError, originalError);
  8254. }, function (newError) {
  8255. return finalize(true, newError);
  8256. });
  8257. }
  8258. }
  8259. function shutdown(isError, error) {
  8260. if (shuttingDown === true) {
  8261. return;
  8262. }
  8263. shuttingDown = true;
  8264. if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
  8265. uponFulfillment(waitForWritesToFinish(), function () {
  8266. return finalize(isError, error);
  8267. });
  8268. } else {
  8269. finalize(isError, error);
  8270. }
  8271. }
  8272. function finalize(isError, error) {
  8273. WritableStreamDefaultWriterRelease(writer);
  8274. ReadableStreamReaderGenericRelease(reader);
  8275. if (signal !== undefined) {
  8276. signal.removeEventListener('abort', abortAlgorithm);
  8277. }
  8278. if (isError) {
  8279. reject(error);
  8280. } else {
  8281. resolve(undefined);
  8282. }
  8283. }
  8284. });
  8285. }
  8286. var ReadableStreamDefaultController = function () {
  8287. function ReadableStreamDefaultController() {
  8288. throw new TypeError();
  8289. }
  8290. Object.defineProperty(ReadableStreamDefaultController.prototype, "desiredSize", {
  8291. get: function () {
  8292. if (IsReadableStreamDefaultController(this) === false) {
  8293. throw defaultControllerBrandCheckException('desiredSize');
  8294. }
  8295. return ReadableStreamDefaultControllerGetDesiredSize(this);
  8296. },
  8297. enumerable: true,
  8298. configurable: true
  8299. });
  8300. ReadableStreamDefaultController.prototype.close = function () {
  8301. if (IsReadableStreamDefaultController(this) === false) {
  8302. throw defaultControllerBrandCheckException('close');
  8303. }
  8304. if (ReadableStreamDefaultControllerCanCloseOrEnqueue(this) === false) {
  8305. throw new TypeError('The stream is not in a state that permits close');
  8306. }
  8307. ReadableStreamDefaultControllerClose(this);
  8308. };
  8309. ReadableStreamDefaultController.prototype.enqueue = function (chunk) {
  8310. if (IsReadableStreamDefaultController(this) === false) {
  8311. throw defaultControllerBrandCheckException('enqueue');
  8312. }
  8313. if (ReadableStreamDefaultControllerCanCloseOrEnqueue(this) === false) {
  8314. throw new TypeError('The stream is not in a state that permits enqueue');
  8315. }
  8316. return ReadableStreamDefaultControllerEnqueue(this, chunk);
  8317. };
  8318. ReadableStreamDefaultController.prototype.error = function (e) {
  8319. if (IsReadableStreamDefaultController(this) === false) {
  8320. throw defaultControllerBrandCheckException('error');
  8321. }
  8322. ReadableStreamDefaultControllerError(this, e);
  8323. };
  8324. ReadableStreamDefaultController.prototype[CancelSteps] = function (reason) {
  8325. ResetQueue(this);
  8326. var result = this._cancelAlgorithm(reason);
  8327. ReadableStreamDefaultControllerClearAlgorithms(this);
  8328. return result;
  8329. };
  8330. ReadableStreamDefaultController.prototype[PullSteps] = function () {
  8331. var stream = this._controlledReadableStream;
  8332. if (this._queue.length > 0) {
  8333. var chunk = DequeueValue(this);
  8334. if (this._closeRequested === true && this._queue.length === 0) {
  8335. ReadableStreamDefaultControllerClearAlgorithms(this);
  8336. ReadableStreamClose(stream);
  8337. } else {
  8338. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  8339. }
  8340. return promiseResolvedWith(ReadableStreamCreateReadResult(chunk, false, stream._reader._forAuthorCode));
  8341. }
  8342. var pendingPromise = ReadableStreamAddReadRequest(stream);
  8343. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  8344. return pendingPromise;
  8345. };
  8346. return ReadableStreamDefaultController;
  8347. }();
  8348. function IsReadableStreamDefaultController(x) {
  8349. if (!typeIsObject(x)) {
  8350. return false;
  8351. }
  8352. if (!Object.prototype.hasOwnProperty.call(x, '_controlledReadableStream')) {
  8353. return false;
  8354. }
  8355. return true;
  8356. }
  8357. function ReadableStreamDefaultControllerCallPullIfNeeded(controller) {
  8358. var shouldPull = ReadableStreamDefaultControllerShouldCallPull(controller);
  8359. if (shouldPull === false) {
  8360. return;
  8361. }
  8362. if (controller._pulling === true) {
  8363. controller._pullAgain = true;
  8364. return;
  8365. }
  8366. controller._pulling = true;
  8367. var pullPromise = controller._pullAlgorithm();
  8368. uponPromise(pullPromise, function () {
  8369. controller._pulling = false;
  8370. if (controller._pullAgain === true) {
  8371. controller._pullAgain = false;
  8372. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  8373. }
  8374. }, function (e) {
  8375. ReadableStreamDefaultControllerError(controller, e);
  8376. });
  8377. }
  8378. function ReadableStreamDefaultControllerShouldCallPull(controller) {
  8379. var stream = controller._controlledReadableStream;
  8380. if (ReadableStreamDefaultControllerCanCloseOrEnqueue(controller) === false) {
  8381. return false;
  8382. }
  8383. if (controller._started === false) {
  8384. return false;
  8385. }
  8386. if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  8387. return true;
  8388. }
  8389. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);
  8390. if (desiredSize > 0) {
  8391. return true;
  8392. }
  8393. return false;
  8394. }
  8395. function ReadableStreamDefaultControllerClearAlgorithms(controller) {
  8396. controller._pullAlgorithm = undefined;
  8397. controller._cancelAlgorithm = undefined;
  8398. controller._strategySizeAlgorithm = undefined;
  8399. }
  8400. function ReadableStreamDefaultControllerClose(controller) {
  8401. var stream = controller._controlledReadableStream;
  8402. controller._closeRequested = true;
  8403. if (controller._queue.length === 0) {
  8404. ReadableStreamDefaultControllerClearAlgorithms(controller);
  8405. ReadableStreamClose(stream);
  8406. }
  8407. }
  8408. function ReadableStreamDefaultControllerEnqueue(controller, chunk) {
  8409. var stream = controller._controlledReadableStream;
  8410. if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  8411. ReadableStreamFulfillReadRequest(stream, chunk, false);
  8412. } else {
  8413. var chunkSize = void 0;
  8414. try {
  8415. chunkSize = controller._strategySizeAlgorithm(chunk);
  8416. } catch (chunkSizeE) {
  8417. ReadableStreamDefaultControllerError(controller, chunkSizeE);
  8418. throw chunkSizeE;
  8419. }
  8420. try {
  8421. EnqueueValueWithSize(controller, chunk, chunkSize);
  8422. } catch (enqueueE) {
  8423. ReadableStreamDefaultControllerError(controller, enqueueE);
  8424. throw enqueueE;
  8425. }
  8426. }
  8427. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  8428. }
  8429. function ReadableStreamDefaultControllerError(controller, e) {
  8430. var stream = controller._controlledReadableStream;
  8431. if (stream._state !== 'readable') {
  8432. return;
  8433. }
  8434. ResetQueue(controller);
  8435. ReadableStreamDefaultControllerClearAlgorithms(controller);
  8436. ReadableStreamError(stream, e);
  8437. }
  8438. function ReadableStreamDefaultControllerGetDesiredSize(controller) {
  8439. var stream = controller._controlledReadableStream;
  8440. var state = stream._state;
  8441. if (state === 'errored') {
  8442. return null;
  8443. }
  8444. if (state === 'closed') {
  8445. return 0;
  8446. }
  8447. return controller._strategyHWM - controller._queueTotalSize;
  8448. }
  8449. function ReadableStreamDefaultControllerHasBackpressure(controller) {
  8450. if (ReadableStreamDefaultControllerShouldCallPull(controller) === true) {
  8451. return false;
  8452. }
  8453. return true;
  8454. }
  8455. function ReadableStreamDefaultControllerCanCloseOrEnqueue(controller) {
  8456. var state = controller._controlledReadableStream._state;
  8457. if (controller._closeRequested === false && state === 'readable') {
  8458. return true;
  8459. }
  8460. return false;
  8461. }
  8462. function SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm) {
  8463. controller._controlledReadableStream = stream;
  8464. controller._queue = undefined;
  8465. controller._queueTotalSize = undefined;
  8466. ResetQueue(controller);
  8467. controller._started = false;
  8468. controller._closeRequested = false;
  8469. controller._pullAgain = false;
  8470. controller._pulling = false;
  8471. controller._strategySizeAlgorithm = sizeAlgorithm;
  8472. controller._strategyHWM = highWaterMark;
  8473. controller._pullAlgorithm = pullAlgorithm;
  8474. controller._cancelAlgorithm = cancelAlgorithm;
  8475. stream._readableStreamController = controller;
  8476. var startResult = startAlgorithm();
  8477. uponPromise(promiseResolvedWith(startResult), function () {
  8478. controller._started = true;
  8479. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  8480. }, function (r) {
  8481. ReadableStreamDefaultControllerError(controller, r);
  8482. });
  8483. }
  8484. function SetUpReadableStreamDefaultControllerFromUnderlyingSource(stream, underlyingSource, highWaterMark, sizeAlgorithm) {
  8485. var controller = Object.create(ReadableStreamDefaultController.prototype);
  8486. function startAlgorithm() {
  8487. return InvokeOrNoop(underlyingSource, 'start', [controller]);
  8488. }
  8489. var pullAlgorithm = CreateAlgorithmFromUnderlyingMethod(underlyingSource, 'pull', 0, [controller]);
  8490. var cancelAlgorithm = CreateAlgorithmFromUnderlyingMethod(underlyingSource, 'cancel', 1, []);
  8491. SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
  8492. }
  8493. function defaultControllerBrandCheckException(name) {
  8494. return new TypeError("ReadableStreamDefaultController.prototype." + name + " can only be used on a ReadableStreamDefaultController");
  8495. }
  8496. function ReadableStreamTee(stream, cloneForBranch2) {
  8497. var reader = AcquireReadableStreamDefaultReader(stream);
  8498. var reading = false;
  8499. var canceled1 = false;
  8500. var canceled2 = false;
  8501. var reason1;
  8502. var reason2;
  8503. var branch1;
  8504. var branch2;
  8505. var resolveCancelPromise;
  8506. var cancelPromise = newPromise(function (resolve) {
  8507. resolveCancelPromise = resolve;
  8508. });
  8509. function pullAlgorithm() {
  8510. if (reading === true) {
  8511. return promiseResolvedWith(undefined);
  8512. }
  8513. reading = true;
  8514. var readPromise = transformPromiseWith(ReadableStreamDefaultReaderRead(reader), function (result) {
  8515. reading = false;
  8516. var done = result.done;
  8517. if (done === true) {
  8518. if (canceled1 === false) {
  8519. ReadableStreamDefaultControllerClose(branch1._readableStreamController);
  8520. }
  8521. if (canceled2 === false) {
  8522. ReadableStreamDefaultControllerClose(branch2._readableStreamController);
  8523. }
  8524. return;
  8525. }
  8526. var value = result.value;
  8527. var value1 = value;
  8528. var value2 = value;
  8529. if (canceled1 === false) {
  8530. ReadableStreamDefaultControllerEnqueue(branch1._readableStreamController, value1);
  8531. }
  8532. if (canceled2 === false) {
  8533. ReadableStreamDefaultControllerEnqueue(branch2._readableStreamController, value2);
  8534. }
  8535. });
  8536. setPromiseIsHandledToTrue(readPromise);
  8537. return promiseResolvedWith(undefined);
  8538. }
  8539. function cancel1Algorithm(reason) {
  8540. canceled1 = true;
  8541. reason1 = reason;
  8542. if (canceled2 === true) {
  8543. var compositeReason = createArrayFromList([
  8544. reason1,
  8545. reason2
  8546. ]);
  8547. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  8548. resolveCancelPromise(cancelResult);
  8549. }
  8550. return cancelPromise;
  8551. }
  8552. function cancel2Algorithm(reason) {
  8553. canceled2 = true;
  8554. reason2 = reason;
  8555. if (canceled1 === true) {
  8556. var compositeReason = createArrayFromList([
  8557. reason1,
  8558. reason2
  8559. ]);
  8560. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  8561. resolveCancelPromise(cancelResult);
  8562. }
  8563. return cancelPromise;
  8564. }
  8565. function startAlgorithm() {
  8566. }
  8567. branch1 = CreateReadableStream(startAlgorithm, pullAlgorithm, cancel1Algorithm);
  8568. branch2 = CreateReadableStream(startAlgorithm, pullAlgorithm, cancel2Algorithm);
  8569. uponRejection(reader._closedPromise, function (r) {
  8570. ReadableStreamDefaultControllerError(branch1._readableStreamController, r);
  8571. ReadableStreamDefaultControllerError(branch2._readableStreamController, r);
  8572. });
  8573. return [
  8574. branch1,
  8575. branch2
  8576. ];
  8577. }
  8578. var NumberIsInteger = Number.isInteger || function (value) {
  8579. return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
  8580. };
  8581. var ReadableStreamBYOBRequest = function () {
  8582. function ReadableStreamBYOBRequest() {
  8583. throw new TypeError('ReadableStreamBYOBRequest cannot be used directly');
  8584. }
  8585. Object.defineProperty(ReadableStreamBYOBRequest.prototype, "view", {
  8586. get: function () {
  8587. if (IsReadableStreamBYOBRequest(this) === false) {
  8588. throw byobRequestBrandCheckException('view');
  8589. }
  8590. return this._view;
  8591. },
  8592. enumerable: true,
  8593. configurable: true
  8594. });
  8595. ReadableStreamBYOBRequest.prototype.respond = function (bytesWritten) {
  8596. if (IsReadableStreamBYOBRequest(this) === false) {
  8597. throw byobRequestBrandCheckException('respond');
  8598. }
  8599. if (this._associatedReadableByteStreamController === undefined) {
  8600. throw new TypeError('This BYOB request has been invalidated');
  8601. }
  8602. if (IsDetachedBuffer(this._view.buffer) === true);
  8603. ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten);
  8604. };
  8605. ReadableStreamBYOBRequest.prototype.respondWithNewView = function (view) {
  8606. if (IsReadableStreamBYOBRequest(this) === false) {
  8607. throw byobRequestBrandCheckException('respond');
  8608. }
  8609. if (this._associatedReadableByteStreamController === undefined) {
  8610. throw new TypeError('This BYOB request has been invalidated');
  8611. }
  8612. if (!ArrayBuffer.isView(view)) {
  8613. throw new TypeError('You can only respond with array buffer views');
  8614. }
  8615. if (IsDetachedBuffer(view.buffer) === true);
  8616. ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
  8617. };
  8618. return ReadableStreamBYOBRequest;
  8619. }();
  8620. var ReadableByteStreamController = function () {
  8621. function ReadableByteStreamController() {
  8622. throw new TypeError('ReadableByteStreamController constructor cannot be used directly');
  8623. }
  8624. Object.defineProperty(ReadableByteStreamController.prototype, "byobRequest", {
  8625. get: function () {
  8626. if (IsReadableByteStreamController(this) === false) {
  8627. throw byteStreamControllerBrandCheckException('byobRequest');
  8628. }
  8629. if (this._byobRequest === undefined && this._pendingPullIntos.length > 0) {
  8630. var firstDescriptor = this._pendingPullIntos.peek();
  8631. var view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled);
  8632. var byobRequest = Object.create(ReadableStreamBYOBRequest.prototype);
  8633. SetUpReadableStreamBYOBRequest(byobRequest, this, view);
  8634. this._byobRequest = byobRequest;
  8635. }
  8636. return this._byobRequest;
  8637. },
  8638. enumerable: true,
  8639. configurable: true
  8640. });
  8641. Object.defineProperty(ReadableByteStreamController.prototype, "desiredSize", {
  8642. get: function () {
  8643. if (IsReadableByteStreamController(this) === false) {
  8644. throw byteStreamControllerBrandCheckException('desiredSize');
  8645. }
  8646. return ReadableByteStreamControllerGetDesiredSize(this);
  8647. },
  8648. enumerable: true,
  8649. configurable: true
  8650. });
  8651. ReadableByteStreamController.prototype.close = function () {
  8652. if (IsReadableByteStreamController(this) === false) {
  8653. throw byteStreamControllerBrandCheckException('close');
  8654. }
  8655. if (this._closeRequested === true) {
  8656. throw new TypeError('The stream has already been closed; do not close it again!');
  8657. }
  8658. var state = this._controlledReadableByteStream._state;
  8659. if (state !== 'readable') {
  8660. throw new TypeError("The stream (in " + state + " state) is not in the readable state and cannot be closed");
  8661. }
  8662. ReadableByteStreamControllerClose(this);
  8663. };
  8664. ReadableByteStreamController.prototype.enqueue = function (chunk) {
  8665. if (IsReadableByteStreamController(this) === false) {
  8666. throw byteStreamControllerBrandCheckException('enqueue');
  8667. }
  8668. if (this._closeRequested === true) {
  8669. throw new TypeError('stream is closed or draining');
  8670. }
  8671. var state = this._controlledReadableByteStream._state;
  8672. if (state !== 'readable') {
  8673. throw new TypeError("The stream (in " + state + " state) is not in the readable state and cannot be enqueued to");
  8674. }
  8675. if (!ArrayBuffer.isView(chunk)) {
  8676. throw new TypeError('You can only enqueue array buffer views when using a ReadableByteStreamController');
  8677. }
  8678. if (IsDetachedBuffer(chunk.buffer) === true);
  8679. ReadableByteStreamControllerEnqueue(this, chunk);
  8680. };
  8681. ReadableByteStreamController.prototype.error = function (e) {
  8682. if (IsReadableByteStreamController(this) === false) {
  8683. throw byteStreamControllerBrandCheckException('error');
  8684. }
  8685. ReadableByteStreamControllerError(this, e);
  8686. };
  8687. ReadableByteStreamController.prototype[CancelSteps] = function (reason) {
  8688. if (this._pendingPullIntos.length > 0) {
  8689. var firstDescriptor = this._pendingPullIntos.peek();
  8690. firstDescriptor.bytesFilled = 0;
  8691. }
  8692. ResetQueue(this);
  8693. var result = this._cancelAlgorithm(reason);
  8694. ReadableByteStreamControllerClearAlgorithms(this);
  8695. return result;
  8696. };
  8697. ReadableByteStreamController.prototype[PullSteps] = function () {
  8698. var stream = this._controlledReadableByteStream;
  8699. if (this._queueTotalSize > 0) {
  8700. var entry = this._queue.shift();
  8701. this._queueTotalSize -= entry.byteLength;
  8702. ReadableByteStreamControllerHandleQueueDrain(this);
  8703. var view = void 0;
  8704. try {
  8705. view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
  8706. } catch (viewE) {
  8707. return promiseRejectedWith(viewE);
  8708. }
  8709. return promiseResolvedWith(ReadableStreamCreateReadResult(view, false, stream._reader._forAuthorCode));
  8710. }
  8711. var autoAllocateChunkSize = this._autoAllocateChunkSize;
  8712. if (autoAllocateChunkSize !== undefined) {
  8713. var buffer = void 0;
  8714. try {
  8715. buffer = new ArrayBuffer(autoAllocateChunkSize);
  8716. } catch (bufferE) {
  8717. return promiseRejectedWith(bufferE);
  8718. }
  8719. var pullIntoDescriptor = {
  8720. buffer: buffer,
  8721. byteOffset: 0,
  8722. byteLength: autoAllocateChunkSize,
  8723. bytesFilled: 0,
  8724. elementSize: 1,
  8725. ctor: Uint8Array,
  8726. readerType: 'default'
  8727. };
  8728. this._pendingPullIntos.push(pullIntoDescriptor);
  8729. }
  8730. var promise = ReadableStreamAddReadRequest(stream);
  8731. ReadableByteStreamControllerCallPullIfNeeded(this);
  8732. return promise;
  8733. };
  8734. return ReadableByteStreamController;
  8735. }();
  8736. function IsReadableByteStreamController(x) {
  8737. if (!typeIsObject(x)) {
  8738. return false;
  8739. }
  8740. if (!Object.prototype.hasOwnProperty.call(x, '_controlledReadableByteStream')) {
  8741. return false;
  8742. }
  8743. return true;
  8744. }
  8745. function IsReadableStreamBYOBRequest(x) {
  8746. if (!typeIsObject(x)) {
  8747. return false;
  8748. }
  8749. if (!Object.prototype.hasOwnProperty.call(x, '_associatedReadableByteStreamController')) {
  8750. return false;
  8751. }
  8752. return true;
  8753. }
  8754. function ReadableByteStreamControllerCallPullIfNeeded(controller) {
  8755. var shouldPull = ReadableByteStreamControllerShouldCallPull(controller);
  8756. if (shouldPull === false) {
  8757. return;
  8758. }
  8759. if (controller._pulling === true) {
  8760. controller._pullAgain = true;
  8761. return;
  8762. }
  8763. controller._pulling = true;
  8764. var pullPromise = controller._pullAlgorithm();
  8765. uponPromise(pullPromise, function () {
  8766. controller._pulling = false;
  8767. if (controller._pullAgain === true) {
  8768. controller._pullAgain = false;
  8769. ReadableByteStreamControllerCallPullIfNeeded(controller);
  8770. }
  8771. }, function (e) {
  8772. ReadableByteStreamControllerError(controller, e);
  8773. });
  8774. }
  8775. function ReadableByteStreamControllerClearPendingPullIntos(controller) {
  8776. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  8777. controller._pendingPullIntos = new SimpleQueue();
  8778. }
  8779. function ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor) {
  8780. var done = false;
  8781. if (stream._state === 'closed') {
  8782. done = true;
  8783. }
  8784. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  8785. if (pullIntoDescriptor.readerType === 'default') {
  8786. ReadableStreamFulfillReadRequest(stream, filledView, done);
  8787. } else {
  8788. ReadableStreamFulfillReadIntoRequest(stream, filledView, done);
  8789. }
  8790. }
  8791. function ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor) {
  8792. var bytesFilled = pullIntoDescriptor.bytesFilled;
  8793. var elementSize = pullIntoDescriptor.elementSize;
  8794. return new pullIntoDescriptor.ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, bytesFilled / elementSize);
  8795. }
  8796. function ReadableByteStreamControllerEnqueueChunkToQueue(controller, buffer, byteOffset, byteLength) {
  8797. controller._queue.push({
  8798. buffer: buffer,
  8799. byteOffset: byteOffset,
  8800. byteLength: byteLength
  8801. });
  8802. controller._queueTotalSize += byteLength;
  8803. }
  8804. function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) {
  8805. var elementSize = pullIntoDescriptor.elementSize;
  8806. var currentAlignedBytes = pullIntoDescriptor.bytesFilled - pullIntoDescriptor.bytesFilled % elementSize;
  8807. var maxBytesToCopy = Math.min(controller._queueTotalSize, pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled);
  8808. var maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;
  8809. var maxAlignedBytes = maxBytesFilled - maxBytesFilled % elementSize;
  8810. var totalBytesToCopyRemaining = maxBytesToCopy;
  8811. var ready = false;
  8812. if (maxAlignedBytes > currentAlignedBytes) {
  8813. totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;
  8814. ready = true;
  8815. }
  8816. var queue = controller._queue;
  8817. while (totalBytesToCopyRemaining > 0) {
  8818. var headOfQueue = queue.peek();
  8819. var bytesToCopy = Math.min(totalBytesToCopyRemaining, headOfQueue.byteLength);
  8820. var destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  8821. ArrayBufferCopy(pullIntoDescriptor.buffer, destStart, headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy);
  8822. if (headOfQueue.byteLength === bytesToCopy) {
  8823. queue.shift();
  8824. } else {
  8825. headOfQueue.byteOffset += bytesToCopy;
  8826. headOfQueue.byteLength -= bytesToCopy;
  8827. }
  8828. controller._queueTotalSize -= bytesToCopy;
  8829. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesToCopy, pullIntoDescriptor);
  8830. totalBytesToCopyRemaining -= bytesToCopy;
  8831. }
  8832. return ready;
  8833. }
  8834. function ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, size, pullIntoDescriptor) {
  8835. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  8836. pullIntoDescriptor.bytesFilled += size;
  8837. }
  8838. function ReadableByteStreamControllerHandleQueueDrain(controller) {
  8839. if (controller._queueTotalSize === 0 && controller._closeRequested === true) {
  8840. ReadableByteStreamControllerClearAlgorithms(controller);
  8841. ReadableStreamClose(controller._controlledReadableByteStream);
  8842. } else {
  8843. ReadableByteStreamControllerCallPullIfNeeded(controller);
  8844. }
  8845. }
  8846. function ReadableByteStreamControllerInvalidateBYOBRequest(controller) {
  8847. if (controller._byobRequest === undefined) {
  8848. return;
  8849. }
  8850. controller._byobRequest._associatedReadableByteStreamController = undefined;
  8851. controller._byobRequest._view = undefined;
  8852. controller._byobRequest = undefined;
  8853. }
  8854. function ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller) {
  8855. while (controller._pendingPullIntos.length > 0) {
  8856. if (controller._queueTotalSize === 0) {
  8857. return;
  8858. }
  8859. var pullIntoDescriptor = controller._pendingPullIntos.peek();
  8860. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {
  8861. ReadableByteStreamControllerShiftPendingPullInto(controller);
  8862. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableByteStream, pullIntoDescriptor);
  8863. }
  8864. }
  8865. }
  8866. function ReadableByteStreamControllerPullInto(controller, view) {
  8867. var stream = controller._controlledReadableByteStream;
  8868. var elementSize = 1;
  8869. if (view.constructor !== DataView) {
  8870. elementSize = view.constructor.BYTES_PER_ELEMENT;
  8871. }
  8872. var ctor = view.constructor;
  8873. var buffer = TransferArrayBuffer(view.buffer);
  8874. var pullIntoDescriptor = {
  8875. buffer: buffer,
  8876. byteOffset: view.byteOffset,
  8877. byteLength: view.byteLength,
  8878. bytesFilled: 0,
  8879. elementSize: elementSize,
  8880. ctor: ctor,
  8881. readerType: 'byob'
  8882. };
  8883. if (controller._pendingPullIntos.length > 0) {
  8884. controller._pendingPullIntos.push(pullIntoDescriptor);
  8885. return ReadableStreamAddReadIntoRequest(stream);
  8886. }
  8887. if (stream._state === 'closed') {
  8888. var emptyView = new ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);
  8889. return promiseResolvedWith(ReadableStreamCreateReadResult(emptyView, true, stream._reader._forAuthorCode));
  8890. }
  8891. if (controller._queueTotalSize > 0) {
  8892. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {
  8893. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  8894. ReadableByteStreamControllerHandleQueueDrain(controller);
  8895. return promiseResolvedWith(ReadableStreamCreateReadResult(filledView, false, stream._reader._forAuthorCode));
  8896. }
  8897. if (controller._closeRequested === true) {
  8898. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  8899. ReadableByteStreamControllerError(controller, e);
  8900. return promiseRejectedWith(e);
  8901. }
  8902. }
  8903. controller._pendingPullIntos.push(pullIntoDescriptor);
  8904. var promise = ReadableStreamAddReadIntoRequest(stream);
  8905. ReadableByteStreamControllerCallPullIfNeeded(controller);
  8906. return promise;
  8907. }
  8908. function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
  8909. firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer);
  8910. var stream = controller._controlledReadableByteStream;
  8911. if (ReadableStreamHasBYOBReader(stream) === true) {
  8912. while (ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  8913. var pullIntoDescriptor = ReadableByteStreamControllerShiftPendingPullInto(controller);
  8914. ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor);
  8915. }
  8916. }
  8917. }
  8918. function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {
  8919. if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength) {
  8920. throw new RangeError('bytesWritten out of range');
  8921. }
  8922. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor);
  8923. if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) {
  8924. return;
  8925. }
  8926. ReadableByteStreamControllerShiftPendingPullInto(controller);
  8927. var remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
  8928. if (remainderSize > 0) {
  8929. var end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  8930. var remainder = pullIntoDescriptor.buffer.slice(end - remainderSize, end);
  8931. ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength);
  8932. }
  8933. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  8934. pullIntoDescriptor.bytesFilled -= remainderSize;
  8935. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableByteStream, pullIntoDescriptor);
  8936. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  8937. }
  8938. function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) {
  8939. var firstDescriptor = controller._pendingPullIntos.peek();
  8940. var stream = controller._controlledReadableByteStream;
  8941. if (stream._state === 'closed') {
  8942. if (bytesWritten !== 0) {
  8943. throw new TypeError('bytesWritten must be 0 when calling respond() on a closed stream');
  8944. }
  8945. ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
  8946. } else {
  8947. ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
  8948. }
  8949. ReadableByteStreamControllerCallPullIfNeeded(controller);
  8950. }
  8951. function ReadableByteStreamControllerShiftPendingPullInto(controller) {
  8952. var descriptor = controller._pendingPullIntos.shift();
  8953. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  8954. return descriptor;
  8955. }
  8956. function ReadableByteStreamControllerShouldCallPull(controller) {
  8957. var stream = controller._controlledReadableByteStream;
  8958. if (stream._state !== 'readable') {
  8959. return false;
  8960. }
  8961. if (controller._closeRequested === true) {
  8962. return false;
  8963. }
  8964. if (controller._started === false) {
  8965. return false;
  8966. }
  8967. if (ReadableStreamHasDefaultReader(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  8968. return true;
  8969. }
  8970. if (ReadableStreamHasBYOBReader(stream) === true && ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  8971. return true;
  8972. }
  8973. var desiredSize = ReadableByteStreamControllerGetDesiredSize(controller);
  8974. if (desiredSize > 0) {
  8975. return true;
  8976. }
  8977. return false;
  8978. }
  8979. function ReadableByteStreamControllerClearAlgorithms(controller) {
  8980. controller._pullAlgorithm = undefined;
  8981. controller._cancelAlgorithm = undefined;
  8982. }
  8983. function ReadableByteStreamControllerClose(controller) {
  8984. var stream = controller._controlledReadableByteStream;
  8985. if (controller._queueTotalSize > 0) {
  8986. controller._closeRequested = true;
  8987. return;
  8988. }
  8989. if (controller._pendingPullIntos.length > 0) {
  8990. var firstPendingPullInto = controller._pendingPullIntos.peek();
  8991. if (firstPendingPullInto.bytesFilled > 0) {
  8992. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  8993. ReadableByteStreamControllerError(controller, e);
  8994. throw e;
  8995. }
  8996. }
  8997. ReadableByteStreamControllerClearAlgorithms(controller);
  8998. ReadableStreamClose(stream);
  8999. }
  9000. function ReadableByteStreamControllerEnqueue(controller, chunk) {
  9001. var stream = controller._controlledReadableByteStream;
  9002. var buffer = chunk.buffer;
  9003. var byteOffset = chunk.byteOffset;
  9004. var byteLength = chunk.byteLength;
  9005. var transferredBuffer = TransferArrayBuffer(buffer);
  9006. if (ReadableStreamHasDefaultReader(stream) === true) {
  9007. if (ReadableStreamGetNumReadRequests(stream) === 0) {
  9008. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  9009. } else {
  9010. var transferredView = new Uint8Array(transferredBuffer, byteOffset, byteLength);
  9011. ReadableStreamFulfillReadRequest(stream, transferredView, false);
  9012. }
  9013. } else if (ReadableStreamHasBYOBReader(stream) === true) {
  9014. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  9015. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  9016. } else {
  9017. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  9018. }
  9019. ReadableByteStreamControllerCallPullIfNeeded(controller);
  9020. }
  9021. function ReadableByteStreamControllerError(controller, e) {
  9022. var stream = controller._controlledReadableByteStream;
  9023. if (stream._state !== 'readable') {
  9024. return;
  9025. }
  9026. ReadableByteStreamControllerClearPendingPullIntos(controller);
  9027. ResetQueue(controller);
  9028. ReadableByteStreamControllerClearAlgorithms(controller);
  9029. ReadableStreamError(stream, e);
  9030. }
  9031. function ReadableByteStreamControllerGetDesiredSize(controller) {
  9032. var stream = controller._controlledReadableByteStream;
  9033. var state = stream._state;
  9034. if (state === 'errored') {
  9035. return null;
  9036. }
  9037. if (state === 'closed') {
  9038. return 0;
  9039. }
  9040. return controller._strategyHWM - controller._queueTotalSize;
  9041. }
  9042. function ReadableByteStreamControllerRespond(controller, bytesWritten) {
  9043. bytesWritten = Number(bytesWritten);
  9044. if (IsFiniteNonNegativeNumber(bytesWritten) === false) {
  9045. throw new RangeError('bytesWritten must be a finite');
  9046. }
  9047. ReadableByteStreamControllerRespondInternal(controller, bytesWritten);
  9048. }
  9049. function ReadableByteStreamControllerRespondWithNewView(controller, view) {
  9050. var firstDescriptor = controller._pendingPullIntos.peek();
  9051. if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset) {
  9052. throw new RangeError('The region specified by view does not match byobRequest');
  9053. }
  9054. if (firstDescriptor.byteLength !== view.byteLength) {
  9055. throw new RangeError('The buffer of view has different capacity than byobRequest');
  9056. }
  9057. firstDescriptor.buffer = view.buffer;
  9058. ReadableByteStreamControllerRespondInternal(controller, view.byteLength);
  9059. }
  9060. function SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize) {
  9061. controller._controlledReadableByteStream = stream;
  9062. controller._pullAgain = false;
  9063. controller._pulling = false;
  9064. controller._byobRequest = undefined;
  9065. controller._queue = controller._queueTotalSize = undefined;
  9066. ResetQueue(controller);
  9067. controller._closeRequested = false;
  9068. controller._started = false;
  9069. controller._strategyHWM = ValidateAndNormalizeHighWaterMark(highWaterMark);
  9070. controller._pullAlgorithm = pullAlgorithm;
  9071. controller._cancelAlgorithm = cancelAlgorithm;
  9072. controller._autoAllocateChunkSize = autoAllocateChunkSize;
  9073. controller._pendingPullIntos = new SimpleQueue();
  9074. stream._readableStreamController = controller;
  9075. var startResult = startAlgorithm();
  9076. uponPromise(promiseResolvedWith(startResult), function () {
  9077. controller._started = true;
  9078. ReadableByteStreamControllerCallPullIfNeeded(controller);
  9079. }, function (r) {
  9080. ReadableByteStreamControllerError(controller, r);
  9081. });
  9082. }
  9083. function SetUpReadableByteStreamControllerFromUnderlyingSource(stream, underlyingByteSource, highWaterMark) {
  9084. var controller = Object.create(ReadableByteStreamController.prototype);
  9085. function startAlgorithm() {
  9086. return InvokeOrNoop(underlyingByteSource, 'start', [controller]);
  9087. }
  9088. var pullAlgorithm = CreateAlgorithmFromUnderlyingMethod(underlyingByteSource, 'pull', 0, [controller]);
  9089. var cancelAlgorithm = CreateAlgorithmFromUnderlyingMethod(underlyingByteSource, 'cancel', 1, []);
  9090. var autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
  9091. if (autoAllocateChunkSize !== undefined) {
  9092. autoAllocateChunkSize = Number(autoAllocateChunkSize);
  9093. if (NumberIsInteger(autoAllocateChunkSize) === false || autoAllocateChunkSize <= 0) {
  9094. throw new RangeError('autoAllocateChunkSize must be a positive integer');
  9095. }
  9096. }
  9097. SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize);
  9098. }
  9099. function SetUpReadableStreamBYOBRequest(request, controller, view) {
  9100. request._associatedReadableByteStreamController = controller;
  9101. request._view = view;
  9102. }
  9103. function byobRequestBrandCheckException(name) {
  9104. return new TypeError("ReadableStreamBYOBRequest.prototype." + name + " can only be used on a ReadableStreamBYOBRequest");
  9105. }
  9106. function byteStreamControllerBrandCheckException(name) {
  9107. return new TypeError("ReadableByteStreamController.prototype." + name + " can only be used on a ReadableByteStreamController");
  9108. }
  9109. function AcquireReadableStreamBYOBReader(stream, forAuthorCode) {
  9110. if (forAuthorCode === void 0) {
  9111. forAuthorCode = false;
  9112. }
  9113. var reader = new ReadableStreamBYOBReader(stream);
  9114. reader._forAuthorCode = forAuthorCode;
  9115. return reader;
  9116. }
  9117. function ReadableStreamAddReadIntoRequest(stream) {
  9118. var promise = newPromise(function (resolve, reject) {
  9119. var readIntoRequest = {
  9120. _resolve: resolve,
  9121. _reject: reject
  9122. };
  9123. stream._reader._readIntoRequests.push(readIntoRequest);
  9124. });
  9125. return promise;
  9126. }
  9127. function ReadableStreamFulfillReadIntoRequest(stream, chunk, done) {
  9128. var reader = stream._reader;
  9129. var readIntoRequest = reader._readIntoRequests.shift();
  9130. readIntoRequest._resolve(ReadableStreamCreateReadResult(chunk, done, reader._forAuthorCode));
  9131. }
  9132. function ReadableStreamGetNumReadIntoRequests(stream) {
  9133. return stream._reader._readIntoRequests.length;
  9134. }
  9135. function ReadableStreamHasBYOBReader(stream) {
  9136. var reader = stream._reader;
  9137. if (reader === undefined) {
  9138. return false;
  9139. }
  9140. if (!IsReadableStreamBYOBReader(reader)) {
  9141. return false;
  9142. }
  9143. return true;
  9144. }
  9145. var ReadableStreamBYOBReader = function () {
  9146. function ReadableStreamBYOBReader(stream) {
  9147. if (!IsReadableStream(stream)) {
  9148. throw new TypeError('ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a ' + 'byte source');
  9149. }
  9150. if (IsReadableByteStreamController(stream._readableStreamController) === false) {
  9151. throw new TypeError('Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte ' + 'source');
  9152. }
  9153. if (IsReadableStreamLocked(stream)) {
  9154. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  9155. }
  9156. ReadableStreamReaderGenericInitialize(this, stream);
  9157. this._readIntoRequests = new SimpleQueue();
  9158. }
  9159. Object.defineProperty(ReadableStreamBYOBReader.prototype, "closed", {
  9160. get: function () {
  9161. if (!IsReadableStreamBYOBReader(this)) {
  9162. return promiseRejectedWith(byobReaderBrandCheckException('closed'));
  9163. }
  9164. return this._closedPromise;
  9165. },
  9166. enumerable: true,
  9167. configurable: true
  9168. });
  9169. ReadableStreamBYOBReader.prototype.cancel = function (reason) {
  9170. if (!IsReadableStreamBYOBReader(this)) {
  9171. return promiseRejectedWith(byobReaderBrandCheckException('cancel'));
  9172. }
  9173. if (this._ownerReadableStream === undefined) {
  9174. return promiseRejectedWith(readerLockException('cancel'));
  9175. }
  9176. return ReadableStreamReaderGenericCancel(this, reason);
  9177. };
  9178. ReadableStreamBYOBReader.prototype.read = function (view) {
  9179. if (!IsReadableStreamBYOBReader(this)) {
  9180. return promiseRejectedWith(byobReaderBrandCheckException('read'));
  9181. }
  9182. if (this._ownerReadableStream === undefined) {
  9183. return promiseRejectedWith(readerLockException('read from'));
  9184. }
  9185. if (!ArrayBuffer.isView(view)) {
  9186. return promiseRejectedWith(new TypeError('view must be an array buffer view'));
  9187. }
  9188. if (IsDetachedBuffer(view.buffer) === true);
  9189. if (view.byteLength === 0) {
  9190. return promiseRejectedWith(new TypeError('view must have non-zero byteLength'));
  9191. }
  9192. return ReadableStreamBYOBReaderRead(this, view);
  9193. };
  9194. ReadableStreamBYOBReader.prototype.releaseLock = function () {
  9195. if (!IsReadableStreamBYOBReader(this)) {
  9196. throw byobReaderBrandCheckException('releaseLock');
  9197. }
  9198. if (this._ownerReadableStream === undefined) {
  9199. return;
  9200. }
  9201. if (this._readIntoRequests.length > 0) {
  9202. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  9203. }
  9204. ReadableStreamReaderGenericRelease(this);
  9205. };
  9206. return ReadableStreamBYOBReader;
  9207. }();
  9208. function IsReadableStreamBYOBReader(x) {
  9209. if (!typeIsObject(x)) {
  9210. return false;
  9211. }
  9212. if (!Object.prototype.hasOwnProperty.call(x, '_readIntoRequests')) {
  9213. return false;
  9214. }
  9215. return true;
  9216. }
  9217. function ReadableStreamBYOBReaderRead(reader, view) {
  9218. var stream = reader._ownerReadableStream;
  9219. stream._disturbed = true;
  9220. if (stream._state === 'errored') {
  9221. return promiseRejectedWith(stream._storedError);
  9222. }
  9223. return ReadableByteStreamControllerPullInto(stream._readableStreamController, view);
  9224. }
  9225. function byobReaderBrandCheckException(name) {
  9226. return new TypeError("ReadableStreamBYOBReader.prototype." + name + " can only be used on a ReadableStreamBYOBReader");
  9227. }
  9228. var ReadableStream = function () {
  9229. function ReadableStream(underlyingSource, strategy) {
  9230. if (underlyingSource === void 0) {
  9231. underlyingSource = {};
  9232. }
  9233. if (strategy === void 0) {
  9234. strategy = {};
  9235. }
  9236. InitializeReadableStream(this);
  9237. var size = strategy.size;
  9238. var highWaterMark = strategy.highWaterMark;
  9239. var type = underlyingSource.type;
  9240. var typeString = String(type);
  9241. if (typeString === 'bytes') {
  9242. if (size !== undefined) {
  9243. throw new RangeError('The strategy for a byte stream cannot have a size function');
  9244. }
  9245. if (highWaterMark === undefined) {
  9246. highWaterMark = 0;
  9247. }
  9248. highWaterMark = ValidateAndNormalizeHighWaterMark(highWaterMark);
  9249. SetUpReadableByteStreamControllerFromUnderlyingSource(this, underlyingSource, highWaterMark);
  9250. } else if (type === undefined) {
  9251. var sizeAlgorithm = MakeSizeAlgorithmFromSizeFunction(size);
  9252. if (highWaterMark === undefined) {
  9253. highWaterMark = 1;
  9254. }
  9255. highWaterMark = ValidateAndNormalizeHighWaterMark(highWaterMark);
  9256. SetUpReadableStreamDefaultControllerFromUnderlyingSource(this, underlyingSource, highWaterMark, sizeAlgorithm);
  9257. } else {
  9258. throw new RangeError('Invalid type is specified');
  9259. }
  9260. }
  9261. Object.defineProperty(ReadableStream.prototype, "locked", {
  9262. get: function () {
  9263. if (IsReadableStream(this) === false) {
  9264. throw streamBrandCheckException$1('locked');
  9265. }
  9266. return IsReadableStreamLocked(this);
  9267. },
  9268. enumerable: true,
  9269. configurable: true
  9270. });
  9271. ReadableStream.prototype.cancel = function (reason) {
  9272. if (IsReadableStream(this) === false) {
  9273. return promiseRejectedWith(streamBrandCheckException$1('cancel'));
  9274. }
  9275. if (IsReadableStreamLocked(this) === true) {
  9276. return promiseRejectedWith(new TypeError('Cannot cancel a stream that already has a reader'));
  9277. }
  9278. return ReadableStreamCancel(this, reason);
  9279. };
  9280. ReadableStream.prototype.getReader = function (_a) {
  9281. var mode = (_a === void 0 ? {} : _a).mode;
  9282. if (IsReadableStream(this) === false) {
  9283. throw streamBrandCheckException$1('getReader');
  9284. }
  9285. if (mode === undefined) {
  9286. return AcquireReadableStreamDefaultReader(this, true);
  9287. }
  9288. mode = String(mode);
  9289. if (mode === 'byob') {
  9290. return AcquireReadableStreamBYOBReader(this, true);
  9291. }
  9292. throw new RangeError('Invalid mode is specified');
  9293. };
  9294. ReadableStream.prototype.pipeThrough = function (_a, _b) {
  9295. var writable = _a.writable, readable = _a.readable;
  9296. var _c = _b === void 0 ? {} : _b, preventClose = _c.preventClose, preventAbort = _c.preventAbort, preventCancel = _c.preventCancel, signal = _c.signal;
  9297. if (IsReadableStream(this) === false) {
  9298. throw streamBrandCheckException$1('pipeThrough');
  9299. }
  9300. if (IsWritableStream(writable) === false) {
  9301. throw new TypeError('writable argument to pipeThrough must be a WritableStream');
  9302. }
  9303. if (IsReadableStream(readable) === false) {
  9304. throw new TypeError('readable argument to pipeThrough must be a ReadableStream');
  9305. }
  9306. preventClose = Boolean(preventClose);
  9307. preventAbort = Boolean(preventAbort);
  9308. preventCancel = Boolean(preventCancel);
  9309. if (signal !== undefined && !isAbortSignal(signal)) {
  9310. throw new TypeError('ReadableStream.prototype.pipeThrough\'s signal option must be an AbortSignal');
  9311. }
  9312. if (IsReadableStreamLocked(this) === true) {
  9313. throw new TypeError('ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream');
  9314. }
  9315. if (IsWritableStreamLocked(writable) === true) {
  9316. throw new TypeError('ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream');
  9317. }
  9318. var promise = ReadableStreamPipeTo(this, writable, preventClose, preventAbort, preventCancel, signal);
  9319. setPromiseIsHandledToTrue(promise);
  9320. return readable;
  9321. };
  9322. ReadableStream.prototype.pipeTo = function (dest, _a) {
  9323. var _b = _a === void 0 ? {} : _a, preventClose = _b.preventClose, preventAbort = _b.preventAbort, preventCancel = _b.preventCancel, signal = _b.signal;
  9324. if (IsReadableStream(this) === false) {
  9325. return promiseRejectedWith(streamBrandCheckException$1('pipeTo'));
  9326. }
  9327. if (IsWritableStream(dest) === false) {
  9328. return promiseRejectedWith(new TypeError('ReadableStream.prototype.pipeTo\'s first argument must be a WritableStream'));
  9329. }
  9330. preventClose = Boolean(preventClose);
  9331. preventAbort = Boolean(preventAbort);
  9332. preventCancel = Boolean(preventCancel);
  9333. if (signal !== undefined && !isAbortSignal(signal)) {
  9334. return promiseRejectedWith(new TypeError('ReadableStream.prototype.pipeTo\'s signal option must be an AbortSignal'));
  9335. }
  9336. if (IsReadableStreamLocked(this) === true) {
  9337. return promiseRejectedWith(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream'));
  9338. }
  9339. if (IsWritableStreamLocked(dest) === true) {
  9340. return promiseRejectedWith(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream'));
  9341. }
  9342. return ReadableStreamPipeTo(this, dest, preventClose, preventAbort, preventCancel, signal);
  9343. };
  9344. ReadableStream.prototype.tee = function () {
  9345. if (IsReadableStream(this) === false) {
  9346. throw streamBrandCheckException$1('tee');
  9347. }
  9348. var branches = ReadableStreamTee(this);
  9349. return createArrayFromList(branches);
  9350. };
  9351. ReadableStream.prototype.getIterator = function (_a) {
  9352. var _b = (_a === void 0 ? {} : _a).preventCancel, preventCancel = _b === void 0 ? false : _b;
  9353. if (IsReadableStream(this) === false) {
  9354. throw streamBrandCheckException$1('getIterator');
  9355. }
  9356. return AcquireReadableStreamAsyncIterator(this, preventCancel);
  9357. };
  9358. return ReadableStream;
  9359. }();
  9360. if (typeof SymbolPolyfill.asyncIterator === 'symbol') {
  9361. Object.defineProperty(ReadableStream.prototype, SymbolPolyfill.asyncIterator, {
  9362. value: ReadableStream.prototype.getIterator,
  9363. enumerable: false,
  9364. writable: true,
  9365. configurable: true
  9366. });
  9367. }
  9368. function CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm) {
  9369. if (highWaterMark === void 0) {
  9370. highWaterMark = 1;
  9371. }
  9372. if (sizeAlgorithm === void 0) {
  9373. sizeAlgorithm = function () {
  9374. return 1;
  9375. };
  9376. }
  9377. var stream = Object.create(ReadableStream.prototype);
  9378. InitializeReadableStream(stream);
  9379. var controller = Object.create(ReadableStreamDefaultController.prototype);
  9380. SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
  9381. return stream;
  9382. }
  9383. function InitializeReadableStream(stream) {
  9384. stream._state = 'readable';
  9385. stream._reader = undefined;
  9386. stream._storedError = undefined;
  9387. stream._disturbed = false;
  9388. }
  9389. function IsReadableStream(x) {
  9390. if (!typeIsObject(x)) {
  9391. return false;
  9392. }
  9393. if (!Object.prototype.hasOwnProperty.call(x, '_readableStreamController')) {
  9394. return false;
  9395. }
  9396. return true;
  9397. }
  9398. function IsReadableStreamLocked(stream) {
  9399. if (stream._reader === undefined) {
  9400. return false;
  9401. }
  9402. return true;
  9403. }
  9404. function ReadableStreamCancel(stream, reason) {
  9405. stream._disturbed = true;
  9406. if (stream._state === 'closed') {
  9407. return promiseResolvedWith(undefined);
  9408. }
  9409. if (stream._state === 'errored') {
  9410. return promiseRejectedWith(stream._storedError);
  9411. }
  9412. ReadableStreamClose(stream);
  9413. var sourceCancelPromise = stream._readableStreamController[CancelSteps](reason);
  9414. return transformPromiseWith(sourceCancelPromise, noop);
  9415. }
  9416. function ReadableStreamClose(stream) {
  9417. stream._state = 'closed';
  9418. var reader = stream._reader;
  9419. if (reader === undefined) {
  9420. return;
  9421. }
  9422. if (IsReadableStreamDefaultReader(reader)) {
  9423. reader._readRequests.forEach(function (readRequest) {
  9424. readRequest._resolve(ReadableStreamCreateReadResult(undefined, true, reader._forAuthorCode));
  9425. });
  9426. reader._readRequests = new SimpleQueue();
  9427. }
  9428. defaultReaderClosedPromiseResolve(reader);
  9429. }
  9430. function ReadableStreamError(stream, e) {
  9431. stream._state = 'errored';
  9432. stream._storedError = e;
  9433. var reader = stream._reader;
  9434. if (reader === undefined) {
  9435. return;
  9436. }
  9437. if (IsReadableStreamDefaultReader(reader)) {
  9438. reader._readRequests.forEach(function (readRequest) {
  9439. readRequest._reject(e);
  9440. });
  9441. reader._readRequests = new SimpleQueue();
  9442. } else {
  9443. reader._readIntoRequests.forEach(function (readIntoRequest) {
  9444. readIntoRequest._reject(e);
  9445. });
  9446. reader._readIntoRequests = new SimpleQueue();
  9447. }
  9448. defaultReaderClosedPromiseReject(reader, e);
  9449. }
  9450. function streamBrandCheckException$1(name) {
  9451. return new TypeError("ReadableStream.prototype." + name + " can only be used on a ReadableStream");
  9452. }
  9453. var ByteLengthQueuingStrategy = function () {
  9454. function ByteLengthQueuingStrategy(_a) {
  9455. var highWaterMark = _a.highWaterMark;
  9456. this.highWaterMark = highWaterMark;
  9457. }
  9458. ByteLengthQueuingStrategy.prototype.size = function (chunk) {
  9459. return chunk.byteLength;
  9460. };
  9461. return ByteLengthQueuingStrategy;
  9462. }();
  9463. var CountQueuingStrategy = function () {
  9464. function CountQueuingStrategy(_a) {
  9465. var highWaterMark = _a.highWaterMark;
  9466. this.highWaterMark = highWaterMark;
  9467. }
  9468. CountQueuingStrategy.prototype.size = function () {
  9469. return 1;
  9470. };
  9471. return CountQueuingStrategy;
  9472. }();
  9473. var TransformStream = function () {
  9474. function TransformStream(transformer, writableStrategy, readableStrategy) {
  9475. if (transformer === void 0) {
  9476. transformer = {};
  9477. }
  9478. if (writableStrategy === void 0) {
  9479. writableStrategy = {};
  9480. }
  9481. if (readableStrategy === void 0) {
  9482. readableStrategy = {};
  9483. }
  9484. var writableSizeFunction = writableStrategy.size;
  9485. var writableHighWaterMark = writableStrategy.highWaterMark;
  9486. var readableSizeFunction = readableStrategy.size;
  9487. var readableHighWaterMark = readableStrategy.highWaterMark;
  9488. var writableType = transformer.writableType;
  9489. if (writableType !== undefined) {
  9490. throw new RangeError('Invalid writable type specified');
  9491. }
  9492. var writableSizeAlgorithm = MakeSizeAlgorithmFromSizeFunction(writableSizeFunction);
  9493. if (writableHighWaterMark === undefined) {
  9494. writableHighWaterMark = 1;
  9495. }
  9496. writableHighWaterMark = ValidateAndNormalizeHighWaterMark(writableHighWaterMark);
  9497. var readableType = transformer.readableType;
  9498. if (readableType !== undefined) {
  9499. throw new RangeError('Invalid readable type specified');
  9500. }
  9501. var readableSizeAlgorithm = MakeSizeAlgorithmFromSizeFunction(readableSizeFunction);
  9502. if (readableHighWaterMark === undefined) {
  9503. readableHighWaterMark = 0;
  9504. }
  9505. readableHighWaterMark = ValidateAndNormalizeHighWaterMark(readableHighWaterMark);
  9506. var startPromise_resolve;
  9507. var startPromise = newPromise(function (resolve) {
  9508. startPromise_resolve = resolve;
  9509. });
  9510. InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
  9511. SetUpTransformStreamDefaultControllerFromTransformer(this, transformer);
  9512. var startResult = InvokeOrNoop(transformer, 'start', [this._transformStreamController]);
  9513. startPromise_resolve(startResult);
  9514. }
  9515. Object.defineProperty(TransformStream.prototype, "readable", {
  9516. get: function () {
  9517. if (IsTransformStream(this) === false) {
  9518. throw streamBrandCheckException$2('readable');
  9519. }
  9520. return this._readable;
  9521. },
  9522. enumerable: true,
  9523. configurable: true
  9524. });
  9525. Object.defineProperty(TransformStream.prototype, "writable", {
  9526. get: function () {
  9527. if (IsTransformStream(this) === false) {
  9528. throw streamBrandCheckException$2('writable');
  9529. }
  9530. return this._writable;
  9531. },
  9532. enumerable: true,
  9533. configurable: true
  9534. });
  9535. return TransformStream;
  9536. }();
  9537. function InitializeTransformStream(stream, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm) {
  9538. function startAlgorithm() {
  9539. return startPromise;
  9540. }
  9541. function writeAlgorithm(chunk) {
  9542. return TransformStreamDefaultSinkWriteAlgorithm(stream, chunk);
  9543. }
  9544. function abortAlgorithm(reason) {
  9545. return TransformStreamDefaultSinkAbortAlgorithm(stream, reason);
  9546. }
  9547. function closeAlgorithm() {
  9548. return TransformStreamDefaultSinkCloseAlgorithm(stream);
  9549. }
  9550. stream._writable = CreateWritableStream(startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, writableHighWaterMark, writableSizeAlgorithm);
  9551. function pullAlgorithm() {
  9552. return TransformStreamDefaultSourcePullAlgorithm(stream);
  9553. }
  9554. function cancelAlgorithm(reason) {
  9555. TransformStreamErrorWritableAndUnblockWrite(stream, reason);
  9556. return promiseResolvedWith(undefined);
  9557. }
  9558. stream._readable = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
  9559. stream._backpressure = undefined;
  9560. stream._backpressureChangePromise = undefined;
  9561. stream._backpressureChangePromise_resolve = undefined;
  9562. TransformStreamSetBackpressure(stream, true);
  9563. stream._transformStreamController = undefined;
  9564. }
  9565. function IsTransformStream(x) {
  9566. if (!typeIsObject(x)) {
  9567. return false;
  9568. }
  9569. if (!Object.prototype.hasOwnProperty.call(x, '_transformStreamController')) {
  9570. return false;
  9571. }
  9572. return true;
  9573. }
  9574. function TransformStreamError(stream, e) {
  9575. ReadableStreamDefaultControllerError(stream._readable._readableStreamController, e);
  9576. TransformStreamErrorWritableAndUnblockWrite(stream, e);
  9577. }
  9578. function TransformStreamErrorWritableAndUnblockWrite(stream, e) {
  9579. TransformStreamDefaultControllerClearAlgorithms(stream._transformStreamController);
  9580. WritableStreamDefaultControllerErrorIfNeeded(stream._writable._writableStreamController, e);
  9581. if (stream._backpressure === true) {
  9582. TransformStreamSetBackpressure(stream, false);
  9583. }
  9584. }
  9585. function TransformStreamSetBackpressure(stream, backpressure) {
  9586. if (stream._backpressureChangePromise !== undefined) {
  9587. stream._backpressureChangePromise_resolve();
  9588. }
  9589. stream._backpressureChangePromise = newPromise(function (resolve) {
  9590. stream._backpressureChangePromise_resolve = resolve;
  9591. });
  9592. stream._backpressure = backpressure;
  9593. }
  9594. var TransformStreamDefaultController = function () {
  9595. function TransformStreamDefaultController() {
  9596. throw new TypeError('TransformStreamDefaultController instances cannot be created directly');
  9597. }
  9598. Object.defineProperty(TransformStreamDefaultController.prototype, "desiredSize", {
  9599. get: function () {
  9600. if (IsTransformStreamDefaultController(this) === false) {
  9601. throw defaultControllerBrandCheckException$1('desiredSize');
  9602. }
  9603. var readableController = this._controlledTransformStream._readable._readableStreamController;
  9604. return ReadableStreamDefaultControllerGetDesiredSize(readableController);
  9605. },
  9606. enumerable: true,
  9607. configurable: true
  9608. });
  9609. TransformStreamDefaultController.prototype.enqueue = function (chunk) {
  9610. if (IsTransformStreamDefaultController(this) === false) {
  9611. throw defaultControllerBrandCheckException$1('enqueue');
  9612. }
  9613. TransformStreamDefaultControllerEnqueue(this, chunk);
  9614. };
  9615. TransformStreamDefaultController.prototype.error = function (reason) {
  9616. if (IsTransformStreamDefaultController(this) === false) {
  9617. throw defaultControllerBrandCheckException$1('error');
  9618. }
  9619. TransformStreamDefaultControllerError(this, reason);
  9620. };
  9621. TransformStreamDefaultController.prototype.terminate = function () {
  9622. if (IsTransformStreamDefaultController(this) === false) {
  9623. throw defaultControllerBrandCheckException$1('terminate');
  9624. }
  9625. TransformStreamDefaultControllerTerminate(this);
  9626. };
  9627. return TransformStreamDefaultController;
  9628. }();
  9629. function IsTransformStreamDefaultController(x) {
  9630. if (!typeIsObject(x)) {
  9631. return false;
  9632. }
  9633. if (!Object.prototype.hasOwnProperty.call(x, '_controlledTransformStream')) {
  9634. return false;
  9635. }
  9636. return true;
  9637. }
  9638. function SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm) {
  9639. controller._controlledTransformStream = stream;
  9640. stream._transformStreamController = controller;
  9641. controller._transformAlgorithm = transformAlgorithm;
  9642. controller._flushAlgorithm = flushAlgorithm;
  9643. }
  9644. function SetUpTransformStreamDefaultControllerFromTransformer(stream, transformer) {
  9645. var controller = Object.create(TransformStreamDefaultController.prototype);
  9646. var transformAlgorithm = function (chunk) {
  9647. try {
  9648. TransformStreamDefaultControllerEnqueue(controller, chunk);
  9649. return promiseResolvedWith(undefined);
  9650. } catch (transformResultE) {
  9651. return promiseRejectedWith(transformResultE);
  9652. }
  9653. };
  9654. var transformMethod = transformer.transform;
  9655. if (transformMethod !== undefined) {
  9656. if (typeof transformMethod !== 'function') {
  9657. throw new TypeError('transform is not a method');
  9658. }
  9659. transformAlgorithm = function (chunk) {
  9660. return PromiseCall(transformMethod, transformer, [
  9661. chunk,
  9662. controller
  9663. ]);
  9664. };
  9665. }
  9666. var flushAlgorithm = CreateAlgorithmFromUnderlyingMethod(transformer, 'flush', 0, [controller]);
  9667. SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm);
  9668. }
  9669. function TransformStreamDefaultControllerClearAlgorithms(controller) {
  9670. controller._transformAlgorithm = undefined;
  9671. controller._flushAlgorithm = undefined;
  9672. }
  9673. function TransformStreamDefaultControllerEnqueue(controller, chunk) {
  9674. var stream = controller._controlledTransformStream;
  9675. var readableController = stream._readable._readableStreamController;
  9676. if (ReadableStreamDefaultControllerCanCloseOrEnqueue(readableController) === false) {
  9677. throw new TypeError('Readable side is not in a state that permits enqueue');
  9678. }
  9679. try {
  9680. ReadableStreamDefaultControllerEnqueue(readableController, chunk);
  9681. } catch (e) {
  9682. TransformStreamErrorWritableAndUnblockWrite(stream, e);
  9683. throw stream._readable._storedError;
  9684. }
  9685. var backpressure = ReadableStreamDefaultControllerHasBackpressure(readableController);
  9686. if (backpressure !== stream._backpressure) {
  9687. TransformStreamSetBackpressure(stream, true);
  9688. }
  9689. }
  9690. function TransformStreamDefaultControllerError(controller, e) {
  9691. TransformStreamError(controller._controlledTransformStream, e);
  9692. }
  9693. function TransformStreamDefaultControllerPerformTransform(controller, chunk) {
  9694. var transformPromise = controller._transformAlgorithm(chunk);
  9695. return transformPromiseWith(transformPromise, undefined, function (r) {
  9696. TransformStreamError(controller._controlledTransformStream, r);
  9697. throw r;
  9698. });
  9699. }
  9700. function TransformStreamDefaultControllerTerminate(controller) {
  9701. var stream = controller._controlledTransformStream;
  9702. var readableController = stream._readable._readableStreamController;
  9703. if (ReadableStreamDefaultControllerCanCloseOrEnqueue(readableController) === true) {
  9704. ReadableStreamDefaultControllerClose(readableController);
  9705. }
  9706. var error = new TypeError('TransformStream terminated');
  9707. TransformStreamErrorWritableAndUnblockWrite(stream, error);
  9708. }
  9709. function TransformStreamDefaultSinkWriteAlgorithm(stream, chunk) {
  9710. var controller = stream._transformStreamController;
  9711. if (stream._backpressure === true) {
  9712. var backpressureChangePromise = stream._backpressureChangePromise;
  9713. return transformPromiseWith(backpressureChangePromise, function () {
  9714. var writable = stream._writable;
  9715. var state = writable._state;
  9716. if (state === 'erroring') {
  9717. throw writable._storedError;
  9718. }
  9719. return TransformStreamDefaultControllerPerformTransform(controller, chunk);
  9720. });
  9721. }
  9722. return TransformStreamDefaultControllerPerformTransform(controller, chunk);
  9723. }
  9724. function TransformStreamDefaultSinkAbortAlgorithm(stream, reason) {
  9725. TransformStreamError(stream, reason);
  9726. return promiseResolvedWith(undefined);
  9727. }
  9728. function TransformStreamDefaultSinkCloseAlgorithm(stream) {
  9729. var readable = stream._readable;
  9730. var controller = stream._transformStreamController;
  9731. var flushPromise = controller._flushAlgorithm();
  9732. TransformStreamDefaultControllerClearAlgorithms(controller);
  9733. return transformPromiseWith(flushPromise, function () {
  9734. if (readable._state === 'errored') {
  9735. throw readable._storedError;
  9736. }
  9737. var readableController = readable._readableStreamController;
  9738. if (ReadableStreamDefaultControllerCanCloseOrEnqueue(readableController) === true) {
  9739. ReadableStreamDefaultControllerClose(readableController);
  9740. }
  9741. }, function (r) {
  9742. TransformStreamError(stream, r);
  9743. throw readable._storedError;
  9744. });
  9745. }
  9746. function TransformStreamDefaultSourcePullAlgorithm(stream) {
  9747. TransformStreamSetBackpressure(stream, false);
  9748. return stream._backpressureChangePromise;
  9749. }
  9750. function defaultControllerBrandCheckException$1(name) {
  9751. return new TypeError("TransformStreamDefaultController.prototype." + name + " can only be used on a TransformStreamDefaultController");
  9752. }
  9753. function streamBrandCheckException$2(name) {
  9754. return new TypeError("TransformStream.prototype." + name + " can only be used on a TransformStream");
  9755. }
  9756. exports.ByteLengthQueuingStrategy = ByteLengthQueuingStrategy;
  9757. exports.CountQueuingStrategy = CountQueuingStrategy;
  9758. exports.ReadableStream = ReadableStream;
  9759. exports.TransformStream = TransformStream;
  9760. exports.WritableStream = WritableStream;
  9761. Object.defineProperty(exports, '__esModule', { value: true });
  9762. }));
  9763. /***/ }),
  9764. /* 146 */
  9765. /***/ (function(module, exports, __w_pdfjs_require__) {
  9766. __w_pdfjs_require__(147);
  9767. __w_pdfjs_require__(118);
  9768. __w_pdfjs_require__(77);
  9769. __w_pdfjs_require__(120);
  9770. var path = __w_pdfjs_require__(43);
  9771. module.exports = path.Map;
  9772. /***/ }),
  9773. /* 147 */
  9774. /***/ (function(module, exports, __w_pdfjs_require__) {
  9775. "use strict";
  9776. var collection = __w_pdfjs_require__(148);
  9777. var collectionStrong = __w_pdfjs_require__(152);
  9778. module.exports = collection('Map', function (init) {
  9779. return function Map() {
  9780. return init(this, arguments.length ? arguments[0] : undefined);
  9781. };
  9782. }, collectionStrong);
  9783. /***/ }),
  9784. /* 148 */
  9785. /***/ (function(module, exports, __w_pdfjs_require__) {
  9786. "use strict";
  9787. var $ = __w_pdfjs_require__(10);
  9788. var global = __w_pdfjs_require__(11);
  9789. var isForced = __w_pdfjs_require__(52);
  9790. var redefine = __w_pdfjs_require__(29);
  9791. var InternalMetadataModule = __w_pdfjs_require__(149);
  9792. var iterate = __w_pdfjs_require__(104);
  9793. var anInstance = __w_pdfjs_require__(126);
  9794. var isObject = __w_pdfjs_require__(22);
  9795. var fails = __w_pdfjs_require__(14);
  9796. var checkCorrectnessOfIteration = __w_pdfjs_require__(97);
  9797. var setToStringTag = __w_pdfjs_require__(85);
  9798. var inheritIfRequired = __w_pdfjs_require__(151);
  9799. module.exports = function (CONSTRUCTOR_NAME, wrapper, common) {
  9800. var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
  9801. var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
  9802. var ADDER = IS_MAP ? 'set' : 'add';
  9803. var NativeConstructor = global[CONSTRUCTOR_NAME];
  9804. var NativePrototype = NativeConstructor && NativeConstructor.prototype;
  9805. var Constructor = NativeConstructor;
  9806. var exported = {};
  9807. var fixMethod = function (KEY) {
  9808. var nativeMethod = NativePrototype[KEY];
  9809. redefine(NativePrototype, KEY, KEY == 'add' ? function add(value) {
  9810. nativeMethod.call(this, value === 0 ? 0 : value);
  9811. return this;
  9812. } : KEY == 'delete' ? function (key) {
  9813. return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);
  9814. } : KEY == 'get' ? function get(key) {
  9815. return IS_WEAK && !isObject(key) ? undefined : nativeMethod.call(this, key === 0 ? 0 : key);
  9816. } : KEY == 'has' ? function has(key) {
  9817. return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);
  9818. } : function set(key, value) {
  9819. nativeMethod.call(this, key === 0 ? 0 : key, value);
  9820. return this;
  9821. });
  9822. };
  9823. if (isForced(CONSTRUCTOR_NAME, typeof NativeConstructor != 'function' || !(IS_WEAK || NativePrototype.forEach && !fails(function () {
  9824. new NativeConstructor().entries().next();
  9825. })))) {
  9826. Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
  9827. InternalMetadataModule.REQUIRED = true;
  9828. } else if (isForced(CONSTRUCTOR_NAME, true)) {
  9829. var instance = new Constructor();
  9830. var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
  9831. var THROWS_ON_PRIMITIVES = fails(function () {
  9832. instance.has(1);
  9833. });
  9834. var ACCEPT_ITERABLES = checkCorrectnessOfIteration(function (iterable) {
  9835. new NativeConstructor(iterable);
  9836. });
  9837. var BUGGY_ZERO = !IS_WEAK && fails(function () {
  9838. var $instance = new NativeConstructor();
  9839. var index = 5;
  9840. while (index--)
  9841. $instance[ADDER](index, index);
  9842. return !$instance.has(-0);
  9843. });
  9844. if (!ACCEPT_ITERABLES) {
  9845. Constructor = wrapper(function (dummy, iterable) {
  9846. anInstance(dummy, Constructor, CONSTRUCTOR_NAME);
  9847. var that = inheritIfRequired(new NativeConstructor(), dummy, Constructor);
  9848. if (iterable != undefined)
  9849. iterate(iterable, that[ADDER], that, IS_MAP);
  9850. return that;
  9851. });
  9852. Constructor.prototype = NativePrototype;
  9853. NativePrototype.constructor = Constructor;
  9854. }
  9855. if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
  9856. fixMethod('delete');
  9857. fixMethod('has');
  9858. IS_MAP && fixMethod('get');
  9859. }
  9860. if (BUGGY_ZERO || HASNT_CHAINING)
  9861. fixMethod(ADDER);
  9862. if (IS_WEAK && NativePrototype.clear)
  9863. delete NativePrototype.clear;
  9864. }
  9865. exported[CONSTRUCTOR_NAME] = Constructor;
  9866. $({
  9867. global: true,
  9868. forced: Constructor != NativeConstructor
  9869. }, exported);
  9870. setToStringTag(Constructor, CONSTRUCTOR_NAME);
  9871. if (!IS_WEAK)
  9872. common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
  9873. return Constructor;
  9874. };
  9875. /***/ }),
  9876. /* 149 */
  9877. /***/ (function(module, exports, __w_pdfjs_require__) {
  9878. var hiddenKeys = __w_pdfjs_require__(39);
  9879. var isObject = __w_pdfjs_require__(22);
  9880. var has = __w_pdfjs_require__(23);
  9881. var defineProperty = __w_pdfjs_require__(27).f;
  9882. var uid = __w_pdfjs_require__(38);
  9883. var FREEZING = __w_pdfjs_require__(150);
  9884. var METADATA = uid('meta');
  9885. var id = 0;
  9886. var isExtensible = Object.isExtensible || function () {
  9887. return true;
  9888. };
  9889. var setMetadata = function (it) {
  9890. defineProperty(it, METADATA, {
  9891. value: {
  9892. objectID: 'O' + ++id,
  9893. weakData: {}
  9894. }
  9895. });
  9896. };
  9897. var fastKey = function (it, create) {
  9898. if (!isObject(it))
  9899. return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  9900. if (!has(it, METADATA)) {
  9901. if (!isExtensible(it))
  9902. return 'F';
  9903. if (!create)
  9904. return 'E';
  9905. setMetadata(it);
  9906. }
  9907. return it[METADATA].objectID;
  9908. };
  9909. var getWeakData = function (it, create) {
  9910. if (!has(it, METADATA)) {
  9911. if (!isExtensible(it))
  9912. return true;
  9913. if (!create)
  9914. return false;
  9915. setMetadata(it);
  9916. }
  9917. return it[METADATA].weakData;
  9918. };
  9919. var onFreeze = function (it) {
  9920. if (FREEZING && meta.REQUIRED && isExtensible(it) && !has(it, METADATA))
  9921. setMetadata(it);
  9922. return it;
  9923. };
  9924. var meta = module.exports = {
  9925. REQUIRED: false,
  9926. fastKey: fastKey,
  9927. getWeakData: getWeakData,
  9928. onFreeze: onFreeze
  9929. };
  9930. hiddenKeys[METADATA] = true;
  9931. /***/ }),
  9932. /* 150 */
  9933. /***/ (function(module, exports, __w_pdfjs_require__) {
  9934. var fails = __w_pdfjs_require__(14);
  9935. module.exports = !fails(function () {
  9936. return Object.isExtensible(Object.preventExtensions({}));
  9937. });
  9938. /***/ }),
  9939. /* 151 */
  9940. /***/ (function(module, exports, __w_pdfjs_require__) {
  9941. var isObject = __w_pdfjs_require__(22);
  9942. var setPrototypeOf = __w_pdfjs_require__(87);
  9943. module.exports = function ($this, dummy, Wrapper) {
  9944. var NewTarget, NewTargetPrototype;
  9945. if (setPrototypeOf && typeof (NewTarget = dummy.constructor) == 'function' && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype)
  9946. setPrototypeOf($this, NewTargetPrototype);
  9947. return $this;
  9948. };
  9949. /***/ }),
  9950. /* 152 */
  9951. /***/ (function(module, exports, __w_pdfjs_require__) {
  9952. "use strict";
  9953. var defineProperty = __w_pdfjs_require__(27).f;
  9954. var create = __w_pdfjs_require__(71);
  9955. var redefineAll = __w_pdfjs_require__(124);
  9956. var bind = __w_pdfjs_require__(62);
  9957. var anInstance = __w_pdfjs_require__(126);
  9958. var iterate = __w_pdfjs_require__(104);
  9959. var defineIterator = __w_pdfjs_require__(79);
  9960. var setSpecies = __w_pdfjs_require__(125);
  9961. var DESCRIPTORS = __w_pdfjs_require__(13);
  9962. var fastKey = __w_pdfjs_require__(149).fastKey;
  9963. var InternalStateModule = __w_pdfjs_require__(33);
  9964. var setInternalState = InternalStateModule.set;
  9965. var internalStateGetterFor = InternalStateModule.getterFor;
  9966. module.exports = {
  9967. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  9968. var C = wrapper(function (that, iterable) {
  9969. anInstance(that, C, CONSTRUCTOR_NAME);
  9970. setInternalState(that, {
  9971. type: CONSTRUCTOR_NAME,
  9972. index: create(null),
  9973. first: undefined,
  9974. last: undefined,
  9975. size: 0
  9976. });
  9977. if (!DESCRIPTORS)
  9978. that.size = 0;
  9979. if (iterable != undefined)
  9980. iterate(iterable, that[ADDER], that, IS_MAP);
  9981. });
  9982. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  9983. var define = function (that, key, value) {
  9984. var state = getInternalState(that);
  9985. var entry = getEntry(that, key);
  9986. var previous, index;
  9987. if (entry) {
  9988. entry.value = value;
  9989. } else {
  9990. state.last = entry = {
  9991. index: index = fastKey(key, true),
  9992. key: key,
  9993. value: value,
  9994. previous: previous = state.last,
  9995. next: undefined,
  9996. removed: false
  9997. };
  9998. if (!state.first)
  9999. state.first = entry;
  10000. if (previous)
  10001. previous.next = entry;
  10002. if (DESCRIPTORS)
  10003. state.size++;
  10004. else
  10005. that.size++;
  10006. if (index !== 'F')
  10007. state.index[index] = entry;
  10008. }
  10009. return that;
  10010. };
  10011. var getEntry = function (that, key) {
  10012. var state = getInternalState(that);
  10013. var index = fastKey(key);
  10014. var entry;
  10015. if (index !== 'F')
  10016. return state.index[index];
  10017. for (entry = state.first; entry; entry = entry.next) {
  10018. if (entry.key == key)
  10019. return entry;
  10020. }
  10021. };
  10022. redefineAll(C.prototype, {
  10023. clear: function clear() {
  10024. var that = this;
  10025. var state = getInternalState(that);
  10026. var data = state.index;
  10027. var entry = state.first;
  10028. while (entry) {
  10029. entry.removed = true;
  10030. if (entry.previous)
  10031. entry.previous = entry.previous.next = undefined;
  10032. delete data[entry.index];
  10033. entry = entry.next;
  10034. }
  10035. state.first = state.last = undefined;
  10036. if (DESCRIPTORS)
  10037. state.size = 0;
  10038. else
  10039. that.size = 0;
  10040. },
  10041. 'delete': function (key) {
  10042. var that = this;
  10043. var state = getInternalState(that);
  10044. var entry = getEntry(that, key);
  10045. if (entry) {
  10046. var next = entry.next;
  10047. var prev = entry.previous;
  10048. delete state.index[entry.index];
  10049. entry.removed = true;
  10050. if (prev)
  10051. prev.next = next;
  10052. if (next)
  10053. next.previous = prev;
  10054. if (state.first == entry)
  10055. state.first = next;
  10056. if (state.last == entry)
  10057. state.last = prev;
  10058. if (DESCRIPTORS)
  10059. state.size--;
  10060. else
  10061. that.size--;
  10062. }
  10063. return !!entry;
  10064. },
  10065. forEach: function forEach(callbackfn) {
  10066. var state = getInternalState(this);
  10067. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
  10068. var entry;
  10069. while (entry = entry ? entry.next : state.first) {
  10070. boundFunction(entry.value, entry.key, this);
  10071. while (entry && entry.removed)
  10072. entry = entry.previous;
  10073. }
  10074. },
  10075. has: function has(key) {
  10076. return !!getEntry(this, key);
  10077. }
  10078. });
  10079. redefineAll(C.prototype, IS_MAP ? {
  10080. get: function get(key) {
  10081. var entry = getEntry(this, key);
  10082. return entry && entry.value;
  10083. },
  10084. set: function set(key, value) {
  10085. return define(this, key === 0 ? 0 : key, value);
  10086. }
  10087. } : {
  10088. add: function add(value) {
  10089. return define(this, value = value === 0 ? 0 : value, value);
  10090. }
  10091. });
  10092. if (DESCRIPTORS)
  10093. defineProperty(C.prototype, 'size', {
  10094. get: function () {
  10095. return getInternalState(this).size;
  10096. }
  10097. });
  10098. return C;
  10099. },
  10100. setStrong: function (C, CONSTRUCTOR_NAME, IS_MAP) {
  10101. var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';
  10102. var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);
  10103. var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME);
  10104. defineIterator(C, CONSTRUCTOR_NAME, function (iterated, kind) {
  10105. setInternalState(this, {
  10106. type: ITERATOR_NAME,
  10107. target: iterated,
  10108. state: getInternalCollectionState(iterated),
  10109. kind: kind,
  10110. last: undefined
  10111. });
  10112. }, function () {
  10113. var state = getInternalIteratorState(this);
  10114. var kind = state.kind;
  10115. var entry = state.last;
  10116. while (entry && entry.removed)
  10117. entry = entry.previous;
  10118. if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
  10119. state.target = undefined;
  10120. return {
  10121. value: undefined,
  10122. done: true
  10123. };
  10124. }
  10125. if (kind == 'keys')
  10126. return {
  10127. value: entry.key,
  10128. done: false
  10129. };
  10130. if (kind == 'values')
  10131. return {
  10132. value: entry.value,
  10133. done: false
  10134. };
  10135. return {
  10136. value: [
  10137. entry.key,
  10138. entry.value
  10139. ],
  10140. done: false
  10141. };
  10142. }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
  10143. setSpecies(CONSTRUCTOR_NAME);
  10144. }
  10145. };
  10146. /***/ }),
  10147. /* 153 */
  10148. /***/ (function(module, exports, __w_pdfjs_require__) {
  10149. __w_pdfjs_require__(154);
  10150. __w_pdfjs_require__(118);
  10151. __w_pdfjs_require__(77);
  10152. __w_pdfjs_require__(120);
  10153. var path = __w_pdfjs_require__(43);
  10154. module.exports = path.Set;
  10155. /***/ }),
  10156. /* 154 */
  10157. /***/ (function(module, exports, __w_pdfjs_require__) {
  10158. "use strict";
  10159. var collection = __w_pdfjs_require__(148);
  10160. var collectionStrong = __w_pdfjs_require__(152);
  10161. module.exports = collection('Set', function (init) {
  10162. return function Set() {
  10163. return init(this, arguments.length ? arguments[0] : undefined);
  10164. };
  10165. }, collectionStrong);
  10166. /***/ }),
  10167. /* 155 */
  10168. /***/ (function(module, exports, __w_pdfjs_require__) {
  10169. __w_pdfjs_require__(118);
  10170. __w_pdfjs_require__(156);
  10171. __w_pdfjs_require__(120);
  10172. var path = __w_pdfjs_require__(43);
  10173. module.exports = path.WeakMap;
  10174. /***/ }),
  10175. /* 156 */
  10176. /***/ (function(module, exports, __w_pdfjs_require__) {
  10177. "use strict";
  10178. var global = __w_pdfjs_require__(11);
  10179. var redefineAll = __w_pdfjs_require__(124);
  10180. var InternalMetadataModule = __w_pdfjs_require__(149);
  10181. var collection = __w_pdfjs_require__(148);
  10182. var collectionWeak = __w_pdfjs_require__(157);
  10183. var isObject = __w_pdfjs_require__(22);
  10184. var enforceIternalState = __w_pdfjs_require__(33).enforce;
  10185. var NATIVE_WEAK_MAP = __w_pdfjs_require__(34);
  10186. var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
  10187. var isExtensible = Object.isExtensible;
  10188. var InternalWeakMap;
  10189. var wrapper = function (init) {
  10190. return function WeakMap() {
  10191. return init(this, arguments.length ? arguments[0] : undefined);
  10192. };
  10193. };
  10194. var $WeakMap = module.exports = collection('WeakMap', wrapper, collectionWeak);
  10195. if (NATIVE_WEAK_MAP && IS_IE11) {
  10196. InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
  10197. InternalMetadataModule.REQUIRED = true;
  10198. var WeakMapPrototype = $WeakMap.prototype;
  10199. var nativeDelete = WeakMapPrototype['delete'];
  10200. var nativeHas = WeakMapPrototype.has;
  10201. var nativeGet = WeakMapPrototype.get;
  10202. var nativeSet = WeakMapPrototype.set;
  10203. redefineAll(WeakMapPrototype, {
  10204. 'delete': function (key) {
  10205. if (isObject(key) && !isExtensible(key)) {
  10206. var state = enforceIternalState(this);
  10207. if (!state.frozen)
  10208. state.frozen = new InternalWeakMap();
  10209. return nativeDelete.call(this, key) || state.frozen['delete'](key);
  10210. }
  10211. return nativeDelete.call(this, key);
  10212. },
  10213. has: function has(key) {
  10214. if (isObject(key) && !isExtensible(key)) {
  10215. var state = enforceIternalState(this);
  10216. if (!state.frozen)
  10217. state.frozen = new InternalWeakMap();
  10218. return nativeHas.call(this, key) || state.frozen.has(key);
  10219. }
  10220. return nativeHas.call(this, key);
  10221. },
  10222. get: function get(key) {
  10223. if (isObject(key) && !isExtensible(key)) {
  10224. var state = enforceIternalState(this);
  10225. if (!state.frozen)
  10226. state.frozen = new InternalWeakMap();
  10227. return nativeHas.call(this, key) ? nativeGet.call(this, key) : state.frozen.get(key);
  10228. }
  10229. return nativeGet.call(this, key);
  10230. },
  10231. set: function set(key, value) {
  10232. if (isObject(key) && !isExtensible(key)) {
  10233. var state = enforceIternalState(this);
  10234. if (!state.frozen)
  10235. state.frozen = new InternalWeakMap();
  10236. nativeHas.call(this, key) ? nativeSet.call(this, key, value) : state.frozen.set(key, value);
  10237. } else
  10238. nativeSet.call(this, key, value);
  10239. return this;
  10240. }
  10241. });
  10242. }
  10243. /***/ }),
  10244. /* 157 */
  10245. /***/ (function(module, exports, __w_pdfjs_require__) {
  10246. "use strict";
  10247. var redefineAll = __w_pdfjs_require__(124);
  10248. var getWeakData = __w_pdfjs_require__(149).getWeakData;
  10249. var anObject = __w_pdfjs_require__(28);
  10250. var isObject = __w_pdfjs_require__(22);
  10251. var anInstance = __w_pdfjs_require__(126);
  10252. var iterate = __w_pdfjs_require__(104);
  10253. var ArrayIterationModule = __w_pdfjs_require__(158);
  10254. var $has = __w_pdfjs_require__(23);
  10255. var InternalStateModule = __w_pdfjs_require__(33);
  10256. var setInternalState = InternalStateModule.set;
  10257. var internalStateGetterFor = InternalStateModule.getterFor;
  10258. var find = ArrayIterationModule.find;
  10259. var findIndex = ArrayIterationModule.findIndex;
  10260. var id = 0;
  10261. var uncaughtFrozenStore = function (store) {
  10262. return store.frozen || (store.frozen = new UncaughtFrozenStore());
  10263. };
  10264. var UncaughtFrozenStore = function () {
  10265. this.entries = [];
  10266. };
  10267. var findUncaughtFrozen = function (store, key) {
  10268. return find(store.entries, function (it) {
  10269. return it[0] === key;
  10270. });
  10271. };
  10272. UncaughtFrozenStore.prototype = {
  10273. get: function (key) {
  10274. var entry = findUncaughtFrozen(this, key);
  10275. if (entry)
  10276. return entry[1];
  10277. },
  10278. has: function (key) {
  10279. return !!findUncaughtFrozen(this, key);
  10280. },
  10281. set: function (key, value) {
  10282. var entry = findUncaughtFrozen(this, key);
  10283. if (entry)
  10284. entry[1] = value;
  10285. else
  10286. this.entries.push([
  10287. key,
  10288. value
  10289. ]);
  10290. },
  10291. 'delete': function (key) {
  10292. var index = findIndex(this.entries, function (it) {
  10293. return it[0] === key;
  10294. });
  10295. if (~index)
  10296. this.entries.splice(index, 1);
  10297. return !!~index;
  10298. }
  10299. };
  10300. module.exports = {
  10301. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  10302. var C = wrapper(function (that, iterable) {
  10303. anInstance(that, C, CONSTRUCTOR_NAME);
  10304. setInternalState(that, {
  10305. type: CONSTRUCTOR_NAME,
  10306. id: id++,
  10307. frozen: undefined
  10308. });
  10309. if (iterable != undefined)
  10310. iterate(iterable, that[ADDER], that, IS_MAP);
  10311. });
  10312. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  10313. var define = function (that, key, value) {
  10314. var state = getInternalState(that);
  10315. var data = getWeakData(anObject(key), true);
  10316. if (data === true)
  10317. uncaughtFrozenStore(state).set(key, value);
  10318. else
  10319. data[state.id] = value;
  10320. return that;
  10321. };
  10322. redefineAll(C.prototype, {
  10323. 'delete': function (key) {
  10324. var state = getInternalState(this);
  10325. if (!isObject(key))
  10326. return false;
  10327. var data = getWeakData(key);
  10328. if (data === true)
  10329. return uncaughtFrozenStore(state)['delete'](key);
  10330. return data && $has(data, state.id) && delete data[state.id];
  10331. },
  10332. has: function has(key) {
  10333. var state = getInternalState(this);
  10334. if (!isObject(key))
  10335. return false;
  10336. var data = getWeakData(key);
  10337. if (data === true)
  10338. return uncaughtFrozenStore(state).has(key);
  10339. return data && $has(data, state.id);
  10340. }
  10341. });
  10342. redefineAll(C.prototype, IS_MAP ? {
  10343. get: function get(key) {
  10344. var state = getInternalState(this);
  10345. if (isObject(key)) {
  10346. var data = getWeakData(key);
  10347. if (data === true)
  10348. return uncaughtFrozenStore(state).get(key);
  10349. return data ? data[state.id] : undefined;
  10350. }
  10351. },
  10352. set: function set(key, value) {
  10353. return define(this, key, value);
  10354. }
  10355. } : {
  10356. add: function add(value) {
  10357. return define(this, value, true);
  10358. }
  10359. });
  10360. return C;
  10361. }
  10362. };
  10363. /***/ }),
  10364. /* 158 */
  10365. /***/ (function(module, exports, __w_pdfjs_require__) {
  10366. var bind = __w_pdfjs_require__(62);
  10367. var IndexedObject = __w_pdfjs_require__(18);
  10368. var toObject = __w_pdfjs_require__(83);
  10369. var toLength = __w_pdfjs_require__(47);
  10370. var arraySpeciesCreate = __w_pdfjs_require__(159);
  10371. var push = [].push;
  10372. var createMethod = function (TYPE) {
  10373. var IS_MAP = TYPE == 1;
  10374. var IS_FILTER = TYPE == 2;
  10375. var IS_SOME = TYPE == 3;
  10376. var IS_EVERY = TYPE == 4;
  10377. var IS_FIND_INDEX = TYPE == 6;
  10378. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  10379. return function ($this, callbackfn, that, specificCreate) {
  10380. var O = toObject($this);
  10381. var self = IndexedObject(O);
  10382. var boundFunction = bind(callbackfn, that, 3);
  10383. var length = toLength(self.length);
  10384. var index = 0;
  10385. var create = specificCreate || arraySpeciesCreate;
  10386. var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  10387. var value, result;
  10388. for (; length > index; index++)
  10389. if (NO_HOLES || index in self) {
  10390. value = self[index];
  10391. result = boundFunction(value, index, O);
  10392. if (TYPE) {
  10393. if (IS_MAP)
  10394. target[index] = result;
  10395. else if (result)
  10396. switch (TYPE) {
  10397. case 3:
  10398. return true;
  10399. case 5:
  10400. return value;
  10401. case 6:
  10402. return index;
  10403. case 2:
  10404. push.call(target, value);
  10405. }
  10406. else if (IS_EVERY)
  10407. return false;
  10408. }
  10409. }
  10410. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  10411. };
  10412. };
  10413. module.exports = {
  10414. forEach: createMethod(0),
  10415. map: createMethod(1),
  10416. filter: createMethod(2),
  10417. some: createMethod(3),
  10418. every: createMethod(4),
  10419. find: createMethod(5),
  10420. findIndex: createMethod(6)
  10421. };
  10422. /***/ }),
  10423. /* 159 */
  10424. /***/ (function(module, exports, __w_pdfjs_require__) {
  10425. var isObject = __w_pdfjs_require__(22);
  10426. var isArray = __w_pdfjs_require__(160);
  10427. var wellKnownSymbol = __w_pdfjs_require__(57);
  10428. var SPECIES = wellKnownSymbol('species');
  10429. module.exports = function (originalArray, length) {
  10430. var C;
  10431. if (isArray(originalArray)) {
  10432. C = originalArray.constructor;
  10433. if (typeof C == 'function' && (C === Array || isArray(C.prototype)))
  10434. C = undefined;
  10435. else if (isObject(C)) {
  10436. C = C[SPECIES];
  10437. if (C === null)
  10438. C = undefined;
  10439. }
  10440. }
  10441. return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
  10442. };
  10443. /***/ }),
  10444. /* 160 */
  10445. /***/ (function(module, exports, __w_pdfjs_require__) {
  10446. var classof = __w_pdfjs_require__(19);
  10447. module.exports = Array.isArray || function isArray(arg) {
  10448. return classof(arg) == 'Array';
  10449. };
  10450. /***/ }),
  10451. /* 161 */
  10452. /***/ (function(module, exports, __w_pdfjs_require__) {
  10453. __w_pdfjs_require__(118);
  10454. __w_pdfjs_require__(162);
  10455. __w_pdfjs_require__(120);
  10456. var path = __w_pdfjs_require__(43);
  10457. module.exports = path.WeakSet;
  10458. /***/ }),
  10459. /* 162 */
  10460. /***/ (function(module, exports, __w_pdfjs_require__) {
  10461. "use strict";
  10462. var collection = __w_pdfjs_require__(148);
  10463. var collectionWeak = __w_pdfjs_require__(157);
  10464. collection('WeakSet', function (init) {
  10465. return function WeakSet() {
  10466. return init(this, arguments.length ? arguments[0] : undefined);
  10467. };
  10468. }, collectionWeak);
  10469. /***/ }),
  10470. /* 163 */
  10471. /***/ (function(module, exports, __w_pdfjs_require__) {
  10472. __w_pdfjs_require__(164);
  10473. var entryUnbind = __w_pdfjs_require__(61);
  10474. module.exports = entryUnbind('String', 'codePointAt');
  10475. /***/ }),
  10476. /* 164 */
  10477. /***/ (function(module, exports, __w_pdfjs_require__) {
  10478. "use strict";
  10479. var $ = __w_pdfjs_require__(10);
  10480. var codeAt = __w_pdfjs_require__(78).codeAt;
  10481. $({
  10482. target: 'String',
  10483. proto: true
  10484. }, {
  10485. codePointAt: function codePointAt(pos) {
  10486. return codeAt(this, pos);
  10487. }
  10488. });
  10489. /***/ }),
  10490. /* 165 */
  10491. /***/ (function(module, exports, __w_pdfjs_require__) {
  10492. __w_pdfjs_require__(166);
  10493. var path = __w_pdfjs_require__(43);
  10494. module.exports = path.String.fromCodePoint;
  10495. /***/ }),
  10496. /* 166 */
  10497. /***/ (function(module, exports, __w_pdfjs_require__) {
  10498. var $ = __w_pdfjs_require__(10);
  10499. var toAbsoluteIndex = __w_pdfjs_require__(49);
  10500. var fromCharCode = String.fromCharCode;
  10501. var nativeFromCodePoint = String.fromCodePoint;
  10502. var INCORRECT_LENGTH = !!nativeFromCodePoint && nativeFromCodePoint.length != 1;
  10503. $({
  10504. target: 'String',
  10505. stat: true,
  10506. forced: INCORRECT_LENGTH
  10507. }, {
  10508. fromCodePoint: function fromCodePoint(x) {
  10509. var elements = [];
  10510. var length = arguments.length;
  10511. var i = 0;
  10512. var code;
  10513. while (length > i) {
  10514. code = +arguments[i++];
  10515. if (toAbsoluteIndex(code, 0x10FFFF) !== code)
  10516. throw RangeError(code + ' is not a valid code point');
  10517. elements.push(code < 0x10000 ? fromCharCode(code) : fromCharCode(((code -= 0x10000) >> 10) + 0xD800, code % 0x400 + 0xDC00));
  10518. }
  10519. return elements.join('');
  10520. }
  10521. });
  10522. /***/ }),
  10523. /* 167 */
  10524. /***/ (function(module, exports, __w_pdfjs_require__) {
  10525. __w_pdfjs_require__(168);
  10526. __w_pdfjs_require__(118);
  10527. __w_pdfjs_require__(170);
  10528. __w_pdfjs_require__(174);
  10529. __w_pdfjs_require__(175);
  10530. __w_pdfjs_require__(176);
  10531. __w_pdfjs_require__(177);
  10532. __w_pdfjs_require__(178);
  10533. __w_pdfjs_require__(179);
  10534. __w_pdfjs_require__(180);
  10535. __w_pdfjs_require__(181);
  10536. __w_pdfjs_require__(182);
  10537. __w_pdfjs_require__(183);
  10538. __w_pdfjs_require__(184);
  10539. __w_pdfjs_require__(185);
  10540. __w_pdfjs_require__(186);
  10541. __w_pdfjs_require__(187);
  10542. __w_pdfjs_require__(188);
  10543. __w_pdfjs_require__(189);
  10544. var path = __w_pdfjs_require__(43);
  10545. module.exports = path.Symbol;
  10546. /***/ }),
  10547. /* 168 */
  10548. /***/ (function(module, exports, __w_pdfjs_require__) {
  10549. "use strict";
  10550. var $ = __w_pdfjs_require__(10);
  10551. var fails = __w_pdfjs_require__(14);
  10552. var isArray = __w_pdfjs_require__(160);
  10553. var isObject = __w_pdfjs_require__(22);
  10554. var toObject = __w_pdfjs_require__(83);
  10555. var toLength = __w_pdfjs_require__(47);
  10556. var createProperty = __w_pdfjs_require__(93);
  10557. var arraySpeciesCreate = __w_pdfjs_require__(159);
  10558. var arrayMethodHasSpeciesSupport = __w_pdfjs_require__(169);
  10559. var wellKnownSymbol = __w_pdfjs_require__(57);
  10560. var V8_VERSION = __w_pdfjs_require__(135);
  10561. var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
  10562. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
  10563. var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';
  10564. var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () {
  10565. var array = [];
  10566. array[IS_CONCAT_SPREADABLE] = false;
  10567. return array.concat()[0] !== array;
  10568. });
  10569. var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
  10570. var isConcatSpreadable = function (O) {
  10571. if (!isObject(O))
  10572. return false;
  10573. var spreadable = O[IS_CONCAT_SPREADABLE];
  10574. return spreadable !== undefined ? !!spreadable : isArray(O);
  10575. };
  10576. var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
  10577. $({
  10578. target: 'Array',
  10579. proto: true,
  10580. forced: FORCED
  10581. }, {
  10582. concat: function concat(arg) {
  10583. var O = toObject(this);
  10584. var A = arraySpeciesCreate(O, 0);
  10585. var n = 0;
  10586. var i, k, length, len, E;
  10587. for (i = -1, length = arguments.length; i < length; i++) {
  10588. E = i === -1 ? O : arguments[i];
  10589. if (isConcatSpreadable(E)) {
  10590. len = toLength(E.length);
  10591. if (n + len > MAX_SAFE_INTEGER)
  10592. throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  10593. for (k = 0; k < len; k++, n++)
  10594. if (k in E)
  10595. createProperty(A, n, E[k]);
  10596. } else {
  10597. if (n >= MAX_SAFE_INTEGER)
  10598. throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  10599. createProperty(A, n++, E);
  10600. }
  10601. }
  10602. A.length = n;
  10603. return A;
  10604. }
  10605. });
  10606. /***/ }),
  10607. /* 169 */
  10608. /***/ (function(module, exports, __w_pdfjs_require__) {
  10609. var fails = __w_pdfjs_require__(14);
  10610. var wellKnownSymbol = __w_pdfjs_require__(57);
  10611. var V8_VERSION = __w_pdfjs_require__(135);
  10612. var SPECIES = wellKnownSymbol('species');
  10613. module.exports = function (METHOD_NAME) {
  10614. return V8_VERSION >= 51 || !fails(function () {
  10615. var array = [];
  10616. var constructor = array.constructor = {};
  10617. constructor[SPECIES] = function () {
  10618. return { foo: 1 };
  10619. };
  10620. return array[METHOD_NAME](Boolean).foo !== 1;
  10621. });
  10622. };
  10623. /***/ }),
  10624. /* 170 */
  10625. /***/ (function(module, exports, __w_pdfjs_require__) {
  10626. "use strict";
  10627. var $ = __w_pdfjs_require__(10);
  10628. var global = __w_pdfjs_require__(11);
  10629. var getBuiltIn = __w_pdfjs_require__(42);
  10630. var IS_PURE = __w_pdfjs_require__(37);
  10631. var DESCRIPTORS = __w_pdfjs_require__(13);
  10632. var NATIVE_SYMBOL = __w_pdfjs_require__(58);
  10633. var USE_SYMBOL_AS_UID = __w_pdfjs_require__(59);
  10634. var fails = __w_pdfjs_require__(14);
  10635. var has = __w_pdfjs_require__(23);
  10636. var isArray = __w_pdfjs_require__(160);
  10637. var isObject = __w_pdfjs_require__(22);
  10638. var anObject = __w_pdfjs_require__(28);
  10639. var toObject = __w_pdfjs_require__(83);
  10640. var toIndexedObject = __w_pdfjs_require__(17);
  10641. var toPrimitive = __w_pdfjs_require__(21);
  10642. var createPropertyDescriptor = __w_pdfjs_require__(16);
  10643. var nativeObjectCreate = __w_pdfjs_require__(71);
  10644. var objectKeys = __w_pdfjs_require__(73);
  10645. var getOwnPropertyNamesModule = __w_pdfjs_require__(44);
  10646. var getOwnPropertyNamesExternal = __w_pdfjs_require__(171);
  10647. var getOwnPropertySymbolsModule = __w_pdfjs_require__(51);
  10648. var getOwnPropertyDescriptorModule = __w_pdfjs_require__(12);
  10649. var definePropertyModule = __w_pdfjs_require__(27);
  10650. var propertyIsEnumerableModule = __w_pdfjs_require__(15);
  10651. var createNonEnumerableProperty = __w_pdfjs_require__(26);
  10652. var redefine = __w_pdfjs_require__(29);
  10653. var shared = __w_pdfjs_require__(36);
  10654. var sharedKey = __w_pdfjs_require__(35);
  10655. var hiddenKeys = __w_pdfjs_require__(39);
  10656. var uid = __w_pdfjs_require__(38);
  10657. var wellKnownSymbol = __w_pdfjs_require__(57);
  10658. var wrappedWellKnownSymbolModule = __w_pdfjs_require__(172);
  10659. var defineWellKnownSymbol = __w_pdfjs_require__(173);
  10660. var setToStringTag = __w_pdfjs_require__(85);
  10661. var InternalStateModule = __w_pdfjs_require__(33);
  10662. var $forEach = __w_pdfjs_require__(158).forEach;
  10663. var HIDDEN = sharedKey('hidden');
  10664. var SYMBOL = 'Symbol';
  10665. var PROTOTYPE = 'prototype';
  10666. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  10667. var setInternalState = InternalStateModule.set;
  10668. var getInternalState = InternalStateModule.getterFor(SYMBOL);
  10669. var ObjectPrototype = Object[PROTOTYPE];
  10670. var $Symbol = global.Symbol;
  10671. var $stringify = getBuiltIn('JSON', 'stringify');
  10672. var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  10673. var nativeDefineProperty = definePropertyModule.f;
  10674. var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
  10675. var nativePropertyIsEnumerable = propertyIsEnumerableModule.f;
  10676. var AllSymbols = shared('symbols');
  10677. var ObjectPrototypeSymbols = shared('op-symbols');
  10678. var StringToSymbolRegistry = shared('string-to-symbol-registry');
  10679. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  10680. var WellKnownSymbolsStore = shared('wks');
  10681. var QObject = global.QObject;
  10682. var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  10683. var setSymbolDescriptor = DESCRIPTORS && fails(function () {
  10684. return nativeObjectCreate(nativeDefineProperty({}, 'a', {
  10685. get: function () {
  10686. return nativeDefineProperty(this, 'a', { value: 7 }).a;
  10687. }
  10688. })).a != 7;
  10689. }) ? function (O, P, Attributes) {
  10690. var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);
  10691. if (ObjectPrototypeDescriptor)
  10692. delete ObjectPrototype[P];
  10693. nativeDefineProperty(O, P, Attributes);
  10694. if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {
  10695. nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);
  10696. }
  10697. } : nativeDefineProperty;
  10698. var wrap = function (tag, description) {
  10699. var symbol = AllSymbols[tag] = nativeObjectCreate($Symbol[PROTOTYPE]);
  10700. setInternalState(symbol, {
  10701. type: SYMBOL,
  10702. tag: tag,
  10703. description: description
  10704. });
  10705. if (!DESCRIPTORS)
  10706. symbol.description = description;
  10707. return symbol;
  10708. };
  10709. var isSymbol = USE_SYMBOL_AS_UID ? function (it) {
  10710. return typeof it == 'symbol';
  10711. } : function (it) {
  10712. return Object(it) instanceof $Symbol;
  10713. };
  10714. var $defineProperty = function defineProperty(O, P, Attributes) {
  10715. if (O === ObjectPrototype)
  10716. $defineProperty(ObjectPrototypeSymbols, P, Attributes);
  10717. anObject(O);
  10718. var key = toPrimitive(P, true);
  10719. anObject(Attributes);
  10720. if (has(AllSymbols, key)) {
  10721. if (!Attributes.enumerable) {
  10722. if (!has(O, HIDDEN))
  10723. nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));
  10724. O[HIDDEN][key] = true;
  10725. } else {
  10726. if (has(O, HIDDEN) && O[HIDDEN][key])
  10727. O[HIDDEN][key] = false;
  10728. Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });
  10729. }
  10730. return setSymbolDescriptor(O, key, Attributes);
  10731. }
  10732. return nativeDefineProperty(O, key, Attributes);
  10733. };
  10734. var $defineProperties = function defineProperties(O, Properties) {
  10735. anObject(O);
  10736. var properties = toIndexedObject(Properties);
  10737. var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
  10738. $forEach(keys, function (key) {
  10739. if (!DESCRIPTORS || $propertyIsEnumerable.call(properties, key))
  10740. $defineProperty(O, key, properties[key]);
  10741. });
  10742. return O;
  10743. };
  10744. var $create = function create(O, Properties) {
  10745. return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);
  10746. };
  10747. var $propertyIsEnumerable = function propertyIsEnumerable(V) {
  10748. var P = toPrimitive(V, true);
  10749. var enumerable = nativePropertyIsEnumerable.call(this, P);
  10750. if (this === ObjectPrototype && has(AllSymbols, P) && !has(ObjectPrototypeSymbols, P))
  10751. return false;
  10752. return enumerable || !has(this, P) || !has(AllSymbols, P) || has(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true;
  10753. };
  10754. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
  10755. var it = toIndexedObject(O);
  10756. var key = toPrimitive(P, true);
  10757. if (it === ObjectPrototype && has(AllSymbols, key) && !has(ObjectPrototypeSymbols, key))
  10758. return;
  10759. var descriptor = nativeGetOwnPropertyDescriptor(it, key);
  10760. if (descriptor && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) {
  10761. descriptor.enumerable = true;
  10762. }
  10763. return descriptor;
  10764. };
  10765. var $getOwnPropertyNames = function getOwnPropertyNames(O) {
  10766. var names = nativeGetOwnPropertyNames(toIndexedObject(O));
  10767. var result = [];
  10768. $forEach(names, function (key) {
  10769. if (!has(AllSymbols, key) && !has(hiddenKeys, key))
  10770. result.push(key);
  10771. });
  10772. return result;
  10773. };
  10774. var $getOwnPropertySymbols = function getOwnPropertySymbols(O) {
  10775. var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
  10776. var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
  10777. var result = [];
  10778. $forEach(names, function (key) {
  10779. if (has(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || has(ObjectPrototype, key))) {
  10780. result.push(AllSymbols[key]);
  10781. }
  10782. });
  10783. return result;
  10784. };
  10785. if (!NATIVE_SYMBOL) {
  10786. $Symbol = function Symbol() {
  10787. if (this instanceof $Symbol)
  10788. throw TypeError('Symbol is not a constructor');
  10789. var description = !arguments.length || arguments[0] === undefined ? undefined : String(arguments[0]);
  10790. var tag = uid(description);
  10791. var setter = function (value) {
  10792. if (this === ObjectPrototype)
  10793. setter.call(ObjectPrototypeSymbols, value);
  10794. if (has(this, HIDDEN) && has(this[HIDDEN], tag))
  10795. this[HIDDEN][tag] = false;
  10796. setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
  10797. };
  10798. if (DESCRIPTORS && USE_SETTER)
  10799. setSymbolDescriptor(ObjectPrototype, tag, {
  10800. configurable: true,
  10801. set: setter
  10802. });
  10803. return wrap(tag, description);
  10804. };
  10805. redefine($Symbol[PROTOTYPE], 'toString', function toString() {
  10806. return getInternalState(this).tag;
  10807. });
  10808. redefine($Symbol, 'withoutSetter', function (description) {
  10809. return wrap(uid(description), description);
  10810. });
  10811. propertyIsEnumerableModule.f = $propertyIsEnumerable;
  10812. definePropertyModule.f = $defineProperty;
  10813. getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
  10814. getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
  10815. getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;
  10816. wrappedWellKnownSymbolModule.f = function (name) {
  10817. return wrap(wellKnownSymbol(name), name);
  10818. };
  10819. if (DESCRIPTORS) {
  10820. nativeDefineProperty($Symbol[PROTOTYPE], 'description', {
  10821. configurable: true,
  10822. get: function description() {
  10823. return getInternalState(this).description;
  10824. }
  10825. });
  10826. if (!IS_PURE) {
  10827. redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });
  10828. }
  10829. }
  10830. }
  10831. $({
  10832. global: true,
  10833. wrap: true,
  10834. forced: !NATIVE_SYMBOL,
  10835. sham: !NATIVE_SYMBOL
  10836. }, { Symbol: $Symbol });
  10837. $forEach(objectKeys(WellKnownSymbolsStore), function (name) {
  10838. defineWellKnownSymbol(name);
  10839. });
  10840. $({
  10841. target: SYMBOL,
  10842. stat: true,
  10843. forced: !NATIVE_SYMBOL
  10844. }, {
  10845. 'for': function (key) {
  10846. var string = String(key);
  10847. if (has(StringToSymbolRegistry, string))
  10848. return StringToSymbolRegistry[string];
  10849. var symbol = $Symbol(string);
  10850. StringToSymbolRegistry[string] = symbol;
  10851. SymbolToStringRegistry[symbol] = string;
  10852. return symbol;
  10853. },
  10854. keyFor: function keyFor(sym) {
  10855. if (!isSymbol(sym))
  10856. throw TypeError(sym + ' is not a symbol');
  10857. if (has(SymbolToStringRegistry, sym))
  10858. return SymbolToStringRegistry[sym];
  10859. },
  10860. useSetter: function () {
  10861. USE_SETTER = true;
  10862. },
  10863. useSimple: function () {
  10864. USE_SETTER = false;
  10865. }
  10866. });
  10867. $({
  10868. target: 'Object',
  10869. stat: true,
  10870. forced: !NATIVE_SYMBOL,
  10871. sham: !DESCRIPTORS
  10872. }, {
  10873. create: $create,
  10874. defineProperty: $defineProperty,
  10875. defineProperties: $defineProperties,
  10876. getOwnPropertyDescriptor: $getOwnPropertyDescriptor
  10877. });
  10878. $({
  10879. target: 'Object',
  10880. stat: true,
  10881. forced: !NATIVE_SYMBOL
  10882. }, {
  10883. getOwnPropertyNames: $getOwnPropertyNames,
  10884. getOwnPropertySymbols: $getOwnPropertySymbols
  10885. });
  10886. $({
  10887. target: 'Object',
  10888. stat: true,
  10889. forced: fails(function () {
  10890. getOwnPropertySymbolsModule.f(1);
  10891. })
  10892. }, {
  10893. getOwnPropertySymbols: function getOwnPropertySymbols(it) {
  10894. return getOwnPropertySymbolsModule.f(toObject(it));
  10895. }
  10896. });
  10897. if ($stringify) {
  10898. var FORCED_JSON_STRINGIFY = !NATIVE_SYMBOL || fails(function () {
  10899. var symbol = $Symbol();
  10900. return $stringify([symbol]) != '[null]' || $stringify({ a: symbol }) != '{}' || $stringify(Object(symbol)) != '{}';
  10901. });
  10902. $({
  10903. target: 'JSON',
  10904. stat: true,
  10905. forced: FORCED_JSON_STRINGIFY
  10906. }, {
  10907. stringify: function stringify(it, replacer, space) {
  10908. var args = [it];
  10909. var index = 1;
  10910. var $replacer;
  10911. while (arguments.length > index)
  10912. args.push(arguments[index++]);
  10913. $replacer = replacer;
  10914. if (!isObject(replacer) && it === undefined || isSymbol(it))
  10915. return;
  10916. if (!isArray(replacer))
  10917. replacer = function (key, value) {
  10918. if (typeof $replacer == 'function')
  10919. value = $replacer.call(this, key, value);
  10920. if (!isSymbol(value))
  10921. return value;
  10922. };
  10923. args[1] = replacer;
  10924. return $stringify.apply(null, args);
  10925. }
  10926. });
  10927. }
  10928. if (!$Symbol[PROTOTYPE][TO_PRIMITIVE]) {
  10929. createNonEnumerableProperty($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
  10930. }
  10931. setToStringTag($Symbol, SYMBOL);
  10932. hiddenKeys[HIDDEN] = true;
  10933. /***/ }),
  10934. /* 171 */
  10935. /***/ (function(module, exports, __w_pdfjs_require__) {
  10936. var toIndexedObject = __w_pdfjs_require__(17);
  10937. var nativeGetOwnPropertyNames = __w_pdfjs_require__(44).f;
  10938. var toString = {}.toString;
  10939. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : [];
  10940. var getWindowNames = function (it) {
  10941. try {
  10942. return nativeGetOwnPropertyNames(it);
  10943. } catch (error) {
  10944. return windowNames.slice();
  10945. }
  10946. };
  10947. module.exports.f = function getOwnPropertyNames(it) {
  10948. return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : nativeGetOwnPropertyNames(toIndexedObject(it));
  10949. };
  10950. /***/ }),
  10951. /* 172 */
  10952. /***/ (function(module, exports, __w_pdfjs_require__) {
  10953. var wellKnownSymbol = __w_pdfjs_require__(57);
  10954. exports.f = wellKnownSymbol;
  10955. /***/ }),
  10956. /* 173 */
  10957. /***/ (function(module, exports, __w_pdfjs_require__) {
  10958. var path = __w_pdfjs_require__(43);
  10959. var has = __w_pdfjs_require__(23);
  10960. var wrappedWellKnownSymbolModule = __w_pdfjs_require__(172);
  10961. var defineProperty = __w_pdfjs_require__(27).f;
  10962. module.exports = function (NAME) {
  10963. var Symbol = path.Symbol || (path.Symbol = {});
  10964. if (!has(Symbol, NAME))
  10965. defineProperty(Symbol, NAME, { value: wrappedWellKnownSymbolModule.f(NAME) });
  10966. };
  10967. /***/ }),
  10968. /* 174 */
  10969. /***/ (function(module, exports, __w_pdfjs_require__) {
  10970. var defineWellKnownSymbol = __w_pdfjs_require__(173);
  10971. defineWellKnownSymbol('asyncIterator');
  10972. /***/ }),
  10973. /* 175 */
  10974. /***/ (function(module, exports, __w_pdfjs_require__) {
  10975. "use strict";
  10976. var $ = __w_pdfjs_require__(10);
  10977. var DESCRIPTORS = __w_pdfjs_require__(13);
  10978. var global = __w_pdfjs_require__(11);
  10979. var has = __w_pdfjs_require__(23);
  10980. var isObject = __w_pdfjs_require__(22);
  10981. var defineProperty = __w_pdfjs_require__(27).f;
  10982. var copyConstructorProperties = __w_pdfjs_require__(40);
  10983. var NativeSymbol = global.Symbol;
  10984. if (DESCRIPTORS && typeof NativeSymbol == 'function' && (!('description' in NativeSymbol.prototype) || NativeSymbol().description !== undefined)) {
  10985. var EmptyStringDescriptionStore = {};
  10986. var SymbolWrapper = function Symbol() {
  10987. var description = arguments.length < 1 || arguments[0] === undefined ? undefined : String(arguments[0]);
  10988. var result = this instanceof SymbolWrapper ? new NativeSymbol(description) : description === undefined ? NativeSymbol() : NativeSymbol(description);
  10989. if (description === '')
  10990. EmptyStringDescriptionStore[result] = true;
  10991. return result;
  10992. };
  10993. copyConstructorProperties(SymbolWrapper, NativeSymbol);
  10994. var symbolPrototype = SymbolWrapper.prototype = NativeSymbol.prototype;
  10995. symbolPrototype.constructor = SymbolWrapper;
  10996. var symbolToString = symbolPrototype.toString;
  10997. var native = String(NativeSymbol('test')) == 'Symbol(test)';
  10998. var regexp = /^Symbol\((.*)\)[^)]+$/;
  10999. defineProperty(symbolPrototype, 'description', {
  11000. configurable: true,
  11001. get: function description() {
  11002. var symbol = isObject(this) ? this.valueOf() : this;
  11003. var string = symbolToString.call(symbol);
  11004. if (has(EmptyStringDescriptionStore, symbol))
  11005. return '';
  11006. var desc = native ? string.slice(7, -1) : string.replace(regexp, '$1');
  11007. return desc === '' ? undefined : desc;
  11008. }
  11009. });
  11010. $({
  11011. global: true,
  11012. forced: true
  11013. }, { Symbol: SymbolWrapper });
  11014. }
  11015. /***/ }),
  11016. /* 176 */
  11017. /***/ (function(module, exports, __w_pdfjs_require__) {
  11018. var defineWellKnownSymbol = __w_pdfjs_require__(173);
  11019. defineWellKnownSymbol('hasInstance');
  11020. /***/ }),
  11021. /* 177 */
  11022. /***/ (function(module, exports, __w_pdfjs_require__) {
  11023. var defineWellKnownSymbol = __w_pdfjs_require__(173);
  11024. defineWellKnownSymbol('isConcatSpreadable');
  11025. /***/ }),
  11026. /* 178 */
  11027. /***/ (function(module, exports, __w_pdfjs_require__) {
  11028. var defineWellKnownSymbol = __w_pdfjs_require__(173);
  11029. defineWellKnownSymbol('iterator');
  11030. /***/ }),
  11031. /* 179 */
  11032. /***/ (function(module, exports, __w_pdfjs_require__) {
  11033. var defineWellKnownSymbol = __w_pdfjs_require__(173);
  11034. defineWellKnownSymbol('match');
  11035. /***/ }),
  11036. /* 180 */
  11037. /***/ (function(module, exports, __w_pdfjs_require__) {
  11038. var defineWellKnownSymbol = __w_pdfjs_require__(173);
  11039. defineWellKnownSymbol('matchAll');
  11040. /***/ }),
  11041. /* 181 */
  11042. /***/ (function(module, exports, __w_pdfjs_require__) {
  11043. var defineWellKnownSymbol = __w_pdfjs_require__(173);
  11044. defineWellKnownSymbol('replace');
  11045. /***/ }),
  11046. /* 182 */
  11047. /***/ (function(module, exports, __w_pdfjs_require__) {
  11048. var defineWellKnownSymbol = __w_pdfjs_require__(173);
  11049. defineWellKnownSymbol('search');
  11050. /***/ }),
  11051. /* 183 */
  11052. /***/ (function(module, exports, __w_pdfjs_require__) {
  11053. var defineWellKnownSymbol = __w_pdfjs_require__(173);
  11054. defineWellKnownSymbol('species');
  11055. /***/ }),
  11056. /* 184 */
  11057. /***/ (function(module, exports, __w_pdfjs_require__) {
  11058. var defineWellKnownSymbol = __w_pdfjs_require__(173);
  11059. defineWellKnownSymbol('split');
  11060. /***/ }),
  11061. /* 185 */
  11062. /***/ (function(module, exports, __w_pdfjs_require__) {
  11063. var defineWellKnownSymbol = __w_pdfjs_require__(173);
  11064. defineWellKnownSymbol('toPrimitive');
  11065. /***/ }),
  11066. /* 186 */
  11067. /***/ (function(module, exports, __w_pdfjs_require__) {
  11068. var defineWellKnownSymbol = __w_pdfjs_require__(173);
  11069. defineWellKnownSymbol('toStringTag');
  11070. /***/ }),
  11071. /* 187 */
  11072. /***/ (function(module, exports, __w_pdfjs_require__) {
  11073. var defineWellKnownSymbol = __w_pdfjs_require__(173);
  11074. defineWellKnownSymbol('unscopables');
  11075. /***/ }),
  11076. /* 188 */
  11077. /***/ (function(module, exports, __w_pdfjs_require__) {
  11078. var setToStringTag = __w_pdfjs_require__(85);
  11079. setToStringTag(Math, 'Math', true);
  11080. /***/ }),
  11081. /* 189 */
  11082. /***/ (function(module, exports, __w_pdfjs_require__) {
  11083. var global = __w_pdfjs_require__(11);
  11084. var setToStringTag = __w_pdfjs_require__(85);
  11085. setToStringTag(global.JSON, 'JSON', true);
  11086. /***/ }),
  11087. /* 190 */
  11088. /***/ (function(module, exports, __w_pdfjs_require__) {
  11089. __w_pdfjs_require__(191);
  11090. var entryUnbind = __w_pdfjs_require__(61);
  11091. module.exports = entryUnbind('String', 'padStart');
  11092. /***/ }),
  11093. /* 191 */
  11094. /***/ (function(module, exports, __w_pdfjs_require__) {
  11095. "use strict";
  11096. var $ = __w_pdfjs_require__(10);
  11097. var $padStart = __w_pdfjs_require__(192).start;
  11098. var WEBKIT_BUG = __w_pdfjs_require__(194);
  11099. $({
  11100. target: 'String',
  11101. proto: true,
  11102. forced: WEBKIT_BUG
  11103. }, {
  11104. padStart: function padStart(maxLength) {
  11105. return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
  11106. }
  11107. });
  11108. /***/ }),
  11109. /* 192 */
  11110. /***/ (function(module, exports, __w_pdfjs_require__) {
  11111. var toLength = __w_pdfjs_require__(47);
  11112. var repeat = __w_pdfjs_require__(193);
  11113. var requireObjectCoercible = __w_pdfjs_require__(20);
  11114. var ceil = Math.ceil;
  11115. var createMethod = function (IS_END) {
  11116. return function ($this, maxLength, fillString) {
  11117. var S = String(requireObjectCoercible($this));
  11118. var stringLength = S.length;
  11119. var fillStr = fillString === undefined ? ' ' : String(fillString);
  11120. var intMaxLength = toLength(maxLength);
  11121. var fillLen, stringFiller;
  11122. if (intMaxLength <= stringLength || fillStr == '')
  11123. return S;
  11124. fillLen = intMaxLength - stringLength;
  11125. stringFiller = repeat.call(fillStr, ceil(fillLen / fillStr.length));
  11126. if (stringFiller.length > fillLen)
  11127. stringFiller = stringFiller.slice(0, fillLen);
  11128. return IS_END ? S + stringFiller : stringFiller + S;
  11129. };
  11130. };
  11131. module.exports = {
  11132. start: createMethod(false),
  11133. end: createMethod(true)
  11134. };
  11135. /***/ }),
  11136. /* 193 */
  11137. /***/ (function(module, exports, __w_pdfjs_require__) {
  11138. "use strict";
  11139. var toInteger = __w_pdfjs_require__(48);
  11140. var requireObjectCoercible = __w_pdfjs_require__(20);
  11141. module.exports = ''.repeat || function repeat(count) {
  11142. var str = String(requireObjectCoercible(this));
  11143. var result = '';
  11144. var n = toInteger(count);
  11145. if (n < 0 || n == Infinity)
  11146. throw RangeError('Wrong number of repetitions');
  11147. for (; n > 0; (n >>>= 1) && (str += str))
  11148. if (n & 1)
  11149. result += str;
  11150. return result;
  11151. };
  11152. /***/ }),
  11153. /* 194 */
  11154. /***/ (function(module, exports, __w_pdfjs_require__) {
  11155. var userAgent = __w_pdfjs_require__(129);
  11156. module.exports = /Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(userAgent);
  11157. /***/ }),
  11158. /* 195 */
  11159. /***/ (function(module, exports, __w_pdfjs_require__) {
  11160. __w_pdfjs_require__(196);
  11161. var entryUnbind = __w_pdfjs_require__(61);
  11162. module.exports = entryUnbind('String', 'padEnd');
  11163. /***/ }),
  11164. /* 196 */
  11165. /***/ (function(module, exports, __w_pdfjs_require__) {
  11166. "use strict";
  11167. var $ = __w_pdfjs_require__(10);
  11168. var $padEnd = __w_pdfjs_require__(192).end;
  11169. var WEBKIT_BUG = __w_pdfjs_require__(194);
  11170. $({
  11171. target: 'String',
  11172. proto: true,
  11173. forced: WEBKIT_BUG
  11174. }, {
  11175. padEnd: function padEnd(maxLength) {
  11176. return $padEnd(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
  11177. }
  11178. });
  11179. /***/ }),
  11180. /* 197 */
  11181. /***/ (function(module, exports, __w_pdfjs_require__) {
  11182. __w_pdfjs_require__(198);
  11183. var path = __w_pdfjs_require__(43);
  11184. module.exports = path.Object.values;
  11185. /***/ }),
  11186. /* 198 */
  11187. /***/ (function(module, exports, __w_pdfjs_require__) {
  11188. var $ = __w_pdfjs_require__(10);
  11189. var $values = __w_pdfjs_require__(199).values;
  11190. $({
  11191. target: 'Object',
  11192. stat: true
  11193. }, {
  11194. values: function values(O) {
  11195. return $values(O);
  11196. }
  11197. });
  11198. /***/ }),
  11199. /* 199 */
  11200. /***/ (function(module, exports, __w_pdfjs_require__) {
  11201. var DESCRIPTORS = __w_pdfjs_require__(13);
  11202. var objectKeys = __w_pdfjs_require__(73);
  11203. var toIndexedObject = __w_pdfjs_require__(17);
  11204. var propertyIsEnumerable = __w_pdfjs_require__(15).f;
  11205. var createMethod = function (TO_ENTRIES) {
  11206. return function (it) {
  11207. var O = toIndexedObject(it);
  11208. var keys = objectKeys(O);
  11209. var length = keys.length;
  11210. var i = 0;
  11211. var result = [];
  11212. var key;
  11213. while (length > i) {
  11214. key = keys[i++];
  11215. if (!DESCRIPTORS || propertyIsEnumerable.call(O, key)) {
  11216. result.push(TO_ENTRIES ? [
  11217. key,
  11218. O[key]
  11219. ] : O[key]);
  11220. }
  11221. }
  11222. return result;
  11223. };
  11224. };
  11225. module.exports = {
  11226. entries: createMethod(true),
  11227. values: createMethod(false)
  11228. };
  11229. /***/ }),
  11230. /* 200 */
  11231. /***/ (function(module, exports, __w_pdfjs_require__) {
  11232. __w_pdfjs_require__(201);
  11233. var path = __w_pdfjs_require__(43);
  11234. module.exports = path.Object.entries;
  11235. /***/ }),
  11236. /* 201 */
  11237. /***/ (function(module, exports, __w_pdfjs_require__) {
  11238. var $ = __w_pdfjs_require__(10);
  11239. var $entries = __w_pdfjs_require__(199).entries;
  11240. $({
  11241. target: 'Object',
  11242. stat: true
  11243. }, {
  11244. entries: function entries(O) {
  11245. return $entries(O);
  11246. }
  11247. });
  11248. /***/ }),
  11249. /* 202 */
  11250. /***/ (function(module, exports, __w_pdfjs_require__) {
  11251. "use strict";
  11252. Object.defineProperty(exports, "__esModule", {
  11253. value: true
  11254. });
  11255. exports.getDocument = getDocument;
  11256. exports.setPDFNetworkStreamFactory = setPDFNetworkStreamFactory;
  11257. exports.build = exports.version = exports.PDFPageProxy = exports.PDFDocumentProxy = exports.PDFWorker = exports.PDFDataRangeTransport = exports.LoopbackPort = void 0;
  11258. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(2));
  11259. var _util = __w_pdfjs_require__(5);
  11260. var _display_utils = __w_pdfjs_require__(1);
  11261. var _font_loader = __w_pdfjs_require__(203);
  11262. var _node_utils = __w_pdfjs_require__(204);
  11263. var _annotation_storage = __w_pdfjs_require__(205);
  11264. var _api_compatibility = __w_pdfjs_require__(206);
  11265. var _canvas = __w_pdfjs_require__(207);
  11266. var _worker_options = __w_pdfjs_require__(209);
  11267. var _is_node = __w_pdfjs_require__(7);
  11268. var _message_handler = __w_pdfjs_require__(210);
  11269. var _metadata = __w_pdfjs_require__(211);
  11270. var _optional_content_config = __w_pdfjs_require__(213);
  11271. var _transport_stream = __w_pdfjs_require__(214);
  11272. var _webgl = __w_pdfjs_require__(215);
  11273. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11274. 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); } }
  11275. 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); }); }; }
  11276. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  11277. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  11278. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
  11279. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  11280. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  11281. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11282. 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); } }
  11283. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11284. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  11285. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  11286. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  11287. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  11288. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  11289. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  11290. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11291. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  11292. var RENDERING_CANCELLED_TIMEOUT = 100;
  11293. var DefaultCanvasFactory = _is_node.isNodeJS ? _node_utils.NodeCanvasFactory : _display_utils.DOMCanvasFactory;
  11294. var DefaultCMapReaderFactory = _is_node.isNodeJS ? _node_utils.NodeCMapReaderFactory : _display_utils.DOMCMapReaderFactory;
  11295. var createPDFNetworkStream;
  11296. function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
  11297. createPDFNetworkStream = pdfNetworkStreamFactory;
  11298. }
  11299. function getDocument(src) {
  11300. var task = new PDFDocumentLoadingTask();
  11301. var source;
  11302. if (typeof src === "string") {
  11303. source = {
  11304. url: src
  11305. };
  11306. } else if ((0, _util.isArrayBuffer)(src)) {
  11307. source = {
  11308. data: src
  11309. };
  11310. } else if (src instanceof PDFDataRangeTransport) {
  11311. source = {
  11312. range: src
  11313. };
  11314. } else {
  11315. if (_typeof(src) !== "object") {
  11316. throw new Error("Invalid parameter in getDocument, " + "need either Uint8Array, string or a parameter object");
  11317. }
  11318. if (!src.url && !src.data && !src.range) {
  11319. throw new Error("Invalid parameter object: need either .data, .range or .url");
  11320. }
  11321. source = src;
  11322. }
  11323. var params = Object.create(null);
  11324. var rangeTransport = null,
  11325. worker = null;
  11326. for (var key in source) {
  11327. if (key === "url" && typeof window !== "undefined") {
  11328. params[key] = new URL(source[key], window.location).href;
  11329. continue;
  11330. } else if (key === "range") {
  11331. rangeTransport = source[key];
  11332. continue;
  11333. } else if (key === "worker") {
  11334. worker = source[key];
  11335. continue;
  11336. } else if (key === "data" && !(source[key] instanceof Uint8Array)) {
  11337. var pdfBytes = source[key];
  11338. if (typeof pdfBytes === "string") {
  11339. params[key] = (0, _util.stringToBytes)(pdfBytes);
  11340. } else if (_typeof(pdfBytes) === "object" && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  11341. params[key] = new Uint8Array(pdfBytes);
  11342. } else if ((0, _util.isArrayBuffer)(pdfBytes)) {
  11343. params[key] = new Uint8Array(pdfBytes);
  11344. } else {
  11345. throw new Error("Invalid PDF binary data: either typed array, " + "string or array-like object is expected in the " + "data property.");
  11346. }
  11347. continue;
  11348. }
  11349. params[key] = source[key];
  11350. }
  11351. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  11352. params.CMapReaderFactory = params.CMapReaderFactory || DefaultCMapReaderFactory;
  11353. params.ignoreErrors = params.stopAtErrors !== true;
  11354. params.fontExtraProperties = params.fontExtraProperties === true;
  11355. params.pdfBug = params.pdfBug === true;
  11356. if (!Number.isInteger(params.maxImageSize)) {
  11357. params.maxImageSize = -1;
  11358. }
  11359. if (typeof params.isEvalSupported !== "boolean") {
  11360. params.isEvalSupported = true;
  11361. }
  11362. if (typeof params.disableFontFace !== "boolean") {
  11363. params.disableFontFace = _api_compatibility.apiCompatibilityParams.disableFontFace || false;
  11364. }
  11365. if (typeof params.ownerDocument === "undefined") {
  11366. params.ownerDocument = globalThis.document;
  11367. }
  11368. if (typeof params.disableRange !== "boolean") {
  11369. params.disableRange = false;
  11370. }
  11371. if (typeof params.disableStream !== "boolean") {
  11372. params.disableStream = false;
  11373. }
  11374. if (typeof params.disableAutoFetch !== "boolean") {
  11375. params.disableAutoFetch = false;
  11376. }
  11377. (0, _util.setVerbosityLevel)(params.verbosity);
  11378. if (!worker) {
  11379. var workerParams = {
  11380. verbosity: params.verbosity,
  11381. port: _worker_options.GlobalWorkerOptions.workerPort
  11382. };
  11383. worker = workerParams.port ? PDFWorker.fromPort(workerParams) : new PDFWorker(workerParams);
  11384. task._worker = worker;
  11385. }
  11386. var docId = task.docId;
  11387. worker.promise.then(function () {
  11388. if (task.destroyed) {
  11389. throw new Error("Loading aborted");
  11390. }
  11391. var workerIdPromise = _fetchDocument(worker, params, rangeTransport, docId);
  11392. var networkStreamPromise = new Promise(function (resolve) {
  11393. var networkStream;
  11394. if (rangeTransport) {
  11395. networkStream = new _transport_stream.PDFDataTransportStream({
  11396. length: params.length,
  11397. initialData: params.initialData,
  11398. progressiveDone: params.progressiveDone,
  11399. disableRange: params.disableRange,
  11400. disableStream: params.disableStream
  11401. }, rangeTransport);
  11402. } else if (!params.data) {
  11403. networkStream = createPDFNetworkStream({
  11404. url: params.url,
  11405. length: params.length,
  11406. httpHeaders: params.httpHeaders,
  11407. withCredentials: params.withCredentials,
  11408. rangeChunkSize: params.rangeChunkSize,
  11409. disableRange: params.disableRange,
  11410. disableStream: params.disableStream
  11411. });
  11412. }
  11413. resolve(networkStream);
  11414. });
  11415. return Promise.all([workerIdPromise, networkStreamPromise]).then(function (_ref) {
  11416. var _ref2 = _slicedToArray(_ref, 2),
  11417. workerId = _ref2[0],
  11418. networkStream = _ref2[1];
  11419. if (task.destroyed) {
  11420. throw new Error("Loading aborted");
  11421. }
  11422. var messageHandler = new _message_handler.MessageHandler(docId, workerId, worker.port);
  11423. messageHandler.postMessageTransfers = worker.postMessageTransfers;
  11424. var transport = new WorkerTransport(messageHandler, task, networkStream, params);
  11425. task._transport = transport;
  11426. messageHandler.send("Ready", null);
  11427. });
  11428. })["catch"](task._capability.reject);
  11429. return task;
  11430. }
  11431. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  11432. if (worker.destroyed) {
  11433. return Promise.reject(new Error("Worker was destroyed"));
  11434. }
  11435. if (pdfDataRangeTransport) {
  11436. source.length = pdfDataRangeTransport.length;
  11437. source.initialData = pdfDataRangeTransport.initialData;
  11438. source.progressiveDone = pdfDataRangeTransport.progressiveDone;
  11439. }
  11440. return worker.messageHandler.sendWithPromise("GetDocRequest", {
  11441. docId: docId,
  11442. apiVersion: '2.6.347',
  11443. source: {
  11444. data: source.data,
  11445. url: source.url,
  11446. password: source.password,
  11447. disableAutoFetch: source.disableAutoFetch,
  11448. rangeChunkSize: source.rangeChunkSize,
  11449. length: source.length
  11450. },
  11451. maxImageSize: source.maxImageSize,
  11452. disableFontFace: source.disableFontFace,
  11453. postMessageTransfers: worker.postMessageTransfers,
  11454. docBaseUrl: source.docBaseUrl,
  11455. ignoreErrors: source.ignoreErrors,
  11456. isEvalSupported: source.isEvalSupported,
  11457. fontExtraProperties: source.fontExtraProperties
  11458. }).then(function (workerId) {
  11459. if (worker.destroyed) {
  11460. throw new Error("Worker was destroyed");
  11461. }
  11462. return workerId;
  11463. });
  11464. }
  11465. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  11466. var nextDocumentId = 0;
  11467. var PDFDocumentLoadingTask = /*#__PURE__*/function () {
  11468. function PDFDocumentLoadingTask() {
  11469. _classCallCheck(this, PDFDocumentLoadingTask);
  11470. this._capability = (0, _util.createPromiseCapability)();
  11471. this._transport = null;
  11472. this._worker = null;
  11473. this.docId = "d" + nextDocumentId++;
  11474. this.destroyed = false;
  11475. this.onPassword = null;
  11476. this.onProgress = null;
  11477. this.onUnsupportedFeature = null;
  11478. }
  11479. _createClass(PDFDocumentLoadingTask, [{
  11480. key: "destroy",
  11481. value: function destroy() {
  11482. var _this = this;
  11483. this.destroyed = true;
  11484. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  11485. return transportDestroyed.then(function () {
  11486. _this._transport = null;
  11487. if (_this._worker) {
  11488. _this._worker.destroy();
  11489. _this._worker = null;
  11490. }
  11491. });
  11492. }
  11493. }, {
  11494. key: "promise",
  11495. get: function get() {
  11496. return this._capability.promise;
  11497. }
  11498. }]);
  11499. return PDFDocumentLoadingTask;
  11500. }();
  11501. return PDFDocumentLoadingTask;
  11502. }();
  11503. var PDFDataRangeTransport = /*#__PURE__*/function () {
  11504. function PDFDataRangeTransport(length, initialData) {
  11505. var progressiveDone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  11506. _classCallCheck(this, PDFDataRangeTransport);
  11507. this.length = length;
  11508. this.initialData = initialData;
  11509. this.progressiveDone = progressiveDone;
  11510. this._rangeListeners = [];
  11511. this._progressListeners = [];
  11512. this._progressiveReadListeners = [];
  11513. this._progressiveDoneListeners = [];
  11514. this._readyCapability = (0, _util.createPromiseCapability)();
  11515. }
  11516. _createClass(PDFDataRangeTransport, [{
  11517. key: "addRangeListener",
  11518. value: function addRangeListener(listener) {
  11519. this._rangeListeners.push(listener);
  11520. }
  11521. }, {
  11522. key: "addProgressListener",
  11523. value: function addProgressListener(listener) {
  11524. this._progressListeners.push(listener);
  11525. }
  11526. }, {
  11527. key: "addProgressiveReadListener",
  11528. value: function addProgressiveReadListener(listener) {
  11529. this._progressiveReadListeners.push(listener);
  11530. }
  11531. }, {
  11532. key: "addProgressiveDoneListener",
  11533. value: function addProgressiveDoneListener(listener) {
  11534. this._progressiveDoneListeners.push(listener);
  11535. }
  11536. }, {
  11537. key: "onDataRange",
  11538. value: function onDataRange(begin, chunk) {
  11539. var _iterator = _createForOfIteratorHelper(this._rangeListeners),
  11540. _step;
  11541. try {
  11542. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11543. var listener = _step.value;
  11544. listener(begin, chunk);
  11545. }
  11546. } catch (err) {
  11547. _iterator.e(err);
  11548. } finally {
  11549. _iterator.f();
  11550. }
  11551. }
  11552. }, {
  11553. key: "onDataProgress",
  11554. value: function onDataProgress(loaded, total) {
  11555. var _this2 = this;
  11556. this._readyCapability.promise.then(function () {
  11557. var _iterator2 = _createForOfIteratorHelper(_this2._progressListeners),
  11558. _step2;
  11559. try {
  11560. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  11561. var listener = _step2.value;
  11562. listener(loaded, total);
  11563. }
  11564. } catch (err) {
  11565. _iterator2.e(err);
  11566. } finally {
  11567. _iterator2.f();
  11568. }
  11569. });
  11570. }
  11571. }, {
  11572. key: "onDataProgressiveRead",
  11573. value: function onDataProgressiveRead(chunk) {
  11574. var _this3 = this;
  11575. this._readyCapability.promise.then(function () {
  11576. var _iterator3 = _createForOfIteratorHelper(_this3._progressiveReadListeners),
  11577. _step3;
  11578. try {
  11579. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  11580. var listener = _step3.value;
  11581. listener(chunk);
  11582. }
  11583. } catch (err) {
  11584. _iterator3.e(err);
  11585. } finally {
  11586. _iterator3.f();
  11587. }
  11588. });
  11589. }
  11590. }, {
  11591. key: "onDataProgressiveDone",
  11592. value: function onDataProgressiveDone() {
  11593. var _this4 = this;
  11594. this._readyCapability.promise.then(function () {
  11595. var _iterator4 = _createForOfIteratorHelper(_this4._progressiveDoneListeners),
  11596. _step4;
  11597. try {
  11598. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  11599. var listener = _step4.value;
  11600. listener();
  11601. }
  11602. } catch (err) {
  11603. _iterator4.e(err);
  11604. } finally {
  11605. _iterator4.f();
  11606. }
  11607. });
  11608. }
  11609. }, {
  11610. key: "transportReady",
  11611. value: function transportReady() {
  11612. this._readyCapability.resolve();
  11613. }
  11614. }, {
  11615. key: "requestDataRange",
  11616. value: function requestDataRange(begin, end) {
  11617. (0, _util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange");
  11618. }
  11619. }, {
  11620. key: "abort",
  11621. value: function abort() {}
  11622. }]);
  11623. return PDFDataRangeTransport;
  11624. }();
  11625. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  11626. var PDFDocumentProxy = /*#__PURE__*/function () {
  11627. function PDFDocumentProxy(pdfInfo, transport) {
  11628. _classCallCheck(this, PDFDocumentProxy);
  11629. this._pdfInfo = pdfInfo;
  11630. this._transport = transport;
  11631. }
  11632. _createClass(PDFDocumentProxy, [{
  11633. key: "getPage",
  11634. value: function getPage(pageNumber) {
  11635. return this._transport.getPage(pageNumber);
  11636. }
  11637. }, {
  11638. key: "getPageIndex",
  11639. value: function getPageIndex(ref) {
  11640. return this._transport.getPageIndex(ref);
  11641. }
  11642. }, {
  11643. key: "getDestinations",
  11644. value: function getDestinations() {
  11645. return this._transport.getDestinations();
  11646. }
  11647. }, {
  11648. key: "getDestination",
  11649. value: function getDestination(id) {
  11650. return this._transport.getDestination(id);
  11651. }
  11652. }, {
  11653. key: "getPageLabels",
  11654. value: function getPageLabels() {
  11655. return this._transport.getPageLabels();
  11656. }
  11657. }, {
  11658. key: "getPageLayout",
  11659. value: function getPageLayout() {
  11660. return this._transport.getPageLayout();
  11661. }
  11662. }, {
  11663. key: "getPageMode",
  11664. value: function getPageMode() {
  11665. return this._transport.getPageMode();
  11666. }
  11667. }, {
  11668. key: "getViewerPreferences",
  11669. value: function getViewerPreferences() {
  11670. return this._transport.getViewerPreferences();
  11671. }
  11672. }, {
  11673. key: "getOpenAction",
  11674. value: function getOpenAction() {
  11675. return this._transport.getOpenAction();
  11676. }
  11677. }, {
  11678. key: "getAttachments",
  11679. value: function getAttachments() {
  11680. return this._transport.getAttachments();
  11681. }
  11682. }, {
  11683. key: "getJavaScript",
  11684. value: function getJavaScript() {
  11685. return this._transport.getJavaScript();
  11686. }
  11687. }, {
  11688. key: "getOutline",
  11689. value: function getOutline() {
  11690. return this._transport.getOutline();
  11691. }
  11692. }, {
  11693. key: "getOptionalContentConfig",
  11694. value: function getOptionalContentConfig() {
  11695. return this._transport.getOptionalContentConfig();
  11696. }
  11697. }, {
  11698. key: "getPermissions",
  11699. value: function getPermissions() {
  11700. return this._transport.getPermissions();
  11701. }
  11702. }, {
  11703. key: "getMetadata",
  11704. value: function getMetadata() {
  11705. return this._transport.getMetadata();
  11706. }
  11707. }, {
  11708. key: "getData",
  11709. value: function getData() {
  11710. return this._transport.getData();
  11711. }
  11712. }, {
  11713. key: "getDownloadInfo",
  11714. value: function getDownloadInfo() {
  11715. return this._transport.downloadInfoCapability.promise;
  11716. }
  11717. }, {
  11718. key: "getStats",
  11719. value: function getStats() {
  11720. return this._transport.getStats();
  11721. }
  11722. }, {
  11723. key: "cleanup",
  11724. value: function cleanup() {
  11725. return this._transport.startCleanup();
  11726. }
  11727. }, {
  11728. key: "destroy",
  11729. value: function destroy() {
  11730. return this.loadingTask.destroy();
  11731. }
  11732. }, {
  11733. key: "saveDocument",
  11734. value: function saveDocument(annotationStorage) {
  11735. return this._transport.saveDocument(annotationStorage);
  11736. }
  11737. }, {
  11738. key: "annotationStorage",
  11739. get: function get() {
  11740. return (0, _util.shadow)(this, "annotationStorage", new _annotation_storage.AnnotationStorage());
  11741. }
  11742. }, {
  11743. key: "numPages",
  11744. get: function get() {
  11745. return this._pdfInfo.numPages;
  11746. }
  11747. }, {
  11748. key: "fingerprint",
  11749. get: function get() {
  11750. return this._pdfInfo.fingerprint;
  11751. }
  11752. }, {
  11753. key: "loadingParams",
  11754. get: function get() {
  11755. return this._transport.loadingParams;
  11756. }
  11757. }, {
  11758. key: "loadingTask",
  11759. get: function get() {
  11760. return this._transport.loadingTask;
  11761. }
  11762. }]);
  11763. return PDFDocumentProxy;
  11764. }();
  11765. exports.PDFDocumentProxy = PDFDocumentProxy;
  11766. var PDFPageProxy = /*#__PURE__*/function () {
  11767. function PDFPageProxy(pageIndex, pageInfo, transport, ownerDocument) {
  11768. var pdfBug = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  11769. _classCallCheck(this, PDFPageProxy);
  11770. this._pageIndex = pageIndex;
  11771. this._pageInfo = pageInfo;
  11772. this._ownerDocument = ownerDocument;
  11773. this._transport = transport;
  11774. this._stats = pdfBug ? new _display_utils.StatTimer() : null;
  11775. this._pdfBug = pdfBug;
  11776. this.commonObjs = transport.commonObjs;
  11777. this.objs = new PDFObjects();
  11778. this.cleanupAfterRender = false;
  11779. this.pendingCleanup = false;
  11780. this._intentStates = new Map();
  11781. this.destroyed = false;
  11782. }
  11783. _createClass(PDFPageProxy, [{
  11784. key: "getViewport",
  11785. value: function getViewport() {
  11786. var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  11787. scale = _ref3.scale,
  11788. _ref3$rotation = _ref3.rotation,
  11789. rotation = _ref3$rotation === void 0 ? this.rotate : _ref3$rotation,
  11790. _ref3$offsetX = _ref3.offsetX,
  11791. offsetX = _ref3$offsetX === void 0 ? 0 : _ref3$offsetX,
  11792. _ref3$offsetY = _ref3.offsetY,
  11793. offsetY = _ref3$offsetY === void 0 ? 0 : _ref3$offsetY,
  11794. _ref3$dontFlip = _ref3.dontFlip,
  11795. dontFlip = _ref3$dontFlip === void 0 ? false : _ref3$dontFlip;
  11796. return new _display_utils.PageViewport({
  11797. viewBox: this.view,
  11798. scale: scale,
  11799. rotation: rotation,
  11800. offsetX: offsetX,
  11801. offsetY: offsetY,
  11802. dontFlip: dontFlip
  11803. });
  11804. }
  11805. }, {
  11806. key: "getAnnotations",
  11807. value: function getAnnotations() {
  11808. var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  11809. _ref4$intent = _ref4.intent,
  11810. intent = _ref4$intent === void 0 ? null : _ref4$intent;
  11811. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  11812. this.annotationsPromise = this._transport.getAnnotations(this._pageIndex, intent);
  11813. this.annotationsIntent = intent;
  11814. }
  11815. return this.annotationsPromise;
  11816. }
  11817. }, {
  11818. key: "render",
  11819. value: function render(_ref5) {
  11820. var _this5 = this;
  11821. var canvasContext = _ref5.canvasContext,
  11822. viewport = _ref5.viewport,
  11823. _ref5$intent = _ref5.intent,
  11824. intent = _ref5$intent === void 0 ? "display" : _ref5$intent,
  11825. _ref5$enableWebGL = _ref5.enableWebGL,
  11826. enableWebGL = _ref5$enableWebGL === void 0 ? false : _ref5$enableWebGL,
  11827. _ref5$renderInteracti = _ref5.renderInteractiveForms,
  11828. renderInteractiveForms = _ref5$renderInteracti === void 0 ? false : _ref5$renderInteracti,
  11829. _ref5$transform = _ref5.transform,
  11830. transform = _ref5$transform === void 0 ? null : _ref5$transform,
  11831. _ref5$imageLayer = _ref5.imageLayer,
  11832. imageLayer = _ref5$imageLayer === void 0 ? null : _ref5$imageLayer,
  11833. _ref5$canvasFactory = _ref5.canvasFactory,
  11834. canvasFactory = _ref5$canvasFactory === void 0 ? null : _ref5$canvasFactory,
  11835. _ref5$background = _ref5.background,
  11836. background = _ref5$background === void 0 ? null : _ref5$background,
  11837. _ref5$annotationStora = _ref5.annotationStorage,
  11838. annotationStorage = _ref5$annotationStora === void 0 ? null : _ref5$annotationStora,
  11839. _ref5$optionalContent = _ref5.optionalContentConfigPromise,
  11840. optionalContentConfigPromise = _ref5$optionalContent === void 0 ? null : _ref5$optionalContent;
  11841. if (this._stats) {
  11842. this._stats.time("Overall");
  11843. }
  11844. var renderingIntent = intent === "print" ? "print" : "display";
  11845. this.pendingCleanup = false;
  11846. if (!optionalContentConfigPromise) {
  11847. optionalContentConfigPromise = this._transport.getOptionalContentConfig();
  11848. }
  11849. var intentState = this._intentStates.get(renderingIntent);
  11850. if (!intentState) {
  11851. intentState = Object.create(null);
  11852. this._intentStates.set(renderingIntent, intentState);
  11853. }
  11854. if (intentState.streamReaderCancelTimeout) {
  11855. clearTimeout(intentState.streamReaderCancelTimeout);
  11856. intentState.streamReaderCancelTimeout = null;
  11857. }
  11858. var canvasFactoryInstance = canvasFactory || new DefaultCanvasFactory({
  11859. ownerDocument: this._ownerDocument
  11860. });
  11861. var webGLContext = new _webgl.WebGLContext({
  11862. enable: enableWebGL
  11863. });
  11864. if (!intentState.displayReadyCapability) {
  11865. intentState.displayReadyCapability = (0, _util.createPromiseCapability)();
  11866. intentState.operatorList = {
  11867. fnArray: [],
  11868. argsArray: [],
  11869. lastChunk: false
  11870. };
  11871. if (this._stats) {
  11872. this._stats.time("Page Request");
  11873. }
  11874. this._pumpOperatorList({
  11875. pageIndex: this._pageIndex,
  11876. intent: renderingIntent,
  11877. renderInteractiveForms: renderInteractiveForms === true,
  11878. annotationStorage: annotationStorage && annotationStorage.getAll() || null
  11879. });
  11880. }
  11881. var complete = function complete(error) {
  11882. var i = intentState.renderTasks.indexOf(internalRenderTask);
  11883. if (i >= 0) {
  11884. intentState.renderTasks.splice(i, 1);
  11885. }
  11886. if (_this5.cleanupAfterRender || renderingIntent === "print") {
  11887. _this5.pendingCleanup = true;
  11888. }
  11889. _this5._tryCleanup();
  11890. if (error) {
  11891. internalRenderTask.capability.reject(error);
  11892. _this5._abortOperatorList({
  11893. intentState: intentState,
  11894. reason: error
  11895. });
  11896. } else {
  11897. internalRenderTask.capability.resolve();
  11898. }
  11899. if (_this5._stats) {
  11900. _this5._stats.timeEnd("Rendering");
  11901. _this5._stats.timeEnd("Overall");
  11902. }
  11903. };
  11904. var internalRenderTask = new InternalRenderTask({
  11905. callback: complete,
  11906. params: {
  11907. canvasContext: canvasContext,
  11908. viewport: viewport,
  11909. transform: transform,
  11910. imageLayer: imageLayer,
  11911. background: background
  11912. },
  11913. objs: this.objs,
  11914. commonObjs: this.commonObjs,
  11915. operatorList: intentState.operatorList,
  11916. pageIndex: this._pageIndex,
  11917. canvasFactory: canvasFactoryInstance,
  11918. webGLContext: webGLContext,
  11919. useRequestAnimationFrame: renderingIntent !== "print",
  11920. pdfBug: this._pdfBug
  11921. });
  11922. if (!intentState.renderTasks) {
  11923. intentState.renderTasks = [];
  11924. }
  11925. intentState.renderTasks.push(internalRenderTask);
  11926. var renderTask = internalRenderTask.task;
  11927. Promise.all([intentState.displayReadyCapability.promise, optionalContentConfigPromise]).then(function (_ref6) {
  11928. var _ref7 = _slicedToArray(_ref6, 2),
  11929. transparency = _ref7[0],
  11930. optionalContentConfig = _ref7[1];
  11931. if (_this5.pendingCleanup) {
  11932. complete();
  11933. return;
  11934. }
  11935. if (_this5._stats) {
  11936. _this5._stats.time("Rendering");
  11937. }
  11938. internalRenderTask.initializeGraphics({
  11939. transparency: transparency,
  11940. optionalContentConfig: optionalContentConfig
  11941. });
  11942. internalRenderTask.operatorListChanged();
  11943. })["catch"](complete);
  11944. return renderTask;
  11945. }
  11946. }, {
  11947. key: "getOperatorList",
  11948. value: function getOperatorList() {
  11949. function operatorListChanged() {
  11950. if (intentState.operatorList.lastChunk) {
  11951. intentState.opListReadCapability.resolve(intentState.operatorList);
  11952. var i = intentState.renderTasks.indexOf(opListTask);
  11953. if (i >= 0) {
  11954. intentState.renderTasks.splice(i, 1);
  11955. }
  11956. }
  11957. }
  11958. var renderingIntent = "oplist";
  11959. var intentState = this._intentStates.get(renderingIntent);
  11960. if (!intentState) {
  11961. intentState = Object.create(null);
  11962. this._intentStates.set(renderingIntent, intentState);
  11963. }
  11964. var opListTask;
  11965. if (!intentState.opListReadCapability) {
  11966. opListTask = Object.create(null);
  11967. opListTask.operatorListChanged = operatorListChanged;
  11968. intentState.opListReadCapability = (0, _util.createPromiseCapability)();
  11969. intentState.renderTasks = [];
  11970. intentState.renderTasks.push(opListTask);
  11971. intentState.operatorList = {
  11972. fnArray: [],
  11973. argsArray: [],
  11974. lastChunk: false
  11975. };
  11976. if (this._stats) {
  11977. this._stats.time("Page Request");
  11978. }
  11979. this._pumpOperatorList({
  11980. pageIndex: this._pageIndex,
  11981. intent: renderingIntent
  11982. });
  11983. }
  11984. return intentState.opListReadCapability.promise;
  11985. }
  11986. }, {
  11987. key: "streamTextContent",
  11988. value: function streamTextContent() {
  11989. var _ref8 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  11990. _ref8$normalizeWhites = _ref8.normalizeWhitespace,
  11991. normalizeWhitespace = _ref8$normalizeWhites === void 0 ? false : _ref8$normalizeWhites,
  11992. _ref8$disableCombineT = _ref8.disableCombineTextItems,
  11993. disableCombineTextItems = _ref8$disableCombineT === void 0 ? false : _ref8$disableCombineT;
  11994. var TEXT_CONTENT_CHUNK_SIZE = 100;
  11995. return this._transport.messageHandler.sendWithStream("GetTextContent", {
  11996. pageIndex: this._pageIndex,
  11997. normalizeWhitespace: normalizeWhitespace === true,
  11998. combineTextItems: disableCombineTextItems !== true
  11999. }, {
  12000. highWaterMark: TEXT_CONTENT_CHUNK_SIZE,
  12001. size: function size(textContent) {
  12002. return textContent.items.length;
  12003. }
  12004. });
  12005. }
  12006. }, {
  12007. key: "getTextContent",
  12008. value: function getTextContent() {
  12009. var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12010. var readableStream = this.streamTextContent(params);
  12011. return new Promise(function (resolve, reject) {
  12012. function pump() {
  12013. reader.read().then(function (_ref9) {
  12014. var _textContent$items;
  12015. var value = _ref9.value,
  12016. done = _ref9.done;
  12017. if (done) {
  12018. resolve(textContent);
  12019. return;
  12020. }
  12021. Object.assign(textContent.styles, value.styles);
  12022. (_textContent$items = textContent.items).push.apply(_textContent$items, _toConsumableArray(value.items));
  12023. pump();
  12024. }, reject);
  12025. }
  12026. var reader = readableStream.getReader();
  12027. var textContent = {
  12028. items: [],
  12029. styles: Object.create(null)
  12030. };
  12031. pump();
  12032. });
  12033. }
  12034. }, {
  12035. key: "_destroy",
  12036. value: function _destroy() {
  12037. this.destroyed = true;
  12038. this._transport.pageCache[this._pageIndex] = null;
  12039. var waitOn = [];
  12040. var _iterator5 = _createForOfIteratorHelper(this._intentStates),
  12041. _step5;
  12042. try {
  12043. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  12044. var _step5$value = _slicedToArray(_step5.value, 2),
  12045. intent = _step5$value[0],
  12046. intentState = _step5$value[1];
  12047. this._abortOperatorList({
  12048. intentState: intentState,
  12049. reason: new Error("Page was destroyed."),
  12050. force: true
  12051. });
  12052. if (intent === "oplist") {
  12053. continue;
  12054. }
  12055. var _iterator6 = _createForOfIteratorHelper(intentState.renderTasks),
  12056. _step6;
  12057. try {
  12058. for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
  12059. var internalRenderTask = _step6.value;
  12060. waitOn.push(internalRenderTask.completed);
  12061. internalRenderTask.cancel();
  12062. }
  12063. } catch (err) {
  12064. _iterator6.e(err);
  12065. } finally {
  12066. _iterator6.f();
  12067. }
  12068. }
  12069. } catch (err) {
  12070. _iterator5.e(err);
  12071. } finally {
  12072. _iterator5.f();
  12073. }
  12074. this.objs.clear();
  12075. this.annotationsPromise = null;
  12076. this.pendingCleanup = false;
  12077. return Promise.all(waitOn);
  12078. }
  12079. }, {
  12080. key: "cleanup",
  12081. value: function cleanup() {
  12082. var resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12083. this.pendingCleanup = true;
  12084. return this._tryCleanup(resetStats);
  12085. }
  12086. }, {
  12087. key: "_tryCleanup",
  12088. value: function _tryCleanup() {
  12089. var resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12090. if (!this.pendingCleanup) {
  12091. return false;
  12092. }
  12093. var _iterator7 = _createForOfIteratorHelper(this._intentStates.values()),
  12094. _step7;
  12095. try {
  12096. for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
  12097. var _step7$value = _step7.value,
  12098. renderTasks = _step7$value.renderTasks,
  12099. operatorList = _step7$value.operatorList;
  12100. if (renderTasks.length !== 0 || !operatorList.lastChunk) {
  12101. return false;
  12102. }
  12103. }
  12104. } catch (err) {
  12105. _iterator7.e(err);
  12106. } finally {
  12107. _iterator7.f();
  12108. }
  12109. this._intentStates.clear();
  12110. this.objs.clear();
  12111. this.annotationsPromise = null;
  12112. if (resetStats && this._stats) {
  12113. this._stats = new _display_utils.StatTimer();
  12114. }
  12115. this.pendingCleanup = false;
  12116. return true;
  12117. }
  12118. }, {
  12119. key: "_startRenderPage",
  12120. value: function _startRenderPage(transparency, intent) {
  12121. var intentState = this._intentStates.get(intent);
  12122. if (!intentState) {
  12123. return;
  12124. }
  12125. if (this._stats) {
  12126. this._stats.timeEnd("Page Request");
  12127. }
  12128. if (intentState.displayReadyCapability) {
  12129. intentState.displayReadyCapability.resolve(transparency);
  12130. }
  12131. }
  12132. }, {
  12133. key: "_renderPageChunk",
  12134. value: function _renderPageChunk(operatorListChunk, intentState) {
  12135. for (var i = 0, ii = operatorListChunk.length; i < ii; i++) {
  12136. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  12137. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  12138. }
  12139. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  12140. for (var _i2 = 0; _i2 < intentState.renderTasks.length; _i2++) {
  12141. intentState.renderTasks[_i2].operatorListChanged();
  12142. }
  12143. if (operatorListChunk.lastChunk) {
  12144. this._tryCleanup();
  12145. }
  12146. }
  12147. }, {
  12148. key: "_pumpOperatorList",
  12149. value: function _pumpOperatorList(args) {
  12150. var _this6 = this;
  12151. (0, _util.assert)(args.intent, 'PDFPageProxy._pumpOperatorList: Expected "intent" argument.');
  12152. var readableStream = this._transport.messageHandler.sendWithStream("GetOperatorList", args);
  12153. var reader = readableStream.getReader();
  12154. var intentState = this._intentStates.get(args.intent);
  12155. intentState.streamReader = reader;
  12156. var pump = function pump() {
  12157. reader.read().then(function (_ref10) {
  12158. var value = _ref10.value,
  12159. done = _ref10.done;
  12160. if (done) {
  12161. intentState.streamReader = null;
  12162. return;
  12163. }
  12164. if (_this6._transport.destroyed) {
  12165. return;
  12166. }
  12167. _this6._renderPageChunk(value, intentState);
  12168. pump();
  12169. }, function (reason) {
  12170. intentState.streamReader = null;
  12171. if (_this6._transport.destroyed) {
  12172. return;
  12173. }
  12174. if (intentState.operatorList) {
  12175. intentState.operatorList.lastChunk = true;
  12176. for (var i = 0; i < intentState.renderTasks.length; i++) {
  12177. intentState.renderTasks[i].operatorListChanged();
  12178. }
  12179. _this6._tryCleanup();
  12180. }
  12181. if (intentState.displayReadyCapability) {
  12182. intentState.displayReadyCapability.reject(reason);
  12183. } else if (intentState.opListReadCapability) {
  12184. intentState.opListReadCapability.reject(reason);
  12185. } else {
  12186. throw reason;
  12187. }
  12188. });
  12189. };
  12190. pump();
  12191. }
  12192. }, {
  12193. key: "_abortOperatorList",
  12194. value: function _abortOperatorList(_ref11) {
  12195. var _this7 = this;
  12196. var intentState = _ref11.intentState,
  12197. reason = _ref11.reason,
  12198. _ref11$force = _ref11.force,
  12199. force = _ref11$force === void 0 ? false : _ref11$force;
  12200. (0, _util.assert)(reason instanceof Error || _typeof(reason) === "object" && reason !== null, 'PDFPageProxy._abortOperatorList: Expected "reason" argument.');
  12201. if (!intentState.streamReader) {
  12202. return;
  12203. }
  12204. if (!force) {
  12205. if (intentState.renderTasks.length !== 0) {
  12206. return;
  12207. }
  12208. if (reason instanceof _display_utils.RenderingCancelledException) {
  12209. intentState.streamReaderCancelTimeout = setTimeout(function () {
  12210. _this7._abortOperatorList({
  12211. intentState: intentState,
  12212. reason: reason,
  12213. force: true
  12214. });
  12215. intentState.streamReaderCancelTimeout = null;
  12216. }, RENDERING_CANCELLED_TIMEOUT);
  12217. return;
  12218. }
  12219. }
  12220. intentState.streamReader.cancel(new _util.AbortException(reason && reason.message));
  12221. intentState.streamReader = null;
  12222. if (this._transport.destroyed) {
  12223. return;
  12224. }
  12225. var _iterator8 = _createForOfIteratorHelper(this._intentStates),
  12226. _step8;
  12227. try {
  12228. for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
  12229. var _step8$value = _slicedToArray(_step8.value, 2),
  12230. intent = _step8$value[0],
  12231. curIntentState = _step8$value[1];
  12232. if (curIntentState === intentState) {
  12233. this._intentStates["delete"](intent);
  12234. break;
  12235. }
  12236. }
  12237. } catch (err) {
  12238. _iterator8.e(err);
  12239. } finally {
  12240. _iterator8.f();
  12241. }
  12242. this.cleanup();
  12243. }
  12244. }, {
  12245. key: "pageNumber",
  12246. get: function get() {
  12247. return this._pageIndex + 1;
  12248. }
  12249. }, {
  12250. key: "rotate",
  12251. get: function get() {
  12252. return this._pageInfo.rotate;
  12253. }
  12254. }, {
  12255. key: "ref",
  12256. get: function get() {
  12257. return this._pageInfo.ref;
  12258. }
  12259. }, {
  12260. key: "userUnit",
  12261. get: function get() {
  12262. return this._pageInfo.userUnit;
  12263. }
  12264. }, {
  12265. key: "view",
  12266. get: function get() {
  12267. return this._pageInfo.view;
  12268. }
  12269. }, {
  12270. key: "stats",
  12271. get: function get() {
  12272. return this._stats;
  12273. }
  12274. }]);
  12275. return PDFPageProxy;
  12276. }();
  12277. exports.PDFPageProxy = PDFPageProxy;
  12278. var LoopbackPort = /*#__PURE__*/function () {
  12279. function LoopbackPort() {
  12280. var defer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  12281. _classCallCheck(this, LoopbackPort);
  12282. this._listeners = [];
  12283. this._defer = defer;
  12284. this._deferred = Promise.resolve(undefined);
  12285. }
  12286. _createClass(LoopbackPort, [{
  12287. key: "postMessage",
  12288. value: function postMessage(obj, transfers) {
  12289. var _this8 = this;
  12290. function cloneValue(value) {
  12291. if (_typeof(value) !== "object" || value === null) {
  12292. return value;
  12293. }
  12294. if (cloned.has(value)) {
  12295. return cloned.get(value);
  12296. }
  12297. var buffer, result;
  12298. if ((buffer = value.buffer) && (0, _util.isArrayBuffer)(buffer)) {
  12299. var transferable = transfers && transfers.includes(buffer);
  12300. if (transferable) {
  12301. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  12302. } else {
  12303. result = new value.constructor(value);
  12304. }
  12305. cloned.set(value, result);
  12306. return result;
  12307. }
  12308. result = Array.isArray(value) ? [] : {};
  12309. cloned.set(value, result);
  12310. for (var i in value) {
  12311. var desc = void 0,
  12312. p = value;
  12313. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  12314. p = Object.getPrototypeOf(p);
  12315. }
  12316. if (typeof desc.value === "undefined") {
  12317. continue;
  12318. }
  12319. if (typeof desc.value === "function") {
  12320. if (value.hasOwnProperty && value.hasOwnProperty(i)) {
  12321. throw new Error("LoopbackPort.postMessage - cannot clone: ".concat(value[i]));
  12322. }
  12323. continue;
  12324. }
  12325. result[i] = cloneValue(desc.value);
  12326. }
  12327. return result;
  12328. }
  12329. if (!this._defer) {
  12330. this._listeners.forEach(function (listener) {
  12331. listener.call(_this8, {
  12332. data: obj
  12333. });
  12334. });
  12335. return;
  12336. }
  12337. var cloned = new WeakMap();
  12338. var e = {
  12339. data: cloneValue(obj)
  12340. };
  12341. this._deferred.then(function () {
  12342. _this8._listeners.forEach(function (listener) {
  12343. listener.call(_this8, e);
  12344. });
  12345. });
  12346. }
  12347. }, {
  12348. key: "addEventListener",
  12349. value: function addEventListener(name, listener) {
  12350. this._listeners.push(listener);
  12351. }
  12352. }, {
  12353. key: "removeEventListener",
  12354. value: function removeEventListener(name, listener) {
  12355. var i = this._listeners.indexOf(listener);
  12356. this._listeners.splice(i, 1);
  12357. }
  12358. }, {
  12359. key: "terminate",
  12360. value: function terminate() {
  12361. this._listeners.length = 0;
  12362. }
  12363. }]);
  12364. return LoopbackPort;
  12365. }();
  12366. exports.LoopbackPort = LoopbackPort;
  12367. var PDFWorker = function PDFWorkerClosure() {
  12368. var pdfWorkerPorts = new WeakMap();
  12369. var isWorkerDisabled = false;
  12370. var fallbackWorkerSrc;
  12371. var nextFakeWorkerId = 0;
  12372. var fakeWorkerCapability;
  12373. if (_is_node.isNodeJS && typeof require === "function") {
  12374. isWorkerDisabled = true;
  12375. fallbackWorkerSrc = "./pdf.worker.js";
  12376. } else if ((typeof document === "undefined" ? "undefined" : _typeof(document)) === "object" && "currentScript" in document) {
  12377. var pdfjsFilePath = document.currentScript && document.currentScript.src;
  12378. if (pdfjsFilePath) {
  12379. fallbackWorkerSrc = pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, ".worker$1$2");
  12380. }
  12381. }
  12382. function _getWorkerSrc() {
  12383. if (_worker_options.GlobalWorkerOptions.workerSrc) {
  12384. return _worker_options.GlobalWorkerOptions.workerSrc;
  12385. }
  12386. if (typeof fallbackWorkerSrc !== "undefined") {
  12387. if (!_is_node.isNodeJS) {
  12388. (0, _display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.');
  12389. }
  12390. return fallbackWorkerSrc;
  12391. }
  12392. throw new Error('No "GlobalWorkerOptions.workerSrc" specified.');
  12393. }
  12394. function getMainThreadWorkerMessageHandler() {
  12395. var mainWorkerMessageHandler;
  12396. try {
  12397. mainWorkerMessageHandler = globalThis.pdfjsWorker && globalThis.pdfjsWorker.WorkerMessageHandler;
  12398. } catch (ex) {}
  12399. return mainWorkerMessageHandler || null;
  12400. }
  12401. function setupFakeWorkerGlobal() {
  12402. if (fakeWorkerCapability) {
  12403. return fakeWorkerCapability.promise;
  12404. }
  12405. fakeWorkerCapability = (0, _util.createPromiseCapability)();
  12406. var loader = /*#__PURE__*/function () {
  12407. var _ref12 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  12408. var mainWorkerMessageHandler, worker;
  12409. return _regenerator["default"].wrap(function _callee$(_context) {
  12410. while (1) {
  12411. switch (_context.prev = _context.next) {
  12412. case 0:
  12413. mainWorkerMessageHandler = getMainThreadWorkerMessageHandler();
  12414. if (!mainWorkerMessageHandler) {
  12415. _context.next = 3;
  12416. break;
  12417. }
  12418. return _context.abrupt("return", mainWorkerMessageHandler);
  12419. case 3:
  12420. if (!(_is_node.isNodeJS && typeof require === "function")) {
  12421. _context.next = 6;
  12422. break;
  12423. }
  12424. worker = eval("require")(_getWorkerSrc());
  12425. return _context.abrupt("return", worker.WorkerMessageHandler);
  12426. case 6:
  12427. _context.next = 8;
  12428. return (0, _display_utils.loadScript)(_getWorkerSrc());
  12429. case 8:
  12430. return _context.abrupt("return", window.pdfjsWorker.WorkerMessageHandler);
  12431. case 9:
  12432. case "end":
  12433. return _context.stop();
  12434. }
  12435. }
  12436. }, _callee);
  12437. }));
  12438. return function loader() {
  12439. return _ref12.apply(this, arguments);
  12440. };
  12441. }();
  12442. loader().then(fakeWorkerCapability.resolve, fakeWorkerCapability.reject);
  12443. return fakeWorkerCapability.promise;
  12444. }
  12445. function createCDNWrapper(url) {
  12446. var wrapper = "importScripts('" + url + "');";
  12447. return URL.createObjectURL(new Blob([wrapper]));
  12448. }
  12449. var PDFWorker = /*#__PURE__*/function () {
  12450. function PDFWorker() {
  12451. var _ref13 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  12452. _ref13$name = _ref13.name,
  12453. name = _ref13$name === void 0 ? null : _ref13$name,
  12454. _ref13$port = _ref13.port,
  12455. port = _ref13$port === void 0 ? null : _ref13$port,
  12456. _ref13$verbosity = _ref13.verbosity,
  12457. verbosity = _ref13$verbosity === void 0 ? (0, _util.getVerbosityLevel)() : _ref13$verbosity;
  12458. _classCallCheck(this, PDFWorker);
  12459. if (port && pdfWorkerPorts.has(port)) {
  12460. throw new Error("Cannot use more than one PDFWorker per port");
  12461. }
  12462. this.name = name;
  12463. this.destroyed = false;
  12464. this.postMessageTransfers = true;
  12465. this.verbosity = verbosity;
  12466. this._readyCapability = (0, _util.createPromiseCapability)();
  12467. this._port = null;
  12468. this._webWorker = null;
  12469. this._messageHandler = null;
  12470. if (port) {
  12471. pdfWorkerPorts.set(port, this);
  12472. this._initializeFromPort(port);
  12473. return;
  12474. }
  12475. this._initialize();
  12476. }
  12477. _createClass(PDFWorker, [{
  12478. key: "_initializeFromPort",
  12479. value: function _initializeFromPort(port) {
  12480. this._port = port;
  12481. this._messageHandler = new _message_handler.MessageHandler("main", "worker", port);
  12482. this._messageHandler.on("ready", function () {});
  12483. this._readyCapability.resolve();
  12484. }
  12485. }, {
  12486. key: "_initialize",
  12487. value: function _initialize() {
  12488. var _this9 = this;
  12489. if (typeof Worker !== "undefined" && !isWorkerDisabled && !getMainThreadWorkerMessageHandler()) {
  12490. var workerSrc = _getWorkerSrc();
  12491. try {
  12492. if (!(0, _util.isSameOrigin)(window.location.href, workerSrc)) {
  12493. workerSrc = createCDNWrapper(new URL(workerSrc, window.location).href);
  12494. }
  12495. var worker = new Worker(workerSrc);
  12496. var messageHandler = new _message_handler.MessageHandler("main", "worker", worker);
  12497. var terminateEarly = function terminateEarly() {
  12498. worker.removeEventListener("error", onWorkerError);
  12499. messageHandler.destroy();
  12500. worker.terminate();
  12501. if (_this9.destroyed) {
  12502. _this9._readyCapability.reject(new Error("Worker was destroyed"));
  12503. } else {
  12504. _this9._setupFakeWorker();
  12505. }
  12506. };
  12507. var onWorkerError = function onWorkerError() {
  12508. if (!_this9._webWorker) {
  12509. terminateEarly();
  12510. }
  12511. };
  12512. worker.addEventListener("error", onWorkerError);
  12513. messageHandler.on("test", function (data) {
  12514. worker.removeEventListener("error", onWorkerError);
  12515. if (_this9.destroyed) {
  12516. terminateEarly();
  12517. return;
  12518. }
  12519. if (data) {
  12520. _this9._messageHandler = messageHandler;
  12521. _this9._port = worker;
  12522. _this9._webWorker = worker;
  12523. if (!data.supportTransfers) {
  12524. _this9.postMessageTransfers = false;
  12525. }
  12526. _this9._readyCapability.resolve();
  12527. messageHandler.send("configure", {
  12528. verbosity: _this9.verbosity
  12529. });
  12530. } else {
  12531. _this9._setupFakeWorker();
  12532. messageHandler.destroy();
  12533. worker.terminate();
  12534. }
  12535. });
  12536. messageHandler.on("ready", function (data) {
  12537. worker.removeEventListener("error", onWorkerError);
  12538. if (_this9.destroyed) {
  12539. terminateEarly();
  12540. return;
  12541. }
  12542. try {
  12543. sendTest();
  12544. } catch (e) {
  12545. _this9._setupFakeWorker();
  12546. }
  12547. });
  12548. var sendTest = function sendTest() {
  12549. var testObj = new Uint8Array([_this9.postMessageTransfers ? 255 : 0]);
  12550. try {
  12551. messageHandler.send("test", testObj, [testObj.buffer]);
  12552. } catch (ex) {
  12553. (0, _util.warn)("Cannot use postMessage transfers.");
  12554. testObj[0] = 0;
  12555. messageHandler.send("test", testObj);
  12556. }
  12557. };
  12558. sendTest();
  12559. return;
  12560. } catch (e) {
  12561. (0, _util.info)("The worker has been disabled.");
  12562. }
  12563. }
  12564. this._setupFakeWorker();
  12565. }
  12566. }, {
  12567. key: "_setupFakeWorker",
  12568. value: function _setupFakeWorker() {
  12569. var _this10 = this;
  12570. if (!isWorkerDisabled) {
  12571. (0, _util.warn)("Setting up fake worker.");
  12572. isWorkerDisabled = true;
  12573. }
  12574. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  12575. if (_this10.destroyed) {
  12576. _this10._readyCapability.reject(new Error("Worker was destroyed"));
  12577. return;
  12578. }
  12579. var port = new LoopbackPort();
  12580. _this10._port = port;
  12581. var id = "fake" + nextFakeWorkerId++;
  12582. var workerHandler = new _message_handler.MessageHandler(id + "_worker", id, port);
  12583. WorkerMessageHandler.setup(workerHandler, port);
  12584. var messageHandler = new _message_handler.MessageHandler(id, id + "_worker", port);
  12585. _this10._messageHandler = messageHandler;
  12586. _this10._readyCapability.resolve();
  12587. messageHandler.send("configure", {
  12588. verbosity: _this10.verbosity
  12589. });
  12590. })["catch"](function (reason) {
  12591. _this10._readyCapability.reject(new Error("Setting up fake worker failed: \"".concat(reason.message, "\".")));
  12592. });
  12593. }
  12594. }, {
  12595. key: "destroy",
  12596. value: function destroy() {
  12597. this.destroyed = true;
  12598. if (this._webWorker) {
  12599. this._webWorker.terminate();
  12600. this._webWorker = null;
  12601. }
  12602. pdfWorkerPorts["delete"](this._port);
  12603. this._port = null;
  12604. if (this._messageHandler) {
  12605. this._messageHandler.destroy();
  12606. this._messageHandler = null;
  12607. }
  12608. }
  12609. }, {
  12610. key: "promise",
  12611. get: function get() {
  12612. return this._readyCapability.promise;
  12613. }
  12614. }, {
  12615. key: "port",
  12616. get: function get() {
  12617. return this._port;
  12618. }
  12619. }, {
  12620. key: "messageHandler",
  12621. get: function get() {
  12622. return this._messageHandler;
  12623. }
  12624. }], [{
  12625. key: "fromPort",
  12626. value: function fromPort(params) {
  12627. if (!params || !params.port) {
  12628. throw new Error("PDFWorker.fromPort - invalid method signature.");
  12629. }
  12630. if (pdfWorkerPorts.has(params.port)) {
  12631. return pdfWorkerPorts.get(params.port);
  12632. }
  12633. return new PDFWorker(params);
  12634. }
  12635. }, {
  12636. key: "getWorkerSrc",
  12637. value: function getWorkerSrc() {
  12638. return _getWorkerSrc();
  12639. }
  12640. }]);
  12641. return PDFWorker;
  12642. }();
  12643. return PDFWorker;
  12644. }();
  12645. exports.PDFWorker = PDFWorker;
  12646. var WorkerTransport = /*#__PURE__*/function () {
  12647. function WorkerTransport(messageHandler, loadingTask, networkStream, params) {
  12648. _classCallCheck(this, WorkerTransport);
  12649. this.messageHandler = messageHandler;
  12650. this.loadingTask = loadingTask;
  12651. this.commonObjs = new PDFObjects();
  12652. this.fontLoader = new _font_loader.FontLoader({
  12653. docId: loadingTask.docId,
  12654. onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
  12655. ownerDocument: params.ownerDocument
  12656. });
  12657. this._params = params;
  12658. this.CMapReaderFactory = new params.CMapReaderFactory({
  12659. baseUrl: params.cMapUrl,
  12660. isCompressed: params.cMapPacked
  12661. });
  12662. this.destroyed = false;
  12663. this.destroyCapability = null;
  12664. this._passwordCapability = null;
  12665. this._networkStream = networkStream;
  12666. this._fullReader = null;
  12667. this._lastProgress = null;
  12668. this.pageCache = [];
  12669. this.pagePromises = [];
  12670. this.downloadInfoCapability = (0, _util.createPromiseCapability)();
  12671. this.setupMessageHandler();
  12672. }
  12673. _createClass(WorkerTransport, [{
  12674. key: "destroy",
  12675. value: function destroy() {
  12676. var _this11 = this;
  12677. if (this.destroyCapability) {
  12678. return this.destroyCapability.promise;
  12679. }
  12680. this.destroyed = true;
  12681. this.destroyCapability = (0, _util.createPromiseCapability)();
  12682. if (this._passwordCapability) {
  12683. this._passwordCapability.reject(new Error("Worker was destroyed during onPassword callback"));
  12684. }
  12685. var waitOn = [];
  12686. this.pageCache.forEach(function (page) {
  12687. if (page) {
  12688. waitOn.push(page._destroy());
  12689. }
  12690. });
  12691. this.pageCache.length = 0;
  12692. this.pagePromises.length = 0;
  12693. var terminated = this.messageHandler.sendWithPromise("Terminate", null);
  12694. waitOn.push(terminated);
  12695. Promise.all(waitOn).then(function () {
  12696. _this11.fontLoader.clear();
  12697. if (_this11._networkStream) {
  12698. _this11._networkStream.cancelAllRequests(new _util.AbortException("Worker was terminated."));
  12699. }
  12700. if (_this11.messageHandler) {
  12701. _this11.messageHandler.destroy();
  12702. _this11.messageHandler = null;
  12703. }
  12704. _this11.destroyCapability.resolve();
  12705. }, this.destroyCapability.reject);
  12706. return this.destroyCapability.promise;
  12707. }
  12708. }, {
  12709. key: "setupMessageHandler",
  12710. value: function setupMessageHandler() {
  12711. var _this12 = this;
  12712. var messageHandler = this.messageHandler,
  12713. loadingTask = this.loadingTask;
  12714. messageHandler.on("GetReader", function (data, sink) {
  12715. (0, _util.assert)(_this12._networkStream, "GetReader - no `IPDFStream` instance available.");
  12716. _this12._fullReader = _this12._networkStream.getFullReader();
  12717. _this12._fullReader.onProgress = function (evt) {
  12718. _this12._lastProgress = {
  12719. loaded: evt.loaded,
  12720. total: evt.total
  12721. };
  12722. };
  12723. sink.onPull = function () {
  12724. _this12._fullReader.read().then(function (_ref14) {
  12725. var value = _ref14.value,
  12726. done = _ref14.done;
  12727. if (done) {
  12728. sink.close();
  12729. return;
  12730. }
  12731. (0, _util.assert)((0, _util.isArrayBuffer)(value), "GetReader - expected an ArrayBuffer.");
  12732. sink.enqueue(new Uint8Array(value), 1, [value]);
  12733. })["catch"](function (reason) {
  12734. sink.error(reason);
  12735. });
  12736. };
  12737. sink.onCancel = function (reason) {
  12738. _this12._fullReader.cancel(reason);
  12739. sink.ready["catch"](function (readyReason) {
  12740. if (_this12.destroyed) {
  12741. return;
  12742. }
  12743. throw readyReason;
  12744. });
  12745. };
  12746. });
  12747. messageHandler.on("ReaderHeadersReady", function (data) {
  12748. var headersCapability = (0, _util.createPromiseCapability)();
  12749. var fullReader = _this12._fullReader;
  12750. fullReader.headersReady.then(function () {
  12751. if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) {
  12752. if (_this12._lastProgress && loadingTask.onProgress) {
  12753. loadingTask.onProgress(_this12._lastProgress);
  12754. }
  12755. fullReader.onProgress = function (evt) {
  12756. if (loadingTask.onProgress) {
  12757. loadingTask.onProgress({
  12758. loaded: evt.loaded,
  12759. total: evt.total
  12760. });
  12761. }
  12762. };
  12763. }
  12764. headersCapability.resolve({
  12765. isStreamingSupported: fullReader.isStreamingSupported,
  12766. isRangeSupported: fullReader.isRangeSupported,
  12767. contentLength: fullReader.contentLength
  12768. });
  12769. }, headersCapability.reject);
  12770. return headersCapability.promise;
  12771. });
  12772. messageHandler.on("GetRangeReader", function (data, sink) {
  12773. (0, _util.assert)(_this12._networkStream, "GetRangeReader - no `IPDFStream` instance available.");
  12774. var rangeReader = _this12._networkStream.getRangeReader(data.begin, data.end);
  12775. if (!rangeReader) {
  12776. sink.close();
  12777. return;
  12778. }
  12779. sink.onPull = function () {
  12780. rangeReader.read().then(function (_ref15) {
  12781. var value = _ref15.value,
  12782. done = _ref15.done;
  12783. if (done) {
  12784. sink.close();
  12785. return;
  12786. }
  12787. (0, _util.assert)((0, _util.isArrayBuffer)(value), "GetRangeReader - expected an ArrayBuffer.");
  12788. sink.enqueue(new Uint8Array(value), 1, [value]);
  12789. })["catch"](function (reason) {
  12790. sink.error(reason);
  12791. });
  12792. };
  12793. sink.onCancel = function (reason) {
  12794. rangeReader.cancel(reason);
  12795. sink.ready["catch"](function (readyReason) {
  12796. if (_this12.destroyed) {
  12797. return;
  12798. }
  12799. throw readyReason;
  12800. });
  12801. };
  12802. });
  12803. messageHandler.on("GetDoc", function (_ref16) {
  12804. var pdfInfo = _ref16.pdfInfo;
  12805. _this12._numPages = pdfInfo.numPages;
  12806. loadingTask._capability.resolve(new PDFDocumentProxy(pdfInfo, _this12));
  12807. });
  12808. messageHandler.on("DocException", function (ex) {
  12809. var reason;
  12810. switch (ex.name) {
  12811. case "PasswordException":
  12812. reason = new _util.PasswordException(ex.message, ex.code);
  12813. break;
  12814. case "InvalidPDFException":
  12815. reason = new _util.InvalidPDFException(ex.message);
  12816. break;
  12817. case "MissingPDFException":
  12818. reason = new _util.MissingPDFException(ex.message);
  12819. break;
  12820. case "UnexpectedResponseException":
  12821. reason = new _util.UnexpectedResponseException(ex.message, ex.status);
  12822. break;
  12823. case "UnknownErrorException":
  12824. reason = new _util.UnknownErrorException(ex.message, ex.details);
  12825. break;
  12826. }
  12827. if (!(reason instanceof Error)) {
  12828. var msg = "DocException - expected a valid Error.";
  12829. (0, _util.warn)(msg);
  12830. }
  12831. loadingTask._capability.reject(reason);
  12832. });
  12833. messageHandler.on("PasswordRequest", function (exception) {
  12834. _this12._passwordCapability = (0, _util.createPromiseCapability)();
  12835. if (loadingTask.onPassword) {
  12836. var updatePassword = function updatePassword(password) {
  12837. _this12._passwordCapability.resolve({
  12838. password: password
  12839. });
  12840. };
  12841. try {
  12842. loadingTask.onPassword(updatePassword, exception.code);
  12843. } catch (ex) {
  12844. _this12._passwordCapability.reject(ex);
  12845. }
  12846. } else {
  12847. _this12._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
  12848. }
  12849. return _this12._passwordCapability.promise;
  12850. });
  12851. messageHandler.on("DataLoaded", function (data) {
  12852. if (loadingTask.onProgress) {
  12853. loadingTask.onProgress({
  12854. loaded: data.length,
  12855. total: data.length
  12856. });
  12857. }
  12858. _this12.downloadInfoCapability.resolve(data);
  12859. });
  12860. messageHandler.on("StartRenderPage", function (data) {
  12861. if (_this12.destroyed) {
  12862. return;
  12863. }
  12864. var page = _this12.pageCache[data.pageIndex];
  12865. page._startRenderPage(data.transparency, data.intent);
  12866. });
  12867. messageHandler.on("commonobj", function (data) {
  12868. if (_this12.destroyed) {
  12869. return;
  12870. }
  12871. var _data = _slicedToArray(data, 3),
  12872. id = _data[0],
  12873. type = _data[1],
  12874. exportedData = _data[2];
  12875. if (_this12.commonObjs.has(id)) {
  12876. return;
  12877. }
  12878. switch (type) {
  12879. case "Font":
  12880. var params = _this12._params;
  12881. if ("error" in exportedData) {
  12882. var exportedError = exportedData.error;
  12883. (0, _util.warn)("Error during font loading: ".concat(exportedError));
  12884. _this12.commonObjs.resolve(id, exportedError);
  12885. break;
  12886. }
  12887. var fontRegistry = null;
  12888. if (params.pdfBug && globalThis.FontInspector && globalThis.FontInspector.enabled) {
  12889. fontRegistry = {
  12890. registerFont: function registerFont(font, url) {
  12891. globalThis.FontInspector.fontAdded(font, url);
  12892. }
  12893. };
  12894. }
  12895. var font = new _font_loader.FontFaceObject(exportedData, {
  12896. isEvalSupported: params.isEvalSupported,
  12897. disableFontFace: params.disableFontFace,
  12898. ignoreErrors: params.ignoreErrors,
  12899. onUnsupportedFeature: _this12._onUnsupportedFeature.bind(_this12),
  12900. fontRegistry: fontRegistry
  12901. });
  12902. _this12.fontLoader.bind(font)["catch"](function (reason) {
  12903. return messageHandler.sendWithPromise("FontFallback", {
  12904. id: id
  12905. });
  12906. })["finally"](function () {
  12907. if (!params.fontExtraProperties && font.data) {
  12908. font.data = null;
  12909. }
  12910. _this12.commonObjs.resolve(id, font);
  12911. });
  12912. break;
  12913. case "FontPath":
  12914. case "Image":
  12915. _this12.commonObjs.resolve(id, exportedData);
  12916. break;
  12917. default:
  12918. throw new Error("Got unknown common object type ".concat(type));
  12919. }
  12920. });
  12921. messageHandler.on("obj", function (data) {
  12922. if (_this12.destroyed) {
  12923. return undefined;
  12924. }
  12925. var _data2 = _slicedToArray(data, 4),
  12926. id = _data2[0],
  12927. pageIndex = _data2[1],
  12928. type = _data2[2],
  12929. imageData = _data2[3];
  12930. var pageProxy = _this12.pageCache[pageIndex];
  12931. if (pageProxy.objs.has(id)) {
  12932. return undefined;
  12933. }
  12934. switch (type) {
  12935. case "Image":
  12936. pageProxy.objs.resolve(id, imageData);
  12937. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  12938. if (imageData && "data" in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  12939. pageProxy.cleanupAfterRender = true;
  12940. }
  12941. break;
  12942. default:
  12943. throw new Error("Got unknown object type ".concat(type));
  12944. }
  12945. return undefined;
  12946. });
  12947. messageHandler.on("DocProgress", function (data) {
  12948. if (_this12.destroyed) {
  12949. return;
  12950. }
  12951. if (loadingTask.onProgress) {
  12952. loadingTask.onProgress({
  12953. loaded: data.loaded,
  12954. total: data.total
  12955. });
  12956. }
  12957. });
  12958. messageHandler.on("UnsupportedFeature", this._onUnsupportedFeature.bind(this));
  12959. messageHandler.on("FetchBuiltInCMap", function (data, sink) {
  12960. if (_this12.destroyed) {
  12961. sink.error(new Error("Worker was destroyed"));
  12962. return;
  12963. }
  12964. var fetched = false;
  12965. sink.onPull = function () {
  12966. if (fetched) {
  12967. sink.close();
  12968. return;
  12969. }
  12970. fetched = true;
  12971. _this12.CMapReaderFactory.fetch(data).then(function (builtInCMap) {
  12972. sink.enqueue(builtInCMap, 1, [builtInCMap.cMapData.buffer]);
  12973. })["catch"](function (reason) {
  12974. sink.error(reason);
  12975. });
  12976. };
  12977. });
  12978. }
  12979. }, {
  12980. key: "_onUnsupportedFeature",
  12981. value: function _onUnsupportedFeature(_ref17) {
  12982. var featureId = _ref17.featureId;
  12983. if (this.destroyed) {
  12984. return;
  12985. }
  12986. if (this.loadingTask.onUnsupportedFeature) {
  12987. this.loadingTask.onUnsupportedFeature(featureId);
  12988. }
  12989. }
  12990. }, {
  12991. key: "getData",
  12992. value: function getData() {
  12993. return this.messageHandler.sendWithPromise("GetData", null);
  12994. }
  12995. }, {
  12996. key: "getPage",
  12997. value: function getPage(pageNumber) {
  12998. var _this13 = this;
  12999. if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this._numPages) {
  13000. return Promise.reject(new Error("Invalid page request"));
  13001. }
  13002. var pageIndex = pageNumber - 1;
  13003. if (pageIndex in this.pagePromises) {
  13004. return this.pagePromises[pageIndex];
  13005. }
  13006. var promise = this.messageHandler.sendWithPromise("GetPage", {
  13007. pageIndex: pageIndex
  13008. }).then(function (pageInfo) {
  13009. if (_this13.destroyed) {
  13010. throw new Error("Transport destroyed");
  13011. }
  13012. var page = new PDFPageProxy(pageIndex, pageInfo, _this13, _this13._params.ownerDocument, _this13._params.pdfBug);
  13013. _this13.pageCache[pageIndex] = page;
  13014. return page;
  13015. });
  13016. this.pagePromises[pageIndex] = promise;
  13017. return promise;
  13018. }
  13019. }, {
  13020. key: "getPageIndex",
  13021. value: function getPageIndex(ref) {
  13022. return this.messageHandler.sendWithPromise("GetPageIndex", {
  13023. ref: ref
  13024. })["catch"](function (reason) {
  13025. return Promise.reject(new Error(reason));
  13026. });
  13027. }
  13028. }, {
  13029. key: "getAnnotations",
  13030. value: function getAnnotations(pageIndex, intent) {
  13031. return this.messageHandler.sendWithPromise("GetAnnotations", {
  13032. pageIndex: pageIndex,
  13033. intent: intent
  13034. });
  13035. }
  13036. }, {
  13037. key: "saveDocument",
  13038. value: function saveDocument(annotationStorage) {
  13039. return this.messageHandler.sendWithPromise("SaveDocument", {
  13040. numPages: this._numPages,
  13041. annotationStorage: annotationStorage && annotationStorage.getAll() || null,
  13042. filename: this._fullReader ? this._fullReader.filename : null
  13043. })["finally"](function () {
  13044. if (annotationStorage) {
  13045. annotationStorage.resetModified();
  13046. }
  13047. });
  13048. }
  13049. }, {
  13050. key: "getDestinations",
  13051. value: function getDestinations() {
  13052. return this.messageHandler.sendWithPromise("GetDestinations", null);
  13053. }
  13054. }, {
  13055. key: "getDestination",
  13056. value: function getDestination(id) {
  13057. if (typeof id !== "string") {
  13058. return Promise.reject(new Error("Invalid destination request."));
  13059. }
  13060. return this.messageHandler.sendWithPromise("GetDestination", {
  13061. id: id
  13062. });
  13063. }
  13064. }, {
  13065. key: "getPageLabels",
  13066. value: function getPageLabels() {
  13067. return this.messageHandler.sendWithPromise("GetPageLabels", null);
  13068. }
  13069. }, {
  13070. key: "getPageLayout",
  13071. value: function getPageLayout() {
  13072. return this.messageHandler.sendWithPromise("GetPageLayout", null);
  13073. }
  13074. }, {
  13075. key: "getPageMode",
  13076. value: function getPageMode() {
  13077. return this.messageHandler.sendWithPromise("GetPageMode", null);
  13078. }
  13079. }, {
  13080. key: "getViewerPreferences",
  13081. value: function getViewerPreferences() {
  13082. return this.messageHandler.sendWithPromise("GetViewerPreferences", null);
  13083. }
  13084. }, {
  13085. key: "getOpenAction",
  13086. value: function getOpenAction() {
  13087. return this.messageHandler.sendWithPromise("GetOpenAction", null);
  13088. }
  13089. }, {
  13090. key: "getAttachments",
  13091. value: function getAttachments() {
  13092. return this.messageHandler.sendWithPromise("GetAttachments", null);
  13093. }
  13094. }, {
  13095. key: "getJavaScript",
  13096. value: function getJavaScript() {
  13097. return this.messageHandler.sendWithPromise("GetJavaScript", null);
  13098. }
  13099. }, {
  13100. key: "getOutline",
  13101. value: function getOutline() {
  13102. return this.messageHandler.sendWithPromise("GetOutline", null);
  13103. }
  13104. }, {
  13105. key: "getOptionalContentConfig",
  13106. value: function getOptionalContentConfig() {
  13107. return this.messageHandler.sendWithPromise("GetOptionalContentConfig", null).then(function (results) {
  13108. return new _optional_content_config.OptionalContentConfig(results);
  13109. });
  13110. }
  13111. }, {
  13112. key: "getPermissions",
  13113. value: function getPermissions() {
  13114. return this.messageHandler.sendWithPromise("GetPermissions", null);
  13115. }
  13116. }, {
  13117. key: "getMetadata",
  13118. value: function getMetadata() {
  13119. var _this14 = this;
  13120. return this.messageHandler.sendWithPromise("GetMetadata", null).then(function (results) {
  13121. return {
  13122. info: results[0],
  13123. metadata: results[1] ? new _metadata.Metadata(results[1]) : null,
  13124. contentDispositionFilename: _this14._fullReader ? _this14._fullReader.filename : null
  13125. };
  13126. });
  13127. }
  13128. }, {
  13129. key: "getStats",
  13130. value: function getStats() {
  13131. return this.messageHandler.sendWithPromise("GetStats", null);
  13132. }
  13133. }, {
  13134. key: "startCleanup",
  13135. value: function startCleanup() {
  13136. var _this15 = this;
  13137. return this.messageHandler.sendWithPromise("Cleanup", null).then(function () {
  13138. for (var i = 0, ii = _this15.pageCache.length; i < ii; i++) {
  13139. var page = _this15.pageCache[i];
  13140. if (page) {
  13141. var cleanupSuccessful = page.cleanup();
  13142. if (!cleanupSuccessful) {
  13143. throw new Error("startCleanup: Page ".concat(i + 1, " is currently rendering."));
  13144. }
  13145. }
  13146. }
  13147. _this15.commonObjs.clear();
  13148. _this15.fontLoader.clear();
  13149. });
  13150. }
  13151. }, {
  13152. key: "loadingParams",
  13153. get: function get() {
  13154. var params = this._params;
  13155. return (0, _util.shadow)(this, "loadingParams", {
  13156. disableAutoFetch: params.disableAutoFetch,
  13157. disableFontFace: params.disableFontFace
  13158. });
  13159. }
  13160. }]);
  13161. return WorkerTransport;
  13162. }();
  13163. var PDFObjects = /*#__PURE__*/function () {
  13164. function PDFObjects() {
  13165. _classCallCheck(this, PDFObjects);
  13166. this._objs = Object.create(null);
  13167. }
  13168. _createClass(PDFObjects, [{
  13169. key: "_ensureObj",
  13170. value: function _ensureObj(objId) {
  13171. if (this._objs[objId]) {
  13172. return this._objs[objId];
  13173. }
  13174. return this._objs[objId] = {
  13175. capability: (0, _util.createPromiseCapability)(),
  13176. data: null,
  13177. resolved: false
  13178. };
  13179. }
  13180. }, {
  13181. key: "get",
  13182. value: function get(objId) {
  13183. var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  13184. if (callback) {
  13185. this._ensureObj(objId).capability.promise.then(callback);
  13186. return null;
  13187. }
  13188. var obj = this._objs[objId];
  13189. if (!obj || !obj.resolved) {
  13190. throw new Error("Requesting object that isn't resolved yet ".concat(objId, "."));
  13191. }
  13192. return obj.data;
  13193. }
  13194. }, {
  13195. key: "has",
  13196. value: function has(objId) {
  13197. var obj = this._objs[objId];
  13198. return obj ? obj.resolved : false;
  13199. }
  13200. }, {
  13201. key: "resolve",
  13202. value: function resolve(objId, data) {
  13203. var obj = this._ensureObj(objId);
  13204. obj.resolved = true;
  13205. obj.data = data;
  13206. obj.capability.resolve(data);
  13207. }
  13208. }, {
  13209. key: "clear",
  13210. value: function clear() {
  13211. this._objs = Object.create(null);
  13212. }
  13213. }]);
  13214. return PDFObjects;
  13215. }();
  13216. var RenderTask = /*#__PURE__*/function () {
  13217. function RenderTask(internalRenderTask) {
  13218. _classCallCheck(this, RenderTask);
  13219. this._internalRenderTask = internalRenderTask;
  13220. this.onContinue = null;
  13221. }
  13222. _createClass(RenderTask, [{
  13223. key: "cancel",
  13224. value: function cancel() {
  13225. this._internalRenderTask.cancel();
  13226. }
  13227. }, {
  13228. key: "promise",
  13229. get: function get() {
  13230. return this._internalRenderTask.capability.promise;
  13231. }
  13232. }]);
  13233. return RenderTask;
  13234. }();
  13235. var InternalRenderTask = function InternalRenderTaskClosure() {
  13236. var canvasInRendering = new WeakSet();
  13237. var InternalRenderTask = /*#__PURE__*/function () {
  13238. function InternalRenderTask(_ref18) {
  13239. var callback = _ref18.callback,
  13240. params = _ref18.params,
  13241. objs = _ref18.objs,
  13242. commonObjs = _ref18.commonObjs,
  13243. operatorList = _ref18.operatorList,
  13244. pageIndex = _ref18.pageIndex,
  13245. canvasFactory = _ref18.canvasFactory,
  13246. webGLContext = _ref18.webGLContext,
  13247. _ref18$useRequestAnim = _ref18.useRequestAnimationFrame,
  13248. useRequestAnimationFrame = _ref18$useRequestAnim === void 0 ? false : _ref18$useRequestAnim,
  13249. _ref18$pdfBug = _ref18.pdfBug,
  13250. pdfBug = _ref18$pdfBug === void 0 ? false : _ref18$pdfBug;
  13251. _classCallCheck(this, InternalRenderTask);
  13252. this.callback = callback;
  13253. this.params = params;
  13254. this.objs = objs;
  13255. this.commonObjs = commonObjs;
  13256. this.operatorListIdx = null;
  13257. this.operatorList = operatorList;
  13258. this._pageIndex = pageIndex;
  13259. this.canvasFactory = canvasFactory;
  13260. this.webGLContext = webGLContext;
  13261. this._pdfBug = pdfBug;
  13262. this.running = false;
  13263. this.graphicsReadyCallback = null;
  13264. this.graphicsReady = false;
  13265. this._useRequestAnimationFrame = useRequestAnimationFrame === true && typeof window !== "undefined";
  13266. this.cancelled = false;
  13267. this.capability = (0, _util.createPromiseCapability)();
  13268. this.task = new RenderTask(this);
  13269. this._continueBound = this._continue.bind(this);
  13270. this._scheduleNextBound = this._scheduleNext.bind(this);
  13271. this._nextBound = this._next.bind(this);
  13272. this._canvas = params.canvasContext.canvas;
  13273. }
  13274. _createClass(InternalRenderTask, [{
  13275. key: "initializeGraphics",
  13276. value: function initializeGraphics(_ref19) {
  13277. var _ref19$transparency = _ref19.transparency,
  13278. transparency = _ref19$transparency === void 0 ? false : _ref19$transparency,
  13279. optionalContentConfig = _ref19.optionalContentConfig;
  13280. if (this.cancelled) {
  13281. return;
  13282. }
  13283. if (this._canvas) {
  13284. if (canvasInRendering.has(this._canvas)) {
  13285. throw new Error("Cannot use the same canvas during multiple render() operations. " + "Use different canvas or ensure previous operations were " + "cancelled or completed.");
  13286. }
  13287. canvasInRendering.add(this._canvas);
  13288. }
  13289. if (this._pdfBug && globalThis.StepperManager && globalThis.StepperManager.enabled) {
  13290. this.stepper = globalThis.StepperManager.create(this._pageIndex);
  13291. this.stepper.init(this.operatorList);
  13292. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  13293. }
  13294. var _this$params = this.params,
  13295. canvasContext = _this$params.canvasContext,
  13296. viewport = _this$params.viewport,
  13297. transform = _this$params.transform,
  13298. imageLayer = _this$params.imageLayer,
  13299. background = _this$params.background;
  13300. this.gfx = new _canvas.CanvasGraphics(canvasContext, this.commonObjs, this.objs, this.canvasFactory, this.webGLContext, imageLayer, optionalContentConfig);
  13301. this.gfx.beginDrawing({
  13302. transform: transform,
  13303. viewport: viewport,
  13304. transparency: transparency,
  13305. background: background
  13306. });
  13307. this.operatorListIdx = 0;
  13308. this.graphicsReady = true;
  13309. if (this.graphicsReadyCallback) {
  13310. this.graphicsReadyCallback();
  13311. }
  13312. }
  13313. }, {
  13314. key: "cancel",
  13315. value: function cancel() {
  13316. var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  13317. this.running = false;
  13318. this.cancelled = true;
  13319. if (this.gfx) {
  13320. this.gfx.endDrawing();
  13321. }
  13322. if (this._canvas) {
  13323. canvasInRendering["delete"](this._canvas);
  13324. }
  13325. this.callback(error || new _display_utils.RenderingCancelledException("Rendering cancelled, page ".concat(this._pageIndex + 1), "canvas"));
  13326. }
  13327. }, {
  13328. key: "operatorListChanged",
  13329. value: function operatorListChanged() {
  13330. if (!this.graphicsReady) {
  13331. if (!this.graphicsReadyCallback) {
  13332. this.graphicsReadyCallback = this._continueBound;
  13333. }
  13334. return;
  13335. }
  13336. if (this.stepper) {
  13337. this.stepper.updateOperatorList(this.operatorList);
  13338. }
  13339. if (this.running) {
  13340. return;
  13341. }
  13342. this._continue();
  13343. }
  13344. }, {
  13345. key: "_continue",
  13346. value: function _continue() {
  13347. this.running = true;
  13348. if (this.cancelled) {
  13349. return;
  13350. }
  13351. if (this.task.onContinue) {
  13352. this.task.onContinue(this._scheduleNextBound);
  13353. } else {
  13354. this._scheduleNext();
  13355. }
  13356. }
  13357. }, {
  13358. key: "_scheduleNext",
  13359. value: function _scheduleNext() {
  13360. var _this16 = this;
  13361. if (this._useRequestAnimationFrame) {
  13362. window.requestAnimationFrame(function () {
  13363. _this16._nextBound()["catch"](_this16.cancel.bind(_this16));
  13364. });
  13365. } else {
  13366. Promise.resolve().then(this._nextBound)["catch"](this.cancel.bind(this));
  13367. }
  13368. }
  13369. }, {
  13370. key: "_next",
  13371. value: function () {
  13372. var _next2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  13373. return _regenerator["default"].wrap(function _callee2$(_context2) {
  13374. while (1) {
  13375. switch (_context2.prev = _context2.next) {
  13376. case 0:
  13377. if (!this.cancelled) {
  13378. _context2.next = 2;
  13379. break;
  13380. }
  13381. return _context2.abrupt("return");
  13382. case 2:
  13383. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  13384. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  13385. this.running = false;
  13386. if (this.operatorList.lastChunk) {
  13387. this.gfx.endDrawing();
  13388. if (this._canvas) {
  13389. canvasInRendering["delete"](this._canvas);
  13390. }
  13391. this.callback();
  13392. }
  13393. }
  13394. case 4:
  13395. case "end":
  13396. return _context2.stop();
  13397. }
  13398. }
  13399. }, _callee2, this);
  13400. }));
  13401. function _next() {
  13402. return _next2.apply(this, arguments);
  13403. }
  13404. return _next;
  13405. }()
  13406. }, {
  13407. key: "completed",
  13408. get: function get() {
  13409. return this.capability.promise["catch"](function () {});
  13410. }
  13411. }]);
  13412. return InternalRenderTask;
  13413. }();
  13414. return InternalRenderTask;
  13415. }();
  13416. var version = '2.6.347';
  13417. exports.version = version;
  13418. var build = '3be9c65f';
  13419. exports.build = build;
  13420. /***/ }),
  13421. /* 203 */
  13422. /***/ (function(module, exports, __w_pdfjs_require__) {
  13423. "use strict";
  13424. Object.defineProperty(exports, "__esModule", {
  13425. value: true
  13426. });
  13427. exports.FontLoader = exports.FontFaceObject = void 0;
  13428. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(2));
  13429. var _util = __w_pdfjs_require__(5);
  13430. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13431. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13432. 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); }
  13433. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13434. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13435. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13436. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13437. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  13438. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13439. 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); } }
  13440. 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); }); }; }
  13441. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13442. 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); } }
  13443. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13444. var BaseFontLoader = /*#__PURE__*/function () {
  13445. function BaseFontLoader(_ref) {
  13446. var docId = _ref.docId,
  13447. onUnsupportedFeature = _ref.onUnsupportedFeature,
  13448. _ref$ownerDocument = _ref.ownerDocument,
  13449. ownerDocument = _ref$ownerDocument === void 0 ? globalThis.document : _ref$ownerDocument;
  13450. _classCallCheck(this, BaseFontLoader);
  13451. if (this.constructor === BaseFontLoader) {
  13452. (0, _util.unreachable)("Cannot initialize BaseFontLoader.");
  13453. }
  13454. this.docId = docId;
  13455. this._onUnsupportedFeature = onUnsupportedFeature;
  13456. this._document = ownerDocument;
  13457. this.nativeFontFaces = [];
  13458. this.styleElement = null;
  13459. }
  13460. _createClass(BaseFontLoader, [{
  13461. key: "addNativeFontFace",
  13462. value: function addNativeFontFace(nativeFontFace) {
  13463. this.nativeFontFaces.push(nativeFontFace);
  13464. this._document.fonts.add(nativeFontFace);
  13465. }
  13466. }, {
  13467. key: "insertRule",
  13468. value: function insertRule(rule) {
  13469. var styleElement = this.styleElement;
  13470. if (!styleElement) {
  13471. styleElement = this.styleElement = this._document.createElement("style");
  13472. styleElement.id = "PDFJS_FONT_STYLE_TAG_".concat(this.docId);
  13473. this._document.documentElement.getElementsByTagName("head")[0].appendChild(styleElement);
  13474. }
  13475. var styleSheet = styleElement.sheet;
  13476. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  13477. }
  13478. }, {
  13479. key: "clear",
  13480. value: function clear() {
  13481. var _this = this;
  13482. this.nativeFontFaces.forEach(function (nativeFontFace) {
  13483. _this._document.fonts["delete"](nativeFontFace);
  13484. });
  13485. this.nativeFontFaces.length = 0;
  13486. if (this.styleElement) {
  13487. this.styleElement.remove();
  13488. this.styleElement = null;
  13489. }
  13490. }
  13491. }, {
  13492. key: "bind",
  13493. value: function () {
  13494. var _bind = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(font) {
  13495. var _this2 = this;
  13496. var nativeFontFace, rule;
  13497. return _regenerator["default"].wrap(function _callee$(_context) {
  13498. while (1) {
  13499. switch (_context.prev = _context.next) {
  13500. case 0:
  13501. if (!(font.attached || font.missingFile)) {
  13502. _context.next = 2;
  13503. break;
  13504. }
  13505. return _context.abrupt("return");
  13506. case 2:
  13507. font.attached = true;
  13508. if (!this.isFontLoadingAPISupported) {
  13509. _context.next = 19;
  13510. break;
  13511. }
  13512. nativeFontFace = font.createNativeFontFace();
  13513. if (!nativeFontFace) {
  13514. _context.next = 18;
  13515. break;
  13516. }
  13517. this.addNativeFontFace(nativeFontFace);
  13518. _context.prev = 7;
  13519. _context.next = 10;
  13520. return nativeFontFace.loaded;
  13521. case 10:
  13522. _context.next = 18;
  13523. break;
  13524. case 12:
  13525. _context.prev = 12;
  13526. _context.t0 = _context["catch"](7);
  13527. this._onUnsupportedFeature({
  13528. featureId: _util.UNSUPPORTED_FEATURES.errorFontLoadNative
  13529. });
  13530. (0, _util.warn)("Failed to load font '".concat(nativeFontFace.family, "': '").concat(_context.t0, "'."));
  13531. font.disableFontFace = true;
  13532. throw _context.t0;
  13533. case 18:
  13534. return _context.abrupt("return");
  13535. case 19:
  13536. rule = font.createFontFaceRule();
  13537. if (!rule) {
  13538. _context.next = 26;
  13539. break;
  13540. }
  13541. this.insertRule(rule);
  13542. if (!this.isSyncFontLoadingSupported) {
  13543. _context.next = 24;
  13544. break;
  13545. }
  13546. return _context.abrupt("return");
  13547. case 24:
  13548. _context.next = 26;
  13549. return new Promise(function (resolve) {
  13550. var request = _this2._queueLoadingCallback(resolve);
  13551. _this2._prepareFontLoadEvent([rule], [font], request);
  13552. });
  13553. case 26:
  13554. case "end":
  13555. return _context.stop();
  13556. }
  13557. }
  13558. }, _callee, this, [[7, 12]]);
  13559. }));
  13560. function bind(_x) {
  13561. return _bind.apply(this, arguments);
  13562. }
  13563. return bind;
  13564. }()
  13565. }, {
  13566. key: "_queueLoadingCallback",
  13567. value: function _queueLoadingCallback(callback) {
  13568. (0, _util.unreachable)("Abstract method `_queueLoadingCallback`.");
  13569. }
  13570. }, {
  13571. key: "_prepareFontLoadEvent",
  13572. value: function _prepareFontLoadEvent(rules, fontsToLoad, request) {
  13573. (0, _util.unreachable)("Abstract method `_prepareFontLoadEvent`.");
  13574. }
  13575. }, {
  13576. key: "isFontLoadingAPISupported",
  13577. get: function get() {
  13578. var supported = typeof this._document !== "undefined" && !!this._document.fonts;
  13579. return (0, _util.shadow)(this, "isFontLoadingAPISupported", supported);
  13580. }
  13581. }, {
  13582. key: "isSyncFontLoadingSupported",
  13583. get: function get() {
  13584. (0, _util.unreachable)("Abstract method `isSyncFontLoadingSupported`.");
  13585. }
  13586. }, {
  13587. key: "_loadTestFont",
  13588. get: function get() {
  13589. (0, _util.unreachable)("Abstract method `_loadTestFont`.");
  13590. }
  13591. }]);
  13592. return BaseFontLoader;
  13593. }();
  13594. var FontLoader;
  13595. exports.FontLoader = FontLoader;
  13596. {
  13597. exports.FontLoader = FontLoader = /*#__PURE__*/function (_BaseFontLoader) {
  13598. _inherits(GenericFontLoader, _BaseFontLoader);
  13599. var _super = _createSuper(GenericFontLoader);
  13600. function GenericFontLoader(params) {
  13601. var _this3;
  13602. _classCallCheck(this, GenericFontLoader);
  13603. _this3 = _super.call(this, params);
  13604. _this3.loadingContext = {
  13605. requests: [],
  13606. nextRequestId: 0
  13607. };
  13608. _this3.loadTestFontId = 0;
  13609. return _this3;
  13610. }
  13611. _createClass(GenericFontLoader, [{
  13612. key: "_queueLoadingCallback",
  13613. value: function _queueLoadingCallback(callback) {
  13614. function completeRequest() {
  13615. (0, _util.assert)(!request.done, "completeRequest() cannot be called twice.");
  13616. request.done = true;
  13617. while (context.requests.length > 0 && context.requests[0].done) {
  13618. var otherRequest = context.requests.shift();
  13619. setTimeout(otherRequest.callback, 0);
  13620. }
  13621. }
  13622. var context = this.loadingContext;
  13623. var request = {
  13624. id: "pdfjs-font-loading-".concat(context.nextRequestId++),
  13625. done: false,
  13626. complete: completeRequest,
  13627. callback: callback
  13628. };
  13629. context.requests.push(request);
  13630. return request;
  13631. }
  13632. }, {
  13633. key: "_prepareFontLoadEvent",
  13634. value: function _prepareFontLoadEvent(rules, fonts, request) {
  13635. var _this4 = this;
  13636. function int32(data, offset) {
  13637. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  13638. }
  13639. function spliceString(s, offset, remove, insert) {
  13640. var chunk1 = s.substring(0, offset);
  13641. var chunk2 = s.substring(offset + remove);
  13642. return chunk1 + insert + chunk2;
  13643. }
  13644. var i, ii;
  13645. var canvas = this._document.createElement("canvas");
  13646. canvas.width = 1;
  13647. canvas.height = 1;
  13648. var ctx = canvas.getContext("2d");
  13649. var called = 0;
  13650. function isFontReady(name, callback) {
  13651. called++;
  13652. if (called > 30) {
  13653. (0, _util.warn)("Load test font never loaded.");
  13654. callback();
  13655. return;
  13656. }
  13657. ctx.font = "30px " + name;
  13658. ctx.fillText(".", 0, 20);
  13659. var imageData = ctx.getImageData(0, 0, 1, 1);
  13660. if (imageData.data[3] > 0) {
  13661. callback();
  13662. return;
  13663. }
  13664. setTimeout(isFontReady.bind(null, name, callback));
  13665. }
  13666. var loadTestFontId = "lt".concat(Date.now()).concat(this.loadTestFontId++);
  13667. var data = this._loadTestFont;
  13668. var COMMENT_OFFSET = 976;
  13669. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  13670. var CFF_CHECKSUM_OFFSET = 16;
  13671. var XXXX_VALUE = 0x58585858;
  13672. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  13673. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  13674. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  13675. }
  13676. if (i < loadTestFontId.length) {
  13677. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + "XXX", i) | 0;
  13678. }
  13679. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, (0, _util.string32)(checksum));
  13680. var url = "url(data:font/opentype;base64,".concat(btoa(data), ");");
  13681. var rule = "@font-face {font-family:\"".concat(loadTestFontId, "\";src:").concat(url, "}");
  13682. this.insertRule(rule);
  13683. var names = [];
  13684. for (i = 0, ii = fonts.length; i < ii; i++) {
  13685. names.push(fonts[i].loadedName);
  13686. }
  13687. names.push(loadTestFontId);
  13688. var div = this._document.createElement("div");
  13689. div.style.visibility = "hidden";
  13690. div.style.width = div.style.height = "10px";
  13691. div.style.position = "absolute";
  13692. div.style.top = div.style.left = "0px";
  13693. for (i = 0, ii = names.length; i < ii; ++i) {
  13694. var span = this._document.createElement("span");
  13695. span.textContent = "Hi";
  13696. span.style.fontFamily = names[i];
  13697. div.appendChild(span);
  13698. }
  13699. this._document.body.appendChild(div);
  13700. isFontReady(loadTestFontId, function () {
  13701. _this4._document.body.removeChild(div);
  13702. request.complete();
  13703. });
  13704. }
  13705. }, {
  13706. key: "isSyncFontLoadingSupported",
  13707. get: function get() {
  13708. var supported = false;
  13709. if (typeof navigator === "undefined") {
  13710. supported = true;
  13711. } else {
  13712. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  13713. if (m && m[1] >= 14) {
  13714. supported = true;
  13715. }
  13716. }
  13717. return (0, _util.shadow)(this, "isSyncFontLoadingSupported", supported);
  13718. }
  13719. }, {
  13720. key: "_loadTestFont",
  13721. get: function get() {
  13722. var getLoadTestFont = function getLoadTestFont() {
  13723. 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==");
  13724. };
  13725. return (0, _util.shadow)(this, "_loadTestFont", getLoadTestFont());
  13726. }
  13727. }]);
  13728. return GenericFontLoader;
  13729. }(BaseFontLoader);
  13730. }
  13731. var FontFaceObject = /*#__PURE__*/function () {
  13732. function FontFaceObject(translatedData, _ref2) {
  13733. var _ref2$isEvalSupported = _ref2.isEvalSupported,
  13734. isEvalSupported = _ref2$isEvalSupported === void 0 ? true : _ref2$isEvalSupported,
  13735. _ref2$disableFontFace = _ref2.disableFontFace,
  13736. disableFontFace = _ref2$disableFontFace === void 0 ? false : _ref2$disableFontFace,
  13737. _ref2$ignoreErrors = _ref2.ignoreErrors,
  13738. ignoreErrors = _ref2$ignoreErrors === void 0 ? false : _ref2$ignoreErrors,
  13739. _ref2$onUnsupportedFe = _ref2.onUnsupportedFeature,
  13740. onUnsupportedFeature = _ref2$onUnsupportedFe === void 0 ? null : _ref2$onUnsupportedFe,
  13741. _ref2$fontRegistry = _ref2.fontRegistry,
  13742. fontRegistry = _ref2$fontRegistry === void 0 ? null : _ref2$fontRegistry;
  13743. _classCallCheck(this, FontFaceObject);
  13744. this.compiledGlyphs = Object.create(null);
  13745. for (var i in translatedData) {
  13746. this[i] = translatedData[i];
  13747. }
  13748. this.isEvalSupported = isEvalSupported !== false;
  13749. this.disableFontFace = disableFontFace === true;
  13750. this.ignoreErrors = ignoreErrors === true;
  13751. this._onUnsupportedFeature = onUnsupportedFeature;
  13752. this.fontRegistry = fontRegistry;
  13753. }
  13754. _createClass(FontFaceObject, [{
  13755. key: "createNativeFontFace",
  13756. value: function createNativeFontFace() {
  13757. if (!this.data || this.disableFontFace) {
  13758. return null;
  13759. }
  13760. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  13761. if (this.fontRegistry) {
  13762. this.fontRegistry.registerFont(this);
  13763. }
  13764. return nativeFontFace;
  13765. }
  13766. }, {
  13767. key: "createFontFaceRule",
  13768. value: function createFontFaceRule() {
  13769. if (!this.data || this.disableFontFace) {
  13770. return null;
  13771. }
  13772. var data = (0, _util.bytesToString)(new Uint8Array(this.data));
  13773. var url = "url(data:".concat(this.mimetype, ";base64,").concat(btoa(data), ");");
  13774. var rule = "@font-face {font-family:\"".concat(this.loadedName, "\";src:").concat(url, "}");
  13775. if (this.fontRegistry) {
  13776. this.fontRegistry.registerFont(this, url);
  13777. }
  13778. return rule;
  13779. }
  13780. }, {
  13781. key: "getPathGenerator",
  13782. value: function getPathGenerator(objs, character) {
  13783. if (this.compiledGlyphs[character] !== undefined) {
  13784. return this.compiledGlyphs[character];
  13785. }
  13786. var cmds, current;
  13787. try {
  13788. cmds = objs.get(this.loadedName + "_path_" + character);
  13789. } catch (ex) {
  13790. if (!this.ignoreErrors) {
  13791. throw ex;
  13792. }
  13793. if (this._onUnsupportedFeature) {
  13794. this._onUnsupportedFeature({
  13795. featureId: _util.UNSUPPORTED_FEATURES.errorFontGetPath
  13796. });
  13797. }
  13798. (0, _util.warn)("getPathGenerator - ignoring character: \"".concat(ex, "\"."));
  13799. return this.compiledGlyphs[character] = function (c, size) {};
  13800. }
  13801. if (this.isEvalSupported && _util.IsEvalSupportedCached.value) {
  13802. var args,
  13803. js = "";
  13804. for (var i = 0, ii = cmds.length; i < ii; i++) {
  13805. current = cmds[i];
  13806. if (current.args !== undefined) {
  13807. args = current.args.join(",");
  13808. } else {
  13809. args = "";
  13810. }
  13811. js += "c." + current.cmd + "(" + args + ");\n";
  13812. }
  13813. return this.compiledGlyphs[character] = new Function("c", "size", js);
  13814. }
  13815. return this.compiledGlyphs[character] = function (c, size) {
  13816. for (var _i = 0, _ii = cmds.length; _i < _ii; _i++) {
  13817. current = cmds[_i];
  13818. if (current.cmd === "scale") {
  13819. current.args = [size, -size];
  13820. }
  13821. c[current.cmd].apply(c, current.args);
  13822. }
  13823. };
  13824. }
  13825. }]);
  13826. return FontFaceObject;
  13827. }();
  13828. exports.FontFaceObject = FontFaceObject;
  13829. /***/ }),
  13830. /* 204 */
  13831. /***/ (function(module, exports, __w_pdfjs_require__) {
  13832. "use strict";
  13833. Object.defineProperty(exports, "__esModule", {
  13834. value: true
  13835. });
  13836. exports.NodeCMapReaderFactory = exports.NodeCanvasFactory = void 0;
  13837. var _display_utils = __w_pdfjs_require__(1);
  13838. var _is_node = __w_pdfjs_require__(7);
  13839. var _util = __w_pdfjs_require__(5);
  13840. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13841. 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); } }
  13842. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13843. 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); }
  13844. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13845. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13846. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13847. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13848. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  13849. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13850. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13851. var NodeCanvasFactory = function NodeCanvasFactory() {
  13852. _classCallCheck(this, NodeCanvasFactory);
  13853. (0, _util.unreachable)("Not implemented: NodeCanvasFactory");
  13854. };
  13855. exports.NodeCanvasFactory = NodeCanvasFactory;
  13856. var NodeCMapReaderFactory = function NodeCMapReaderFactory() {
  13857. _classCallCheck(this, NodeCMapReaderFactory);
  13858. (0, _util.unreachable)("Not implemented: NodeCMapReaderFactory");
  13859. };
  13860. exports.NodeCMapReaderFactory = NodeCMapReaderFactory;
  13861. if (_is_node.isNodeJS) {
  13862. exports.NodeCanvasFactory = NodeCanvasFactory = /*#__PURE__*/function (_BaseCanvasFactory) {
  13863. _inherits(NodeCanvasFactory, _BaseCanvasFactory);
  13864. var _super = _createSuper(NodeCanvasFactory);
  13865. function NodeCanvasFactory() {
  13866. _classCallCheck(this, NodeCanvasFactory);
  13867. return _super.apply(this, arguments);
  13868. }
  13869. _createClass(NodeCanvasFactory, [{
  13870. key: "create",
  13871. value: function create(width, height) {
  13872. if (width <= 0 || height <= 0) {
  13873. throw new Error("Invalid canvas size");
  13874. }
  13875. var Canvas = require("canvas");
  13876. var canvas = Canvas.createCanvas(width, height);
  13877. return {
  13878. canvas: canvas,
  13879. context: canvas.getContext("2d")
  13880. };
  13881. }
  13882. }]);
  13883. return NodeCanvasFactory;
  13884. }(_display_utils.BaseCanvasFactory);
  13885. exports.NodeCMapReaderFactory = NodeCMapReaderFactory = /*#__PURE__*/function (_BaseCMapReaderFactor) {
  13886. _inherits(NodeCMapReaderFactory, _BaseCMapReaderFactor);
  13887. var _super2 = _createSuper(NodeCMapReaderFactory);
  13888. function NodeCMapReaderFactory() {
  13889. _classCallCheck(this, NodeCMapReaderFactory);
  13890. return _super2.apply(this, arguments);
  13891. }
  13892. _createClass(NodeCMapReaderFactory, [{
  13893. key: "_fetchData",
  13894. value: function _fetchData(url, compressionType) {
  13895. return new Promise(function (resolve, reject) {
  13896. var fs = require("fs");
  13897. fs.readFile(url, function (error, data) {
  13898. if (error || !data) {
  13899. reject(new Error(error));
  13900. return;
  13901. }
  13902. resolve({
  13903. cMapData: new Uint8Array(data),
  13904. compressionType: compressionType
  13905. });
  13906. });
  13907. });
  13908. }
  13909. }]);
  13910. return NodeCMapReaderFactory;
  13911. }(_display_utils.BaseCMapReaderFactory);
  13912. }
  13913. /***/ }),
  13914. /* 205 */
  13915. /***/ (function(module, exports, __w_pdfjs_require__) {
  13916. "use strict";
  13917. Object.defineProperty(exports, "__esModule", {
  13918. value: true
  13919. });
  13920. exports.AnnotationStorage = void 0;
  13921. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13922. 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); } }
  13923. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13924. var AnnotationStorage = /*#__PURE__*/function () {
  13925. function AnnotationStorage() {
  13926. _classCallCheck(this, AnnotationStorage);
  13927. this._storage = new Map();
  13928. this._modified = false;
  13929. this.onSetModified = null;
  13930. this.onResetModified = null;
  13931. }
  13932. _createClass(AnnotationStorage, [{
  13933. key: "getOrCreateValue",
  13934. value: function getOrCreateValue(key, defaultValue) {
  13935. if (this._storage.has(key)) {
  13936. return this._storage.get(key);
  13937. }
  13938. this._storage.set(key, defaultValue);
  13939. return defaultValue;
  13940. }
  13941. }, {
  13942. key: "setValue",
  13943. value: function setValue(key, value) {
  13944. if (this._storage.get(key) !== value) {
  13945. this._setModified();
  13946. }
  13947. this._storage.set(key, value);
  13948. }
  13949. }, {
  13950. key: "getAll",
  13951. value: function getAll() {
  13952. if (this._storage.size === 0) {
  13953. return null;
  13954. }
  13955. return Object.fromEntries(this._storage);
  13956. }
  13957. }, {
  13958. key: "_setModified",
  13959. value: function _setModified() {
  13960. if (!this._modified) {
  13961. this._modified = true;
  13962. if (typeof this.onSetModified === "function") {
  13963. this.onSetModified();
  13964. }
  13965. }
  13966. }
  13967. }, {
  13968. key: "resetModified",
  13969. value: function resetModified() {
  13970. if (this._modified) {
  13971. this._modified = false;
  13972. if (typeof this.onResetModified === "function") {
  13973. this.onResetModified();
  13974. }
  13975. }
  13976. }
  13977. }, {
  13978. key: "size",
  13979. get: function get() {
  13980. return this._storage.size;
  13981. }
  13982. }]);
  13983. return AnnotationStorage;
  13984. }();
  13985. exports.AnnotationStorage = AnnotationStorage;
  13986. /***/ }),
  13987. /* 206 */
  13988. /***/ (function(module, exports, __w_pdfjs_require__) {
  13989. "use strict";
  13990. Object.defineProperty(exports, "__esModule", {
  13991. value: true
  13992. });
  13993. exports.apiCompatibilityParams = void 0;
  13994. var _is_node = __w_pdfjs_require__(7);
  13995. var compatibilityParams = Object.create(null);
  13996. {
  13997. (function checkFontFace() {
  13998. if (_is_node.isNodeJS) {
  13999. compatibilityParams.disableFontFace = true;
  14000. }
  14001. })();
  14002. }
  14003. var apiCompatibilityParams = Object.freeze(compatibilityParams);
  14004. exports.apiCompatibilityParams = apiCompatibilityParams;
  14005. /***/ }),
  14006. /* 207 */
  14007. /***/ (function(module, exports, __w_pdfjs_require__) {
  14008. "use strict";
  14009. Object.defineProperty(exports, "__esModule", {
  14010. value: true
  14011. });
  14012. exports.CanvasGraphics = void 0;
  14013. var _util = __w_pdfjs_require__(5);
  14014. var _pattern_helper = __w_pdfjs_require__(208);
  14015. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  14016. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  14017. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  14018. var MIN_FONT_SIZE = 16;
  14019. var MAX_FONT_SIZE = 100;
  14020. var MAX_GROUP_SIZE = 4096;
  14021. var MIN_WIDTH_FACTOR = 0.65;
  14022. var COMPILE_TYPE3_GLYPHS = true;
  14023. var MAX_SIZE_TO_COMPILE = 1000;
  14024. var FULL_CHUNK_HEIGHT = 16;
  14025. function addContextCurrentTransform(ctx) {
  14026. if (!ctx.mozCurrentTransform) {
  14027. ctx._originalSave = ctx.save;
  14028. ctx._originalRestore = ctx.restore;
  14029. ctx._originalRotate = ctx.rotate;
  14030. ctx._originalScale = ctx.scale;
  14031. ctx._originalTranslate = ctx.translate;
  14032. ctx._originalTransform = ctx.transform;
  14033. ctx._originalSetTransform = ctx.setTransform;
  14034. ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0];
  14035. ctx._transformStack = [];
  14036. Object.defineProperty(ctx, "mozCurrentTransform", {
  14037. get: function getCurrentTransform() {
  14038. return this._transformMatrix;
  14039. }
  14040. });
  14041. Object.defineProperty(ctx, "mozCurrentTransformInverse", {
  14042. get: function getCurrentTransformInverse() {
  14043. var m = this._transformMatrix;
  14044. var a = m[0],
  14045. b = m[1],
  14046. c = m[2],
  14047. d = m[3],
  14048. e = m[4],
  14049. f = m[5];
  14050. var ad_bc = a * d - b * c;
  14051. var bc_ad = b * c - a * d;
  14052. 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];
  14053. }
  14054. });
  14055. ctx.save = function ctxSave() {
  14056. var old = this._transformMatrix;
  14057. this._transformStack.push(old);
  14058. this._transformMatrix = old.slice(0, 6);
  14059. this._originalSave();
  14060. };
  14061. ctx.restore = function ctxRestore() {
  14062. var prev = this._transformStack.pop();
  14063. if (prev) {
  14064. this._transformMatrix = prev;
  14065. this._originalRestore();
  14066. }
  14067. };
  14068. ctx.translate = function ctxTranslate(x, y) {
  14069. var m = this._transformMatrix;
  14070. m[4] = m[0] * x + m[2] * y + m[4];
  14071. m[5] = m[1] * x + m[3] * y + m[5];
  14072. this._originalTranslate(x, y);
  14073. };
  14074. ctx.scale = function ctxScale(x, y) {
  14075. var m = this._transformMatrix;
  14076. m[0] = m[0] * x;
  14077. m[1] = m[1] * x;
  14078. m[2] = m[2] * y;
  14079. m[3] = m[3] * y;
  14080. this._originalScale(x, y);
  14081. };
  14082. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  14083. var m = this._transformMatrix;
  14084. 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]];
  14085. ctx._originalTransform(a, b, c, d, e, f);
  14086. };
  14087. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  14088. this._transformMatrix = [a, b, c, d, e, f];
  14089. ctx._originalSetTransform(a, b, c, d, e, f);
  14090. };
  14091. ctx.rotate = function ctxRotate(angle) {
  14092. var cosValue = Math.cos(angle);
  14093. var sinValue = Math.sin(angle);
  14094. var m = this._transformMatrix;
  14095. 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]];
  14096. this._originalRotate(angle);
  14097. };
  14098. }
  14099. }
  14100. var CachedCanvases = function CachedCanvasesClosure() {
  14101. function CachedCanvases(canvasFactory) {
  14102. this.canvasFactory = canvasFactory;
  14103. this.cache = Object.create(null);
  14104. }
  14105. CachedCanvases.prototype = {
  14106. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  14107. var canvasEntry;
  14108. if (this.cache[id] !== undefined) {
  14109. canvasEntry = this.cache[id];
  14110. this.canvasFactory.reset(canvasEntry, width, height);
  14111. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  14112. } else {
  14113. canvasEntry = this.canvasFactory.create(width, height);
  14114. this.cache[id] = canvasEntry;
  14115. }
  14116. if (trackTransform) {
  14117. addContextCurrentTransform(canvasEntry.context);
  14118. }
  14119. return canvasEntry;
  14120. },
  14121. clear: function clear() {
  14122. for (var id in this.cache) {
  14123. var canvasEntry = this.cache[id];
  14124. this.canvasFactory.destroy(canvasEntry);
  14125. delete this.cache[id];
  14126. }
  14127. }
  14128. };
  14129. return CachedCanvases;
  14130. }();
  14131. function compileType3Glyph(imgData) {
  14132. var POINT_TO_PROCESS_LIMIT = 1000;
  14133. var width = imgData.width,
  14134. height = imgData.height;
  14135. var i,
  14136. j,
  14137. j0,
  14138. width1 = width + 1;
  14139. var points = new Uint8Array(width1 * (height + 1));
  14140. var POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]);
  14141. var lineSize = width + 7 & ~7,
  14142. data0 = imgData.data;
  14143. var data = new Uint8Array(lineSize * height),
  14144. pos = 0,
  14145. ii;
  14146. for (i = 0, ii = data0.length; i < ii; i++) {
  14147. var mask = 128,
  14148. elem = data0[i];
  14149. while (mask > 0) {
  14150. data[pos++] = elem & mask ? 0 : 255;
  14151. mask >>= 1;
  14152. }
  14153. }
  14154. var count = 0;
  14155. pos = 0;
  14156. if (data[pos] !== 0) {
  14157. points[0] = 1;
  14158. ++count;
  14159. }
  14160. for (j = 1; j < width; j++) {
  14161. if (data[pos] !== data[pos + 1]) {
  14162. points[j] = data[pos] ? 2 : 1;
  14163. ++count;
  14164. }
  14165. pos++;
  14166. }
  14167. if (data[pos] !== 0) {
  14168. points[j] = 2;
  14169. ++count;
  14170. }
  14171. for (i = 1; i < height; i++) {
  14172. pos = i * lineSize;
  14173. j0 = i * width1;
  14174. if (data[pos - lineSize] !== data[pos]) {
  14175. points[j0] = data[pos] ? 1 : 8;
  14176. ++count;
  14177. }
  14178. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  14179. for (j = 1; j < width; j++) {
  14180. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  14181. if (POINT_TYPES[sum]) {
  14182. points[j0 + j] = POINT_TYPES[sum];
  14183. ++count;
  14184. }
  14185. pos++;
  14186. }
  14187. if (data[pos - lineSize] !== data[pos]) {
  14188. points[j0 + j] = data[pos] ? 2 : 4;
  14189. ++count;
  14190. }
  14191. if (count > POINT_TO_PROCESS_LIMIT) {
  14192. return null;
  14193. }
  14194. }
  14195. pos = lineSize * (height - 1);
  14196. j0 = i * width1;
  14197. if (data[pos] !== 0) {
  14198. points[j0] = 8;
  14199. ++count;
  14200. }
  14201. for (j = 1; j < width; j++) {
  14202. if (data[pos] !== data[pos + 1]) {
  14203. points[j0 + j] = data[pos] ? 4 : 8;
  14204. ++count;
  14205. }
  14206. pos++;
  14207. }
  14208. if (data[pos] !== 0) {
  14209. points[j0 + j] = 4;
  14210. ++count;
  14211. }
  14212. if (count > POINT_TO_PROCESS_LIMIT) {
  14213. return null;
  14214. }
  14215. var steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
  14216. var outlines = [];
  14217. for (i = 0; count && i <= height; i++) {
  14218. var p = i * width1;
  14219. var end = p + width;
  14220. while (p < end && !points[p]) {
  14221. p++;
  14222. }
  14223. if (p === end) {
  14224. continue;
  14225. }
  14226. var coords = [p % width1, i];
  14227. var type = points[p],
  14228. p0 = p,
  14229. pp;
  14230. do {
  14231. var step = steps[type];
  14232. do {
  14233. p += step;
  14234. } while (!points[p]);
  14235. pp = points[p];
  14236. if (pp !== 5 && pp !== 10) {
  14237. type = pp;
  14238. points[p] = 0;
  14239. } else {
  14240. type = pp & 0x33 * type >> 4;
  14241. points[p] &= type >> 2 | type << 2;
  14242. }
  14243. coords.push(p % width1);
  14244. coords.push(p / width1 | 0);
  14245. if (!points[p]) {
  14246. --count;
  14247. }
  14248. } while (p0 !== p);
  14249. outlines.push(coords);
  14250. --i;
  14251. }
  14252. var drawOutline = function drawOutline(c) {
  14253. c.save();
  14254. c.scale(1 / width, -1 / height);
  14255. c.translate(0, -height);
  14256. c.beginPath();
  14257. for (var k = 0, kk = outlines.length; k < kk; k++) {
  14258. var o = outlines[k];
  14259. c.moveTo(o[0], o[1]);
  14260. for (var l = 2, ll = o.length; l < ll; l += 2) {
  14261. c.lineTo(o[l], o[l + 1]);
  14262. }
  14263. }
  14264. c.fill();
  14265. c.beginPath();
  14266. c.restore();
  14267. };
  14268. return drawOutline;
  14269. }
  14270. var CanvasExtraState = function CanvasExtraStateClosure() {
  14271. function CanvasExtraState() {
  14272. this.alphaIsShape = false;
  14273. this.fontSize = 0;
  14274. this.fontSizeScale = 1;
  14275. this.textMatrix = _util.IDENTITY_MATRIX;
  14276. this.textMatrixScale = 1;
  14277. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  14278. this.leading = 0;
  14279. this.x = 0;
  14280. this.y = 0;
  14281. this.lineX = 0;
  14282. this.lineY = 0;
  14283. this.charSpacing = 0;
  14284. this.wordSpacing = 0;
  14285. this.textHScale = 1;
  14286. this.textRenderingMode = _util.TextRenderingMode.FILL;
  14287. this.textRise = 0;
  14288. this.fillColor = "#000000";
  14289. this.strokeColor = "#000000";
  14290. this.patternFill = false;
  14291. this.fillAlpha = 1;
  14292. this.strokeAlpha = 1;
  14293. this.lineWidth = 1;
  14294. this.activeSMask = null;
  14295. this.resumeSMaskCtx = null;
  14296. this.transferMaps = null;
  14297. }
  14298. CanvasExtraState.prototype = {
  14299. clone: function CanvasExtraState_clone() {
  14300. return Object.create(this);
  14301. },
  14302. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  14303. this.x = x;
  14304. this.y = y;
  14305. }
  14306. };
  14307. return CanvasExtraState;
  14308. }();
  14309. var CanvasGraphics = function CanvasGraphicsClosure() {
  14310. var EXECUTION_TIME = 15;
  14311. var EXECUTION_STEPS = 10;
  14312. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, webGLContext, imageLayer, optionalContentConfig) {
  14313. this.ctx = canvasCtx;
  14314. this.current = new CanvasExtraState();
  14315. this.stateStack = [];
  14316. this.pendingClip = null;
  14317. this.pendingEOFill = false;
  14318. this.res = null;
  14319. this.xobjs = null;
  14320. this.commonObjs = commonObjs;
  14321. this.objs = objs;
  14322. this.canvasFactory = canvasFactory;
  14323. this.webGLContext = webGLContext;
  14324. this.imageLayer = imageLayer;
  14325. this.groupStack = [];
  14326. this.processingType3 = null;
  14327. this.baseTransform = null;
  14328. this.baseTransformStack = [];
  14329. this.groupLevel = 0;
  14330. this.smaskStack = [];
  14331. this.smaskCounter = 0;
  14332. this.tempSMask = null;
  14333. this.contentVisible = true;
  14334. this.markedContentStack = [];
  14335. this.optionalContentConfig = optionalContentConfig;
  14336. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  14337. if (canvasCtx) {
  14338. addContextCurrentTransform(canvasCtx);
  14339. }
  14340. this._cachedGetSinglePixelWidth = null;
  14341. }
  14342. function putBinaryImageData(ctx, imgData) {
  14343. var transferMaps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  14344. if (typeof ImageData !== "undefined" && imgData instanceof ImageData) {
  14345. ctx.putImageData(imgData, 0, 0);
  14346. return;
  14347. }
  14348. var height = imgData.height,
  14349. width = imgData.width;
  14350. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  14351. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  14352. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  14353. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  14354. var srcPos = 0,
  14355. destPos;
  14356. var src = imgData.data;
  14357. var dest = chunkImgData.data;
  14358. var i, j, thisChunkHeight, elemsInThisChunk;
  14359. var transferMapRed, transferMapGreen, transferMapBlue, transferMapGray;
  14360. if (transferMaps) {
  14361. switch (transferMaps.length) {
  14362. case 1:
  14363. transferMapRed = transferMaps[0];
  14364. transferMapGreen = transferMaps[0];
  14365. transferMapBlue = transferMaps[0];
  14366. transferMapGray = transferMaps[0];
  14367. break;
  14368. case 4:
  14369. transferMapRed = transferMaps[0];
  14370. transferMapGreen = transferMaps[1];
  14371. transferMapBlue = transferMaps[2];
  14372. transferMapGray = transferMaps[3];
  14373. break;
  14374. }
  14375. }
  14376. if (imgData.kind === _util.ImageKind.GRAYSCALE_1BPP) {
  14377. var srcLength = src.byteLength;
  14378. var dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
  14379. var dest32DataLength = dest32.length;
  14380. var fullSrcDiff = width + 7 >> 3;
  14381. var white = 0xffffffff;
  14382. var black = _util.IsLittleEndianCached.value ? 0xff000000 : 0x000000ff;
  14383. if (transferMapGray) {
  14384. if (transferMapGray[0] === 0xff && transferMapGray[0xff] === 0) {
  14385. var _ref = [black, white];
  14386. white = _ref[0];
  14387. black = _ref[1];
  14388. }
  14389. }
  14390. for (i = 0; i < totalChunks; i++) {
  14391. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  14392. destPos = 0;
  14393. for (j = 0; j < thisChunkHeight; j++) {
  14394. var srcDiff = srcLength - srcPos;
  14395. var k = 0;
  14396. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  14397. var kEndUnrolled = kEnd & ~7;
  14398. var mask = 0;
  14399. var srcByte = 0;
  14400. for (; k < kEndUnrolled; k += 8) {
  14401. srcByte = src[srcPos++];
  14402. dest32[destPos++] = srcByte & 128 ? white : black;
  14403. dest32[destPos++] = srcByte & 64 ? white : black;
  14404. dest32[destPos++] = srcByte & 32 ? white : black;
  14405. dest32[destPos++] = srcByte & 16 ? white : black;
  14406. dest32[destPos++] = srcByte & 8 ? white : black;
  14407. dest32[destPos++] = srcByte & 4 ? white : black;
  14408. dest32[destPos++] = srcByte & 2 ? white : black;
  14409. dest32[destPos++] = srcByte & 1 ? white : black;
  14410. }
  14411. for (; k < kEnd; k++) {
  14412. if (mask === 0) {
  14413. srcByte = src[srcPos++];
  14414. mask = 128;
  14415. }
  14416. dest32[destPos++] = srcByte & mask ? white : black;
  14417. mask >>= 1;
  14418. }
  14419. }
  14420. while (destPos < dest32DataLength) {
  14421. dest32[destPos++] = 0;
  14422. }
  14423. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  14424. }
  14425. } else if (imgData.kind === _util.ImageKind.RGBA_32BPP) {
  14426. var hasTransferMaps = !!(transferMapRed || transferMapGreen || transferMapBlue);
  14427. j = 0;
  14428. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  14429. for (i = 0; i < fullChunks; i++) {
  14430. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  14431. srcPos += elemsInThisChunk;
  14432. if (hasTransferMaps) {
  14433. for (var _k = 0; _k < elemsInThisChunk; _k += 4) {
  14434. if (transferMapRed) {
  14435. dest[_k + 0] = transferMapRed[dest[_k + 0]];
  14436. }
  14437. if (transferMapGreen) {
  14438. dest[_k + 1] = transferMapGreen[dest[_k + 1]];
  14439. }
  14440. if (transferMapBlue) {
  14441. dest[_k + 2] = transferMapBlue[dest[_k + 2]];
  14442. }
  14443. }
  14444. }
  14445. ctx.putImageData(chunkImgData, 0, j);
  14446. j += FULL_CHUNK_HEIGHT;
  14447. }
  14448. if (i < totalChunks) {
  14449. elemsInThisChunk = width * partialChunkHeight * 4;
  14450. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  14451. if (hasTransferMaps) {
  14452. for (var _k2 = 0; _k2 < elemsInThisChunk; _k2 += 4) {
  14453. if (transferMapRed) {
  14454. dest[_k2 + 0] = transferMapRed[dest[_k2 + 0]];
  14455. }
  14456. if (transferMapGreen) {
  14457. dest[_k2 + 1] = transferMapGreen[dest[_k2 + 1]];
  14458. }
  14459. if (transferMapBlue) {
  14460. dest[_k2 + 2] = transferMapBlue[dest[_k2 + 2]];
  14461. }
  14462. }
  14463. }
  14464. ctx.putImageData(chunkImgData, 0, j);
  14465. }
  14466. } else if (imgData.kind === _util.ImageKind.RGB_24BPP) {
  14467. var _hasTransferMaps = !!(transferMapRed || transferMapGreen || transferMapBlue);
  14468. thisChunkHeight = FULL_CHUNK_HEIGHT;
  14469. elemsInThisChunk = width * thisChunkHeight;
  14470. for (i = 0; i < totalChunks; i++) {
  14471. if (i >= fullChunks) {
  14472. thisChunkHeight = partialChunkHeight;
  14473. elemsInThisChunk = width * thisChunkHeight;
  14474. }
  14475. destPos = 0;
  14476. for (j = elemsInThisChunk; j--;) {
  14477. dest[destPos++] = src[srcPos++];
  14478. dest[destPos++] = src[srcPos++];
  14479. dest[destPos++] = src[srcPos++];
  14480. dest[destPos++] = 255;
  14481. }
  14482. if (_hasTransferMaps) {
  14483. for (var _k3 = 0; _k3 < destPos; _k3 += 4) {
  14484. if (transferMapRed) {
  14485. dest[_k3 + 0] = transferMapRed[dest[_k3 + 0]];
  14486. }
  14487. if (transferMapGreen) {
  14488. dest[_k3 + 1] = transferMapGreen[dest[_k3 + 1]];
  14489. }
  14490. if (transferMapBlue) {
  14491. dest[_k3 + 2] = transferMapBlue[dest[_k3 + 2]];
  14492. }
  14493. }
  14494. }
  14495. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  14496. }
  14497. } else {
  14498. throw new Error("bad image kind: ".concat(imgData.kind));
  14499. }
  14500. }
  14501. function putBinaryImageMask(ctx, imgData) {
  14502. var height = imgData.height,
  14503. width = imgData.width;
  14504. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  14505. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  14506. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  14507. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  14508. var srcPos = 0;
  14509. var src = imgData.data;
  14510. var dest = chunkImgData.data;
  14511. for (var i = 0; i < totalChunks; i++) {
  14512. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  14513. var destPos = 3;
  14514. for (var j = 0; j < thisChunkHeight; j++) {
  14515. var mask = 0;
  14516. for (var k = 0; k < width; k++) {
  14517. if (!mask) {
  14518. var elem = src[srcPos++];
  14519. mask = 128;
  14520. }
  14521. dest[destPos] = elem & mask ? 0 : 255;
  14522. destPos += 4;
  14523. mask >>= 1;
  14524. }
  14525. }
  14526. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  14527. }
  14528. }
  14529. function copyCtxState(sourceCtx, destCtx) {
  14530. var properties = ["strokeStyle", "fillStyle", "fillRule", "globalAlpha", "lineWidth", "lineCap", "lineJoin", "miterLimit", "globalCompositeOperation", "font"];
  14531. for (var i = 0, ii = properties.length; i < ii; i++) {
  14532. var property = properties[i];
  14533. if (sourceCtx[property] !== undefined) {
  14534. destCtx[property] = sourceCtx[property];
  14535. }
  14536. }
  14537. if (sourceCtx.setLineDash !== undefined) {
  14538. destCtx.setLineDash(sourceCtx.getLineDash());
  14539. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  14540. }
  14541. }
  14542. function resetCtxToDefault(ctx) {
  14543. ctx.strokeStyle = "#000000";
  14544. ctx.fillStyle = "#000000";
  14545. ctx.fillRule = "nonzero";
  14546. ctx.globalAlpha = 1;
  14547. ctx.lineWidth = 1;
  14548. ctx.lineCap = "butt";
  14549. ctx.lineJoin = "miter";
  14550. ctx.miterLimit = 10;
  14551. ctx.globalCompositeOperation = "source-over";
  14552. ctx.font = "10px sans-serif";
  14553. if (ctx.setLineDash !== undefined) {
  14554. ctx.setLineDash([]);
  14555. ctx.lineDashOffset = 0;
  14556. }
  14557. }
  14558. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  14559. var length = bytes.length;
  14560. for (var i = 3; i < length; i += 4) {
  14561. var alpha = bytes[i];
  14562. if (alpha === 0) {
  14563. bytes[i - 3] = r0;
  14564. bytes[i - 2] = g0;
  14565. bytes[i - 1] = b0;
  14566. } else if (alpha < 255) {
  14567. var alpha_ = 255 - alpha;
  14568. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  14569. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  14570. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  14571. }
  14572. }
  14573. }
  14574. function composeSMaskAlpha(maskData, layerData, transferMap) {
  14575. var length = maskData.length;
  14576. var scale = 1 / 255;
  14577. for (var i = 3; i < length; i += 4) {
  14578. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  14579. layerData[i] = layerData[i] * alpha * scale | 0;
  14580. }
  14581. }
  14582. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  14583. var length = maskData.length;
  14584. for (var i = 3; i < length; i += 4) {
  14585. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  14586. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  14587. }
  14588. }
  14589. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  14590. var hasBackdrop = !!backdrop;
  14591. var r0 = hasBackdrop ? backdrop[0] : 0;
  14592. var g0 = hasBackdrop ? backdrop[1] : 0;
  14593. var b0 = hasBackdrop ? backdrop[2] : 0;
  14594. var composeFn;
  14595. if (subtype === "Luminosity") {
  14596. composeFn = composeSMaskLuminosity;
  14597. } else {
  14598. composeFn = composeSMaskAlpha;
  14599. }
  14600. var PIXELS_TO_PROCESS = 1048576;
  14601. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  14602. for (var row = 0; row < height; row += chunkSize) {
  14603. var chunkHeight = Math.min(chunkSize, height - row);
  14604. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  14605. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  14606. if (hasBackdrop) {
  14607. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  14608. }
  14609. composeFn(maskData.data, layerData.data, transferMap);
  14610. maskCtx.putImageData(layerData, 0, row);
  14611. }
  14612. }
  14613. function composeSMask(ctx, smask, layerCtx, webGLContext) {
  14614. var mask = smask.canvas;
  14615. var maskCtx = smask.context;
  14616. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  14617. var backdrop = smask.backdrop || null;
  14618. if (!smask.transferMap && webGLContext.isEnabled) {
  14619. var composed = webGLContext.composeSMask({
  14620. layer: layerCtx.canvas,
  14621. mask: mask,
  14622. properties: {
  14623. subtype: smask.subtype,
  14624. backdrop: backdrop
  14625. }
  14626. });
  14627. ctx.setTransform(1, 0, 0, 1, 0, 0);
  14628. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  14629. return;
  14630. }
  14631. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  14632. ctx.drawImage(mask, 0, 0);
  14633. }
  14634. var LINE_CAP_STYLES = ["butt", "round", "square"];
  14635. var LINE_JOIN_STYLES = ["miter", "round", "bevel"];
  14636. var NORMAL_CLIP = {};
  14637. var EO_CLIP = {};
  14638. CanvasGraphics.prototype = {
  14639. beginDrawing: function beginDrawing(_ref2) {
  14640. var transform = _ref2.transform,
  14641. viewport = _ref2.viewport,
  14642. _ref2$transparency = _ref2.transparency,
  14643. transparency = _ref2$transparency === void 0 ? false : _ref2$transparency,
  14644. _ref2$background = _ref2.background,
  14645. background = _ref2$background === void 0 ? null : _ref2$background;
  14646. var width = this.ctx.canvas.width;
  14647. var height = this.ctx.canvas.height;
  14648. this.ctx.save();
  14649. this.ctx.fillStyle = background || "rgb(255, 255, 255)";
  14650. this.ctx.fillRect(0, 0, width, height);
  14651. this.ctx.restore();
  14652. if (transparency) {
  14653. var transparentCanvas = this.cachedCanvases.getCanvas("transparent", width, height, true);
  14654. this.compositeCtx = this.ctx;
  14655. this.transparentCanvas = transparentCanvas.canvas;
  14656. this.ctx = transparentCanvas.context;
  14657. this.ctx.save();
  14658. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  14659. }
  14660. this.ctx.save();
  14661. resetCtxToDefault(this.ctx);
  14662. if (transform) {
  14663. this.ctx.transform.apply(this.ctx, transform);
  14664. }
  14665. this.ctx.transform.apply(this.ctx, viewport.transform);
  14666. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  14667. if (this.imageLayer) {
  14668. this.imageLayer.beginLayout();
  14669. }
  14670. },
  14671. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  14672. var argsArray = operatorList.argsArray;
  14673. var fnArray = operatorList.fnArray;
  14674. var i = executionStartIdx || 0;
  14675. var argsArrayLen = argsArray.length;
  14676. if (argsArrayLen === i) {
  14677. return i;
  14678. }
  14679. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === "function";
  14680. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  14681. var steps = 0;
  14682. var commonObjs = this.commonObjs;
  14683. var objs = this.objs;
  14684. var fnId;
  14685. while (true) {
  14686. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  14687. stepper.breakIt(i, continueCallback);
  14688. return i;
  14689. }
  14690. fnId = fnArray[i];
  14691. if (fnId !== _util.OPS.dependency) {
  14692. this[fnId].apply(this, argsArray[i]);
  14693. } else {
  14694. var _iterator = _createForOfIteratorHelper(argsArray[i]),
  14695. _step;
  14696. try {
  14697. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  14698. var depObjId = _step.value;
  14699. var objsPool = depObjId.startsWith("g_") ? commonObjs : objs;
  14700. if (!objsPool.has(depObjId)) {
  14701. objsPool.get(depObjId, continueCallback);
  14702. return i;
  14703. }
  14704. }
  14705. } catch (err) {
  14706. _iterator.e(err);
  14707. } finally {
  14708. _iterator.f();
  14709. }
  14710. }
  14711. i++;
  14712. if (i === argsArrayLen) {
  14713. return i;
  14714. }
  14715. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  14716. if (Date.now() > endTime) {
  14717. continueCallback();
  14718. return i;
  14719. }
  14720. steps = 0;
  14721. }
  14722. }
  14723. },
  14724. endDrawing: function CanvasGraphics_endDrawing() {
  14725. if (this.current.activeSMask !== null) {
  14726. this.endSMaskGroup();
  14727. }
  14728. this.ctx.restore();
  14729. if (this.transparentCanvas) {
  14730. this.ctx = this.compositeCtx;
  14731. this.ctx.save();
  14732. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  14733. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  14734. this.ctx.restore();
  14735. this.transparentCanvas = null;
  14736. }
  14737. this.cachedCanvases.clear();
  14738. this.webGLContext.clear();
  14739. if (this.imageLayer) {
  14740. this.imageLayer.endLayout();
  14741. }
  14742. },
  14743. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  14744. this.current.lineWidth = width;
  14745. this.ctx.lineWidth = width;
  14746. },
  14747. setLineCap: function CanvasGraphics_setLineCap(style) {
  14748. this.ctx.lineCap = LINE_CAP_STYLES[style];
  14749. },
  14750. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  14751. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  14752. },
  14753. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  14754. this.ctx.miterLimit = limit;
  14755. },
  14756. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  14757. var ctx = this.ctx;
  14758. if (ctx.setLineDash !== undefined) {
  14759. ctx.setLineDash(dashArray);
  14760. ctx.lineDashOffset = dashPhase;
  14761. }
  14762. },
  14763. setRenderingIntent: function setRenderingIntent(intent) {},
  14764. setFlatness: function setFlatness(flatness) {},
  14765. setGState: function CanvasGraphics_setGState(states) {
  14766. for (var i = 0, ii = states.length; i < ii; i++) {
  14767. var state = states[i];
  14768. var key = state[0];
  14769. var value = state[1];
  14770. switch (key) {
  14771. case "LW":
  14772. this.setLineWidth(value);
  14773. break;
  14774. case "LC":
  14775. this.setLineCap(value);
  14776. break;
  14777. case "LJ":
  14778. this.setLineJoin(value);
  14779. break;
  14780. case "ML":
  14781. this.setMiterLimit(value);
  14782. break;
  14783. case "D":
  14784. this.setDash(value[0], value[1]);
  14785. break;
  14786. case "RI":
  14787. this.setRenderingIntent(value);
  14788. break;
  14789. case "FL":
  14790. this.setFlatness(value);
  14791. break;
  14792. case "Font":
  14793. this.setFont(value[0], value[1]);
  14794. break;
  14795. case "CA":
  14796. this.current.strokeAlpha = state[1];
  14797. break;
  14798. case "ca":
  14799. this.current.fillAlpha = state[1];
  14800. this.ctx.globalAlpha = state[1];
  14801. break;
  14802. case "BM":
  14803. this.ctx.globalCompositeOperation = value;
  14804. break;
  14805. case "SMask":
  14806. if (this.current.activeSMask) {
  14807. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  14808. this.suspendSMaskGroup();
  14809. } else {
  14810. this.endSMaskGroup();
  14811. }
  14812. }
  14813. this.current.activeSMask = value ? this.tempSMask : null;
  14814. if (this.current.activeSMask) {
  14815. this.beginSMaskGroup();
  14816. }
  14817. this.tempSMask = null;
  14818. break;
  14819. case "TR":
  14820. this.current.transferMaps = value;
  14821. }
  14822. }
  14823. },
  14824. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  14825. var activeSMask = this.current.activeSMask;
  14826. var drawnWidth = activeSMask.canvas.width;
  14827. var drawnHeight = activeSMask.canvas.height;
  14828. var cacheId = "smaskGroupAt" + this.groupLevel;
  14829. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  14830. var currentCtx = this.ctx;
  14831. var currentTransform = currentCtx.mozCurrentTransform;
  14832. this.ctx.save();
  14833. var groupCtx = scratchCanvas.context;
  14834. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  14835. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  14836. groupCtx.transform.apply(groupCtx, currentTransform);
  14837. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  14838. copyCtxState(currentCtx, groupCtx);
  14839. this.ctx = groupCtx;
  14840. this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
  14841. this.groupStack.push(currentCtx);
  14842. this.groupLevel++;
  14843. },
  14844. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  14845. var groupCtx = this.ctx;
  14846. this.groupLevel--;
  14847. this.ctx = this.groupStack.pop();
  14848. composeSMask(this.ctx, this.current.activeSMask, groupCtx, this.webGLContext);
  14849. this.ctx.restore();
  14850. this.ctx.save();
  14851. copyCtxState(groupCtx, this.ctx);
  14852. this.current.resumeSMaskCtx = groupCtx;
  14853. var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  14854. this.ctx.transform.apply(this.ctx, deltaTransform);
  14855. groupCtx.save();
  14856. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  14857. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  14858. groupCtx.restore();
  14859. },
  14860. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  14861. var groupCtx = this.current.resumeSMaskCtx;
  14862. var currentCtx = this.ctx;
  14863. this.ctx = groupCtx;
  14864. this.groupStack.push(currentCtx);
  14865. this.groupLevel++;
  14866. },
  14867. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  14868. var groupCtx = this.ctx;
  14869. this.groupLevel--;
  14870. this.ctx = this.groupStack.pop();
  14871. composeSMask(this.ctx, this.current.activeSMask, groupCtx, this.webGLContext);
  14872. this.ctx.restore();
  14873. copyCtxState(groupCtx, this.ctx);
  14874. var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  14875. this.ctx.transform.apply(this.ctx, deltaTransform);
  14876. },
  14877. save: function CanvasGraphics_save() {
  14878. this.ctx.save();
  14879. var old = this.current;
  14880. this.stateStack.push(old);
  14881. this.current = old.clone();
  14882. this.current.resumeSMaskCtx = null;
  14883. },
  14884. restore: function CanvasGraphics_restore() {
  14885. if (this.current.resumeSMaskCtx) {
  14886. this.resumeSMaskGroup();
  14887. }
  14888. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  14889. this.endSMaskGroup();
  14890. }
  14891. if (this.stateStack.length !== 0) {
  14892. this.current = this.stateStack.pop();
  14893. this.ctx.restore();
  14894. this.pendingClip = null;
  14895. this._cachedGetSinglePixelWidth = null;
  14896. }
  14897. },
  14898. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  14899. this.ctx.transform(a, b, c, d, e, f);
  14900. this._cachedGetSinglePixelWidth = null;
  14901. },
  14902. constructPath: function CanvasGraphics_constructPath(ops, args) {
  14903. var ctx = this.ctx;
  14904. var current = this.current;
  14905. var x = current.x,
  14906. y = current.y;
  14907. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  14908. switch (ops[i] | 0) {
  14909. case _util.OPS.rectangle:
  14910. x = args[j++];
  14911. y = args[j++];
  14912. var width = args[j++];
  14913. var height = args[j++];
  14914. if (width === 0 && ctx.lineWidth < this.getSinglePixelWidth()) {
  14915. width = this.getSinglePixelWidth();
  14916. }
  14917. if (height === 0 && ctx.lineWidth < this.getSinglePixelWidth()) {
  14918. height = this.getSinglePixelWidth();
  14919. }
  14920. var xw = x + width;
  14921. var yh = y + height;
  14922. ctx.moveTo(x, y);
  14923. ctx.lineTo(xw, y);
  14924. ctx.lineTo(xw, yh);
  14925. ctx.lineTo(x, yh);
  14926. ctx.lineTo(x, y);
  14927. ctx.closePath();
  14928. break;
  14929. case _util.OPS.moveTo:
  14930. x = args[j++];
  14931. y = args[j++];
  14932. ctx.moveTo(x, y);
  14933. break;
  14934. case _util.OPS.lineTo:
  14935. x = args[j++];
  14936. y = args[j++];
  14937. ctx.lineTo(x, y);
  14938. break;
  14939. case _util.OPS.curveTo:
  14940. x = args[j + 4];
  14941. y = args[j + 5];
  14942. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  14943. j += 6;
  14944. break;
  14945. case _util.OPS.curveTo2:
  14946. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  14947. x = args[j + 2];
  14948. y = args[j + 3];
  14949. j += 4;
  14950. break;
  14951. case _util.OPS.curveTo3:
  14952. x = args[j + 2];
  14953. y = args[j + 3];
  14954. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  14955. j += 4;
  14956. break;
  14957. case _util.OPS.closePath:
  14958. ctx.closePath();
  14959. break;
  14960. }
  14961. }
  14962. current.setCurrentPoint(x, y);
  14963. },
  14964. closePath: function CanvasGraphics_closePath() {
  14965. this.ctx.closePath();
  14966. },
  14967. stroke: function CanvasGraphics_stroke(consumePath) {
  14968. consumePath = typeof consumePath !== "undefined" ? consumePath : true;
  14969. var ctx = this.ctx;
  14970. var strokeColor = this.current.strokeColor;
  14971. ctx.globalAlpha = this.current.strokeAlpha;
  14972. if (this.contentVisible) {
  14973. if (strokeColor && strokeColor.hasOwnProperty("type") && strokeColor.type === "Pattern") {
  14974. ctx.save();
  14975. var transform = ctx.mozCurrentTransform;
  14976. var scale = _util.Util.singularValueDecompose2dScale(transform)[0];
  14977. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  14978. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth * scale);
  14979. ctx.stroke();
  14980. ctx.restore();
  14981. } else {
  14982. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  14983. ctx.stroke();
  14984. }
  14985. }
  14986. if (consumePath) {
  14987. this.consumePath();
  14988. }
  14989. ctx.globalAlpha = this.current.fillAlpha;
  14990. },
  14991. closeStroke: function CanvasGraphics_closeStroke() {
  14992. this.closePath();
  14993. this.stroke();
  14994. },
  14995. fill: function CanvasGraphics_fill(consumePath) {
  14996. consumePath = typeof consumePath !== "undefined" ? consumePath : true;
  14997. var ctx = this.ctx;
  14998. var fillColor = this.current.fillColor;
  14999. var isPatternFill = this.current.patternFill;
  15000. var needRestore = false;
  15001. if (isPatternFill) {
  15002. ctx.save();
  15003. if (this.baseTransform) {
  15004. ctx.setTransform.apply(ctx, this.baseTransform);
  15005. }
  15006. ctx.fillStyle = fillColor.getPattern(ctx, this);
  15007. needRestore = true;
  15008. }
  15009. if (this.contentVisible) {
  15010. if (this.pendingEOFill) {
  15011. ctx.fill("evenodd");
  15012. this.pendingEOFill = false;
  15013. } else {
  15014. ctx.fill();
  15015. }
  15016. }
  15017. if (needRestore) {
  15018. ctx.restore();
  15019. }
  15020. if (consumePath) {
  15021. this.consumePath();
  15022. }
  15023. },
  15024. eoFill: function CanvasGraphics_eoFill() {
  15025. this.pendingEOFill = true;
  15026. this.fill();
  15027. },
  15028. fillStroke: function CanvasGraphics_fillStroke() {
  15029. this.fill(false);
  15030. this.stroke(false);
  15031. this.consumePath();
  15032. },
  15033. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  15034. this.pendingEOFill = true;
  15035. this.fillStroke();
  15036. },
  15037. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  15038. this.closePath();
  15039. this.fillStroke();
  15040. },
  15041. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  15042. this.pendingEOFill = true;
  15043. this.closePath();
  15044. this.fillStroke();
  15045. },
  15046. endPath: function CanvasGraphics_endPath() {
  15047. this.consumePath();
  15048. },
  15049. clip: function CanvasGraphics_clip() {
  15050. this.pendingClip = NORMAL_CLIP;
  15051. },
  15052. eoClip: function CanvasGraphics_eoClip() {
  15053. this.pendingClip = EO_CLIP;
  15054. },
  15055. beginText: function CanvasGraphics_beginText() {
  15056. this.current.textMatrix = _util.IDENTITY_MATRIX;
  15057. this.current.textMatrixScale = 1;
  15058. this.current.x = this.current.lineX = 0;
  15059. this.current.y = this.current.lineY = 0;
  15060. },
  15061. endText: function CanvasGraphics_endText() {
  15062. var paths = this.pendingTextPaths;
  15063. var ctx = this.ctx;
  15064. if (paths === undefined) {
  15065. ctx.beginPath();
  15066. return;
  15067. }
  15068. ctx.save();
  15069. ctx.beginPath();
  15070. for (var i = 0; i < paths.length; i++) {
  15071. var path = paths[i];
  15072. ctx.setTransform.apply(ctx, path.transform);
  15073. ctx.translate(path.x, path.y);
  15074. path.addToPath(ctx, path.fontSize);
  15075. }
  15076. ctx.restore();
  15077. ctx.clip();
  15078. ctx.beginPath();
  15079. delete this.pendingTextPaths;
  15080. },
  15081. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  15082. this.current.charSpacing = spacing;
  15083. },
  15084. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  15085. this.current.wordSpacing = spacing;
  15086. },
  15087. setHScale: function CanvasGraphics_setHScale(scale) {
  15088. this.current.textHScale = scale / 100;
  15089. },
  15090. setLeading: function CanvasGraphics_setLeading(leading) {
  15091. this.current.leading = -leading;
  15092. },
  15093. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  15094. var fontObj = this.commonObjs.get(fontRefName);
  15095. var current = this.current;
  15096. if (!fontObj) {
  15097. throw new Error("Can't find font for ".concat(fontRefName));
  15098. }
  15099. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
  15100. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  15101. (0, _util.warn)("Invalid font matrix for font " + fontRefName);
  15102. }
  15103. if (size < 0) {
  15104. size = -size;
  15105. current.fontDirection = -1;
  15106. } else {
  15107. current.fontDirection = 1;
  15108. }
  15109. this.current.font = fontObj;
  15110. this.current.fontSize = size;
  15111. if (fontObj.isType3Font) {
  15112. return;
  15113. }
  15114. var name = fontObj.loadedName || "sans-serif";
  15115. var bold = "normal";
  15116. if (fontObj.black) {
  15117. bold = "900";
  15118. } else if (fontObj.bold) {
  15119. bold = "bold";
  15120. }
  15121. var italic = fontObj.italic ? "italic" : "normal";
  15122. var typeface = "\"".concat(name, "\", ").concat(fontObj.fallbackName);
  15123. var browserFontSize = size;
  15124. if (size < MIN_FONT_SIZE) {
  15125. browserFontSize = MIN_FONT_SIZE;
  15126. } else if (size > MAX_FONT_SIZE) {
  15127. browserFontSize = MAX_FONT_SIZE;
  15128. }
  15129. this.current.fontSizeScale = size / browserFontSize;
  15130. this.ctx.font = "".concat(italic, " ").concat(bold, " ").concat(browserFontSize, "px ").concat(typeface);
  15131. },
  15132. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  15133. this.current.textRenderingMode = mode;
  15134. },
  15135. setTextRise: function CanvasGraphics_setTextRise(rise) {
  15136. this.current.textRise = rise;
  15137. },
  15138. moveText: function CanvasGraphics_moveText(x, y) {
  15139. this.current.x = this.current.lineX += x;
  15140. this.current.y = this.current.lineY += y;
  15141. },
  15142. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  15143. this.setLeading(-y);
  15144. this.moveText(x, y);
  15145. },
  15146. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  15147. this.current.textMatrix = [a, b, c, d, e, f];
  15148. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  15149. this.current.x = this.current.lineX = 0;
  15150. this.current.y = this.current.lineY = 0;
  15151. },
  15152. nextLine: function CanvasGraphics_nextLine() {
  15153. this.moveText(0, this.current.leading);
  15154. },
  15155. paintChar: function paintChar(character, x, y, patternTransform) {
  15156. var ctx = this.ctx;
  15157. var current = this.current;
  15158. var font = current.font;
  15159. var textRenderingMode = current.textRenderingMode;
  15160. var fontSize = current.fontSize / current.fontSizeScale;
  15161. var fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  15162. var isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
  15163. var patternFill = current.patternFill && !font.missingFile;
  15164. var addToPath;
  15165. if (font.disableFontFace || isAddToPathSet || patternFill) {
  15166. addToPath = font.getPathGenerator(this.commonObjs, character);
  15167. }
  15168. if (font.disableFontFace || patternFill) {
  15169. ctx.save();
  15170. ctx.translate(x, y);
  15171. ctx.beginPath();
  15172. addToPath(ctx, fontSize);
  15173. if (patternTransform) {
  15174. ctx.setTransform.apply(ctx, patternTransform);
  15175. }
  15176. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  15177. ctx.fill();
  15178. }
  15179. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  15180. ctx.stroke();
  15181. }
  15182. ctx.restore();
  15183. } else {
  15184. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  15185. ctx.fillText(character, x, y);
  15186. }
  15187. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  15188. ctx.strokeText(character, x, y);
  15189. }
  15190. }
  15191. if (isAddToPathSet) {
  15192. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  15193. paths.push({
  15194. transform: ctx.mozCurrentTransform,
  15195. x: x,
  15196. y: y,
  15197. fontSize: fontSize,
  15198. addToPath: addToPath
  15199. });
  15200. }
  15201. },
  15202. get isFontSubpixelAAEnabled() {
  15203. var _this$cachedCanvases$ = this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled", 10, 10),
  15204. ctx = _this$cachedCanvases$.context;
  15205. ctx.scale(1.5, 1);
  15206. ctx.fillText("I", 0, 10);
  15207. var data = ctx.getImageData(0, 0, 10, 10).data;
  15208. var enabled = false;
  15209. for (var i = 3; i < data.length; i += 4) {
  15210. if (data[i] > 0 && data[i] < 255) {
  15211. enabled = true;
  15212. break;
  15213. }
  15214. }
  15215. return (0, _util.shadow)(this, "isFontSubpixelAAEnabled", enabled);
  15216. },
  15217. showText: function CanvasGraphics_showText(glyphs) {
  15218. var current = this.current;
  15219. var font = current.font;
  15220. if (font.isType3Font) {
  15221. return this.showType3Text(glyphs);
  15222. }
  15223. var fontSize = current.fontSize;
  15224. if (fontSize === 0) {
  15225. return undefined;
  15226. }
  15227. var ctx = this.ctx;
  15228. var fontSizeScale = current.fontSizeScale;
  15229. var charSpacing = current.charSpacing;
  15230. var wordSpacing = current.wordSpacing;
  15231. var fontDirection = current.fontDirection;
  15232. var textHScale = current.textHScale * fontDirection;
  15233. var glyphsLength = glyphs.length;
  15234. var vertical = font.vertical;
  15235. var spacingDir = vertical ? 1 : -1;
  15236. var defaultVMetrics = font.defaultVMetrics;
  15237. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  15238. var simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
  15239. ctx.save();
  15240. var patternTransform;
  15241. if (current.patternFill) {
  15242. ctx.save();
  15243. var pattern = current.fillColor.getPattern(ctx, this);
  15244. patternTransform = ctx.mozCurrentTransform;
  15245. ctx.restore();
  15246. ctx.fillStyle = pattern;
  15247. }
  15248. ctx.transform.apply(ctx, current.textMatrix);
  15249. ctx.translate(current.x, current.y + current.textRise);
  15250. if (fontDirection > 0) {
  15251. ctx.scale(textHScale, -1);
  15252. } else {
  15253. ctx.scale(textHScale, 1);
  15254. }
  15255. var lineWidth = current.lineWidth;
  15256. var scale = current.textMatrixScale;
  15257. if (scale === 0 || lineWidth === 0) {
  15258. var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  15259. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  15260. this._cachedGetSinglePixelWidth = null;
  15261. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  15262. }
  15263. } else {
  15264. lineWidth /= scale;
  15265. }
  15266. if (fontSizeScale !== 1.0) {
  15267. ctx.scale(fontSizeScale, fontSizeScale);
  15268. lineWidth /= fontSizeScale;
  15269. }
  15270. ctx.lineWidth = lineWidth;
  15271. var x = 0,
  15272. i;
  15273. for (i = 0; i < glyphsLength; ++i) {
  15274. var glyph = glyphs[i];
  15275. if ((0, _util.isNum)(glyph)) {
  15276. x += spacingDir * glyph * fontSize / 1000;
  15277. continue;
  15278. }
  15279. var restoreNeeded = false;
  15280. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  15281. var character = glyph.fontChar;
  15282. var accent = glyph.accent;
  15283. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  15284. var width = glyph.width;
  15285. if (vertical) {
  15286. var vmetric, vx, vy;
  15287. vmetric = glyph.vmetric || defaultVMetrics;
  15288. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  15289. vx = -vx * widthAdvanceScale;
  15290. vy = vmetric[2] * widthAdvanceScale;
  15291. width = vmetric ? -vmetric[0] : width;
  15292. scaledX = vx / fontSizeScale;
  15293. scaledY = (x + vy) / fontSizeScale;
  15294. } else {
  15295. scaledX = x / fontSizeScale;
  15296. scaledY = 0;
  15297. }
  15298. if (font.remeasure && width > 0) {
  15299. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  15300. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  15301. var characterScaleX = width / measuredWidth;
  15302. restoreNeeded = true;
  15303. ctx.save();
  15304. ctx.scale(characterScaleX, 1);
  15305. scaledX /= characterScaleX;
  15306. } else if (width !== measuredWidth) {
  15307. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  15308. }
  15309. }
  15310. if (this.contentVisible && (glyph.isInFont || font.missingFile)) {
  15311. if (simpleFillText && !accent) {
  15312. ctx.fillText(character, scaledX, scaledY);
  15313. } else {
  15314. this.paintChar(character, scaledX, scaledY, patternTransform);
  15315. if (accent) {
  15316. scaledAccentX = scaledX + fontSize * accent.offset.x / fontSizeScale;
  15317. scaledAccentY = scaledY - fontSize * accent.offset.y / fontSizeScale;
  15318. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY, patternTransform);
  15319. }
  15320. }
  15321. }
  15322. var charWidth;
  15323. if (vertical) {
  15324. charWidth = width * widthAdvanceScale - spacing * fontDirection;
  15325. } else {
  15326. charWidth = width * widthAdvanceScale + spacing * fontDirection;
  15327. }
  15328. x += charWidth;
  15329. if (restoreNeeded) {
  15330. ctx.restore();
  15331. }
  15332. }
  15333. if (vertical) {
  15334. current.y -= x;
  15335. } else {
  15336. current.x += x * textHScale;
  15337. }
  15338. ctx.restore();
  15339. },
  15340. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  15341. var ctx = this.ctx;
  15342. var current = this.current;
  15343. var font = current.font;
  15344. var fontSize = current.fontSize;
  15345. var fontDirection = current.fontDirection;
  15346. var spacingDir = font.vertical ? 1 : -1;
  15347. var charSpacing = current.charSpacing;
  15348. var wordSpacing = current.wordSpacing;
  15349. var textHScale = current.textHScale * fontDirection;
  15350. var fontMatrix = current.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  15351. var glyphsLength = glyphs.length;
  15352. var isTextInvisible = current.textRenderingMode === _util.TextRenderingMode.INVISIBLE;
  15353. var i, glyph, width, spacingLength;
  15354. if (isTextInvisible || fontSize === 0) {
  15355. return;
  15356. }
  15357. this._cachedGetSinglePixelWidth = null;
  15358. ctx.save();
  15359. ctx.transform.apply(ctx, current.textMatrix);
  15360. ctx.translate(current.x, current.y);
  15361. ctx.scale(textHScale, fontDirection);
  15362. for (i = 0; i < glyphsLength; ++i) {
  15363. glyph = glyphs[i];
  15364. if ((0, _util.isNum)(glyph)) {
  15365. spacingLength = spacingDir * glyph * fontSize / 1000;
  15366. this.ctx.translate(spacingLength, 0);
  15367. current.x += spacingLength * textHScale;
  15368. continue;
  15369. }
  15370. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  15371. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  15372. if (!operatorList) {
  15373. (0, _util.warn)("Type3 character \"".concat(glyph.operatorListId, "\" is not available."));
  15374. continue;
  15375. }
  15376. if (this.contentVisible) {
  15377. this.processingType3 = glyph;
  15378. this.save();
  15379. ctx.scale(fontSize, fontSize);
  15380. ctx.transform.apply(ctx, fontMatrix);
  15381. this.executeOperatorList(operatorList);
  15382. this.restore();
  15383. }
  15384. var transformed = _util.Util.applyTransform([glyph.width, 0], fontMatrix);
  15385. width = transformed[0] * fontSize + spacing;
  15386. ctx.translate(width, 0);
  15387. current.x += width * textHScale;
  15388. }
  15389. ctx.restore();
  15390. this.processingType3 = null;
  15391. },
  15392. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {},
  15393. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  15394. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  15395. this.clip();
  15396. this.endPath();
  15397. },
  15398. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  15399. var _this = this;
  15400. var pattern;
  15401. if (IR[0] === "TilingPattern") {
  15402. var color = IR[1];
  15403. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  15404. var canvasGraphicsFactory = {
  15405. createCanvasGraphics: function createCanvasGraphics(ctx) {
  15406. return new CanvasGraphics(ctx, _this.commonObjs, _this.objs, _this.canvasFactory, _this.webGLContext);
  15407. }
  15408. };
  15409. pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  15410. } else {
  15411. pattern = (0, _pattern_helper.getShadingPatternFromIR)(IR);
  15412. }
  15413. return pattern;
  15414. },
  15415. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  15416. this.current.strokeColor = this.getColorN_Pattern(arguments);
  15417. },
  15418. setFillColorN: function CanvasGraphics_setFillColorN() {
  15419. this.current.fillColor = this.getColorN_Pattern(arguments);
  15420. this.current.patternFill = true;
  15421. },
  15422. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  15423. var color = _util.Util.makeCssRgb(r, g, b);
  15424. this.ctx.strokeStyle = color;
  15425. this.current.strokeColor = color;
  15426. },
  15427. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  15428. var color = _util.Util.makeCssRgb(r, g, b);
  15429. this.ctx.fillStyle = color;
  15430. this.current.fillColor = color;
  15431. this.current.patternFill = false;
  15432. },
  15433. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  15434. if (!this.contentVisible) {
  15435. return;
  15436. }
  15437. var ctx = this.ctx;
  15438. this.save();
  15439. var pattern = (0, _pattern_helper.getShadingPatternFromIR)(patternIR);
  15440. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  15441. var inv = ctx.mozCurrentTransformInverse;
  15442. if (inv) {
  15443. var canvas = ctx.canvas;
  15444. var width = canvas.width;
  15445. var height = canvas.height;
  15446. var bl = _util.Util.applyTransform([0, 0], inv);
  15447. var br = _util.Util.applyTransform([0, height], inv);
  15448. var ul = _util.Util.applyTransform([width, 0], inv);
  15449. var ur = _util.Util.applyTransform([width, height], inv);
  15450. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  15451. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  15452. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  15453. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  15454. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  15455. } else {
  15456. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  15457. }
  15458. this.restore();
  15459. },
  15460. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  15461. (0, _util.unreachable)("Should not call beginInlineImage");
  15462. },
  15463. beginImageData: function CanvasGraphics_beginImageData() {
  15464. (0, _util.unreachable)("Should not call beginImageData");
  15465. },
  15466. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  15467. if (!this.contentVisible) {
  15468. return;
  15469. }
  15470. this.save();
  15471. this.baseTransformStack.push(this.baseTransform);
  15472. if (Array.isArray(matrix) && matrix.length === 6) {
  15473. this.transform.apply(this, matrix);
  15474. }
  15475. this.baseTransform = this.ctx.mozCurrentTransform;
  15476. if (bbox) {
  15477. var width = bbox[2] - bbox[0];
  15478. var height = bbox[3] - bbox[1];
  15479. this.ctx.rect(bbox[0], bbox[1], width, height);
  15480. this.clip();
  15481. this.endPath();
  15482. }
  15483. },
  15484. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  15485. if (!this.contentVisible) {
  15486. return;
  15487. }
  15488. this.restore();
  15489. this.baseTransform = this.baseTransformStack.pop();
  15490. },
  15491. beginGroup: function CanvasGraphics_beginGroup(group) {
  15492. if (!this.contentVisible) {
  15493. return;
  15494. }
  15495. this.save();
  15496. var currentCtx = this.ctx;
  15497. if (!group.isolated) {
  15498. (0, _util.info)("TODO: Support non-isolated groups.");
  15499. }
  15500. if (group.knockout) {
  15501. (0, _util.warn)("Knockout groups not supported.");
  15502. }
  15503. var currentTransform = currentCtx.mozCurrentTransform;
  15504. if (group.matrix) {
  15505. currentCtx.transform.apply(currentCtx, group.matrix);
  15506. }
  15507. if (!group.bbox) {
  15508. throw new Error("Bounding box is required.");
  15509. }
  15510. var bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  15511. var canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height];
  15512. bounds = _util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
  15513. var offsetX = Math.floor(bounds[0]);
  15514. var offsetY = Math.floor(bounds[1]);
  15515. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  15516. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  15517. var scaleX = 1,
  15518. scaleY = 1;
  15519. if (drawnWidth > MAX_GROUP_SIZE) {
  15520. scaleX = drawnWidth / MAX_GROUP_SIZE;
  15521. drawnWidth = MAX_GROUP_SIZE;
  15522. }
  15523. if (drawnHeight > MAX_GROUP_SIZE) {
  15524. scaleY = drawnHeight / MAX_GROUP_SIZE;
  15525. drawnHeight = MAX_GROUP_SIZE;
  15526. }
  15527. var cacheId = "groupAt" + this.groupLevel;
  15528. if (group.smask) {
  15529. cacheId += "_smask_" + this.smaskCounter++ % 2;
  15530. }
  15531. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  15532. var groupCtx = scratchCanvas.context;
  15533. groupCtx.scale(1 / scaleX, 1 / scaleY);
  15534. groupCtx.translate(-offsetX, -offsetY);
  15535. groupCtx.transform.apply(groupCtx, currentTransform);
  15536. if (group.smask) {
  15537. this.smaskStack.push({
  15538. canvas: scratchCanvas.canvas,
  15539. context: groupCtx,
  15540. offsetX: offsetX,
  15541. offsetY: offsetY,
  15542. scaleX: scaleX,
  15543. scaleY: scaleY,
  15544. subtype: group.smask.subtype,
  15545. backdrop: group.smask.backdrop,
  15546. transferMap: group.smask.transferMap || null,
  15547. startTransformInverse: null
  15548. });
  15549. } else {
  15550. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  15551. currentCtx.translate(offsetX, offsetY);
  15552. currentCtx.scale(scaleX, scaleY);
  15553. }
  15554. copyCtxState(currentCtx, groupCtx);
  15555. this.ctx = groupCtx;
  15556. this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
  15557. this.groupStack.push(currentCtx);
  15558. this.groupLevel++;
  15559. this.current.activeSMask = null;
  15560. },
  15561. endGroup: function CanvasGraphics_endGroup(group) {
  15562. if (!this.contentVisible) {
  15563. return;
  15564. }
  15565. this.groupLevel--;
  15566. var groupCtx = this.ctx;
  15567. this.ctx = this.groupStack.pop();
  15568. if (this.ctx.imageSmoothingEnabled !== undefined) {
  15569. this.ctx.imageSmoothingEnabled = false;
  15570. } else {
  15571. this.ctx.mozImageSmoothingEnabled = false;
  15572. }
  15573. if (group.smask) {
  15574. this.tempSMask = this.smaskStack.pop();
  15575. } else {
  15576. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  15577. }
  15578. this.restore();
  15579. },
  15580. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  15581. this.save();
  15582. if (this.baseTransform) {
  15583. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  15584. }
  15585. },
  15586. endAnnotations: function CanvasGraphics_endAnnotations() {
  15587. this.restore();
  15588. },
  15589. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  15590. this.save();
  15591. resetCtxToDefault(this.ctx);
  15592. this.current = new CanvasExtraState();
  15593. if (Array.isArray(rect) && rect.length === 4) {
  15594. var width = rect[2] - rect[0];
  15595. var height = rect[3] - rect[1];
  15596. this.ctx.rect(rect[0], rect[1], width, height);
  15597. this.clip();
  15598. this.endPath();
  15599. }
  15600. this.transform.apply(this, transform);
  15601. this.transform.apply(this, matrix);
  15602. },
  15603. endAnnotation: function CanvasGraphics_endAnnotation() {
  15604. this.restore();
  15605. },
  15606. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  15607. if (!this.contentVisible) {
  15608. return;
  15609. }
  15610. var ctx = this.ctx;
  15611. var width = img.width,
  15612. height = img.height;
  15613. var fillColor = this.current.fillColor;
  15614. var isPatternFill = this.current.patternFill;
  15615. var glyph = this.processingType3;
  15616. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  15617. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  15618. glyph.compiled = compileType3Glyph({
  15619. data: img.data,
  15620. width: width,
  15621. height: height
  15622. });
  15623. } else {
  15624. glyph.compiled = null;
  15625. }
  15626. }
  15627. if (glyph && glyph.compiled) {
  15628. glyph.compiled(ctx);
  15629. return;
  15630. }
  15631. var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
  15632. var maskCtx = maskCanvas.context;
  15633. maskCtx.save();
  15634. putBinaryImageMask(maskCtx, img);
  15635. maskCtx.globalCompositeOperation = "source-in";
  15636. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  15637. maskCtx.fillRect(0, 0, width, height);
  15638. maskCtx.restore();
  15639. this.paintInlineImageXObject(maskCanvas.canvas);
  15640. },
  15641. paintImageMaskXObjectRepeat: function paintImageMaskXObjectRepeat(imgData, scaleX) {
  15642. var skewX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  15643. var skewY = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  15644. var scaleY = arguments.length > 4 ? arguments[4] : undefined;
  15645. var positions = arguments.length > 5 ? arguments[5] : undefined;
  15646. if (!this.contentVisible) {
  15647. return;
  15648. }
  15649. var width = imgData.width;
  15650. var height = imgData.height;
  15651. var fillColor = this.current.fillColor;
  15652. var isPatternFill = this.current.patternFill;
  15653. var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
  15654. var maskCtx = maskCanvas.context;
  15655. maskCtx.save();
  15656. putBinaryImageMask(maskCtx, imgData);
  15657. maskCtx.globalCompositeOperation = "source-in";
  15658. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  15659. maskCtx.fillRect(0, 0, width, height);
  15660. maskCtx.restore();
  15661. var ctx = this.ctx;
  15662. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  15663. ctx.save();
  15664. ctx.transform(scaleX, skewX, skewY, scaleY, positions[i], positions[i + 1]);
  15665. ctx.scale(1, -1);
  15666. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  15667. ctx.restore();
  15668. }
  15669. },
  15670. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  15671. if (!this.contentVisible) {
  15672. return;
  15673. }
  15674. var ctx = this.ctx;
  15675. var fillColor = this.current.fillColor;
  15676. var isPatternFill = this.current.patternFill;
  15677. for (var i = 0, ii = images.length; i < ii; i++) {
  15678. var image = images[i];
  15679. var width = image.width,
  15680. height = image.height;
  15681. var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
  15682. var maskCtx = maskCanvas.context;
  15683. maskCtx.save();
  15684. putBinaryImageMask(maskCtx, image);
  15685. maskCtx.globalCompositeOperation = "source-in";
  15686. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  15687. maskCtx.fillRect(0, 0, width, height);
  15688. maskCtx.restore();
  15689. ctx.save();
  15690. ctx.transform.apply(ctx, image.transform);
  15691. ctx.scale(1, -1);
  15692. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  15693. ctx.restore();
  15694. }
  15695. },
  15696. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  15697. if (!this.contentVisible) {
  15698. return;
  15699. }
  15700. var imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
  15701. if (!imgData) {
  15702. (0, _util.warn)("Dependent image isn't ready yet");
  15703. return;
  15704. }
  15705. this.paintInlineImageXObject(imgData);
  15706. },
  15707. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  15708. if (!this.contentVisible) {
  15709. return;
  15710. }
  15711. var imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
  15712. if (!imgData) {
  15713. (0, _util.warn)("Dependent image isn't ready yet");
  15714. return;
  15715. }
  15716. var width = imgData.width;
  15717. var height = imgData.height;
  15718. var map = [];
  15719. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  15720. map.push({
  15721. transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]],
  15722. x: 0,
  15723. y: 0,
  15724. w: width,
  15725. h: height
  15726. });
  15727. }
  15728. this.paintInlineImageXObjectGroup(imgData, map);
  15729. },
  15730. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  15731. if (!this.contentVisible) {
  15732. return;
  15733. }
  15734. var width = imgData.width;
  15735. var height = imgData.height;
  15736. var ctx = this.ctx;
  15737. this.save();
  15738. ctx.scale(1 / width, -1 / height);
  15739. var currentTransform = ctx.mozCurrentTransformInverse;
  15740. var a = currentTransform[0],
  15741. b = currentTransform[1];
  15742. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  15743. var c = currentTransform[2],
  15744. d = currentTransform[3];
  15745. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  15746. var imgToPaint, tmpCanvas;
  15747. if (typeof HTMLElement === "function" && imgData instanceof HTMLElement || !imgData.data) {
  15748. imgToPaint = imgData;
  15749. } else {
  15750. tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
  15751. var tmpCtx = tmpCanvas.context;
  15752. putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
  15753. imgToPaint = tmpCanvas.canvas;
  15754. }
  15755. var paintWidth = width,
  15756. paintHeight = height;
  15757. var tmpCanvasId = "prescale1";
  15758. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  15759. var newWidth = paintWidth,
  15760. newHeight = paintHeight;
  15761. if (widthScale > 2 && paintWidth > 1) {
  15762. newWidth = Math.ceil(paintWidth / 2);
  15763. widthScale /= paintWidth / newWidth;
  15764. }
  15765. if (heightScale > 2 && paintHeight > 1) {
  15766. newHeight = Math.ceil(paintHeight / 2);
  15767. heightScale /= paintHeight / newHeight;
  15768. }
  15769. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  15770. tmpCtx = tmpCanvas.context;
  15771. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  15772. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  15773. imgToPaint = tmpCanvas.canvas;
  15774. paintWidth = newWidth;
  15775. paintHeight = newHeight;
  15776. tmpCanvasId = tmpCanvasId === "prescale1" ? "prescale2" : "prescale1";
  15777. }
  15778. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  15779. if (this.imageLayer) {
  15780. var position = this.getCanvasPosition(0, -height);
  15781. this.imageLayer.appendImage({
  15782. imgData: imgData,
  15783. left: position[0],
  15784. top: position[1],
  15785. width: width / currentTransform[0],
  15786. height: height / currentTransform[3]
  15787. });
  15788. }
  15789. this.restore();
  15790. },
  15791. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  15792. if (!this.contentVisible) {
  15793. return;
  15794. }
  15795. var ctx = this.ctx;
  15796. var w = imgData.width;
  15797. var h = imgData.height;
  15798. var tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", w, h);
  15799. var tmpCtx = tmpCanvas.context;
  15800. putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
  15801. for (var i = 0, ii = map.length; i < ii; i++) {
  15802. var entry = map[i];
  15803. ctx.save();
  15804. ctx.transform.apply(ctx, entry.transform);
  15805. ctx.scale(1, -1);
  15806. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  15807. if (this.imageLayer) {
  15808. var position = this.getCanvasPosition(entry.x, entry.y);
  15809. this.imageLayer.appendImage({
  15810. imgData: imgData,
  15811. left: position[0],
  15812. top: position[1],
  15813. width: w,
  15814. height: h
  15815. });
  15816. }
  15817. ctx.restore();
  15818. }
  15819. },
  15820. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  15821. if (!this.contentVisible) {
  15822. return;
  15823. }
  15824. this.ctx.fillRect(0, 0, 1, 1);
  15825. },
  15826. markPoint: function CanvasGraphics_markPoint(tag) {},
  15827. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {},
  15828. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  15829. this.markedContentStack.push({
  15830. visible: true
  15831. });
  15832. },
  15833. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  15834. if (tag === "OC") {
  15835. this.markedContentStack.push({
  15836. visible: this.optionalContentConfig.isVisible(properties)
  15837. });
  15838. } else {
  15839. this.markedContentStack.push({
  15840. visible: true
  15841. });
  15842. }
  15843. this.contentVisible = this.isContentVisible();
  15844. },
  15845. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  15846. this.markedContentStack.pop();
  15847. this.contentVisible = this.isContentVisible();
  15848. },
  15849. beginCompat: function CanvasGraphics_beginCompat() {},
  15850. endCompat: function CanvasGraphics_endCompat() {},
  15851. consumePath: function CanvasGraphics_consumePath() {
  15852. var ctx = this.ctx;
  15853. if (this.pendingClip) {
  15854. if (this.pendingClip === EO_CLIP) {
  15855. ctx.clip("evenodd");
  15856. } else {
  15857. ctx.clip();
  15858. }
  15859. this.pendingClip = null;
  15860. }
  15861. ctx.beginPath();
  15862. },
  15863. getSinglePixelWidth: function getSinglePixelWidth(scale) {
  15864. if (this._cachedGetSinglePixelWidth === null) {
  15865. var inverse = this.ctx.mozCurrentTransformInverse;
  15866. this._cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  15867. }
  15868. return this._cachedGetSinglePixelWidth;
  15869. },
  15870. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  15871. var transform = this.ctx.mozCurrentTransform;
  15872. return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]];
  15873. },
  15874. isContentVisible: function CanvasGraphics_isContentVisible() {
  15875. for (var i = this.markedContentStack.length - 1; i >= 0; i--) {
  15876. if (!this.markedContentStack[i].visible) {
  15877. return false;
  15878. }
  15879. }
  15880. return true;
  15881. }
  15882. };
  15883. for (var op in _util.OPS) {
  15884. CanvasGraphics.prototype[_util.OPS[op]] = CanvasGraphics.prototype[op];
  15885. }
  15886. return CanvasGraphics;
  15887. }();
  15888. exports.CanvasGraphics = CanvasGraphics;
  15889. /***/ }),
  15890. /* 208 */
  15891. /***/ (function(module, exports, __w_pdfjs_require__) {
  15892. "use strict";
  15893. Object.defineProperty(exports, "__esModule", {
  15894. value: true
  15895. });
  15896. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  15897. exports.TilingPattern = void 0;
  15898. var _util = __w_pdfjs_require__(5);
  15899. var ShadingIRs = {};
  15900. function applyBoundingBox(ctx, bbox) {
  15901. if (!bbox || typeof Path2D === "undefined") {
  15902. return;
  15903. }
  15904. var width = bbox[2] - bbox[0];
  15905. var height = bbox[3] - bbox[1];
  15906. var region = new Path2D();
  15907. region.rect(bbox[0], bbox[1], width, height);
  15908. ctx.clip(region);
  15909. }
  15910. ShadingIRs.RadialAxial = {
  15911. fromIR: function RadialAxial_fromIR(raw) {
  15912. var type = raw[1];
  15913. var bbox = raw[2];
  15914. var colorStops = raw[3];
  15915. var p0 = raw[4];
  15916. var p1 = raw[5];
  15917. var r0 = raw[6];
  15918. var r1 = raw[7];
  15919. return {
  15920. type: "Pattern",
  15921. getPattern: function RadialAxial_getPattern(ctx) {
  15922. applyBoundingBox(ctx, bbox);
  15923. var grad;
  15924. if (type === "axial") {
  15925. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  15926. } else if (type === "radial") {
  15927. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  15928. }
  15929. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  15930. var c = colorStops[i];
  15931. grad.addColorStop(c[0], c[1]);
  15932. }
  15933. return grad;
  15934. }
  15935. };
  15936. }
  15937. };
  15938. var createMeshCanvas = function createMeshCanvasClosure() {
  15939. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  15940. var coords = context.coords,
  15941. colors = context.colors;
  15942. var bytes = data.data,
  15943. rowSize = data.width * 4;
  15944. var tmp;
  15945. if (coords[p1 + 1] > coords[p2 + 1]) {
  15946. tmp = p1;
  15947. p1 = p2;
  15948. p2 = tmp;
  15949. tmp = c1;
  15950. c1 = c2;
  15951. c2 = tmp;
  15952. }
  15953. if (coords[p2 + 1] > coords[p3 + 1]) {
  15954. tmp = p2;
  15955. p2 = p3;
  15956. p3 = tmp;
  15957. tmp = c2;
  15958. c2 = c3;
  15959. c3 = tmp;
  15960. }
  15961. if (coords[p1 + 1] > coords[p2 + 1]) {
  15962. tmp = p1;
  15963. p1 = p2;
  15964. p2 = tmp;
  15965. tmp = c1;
  15966. c1 = c2;
  15967. c2 = tmp;
  15968. }
  15969. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  15970. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  15971. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  15972. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  15973. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  15974. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  15975. if (y1 >= y3) {
  15976. return;
  15977. }
  15978. var c1r = colors[c1],
  15979. c1g = colors[c1 + 1],
  15980. c1b = colors[c1 + 2];
  15981. var c2r = colors[c2],
  15982. c2g = colors[c2 + 1],
  15983. c2b = colors[c2 + 2];
  15984. var c3r = colors[c3],
  15985. c3g = colors[c3 + 1],
  15986. c3b = colors[c3 + 2];
  15987. var minY = Math.round(y1),
  15988. maxY = Math.round(y3);
  15989. var xa, car, cag, cab;
  15990. var xb, cbr, cbg, cbb;
  15991. for (var y = minY; y <= maxY; y++) {
  15992. if (y < y2) {
  15993. var _k = void 0;
  15994. if (y < y1) {
  15995. _k = 0;
  15996. } else if (y1 === y2) {
  15997. _k = 1;
  15998. } else {
  15999. _k = (y1 - y) / (y1 - y2);
  16000. }
  16001. xa = x1 - (x1 - x2) * _k;
  16002. car = c1r - (c1r - c2r) * _k;
  16003. cag = c1g - (c1g - c2g) * _k;
  16004. cab = c1b - (c1b - c2b) * _k;
  16005. } else {
  16006. var _k2 = void 0;
  16007. if (y > y3) {
  16008. _k2 = 1;
  16009. } else if (y2 === y3) {
  16010. _k2 = 0;
  16011. } else {
  16012. _k2 = (y2 - y) / (y2 - y3);
  16013. }
  16014. xa = x2 - (x2 - x3) * _k2;
  16015. car = c2r - (c2r - c3r) * _k2;
  16016. cag = c2g - (c2g - c3g) * _k2;
  16017. cab = c2b - (c2b - c3b) * _k2;
  16018. }
  16019. var k = void 0;
  16020. if (y < y1) {
  16021. k = 0;
  16022. } else if (y > y3) {
  16023. k = 1;
  16024. } else {
  16025. k = (y1 - y) / (y1 - y3);
  16026. }
  16027. xb = x1 - (x1 - x3) * k;
  16028. cbr = c1r - (c1r - c3r) * k;
  16029. cbg = c1g - (c1g - c3g) * k;
  16030. cbb = c1b - (c1b - c3b) * k;
  16031. var x1_ = Math.round(Math.min(xa, xb));
  16032. var x2_ = Math.round(Math.max(xa, xb));
  16033. var j = rowSize * y + x1_ * 4;
  16034. for (var x = x1_; x <= x2_; x++) {
  16035. k = (xa - x) / (xa - xb);
  16036. if (k < 0) {
  16037. k = 0;
  16038. } else if (k > 1) {
  16039. k = 1;
  16040. }
  16041. bytes[j++] = car - (car - cbr) * k | 0;
  16042. bytes[j++] = cag - (cag - cbg) * k | 0;
  16043. bytes[j++] = cab - (cab - cbb) * k | 0;
  16044. bytes[j++] = 255;
  16045. }
  16046. }
  16047. }
  16048. function drawFigure(data, figure, context) {
  16049. var ps = figure.coords;
  16050. var cs = figure.colors;
  16051. var i, ii;
  16052. switch (figure.type) {
  16053. case "lattice":
  16054. var verticesPerRow = figure.verticesPerRow;
  16055. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  16056. var cols = verticesPerRow - 1;
  16057. for (i = 0; i < rows; i++) {
  16058. var q = i * verticesPerRow;
  16059. for (var j = 0; j < cols; j++, q++) {
  16060. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  16061. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  16062. }
  16063. }
  16064. break;
  16065. case "triangles":
  16066. for (i = 0, ii = ps.length; i < ii; i += 3) {
  16067. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  16068. }
  16069. break;
  16070. default:
  16071. throw new Error("illegal figure");
  16072. }
  16073. }
  16074. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases, webGLContext) {
  16075. var EXPECTED_SCALE = 1.1;
  16076. var MAX_PATTERN_SIZE = 3000;
  16077. var BORDER_SIZE = 2;
  16078. var offsetX = Math.floor(bounds[0]);
  16079. var offsetY = Math.floor(bounds[1]);
  16080. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  16081. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  16082. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  16083. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  16084. var scaleX = boundsWidth / width;
  16085. var scaleY = boundsHeight / height;
  16086. var context = {
  16087. coords: coords,
  16088. colors: colors,
  16089. offsetX: -offsetX,
  16090. offsetY: -offsetY,
  16091. scaleX: 1 / scaleX,
  16092. scaleY: 1 / scaleY
  16093. };
  16094. var paddedWidth = width + BORDER_SIZE * 2;
  16095. var paddedHeight = height + BORDER_SIZE * 2;
  16096. var canvas, tmpCanvas, i, ii;
  16097. if (webGLContext.isEnabled) {
  16098. canvas = webGLContext.drawFigures({
  16099. width: width,
  16100. height: height,
  16101. backgroundColor: backgroundColor,
  16102. figures: figures,
  16103. context: context
  16104. });
  16105. tmpCanvas = cachedCanvases.getCanvas("mesh", paddedWidth, paddedHeight, false);
  16106. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  16107. canvas = tmpCanvas.canvas;
  16108. } else {
  16109. tmpCanvas = cachedCanvases.getCanvas("mesh", paddedWidth, paddedHeight, false);
  16110. var tmpCtx = tmpCanvas.context;
  16111. var data = tmpCtx.createImageData(width, height);
  16112. if (backgroundColor) {
  16113. var bytes = data.data;
  16114. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  16115. bytes[i] = backgroundColor[0];
  16116. bytes[i + 1] = backgroundColor[1];
  16117. bytes[i + 2] = backgroundColor[2];
  16118. bytes[i + 3] = 255;
  16119. }
  16120. }
  16121. for (i = 0; i < figures.length; i++) {
  16122. drawFigure(data, figures[i], context);
  16123. }
  16124. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  16125. canvas = tmpCanvas.canvas;
  16126. }
  16127. return {
  16128. canvas: canvas,
  16129. offsetX: offsetX - BORDER_SIZE * scaleX,
  16130. offsetY: offsetY - BORDER_SIZE * scaleY,
  16131. scaleX: scaleX,
  16132. scaleY: scaleY
  16133. };
  16134. }
  16135. return createMeshCanvas;
  16136. }();
  16137. ShadingIRs.Mesh = {
  16138. fromIR: function Mesh_fromIR(raw) {
  16139. var coords = raw[2];
  16140. var colors = raw[3];
  16141. var figures = raw[4];
  16142. var bounds = raw[5];
  16143. var matrix = raw[6];
  16144. var bbox = raw[7];
  16145. var background = raw[8];
  16146. return {
  16147. type: "Pattern",
  16148. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  16149. applyBoundingBox(ctx, bbox);
  16150. var scale;
  16151. if (shadingFill) {
  16152. scale = _util.Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  16153. } else {
  16154. scale = _util.Util.singularValueDecompose2dScale(owner.baseTransform);
  16155. if (matrix) {
  16156. var matrixScale = _util.Util.singularValueDecompose2dScale(matrix);
  16157. scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
  16158. }
  16159. }
  16160. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases, owner.webGLContext);
  16161. if (!shadingFill) {
  16162. ctx.setTransform.apply(ctx, owner.baseTransform);
  16163. if (matrix) {
  16164. ctx.transform.apply(ctx, matrix);
  16165. }
  16166. }
  16167. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  16168. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  16169. return ctx.createPattern(temporaryPatternCanvas.canvas, "no-repeat");
  16170. }
  16171. };
  16172. }
  16173. };
  16174. ShadingIRs.Dummy = {
  16175. fromIR: function Dummy_fromIR() {
  16176. return {
  16177. type: "Pattern",
  16178. getPattern: function Dummy_fromIR_getPattern() {
  16179. return "hotpink";
  16180. }
  16181. };
  16182. }
  16183. };
  16184. function getShadingPatternFromIR(raw) {
  16185. var shadingIR = ShadingIRs[raw[0]];
  16186. if (!shadingIR) {
  16187. throw new Error("Unknown IR type: ".concat(raw[0]));
  16188. }
  16189. return shadingIR.fromIR(raw);
  16190. }
  16191. var TilingPattern = function TilingPatternClosure() {
  16192. var PaintType = {
  16193. COLORED: 1,
  16194. UNCOLORED: 2
  16195. };
  16196. var MAX_PATTERN_SIZE = 3000;
  16197. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  16198. this.operatorList = IR[2];
  16199. this.matrix = IR[3] || [1, 0, 0, 1, 0, 0];
  16200. this.bbox = IR[4];
  16201. this.xstep = IR[5];
  16202. this.ystep = IR[6];
  16203. this.paintType = IR[7];
  16204. this.tilingType = IR[8];
  16205. this.color = color;
  16206. this.canvasGraphicsFactory = canvasGraphicsFactory;
  16207. this.baseTransform = baseTransform;
  16208. this.type = "Pattern";
  16209. this.ctx = ctx;
  16210. }
  16211. TilingPattern.prototype = {
  16212. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  16213. var operatorList = this.operatorList;
  16214. var bbox = this.bbox;
  16215. var xstep = this.xstep;
  16216. var ystep = this.ystep;
  16217. var paintType = this.paintType;
  16218. var tilingType = this.tilingType;
  16219. var color = this.color;
  16220. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  16221. (0, _util.info)("TilingType: " + tilingType);
  16222. var x0 = bbox[0],
  16223. y0 = bbox[1],
  16224. x1 = bbox[2],
  16225. y1 = bbox[3];
  16226. var matrixScale = _util.Util.singularValueDecompose2dScale(this.matrix);
  16227. var curMatrixScale = _util.Util.singularValueDecompose2dScale(this.baseTransform);
  16228. var combinedScale = [matrixScale[0] * curMatrixScale[0], matrixScale[1] * curMatrixScale[1]];
  16229. var dimx = this.getSizeAndScale(xstep, this.ctx.canvas.width, combinedScale[0]);
  16230. var dimy = this.getSizeAndScale(ystep, this.ctx.canvas.height, combinedScale[1]);
  16231. var tmpCanvas = owner.cachedCanvases.getCanvas("pattern", dimx.size, dimy.size, true);
  16232. var tmpCtx = tmpCanvas.context;
  16233. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  16234. graphics.groupLevel = owner.groupLevel;
  16235. this.setFillAndStrokeStyleToContext(graphics, paintType, color);
  16236. graphics.transform(dimx.scale, 0, 0, dimy.scale, 0, 0);
  16237. graphics.transform(1, 0, 0, 1, -x0, -y0);
  16238. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  16239. graphics.executeOperatorList(operatorList);
  16240. this.ctx.transform(1, 0, 0, 1, x0, y0);
  16241. this.ctx.scale(1 / dimx.scale, 1 / dimy.scale);
  16242. return tmpCanvas.canvas;
  16243. },
  16244. getSizeAndScale: function TilingPattern_getSizeAndScale(step, realOutputSize, scale) {
  16245. step = Math.abs(step);
  16246. var maxSize = Math.max(MAX_PATTERN_SIZE, realOutputSize);
  16247. var size = Math.ceil(step * scale);
  16248. if (size >= maxSize) {
  16249. size = maxSize;
  16250. } else {
  16251. scale = size / step;
  16252. }
  16253. return {
  16254. scale: scale,
  16255. size: size
  16256. };
  16257. },
  16258. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  16259. if (Array.isArray(bbox) && bbox.length === 4) {
  16260. var bboxWidth = x1 - x0;
  16261. var bboxHeight = y1 - y0;
  16262. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  16263. graphics.clip();
  16264. graphics.endPath();
  16265. }
  16266. },
  16267. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(graphics, paintType, color) {
  16268. var context = graphics.ctx,
  16269. current = graphics.current;
  16270. switch (paintType) {
  16271. case PaintType.COLORED:
  16272. var ctx = this.ctx;
  16273. context.fillStyle = ctx.fillStyle;
  16274. context.strokeStyle = ctx.strokeStyle;
  16275. current.fillColor = ctx.fillStyle;
  16276. current.strokeColor = ctx.strokeStyle;
  16277. break;
  16278. case PaintType.UNCOLORED:
  16279. var cssColor = _util.Util.makeCssRgb(color[0], color[1], color[2]);
  16280. context.fillStyle = cssColor;
  16281. context.strokeStyle = cssColor;
  16282. current.fillColor = cssColor;
  16283. current.strokeColor = cssColor;
  16284. break;
  16285. default:
  16286. throw new _util.FormatError("Unsupported paint type: ".concat(paintType));
  16287. }
  16288. },
  16289. getPattern: function TilingPattern_getPattern(ctx, owner) {
  16290. ctx = this.ctx;
  16291. ctx.setTransform.apply(ctx, this.baseTransform);
  16292. ctx.transform.apply(ctx, this.matrix);
  16293. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  16294. return ctx.createPattern(temporaryPatternCanvas, "repeat");
  16295. }
  16296. };
  16297. return TilingPattern;
  16298. }();
  16299. exports.TilingPattern = TilingPattern;
  16300. /***/ }),
  16301. /* 209 */
  16302. /***/ (function(module, exports, __w_pdfjs_require__) {
  16303. "use strict";
  16304. Object.defineProperty(exports, "__esModule", {
  16305. value: true
  16306. });
  16307. exports.GlobalWorkerOptions = void 0;
  16308. var GlobalWorkerOptions = Object.create(null);
  16309. exports.GlobalWorkerOptions = GlobalWorkerOptions;
  16310. GlobalWorkerOptions.workerPort = GlobalWorkerOptions.workerPort === undefined ? null : GlobalWorkerOptions.workerPort;
  16311. GlobalWorkerOptions.workerSrc = GlobalWorkerOptions.workerSrc === undefined ? "" : GlobalWorkerOptions.workerSrc;
  16312. /***/ }),
  16313. /* 210 */
  16314. /***/ (function(module, exports, __w_pdfjs_require__) {
  16315. "use strict";
  16316. Object.defineProperty(exports, "__esModule", {
  16317. value: true
  16318. });
  16319. exports.MessageHandler = void 0;
  16320. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(2));
  16321. var _util = __w_pdfjs_require__(5);
  16322. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  16323. 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); } }
  16324. 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); }); }; }
  16325. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16326. 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); } }
  16327. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16328. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  16329. var CallbackKind = {
  16330. UNKNOWN: 0,
  16331. DATA: 1,
  16332. ERROR: 2
  16333. };
  16334. var StreamKind = {
  16335. UNKNOWN: 0,
  16336. CANCEL: 1,
  16337. CANCEL_COMPLETE: 2,
  16338. CLOSE: 3,
  16339. ENQUEUE: 4,
  16340. ERROR: 5,
  16341. PULL: 6,
  16342. PULL_COMPLETE: 7,
  16343. START_COMPLETE: 8
  16344. };
  16345. function wrapReason(reason) {
  16346. if (_typeof(reason) !== "object" || reason === null) {
  16347. return reason;
  16348. }
  16349. switch (reason.name) {
  16350. case "AbortException":
  16351. return new _util.AbortException(reason.message);
  16352. case "MissingPDFException":
  16353. return new _util.MissingPDFException(reason.message);
  16354. case "UnexpectedResponseException":
  16355. return new _util.UnexpectedResponseException(reason.message, reason.status);
  16356. case "UnknownErrorException":
  16357. return new _util.UnknownErrorException(reason.message, reason.details);
  16358. default:
  16359. return new _util.UnknownErrorException(reason.message, reason.toString());
  16360. }
  16361. }
  16362. var MessageHandler = /*#__PURE__*/function () {
  16363. function MessageHandler(sourceName, targetName, comObj) {
  16364. var _this = this;
  16365. _classCallCheck(this, MessageHandler);
  16366. this.sourceName = sourceName;
  16367. this.targetName = targetName;
  16368. this.comObj = comObj;
  16369. this.callbackId = 1;
  16370. this.streamId = 1;
  16371. this.postMessageTransfers = true;
  16372. this.streamSinks = Object.create(null);
  16373. this.streamControllers = Object.create(null);
  16374. this.callbackCapabilities = Object.create(null);
  16375. this.actionHandler = Object.create(null);
  16376. this._onComObjOnMessage = function (event) {
  16377. var data = event.data;
  16378. if (data.targetName !== _this.sourceName) {
  16379. return;
  16380. }
  16381. if (data.stream) {
  16382. _this._processStreamMessage(data);
  16383. return;
  16384. }
  16385. if (data.callback) {
  16386. var callbackId = data.callbackId;
  16387. var capability = _this.callbackCapabilities[callbackId];
  16388. if (!capability) {
  16389. throw new Error("Cannot resolve callback ".concat(callbackId));
  16390. }
  16391. delete _this.callbackCapabilities[callbackId];
  16392. if (data.callback === CallbackKind.DATA) {
  16393. capability.resolve(data.data);
  16394. } else if (data.callback === CallbackKind.ERROR) {
  16395. capability.reject(wrapReason(data.reason));
  16396. } else {
  16397. throw new Error("Unexpected callback case");
  16398. }
  16399. return;
  16400. }
  16401. var action = _this.actionHandler[data.action];
  16402. if (!action) {
  16403. throw new Error("Unknown action from worker: ".concat(data.action));
  16404. }
  16405. if (data.callbackId) {
  16406. var cbSourceName = _this.sourceName;
  16407. var cbTargetName = data.sourceName;
  16408. new Promise(function (resolve) {
  16409. resolve(action(data.data));
  16410. }).then(function (result) {
  16411. comObj.postMessage({
  16412. sourceName: cbSourceName,
  16413. targetName: cbTargetName,
  16414. callback: CallbackKind.DATA,
  16415. callbackId: data.callbackId,
  16416. data: result
  16417. });
  16418. }, function (reason) {
  16419. comObj.postMessage({
  16420. sourceName: cbSourceName,
  16421. targetName: cbTargetName,
  16422. callback: CallbackKind.ERROR,
  16423. callbackId: data.callbackId,
  16424. reason: wrapReason(reason)
  16425. });
  16426. });
  16427. return;
  16428. }
  16429. if (data.streamId) {
  16430. _this._createStreamSink(data);
  16431. return;
  16432. }
  16433. action(data.data);
  16434. };
  16435. comObj.addEventListener("message", this._onComObjOnMessage);
  16436. }
  16437. _createClass(MessageHandler, [{
  16438. key: "on",
  16439. value: function on(actionName, handler) {
  16440. var ah = this.actionHandler;
  16441. if (ah[actionName]) {
  16442. throw new Error("There is already an actionName called \"".concat(actionName, "\""));
  16443. }
  16444. ah[actionName] = handler;
  16445. }
  16446. }, {
  16447. key: "send",
  16448. value: function send(actionName, data, transfers) {
  16449. this._postMessage({
  16450. sourceName: this.sourceName,
  16451. targetName: this.targetName,
  16452. action: actionName,
  16453. data: data
  16454. }, transfers);
  16455. }
  16456. }, {
  16457. key: "sendWithPromise",
  16458. value: function sendWithPromise(actionName, data, transfers) {
  16459. var callbackId = this.callbackId++;
  16460. var capability = (0, _util.createPromiseCapability)();
  16461. this.callbackCapabilities[callbackId] = capability;
  16462. try {
  16463. this._postMessage({
  16464. sourceName: this.sourceName,
  16465. targetName: this.targetName,
  16466. action: actionName,
  16467. callbackId: callbackId,
  16468. data: data
  16469. }, transfers);
  16470. } catch (ex) {
  16471. capability.reject(ex);
  16472. }
  16473. return capability.promise;
  16474. }
  16475. }, {
  16476. key: "sendWithStream",
  16477. value: function sendWithStream(actionName, data, queueingStrategy, transfers) {
  16478. var _this2 = this;
  16479. var streamId = this.streamId++;
  16480. var sourceName = this.sourceName;
  16481. var targetName = this.targetName;
  16482. var comObj = this.comObj;
  16483. return new ReadableStream({
  16484. start: function start(controller) {
  16485. var startCapability = (0, _util.createPromiseCapability)();
  16486. _this2.streamControllers[streamId] = {
  16487. controller: controller,
  16488. startCall: startCapability,
  16489. pullCall: null,
  16490. cancelCall: null,
  16491. isClosed: false
  16492. };
  16493. _this2._postMessage({
  16494. sourceName: sourceName,
  16495. targetName: targetName,
  16496. action: actionName,
  16497. streamId: streamId,
  16498. data: data,
  16499. desiredSize: controller.desiredSize
  16500. }, transfers);
  16501. return startCapability.promise;
  16502. },
  16503. pull: function pull(controller) {
  16504. var pullCapability = (0, _util.createPromiseCapability)();
  16505. _this2.streamControllers[streamId].pullCall = pullCapability;
  16506. comObj.postMessage({
  16507. sourceName: sourceName,
  16508. targetName: targetName,
  16509. stream: StreamKind.PULL,
  16510. streamId: streamId,
  16511. desiredSize: controller.desiredSize
  16512. });
  16513. return pullCapability.promise;
  16514. },
  16515. cancel: function cancel(reason) {
  16516. (0, _util.assert)(reason instanceof Error, "cancel must have a valid reason");
  16517. var cancelCapability = (0, _util.createPromiseCapability)();
  16518. _this2.streamControllers[streamId].cancelCall = cancelCapability;
  16519. _this2.streamControllers[streamId].isClosed = true;
  16520. comObj.postMessage({
  16521. sourceName: sourceName,
  16522. targetName: targetName,
  16523. stream: StreamKind.CANCEL,
  16524. streamId: streamId,
  16525. reason: wrapReason(reason)
  16526. });
  16527. return cancelCapability.promise;
  16528. }
  16529. }, queueingStrategy);
  16530. }
  16531. }, {
  16532. key: "_createStreamSink",
  16533. value: function _createStreamSink(data) {
  16534. var self = this;
  16535. var action = this.actionHandler[data.action];
  16536. var streamId = data.streamId;
  16537. var sourceName = this.sourceName;
  16538. var targetName = data.sourceName;
  16539. var comObj = this.comObj;
  16540. var streamSink = {
  16541. enqueue: function enqueue(chunk) {
  16542. var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  16543. var transfers = arguments.length > 2 ? arguments[2] : undefined;
  16544. if (this.isCancelled) {
  16545. return;
  16546. }
  16547. var lastDesiredSize = this.desiredSize;
  16548. this.desiredSize -= size;
  16549. if (lastDesiredSize > 0 && this.desiredSize <= 0) {
  16550. this.sinkCapability = (0, _util.createPromiseCapability)();
  16551. this.ready = this.sinkCapability.promise;
  16552. }
  16553. self._postMessage({
  16554. sourceName: sourceName,
  16555. targetName: targetName,
  16556. stream: StreamKind.ENQUEUE,
  16557. streamId: streamId,
  16558. chunk: chunk
  16559. }, transfers);
  16560. },
  16561. close: function close() {
  16562. if (this.isCancelled) {
  16563. return;
  16564. }
  16565. this.isCancelled = true;
  16566. comObj.postMessage({
  16567. sourceName: sourceName,
  16568. targetName: targetName,
  16569. stream: StreamKind.CLOSE,
  16570. streamId: streamId
  16571. });
  16572. delete self.streamSinks[streamId];
  16573. },
  16574. error: function error(reason) {
  16575. (0, _util.assert)(reason instanceof Error, "error must have a valid reason");
  16576. if (this.isCancelled) {
  16577. return;
  16578. }
  16579. this.isCancelled = true;
  16580. comObj.postMessage({
  16581. sourceName: sourceName,
  16582. targetName: targetName,
  16583. stream: StreamKind.ERROR,
  16584. streamId: streamId,
  16585. reason: wrapReason(reason)
  16586. });
  16587. },
  16588. sinkCapability: (0, _util.createPromiseCapability)(),
  16589. onPull: null,
  16590. onCancel: null,
  16591. isCancelled: false,
  16592. desiredSize: data.desiredSize,
  16593. ready: null
  16594. };
  16595. streamSink.sinkCapability.resolve();
  16596. streamSink.ready = streamSink.sinkCapability.promise;
  16597. this.streamSinks[streamId] = streamSink;
  16598. new Promise(function (resolve) {
  16599. resolve(action(data.data, streamSink));
  16600. }).then(function () {
  16601. comObj.postMessage({
  16602. sourceName: sourceName,
  16603. targetName: targetName,
  16604. stream: StreamKind.START_COMPLETE,
  16605. streamId: streamId,
  16606. success: true
  16607. });
  16608. }, function (reason) {
  16609. comObj.postMessage({
  16610. sourceName: sourceName,
  16611. targetName: targetName,
  16612. stream: StreamKind.START_COMPLETE,
  16613. streamId: streamId,
  16614. reason: wrapReason(reason)
  16615. });
  16616. });
  16617. }
  16618. }, {
  16619. key: "_processStreamMessage",
  16620. value: function _processStreamMessage(data) {
  16621. var streamId = data.streamId;
  16622. var sourceName = this.sourceName;
  16623. var targetName = data.sourceName;
  16624. var comObj = this.comObj;
  16625. switch (data.stream) {
  16626. case StreamKind.START_COMPLETE:
  16627. if (data.success) {
  16628. this.streamControllers[streamId].startCall.resolve();
  16629. } else {
  16630. this.streamControllers[streamId].startCall.reject(wrapReason(data.reason));
  16631. }
  16632. break;
  16633. case StreamKind.PULL_COMPLETE:
  16634. if (data.success) {
  16635. this.streamControllers[streamId].pullCall.resolve();
  16636. } else {
  16637. this.streamControllers[streamId].pullCall.reject(wrapReason(data.reason));
  16638. }
  16639. break;
  16640. case StreamKind.PULL:
  16641. if (!this.streamSinks[streamId]) {
  16642. comObj.postMessage({
  16643. sourceName: sourceName,
  16644. targetName: targetName,
  16645. stream: StreamKind.PULL_COMPLETE,
  16646. streamId: streamId,
  16647. success: true
  16648. });
  16649. break;
  16650. }
  16651. if (this.streamSinks[streamId].desiredSize <= 0 && data.desiredSize > 0) {
  16652. this.streamSinks[streamId].sinkCapability.resolve();
  16653. }
  16654. this.streamSinks[streamId].desiredSize = data.desiredSize;
  16655. var onPull = this.streamSinks[data.streamId].onPull;
  16656. new Promise(function (resolve) {
  16657. resolve(onPull && onPull());
  16658. }).then(function () {
  16659. comObj.postMessage({
  16660. sourceName: sourceName,
  16661. targetName: targetName,
  16662. stream: StreamKind.PULL_COMPLETE,
  16663. streamId: streamId,
  16664. success: true
  16665. });
  16666. }, function (reason) {
  16667. comObj.postMessage({
  16668. sourceName: sourceName,
  16669. targetName: targetName,
  16670. stream: StreamKind.PULL_COMPLETE,
  16671. streamId: streamId,
  16672. reason: wrapReason(reason)
  16673. });
  16674. });
  16675. break;
  16676. case StreamKind.ENQUEUE:
  16677. (0, _util.assert)(this.streamControllers[streamId], "enqueue should have stream controller");
  16678. if (this.streamControllers[streamId].isClosed) {
  16679. break;
  16680. }
  16681. this.streamControllers[streamId].controller.enqueue(data.chunk);
  16682. break;
  16683. case StreamKind.CLOSE:
  16684. (0, _util.assert)(this.streamControllers[streamId], "close should have stream controller");
  16685. if (this.streamControllers[streamId].isClosed) {
  16686. break;
  16687. }
  16688. this.streamControllers[streamId].isClosed = true;
  16689. this.streamControllers[streamId].controller.close();
  16690. this._deleteStreamController(streamId);
  16691. break;
  16692. case StreamKind.ERROR:
  16693. (0, _util.assert)(this.streamControllers[streamId], "error should have stream controller");
  16694. this.streamControllers[streamId].controller.error(wrapReason(data.reason));
  16695. this._deleteStreamController(streamId);
  16696. break;
  16697. case StreamKind.CANCEL_COMPLETE:
  16698. if (data.success) {
  16699. this.streamControllers[streamId].cancelCall.resolve();
  16700. } else {
  16701. this.streamControllers[streamId].cancelCall.reject(wrapReason(data.reason));
  16702. }
  16703. this._deleteStreamController(streamId);
  16704. break;
  16705. case StreamKind.CANCEL:
  16706. if (!this.streamSinks[streamId]) {
  16707. break;
  16708. }
  16709. var onCancel = this.streamSinks[data.streamId].onCancel;
  16710. new Promise(function (resolve) {
  16711. resolve(onCancel && onCancel(wrapReason(data.reason)));
  16712. }).then(function () {
  16713. comObj.postMessage({
  16714. sourceName: sourceName,
  16715. targetName: targetName,
  16716. stream: StreamKind.CANCEL_COMPLETE,
  16717. streamId: streamId,
  16718. success: true
  16719. });
  16720. }, function (reason) {
  16721. comObj.postMessage({
  16722. sourceName: sourceName,
  16723. targetName: targetName,
  16724. stream: StreamKind.CANCEL_COMPLETE,
  16725. streamId: streamId,
  16726. reason: wrapReason(reason)
  16727. });
  16728. });
  16729. this.streamSinks[streamId].sinkCapability.reject(wrapReason(data.reason));
  16730. this.streamSinks[streamId].isCancelled = true;
  16731. delete this.streamSinks[streamId];
  16732. break;
  16733. default:
  16734. throw new Error("Unexpected stream case");
  16735. }
  16736. }
  16737. }, {
  16738. key: "_deleteStreamController",
  16739. value: function () {
  16740. var _deleteStreamController2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(streamId) {
  16741. return _regenerator["default"].wrap(function _callee$(_context) {
  16742. while (1) {
  16743. switch (_context.prev = _context.next) {
  16744. case 0:
  16745. _context.next = 2;
  16746. return Promise.allSettled([this.streamControllers[streamId].startCall, this.streamControllers[streamId].pullCall, this.streamControllers[streamId].cancelCall].map(function (capability) {
  16747. return capability && capability.promise;
  16748. }));
  16749. case 2:
  16750. delete this.streamControllers[streamId];
  16751. case 3:
  16752. case "end":
  16753. return _context.stop();
  16754. }
  16755. }
  16756. }, _callee, this);
  16757. }));
  16758. function _deleteStreamController(_x) {
  16759. return _deleteStreamController2.apply(this, arguments);
  16760. }
  16761. return _deleteStreamController;
  16762. }()
  16763. }, {
  16764. key: "_postMessage",
  16765. value: function _postMessage(message, transfers) {
  16766. if (transfers && this.postMessageTransfers) {
  16767. this.comObj.postMessage(message, transfers);
  16768. } else {
  16769. this.comObj.postMessage(message);
  16770. }
  16771. }
  16772. }, {
  16773. key: "destroy",
  16774. value: function destroy() {
  16775. this.comObj.removeEventListener("message", this._onComObjOnMessage);
  16776. }
  16777. }]);
  16778. return MessageHandler;
  16779. }();
  16780. exports.MessageHandler = MessageHandler;
  16781. /***/ }),
  16782. /* 211 */
  16783. /***/ (function(module, exports, __w_pdfjs_require__) {
  16784. "use strict";
  16785. Object.defineProperty(exports, "__esModule", {
  16786. value: true
  16787. });
  16788. exports.Metadata = void 0;
  16789. var _util = __w_pdfjs_require__(5);
  16790. var _xml_parser = __w_pdfjs_require__(212);
  16791. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16792. 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); } }
  16793. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16794. var Metadata = /*#__PURE__*/function () {
  16795. function Metadata(data) {
  16796. _classCallCheck(this, Metadata);
  16797. (0, _util.assert)(typeof data === "string", "Metadata: input is not a string");
  16798. data = this._repair(data);
  16799. var parser = new _xml_parser.SimpleXMLParser();
  16800. var xmlDocument = parser.parseFromString(data);
  16801. this._metadataMap = new Map();
  16802. if (xmlDocument) {
  16803. this._parse(xmlDocument);
  16804. }
  16805. }
  16806. _createClass(Metadata, [{
  16807. key: "_repair",
  16808. value: function _repair(data) {
  16809. return data.replace(/^[^<]+/, "").replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  16810. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  16811. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  16812. }).replace(/&(amp|apos|gt|lt|quot);/g, function (str, name) {
  16813. switch (name) {
  16814. case "amp":
  16815. return "&";
  16816. case "apos":
  16817. return "'";
  16818. case "gt":
  16819. return ">";
  16820. case "lt":
  16821. return "<";
  16822. case "quot":
  16823. return '"';
  16824. }
  16825. throw new Error("_repair: ".concat(name, " isn't defined."));
  16826. });
  16827. var chars = "";
  16828. for (var i = 0, ii = bytes.length; i < ii; i += 2) {
  16829. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  16830. if (code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38) {
  16831. chars += String.fromCharCode(code);
  16832. } else {
  16833. chars += "&#x" + (0x10000 + code).toString(16).substring(1) + ";";
  16834. }
  16835. }
  16836. return ">" + chars;
  16837. });
  16838. }
  16839. }, {
  16840. key: "_parse",
  16841. value: function _parse(xmlDocument) {
  16842. var rdf = xmlDocument.documentElement;
  16843. if (rdf.nodeName.toLowerCase() !== "rdf:rdf") {
  16844. rdf = rdf.firstChild;
  16845. while (rdf && rdf.nodeName.toLowerCase() !== "rdf:rdf") {
  16846. rdf = rdf.nextSibling;
  16847. }
  16848. }
  16849. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  16850. if (!rdf || nodeName !== "rdf:rdf" || !rdf.hasChildNodes()) {
  16851. return;
  16852. }
  16853. var children = rdf.childNodes;
  16854. for (var i = 0, ii = children.length; i < ii; i++) {
  16855. var desc = children[i];
  16856. if (desc.nodeName.toLowerCase() !== "rdf:description") {
  16857. continue;
  16858. }
  16859. for (var j = 0, jj = desc.childNodes.length; j < jj; j++) {
  16860. if (desc.childNodes[j].nodeName.toLowerCase() !== "#text") {
  16861. var entry = desc.childNodes[j];
  16862. var name = entry.nodeName.toLowerCase();
  16863. this._metadataMap.set(name, entry.textContent.trim());
  16864. }
  16865. }
  16866. }
  16867. }
  16868. }, {
  16869. key: "get",
  16870. value: function get(name) {
  16871. return this._metadataMap.has(name) ? this._metadataMap.get(name) : null;
  16872. }
  16873. }, {
  16874. key: "getAll",
  16875. value: function getAll() {
  16876. return Object.fromEntries(this._metadataMap);
  16877. }
  16878. }, {
  16879. key: "has",
  16880. value: function has(name) {
  16881. return this._metadataMap.has(name);
  16882. }
  16883. }]);
  16884. return Metadata;
  16885. }();
  16886. exports.Metadata = Metadata;
  16887. /***/ }),
  16888. /* 212 */
  16889. /***/ (function(module, exports, __w_pdfjs_require__) {
  16890. "use strict";
  16891. Object.defineProperty(exports, "__esModule", {
  16892. value: true
  16893. });
  16894. exports.SimpleXMLParser = void 0;
  16895. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  16896. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  16897. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  16898. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  16899. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  16900. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  16901. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  16902. 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); }
  16903. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  16904. 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); }
  16905. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  16906. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  16907. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  16908. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  16909. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  16910. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  16911. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16912. 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); } }
  16913. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16914. var XMLParserErrorCode = {
  16915. NoError: 0,
  16916. EndOfDocument: -1,
  16917. UnterminatedCdat: -2,
  16918. UnterminatedXmlDeclaration: -3,
  16919. UnterminatedDoctypeDeclaration: -4,
  16920. UnterminatedComment: -5,
  16921. MalformedElement: -6,
  16922. OutOfMemory: -7,
  16923. UnterminatedAttributeValue: -8,
  16924. UnterminatedElement: -9,
  16925. ElementNeverBegun: -10
  16926. };
  16927. function isWhitespace(s, index) {
  16928. var ch = s[index];
  16929. return ch === " " || ch === "\n" || ch === "\r" || ch === "\t";
  16930. }
  16931. function isWhitespaceString(s) {
  16932. for (var i = 0, ii = s.length; i < ii; i++) {
  16933. if (!isWhitespace(s, i)) {
  16934. return false;
  16935. }
  16936. }
  16937. return true;
  16938. }
  16939. var XMLParserBase = /*#__PURE__*/function () {
  16940. function XMLParserBase() {
  16941. _classCallCheck(this, XMLParserBase);
  16942. }
  16943. _createClass(XMLParserBase, [{
  16944. key: "_resolveEntities",
  16945. value: function _resolveEntities(s) {
  16946. var _this = this;
  16947. return s.replace(/&([^;]+);/g, function (all, entity) {
  16948. if (entity.substring(0, 2) === "#x") {
  16949. return String.fromCharCode(parseInt(entity.substring(2), 16));
  16950. } else if (entity.substring(0, 1) === "#") {
  16951. return String.fromCharCode(parseInt(entity.substring(1), 10));
  16952. }
  16953. switch (entity) {
  16954. case "lt":
  16955. return "<";
  16956. case "gt":
  16957. return ">";
  16958. case "amp":
  16959. return "&";
  16960. case "quot":
  16961. return '"';
  16962. }
  16963. return _this.onResolveEntity(entity);
  16964. });
  16965. }
  16966. }, {
  16967. key: "_parseContent",
  16968. value: function _parseContent(s, start) {
  16969. var attributes = [];
  16970. var pos = start;
  16971. function skipWs() {
  16972. while (pos < s.length && isWhitespace(s, pos)) {
  16973. ++pos;
  16974. }
  16975. }
  16976. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== ">" && s[pos] !== "/") {
  16977. ++pos;
  16978. }
  16979. var name = s.substring(start, pos);
  16980. skipWs();
  16981. while (pos < s.length && s[pos] !== ">" && s[pos] !== "/" && s[pos] !== "?") {
  16982. skipWs();
  16983. var attrName = "",
  16984. attrValue = "";
  16985. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== "=") {
  16986. attrName += s[pos];
  16987. ++pos;
  16988. }
  16989. skipWs();
  16990. if (s[pos] !== "=") {
  16991. return null;
  16992. }
  16993. ++pos;
  16994. skipWs();
  16995. var attrEndChar = s[pos];
  16996. if (attrEndChar !== '"' && attrEndChar !== "'") {
  16997. return null;
  16998. }
  16999. var attrEndIndex = s.indexOf(attrEndChar, ++pos);
  17000. if (attrEndIndex < 0) {
  17001. return null;
  17002. }
  17003. attrValue = s.substring(pos, attrEndIndex);
  17004. attributes.push({
  17005. name: attrName,
  17006. value: this._resolveEntities(attrValue)
  17007. });
  17008. pos = attrEndIndex + 1;
  17009. skipWs();
  17010. }
  17011. return {
  17012. name: name,
  17013. attributes: attributes,
  17014. parsed: pos - start
  17015. };
  17016. }
  17017. }, {
  17018. key: "_parseProcessingInstruction",
  17019. value: function _parseProcessingInstruction(s, start) {
  17020. var pos = start;
  17021. function skipWs() {
  17022. while (pos < s.length && isWhitespace(s, pos)) {
  17023. ++pos;
  17024. }
  17025. }
  17026. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== ">" && s[pos] !== "/") {
  17027. ++pos;
  17028. }
  17029. var name = s.substring(start, pos);
  17030. skipWs();
  17031. var attrStart = pos;
  17032. while (pos < s.length && (s[pos] !== "?" || s[pos + 1] !== ">")) {
  17033. ++pos;
  17034. }
  17035. var value = s.substring(attrStart, pos);
  17036. return {
  17037. name: name,
  17038. value: value,
  17039. parsed: pos - start
  17040. };
  17041. }
  17042. }, {
  17043. key: "parseXml",
  17044. value: function parseXml(s) {
  17045. var i = 0;
  17046. while (i < s.length) {
  17047. var ch = s[i];
  17048. var j = i;
  17049. if (ch === "<") {
  17050. ++j;
  17051. var ch2 = s[j];
  17052. var q = void 0;
  17053. switch (ch2) {
  17054. case "/":
  17055. ++j;
  17056. q = s.indexOf(">", j);
  17057. if (q < 0) {
  17058. this.onError(XMLParserErrorCode.UnterminatedElement);
  17059. return;
  17060. }
  17061. this.onEndElement(s.substring(j, q));
  17062. j = q + 1;
  17063. break;
  17064. case "?":
  17065. ++j;
  17066. var pi = this._parseProcessingInstruction(s, j);
  17067. if (s.substring(j + pi.parsed, j + pi.parsed + 2) !== "?>") {
  17068. this.onError(XMLParserErrorCode.UnterminatedXmlDeclaration);
  17069. return;
  17070. }
  17071. this.onPi(pi.name, pi.value);
  17072. j += pi.parsed + 2;
  17073. break;
  17074. case "!":
  17075. if (s.substring(j + 1, j + 3) === "--") {
  17076. q = s.indexOf("-->", j + 3);
  17077. if (q < 0) {
  17078. this.onError(XMLParserErrorCode.UnterminatedComment);
  17079. return;
  17080. }
  17081. this.onComment(s.substring(j + 3, q));
  17082. j = q + 3;
  17083. } else if (s.substring(j + 1, j + 8) === "[CDATA[") {
  17084. q = s.indexOf("]]>", j + 8);
  17085. if (q < 0) {
  17086. this.onError(XMLParserErrorCode.UnterminatedCdat);
  17087. return;
  17088. }
  17089. this.onCdata(s.substring(j + 8, q));
  17090. j = q + 3;
  17091. } else if (s.substring(j + 1, j + 8) === "DOCTYPE") {
  17092. var q2 = s.indexOf("[", j + 8);
  17093. var complexDoctype = false;
  17094. q = s.indexOf(">", j + 8);
  17095. if (q < 0) {
  17096. this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
  17097. return;
  17098. }
  17099. if (q2 > 0 && q > q2) {
  17100. q = s.indexOf("]>", j + 8);
  17101. if (q < 0) {
  17102. this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
  17103. return;
  17104. }
  17105. complexDoctype = true;
  17106. }
  17107. var doctypeContent = s.substring(j + 8, q + (complexDoctype ? 1 : 0));
  17108. this.onDoctype(doctypeContent);
  17109. j = q + (complexDoctype ? 2 : 1);
  17110. } else {
  17111. this.onError(XMLParserErrorCode.MalformedElement);
  17112. return;
  17113. }
  17114. break;
  17115. default:
  17116. var content = this._parseContent(s, j);
  17117. if (content === null) {
  17118. this.onError(XMLParserErrorCode.MalformedElement);
  17119. return;
  17120. }
  17121. var isClosed = false;
  17122. if (s.substring(j + content.parsed, j + content.parsed + 2) === "/>") {
  17123. isClosed = true;
  17124. } else if (s.substring(j + content.parsed, j + content.parsed + 1) !== ">") {
  17125. this.onError(XMLParserErrorCode.UnterminatedElement);
  17126. return;
  17127. }
  17128. this.onBeginElement(content.name, content.attributes, isClosed);
  17129. j += content.parsed + (isClosed ? 2 : 1);
  17130. break;
  17131. }
  17132. } else {
  17133. while (j < s.length && s[j] !== "<") {
  17134. j++;
  17135. }
  17136. var text = s.substring(i, j);
  17137. this.onText(this._resolveEntities(text));
  17138. }
  17139. i = j;
  17140. }
  17141. }
  17142. }, {
  17143. key: "onResolveEntity",
  17144. value: function onResolveEntity(name) {
  17145. return "&".concat(name, ";");
  17146. }
  17147. }, {
  17148. key: "onPi",
  17149. value: function onPi(name, value) {}
  17150. }, {
  17151. key: "onComment",
  17152. value: function onComment(text) {}
  17153. }, {
  17154. key: "onCdata",
  17155. value: function onCdata(text) {}
  17156. }, {
  17157. key: "onDoctype",
  17158. value: function onDoctype(doctypeContent) {}
  17159. }, {
  17160. key: "onText",
  17161. value: function onText(text) {}
  17162. }, {
  17163. key: "onBeginElement",
  17164. value: function onBeginElement(name, attributes, isEmpty) {}
  17165. }, {
  17166. key: "onEndElement",
  17167. value: function onEndElement(name) {}
  17168. }, {
  17169. key: "onError",
  17170. value: function onError(code) {}
  17171. }]);
  17172. return XMLParserBase;
  17173. }();
  17174. var SimpleDOMNode = /*#__PURE__*/function () {
  17175. function SimpleDOMNode(nodeName, nodeValue) {
  17176. _classCallCheck(this, SimpleDOMNode);
  17177. this.nodeName = nodeName;
  17178. this.nodeValue = nodeValue;
  17179. Object.defineProperty(this, "parentNode", {
  17180. value: null,
  17181. writable: true
  17182. });
  17183. }
  17184. _createClass(SimpleDOMNode, [{
  17185. key: "hasChildNodes",
  17186. value: function hasChildNodes() {
  17187. return this.childNodes && this.childNodes.length > 0;
  17188. }
  17189. }, {
  17190. key: "firstChild",
  17191. get: function get() {
  17192. return this.childNodes && this.childNodes[0];
  17193. }
  17194. }, {
  17195. key: "nextSibling",
  17196. get: function get() {
  17197. var childNodes = this.parentNode.childNodes;
  17198. if (!childNodes) {
  17199. return undefined;
  17200. }
  17201. var index = childNodes.indexOf(this);
  17202. if (index === -1) {
  17203. return undefined;
  17204. }
  17205. return childNodes[index + 1];
  17206. }
  17207. }, {
  17208. key: "textContent",
  17209. get: function get() {
  17210. if (!this.childNodes) {
  17211. return this.nodeValue || "";
  17212. }
  17213. return this.childNodes.map(function (child) {
  17214. return child.textContent;
  17215. }).join("");
  17216. }
  17217. }]);
  17218. return SimpleDOMNode;
  17219. }();
  17220. var SimpleXMLParser = /*#__PURE__*/function (_XMLParserBase) {
  17221. _inherits(SimpleXMLParser, _XMLParserBase);
  17222. var _super = _createSuper(SimpleXMLParser);
  17223. function SimpleXMLParser() {
  17224. var _this2;
  17225. _classCallCheck(this, SimpleXMLParser);
  17226. _this2 = _super.call(this);
  17227. _this2._currentFragment = null;
  17228. _this2._stack = null;
  17229. _this2._errorCode = XMLParserErrorCode.NoError;
  17230. return _this2;
  17231. }
  17232. _createClass(SimpleXMLParser, [{
  17233. key: "parseFromString",
  17234. value: function parseFromString(data) {
  17235. this._currentFragment = [];
  17236. this._stack = [];
  17237. this._errorCode = XMLParserErrorCode.NoError;
  17238. this.parseXml(data);
  17239. if (this._errorCode !== XMLParserErrorCode.NoError) {
  17240. return undefined;
  17241. }
  17242. var _this$_currentFragmen = _slicedToArray(this._currentFragment, 1),
  17243. documentElement = _this$_currentFragmen[0];
  17244. if (!documentElement) {
  17245. return undefined;
  17246. }
  17247. return {
  17248. documentElement: documentElement
  17249. };
  17250. }
  17251. }, {
  17252. key: "onResolveEntity",
  17253. value: function onResolveEntity(name) {
  17254. switch (name) {
  17255. case "apos":
  17256. return "'";
  17257. }
  17258. return _get(_getPrototypeOf(SimpleXMLParser.prototype), "onResolveEntity", this).call(this, name);
  17259. }
  17260. }, {
  17261. key: "onText",
  17262. value: function onText(text) {
  17263. if (isWhitespaceString(text)) {
  17264. return;
  17265. }
  17266. var node = new SimpleDOMNode("#text", text);
  17267. this._currentFragment.push(node);
  17268. }
  17269. }, {
  17270. key: "onCdata",
  17271. value: function onCdata(text) {
  17272. var node = new SimpleDOMNode("#text", text);
  17273. this._currentFragment.push(node);
  17274. }
  17275. }, {
  17276. key: "onBeginElement",
  17277. value: function onBeginElement(name, attributes, isEmpty) {
  17278. var node = new SimpleDOMNode(name);
  17279. node.childNodes = [];
  17280. this._currentFragment.push(node);
  17281. if (isEmpty) {
  17282. return;
  17283. }
  17284. this._stack.push(this._currentFragment);
  17285. this._currentFragment = node.childNodes;
  17286. }
  17287. }, {
  17288. key: "onEndElement",
  17289. value: function onEndElement(name) {
  17290. this._currentFragment = this._stack.pop() || [];
  17291. var lastElement = this._currentFragment[this._currentFragment.length - 1];
  17292. if (!lastElement) {
  17293. return;
  17294. }
  17295. for (var i = 0, ii = lastElement.childNodes.length; i < ii; i++) {
  17296. lastElement.childNodes[i].parentNode = lastElement;
  17297. }
  17298. }
  17299. }, {
  17300. key: "onError",
  17301. value: function onError(code) {
  17302. this._errorCode = code;
  17303. }
  17304. }]);
  17305. return SimpleXMLParser;
  17306. }(XMLParserBase);
  17307. exports.SimpleXMLParser = SimpleXMLParser;
  17308. /***/ }),
  17309. /* 213 */
  17310. /***/ (function(module, exports, __w_pdfjs_require__) {
  17311. "use strict";
  17312. Object.defineProperty(exports, "__esModule", {
  17313. value: true
  17314. });
  17315. exports.OptionalContentConfig = void 0;
  17316. var _util = __w_pdfjs_require__(5);
  17317. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  17318. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  17319. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  17320. 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); } }
  17321. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17322. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17323. var OptionalContentGroup = function OptionalContentGroup(name, intent) {
  17324. _classCallCheck(this, OptionalContentGroup);
  17325. this.visible = true;
  17326. this.name = name;
  17327. this.intent = intent;
  17328. };
  17329. var OptionalContentConfig = /*#__PURE__*/function () {
  17330. function OptionalContentConfig(data) {
  17331. _classCallCheck(this, OptionalContentConfig);
  17332. this.name = null;
  17333. this.creator = null;
  17334. this._order = null;
  17335. this._groups = new Map();
  17336. if (data === null) {
  17337. return;
  17338. }
  17339. this.name = data.name;
  17340. this.creator = data.creator;
  17341. this._order = data.order;
  17342. var _iterator = _createForOfIteratorHelper(data.groups),
  17343. _step;
  17344. try {
  17345. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  17346. var _group = _step.value;
  17347. this._groups.set(_group.id, new OptionalContentGroup(_group.name, _group.intent));
  17348. }
  17349. } catch (err) {
  17350. _iterator.e(err);
  17351. } finally {
  17352. _iterator.f();
  17353. }
  17354. if (data.baseState === "OFF") {
  17355. var _iterator2 = _createForOfIteratorHelper(this._groups),
  17356. _step2;
  17357. try {
  17358. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  17359. var group = _step2.value;
  17360. group.visible = false;
  17361. }
  17362. } catch (err) {
  17363. _iterator2.e(err);
  17364. } finally {
  17365. _iterator2.f();
  17366. }
  17367. }
  17368. var _iterator3 = _createForOfIteratorHelper(data.on),
  17369. _step3;
  17370. try {
  17371. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  17372. var on = _step3.value;
  17373. this._groups.get(on).visible = true;
  17374. }
  17375. } catch (err) {
  17376. _iterator3.e(err);
  17377. } finally {
  17378. _iterator3.f();
  17379. }
  17380. var _iterator4 = _createForOfIteratorHelper(data.off),
  17381. _step4;
  17382. try {
  17383. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  17384. var off = _step4.value;
  17385. this._groups.get(off).visible = false;
  17386. }
  17387. } catch (err) {
  17388. _iterator4.e(err);
  17389. } finally {
  17390. _iterator4.f();
  17391. }
  17392. }
  17393. _createClass(OptionalContentConfig, [{
  17394. key: "isVisible",
  17395. value: function isVisible(group) {
  17396. if (group.type === "OCG") {
  17397. if (!this._groups.has(group.id)) {
  17398. (0, _util.warn)("Optional content group not found: ".concat(group.id));
  17399. return true;
  17400. }
  17401. return this._groups.get(group.id).visible;
  17402. } else if (group.type === "OCMD") {
  17403. if (group.expression) {
  17404. (0, _util.warn)("Visibility expression not supported yet.");
  17405. }
  17406. if (!group.policy || group.policy === "AnyOn") {
  17407. var _iterator5 = _createForOfIteratorHelper(group.ids),
  17408. _step5;
  17409. try {
  17410. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  17411. var id = _step5.value;
  17412. if (!this._groups.has(id)) {
  17413. (0, _util.warn)("Optional content group not found: ".concat(id));
  17414. return true;
  17415. }
  17416. if (this._groups.get(id).visible) {
  17417. return true;
  17418. }
  17419. }
  17420. } catch (err) {
  17421. _iterator5.e(err);
  17422. } finally {
  17423. _iterator5.f();
  17424. }
  17425. return false;
  17426. } else if (group.policy === "AllOn") {
  17427. var _iterator6 = _createForOfIteratorHelper(group.ids),
  17428. _step6;
  17429. try {
  17430. for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
  17431. var _id = _step6.value;
  17432. if (!this._groups.has(_id)) {
  17433. (0, _util.warn)("Optional content group not found: ".concat(_id));
  17434. return true;
  17435. }
  17436. if (!this._groups.get(_id).visible) {
  17437. return false;
  17438. }
  17439. }
  17440. } catch (err) {
  17441. _iterator6.e(err);
  17442. } finally {
  17443. _iterator6.f();
  17444. }
  17445. return true;
  17446. } else if (group.policy === "AnyOff") {
  17447. var _iterator7 = _createForOfIteratorHelper(group.ids),
  17448. _step7;
  17449. try {
  17450. for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
  17451. var _id2 = _step7.value;
  17452. if (!this._groups.has(_id2)) {
  17453. (0, _util.warn)("Optional content group not found: ".concat(_id2));
  17454. return true;
  17455. }
  17456. if (!this._groups.get(_id2).visible) {
  17457. return true;
  17458. }
  17459. }
  17460. } catch (err) {
  17461. _iterator7.e(err);
  17462. } finally {
  17463. _iterator7.f();
  17464. }
  17465. return false;
  17466. } else if (group.policy === "AllOff") {
  17467. var _iterator8 = _createForOfIteratorHelper(group.ids),
  17468. _step8;
  17469. try {
  17470. for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
  17471. var _id3 = _step8.value;
  17472. if (!this._groups.has(_id3)) {
  17473. (0, _util.warn)("Optional content group not found: ".concat(_id3));
  17474. return true;
  17475. }
  17476. if (this._groups.get(_id3).visible) {
  17477. return false;
  17478. }
  17479. }
  17480. } catch (err) {
  17481. _iterator8.e(err);
  17482. } finally {
  17483. _iterator8.f();
  17484. }
  17485. return true;
  17486. }
  17487. (0, _util.warn)("Unknown optional content policy ".concat(group.policy, "."));
  17488. return true;
  17489. }
  17490. (0, _util.warn)("Unknown group type ".concat(group.type, "."));
  17491. return true;
  17492. }
  17493. }, {
  17494. key: "setVisibility",
  17495. value: function setVisibility(id) {
  17496. var visible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  17497. if (!this._groups.has(id)) {
  17498. (0, _util.warn)("Optional content group not found: ".concat(id));
  17499. return;
  17500. }
  17501. this._groups.get(id).visible = !!visible;
  17502. }
  17503. }, {
  17504. key: "getOrder",
  17505. value: function getOrder() {
  17506. if (!this._groups.size) {
  17507. return null;
  17508. }
  17509. if (this._order) {
  17510. return this._order.slice();
  17511. }
  17512. return Array.from(this._groups.keys());
  17513. }
  17514. }, {
  17515. key: "getGroups",
  17516. value: function getGroups() {
  17517. if (!this._groups.size) {
  17518. return null;
  17519. }
  17520. return Object.fromEntries(this._groups);
  17521. }
  17522. }, {
  17523. key: "getGroup",
  17524. value: function getGroup(id) {
  17525. return this._groups.get(id) || null;
  17526. }
  17527. }]);
  17528. return OptionalContentConfig;
  17529. }();
  17530. exports.OptionalContentConfig = OptionalContentConfig;
  17531. /***/ }),
  17532. /* 214 */
  17533. /***/ (function(module, exports, __w_pdfjs_require__) {
  17534. "use strict";
  17535. Object.defineProperty(exports, "__esModule", {
  17536. value: true
  17537. });
  17538. exports.PDFDataTransportStream = void 0;
  17539. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(2));
  17540. var _util = __w_pdfjs_require__(5);
  17541. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  17542. 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); } }
  17543. 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); }); }; }
  17544. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  17545. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  17546. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  17547. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17548. 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); } }
  17549. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17550. var PDFDataTransportStream = /*#__PURE__*/function () {
  17551. function PDFDataTransportStream(params, pdfDataRangeTransport) {
  17552. var _this = this;
  17553. _classCallCheck(this, PDFDataTransportStream);
  17554. (0, _util.assert)(pdfDataRangeTransport, 'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');
  17555. this._queuedChunks = [];
  17556. this._progressiveDone = params.progressiveDone || false;
  17557. var initialData = params.initialData;
  17558. if (initialData && initialData.length > 0) {
  17559. var buffer = new Uint8Array(initialData).buffer;
  17560. this._queuedChunks.push(buffer);
  17561. }
  17562. this._pdfDataRangeTransport = pdfDataRangeTransport;
  17563. this._isStreamingSupported = !params.disableStream;
  17564. this._isRangeSupported = !params.disableRange;
  17565. this._contentLength = params.length;
  17566. this._fullRequestReader = null;
  17567. this._rangeReaders = [];
  17568. this._pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  17569. _this._onReceiveData({
  17570. begin: begin,
  17571. chunk: chunk
  17572. });
  17573. });
  17574. this._pdfDataRangeTransport.addProgressListener(function (loaded, total) {
  17575. _this._onProgress({
  17576. loaded: loaded,
  17577. total: total
  17578. });
  17579. });
  17580. this._pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  17581. _this._onReceiveData({
  17582. chunk: chunk
  17583. });
  17584. });
  17585. this._pdfDataRangeTransport.addProgressiveDoneListener(function () {
  17586. _this._onProgressiveDone();
  17587. });
  17588. this._pdfDataRangeTransport.transportReady();
  17589. }
  17590. _createClass(PDFDataTransportStream, [{
  17591. key: "_onReceiveData",
  17592. value: function _onReceiveData(args) {
  17593. var buffer = new Uint8Array(args.chunk).buffer;
  17594. if (args.begin === undefined) {
  17595. if (this._fullRequestReader) {
  17596. this._fullRequestReader._enqueue(buffer);
  17597. } else {
  17598. this._queuedChunks.push(buffer);
  17599. }
  17600. } else {
  17601. var found = this._rangeReaders.some(function (rangeReader) {
  17602. if (rangeReader._begin !== args.begin) {
  17603. return false;
  17604. }
  17605. rangeReader._enqueue(buffer);
  17606. return true;
  17607. });
  17608. (0, _util.assert)(found, "_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.");
  17609. }
  17610. }
  17611. }, {
  17612. key: "_onProgress",
  17613. value: function _onProgress(evt) {
  17614. if (evt.total === undefined) {
  17615. var firstReader = this._rangeReaders[0];
  17616. if (firstReader && firstReader.onProgress) {
  17617. firstReader.onProgress({
  17618. loaded: evt.loaded
  17619. });
  17620. }
  17621. } else {
  17622. var fullReader = this._fullRequestReader;
  17623. if (fullReader && fullReader.onProgress) {
  17624. fullReader.onProgress({
  17625. loaded: evt.loaded,
  17626. total: evt.total
  17627. });
  17628. }
  17629. }
  17630. }
  17631. }, {
  17632. key: "_onProgressiveDone",
  17633. value: function _onProgressiveDone() {
  17634. if (this._fullRequestReader) {
  17635. this._fullRequestReader.progressiveDone();
  17636. }
  17637. this._progressiveDone = true;
  17638. }
  17639. }, {
  17640. key: "_removeRangeReader",
  17641. value: function _removeRangeReader(reader) {
  17642. var i = this._rangeReaders.indexOf(reader);
  17643. if (i >= 0) {
  17644. this._rangeReaders.splice(i, 1);
  17645. }
  17646. }
  17647. }, {
  17648. key: "getFullReader",
  17649. value: function getFullReader() {
  17650. (0, _util.assert)(!this._fullRequestReader, "PDFDataTransportStream.getFullReader can only be called once.");
  17651. var queuedChunks = this._queuedChunks;
  17652. this._queuedChunks = null;
  17653. return new PDFDataTransportStreamReader(this, queuedChunks, this._progressiveDone);
  17654. }
  17655. }, {
  17656. key: "getRangeReader",
  17657. value: function getRangeReader(begin, end) {
  17658. if (end <= this._progressiveDataLength) {
  17659. return null;
  17660. }
  17661. var reader = new PDFDataTransportStreamRangeReader(this, begin, end);
  17662. this._pdfDataRangeTransport.requestDataRange(begin, end);
  17663. this._rangeReaders.push(reader);
  17664. return reader;
  17665. }
  17666. }, {
  17667. key: "cancelAllRequests",
  17668. value: function cancelAllRequests(reason) {
  17669. if (this._fullRequestReader) {
  17670. this._fullRequestReader.cancel(reason);
  17671. }
  17672. var readers = this._rangeReaders.slice(0);
  17673. readers.forEach(function (rangeReader) {
  17674. rangeReader.cancel(reason);
  17675. });
  17676. this._pdfDataRangeTransport.abort();
  17677. }
  17678. }, {
  17679. key: "_progressiveDataLength",
  17680. get: function get() {
  17681. return this._fullRequestReader ? this._fullRequestReader._loaded : 0;
  17682. }
  17683. }]);
  17684. return PDFDataTransportStream;
  17685. }();
  17686. exports.PDFDataTransportStream = PDFDataTransportStream;
  17687. var PDFDataTransportStreamReader = /*#__PURE__*/function () {
  17688. function PDFDataTransportStreamReader(stream, queuedChunks) {
  17689. var progressiveDone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  17690. _classCallCheck(this, PDFDataTransportStreamReader);
  17691. this._stream = stream;
  17692. this._done = progressiveDone || false;
  17693. this._filename = null;
  17694. this._queuedChunks = queuedChunks || [];
  17695. this._loaded = 0;
  17696. var _iterator = _createForOfIteratorHelper(this._queuedChunks),
  17697. _step;
  17698. try {
  17699. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  17700. var chunk = _step.value;
  17701. this._loaded += chunk.byteLength;
  17702. }
  17703. } catch (err) {
  17704. _iterator.e(err);
  17705. } finally {
  17706. _iterator.f();
  17707. }
  17708. this._requests = [];
  17709. this._headersReady = Promise.resolve();
  17710. stream._fullRequestReader = this;
  17711. this.onProgress = null;
  17712. }
  17713. _createClass(PDFDataTransportStreamReader, [{
  17714. key: "_enqueue",
  17715. value: function _enqueue(chunk) {
  17716. if (this._done) {
  17717. return;
  17718. }
  17719. if (this._requests.length > 0) {
  17720. var requestCapability = this._requests.shift();
  17721. requestCapability.resolve({
  17722. value: chunk,
  17723. done: false
  17724. });
  17725. } else {
  17726. this._queuedChunks.push(chunk);
  17727. }
  17728. this._loaded += chunk.byteLength;
  17729. }
  17730. }, {
  17731. key: "read",
  17732. value: function () {
  17733. var _read = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  17734. var chunk, requestCapability;
  17735. return _regenerator["default"].wrap(function _callee$(_context) {
  17736. while (1) {
  17737. switch (_context.prev = _context.next) {
  17738. case 0:
  17739. if (!(this._queuedChunks.length > 0)) {
  17740. _context.next = 3;
  17741. break;
  17742. }
  17743. chunk = this._queuedChunks.shift();
  17744. return _context.abrupt("return", {
  17745. value: chunk,
  17746. done: false
  17747. });
  17748. case 3:
  17749. if (!this._done) {
  17750. _context.next = 5;
  17751. break;
  17752. }
  17753. return _context.abrupt("return", {
  17754. value: undefined,
  17755. done: true
  17756. });
  17757. case 5:
  17758. requestCapability = (0, _util.createPromiseCapability)();
  17759. this._requests.push(requestCapability);
  17760. return _context.abrupt("return", requestCapability.promise);
  17761. case 8:
  17762. case "end":
  17763. return _context.stop();
  17764. }
  17765. }
  17766. }, _callee, this);
  17767. }));
  17768. function read() {
  17769. return _read.apply(this, arguments);
  17770. }
  17771. return read;
  17772. }()
  17773. }, {
  17774. key: "cancel",
  17775. value: function cancel(reason) {
  17776. this._done = true;
  17777. this._requests.forEach(function (requestCapability) {
  17778. requestCapability.resolve({
  17779. value: undefined,
  17780. done: true
  17781. });
  17782. });
  17783. this._requests = [];
  17784. }
  17785. }, {
  17786. key: "progressiveDone",
  17787. value: function progressiveDone() {
  17788. if (this._done) {
  17789. return;
  17790. }
  17791. this._done = true;
  17792. }
  17793. }, {
  17794. key: "headersReady",
  17795. get: function get() {
  17796. return this._headersReady;
  17797. }
  17798. }, {
  17799. key: "filename",
  17800. get: function get() {
  17801. return this._filename;
  17802. }
  17803. }, {
  17804. key: "isRangeSupported",
  17805. get: function get() {
  17806. return this._stream._isRangeSupported;
  17807. }
  17808. }, {
  17809. key: "isStreamingSupported",
  17810. get: function get() {
  17811. return this._stream._isStreamingSupported;
  17812. }
  17813. }, {
  17814. key: "contentLength",
  17815. get: function get() {
  17816. return this._stream._contentLength;
  17817. }
  17818. }]);
  17819. return PDFDataTransportStreamReader;
  17820. }();
  17821. var PDFDataTransportStreamRangeReader = /*#__PURE__*/function () {
  17822. function PDFDataTransportStreamRangeReader(stream, begin, end) {
  17823. _classCallCheck(this, PDFDataTransportStreamRangeReader);
  17824. this._stream = stream;
  17825. this._begin = begin;
  17826. this._end = end;
  17827. this._queuedChunk = null;
  17828. this._requests = [];
  17829. this._done = false;
  17830. this.onProgress = null;
  17831. }
  17832. _createClass(PDFDataTransportStreamRangeReader, [{
  17833. key: "_enqueue",
  17834. value: function _enqueue(chunk) {
  17835. if (this._done) {
  17836. return;
  17837. }
  17838. if (this._requests.length === 0) {
  17839. this._queuedChunk = chunk;
  17840. } else {
  17841. var requestsCapability = this._requests.shift();
  17842. requestsCapability.resolve({
  17843. value: chunk,
  17844. done: false
  17845. });
  17846. this._requests.forEach(function (requestCapability) {
  17847. requestCapability.resolve({
  17848. value: undefined,
  17849. done: true
  17850. });
  17851. });
  17852. this._requests = [];
  17853. }
  17854. this._done = true;
  17855. this._stream._removeRangeReader(this);
  17856. }
  17857. }, {
  17858. key: "read",
  17859. value: function () {
  17860. var _read2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  17861. var chunk, requestCapability;
  17862. return _regenerator["default"].wrap(function _callee2$(_context2) {
  17863. while (1) {
  17864. switch (_context2.prev = _context2.next) {
  17865. case 0:
  17866. if (!this._queuedChunk) {
  17867. _context2.next = 4;
  17868. break;
  17869. }
  17870. chunk = this._queuedChunk;
  17871. this._queuedChunk = null;
  17872. return _context2.abrupt("return", {
  17873. value: chunk,
  17874. done: false
  17875. });
  17876. case 4:
  17877. if (!this._done) {
  17878. _context2.next = 6;
  17879. break;
  17880. }
  17881. return _context2.abrupt("return", {
  17882. value: undefined,
  17883. done: true
  17884. });
  17885. case 6:
  17886. requestCapability = (0, _util.createPromiseCapability)();
  17887. this._requests.push(requestCapability);
  17888. return _context2.abrupt("return", requestCapability.promise);
  17889. case 9:
  17890. case "end":
  17891. return _context2.stop();
  17892. }
  17893. }
  17894. }, _callee2, this);
  17895. }));
  17896. function read() {
  17897. return _read2.apply(this, arguments);
  17898. }
  17899. return read;
  17900. }()
  17901. }, {
  17902. key: "cancel",
  17903. value: function cancel(reason) {
  17904. this._done = true;
  17905. this._requests.forEach(function (requestCapability) {
  17906. requestCapability.resolve({
  17907. value: undefined,
  17908. done: true
  17909. });
  17910. });
  17911. this._requests = [];
  17912. this._stream._removeRangeReader(this);
  17913. }
  17914. }, {
  17915. key: "isStreamingSupported",
  17916. get: function get() {
  17917. return false;
  17918. }
  17919. }]);
  17920. return PDFDataTransportStreamRangeReader;
  17921. }();
  17922. /***/ }),
  17923. /* 215 */
  17924. /***/ (function(module, exports, __w_pdfjs_require__) {
  17925. "use strict";
  17926. Object.defineProperty(exports, "__esModule", {
  17927. value: true
  17928. });
  17929. exports.WebGLContext = void 0;
  17930. var _util = __w_pdfjs_require__(5);
  17931. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17932. 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); } }
  17933. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17934. var WebGLContext = /*#__PURE__*/function () {
  17935. function WebGLContext(_ref) {
  17936. var _ref$enable = _ref.enable,
  17937. enable = _ref$enable === void 0 ? false : _ref$enable;
  17938. _classCallCheck(this, WebGLContext);
  17939. this._enabled = enable === true;
  17940. }
  17941. _createClass(WebGLContext, [{
  17942. key: "composeSMask",
  17943. value: function composeSMask(_ref2) {
  17944. var layer = _ref2.layer,
  17945. mask = _ref2.mask,
  17946. properties = _ref2.properties;
  17947. return WebGLUtils.composeSMask(layer, mask, properties);
  17948. }
  17949. }, {
  17950. key: "drawFigures",
  17951. value: function drawFigures(_ref3) {
  17952. var width = _ref3.width,
  17953. height = _ref3.height,
  17954. backgroundColor = _ref3.backgroundColor,
  17955. figures = _ref3.figures,
  17956. context = _ref3.context;
  17957. return WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  17958. }
  17959. }, {
  17960. key: "clear",
  17961. value: function clear() {
  17962. WebGLUtils.cleanup();
  17963. }
  17964. }, {
  17965. key: "isEnabled",
  17966. get: function get() {
  17967. var enabled = this._enabled;
  17968. if (enabled) {
  17969. enabled = WebGLUtils.tryInitGL();
  17970. }
  17971. return (0, _util.shadow)(this, "isEnabled", enabled);
  17972. }
  17973. }]);
  17974. return WebGLContext;
  17975. }();
  17976. exports.WebGLContext = WebGLContext;
  17977. var WebGLUtils = function WebGLUtilsClosure() {
  17978. function loadShader(gl, code, shaderType) {
  17979. var shader = gl.createShader(shaderType);
  17980. gl.shaderSource(shader, code);
  17981. gl.compileShader(shader);
  17982. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  17983. if (!compiled) {
  17984. var errorMsg = gl.getShaderInfoLog(shader);
  17985. throw new Error("Error during shader compilation: " + errorMsg);
  17986. }
  17987. return shader;
  17988. }
  17989. function createVertexShader(gl, code) {
  17990. return loadShader(gl, code, gl.VERTEX_SHADER);
  17991. }
  17992. function createFragmentShader(gl, code) {
  17993. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  17994. }
  17995. function createProgram(gl, shaders) {
  17996. var program = gl.createProgram();
  17997. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  17998. gl.attachShader(program, shaders[i]);
  17999. }
  18000. gl.linkProgram(program);
  18001. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  18002. if (!linked) {
  18003. var errorMsg = gl.getProgramInfoLog(program);
  18004. throw new Error("Error during program linking: " + errorMsg);
  18005. }
  18006. return program;
  18007. }
  18008. function createTexture(gl, image, textureId) {
  18009. gl.activeTexture(textureId);
  18010. var texture = gl.createTexture();
  18011. gl.bindTexture(gl.TEXTURE_2D, texture);
  18012. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  18013. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  18014. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  18015. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  18016. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  18017. return texture;
  18018. }
  18019. var currentGL, currentCanvas;
  18020. function generateGL() {
  18021. if (currentGL) {
  18022. return;
  18023. }
  18024. currentCanvas = document.createElement("canvas");
  18025. currentGL = currentCanvas.getContext("webgl", {
  18026. premultipliedalpha: false
  18027. });
  18028. }
  18029. var smaskVertexShaderCode = "\
  18030. attribute vec2 a_position; \
  18031. attribute vec2 a_texCoord; \
  18032. \
  18033. uniform vec2 u_resolution; \
  18034. \
  18035. varying vec2 v_texCoord; \
  18036. \
  18037. void main() { \
  18038. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  18039. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  18040. \
  18041. v_texCoord = a_texCoord; \
  18042. } ";
  18043. var smaskFragmentShaderCode = "\
  18044. precision mediump float; \
  18045. \
  18046. uniform vec4 u_backdrop; \
  18047. uniform int u_subtype; \
  18048. uniform sampler2D u_image; \
  18049. uniform sampler2D u_mask; \
  18050. \
  18051. varying vec2 v_texCoord; \
  18052. \
  18053. void main() { \
  18054. vec4 imageColor = texture2D(u_image, v_texCoord); \
  18055. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  18056. if (u_backdrop.a > 0.0) { \
  18057. maskColor.rgb = maskColor.rgb * maskColor.a + \
  18058. u_backdrop.rgb * (1.0 - maskColor.a); \
  18059. } \
  18060. float lum; \
  18061. if (u_subtype == 0) { \
  18062. lum = maskColor.a; \
  18063. } else { \
  18064. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  18065. maskColor.b * 0.11; \
  18066. } \
  18067. imageColor.a *= lum; \
  18068. imageColor.rgb *= imageColor.a; \
  18069. gl_FragColor = imageColor; \
  18070. } ";
  18071. var smaskCache = null;
  18072. function initSmaskGL() {
  18073. var canvas, gl;
  18074. generateGL();
  18075. canvas = currentCanvas;
  18076. currentCanvas = null;
  18077. gl = currentGL;
  18078. currentGL = null;
  18079. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  18080. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  18081. var program = createProgram(gl, [vertexShader, fragmentShader]);
  18082. gl.useProgram(program);
  18083. var cache = {};
  18084. cache.gl = gl;
  18085. cache.canvas = canvas;
  18086. cache.resolutionLocation = gl.getUniformLocation(program, "u_resolution");
  18087. cache.positionLocation = gl.getAttribLocation(program, "a_position");
  18088. cache.backdropLocation = gl.getUniformLocation(program, "u_backdrop");
  18089. cache.subtypeLocation = gl.getUniformLocation(program, "u_subtype");
  18090. var texCoordLocation = gl.getAttribLocation(program, "a_texCoord");
  18091. var texLayerLocation = gl.getUniformLocation(program, "u_image");
  18092. var texMaskLocation = gl.getUniformLocation(program, "u_mask");
  18093. var texCoordBuffer = gl.createBuffer();
  18094. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  18095. 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);
  18096. gl.enableVertexAttribArray(texCoordLocation);
  18097. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  18098. gl.uniform1i(texLayerLocation, 0);
  18099. gl.uniform1i(texMaskLocation, 1);
  18100. smaskCache = cache;
  18101. }
  18102. function composeSMask(layer, mask, properties) {
  18103. var width = layer.width,
  18104. height = layer.height;
  18105. if (!smaskCache) {
  18106. initSmaskGL();
  18107. }
  18108. var cache = smaskCache,
  18109. canvas = cache.canvas,
  18110. gl = cache.gl;
  18111. canvas.width = width;
  18112. canvas.height = height;
  18113. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  18114. gl.uniform2f(cache.resolutionLocation, width, height);
  18115. if (properties.backdrop) {
  18116. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  18117. } else {
  18118. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  18119. }
  18120. gl.uniform1i(cache.subtypeLocation, properties.subtype === "Luminosity" ? 1 : 0);
  18121. var texture = createTexture(gl, layer, gl.TEXTURE0);
  18122. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  18123. var buffer = gl.createBuffer();
  18124. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  18125. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, width, 0, 0, height, 0, height, width, 0, width, height]), gl.STATIC_DRAW);
  18126. gl.enableVertexAttribArray(cache.positionLocation);
  18127. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  18128. gl.clearColor(0, 0, 0, 0);
  18129. gl.enable(gl.BLEND);
  18130. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  18131. gl.clear(gl.COLOR_BUFFER_BIT);
  18132. gl.drawArrays(gl.TRIANGLES, 0, 6);
  18133. gl.flush();
  18134. gl.deleteTexture(texture);
  18135. gl.deleteTexture(maskTexture);
  18136. gl.deleteBuffer(buffer);
  18137. return canvas;
  18138. }
  18139. var figuresVertexShaderCode = "\
  18140. attribute vec2 a_position; \
  18141. attribute vec3 a_color; \
  18142. \
  18143. uniform vec2 u_resolution; \
  18144. uniform vec2 u_scale; \
  18145. uniform vec2 u_offset; \
  18146. \
  18147. varying vec4 v_color; \
  18148. \
  18149. void main() { \
  18150. vec2 position = (a_position + u_offset) * u_scale; \
  18151. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  18152. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  18153. \
  18154. v_color = vec4(a_color / 255.0, 1.0); \
  18155. } ";
  18156. var figuresFragmentShaderCode = "\
  18157. precision mediump float; \
  18158. \
  18159. varying vec4 v_color; \
  18160. \
  18161. void main() { \
  18162. gl_FragColor = v_color; \
  18163. } ";
  18164. var figuresCache = null;
  18165. function initFiguresGL() {
  18166. var canvas, gl;
  18167. generateGL();
  18168. canvas = currentCanvas;
  18169. currentCanvas = null;
  18170. gl = currentGL;
  18171. currentGL = null;
  18172. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  18173. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  18174. var program = createProgram(gl, [vertexShader, fragmentShader]);
  18175. gl.useProgram(program);
  18176. var cache = {};
  18177. cache.gl = gl;
  18178. cache.canvas = canvas;
  18179. cache.resolutionLocation = gl.getUniformLocation(program, "u_resolution");
  18180. cache.scaleLocation = gl.getUniformLocation(program, "u_scale");
  18181. cache.offsetLocation = gl.getUniformLocation(program, "u_offset");
  18182. cache.positionLocation = gl.getAttribLocation(program, "a_position");
  18183. cache.colorLocation = gl.getAttribLocation(program, "a_color");
  18184. figuresCache = cache;
  18185. }
  18186. function drawFigures(width, height, backgroundColor, figures, context) {
  18187. if (!figuresCache) {
  18188. initFiguresGL();
  18189. }
  18190. var cache = figuresCache,
  18191. canvas = cache.canvas,
  18192. gl = cache.gl;
  18193. canvas.width = width;
  18194. canvas.height = height;
  18195. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  18196. gl.uniform2f(cache.resolutionLocation, width, height);
  18197. var count = 0;
  18198. var i, ii, rows;
  18199. for (i = 0, ii = figures.length; i < ii; i++) {
  18200. switch (figures[i].type) {
  18201. case "lattice":
  18202. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  18203. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  18204. break;
  18205. case "triangles":
  18206. count += figures[i].coords.length;
  18207. break;
  18208. }
  18209. }
  18210. var coords = new Float32Array(count * 2);
  18211. var colors = new Uint8Array(count * 3);
  18212. var coordsMap = context.coords,
  18213. colorsMap = context.colors;
  18214. var pIndex = 0,
  18215. cIndex = 0;
  18216. for (i = 0, ii = figures.length; i < ii; i++) {
  18217. var figure = figures[i],
  18218. ps = figure.coords,
  18219. cs = figure.colors;
  18220. switch (figure.type) {
  18221. case "lattice":
  18222. var cols = figure.verticesPerRow;
  18223. rows = ps.length / cols | 0;
  18224. for (var row = 1; row < rows; row++) {
  18225. var offset = row * cols + 1;
  18226. for (var col = 1; col < cols; col++, offset++) {
  18227. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  18228. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  18229. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  18230. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  18231. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  18232. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  18233. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  18234. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  18235. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  18236. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  18237. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  18238. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  18239. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  18240. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  18241. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  18242. coords[pIndex + 6] = coords[pIndex + 2];
  18243. coords[pIndex + 7] = coords[pIndex + 3];
  18244. coords[pIndex + 8] = coords[pIndex + 4];
  18245. coords[pIndex + 9] = coords[pIndex + 5];
  18246. coords[pIndex + 10] = coordsMap[ps[offset]];
  18247. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  18248. colors[cIndex + 9] = colors[cIndex + 3];
  18249. colors[cIndex + 10] = colors[cIndex + 4];
  18250. colors[cIndex + 11] = colors[cIndex + 5];
  18251. colors[cIndex + 12] = colors[cIndex + 6];
  18252. colors[cIndex + 13] = colors[cIndex + 7];
  18253. colors[cIndex + 14] = colors[cIndex + 8];
  18254. colors[cIndex + 15] = colorsMap[cs[offset]];
  18255. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  18256. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  18257. pIndex += 12;
  18258. cIndex += 18;
  18259. }
  18260. }
  18261. break;
  18262. case "triangles":
  18263. for (var j = 0, jj = ps.length; j < jj; j++) {
  18264. coords[pIndex] = coordsMap[ps[j]];
  18265. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  18266. colors[cIndex] = colorsMap[cs[j]];
  18267. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  18268. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  18269. pIndex += 2;
  18270. cIndex += 3;
  18271. }
  18272. break;
  18273. }
  18274. }
  18275. if (backgroundColor) {
  18276. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  18277. } else {
  18278. gl.clearColor(0, 0, 0, 0);
  18279. }
  18280. gl.clear(gl.COLOR_BUFFER_BIT);
  18281. var coordsBuffer = gl.createBuffer();
  18282. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  18283. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  18284. gl.enableVertexAttribArray(cache.positionLocation);
  18285. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  18286. var colorsBuffer = gl.createBuffer();
  18287. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  18288. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  18289. gl.enableVertexAttribArray(cache.colorLocation);
  18290. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  18291. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  18292. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  18293. gl.drawArrays(gl.TRIANGLES, 0, count);
  18294. gl.flush();
  18295. gl.deleteBuffer(coordsBuffer);
  18296. gl.deleteBuffer(colorsBuffer);
  18297. return canvas;
  18298. }
  18299. return {
  18300. tryInitGL: function tryInitGL() {
  18301. try {
  18302. generateGL();
  18303. return !!currentGL;
  18304. } catch (ex) {}
  18305. return false;
  18306. },
  18307. composeSMask: composeSMask,
  18308. drawFigures: drawFigures,
  18309. cleanup: function cleanup() {
  18310. if (smaskCache && smaskCache.canvas) {
  18311. smaskCache.canvas.width = 0;
  18312. smaskCache.canvas.height = 0;
  18313. }
  18314. if (figuresCache && figuresCache.canvas) {
  18315. figuresCache.canvas.width = 0;
  18316. figuresCache.canvas.height = 0;
  18317. }
  18318. smaskCache = null;
  18319. figuresCache = null;
  18320. }
  18321. };
  18322. }();
  18323. /***/ }),
  18324. /* 216 */
  18325. /***/ (function(module, exports, __w_pdfjs_require__) {
  18326. "use strict";
  18327. Object.defineProperty(exports, "__esModule", {
  18328. value: true
  18329. });
  18330. exports.AnnotationLayer = void 0;
  18331. var _display_utils = __w_pdfjs_require__(1);
  18332. var _util = __w_pdfjs_require__(5);
  18333. var _annotation_storage = __w_pdfjs_require__(205);
  18334. 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); }
  18335. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  18336. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  18337. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  18338. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  18339. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  18340. 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); }
  18341. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  18342. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  18343. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  18344. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  18345. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  18346. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  18347. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18348. 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); } }
  18349. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  18350. var AnnotationElementFactory = /*#__PURE__*/function () {
  18351. function AnnotationElementFactory() {
  18352. _classCallCheck(this, AnnotationElementFactory);
  18353. }
  18354. _createClass(AnnotationElementFactory, null, [{
  18355. key: "create",
  18356. value: function create(parameters) {
  18357. var subtype = parameters.data.annotationType;
  18358. switch (subtype) {
  18359. case _util.AnnotationType.LINK:
  18360. return new LinkAnnotationElement(parameters);
  18361. case _util.AnnotationType.TEXT:
  18362. return new TextAnnotationElement(parameters);
  18363. case _util.AnnotationType.WIDGET:
  18364. var fieldType = parameters.data.fieldType;
  18365. switch (fieldType) {
  18366. case "Tx":
  18367. return new TextWidgetAnnotationElement(parameters);
  18368. case "Btn":
  18369. if (parameters.data.radioButton) {
  18370. return new RadioButtonWidgetAnnotationElement(parameters);
  18371. } else if (parameters.data.checkBox) {
  18372. return new CheckboxWidgetAnnotationElement(parameters);
  18373. }
  18374. return new PushButtonWidgetAnnotationElement(parameters);
  18375. case "Ch":
  18376. return new ChoiceWidgetAnnotationElement(parameters);
  18377. }
  18378. return new WidgetAnnotationElement(parameters);
  18379. case _util.AnnotationType.POPUP:
  18380. return new PopupAnnotationElement(parameters);
  18381. case _util.AnnotationType.FREETEXT:
  18382. return new FreeTextAnnotationElement(parameters);
  18383. case _util.AnnotationType.LINE:
  18384. return new LineAnnotationElement(parameters);
  18385. case _util.AnnotationType.SQUARE:
  18386. return new SquareAnnotationElement(parameters);
  18387. case _util.AnnotationType.CIRCLE:
  18388. return new CircleAnnotationElement(parameters);
  18389. case _util.AnnotationType.POLYLINE:
  18390. return new PolylineAnnotationElement(parameters);
  18391. case _util.AnnotationType.CARET:
  18392. return new CaretAnnotationElement(parameters);
  18393. case _util.AnnotationType.INK:
  18394. return new InkAnnotationElement(parameters);
  18395. case _util.AnnotationType.POLYGON:
  18396. return new PolygonAnnotationElement(parameters);
  18397. case _util.AnnotationType.HIGHLIGHT:
  18398. return new HighlightAnnotationElement(parameters);
  18399. case _util.AnnotationType.UNDERLINE:
  18400. return new UnderlineAnnotationElement(parameters);
  18401. case _util.AnnotationType.SQUIGGLY:
  18402. return new SquigglyAnnotationElement(parameters);
  18403. case _util.AnnotationType.STRIKEOUT:
  18404. return new StrikeOutAnnotationElement(parameters);
  18405. case _util.AnnotationType.STAMP:
  18406. return new StampAnnotationElement(parameters);
  18407. case _util.AnnotationType.FILEATTACHMENT:
  18408. return new FileAttachmentAnnotationElement(parameters);
  18409. default:
  18410. return new AnnotationElement(parameters);
  18411. }
  18412. }
  18413. }]);
  18414. return AnnotationElementFactory;
  18415. }();
  18416. var AnnotationElement = /*#__PURE__*/function () {
  18417. function AnnotationElement(parameters) {
  18418. var isRenderable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  18419. var ignoreBorder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  18420. _classCallCheck(this, AnnotationElement);
  18421. this.isRenderable = isRenderable;
  18422. this.data = parameters.data;
  18423. this.layer = parameters.layer;
  18424. this.page = parameters.page;
  18425. this.viewport = parameters.viewport;
  18426. this.linkService = parameters.linkService;
  18427. this.downloadManager = parameters.downloadManager;
  18428. this.imageResourcesPath = parameters.imageResourcesPath;
  18429. this.renderInteractiveForms = parameters.renderInteractiveForms;
  18430. this.svgFactory = parameters.svgFactory;
  18431. this.annotationStorage = parameters.annotationStorage;
  18432. if (isRenderable) {
  18433. this.container = this._createContainer(ignoreBorder);
  18434. }
  18435. }
  18436. _createClass(AnnotationElement, [{
  18437. key: "_createContainer",
  18438. value: function _createContainer() {
  18439. var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  18440. var data = this.data,
  18441. page = this.page,
  18442. viewport = this.viewport;
  18443. var container = document.createElement("section");
  18444. var width = data.rect[2] - data.rect[0];
  18445. var height = data.rect[3] - data.rect[1];
  18446. container.setAttribute("data-annotation-id", data.id);
  18447. 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]]);
  18448. container.style.transform = "matrix(".concat(viewport.transform.join(","), ")");
  18449. container.style.transformOrigin = "-".concat(rect[0], "px -").concat(rect[1], "px");
  18450. if (!ignoreBorder && data.borderStyle.width > 0) {
  18451. container.style.borderWidth = "".concat(data.borderStyle.width, "px");
  18452. if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
  18453. width = width - 2 * data.borderStyle.width;
  18454. height = height - 2 * data.borderStyle.width;
  18455. }
  18456. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  18457. var verticalRadius = data.borderStyle.verticalCornerRadius;
  18458. if (horizontalRadius > 0 || verticalRadius > 0) {
  18459. var radius = "".concat(horizontalRadius, "px / ").concat(verticalRadius, "px");
  18460. container.style.borderRadius = radius;
  18461. }
  18462. switch (data.borderStyle.style) {
  18463. case _util.AnnotationBorderStyleType.SOLID:
  18464. container.style.borderStyle = "solid";
  18465. break;
  18466. case _util.AnnotationBorderStyleType.DASHED:
  18467. container.style.borderStyle = "dashed";
  18468. break;
  18469. case _util.AnnotationBorderStyleType.BEVELED:
  18470. (0, _util.warn)("Unimplemented border style: beveled");
  18471. break;
  18472. case _util.AnnotationBorderStyleType.INSET:
  18473. (0, _util.warn)("Unimplemented border style: inset");
  18474. break;
  18475. case _util.AnnotationBorderStyleType.UNDERLINE:
  18476. container.style.borderBottomStyle = "solid";
  18477. break;
  18478. default:
  18479. break;
  18480. }
  18481. if (data.color) {
  18482. container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  18483. } else {
  18484. container.style.borderWidth = 0;
  18485. }
  18486. }
  18487. container.style.left = "".concat(rect[0], "px");
  18488. container.style.top = "".concat(rect[1], "px");
  18489. container.style.width = "".concat(width, "px");
  18490. container.style.height = "".concat(height, "px");
  18491. return container;
  18492. }
  18493. }, {
  18494. key: "_createPopup",
  18495. value: function _createPopup(container, trigger, data) {
  18496. if (!trigger) {
  18497. trigger = document.createElement("div");
  18498. trigger.style.height = container.style.height;
  18499. trigger.style.width = container.style.width;
  18500. container.appendChild(trigger);
  18501. }
  18502. var popupElement = new PopupElement({
  18503. container: container,
  18504. trigger: trigger,
  18505. color: data.color,
  18506. title: data.title,
  18507. modificationDate: data.modificationDate,
  18508. contents: data.contents,
  18509. hideWrapper: true
  18510. });
  18511. var popup = popupElement.render();
  18512. popup.style.left = container.style.width;
  18513. container.appendChild(popup);
  18514. }
  18515. }, {
  18516. key: "render",
  18517. value: function render() {
  18518. (0, _util.unreachable)("Abstract method `AnnotationElement.render` called");
  18519. }
  18520. }]);
  18521. return AnnotationElement;
  18522. }();
  18523. var LinkAnnotationElement = /*#__PURE__*/function (_AnnotationElement) {
  18524. _inherits(LinkAnnotationElement, _AnnotationElement);
  18525. var _super = _createSuper(LinkAnnotationElement);
  18526. function LinkAnnotationElement(parameters) {
  18527. _classCallCheck(this, LinkAnnotationElement);
  18528. var isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);
  18529. return _super.call(this, parameters, isRenderable);
  18530. }
  18531. _createClass(LinkAnnotationElement, [{
  18532. key: "render",
  18533. value: function render() {
  18534. this.container.className = "linkAnnotation";
  18535. var data = this.data,
  18536. linkService = this.linkService;
  18537. var link = document.createElement("a");
  18538. if (data.url) {
  18539. (0, _display_utils.addLinkAttributes)(link, {
  18540. url: data.url,
  18541. target: data.newWindow ? _display_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
  18542. rel: linkService.externalLinkRel,
  18543. enabled: linkService.externalLinkEnabled
  18544. });
  18545. } else if (data.action) {
  18546. this._bindNamedAction(link, data.action);
  18547. } else {
  18548. this._bindLink(link, data.dest);
  18549. }
  18550. this.container.appendChild(link);
  18551. return this.container;
  18552. }
  18553. }, {
  18554. key: "_bindLink",
  18555. value: function _bindLink(link, destination) {
  18556. var _this = this;
  18557. link.href = this.linkService.getDestinationHash(destination);
  18558. link.onclick = function () {
  18559. if (destination) {
  18560. _this.linkService.navigateTo(destination);
  18561. }
  18562. return false;
  18563. };
  18564. if (destination) {
  18565. link.className = "internalLink";
  18566. }
  18567. }
  18568. }, {
  18569. key: "_bindNamedAction",
  18570. value: function _bindNamedAction(link, action) {
  18571. var _this2 = this;
  18572. link.href = this.linkService.getAnchorUrl("");
  18573. link.onclick = function () {
  18574. _this2.linkService.executeNamedAction(action);
  18575. return false;
  18576. };
  18577. link.className = "internalLink";
  18578. }
  18579. }]);
  18580. return LinkAnnotationElement;
  18581. }(AnnotationElement);
  18582. var TextAnnotationElement = /*#__PURE__*/function (_AnnotationElement2) {
  18583. _inherits(TextAnnotationElement, _AnnotationElement2);
  18584. var _super2 = _createSuper(TextAnnotationElement);
  18585. function TextAnnotationElement(parameters) {
  18586. _classCallCheck(this, TextAnnotationElement);
  18587. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18588. return _super2.call(this, parameters, isRenderable);
  18589. }
  18590. _createClass(TextAnnotationElement, [{
  18591. key: "render",
  18592. value: function render() {
  18593. this.container.className = "textAnnotation";
  18594. var image = document.createElement("img");
  18595. image.style.height = this.container.style.height;
  18596. image.style.width = this.container.style.width;
  18597. image.src = this.imageResourcesPath + "annotation-" + this.data.name.toLowerCase() + ".svg";
  18598. image.alt = "[{{type}} Annotation]";
  18599. image.dataset.l10nId = "text_annotation_type";
  18600. image.dataset.l10nArgs = JSON.stringify({
  18601. type: this.data.name
  18602. });
  18603. if (!this.data.hasPopup) {
  18604. this._createPopup(this.container, image, this.data);
  18605. }
  18606. this.container.appendChild(image);
  18607. return this.container;
  18608. }
  18609. }]);
  18610. return TextAnnotationElement;
  18611. }(AnnotationElement);
  18612. var WidgetAnnotationElement = /*#__PURE__*/function (_AnnotationElement3) {
  18613. _inherits(WidgetAnnotationElement, _AnnotationElement3);
  18614. var _super3 = _createSuper(WidgetAnnotationElement);
  18615. function WidgetAnnotationElement() {
  18616. _classCallCheck(this, WidgetAnnotationElement);
  18617. return _super3.apply(this, arguments);
  18618. }
  18619. _createClass(WidgetAnnotationElement, [{
  18620. key: "render",
  18621. value: function render() {
  18622. return this.container;
  18623. }
  18624. }]);
  18625. return WidgetAnnotationElement;
  18626. }(AnnotationElement);
  18627. var TextWidgetAnnotationElement = /*#__PURE__*/function (_WidgetAnnotationElem) {
  18628. _inherits(TextWidgetAnnotationElement, _WidgetAnnotationElem);
  18629. var _super4 = _createSuper(TextWidgetAnnotationElement);
  18630. function TextWidgetAnnotationElement(parameters) {
  18631. _classCallCheck(this, TextWidgetAnnotationElement);
  18632. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  18633. return _super4.call(this, parameters, isRenderable);
  18634. }
  18635. _createClass(TextWidgetAnnotationElement, [{
  18636. key: "render",
  18637. value: function render() {
  18638. var TEXT_ALIGNMENT = ["left", "center", "right"];
  18639. var storage = this.annotationStorage;
  18640. var id = this.data.id;
  18641. this.container.className = "textWidgetAnnotation";
  18642. var element = null;
  18643. if (this.renderInteractiveForms) {
  18644. var textContent = storage.getOrCreateValue(id, this.data.fieldValue);
  18645. if (this.data.multiLine) {
  18646. element = document.createElement("textarea");
  18647. element.textContent = textContent;
  18648. } else {
  18649. element = document.createElement("input");
  18650. element.type = "text";
  18651. element.setAttribute("value", textContent);
  18652. }
  18653. element.addEventListener("input", function (event) {
  18654. storage.setValue(id, event.target.value);
  18655. });
  18656. element.disabled = this.data.readOnly;
  18657. element.name = this.data.fieldName;
  18658. if (this.data.maxLen !== null) {
  18659. element.maxLength = this.data.maxLen;
  18660. }
  18661. if (this.data.comb) {
  18662. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  18663. var combWidth = fieldWidth / this.data.maxLen;
  18664. element.classList.add("comb");
  18665. element.style.letterSpacing = "calc(".concat(combWidth, "px - 1ch)");
  18666. }
  18667. } else {
  18668. element = document.createElement("div");
  18669. element.textContent = this.data.fieldValue;
  18670. element.style.verticalAlign = "middle";
  18671. element.style.display = "table-cell";
  18672. var font = null;
  18673. if (this.data.fontRefName && this.page.commonObjs.has(this.data.fontRefName)) {
  18674. font = this.page.commonObjs.get(this.data.fontRefName);
  18675. }
  18676. this._setTextStyle(element, font);
  18677. }
  18678. if (this.data.textAlignment !== null) {
  18679. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  18680. }
  18681. this.container.appendChild(element);
  18682. return this.container;
  18683. }
  18684. }, {
  18685. key: "_setTextStyle",
  18686. value: function _setTextStyle(element, font) {
  18687. var style = element.style;
  18688. style.fontSize = "".concat(this.data.fontSize, "px");
  18689. style.direction = this.data.fontDirection < 0 ? "rtl" : "ltr";
  18690. if (!font) {
  18691. return;
  18692. }
  18693. var bold = "normal";
  18694. if (font.black) {
  18695. bold = "900";
  18696. } else if (font.bold) {
  18697. bold = "bold";
  18698. }
  18699. style.fontWeight = bold;
  18700. style.fontStyle = font.italic ? "italic" : "normal";
  18701. var fontFamily = font.loadedName ? "\"".concat(font.loadedName, "\", ") : "";
  18702. var fallbackName = font.fallbackName || "Helvetica, sans-serif";
  18703. style.fontFamily = fontFamily + fallbackName;
  18704. }
  18705. }]);
  18706. return TextWidgetAnnotationElement;
  18707. }(WidgetAnnotationElement);
  18708. var CheckboxWidgetAnnotationElement = /*#__PURE__*/function (_WidgetAnnotationElem2) {
  18709. _inherits(CheckboxWidgetAnnotationElement, _WidgetAnnotationElem2);
  18710. var _super5 = _createSuper(CheckboxWidgetAnnotationElement);
  18711. function CheckboxWidgetAnnotationElement(parameters) {
  18712. _classCallCheck(this, CheckboxWidgetAnnotationElement);
  18713. return _super5.call(this, parameters, parameters.renderInteractiveForms);
  18714. }
  18715. _createClass(CheckboxWidgetAnnotationElement, [{
  18716. key: "render",
  18717. value: function render() {
  18718. var storage = this.annotationStorage;
  18719. var data = this.data;
  18720. var id = data.id;
  18721. var value = storage.getOrCreateValue(id, data.fieldValue && data.fieldValue !== "Off");
  18722. this.container.className = "buttonWidgetAnnotation checkBox";
  18723. var element = document.createElement("input");
  18724. element.disabled = data.readOnly;
  18725. element.type = "checkbox";
  18726. element.name = this.data.fieldName;
  18727. if (value) {
  18728. element.setAttribute("checked", true);
  18729. }
  18730. element.addEventListener("change", function (event) {
  18731. storage.setValue(id, event.target.checked);
  18732. });
  18733. this.container.appendChild(element);
  18734. return this.container;
  18735. }
  18736. }]);
  18737. return CheckboxWidgetAnnotationElement;
  18738. }(WidgetAnnotationElement);
  18739. var RadioButtonWidgetAnnotationElement = /*#__PURE__*/function (_WidgetAnnotationElem3) {
  18740. _inherits(RadioButtonWidgetAnnotationElement, _WidgetAnnotationElem3);
  18741. var _super6 = _createSuper(RadioButtonWidgetAnnotationElement);
  18742. function RadioButtonWidgetAnnotationElement(parameters) {
  18743. _classCallCheck(this, RadioButtonWidgetAnnotationElement);
  18744. return _super6.call(this, parameters, parameters.renderInteractiveForms);
  18745. }
  18746. _createClass(RadioButtonWidgetAnnotationElement, [{
  18747. key: "render",
  18748. value: function render() {
  18749. this.container.className = "buttonWidgetAnnotation radioButton";
  18750. var storage = this.annotationStorage;
  18751. var data = this.data;
  18752. var id = data.id;
  18753. var value = storage.getOrCreateValue(id, data.fieldValue === data.buttonValue);
  18754. var element = document.createElement("input");
  18755. element.disabled = data.readOnly;
  18756. element.type = "radio";
  18757. element.name = data.fieldName;
  18758. if (value) {
  18759. element.setAttribute("checked", true);
  18760. }
  18761. element.addEventListener("change", function (event) {
  18762. var name = event.target.name;
  18763. var _iterator = _createForOfIteratorHelper(document.getElementsByName(name)),
  18764. _step;
  18765. try {
  18766. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  18767. var radio = _step.value;
  18768. if (radio !== event.target) {
  18769. storage.setValue(radio.parentNode.getAttribute("data-annotation-id"), false);
  18770. }
  18771. }
  18772. } catch (err) {
  18773. _iterator.e(err);
  18774. } finally {
  18775. _iterator.f();
  18776. }
  18777. storage.setValue(id, event.target.checked);
  18778. });
  18779. this.container.appendChild(element);
  18780. return this.container;
  18781. }
  18782. }]);
  18783. return RadioButtonWidgetAnnotationElement;
  18784. }(WidgetAnnotationElement);
  18785. var PushButtonWidgetAnnotationElement = /*#__PURE__*/function (_LinkAnnotationElemen) {
  18786. _inherits(PushButtonWidgetAnnotationElement, _LinkAnnotationElemen);
  18787. var _super7 = _createSuper(PushButtonWidgetAnnotationElement);
  18788. function PushButtonWidgetAnnotationElement() {
  18789. _classCallCheck(this, PushButtonWidgetAnnotationElement);
  18790. return _super7.apply(this, arguments);
  18791. }
  18792. _createClass(PushButtonWidgetAnnotationElement, [{
  18793. key: "render",
  18794. value: function render() {
  18795. var container = _get(_getPrototypeOf(PushButtonWidgetAnnotationElement.prototype), "render", this).call(this);
  18796. container.className = "buttonWidgetAnnotation pushButton";
  18797. return container;
  18798. }
  18799. }]);
  18800. return PushButtonWidgetAnnotationElement;
  18801. }(LinkAnnotationElement);
  18802. var ChoiceWidgetAnnotationElement = /*#__PURE__*/function (_WidgetAnnotationElem4) {
  18803. _inherits(ChoiceWidgetAnnotationElement, _WidgetAnnotationElem4);
  18804. var _super8 = _createSuper(ChoiceWidgetAnnotationElement);
  18805. function ChoiceWidgetAnnotationElement(parameters) {
  18806. _classCallCheck(this, ChoiceWidgetAnnotationElement);
  18807. return _super8.call(this, parameters, parameters.renderInteractiveForms);
  18808. }
  18809. _createClass(ChoiceWidgetAnnotationElement, [{
  18810. key: "render",
  18811. value: function render() {
  18812. this.container.className = "choiceWidgetAnnotation";
  18813. var storage = this.annotationStorage;
  18814. var id = this.data.id;
  18815. storage.getOrCreateValue(id, this.data.fieldValue.length > 0 ? this.data.fieldValue[0] : null);
  18816. var selectElement = document.createElement("select");
  18817. selectElement.disabled = this.data.readOnly;
  18818. selectElement.name = this.data.fieldName;
  18819. if (!this.data.combo) {
  18820. selectElement.size = this.data.options.length;
  18821. if (this.data.multiSelect) {
  18822. selectElement.multiple = true;
  18823. }
  18824. }
  18825. var _iterator2 = _createForOfIteratorHelper(this.data.options),
  18826. _step2;
  18827. try {
  18828. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  18829. var option = _step2.value;
  18830. var optionElement = document.createElement("option");
  18831. optionElement.textContent = option.displayValue;
  18832. optionElement.value = option.exportValue;
  18833. if (this.data.fieldValue.includes(option.exportValue)) {
  18834. optionElement.setAttribute("selected", true);
  18835. }
  18836. selectElement.appendChild(optionElement);
  18837. }
  18838. } catch (err) {
  18839. _iterator2.e(err);
  18840. } finally {
  18841. _iterator2.f();
  18842. }
  18843. selectElement.addEventListener("input", function (event) {
  18844. var options = event.target.options;
  18845. var value = options[options.selectedIndex].value;
  18846. storage.setValue(id, value);
  18847. });
  18848. this.container.appendChild(selectElement);
  18849. return this.container;
  18850. }
  18851. }]);
  18852. return ChoiceWidgetAnnotationElement;
  18853. }(WidgetAnnotationElement);
  18854. var PopupAnnotationElement = /*#__PURE__*/function (_AnnotationElement4) {
  18855. _inherits(PopupAnnotationElement, _AnnotationElement4);
  18856. var _super9 = _createSuper(PopupAnnotationElement);
  18857. function PopupAnnotationElement(parameters) {
  18858. _classCallCheck(this, PopupAnnotationElement);
  18859. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  18860. return _super9.call(this, parameters, isRenderable);
  18861. }
  18862. _createClass(PopupAnnotationElement, [{
  18863. key: "render",
  18864. value: function render() {
  18865. var IGNORE_TYPES = ["Line", "Square", "Circle", "PolyLine", "Polygon", "Ink"];
  18866. this.container.className = "popupAnnotation";
  18867. if (IGNORE_TYPES.includes(this.data.parentType)) {
  18868. return this.container;
  18869. }
  18870. var selector = "[data-annotation-id=\"".concat(this.data.parentId, "\"]");
  18871. var parentElement = this.layer.querySelector(selector);
  18872. if (!parentElement) {
  18873. return this.container;
  18874. }
  18875. var popup = new PopupElement({
  18876. container: this.container,
  18877. trigger: parentElement,
  18878. color: this.data.color,
  18879. title: this.data.title,
  18880. modificationDate: this.data.modificationDate,
  18881. contents: this.data.contents
  18882. });
  18883. var parentLeft = parseFloat(parentElement.style.left);
  18884. var parentWidth = parseFloat(parentElement.style.width);
  18885. this.container.style.transformOrigin = "-".concat(parentLeft + parentWidth, "px -").concat(parentElement.style.top);
  18886. this.container.style.left = "".concat(parentLeft + parentWidth, "px");
  18887. this.container.appendChild(popup.render());
  18888. return this.container;
  18889. }
  18890. }]);
  18891. return PopupAnnotationElement;
  18892. }(AnnotationElement);
  18893. var PopupElement = /*#__PURE__*/function () {
  18894. function PopupElement(parameters) {
  18895. _classCallCheck(this, PopupElement);
  18896. this.container = parameters.container;
  18897. this.trigger = parameters.trigger;
  18898. this.color = parameters.color;
  18899. this.title = parameters.title;
  18900. this.modificationDate = parameters.modificationDate;
  18901. this.contents = parameters.contents;
  18902. this.hideWrapper = parameters.hideWrapper || false;
  18903. this.pinned = false;
  18904. }
  18905. _createClass(PopupElement, [{
  18906. key: "render",
  18907. value: function render() {
  18908. var BACKGROUND_ENLIGHT = 0.7;
  18909. var wrapper = document.createElement("div");
  18910. wrapper.className = "popupWrapper";
  18911. this.hideElement = this.hideWrapper ? wrapper : this.container;
  18912. this.hideElement.setAttribute("hidden", true);
  18913. var popup = document.createElement("div");
  18914. popup.className = "popup";
  18915. var color = this.color;
  18916. if (color) {
  18917. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  18918. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  18919. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  18920. popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
  18921. }
  18922. var title = document.createElement("h1");
  18923. title.textContent = this.title;
  18924. popup.appendChild(title);
  18925. var dateObject = _display_utils.PDFDateString.toDateObject(this.modificationDate);
  18926. if (dateObject) {
  18927. var modificationDate = document.createElement("span");
  18928. modificationDate.textContent = "{{date}}, {{time}}";
  18929. modificationDate.dataset.l10nId = "annotation_date_string";
  18930. modificationDate.dataset.l10nArgs = JSON.stringify({
  18931. date: dateObject.toLocaleDateString(),
  18932. time: dateObject.toLocaleTimeString()
  18933. });
  18934. popup.appendChild(modificationDate);
  18935. }
  18936. var contents = this._formatContents(this.contents);
  18937. popup.appendChild(contents);
  18938. this.trigger.addEventListener("click", this._toggle.bind(this));
  18939. this.trigger.addEventListener("mouseover", this._show.bind(this, false));
  18940. this.trigger.addEventListener("mouseout", this._hide.bind(this, false));
  18941. popup.addEventListener("click", this._hide.bind(this, true));
  18942. wrapper.appendChild(popup);
  18943. return wrapper;
  18944. }
  18945. }, {
  18946. key: "_formatContents",
  18947. value: function _formatContents(contents) {
  18948. var p = document.createElement("p");
  18949. var lines = contents.split(/(?:\r\n?|\n)/);
  18950. for (var i = 0, ii = lines.length; i < ii; ++i) {
  18951. var line = lines[i];
  18952. p.appendChild(document.createTextNode(line));
  18953. if (i < ii - 1) {
  18954. p.appendChild(document.createElement("br"));
  18955. }
  18956. }
  18957. return p;
  18958. }
  18959. }, {
  18960. key: "_toggle",
  18961. value: function _toggle() {
  18962. if (this.pinned) {
  18963. this._hide(true);
  18964. } else {
  18965. this._show(true);
  18966. }
  18967. }
  18968. }, {
  18969. key: "_show",
  18970. value: function _show() {
  18971. var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  18972. if (pin) {
  18973. this.pinned = true;
  18974. }
  18975. if (this.hideElement.hasAttribute("hidden")) {
  18976. this.hideElement.removeAttribute("hidden");
  18977. this.container.style.zIndex += 1;
  18978. }
  18979. }
  18980. }, {
  18981. key: "_hide",
  18982. value: function _hide() {
  18983. var unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  18984. if (unpin) {
  18985. this.pinned = false;
  18986. }
  18987. if (!this.hideElement.hasAttribute("hidden") && !this.pinned) {
  18988. this.hideElement.setAttribute("hidden", true);
  18989. this.container.style.zIndex -= 1;
  18990. }
  18991. }
  18992. }]);
  18993. return PopupElement;
  18994. }();
  18995. var FreeTextAnnotationElement = /*#__PURE__*/function (_AnnotationElement5) {
  18996. _inherits(FreeTextAnnotationElement, _AnnotationElement5);
  18997. var _super10 = _createSuper(FreeTextAnnotationElement);
  18998. function FreeTextAnnotationElement(parameters) {
  18999. _classCallCheck(this, FreeTextAnnotationElement);
  19000. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19001. return _super10.call(this, parameters, isRenderable, true);
  19002. }
  19003. _createClass(FreeTextAnnotationElement, [{
  19004. key: "render",
  19005. value: function render() {
  19006. this.container.className = "freeTextAnnotation";
  19007. if (!this.data.hasPopup) {
  19008. this._createPopup(this.container, null, this.data);
  19009. }
  19010. return this.container;
  19011. }
  19012. }]);
  19013. return FreeTextAnnotationElement;
  19014. }(AnnotationElement);
  19015. var LineAnnotationElement = /*#__PURE__*/function (_AnnotationElement6) {
  19016. _inherits(LineAnnotationElement, _AnnotationElement6);
  19017. var _super11 = _createSuper(LineAnnotationElement);
  19018. function LineAnnotationElement(parameters) {
  19019. _classCallCheck(this, LineAnnotationElement);
  19020. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19021. return _super11.call(this, parameters, isRenderable, true);
  19022. }
  19023. _createClass(LineAnnotationElement, [{
  19024. key: "render",
  19025. value: function render() {
  19026. this.container.className = "lineAnnotation";
  19027. var data = this.data;
  19028. var width = data.rect[2] - data.rect[0];
  19029. var height = data.rect[3] - data.rect[1];
  19030. var svg = this.svgFactory.create(width, height);
  19031. var line = this.svgFactory.createElement("svg:line");
  19032. line.setAttribute("x1", data.rect[2] - data.lineCoordinates[0]);
  19033. line.setAttribute("y1", data.rect[3] - data.lineCoordinates[1]);
  19034. line.setAttribute("x2", data.rect[2] - data.lineCoordinates[2]);
  19035. line.setAttribute("y2", data.rect[3] - data.lineCoordinates[3]);
  19036. line.setAttribute("stroke-width", data.borderStyle.width || 1);
  19037. line.setAttribute("stroke", "transparent");
  19038. svg.appendChild(line);
  19039. this.container.append(svg);
  19040. this._createPopup(this.container, line, data);
  19041. return this.container;
  19042. }
  19043. }]);
  19044. return LineAnnotationElement;
  19045. }(AnnotationElement);
  19046. var SquareAnnotationElement = /*#__PURE__*/function (_AnnotationElement7) {
  19047. _inherits(SquareAnnotationElement, _AnnotationElement7);
  19048. var _super12 = _createSuper(SquareAnnotationElement);
  19049. function SquareAnnotationElement(parameters) {
  19050. _classCallCheck(this, SquareAnnotationElement);
  19051. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19052. return _super12.call(this, parameters, isRenderable, true);
  19053. }
  19054. _createClass(SquareAnnotationElement, [{
  19055. key: "render",
  19056. value: function render() {
  19057. this.container.className = "squareAnnotation";
  19058. var data = this.data;
  19059. var width = data.rect[2] - data.rect[0];
  19060. var height = data.rect[3] - data.rect[1];
  19061. var svg = this.svgFactory.create(width, height);
  19062. var borderWidth = data.borderStyle.width;
  19063. var square = this.svgFactory.createElement("svg:rect");
  19064. square.setAttribute("x", borderWidth / 2);
  19065. square.setAttribute("y", borderWidth / 2);
  19066. square.setAttribute("width", width - borderWidth);
  19067. square.setAttribute("height", height - borderWidth);
  19068. square.setAttribute("stroke-width", borderWidth || 1);
  19069. square.setAttribute("stroke", "transparent");
  19070. square.setAttribute("fill", "none");
  19071. svg.appendChild(square);
  19072. this.container.append(svg);
  19073. this._createPopup(this.container, square, data);
  19074. return this.container;
  19075. }
  19076. }]);
  19077. return SquareAnnotationElement;
  19078. }(AnnotationElement);
  19079. var CircleAnnotationElement = /*#__PURE__*/function (_AnnotationElement8) {
  19080. _inherits(CircleAnnotationElement, _AnnotationElement8);
  19081. var _super13 = _createSuper(CircleAnnotationElement);
  19082. function CircleAnnotationElement(parameters) {
  19083. _classCallCheck(this, CircleAnnotationElement);
  19084. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19085. return _super13.call(this, parameters, isRenderable, true);
  19086. }
  19087. _createClass(CircleAnnotationElement, [{
  19088. key: "render",
  19089. value: function render() {
  19090. this.container.className = "circleAnnotation";
  19091. var data = this.data;
  19092. var width = data.rect[2] - data.rect[0];
  19093. var height = data.rect[3] - data.rect[1];
  19094. var svg = this.svgFactory.create(width, height);
  19095. var borderWidth = data.borderStyle.width;
  19096. var circle = this.svgFactory.createElement("svg:ellipse");
  19097. circle.setAttribute("cx", width / 2);
  19098. circle.setAttribute("cy", height / 2);
  19099. circle.setAttribute("rx", width / 2 - borderWidth / 2);
  19100. circle.setAttribute("ry", height / 2 - borderWidth / 2);
  19101. circle.setAttribute("stroke-width", borderWidth || 1);
  19102. circle.setAttribute("stroke", "transparent");
  19103. circle.setAttribute("fill", "none");
  19104. svg.appendChild(circle);
  19105. this.container.append(svg);
  19106. this._createPopup(this.container, circle, data);
  19107. return this.container;
  19108. }
  19109. }]);
  19110. return CircleAnnotationElement;
  19111. }(AnnotationElement);
  19112. var PolylineAnnotationElement = /*#__PURE__*/function (_AnnotationElement9) {
  19113. _inherits(PolylineAnnotationElement, _AnnotationElement9);
  19114. var _super14 = _createSuper(PolylineAnnotationElement);
  19115. function PolylineAnnotationElement(parameters) {
  19116. var _this3;
  19117. _classCallCheck(this, PolylineAnnotationElement);
  19118. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19119. _this3 = _super14.call(this, parameters, isRenderable, true);
  19120. _this3.containerClassName = "polylineAnnotation";
  19121. _this3.svgElementName = "svg:polyline";
  19122. return _this3;
  19123. }
  19124. _createClass(PolylineAnnotationElement, [{
  19125. key: "render",
  19126. value: function render() {
  19127. this.container.className = this.containerClassName;
  19128. var data = this.data;
  19129. var width = data.rect[2] - data.rect[0];
  19130. var height = data.rect[3] - data.rect[1];
  19131. var svg = this.svgFactory.create(width, height);
  19132. var points = [];
  19133. var _iterator3 = _createForOfIteratorHelper(data.vertices),
  19134. _step3;
  19135. try {
  19136. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  19137. var coordinate = _step3.value;
  19138. var x = coordinate.x - data.rect[0];
  19139. var y = data.rect[3] - coordinate.y;
  19140. points.push(x + "," + y);
  19141. }
  19142. } catch (err) {
  19143. _iterator3.e(err);
  19144. } finally {
  19145. _iterator3.f();
  19146. }
  19147. points = points.join(" ");
  19148. var polyline = this.svgFactory.createElement(this.svgElementName);
  19149. polyline.setAttribute("points", points);
  19150. polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
  19151. polyline.setAttribute("stroke", "transparent");
  19152. polyline.setAttribute("fill", "none");
  19153. svg.appendChild(polyline);
  19154. this.container.append(svg);
  19155. this._createPopup(this.container, polyline, data);
  19156. return this.container;
  19157. }
  19158. }]);
  19159. return PolylineAnnotationElement;
  19160. }(AnnotationElement);
  19161. var PolygonAnnotationElement = /*#__PURE__*/function (_PolylineAnnotationEl) {
  19162. _inherits(PolygonAnnotationElement, _PolylineAnnotationEl);
  19163. var _super15 = _createSuper(PolygonAnnotationElement);
  19164. function PolygonAnnotationElement(parameters) {
  19165. var _this4;
  19166. _classCallCheck(this, PolygonAnnotationElement);
  19167. _this4 = _super15.call(this, parameters);
  19168. _this4.containerClassName = "polygonAnnotation";
  19169. _this4.svgElementName = "svg:polygon";
  19170. return _this4;
  19171. }
  19172. return PolygonAnnotationElement;
  19173. }(PolylineAnnotationElement);
  19174. var CaretAnnotationElement = /*#__PURE__*/function (_AnnotationElement10) {
  19175. _inherits(CaretAnnotationElement, _AnnotationElement10);
  19176. var _super16 = _createSuper(CaretAnnotationElement);
  19177. function CaretAnnotationElement(parameters) {
  19178. _classCallCheck(this, CaretAnnotationElement);
  19179. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19180. return _super16.call(this, parameters, isRenderable, true);
  19181. }
  19182. _createClass(CaretAnnotationElement, [{
  19183. key: "render",
  19184. value: function render() {
  19185. this.container.className = "caretAnnotation";
  19186. if (!this.data.hasPopup) {
  19187. this._createPopup(this.container, null, this.data);
  19188. }
  19189. return this.container;
  19190. }
  19191. }]);
  19192. return CaretAnnotationElement;
  19193. }(AnnotationElement);
  19194. var InkAnnotationElement = /*#__PURE__*/function (_AnnotationElement11) {
  19195. _inherits(InkAnnotationElement, _AnnotationElement11);
  19196. var _super17 = _createSuper(InkAnnotationElement);
  19197. function InkAnnotationElement(parameters) {
  19198. var _this5;
  19199. _classCallCheck(this, InkAnnotationElement);
  19200. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19201. _this5 = _super17.call(this, parameters, isRenderable, true);
  19202. _this5.containerClassName = "inkAnnotation";
  19203. _this5.svgElementName = "svg:polyline";
  19204. return _this5;
  19205. }
  19206. _createClass(InkAnnotationElement, [{
  19207. key: "render",
  19208. value: function render() {
  19209. this.container.className = this.containerClassName;
  19210. var data = this.data;
  19211. var width = data.rect[2] - data.rect[0];
  19212. var height = data.rect[3] - data.rect[1];
  19213. var svg = this.svgFactory.create(width, height);
  19214. var _iterator4 = _createForOfIteratorHelper(data.inkLists),
  19215. _step4;
  19216. try {
  19217. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  19218. var inkList = _step4.value;
  19219. var points = [];
  19220. var _iterator5 = _createForOfIteratorHelper(inkList),
  19221. _step5;
  19222. try {
  19223. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  19224. var coordinate = _step5.value;
  19225. var x = coordinate.x - data.rect[0];
  19226. var y = data.rect[3] - coordinate.y;
  19227. points.push("".concat(x, ",").concat(y));
  19228. }
  19229. } catch (err) {
  19230. _iterator5.e(err);
  19231. } finally {
  19232. _iterator5.f();
  19233. }
  19234. points = points.join(" ");
  19235. var polyline = this.svgFactory.createElement(this.svgElementName);
  19236. polyline.setAttribute("points", points);
  19237. polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
  19238. polyline.setAttribute("stroke", "transparent");
  19239. polyline.setAttribute("fill", "none");
  19240. this._createPopup(this.container, polyline, data);
  19241. svg.appendChild(polyline);
  19242. }
  19243. } catch (err) {
  19244. _iterator4.e(err);
  19245. } finally {
  19246. _iterator4.f();
  19247. }
  19248. this.container.append(svg);
  19249. return this.container;
  19250. }
  19251. }]);
  19252. return InkAnnotationElement;
  19253. }(AnnotationElement);
  19254. var HighlightAnnotationElement = /*#__PURE__*/function (_AnnotationElement12) {
  19255. _inherits(HighlightAnnotationElement, _AnnotationElement12);
  19256. var _super18 = _createSuper(HighlightAnnotationElement);
  19257. function HighlightAnnotationElement(parameters) {
  19258. _classCallCheck(this, HighlightAnnotationElement);
  19259. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19260. return _super18.call(this, parameters, isRenderable, true);
  19261. }
  19262. _createClass(HighlightAnnotationElement, [{
  19263. key: "render",
  19264. value: function render() {
  19265. this.container.className = "highlightAnnotation";
  19266. if (!this.data.hasPopup) {
  19267. this._createPopup(this.container, null, this.data);
  19268. }
  19269. return this.container;
  19270. }
  19271. }]);
  19272. return HighlightAnnotationElement;
  19273. }(AnnotationElement);
  19274. var UnderlineAnnotationElement = /*#__PURE__*/function (_AnnotationElement13) {
  19275. _inherits(UnderlineAnnotationElement, _AnnotationElement13);
  19276. var _super19 = _createSuper(UnderlineAnnotationElement);
  19277. function UnderlineAnnotationElement(parameters) {
  19278. _classCallCheck(this, UnderlineAnnotationElement);
  19279. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19280. return _super19.call(this, parameters, isRenderable, true);
  19281. }
  19282. _createClass(UnderlineAnnotationElement, [{
  19283. key: "render",
  19284. value: function render() {
  19285. this.container.className = "underlineAnnotation";
  19286. if (!this.data.hasPopup) {
  19287. this._createPopup(this.container, null, this.data);
  19288. }
  19289. return this.container;
  19290. }
  19291. }]);
  19292. return UnderlineAnnotationElement;
  19293. }(AnnotationElement);
  19294. var SquigglyAnnotationElement = /*#__PURE__*/function (_AnnotationElement14) {
  19295. _inherits(SquigglyAnnotationElement, _AnnotationElement14);
  19296. var _super20 = _createSuper(SquigglyAnnotationElement);
  19297. function SquigglyAnnotationElement(parameters) {
  19298. _classCallCheck(this, SquigglyAnnotationElement);
  19299. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19300. return _super20.call(this, parameters, isRenderable, true);
  19301. }
  19302. _createClass(SquigglyAnnotationElement, [{
  19303. key: "render",
  19304. value: function render() {
  19305. this.container.className = "squigglyAnnotation";
  19306. if (!this.data.hasPopup) {
  19307. this._createPopup(this.container, null, this.data);
  19308. }
  19309. return this.container;
  19310. }
  19311. }]);
  19312. return SquigglyAnnotationElement;
  19313. }(AnnotationElement);
  19314. var StrikeOutAnnotationElement = /*#__PURE__*/function (_AnnotationElement15) {
  19315. _inherits(StrikeOutAnnotationElement, _AnnotationElement15);
  19316. var _super21 = _createSuper(StrikeOutAnnotationElement);
  19317. function StrikeOutAnnotationElement(parameters) {
  19318. _classCallCheck(this, StrikeOutAnnotationElement);
  19319. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19320. return _super21.call(this, parameters, isRenderable, true);
  19321. }
  19322. _createClass(StrikeOutAnnotationElement, [{
  19323. key: "render",
  19324. value: function render() {
  19325. this.container.className = "strikeoutAnnotation";
  19326. if (!this.data.hasPopup) {
  19327. this._createPopup(this.container, null, this.data);
  19328. }
  19329. return this.container;
  19330. }
  19331. }]);
  19332. return StrikeOutAnnotationElement;
  19333. }(AnnotationElement);
  19334. var StampAnnotationElement = /*#__PURE__*/function (_AnnotationElement16) {
  19335. _inherits(StampAnnotationElement, _AnnotationElement16);
  19336. var _super22 = _createSuper(StampAnnotationElement);
  19337. function StampAnnotationElement(parameters) {
  19338. _classCallCheck(this, StampAnnotationElement);
  19339. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19340. return _super22.call(this, parameters, isRenderable, true);
  19341. }
  19342. _createClass(StampAnnotationElement, [{
  19343. key: "render",
  19344. value: function render() {
  19345. this.container.className = "stampAnnotation";
  19346. if (!this.data.hasPopup) {
  19347. this._createPopup(this.container, null, this.data);
  19348. }
  19349. return this.container;
  19350. }
  19351. }]);
  19352. return StampAnnotationElement;
  19353. }(AnnotationElement);
  19354. var FileAttachmentAnnotationElement = /*#__PURE__*/function (_AnnotationElement17) {
  19355. _inherits(FileAttachmentAnnotationElement, _AnnotationElement17);
  19356. var _super23 = _createSuper(FileAttachmentAnnotationElement);
  19357. function FileAttachmentAnnotationElement(parameters) {
  19358. var _this6;
  19359. _classCallCheck(this, FileAttachmentAnnotationElement);
  19360. _this6 = _super23.call(this, parameters, true);
  19361. var _this6$data$file = _this6.data.file,
  19362. filename = _this6$data$file.filename,
  19363. content = _this6$data$file.content;
  19364. _this6.filename = (0, _display_utils.getFilenameFromUrl)(filename);
  19365. _this6.content = content;
  19366. if (_this6.linkService.eventBus) {
  19367. _this6.linkService.eventBus.dispatch("fileattachmentannotation", {
  19368. source: _assertThisInitialized(_this6),
  19369. id: (0, _util.stringToPDFString)(filename),
  19370. filename: filename,
  19371. content: content
  19372. });
  19373. }
  19374. return _this6;
  19375. }
  19376. _createClass(FileAttachmentAnnotationElement, [{
  19377. key: "render",
  19378. value: function render() {
  19379. this.container.className = "fileAttachmentAnnotation";
  19380. var trigger = document.createElement("div");
  19381. trigger.style.height = this.container.style.height;
  19382. trigger.style.width = this.container.style.width;
  19383. trigger.addEventListener("dblclick", this._download.bind(this));
  19384. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  19385. this._createPopup(this.container, trigger, this.data);
  19386. }
  19387. this.container.appendChild(trigger);
  19388. return this.container;
  19389. }
  19390. }, {
  19391. key: "_download",
  19392. value: function _download() {
  19393. if (!this.downloadManager) {
  19394. (0, _util.warn)("Download cannot be started due to unavailable download manager");
  19395. return;
  19396. }
  19397. this.downloadManager.downloadData(this.content, this.filename, "");
  19398. }
  19399. }]);
  19400. return FileAttachmentAnnotationElement;
  19401. }(AnnotationElement);
  19402. var AnnotationLayer = /*#__PURE__*/function () {
  19403. function AnnotationLayer() {
  19404. _classCallCheck(this, AnnotationLayer);
  19405. }
  19406. _createClass(AnnotationLayer, null, [{
  19407. key: "render",
  19408. value: function render(parameters) {
  19409. var sortedAnnotations = [],
  19410. popupAnnotations = [];
  19411. var _iterator6 = _createForOfIteratorHelper(parameters.annotations),
  19412. _step6;
  19413. try {
  19414. for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
  19415. var _data = _step6.value;
  19416. if (!_data) {
  19417. continue;
  19418. }
  19419. if (_data.annotationType === _util.AnnotationType.POPUP) {
  19420. popupAnnotations.push(_data);
  19421. continue;
  19422. }
  19423. sortedAnnotations.push(_data);
  19424. }
  19425. } catch (err) {
  19426. _iterator6.e(err);
  19427. } finally {
  19428. _iterator6.f();
  19429. }
  19430. if (popupAnnotations.length) {
  19431. sortedAnnotations.push.apply(sortedAnnotations, popupAnnotations);
  19432. }
  19433. for (var _i = 0, _sortedAnnotations = sortedAnnotations; _i < _sortedAnnotations.length; _i++) {
  19434. var data = _sortedAnnotations[_i];
  19435. var element = AnnotationElementFactory.create({
  19436. data: data,
  19437. layer: parameters.div,
  19438. page: parameters.page,
  19439. viewport: parameters.viewport,
  19440. linkService: parameters.linkService,
  19441. downloadManager: parameters.downloadManager,
  19442. imageResourcesPath: parameters.imageResourcesPath || "",
  19443. renderInteractiveForms: typeof parameters.renderInteractiveForms === "boolean" ? parameters.renderInteractiveForms : true,
  19444. svgFactory: new _display_utils.DOMSVGFactory(),
  19445. annotationStorage: parameters.annotationStorage || new _annotation_storage.AnnotationStorage()
  19446. });
  19447. if (element.isRenderable) {
  19448. parameters.div.appendChild(element.render());
  19449. }
  19450. }
  19451. }
  19452. }, {
  19453. key: "update",
  19454. value: function update(parameters) {
  19455. var _iterator7 = _createForOfIteratorHelper(parameters.annotations),
  19456. _step7;
  19457. try {
  19458. for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
  19459. var data = _step7.value;
  19460. var element = parameters.div.querySelector("[data-annotation-id=\"".concat(data.id, "\"]"));
  19461. if (element) {
  19462. element.style.transform = "matrix(".concat(parameters.viewport.transform.join(","), ")");
  19463. }
  19464. }
  19465. } catch (err) {
  19466. _iterator7.e(err);
  19467. } finally {
  19468. _iterator7.f();
  19469. }
  19470. parameters.div.removeAttribute("hidden");
  19471. }
  19472. }]);
  19473. return AnnotationLayer;
  19474. }();
  19475. exports.AnnotationLayer = AnnotationLayer;
  19476. /***/ }),
  19477. /* 217 */
  19478. /***/ (function(module, exports, __w_pdfjs_require__) {
  19479. "use strict";
  19480. Object.defineProperty(exports, "__esModule", {
  19481. value: true
  19482. });
  19483. exports.renderTextLayer = void 0;
  19484. var _util = __w_pdfjs_require__(5);
  19485. var renderTextLayer = function renderTextLayerClosure() {
  19486. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  19487. var NonWhitespaceRegexp = /\S/;
  19488. function isAllWhitespace(str) {
  19489. return !NonWhitespaceRegexp.test(str);
  19490. }
  19491. function appendText(task, geom, styles) {
  19492. var textDiv = document.createElement("span");
  19493. var textDivProperties = {
  19494. angle: 0,
  19495. canvasWidth: 0,
  19496. isWhitespace: false,
  19497. originalTransform: null,
  19498. paddingBottom: 0,
  19499. paddingLeft: 0,
  19500. paddingRight: 0,
  19501. paddingTop: 0,
  19502. scale: 1
  19503. };
  19504. task._textDivs.push(textDiv);
  19505. if (isAllWhitespace(geom.str)) {
  19506. textDivProperties.isWhitespace = true;
  19507. task._textDivProperties.set(textDiv, textDivProperties);
  19508. return;
  19509. }
  19510. var tx = _util.Util.transform(task._viewport.transform, geom.transform);
  19511. var angle = Math.atan2(tx[1], tx[0]);
  19512. var style = styles[geom.fontName];
  19513. if (style.vertical) {
  19514. angle += Math.PI / 2;
  19515. }
  19516. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  19517. var fontAscent = fontHeight;
  19518. if (style.ascent) {
  19519. fontAscent = style.ascent * fontAscent;
  19520. } else if (style.descent) {
  19521. fontAscent = (1 + style.descent) * fontAscent;
  19522. }
  19523. var left, top;
  19524. if (angle === 0) {
  19525. left = tx[4];
  19526. top = tx[5] - fontAscent;
  19527. } else {
  19528. left = tx[4] + fontAscent * Math.sin(angle);
  19529. top = tx[5] - fontAscent * Math.cos(angle);
  19530. }
  19531. textDiv.style.left = "".concat(left, "px");
  19532. textDiv.style.top = "".concat(top, "px");
  19533. textDiv.style.fontSize = "".concat(fontHeight, "px");
  19534. textDiv.style.fontFamily = style.fontFamily;
  19535. textDiv.textContent = geom.str;
  19536. if (task._fontInspectorEnabled) {
  19537. textDiv.dataset.fontName = geom.fontName;
  19538. }
  19539. if (angle !== 0) {
  19540. textDivProperties.angle = angle * (180 / Math.PI);
  19541. }
  19542. var shouldScaleText = false;
  19543. if (geom.str.length > 1) {
  19544. shouldScaleText = true;
  19545. } else if (geom.transform[0] !== geom.transform[3]) {
  19546. var absScaleX = Math.abs(geom.transform[0]),
  19547. absScaleY = Math.abs(geom.transform[3]);
  19548. if (absScaleX !== absScaleY && Math.max(absScaleX, absScaleY) / Math.min(absScaleX, absScaleY) > 1.5) {
  19549. shouldScaleText = true;
  19550. }
  19551. }
  19552. if (shouldScaleText) {
  19553. if (style.vertical) {
  19554. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  19555. } else {
  19556. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  19557. }
  19558. }
  19559. task._textDivProperties.set(textDiv, textDivProperties);
  19560. if (task._textContentStream) {
  19561. task._layoutText(textDiv);
  19562. }
  19563. if (task._enhanceTextSelection) {
  19564. var angleCos = 1,
  19565. angleSin = 0;
  19566. if (angle !== 0) {
  19567. angleCos = Math.cos(angle);
  19568. angleSin = Math.sin(angle);
  19569. }
  19570. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  19571. var divHeight = fontHeight;
  19572. var m, b;
  19573. if (angle !== 0) {
  19574. m = [angleCos, angleSin, -angleSin, angleCos, left, top];
  19575. b = _util.Util.getAxialAlignedBoundingBox([0, 0, divWidth, divHeight], m);
  19576. } else {
  19577. b = [left, top, left + divWidth, top + divHeight];
  19578. }
  19579. task._bounds.push({
  19580. left: b[0],
  19581. top: b[1],
  19582. right: b[2],
  19583. bottom: b[3],
  19584. div: textDiv,
  19585. size: [divWidth, divHeight],
  19586. m: m
  19587. });
  19588. }
  19589. }
  19590. function render(task) {
  19591. if (task._canceled) {
  19592. return;
  19593. }
  19594. var textDivs = task._textDivs;
  19595. var capability = task._capability;
  19596. var textDivsLength = textDivs.length;
  19597. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  19598. task._renderingDone = true;
  19599. capability.resolve();
  19600. return;
  19601. }
  19602. if (!task._textContentStream) {
  19603. for (var i = 0; i < textDivsLength; i++) {
  19604. task._layoutText(textDivs[i]);
  19605. }
  19606. }
  19607. task._renderingDone = true;
  19608. capability.resolve();
  19609. }
  19610. function findPositiveMin(ts, offset, count) {
  19611. var result = 0;
  19612. for (var i = 0; i < count; i++) {
  19613. var t = ts[offset++];
  19614. if (t > 0) {
  19615. result = result ? Math.min(t, result) : t;
  19616. }
  19617. }
  19618. return result;
  19619. }
  19620. function expand(task) {
  19621. var bounds = task._bounds;
  19622. var viewport = task._viewport;
  19623. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  19624. for (var i = 0; i < expanded.length; i++) {
  19625. var div = bounds[i].div;
  19626. var divProperties = task._textDivProperties.get(div);
  19627. if (divProperties.angle === 0) {
  19628. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  19629. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  19630. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  19631. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  19632. task._textDivProperties.set(div, divProperties);
  19633. continue;
  19634. }
  19635. var e = expanded[i],
  19636. b = bounds[i];
  19637. var m = b.m,
  19638. c = m[0],
  19639. s = m[1];
  19640. var points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size];
  19641. var ts = new Float64Array(64);
  19642. points.forEach(function (p, j) {
  19643. var t = _util.Util.applyTransform(p, m);
  19644. ts[j + 0] = c && (e.left - t[0]) / c;
  19645. ts[j + 4] = s && (e.top - t[1]) / s;
  19646. ts[j + 8] = c && (e.right - t[0]) / c;
  19647. ts[j + 12] = s && (e.bottom - t[1]) / s;
  19648. ts[j + 16] = s && (e.left - t[0]) / -s;
  19649. ts[j + 20] = c && (e.top - t[1]) / c;
  19650. ts[j + 24] = s && (e.right - t[0]) / -s;
  19651. ts[j + 28] = c && (e.bottom - t[1]) / c;
  19652. ts[j + 32] = c && (e.left - t[0]) / -c;
  19653. ts[j + 36] = s && (e.top - t[1]) / -s;
  19654. ts[j + 40] = c && (e.right - t[0]) / -c;
  19655. ts[j + 44] = s && (e.bottom - t[1]) / -s;
  19656. ts[j + 48] = s && (e.left - t[0]) / s;
  19657. ts[j + 52] = c && (e.top - t[1]) / -c;
  19658. ts[j + 56] = s && (e.right - t[0]) / s;
  19659. ts[j + 60] = c && (e.bottom - t[1]) / -c;
  19660. });
  19661. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  19662. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  19663. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  19664. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  19665. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  19666. task._textDivProperties.set(div, divProperties);
  19667. }
  19668. }
  19669. function expandBounds(width, height, boxes) {
  19670. var bounds = boxes.map(function (box, i) {
  19671. return {
  19672. x1: box.left,
  19673. y1: box.top,
  19674. x2: box.right,
  19675. y2: box.bottom,
  19676. index: i,
  19677. x1New: undefined,
  19678. x2New: undefined
  19679. };
  19680. });
  19681. expandBoundsLTR(width, bounds);
  19682. var expanded = new Array(boxes.length);
  19683. bounds.forEach(function (b) {
  19684. var i = b.index;
  19685. expanded[i] = {
  19686. left: b.x1New,
  19687. top: 0,
  19688. right: b.x2New,
  19689. bottom: 0
  19690. };
  19691. });
  19692. boxes.map(function (box, i) {
  19693. var e = expanded[i],
  19694. b = bounds[i];
  19695. b.x1 = box.top;
  19696. b.y1 = width - e.right;
  19697. b.x2 = box.bottom;
  19698. b.y2 = width - e.left;
  19699. b.index = i;
  19700. b.x1New = undefined;
  19701. b.x2New = undefined;
  19702. });
  19703. expandBoundsLTR(height, bounds);
  19704. bounds.forEach(function (b) {
  19705. var i = b.index;
  19706. expanded[i].top = b.x1New;
  19707. expanded[i].bottom = b.x2New;
  19708. });
  19709. return expanded;
  19710. }
  19711. function expandBoundsLTR(width, bounds) {
  19712. bounds.sort(function (a, b) {
  19713. return a.x1 - b.x1 || a.index - b.index;
  19714. });
  19715. var fakeBoundary = {
  19716. x1: -Infinity,
  19717. y1: -Infinity,
  19718. x2: 0,
  19719. y2: Infinity,
  19720. index: -1,
  19721. x1New: 0,
  19722. x2New: 0
  19723. };
  19724. var horizon = [{
  19725. start: -Infinity,
  19726. end: Infinity,
  19727. boundary: fakeBoundary
  19728. }];
  19729. bounds.forEach(function (boundary) {
  19730. var i = 0;
  19731. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  19732. i++;
  19733. }
  19734. var j = horizon.length - 1;
  19735. while (j >= 0 && horizon[j].start >= boundary.y2) {
  19736. j--;
  19737. }
  19738. var horizonPart, affectedBoundary;
  19739. var q,
  19740. k,
  19741. maxXNew = -Infinity;
  19742. for (q = i; q <= j; q++) {
  19743. horizonPart = horizon[q];
  19744. affectedBoundary = horizonPart.boundary;
  19745. var xNew;
  19746. if (affectedBoundary.x2 > boundary.x1) {
  19747. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  19748. } else if (affectedBoundary.x2New === undefined) {
  19749. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  19750. } else {
  19751. xNew = affectedBoundary.x2New;
  19752. }
  19753. if (xNew > maxXNew) {
  19754. maxXNew = xNew;
  19755. }
  19756. }
  19757. boundary.x1New = maxXNew;
  19758. for (q = i; q <= j; q++) {
  19759. horizonPart = horizon[q];
  19760. affectedBoundary = horizonPart.boundary;
  19761. if (affectedBoundary.x2New === undefined) {
  19762. if (affectedBoundary.x2 > boundary.x1) {
  19763. if (affectedBoundary.index > boundary.index) {
  19764. affectedBoundary.x2New = affectedBoundary.x2;
  19765. }
  19766. } else {
  19767. affectedBoundary.x2New = maxXNew;
  19768. }
  19769. } else if (affectedBoundary.x2New > maxXNew) {
  19770. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  19771. }
  19772. }
  19773. var changedHorizon = [],
  19774. lastBoundary = null;
  19775. for (q = i; q <= j; q++) {
  19776. horizonPart = horizon[q];
  19777. affectedBoundary = horizonPart.boundary;
  19778. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  19779. if (lastBoundary === useBoundary) {
  19780. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  19781. } else {
  19782. changedHorizon.push({
  19783. start: horizonPart.start,
  19784. end: horizonPart.end,
  19785. boundary: useBoundary
  19786. });
  19787. lastBoundary = useBoundary;
  19788. }
  19789. }
  19790. if (horizon[i].start < boundary.y1) {
  19791. changedHorizon[0].start = boundary.y1;
  19792. changedHorizon.unshift({
  19793. start: horizon[i].start,
  19794. end: boundary.y1,
  19795. boundary: horizon[i].boundary
  19796. });
  19797. }
  19798. if (boundary.y2 < horizon[j].end) {
  19799. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  19800. changedHorizon.push({
  19801. start: boundary.y2,
  19802. end: horizon[j].end,
  19803. boundary: horizon[j].boundary
  19804. });
  19805. }
  19806. for (q = i; q <= j; q++) {
  19807. horizonPart = horizon[q];
  19808. affectedBoundary = horizonPart.boundary;
  19809. if (affectedBoundary.x2New !== undefined) {
  19810. continue;
  19811. }
  19812. var used = false;
  19813. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  19814. used = horizon[k].boundary === affectedBoundary;
  19815. }
  19816. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  19817. used = horizon[k].boundary === affectedBoundary;
  19818. }
  19819. for (k = 0; !used && k < changedHorizon.length; k++) {
  19820. used = changedHorizon[k].boundary === affectedBoundary;
  19821. }
  19822. if (!used) {
  19823. affectedBoundary.x2New = maxXNew;
  19824. }
  19825. }
  19826. Array.prototype.splice.apply(horizon, [i, j - i + 1].concat(changedHorizon));
  19827. });
  19828. horizon.forEach(function (horizonPart) {
  19829. var affectedBoundary = horizonPart.boundary;
  19830. if (affectedBoundary.x2New === undefined) {
  19831. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  19832. }
  19833. });
  19834. }
  19835. function TextLayerRenderTask(_ref) {
  19836. var _this = this;
  19837. var textContent = _ref.textContent,
  19838. textContentStream = _ref.textContentStream,
  19839. container = _ref.container,
  19840. viewport = _ref.viewport,
  19841. textDivs = _ref.textDivs,
  19842. textContentItemsStr = _ref.textContentItemsStr,
  19843. enhanceTextSelection = _ref.enhanceTextSelection;
  19844. this._textContent = textContent;
  19845. this._textContentStream = textContentStream;
  19846. this._container = container;
  19847. this._document = container.ownerDocument;
  19848. this._viewport = viewport;
  19849. this._textDivs = textDivs || [];
  19850. this._textContentItemsStr = textContentItemsStr || [];
  19851. this._enhanceTextSelection = !!enhanceTextSelection;
  19852. this._fontInspectorEnabled = !!(globalThis.FontInspector && globalThis.FontInspector.enabled);
  19853. this._reader = null;
  19854. this._layoutTextLastFontSize = null;
  19855. this._layoutTextLastFontFamily = null;
  19856. this._layoutTextCtx = null;
  19857. this._textDivProperties = new WeakMap();
  19858. this._renderingDone = false;
  19859. this._canceled = false;
  19860. this._capability = (0, _util.createPromiseCapability)();
  19861. this._renderTimer = null;
  19862. this._bounds = [];
  19863. this._capability.promise["finally"](function () {
  19864. if (_this._layoutTextCtx) {
  19865. _this._layoutTextCtx.canvas.width = 0;
  19866. _this._layoutTextCtx.canvas.height = 0;
  19867. _this._layoutTextCtx = null;
  19868. }
  19869. })["catch"](function () {});
  19870. }
  19871. TextLayerRenderTask.prototype = {
  19872. get promise() {
  19873. return this._capability.promise;
  19874. },
  19875. cancel: function TextLayer_cancel() {
  19876. this._canceled = true;
  19877. if (this._reader) {
  19878. this._reader.cancel(new _util.AbortException("TextLayer task cancelled."));
  19879. this._reader = null;
  19880. }
  19881. if (this._renderTimer !== null) {
  19882. clearTimeout(this._renderTimer);
  19883. this._renderTimer = null;
  19884. }
  19885. this._capability.reject(new Error("TextLayer task cancelled."));
  19886. },
  19887. _processItems: function _processItems(items, styleCache) {
  19888. for (var i = 0, len = items.length; i < len; i++) {
  19889. this._textContentItemsStr.push(items[i].str);
  19890. appendText(this, items[i], styleCache);
  19891. }
  19892. },
  19893. _layoutText: function _layoutText(textDiv) {
  19894. var textDivProperties = this._textDivProperties.get(textDiv);
  19895. if (textDivProperties.isWhitespace) {
  19896. return;
  19897. }
  19898. var transform = "";
  19899. if (textDivProperties.canvasWidth !== 0) {
  19900. var _textDiv$style = textDiv.style,
  19901. fontSize = _textDiv$style.fontSize,
  19902. fontFamily = _textDiv$style.fontFamily;
  19903. if (fontSize !== this._layoutTextLastFontSize || fontFamily !== this._layoutTextLastFontFamily) {
  19904. this._layoutTextCtx.font = "".concat(fontSize, " ").concat(fontFamily);
  19905. this._layoutTextLastFontSize = fontSize;
  19906. this._layoutTextLastFontFamily = fontFamily;
  19907. }
  19908. var _this$_layoutTextCtx$ = this._layoutTextCtx.measureText(textDiv.textContent),
  19909. width = _this$_layoutTextCtx$.width;
  19910. if (width > 0) {
  19911. textDivProperties.scale = textDivProperties.canvasWidth / width;
  19912. transform = "scaleX(".concat(textDivProperties.scale, ")");
  19913. }
  19914. }
  19915. if (textDivProperties.angle !== 0) {
  19916. transform = "rotate(".concat(textDivProperties.angle, "deg) ").concat(transform);
  19917. }
  19918. if (transform.length > 0) {
  19919. if (this._enhanceTextSelection) {
  19920. textDivProperties.originalTransform = transform;
  19921. }
  19922. textDiv.style.transform = transform;
  19923. }
  19924. this._textDivProperties.set(textDiv, textDivProperties);
  19925. this._container.appendChild(textDiv);
  19926. },
  19927. _render: function TextLayer_render(timeout) {
  19928. var _this2 = this;
  19929. var capability = (0, _util.createPromiseCapability)();
  19930. var styleCache = Object.create(null);
  19931. var canvas = this._document.createElement("canvas");
  19932. canvas.mozOpaque = true;
  19933. this._layoutTextCtx = canvas.getContext("2d", {
  19934. alpha: false
  19935. });
  19936. if (this._textContent) {
  19937. var textItems = this._textContent.items;
  19938. var textStyles = this._textContent.styles;
  19939. this._processItems(textItems, textStyles);
  19940. capability.resolve();
  19941. } else if (this._textContentStream) {
  19942. var pump = function pump() {
  19943. _this2._reader.read().then(function (_ref2) {
  19944. var value = _ref2.value,
  19945. done = _ref2.done;
  19946. if (done) {
  19947. capability.resolve();
  19948. return;
  19949. }
  19950. Object.assign(styleCache, value.styles);
  19951. _this2._processItems(value.items, styleCache);
  19952. pump();
  19953. }, capability.reject);
  19954. };
  19955. this._reader = this._textContentStream.getReader();
  19956. pump();
  19957. } else {
  19958. throw new Error('Neither "textContent" nor "textContentStream"' + " parameters specified.");
  19959. }
  19960. capability.promise.then(function () {
  19961. styleCache = null;
  19962. if (!timeout) {
  19963. render(_this2);
  19964. } else {
  19965. _this2._renderTimer = setTimeout(function () {
  19966. render(_this2);
  19967. _this2._renderTimer = null;
  19968. }, timeout);
  19969. }
  19970. }, this._capability.reject);
  19971. },
  19972. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  19973. if (!this._enhanceTextSelection || !this._renderingDone) {
  19974. return;
  19975. }
  19976. if (this._bounds !== null) {
  19977. expand(this);
  19978. this._bounds = null;
  19979. }
  19980. var transformBuf = [],
  19981. paddingBuf = [];
  19982. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  19983. var div = this._textDivs[i];
  19984. var divProps = this._textDivProperties.get(div);
  19985. if (divProps.isWhitespace) {
  19986. continue;
  19987. }
  19988. if (expandDivs) {
  19989. transformBuf.length = 0;
  19990. paddingBuf.length = 0;
  19991. if (divProps.originalTransform) {
  19992. transformBuf.push(divProps.originalTransform);
  19993. }
  19994. if (divProps.paddingTop > 0) {
  19995. paddingBuf.push("".concat(divProps.paddingTop, "px"));
  19996. transformBuf.push("translateY(".concat(-divProps.paddingTop, "px)"));
  19997. } else {
  19998. paddingBuf.push(0);
  19999. }
  20000. if (divProps.paddingRight > 0) {
  20001. paddingBuf.push("".concat(divProps.paddingRight / divProps.scale, "px"));
  20002. } else {
  20003. paddingBuf.push(0);
  20004. }
  20005. if (divProps.paddingBottom > 0) {
  20006. paddingBuf.push("".concat(divProps.paddingBottom, "px"));
  20007. } else {
  20008. paddingBuf.push(0);
  20009. }
  20010. if (divProps.paddingLeft > 0) {
  20011. paddingBuf.push("".concat(divProps.paddingLeft / divProps.scale, "px"));
  20012. transformBuf.push("translateX(".concat(-divProps.paddingLeft / divProps.scale, "px)"));
  20013. } else {
  20014. paddingBuf.push(0);
  20015. }
  20016. div.style.padding = paddingBuf.join(" ");
  20017. if (transformBuf.length) {
  20018. div.style.transform = transformBuf.join(" ");
  20019. }
  20020. } else {
  20021. div.style.padding = null;
  20022. div.style.transform = divProps.originalTransform;
  20023. }
  20024. }
  20025. }
  20026. };
  20027. function renderTextLayer(renderParameters) {
  20028. var task = new TextLayerRenderTask({
  20029. textContent: renderParameters.textContent,
  20030. textContentStream: renderParameters.textContentStream,
  20031. container: renderParameters.container,
  20032. viewport: renderParameters.viewport,
  20033. textDivs: renderParameters.textDivs,
  20034. textContentItemsStr: renderParameters.textContentItemsStr,
  20035. enhanceTextSelection: renderParameters.enhanceTextSelection
  20036. });
  20037. task._render(renderParameters.timeout);
  20038. return task;
  20039. }
  20040. return renderTextLayer;
  20041. }();
  20042. exports.renderTextLayer = renderTextLayer;
  20043. /***/ }),
  20044. /* 218 */
  20045. /***/ (function(module, exports, __w_pdfjs_require__) {
  20046. "use strict";
  20047. Object.defineProperty(exports, "__esModule", {
  20048. value: true
  20049. });
  20050. exports.SVGGraphics = void 0;
  20051. var _util = __w_pdfjs_require__(5);
  20052. var _display_utils = __w_pdfjs_require__(1);
  20053. var _is_node = __w_pdfjs_require__(7);
  20054. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  20055. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  20056. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
  20057. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  20058. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  20059. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  20060. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  20061. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  20062. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  20063. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  20064. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  20065. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20066. 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); } }
  20067. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  20068. var SVGGraphics = function SVGGraphics() {
  20069. throw new Error("Not implemented: SVGGraphics");
  20070. };
  20071. exports.SVGGraphics = SVGGraphics;
  20072. {
  20073. var opListToTree = function opListToTree(opList) {
  20074. var opTree = [];
  20075. var tmp = [];
  20076. var _iterator = _createForOfIteratorHelper(opList),
  20077. _step;
  20078. try {
  20079. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  20080. var opListElement = _step.value;
  20081. if (opListElement.fn === "save") {
  20082. opTree.push({
  20083. fnId: 92,
  20084. fn: "group",
  20085. items: []
  20086. });
  20087. tmp.push(opTree);
  20088. opTree = opTree[opTree.length - 1].items;
  20089. continue;
  20090. }
  20091. if (opListElement.fn === "restore") {
  20092. opTree = tmp.pop();
  20093. } else {
  20094. opTree.push(opListElement);
  20095. }
  20096. }
  20097. } catch (err) {
  20098. _iterator.e(err);
  20099. } finally {
  20100. _iterator.f();
  20101. }
  20102. return opTree;
  20103. };
  20104. var pf = function pf(value) {
  20105. if (Number.isInteger(value)) {
  20106. return value.toString();
  20107. }
  20108. var s = value.toFixed(10);
  20109. var i = s.length - 1;
  20110. if (s[i] !== "0") {
  20111. return s;
  20112. }
  20113. do {
  20114. i--;
  20115. } while (s[i] === "0");
  20116. return s.substring(0, s[i] === "." ? i : i + 1);
  20117. };
  20118. var pm = function pm(m) {
  20119. if (m[4] === 0 && m[5] === 0) {
  20120. if (m[1] === 0 && m[2] === 0) {
  20121. if (m[0] === 1 && m[3] === 1) {
  20122. return "";
  20123. }
  20124. return "scale(".concat(pf(m[0]), " ").concat(pf(m[3]), ")");
  20125. }
  20126. if (m[0] === m[3] && m[1] === -m[2]) {
  20127. var a = Math.acos(m[0]) * 180 / Math.PI;
  20128. return "rotate(".concat(pf(a), ")");
  20129. }
  20130. } else {
  20131. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  20132. return "translate(".concat(pf(m[4]), " ").concat(pf(m[5]), ")");
  20133. }
  20134. }
  20135. 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]), ")");
  20136. };
  20137. var SVG_DEFAULTS = {
  20138. fontStyle: "normal",
  20139. fontWeight: "normal",
  20140. fillColor: "#000000"
  20141. };
  20142. var XML_NS = "http://www.w3.org/XML/1998/namespace";
  20143. var XLINK_NS = "http://www.w3.org/1999/xlink";
  20144. var LINE_CAP_STYLES = ["butt", "round", "square"];
  20145. var LINE_JOIN_STYLES = ["miter", "round", "bevel"];
  20146. var convertImgDataToPng = function () {
  20147. var PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
  20148. var CHUNK_WRAPPER_SIZE = 12;
  20149. var crcTable = new Int32Array(256);
  20150. for (var i = 0; i < 256; i++) {
  20151. var c = i;
  20152. for (var h = 0; h < 8; h++) {
  20153. if (c & 1) {
  20154. c = 0xedb88320 ^ c >> 1 & 0x7fffffff;
  20155. } else {
  20156. c = c >> 1 & 0x7fffffff;
  20157. }
  20158. }
  20159. crcTable[i] = c;
  20160. }
  20161. function crc32(data, start, end) {
  20162. var crc = -1;
  20163. for (var _i = start; _i < end; _i++) {
  20164. var a = (crc ^ data[_i]) & 0xff;
  20165. var b = crcTable[a];
  20166. crc = crc >>> 8 ^ b;
  20167. }
  20168. return crc ^ -1;
  20169. }
  20170. function writePngChunk(type, body, data, offset) {
  20171. var p = offset;
  20172. var len = body.length;
  20173. data[p] = len >> 24 & 0xff;
  20174. data[p + 1] = len >> 16 & 0xff;
  20175. data[p + 2] = len >> 8 & 0xff;
  20176. data[p + 3] = len & 0xff;
  20177. p += 4;
  20178. data[p] = type.charCodeAt(0) & 0xff;
  20179. data[p + 1] = type.charCodeAt(1) & 0xff;
  20180. data[p + 2] = type.charCodeAt(2) & 0xff;
  20181. data[p + 3] = type.charCodeAt(3) & 0xff;
  20182. p += 4;
  20183. data.set(body, p);
  20184. p += body.length;
  20185. var crc = crc32(data, offset + 4, p);
  20186. data[p] = crc >> 24 & 0xff;
  20187. data[p + 1] = crc >> 16 & 0xff;
  20188. data[p + 2] = crc >> 8 & 0xff;
  20189. data[p + 3] = crc & 0xff;
  20190. }
  20191. function adler32(data, start, end) {
  20192. var a = 1;
  20193. var b = 0;
  20194. for (var _i2 = start; _i2 < end; ++_i2) {
  20195. a = (a + (data[_i2] & 0xff)) % 65521;
  20196. b = (b + a) % 65521;
  20197. }
  20198. return b << 16 | a;
  20199. }
  20200. function deflateSync(literals) {
  20201. if (!_is_node.isNodeJS) {
  20202. return deflateSyncUncompressed(literals);
  20203. }
  20204. try {
  20205. var input;
  20206. if (parseInt(process.versions.node) >= 8) {
  20207. input = literals;
  20208. } else {
  20209. input = Buffer.from(literals);
  20210. }
  20211. var output = require("zlib").deflateSync(input, {
  20212. level: 9
  20213. });
  20214. return output instanceof Uint8Array ? output : new Uint8Array(output);
  20215. } catch (e) {
  20216. (0, _util.warn)("Not compressing PNG because zlib.deflateSync is unavailable: " + e);
  20217. }
  20218. return deflateSyncUncompressed(literals);
  20219. }
  20220. function deflateSyncUncompressed(literals) {
  20221. var len = literals.length;
  20222. var maxBlockLength = 0xffff;
  20223. var deflateBlocks = Math.ceil(len / maxBlockLength);
  20224. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  20225. var pi = 0;
  20226. idat[pi++] = 0x78;
  20227. idat[pi++] = 0x9c;
  20228. var pos = 0;
  20229. while (len > maxBlockLength) {
  20230. idat[pi++] = 0x00;
  20231. idat[pi++] = 0xff;
  20232. idat[pi++] = 0xff;
  20233. idat[pi++] = 0x00;
  20234. idat[pi++] = 0x00;
  20235. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  20236. pi += maxBlockLength;
  20237. pos += maxBlockLength;
  20238. len -= maxBlockLength;
  20239. }
  20240. idat[pi++] = 0x01;
  20241. idat[pi++] = len & 0xff;
  20242. idat[pi++] = len >> 8 & 0xff;
  20243. idat[pi++] = ~len & 0xffff & 0xff;
  20244. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  20245. idat.set(literals.subarray(pos), pi);
  20246. pi += literals.length - pos;
  20247. var adler = adler32(literals, 0, literals.length);
  20248. idat[pi++] = adler >> 24 & 0xff;
  20249. idat[pi++] = adler >> 16 & 0xff;
  20250. idat[pi++] = adler >> 8 & 0xff;
  20251. idat[pi++] = adler & 0xff;
  20252. return idat;
  20253. }
  20254. function encode(imgData, kind, forceDataSchema, isMask) {
  20255. var width = imgData.width;
  20256. var height = imgData.height;
  20257. var bitDepth, colorType, lineSize;
  20258. var bytes = imgData.data;
  20259. switch (kind) {
  20260. case _util.ImageKind.GRAYSCALE_1BPP:
  20261. colorType = 0;
  20262. bitDepth = 1;
  20263. lineSize = width + 7 >> 3;
  20264. break;
  20265. case _util.ImageKind.RGB_24BPP:
  20266. colorType = 2;
  20267. bitDepth = 8;
  20268. lineSize = width * 3;
  20269. break;
  20270. case _util.ImageKind.RGBA_32BPP:
  20271. colorType = 6;
  20272. bitDepth = 8;
  20273. lineSize = width * 4;
  20274. break;
  20275. default:
  20276. throw new Error("invalid format");
  20277. }
  20278. var literals = new Uint8Array((1 + lineSize) * height);
  20279. var offsetLiterals = 0,
  20280. offsetBytes = 0;
  20281. for (var y = 0; y < height; ++y) {
  20282. literals[offsetLiterals++] = 0;
  20283. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  20284. offsetBytes += lineSize;
  20285. offsetLiterals += lineSize;
  20286. }
  20287. if (kind === _util.ImageKind.GRAYSCALE_1BPP && isMask) {
  20288. offsetLiterals = 0;
  20289. for (var _y = 0; _y < height; _y++) {
  20290. offsetLiterals++;
  20291. for (var _i3 = 0; _i3 < lineSize; _i3++) {
  20292. literals[offsetLiterals++] ^= 0xff;
  20293. }
  20294. }
  20295. }
  20296. 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]);
  20297. var idat = deflateSync(literals);
  20298. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  20299. var data = new Uint8Array(pngLength);
  20300. var offset = 0;
  20301. data.set(PNG_HEADER, offset);
  20302. offset += PNG_HEADER.length;
  20303. writePngChunk("IHDR", ihdr, data, offset);
  20304. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  20305. writePngChunk("IDATA", idat, data, offset);
  20306. offset += CHUNK_WRAPPER_SIZE + idat.length;
  20307. writePngChunk("IEND", new Uint8Array(0), data, offset);
  20308. return (0, _util.createObjectURL)(data, "image/png", forceDataSchema);
  20309. }
  20310. return function convertImgDataToPng(imgData, forceDataSchema, isMask) {
  20311. var kind = imgData.kind === undefined ? _util.ImageKind.GRAYSCALE_1BPP : imgData.kind;
  20312. return encode(imgData, kind, forceDataSchema, isMask);
  20313. };
  20314. }();
  20315. var SVGExtraState = /*#__PURE__*/function () {
  20316. function SVGExtraState() {
  20317. _classCallCheck(this, SVGExtraState);
  20318. this.fontSizeScale = 1;
  20319. this.fontWeight = SVG_DEFAULTS.fontWeight;
  20320. this.fontSize = 0;
  20321. this.textMatrix = _util.IDENTITY_MATRIX;
  20322. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  20323. this.leading = 0;
  20324. this.textRenderingMode = _util.TextRenderingMode.FILL;
  20325. this.textMatrixScale = 1;
  20326. this.x = 0;
  20327. this.y = 0;
  20328. this.lineX = 0;
  20329. this.lineY = 0;
  20330. this.charSpacing = 0;
  20331. this.wordSpacing = 0;
  20332. this.textHScale = 1;
  20333. this.textRise = 0;
  20334. this.fillColor = SVG_DEFAULTS.fillColor;
  20335. this.strokeColor = "#000000";
  20336. this.fillAlpha = 1;
  20337. this.strokeAlpha = 1;
  20338. this.lineWidth = 1;
  20339. this.lineJoin = "";
  20340. this.lineCap = "";
  20341. this.miterLimit = 0;
  20342. this.dashArray = [];
  20343. this.dashPhase = 0;
  20344. this.dependencies = [];
  20345. this.activeClipUrl = null;
  20346. this.clipGroup = null;
  20347. this.maskId = "";
  20348. }
  20349. _createClass(SVGExtraState, [{
  20350. key: "clone",
  20351. value: function clone() {
  20352. return Object.create(this);
  20353. }
  20354. }, {
  20355. key: "setCurrentPoint",
  20356. value: function setCurrentPoint(x, y) {
  20357. this.x = x;
  20358. this.y = y;
  20359. }
  20360. }]);
  20361. return SVGExtraState;
  20362. }();
  20363. var clipCount = 0;
  20364. var maskCount = 0;
  20365. var shadingCount = 0;
  20366. exports.SVGGraphics = SVGGraphics = /*#__PURE__*/function () {
  20367. function SVGGraphics(commonObjs, objs) {
  20368. var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  20369. _classCallCheck(this, SVGGraphics);
  20370. this.svgFactory = new _display_utils.DOMSVGFactory();
  20371. this.current = new SVGExtraState();
  20372. this.transformMatrix = _util.IDENTITY_MATRIX;
  20373. this.transformStack = [];
  20374. this.extraStack = [];
  20375. this.commonObjs = commonObjs;
  20376. this.objs = objs;
  20377. this.pendingClip = null;
  20378. this.pendingEOFill = false;
  20379. this.embedFonts = false;
  20380. this.embeddedFonts = Object.create(null);
  20381. this.cssStyle = null;
  20382. this.forceDataSchema = !!forceDataSchema;
  20383. this._operatorIdMapping = [];
  20384. for (var op in _util.OPS) {
  20385. this._operatorIdMapping[_util.OPS[op]] = op;
  20386. }
  20387. }
  20388. _createClass(SVGGraphics, [{
  20389. key: "save",
  20390. value: function save() {
  20391. this.transformStack.push(this.transformMatrix);
  20392. var old = this.current;
  20393. this.extraStack.push(old);
  20394. this.current = old.clone();
  20395. }
  20396. }, {
  20397. key: "restore",
  20398. value: function restore() {
  20399. this.transformMatrix = this.transformStack.pop();
  20400. this.current = this.extraStack.pop();
  20401. this.pendingClip = null;
  20402. this.tgrp = null;
  20403. }
  20404. }, {
  20405. key: "group",
  20406. value: function group(items) {
  20407. this.save();
  20408. this.executeOpTree(items);
  20409. this.restore();
  20410. }
  20411. }, {
  20412. key: "loadDependencies",
  20413. value: function loadDependencies(operatorList) {
  20414. var _this = this;
  20415. var fnArray = operatorList.fnArray;
  20416. var argsArray = operatorList.argsArray;
  20417. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  20418. if (fnArray[i] !== _util.OPS.dependency) {
  20419. continue;
  20420. }
  20421. var _iterator2 = _createForOfIteratorHelper(argsArray[i]),
  20422. _step2;
  20423. try {
  20424. var _loop = function _loop() {
  20425. var obj = _step2.value;
  20426. var objsPool = obj.startsWith("g_") ? _this.commonObjs : _this.objs;
  20427. var promise = new Promise(function (resolve) {
  20428. objsPool.get(obj, resolve);
  20429. });
  20430. _this.current.dependencies.push(promise);
  20431. };
  20432. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  20433. _loop();
  20434. }
  20435. } catch (err) {
  20436. _iterator2.e(err);
  20437. } finally {
  20438. _iterator2.f();
  20439. }
  20440. }
  20441. return Promise.all(this.current.dependencies);
  20442. }
  20443. }, {
  20444. key: "transform",
  20445. value: function transform(a, b, c, d, e, f) {
  20446. var transformMatrix = [a, b, c, d, e, f];
  20447. this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix);
  20448. this.tgrp = null;
  20449. }
  20450. }, {
  20451. key: "getSVG",
  20452. value: function getSVG(operatorList, viewport) {
  20453. var _this2 = this;
  20454. this.viewport = viewport;
  20455. var svgElement = this._initialize(viewport);
  20456. return this.loadDependencies(operatorList).then(function () {
  20457. _this2.transformMatrix = _util.IDENTITY_MATRIX;
  20458. _this2.executeOpTree(_this2.convertOpList(operatorList));
  20459. return svgElement;
  20460. });
  20461. }
  20462. }, {
  20463. key: "convertOpList",
  20464. value: function convertOpList(operatorList) {
  20465. var operatorIdMapping = this._operatorIdMapping;
  20466. var argsArray = operatorList.argsArray;
  20467. var fnArray = operatorList.fnArray;
  20468. var opList = [];
  20469. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  20470. var fnId = fnArray[i];
  20471. opList.push({
  20472. fnId: fnId,
  20473. fn: operatorIdMapping[fnId],
  20474. args: argsArray[i]
  20475. });
  20476. }
  20477. return opListToTree(opList);
  20478. }
  20479. }, {
  20480. key: "executeOpTree",
  20481. value: function executeOpTree(opTree) {
  20482. var _iterator3 = _createForOfIteratorHelper(opTree),
  20483. _step3;
  20484. try {
  20485. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  20486. var opTreeElement = _step3.value;
  20487. var fn = opTreeElement.fn;
  20488. var fnId = opTreeElement.fnId;
  20489. var args = opTreeElement.args;
  20490. switch (fnId | 0) {
  20491. case _util.OPS.beginText:
  20492. this.beginText();
  20493. break;
  20494. case _util.OPS.dependency:
  20495. break;
  20496. case _util.OPS.setLeading:
  20497. this.setLeading(args);
  20498. break;
  20499. case _util.OPS.setLeadingMoveText:
  20500. this.setLeadingMoveText(args[0], args[1]);
  20501. break;
  20502. case _util.OPS.setFont:
  20503. this.setFont(args);
  20504. break;
  20505. case _util.OPS.showText:
  20506. this.showText(args[0]);
  20507. break;
  20508. case _util.OPS.showSpacedText:
  20509. this.showText(args[0]);
  20510. break;
  20511. case _util.OPS.endText:
  20512. this.endText();
  20513. break;
  20514. case _util.OPS.moveText:
  20515. this.moveText(args[0], args[1]);
  20516. break;
  20517. case _util.OPS.setCharSpacing:
  20518. this.setCharSpacing(args[0]);
  20519. break;
  20520. case _util.OPS.setWordSpacing:
  20521. this.setWordSpacing(args[0]);
  20522. break;
  20523. case _util.OPS.setHScale:
  20524. this.setHScale(args[0]);
  20525. break;
  20526. case _util.OPS.setTextMatrix:
  20527. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  20528. break;
  20529. case _util.OPS.setTextRise:
  20530. this.setTextRise(args[0]);
  20531. break;
  20532. case _util.OPS.setTextRenderingMode:
  20533. this.setTextRenderingMode(args[0]);
  20534. break;
  20535. case _util.OPS.setLineWidth:
  20536. this.setLineWidth(args[0]);
  20537. break;
  20538. case _util.OPS.setLineJoin:
  20539. this.setLineJoin(args[0]);
  20540. break;
  20541. case _util.OPS.setLineCap:
  20542. this.setLineCap(args[0]);
  20543. break;
  20544. case _util.OPS.setMiterLimit:
  20545. this.setMiterLimit(args[0]);
  20546. break;
  20547. case _util.OPS.setFillRGBColor:
  20548. this.setFillRGBColor(args[0], args[1], args[2]);
  20549. break;
  20550. case _util.OPS.setStrokeRGBColor:
  20551. this.setStrokeRGBColor(args[0], args[1], args[2]);
  20552. break;
  20553. case _util.OPS.setStrokeColorN:
  20554. this.setStrokeColorN(args);
  20555. break;
  20556. case _util.OPS.setFillColorN:
  20557. this.setFillColorN(args);
  20558. break;
  20559. case _util.OPS.shadingFill:
  20560. this.shadingFill(args[0]);
  20561. break;
  20562. case _util.OPS.setDash:
  20563. this.setDash(args[0], args[1]);
  20564. break;
  20565. case _util.OPS.setRenderingIntent:
  20566. this.setRenderingIntent(args[0]);
  20567. break;
  20568. case _util.OPS.setFlatness:
  20569. this.setFlatness(args[0]);
  20570. break;
  20571. case _util.OPS.setGState:
  20572. this.setGState(args[0]);
  20573. break;
  20574. case _util.OPS.fill:
  20575. this.fill();
  20576. break;
  20577. case _util.OPS.eoFill:
  20578. this.eoFill();
  20579. break;
  20580. case _util.OPS.stroke:
  20581. this.stroke();
  20582. break;
  20583. case _util.OPS.fillStroke:
  20584. this.fillStroke();
  20585. break;
  20586. case _util.OPS.eoFillStroke:
  20587. this.eoFillStroke();
  20588. break;
  20589. case _util.OPS.clip:
  20590. this.clip("nonzero");
  20591. break;
  20592. case _util.OPS.eoClip:
  20593. this.clip("evenodd");
  20594. break;
  20595. case _util.OPS.paintSolidColorImageMask:
  20596. this.paintSolidColorImageMask();
  20597. break;
  20598. case _util.OPS.paintImageXObject:
  20599. this.paintImageXObject(args[0]);
  20600. break;
  20601. case _util.OPS.paintInlineImageXObject:
  20602. this.paintInlineImageXObject(args[0]);
  20603. break;
  20604. case _util.OPS.paintImageMaskXObject:
  20605. this.paintImageMaskXObject(args[0]);
  20606. break;
  20607. case _util.OPS.paintFormXObjectBegin:
  20608. this.paintFormXObjectBegin(args[0], args[1]);
  20609. break;
  20610. case _util.OPS.paintFormXObjectEnd:
  20611. this.paintFormXObjectEnd();
  20612. break;
  20613. case _util.OPS.closePath:
  20614. this.closePath();
  20615. break;
  20616. case _util.OPS.closeStroke:
  20617. this.closeStroke();
  20618. break;
  20619. case _util.OPS.closeFillStroke:
  20620. this.closeFillStroke();
  20621. break;
  20622. case _util.OPS.closeEOFillStroke:
  20623. this.closeEOFillStroke();
  20624. break;
  20625. case _util.OPS.nextLine:
  20626. this.nextLine();
  20627. break;
  20628. case _util.OPS.transform:
  20629. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  20630. break;
  20631. case _util.OPS.constructPath:
  20632. this.constructPath(args[0], args[1]);
  20633. break;
  20634. case _util.OPS.endPath:
  20635. this.endPath();
  20636. break;
  20637. case 92:
  20638. this.group(opTreeElement.items);
  20639. break;
  20640. default:
  20641. (0, _util.warn)("Unimplemented operator ".concat(fn));
  20642. break;
  20643. }
  20644. }
  20645. } catch (err) {
  20646. _iterator3.e(err);
  20647. } finally {
  20648. _iterator3.f();
  20649. }
  20650. }
  20651. }, {
  20652. key: "setWordSpacing",
  20653. value: function setWordSpacing(wordSpacing) {
  20654. this.current.wordSpacing = wordSpacing;
  20655. }
  20656. }, {
  20657. key: "setCharSpacing",
  20658. value: function setCharSpacing(charSpacing) {
  20659. this.current.charSpacing = charSpacing;
  20660. }
  20661. }, {
  20662. key: "nextLine",
  20663. value: function nextLine() {
  20664. this.moveText(0, this.current.leading);
  20665. }
  20666. }, {
  20667. key: "setTextMatrix",
  20668. value: function setTextMatrix(a, b, c, d, e, f) {
  20669. var current = this.current;
  20670. current.textMatrix = current.lineMatrix = [a, b, c, d, e, f];
  20671. current.textMatrixScale = Math.sqrt(a * a + b * b);
  20672. current.x = current.lineX = 0;
  20673. current.y = current.lineY = 0;
  20674. current.xcoords = [];
  20675. current.ycoords = [];
  20676. current.tspan = this.svgFactory.createElement("svg:tspan");
  20677. current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
  20678. current.tspan.setAttributeNS(null, "font-size", "".concat(pf(current.fontSize), "px"));
  20679. current.tspan.setAttributeNS(null, "y", pf(-current.y));
  20680. current.txtElement = this.svgFactory.createElement("svg:text");
  20681. current.txtElement.appendChild(current.tspan);
  20682. }
  20683. }, {
  20684. key: "beginText",
  20685. value: function beginText() {
  20686. var current = this.current;
  20687. current.x = current.lineX = 0;
  20688. current.y = current.lineY = 0;
  20689. current.textMatrix = _util.IDENTITY_MATRIX;
  20690. current.lineMatrix = _util.IDENTITY_MATRIX;
  20691. current.textMatrixScale = 1;
  20692. current.tspan = this.svgFactory.createElement("svg:tspan");
  20693. current.txtElement = this.svgFactory.createElement("svg:text");
  20694. current.txtgrp = this.svgFactory.createElement("svg:g");
  20695. current.xcoords = [];
  20696. current.ycoords = [];
  20697. }
  20698. }, {
  20699. key: "moveText",
  20700. value: function moveText(x, y) {
  20701. var current = this.current;
  20702. current.x = current.lineX += x;
  20703. current.y = current.lineY += y;
  20704. current.xcoords = [];
  20705. current.ycoords = [];
  20706. current.tspan = this.svgFactory.createElement("svg:tspan");
  20707. current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
  20708. current.tspan.setAttributeNS(null, "font-size", "".concat(pf(current.fontSize), "px"));
  20709. current.tspan.setAttributeNS(null, "y", pf(-current.y));
  20710. }
  20711. }, {
  20712. key: "showText",
  20713. value: function showText(glyphs) {
  20714. var current = this.current;
  20715. var font = current.font;
  20716. var fontSize = current.fontSize;
  20717. if (fontSize === 0) {
  20718. return;
  20719. }
  20720. var fontSizeScale = current.fontSizeScale;
  20721. var charSpacing = current.charSpacing;
  20722. var wordSpacing = current.wordSpacing;
  20723. var fontDirection = current.fontDirection;
  20724. var textHScale = current.textHScale * fontDirection;
  20725. var vertical = font.vertical;
  20726. var spacingDir = vertical ? 1 : -1;
  20727. var defaultVMetrics = font.defaultVMetrics;
  20728. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  20729. var x = 0;
  20730. var _iterator4 = _createForOfIteratorHelper(glyphs),
  20731. _step4;
  20732. try {
  20733. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  20734. var glyph = _step4.value;
  20735. if (glyph === null) {
  20736. x += fontDirection * wordSpacing;
  20737. continue;
  20738. } else if ((0, _util.isNum)(glyph)) {
  20739. x += spacingDir * glyph * fontSize / 1000;
  20740. continue;
  20741. }
  20742. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  20743. var character = glyph.fontChar;
  20744. var scaledX = void 0,
  20745. scaledY = void 0;
  20746. var width = glyph.width;
  20747. if (vertical) {
  20748. var vx = void 0;
  20749. var vmetric = glyph.vmetric || defaultVMetrics;
  20750. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  20751. vx = -vx * widthAdvanceScale;
  20752. var vy = vmetric[2] * widthAdvanceScale;
  20753. width = vmetric ? -vmetric[0] : width;
  20754. scaledX = vx / fontSizeScale;
  20755. scaledY = (x + vy) / fontSizeScale;
  20756. } else {
  20757. scaledX = x / fontSizeScale;
  20758. scaledY = 0;
  20759. }
  20760. if (glyph.isInFont || font.missingFile) {
  20761. current.xcoords.push(current.x + scaledX);
  20762. if (vertical) {
  20763. current.ycoords.push(-current.y + scaledY);
  20764. }
  20765. current.tspan.textContent += character;
  20766. } else {}
  20767. var charWidth = void 0;
  20768. if (vertical) {
  20769. charWidth = width * widthAdvanceScale - spacing * fontDirection;
  20770. } else {
  20771. charWidth = width * widthAdvanceScale + spacing * fontDirection;
  20772. }
  20773. x += charWidth;
  20774. }
  20775. } catch (err) {
  20776. _iterator4.e(err);
  20777. } finally {
  20778. _iterator4.f();
  20779. }
  20780. current.tspan.setAttributeNS(null, "x", current.xcoords.map(pf).join(" "));
  20781. if (vertical) {
  20782. current.tspan.setAttributeNS(null, "y", current.ycoords.map(pf).join(" "));
  20783. } else {
  20784. current.tspan.setAttributeNS(null, "y", pf(-current.y));
  20785. }
  20786. if (vertical) {
  20787. current.y -= x;
  20788. } else {
  20789. current.x += x * textHScale;
  20790. }
  20791. current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
  20792. current.tspan.setAttributeNS(null, "font-size", "".concat(pf(current.fontSize), "px"));
  20793. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  20794. current.tspan.setAttributeNS(null, "font-style", current.fontStyle);
  20795. }
  20796. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  20797. current.tspan.setAttributeNS(null, "font-weight", current.fontWeight);
  20798. }
  20799. var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  20800. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  20801. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  20802. current.tspan.setAttributeNS(null, "fill", current.fillColor);
  20803. }
  20804. if (current.fillAlpha < 1) {
  20805. current.tspan.setAttributeNS(null, "fill-opacity", current.fillAlpha);
  20806. }
  20807. } else if (current.textRenderingMode === _util.TextRenderingMode.ADD_TO_PATH) {
  20808. current.tspan.setAttributeNS(null, "fill", "transparent");
  20809. } else {
  20810. current.tspan.setAttributeNS(null, "fill", "none");
  20811. }
  20812. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  20813. var lineWidthScale = 1 / (current.textMatrixScale || 1);
  20814. this._setStrokeAttributes(current.tspan, lineWidthScale);
  20815. }
  20816. var textMatrix = current.textMatrix;
  20817. if (current.textRise !== 0) {
  20818. textMatrix = textMatrix.slice();
  20819. textMatrix[5] += current.textRise;
  20820. }
  20821. current.txtElement.setAttributeNS(null, "transform", "".concat(pm(textMatrix), " scale(").concat(pf(textHScale), ", -1)"));
  20822. current.txtElement.setAttributeNS(XML_NS, "xml:space", "preserve");
  20823. current.txtElement.appendChild(current.tspan);
  20824. current.txtgrp.appendChild(current.txtElement);
  20825. this._ensureTransformGroup().appendChild(current.txtElement);
  20826. }
  20827. }, {
  20828. key: "setLeadingMoveText",
  20829. value: function setLeadingMoveText(x, y) {
  20830. this.setLeading(-y);
  20831. this.moveText(x, y);
  20832. }
  20833. }, {
  20834. key: "addFontStyle",
  20835. value: function addFontStyle(fontObj) {
  20836. if (!fontObj.data) {
  20837. throw new Error("addFontStyle: No font data available, " + 'ensure that the "fontExtraProperties" API parameter is set.');
  20838. }
  20839. if (!this.cssStyle) {
  20840. this.cssStyle = this.svgFactory.createElement("svg:style");
  20841. this.cssStyle.setAttributeNS(null, "type", "text/css");
  20842. this.defs.appendChild(this.cssStyle);
  20843. }
  20844. var url = (0, _util.createObjectURL)(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  20845. this.cssStyle.textContent += "@font-face { font-family: \"".concat(fontObj.loadedName, "\";") + " src: url(".concat(url, "); }\n");
  20846. }
  20847. }, {
  20848. key: "setFont",
  20849. value: function setFont(details) {
  20850. var current = this.current;
  20851. var fontObj = this.commonObjs.get(details[0]);
  20852. var size = details[1];
  20853. current.font = fontObj;
  20854. if (this.embedFonts && !fontObj.missingFile && !this.embeddedFonts[fontObj.loadedName]) {
  20855. this.addFontStyle(fontObj);
  20856. this.embeddedFonts[fontObj.loadedName] = fontObj;
  20857. }
  20858. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
  20859. var bold = "normal";
  20860. if (fontObj.black) {
  20861. bold = "900";
  20862. } else if (fontObj.bold) {
  20863. bold = "bold";
  20864. }
  20865. var italic = fontObj.italic ? "italic" : "normal";
  20866. if (size < 0) {
  20867. size = -size;
  20868. current.fontDirection = -1;
  20869. } else {
  20870. current.fontDirection = 1;
  20871. }
  20872. current.fontSize = size;
  20873. current.fontFamily = fontObj.loadedName;
  20874. current.fontWeight = bold;
  20875. current.fontStyle = italic;
  20876. current.tspan = this.svgFactory.createElement("svg:tspan");
  20877. current.tspan.setAttributeNS(null, "y", pf(-current.y));
  20878. current.xcoords = [];
  20879. current.ycoords = [];
  20880. }
  20881. }, {
  20882. key: "endText",
  20883. value: function endText() {
  20884. var current = this.current;
  20885. if (current.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG && current.txtElement && current.txtElement.hasChildNodes()) {
  20886. current.element = current.txtElement;
  20887. this.clip("nonzero");
  20888. this.endPath();
  20889. }
  20890. }
  20891. }, {
  20892. key: "setLineWidth",
  20893. value: function setLineWidth(width) {
  20894. if (width > 0) {
  20895. this.current.lineWidth = width;
  20896. }
  20897. }
  20898. }, {
  20899. key: "setLineCap",
  20900. value: function setLineCap(style) {
  20901. this.current.lineCap = LINE_CAP_STYLES[style];
  20902. }
  20903. }, {
  20904. key: "setLineJoin",
  20905. value: function setLineJoin(style) {
  20906. this.current.lineJoin = LINE_JOIN_STYLES[style];
  20907. }
  20908. }, {
  20909. key: "setMiterLimit",
  20910. value: function setMiterLimit(limit) {
  20911. this.current.miterLimit = limit;
  20912. }
  20913. }, {
  20914. key: "setStrokeAlpha",
  20915. value: function setStrokeAlpha(strokeAlpha) {
  20916. this.current.strokeAlpha = strokeAlpha;
  20917. }
  20918. }, {
  20919. key: "setStrokeRGBColor",
  20920. value: function setStrokeRGBColor(r, g, b) {
  20921. this.current.strokeColor = _util.Util.makeCssRgb(r, g, b);
  20922. }
  20923. }, {
  20924. key: "setFillAlpha",
  20925. value: function setFillAlpha(fillAlpha) {
  20926. this.current.fillAlpha = fillAlpha;
  20927. }
  20928. }, {
  20929. key: "setFillRGBColor",
  20930. value: function setFillRGBColor(r, g, b) {
  20931. this.current.fillColor = _util.Util.makeCssRgb(r, g, b);
  20932. this.current.tspan = this.svgFactory.createElement("svg:tspan");
  20933. this.current.xcoords = [];
  20934. this.current.ycoords = [];
  20935. }
  20936. }, {
  20937. key: "setStrokeColorN",
  20938. value: function setStrokeColorN(args) {
  20939. this.current.strokeColor = this._makeColorN_Pattern(args);
  20940. }
  20941. }, {
  20942. key: "setFillColorN",
  20943. value: function setFillColorN(args) {
  20944. this.current.fillColor = this._makeColorN_Pattern(args);
  20945. }
  20946. }, {
  20947. key: "shadingFill",
  20948. value: function shadingFill(args) {
  20949. var width = this.viewport.width;
  20950. var height = this.viewport.height;
  20951. var inv = _util.Util.inverseTransform(this.transformMatrix);
  20952. var bl = _util.Util.applyTransform([0, 0], inv);
  20953. var br = _util.Util.applyTransform([0, height], inv);
  20954. var ul = _util.Util.applyTransform([width, 0], inv);
  20955. var ur = _util.Util.applyTransform([width, height], inv);
  20956. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  20957. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  20958. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  20959. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  20960. var rect = this.svgFactory.createElement("svg:rect");
  20961. rect.setAttributeNS(null, "x", x0);
  20962. rect.setAttributeNS(null, "y", y0);
  20963. rect.setAttributeNS(null, "width", x1 - x0);
  20964. rect.setAttributeNS(null, "height", y1 - y0);
  20965. rect.setAttributeNS(null, "fill", this._makeShadingPattern(args));
  20966. if (this.current.fillAlpha < 1) {
  20967. rect.setAttributeNS(null, "fill-opacity", this.current.fillAlpha);
  20968. }
  20969. this._ensureTransformGroup().appendChild(rect);
  20970. }
  20971. }, {
  20972. key: "_makeColorN_Pattern",
  20973. value: function _makeColorN_Pattern(args) {
  20974. if (args[0] === "TilingPattern") {
  20975. return this._makeTilingPattern(args);
  20976. }
  20977. return this._makeShadingPattern(args);
  20978. }
  20979. }, {
  20980. key: "_makeTilingPattern",
  20981. value: function _makeTilingPattern(args) {
  20982. var color = args[1];
  20983. var operatorList = args[2];
  20984. var matrix = args[3] || _util.IDENTITY_MATRIX;
  20985. var _args$ = _slicedToArray(args[4], 4),
  20986. x0 = _args$[0],
  20987. y0 = _args$[1],
  20988. x1 = _args$[2],
  20989. y1 = _args$[3];
  20990. var xstep = args[5];
  20991. var ystep = args[6];
  20992. var paintType = args[7];
  20993. var tilingId = "shading".concat(shadingCount++);
  20994. var _Util$applyTransform = _util.Util.applyTransform([x0, y0], matrix),
  20995. _Util$applyTransform2 = _slicedToArray(_Util$applyTransform, 2),
  20996. tx0 = _Util$applyTransform2[0],
  20997. ty0 = _Util$applyTransform2[1];
  20998. var _Util$applyTransform3 = _util.Util.applyTransform([x1, y1], matrix),
  20999. _Util$applyTransform4 = _slicedToArray(_Util$applyTransform3, 2),
  21000. tx1 = _Util$applyTransform4[0],
  21001. ty1 = _Util$applyTransform4[1];
  21002. var _Util$singularValueDe = _util.Util.singularValueDecompose2dScale(matrix),
  21003. _Util$singularValueDe2 = _slicedToArray(_Util$singularValueDe, 2),
  21004. xscale = _Util$singularValueDe2[0],
  21005. yscale = _Util$singularValueDe2[1];
  21006. var txstep = xstep * xscale;
  21007. var tystep = ystep * yscale;
  21008. var tiling = this.svgFactory.createElement("svg:pattern");
  21009. tiling.setAttributeNS(null, "id", tilingId);
  21010. tiling.setAttributeNS(null, "patternUnits", "userSpaceOnUse");
  21011. tiling.setAttributeNS(null, "width", txstep);
  21012. tiling.setAttributeNS(null, "height", tystep);
  21013. tiling.setAttributeNS(null, "x", "".concat(tx0));
  21014. tiling.setAttributeNS(null, "y", "".concat(ty0));
  21015. var svg = this.svg;
  21016. var transformMatrix = this.transformMatrix;
  21017. var fillColor = this.current.fillColor;
  21018. var strokeColor = this.current.strokeColor;
  21019. var bbox = this.svgFactory.create(tx1 - tx0, ty1 - ty0);
  21020. this.svg = bbox;
  21021. this.transformMatrix = matrix;
  21022. if (paintType === 2) {
  21023. var cssColor = _util.Util.makeCssRgb.apply(_util.Util, _toConsumableArray(color));
  21024. this.current.fillColor = cssColor;
  21025. this.current.strokeColor = cssColor;
  21026. }
  21027. this.executeOpTree(this.convertOpList(operatorList));
  21028. this.svg = svg;
  21029. this.transformMatrix = transformMatrix;
  21030. this.current.fillColor = fillColor;
  21031. this.current.strokeColor = strokeColor;
  21032. tiling.appendChild(bbox.childNodes[0]);
  21033. this.defs.appendChild(tiling);
  21034. return "url(#".concat(tilingId, ")");
  21035. }
  21036. }, {
  21037. key: "_makeShadingPattern",
  21038. value: function _makeShadingPattern(args) {
  21039. switch (args[0]) {
  21040. case "RadialAxial":
  21041. var shadingId = "shading".concat(shadingCount++);
  21042. var colorStops = args[3];
  21043. var gradient;
  21044. switch (args[1]) {
  21045. case "axial":
  21046. var point0 = args[4];
  21047. var point1 = args[5];
  21048. gradient = this.svgFactory.createElement("svg:linearGradient");
  21049. gradient.setAttributeNS(null, "id", shadingId);
  21050. gradient.setAttributeNS(null, "gradientUnits", "userSpaceOnUse");
  21051. gradient.setAttributeNS(null, "x1", point0[0]);
  21052. gradient.setAttributeNS(null, "y1", point0[1]);
  21053. gradient.setAttributeNS(null, "x2", point1[0]);
  21054. gradient.setAttributeNS(null, "y2", point1[1]);
  21055. break;
  21056. case "radial":
  21057. var focalPoint = args[4];
  21058. var circlePoint = args[5];
  21059. var focalRadius = args[6];
  21060. var circleRadius = args[7];
  21061. gradient = this.svgFactory.createElement("svg:radialGradient");
  21062. gradient.setAttributeNS(null, "id", shadingId);
  21063. gradient.setAttributeNS(null, "gradientUnits", "userSpaceOnUse");
  21064. gradient.setAttributeNS(null, "cx", circlePoint[0]);
  21065. gradient.setAttributeNS(null, "cy", circlePoint[1]);
  21066. gradient.setAttributeNS(null, "r", circleRadius);
  21067. gradient.setAttributeNS(null, "fx", focalPoint[0]);
  21068. gradient.setAttributeNS(null, "fy", focalPoint[1]);
  21069. gradient.setAttributeNS(null, "fr", focalRadius);
  21070. break;
  21071. default:
  21072. throw new Error("Unknown RadialAxial type: ".concat(args[1]));
  21073. }
  21074. var _iterator5 = _createForOfIteratorHelper(colorStops),
  21075. _step5;
  21076. try {
  21077. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  21078. var colorStop = _step5.value;
  21079. var stop = this.svgFactory.createElement("svg:stop");
  21080. stop.setAttributeNS(null, "offset", colorStop[0]);
  21081. stop.setAttributeNS(null, "stop-color", colorStop[1]);
  21082. gradient.appendChild(stop);
  21083. }
  21084. } catch (err) {
  21085. _iterator5.e(err);
  21086. } finally {
  21087. _iterator5.f();
  21088. }
  21089. this.defs.appendChild(gradient);
  21090. return "url(#".concat(shadingId, ")");
  21091. case "Mesh":
  21092. (0, _util.warn)("Unimplemented pattern Mesh");
  21093. return null;
  21094. case "Dummy":
  21095. return "hotpink";
  21096. default:
  21097. throw new Error("Unknown IR type: ".concat(args[0]));
  21098. }
  21099. }
  21100. }, {
  21101. key: "setDash",
  21102. value: function setDash(dashArray, dashPhase) {
  21103. this.current.dashArray = dashArray;
  21104. this.current.dashPhase = dashPhase;
  21105. }
  21106. }, {
  21107. key: "constructPath",
  21108. value: function constructPath(ops, args) {
  21109. var current = this.current;
  21110. var x = current.x,
  21111. y = current.y;
  21112. var d = [];
  21113. var j = 0;
  21114. var _iterator6 = _createForOfIteratorHelper(ops),
  21115. _step6;
  21116. try {
  21117. for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
  21118. var op = _step6.value;
  21119. switch (op | 0) {
  21120. case _util.OPS.rectangle:
  21121. x = args[j++];
  21122. y = args[j++];
  21123. var width = args[j++];
  21124. var height = args[j++];
  21125. var xw = x + width;
  21126. var yh = y + height;
  21127. d.push("M", pf(x), pf(y), "L", pf(xw), pf(y), "L", pf(xw), pf(yh), "L", pf(x), pf(yh), "Z");
  21128. break;
  21129. case _util.OPS.moveTo:
  21130. x = args[j++];
  21131. y = args[j++];
  21132. d.push("M", pf(x), pf(y));
  21133. break;
  21134. case _util.OPS.lineTo:
  21135. x = args[j++];
  21136. y = args[j++];
  21137. d.push("L", pf(x), pf(y));
  21138. break;
  21139. case _util.OPS.curveTo:
  21140. x = args[j + 4];
  21141. y = args[j + 5];
  21142. d.push("C", pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  21143. j += 6;
  21144. break;
  21145. case _util.OPS.curveTo2:
  21146. d.push("C", pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  21147. x = args[j + 2];
  21148. y = args[j + 3];
  21149. j += 4;
  21150. break;
  21151. case _util.OPS.curveTo3:
  21152. x = args[j + 2];
  21153. y = args[j + 3];
  21154. d.push("C", pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  21155. j += 4;
  21156. break;
  21157. case _util.OPS.closePath:
  21158. d.push("Z");
  21159. break;
  21160. }
  21161. }
  21162. } catch (err) {
  21163. _iterator6.e(err);
  21164. } finally {
  21165. _iterator6.f();
  21166. }
  21167. d = d.join(" ");
  21168. if (current.path && ops.length > 0 && ops[0] !== _util.OPS.rectangle && ops[0] !== _util.OPS.moveTo) {
  21169. d = current.path.getAttributeNS(null, "d") + d;
  21170. } else {
  21171. current.path = this.svgFactory.createElement("svg:path");
  21172. this._ensureTransformGroup().appendChild(current.path);
  21173. }
  21174. current.path.setAttributeNS(null, "d", d);
  21175. current.path.setAttributeNS(null, "fill", "none");
  21176. current.element = current.path;
  21177. current.setCurrentPoint(x, y);
  21178. }
  21179. }, {
  21180. key: "endPath",
  21181. value: function endPath() {
  21182. var current = this.current;
  21183. current.path = null;
  21184. if (!this.pendingClip) {
  21185. return;
  21186. }
  21187. if (!current.element) {
  21188. this.pendingClip = null;
  21189. return;
  21190. }
  21191. var clipId = "clippath".concat(clipCount++);
  21192. var clipPath = this.svgFactory.createElement("svg:clipPath");
  21193. clipPath.setAttributeNS(null, "id", clipId);
  21194. clipPath.setAttributeNS(null, "transform", pm(this.transformMatrix));
  21195. var clipElement = current.element.cloneNode(true);
  21196. if (this.pendingClip === "evenodd") {
  21197. clipElement.setAttributeNS(null, "clip-rule", "evenodd");
  21198. } else {
  21199. clipElement.setAttributeNS(null, "clip-rule", "nonzero");
  21200. }
  21201. this.pendingClip = null;
  21202. clipPath.appendChild(clipElement);
  21203. this.defs.appendChild(clipPath);
  21204. if (current.activeClipUrl) {
  21205. current.clipGroup = null;
  21206. this.extraStack.forEach(function (prev) {
  21207. prev.clipGroup = null;
  21208. });
  21209. clipPath.setAttributeNS(null, "clip-path", current.activeClipUrl);
  21210. }
  21211. current.activeClipUrl = "url(#".concat(clipId, ")");
  21212. this.tgrp = null;
  21213. }
  21214. }, {
  21215. key: "clip",
  21216. value: function clip(type) {
  21217. this.pendingClip = type;
  21218. }
  21219. }, {
  21220. key: "closePath",
  21221. value: function closePath() {
  21222. var current = this.current;
  21223. if (current.path) {
  21224. var d = "".concat(current.path.getAttributeNS(null, "d"), "Z");
  21225. current.path.setAttributeNS(null, "d", d);
  21226. }
  21227. }
  21228. }, {
  21229. key: "setLeading",
  21230. value: function setLeading(leading) {
  21231. this.current.leading = -leading;
  21232. }
  21233. }, {
  21234. key: "setTextRise",
  21235. value: function setTextRise(textRise) {
  21236. this.current.textRise = textRise;
  21237. }
  21238. }, {
  21239. key: "setTextRenderingMode",
  21240. value: function setTextRenderingMode(textRenderingMode) {
  21241. this.current.textRenderingMode = textRenderingMode;
  21242. }
  21243. }, {
  21244. key: "setHScale",
  21245. value: function setHScale(scale) {
  21246. this.current.textHScale = scale / 100;
  21247. }
  21248. }, {
  21249. key: "setRenderingIntent",
  21250. value: function setRenderingIntent(intent) {}
  21251. }, {
  21252. key: "setFlatness",
  21253. value: function setFlatness(flatness) {}
  21254. }, {
  21255. key: "setGState",
  21256. value: function setGState(states) {
  21257. var _iterator7 = _createForOfIteratorHelper(states),
  21258. _step7;
  21259. try {
  21260. for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
  21261. var _step7$value = _slicedToArray(_step7.value, 2),
  21262. key = _step7$value[0],
  21263. value = _step7$value[1];
  21264. switch (key) {
  21265. case "LW":
  21266. this.setLineWidth(value);
  21267. break;
  21268. case "LC":
  21269. this.setLineCap(value);
  21270. break;
  21271. case "LJ":
  21272. this.setLineJoin(value);
  21273. break;
  21274. case "ML":
  21275. this.setMiterLimit(value);
  21276. break;
  21277. case "D":
  21278. this.setDash(value[0], value[1]);
  21279. break;
  21280. case "RI":
  21281. this.setRenderingIntent(value);
  21282. break;
  21283. case "FL":
  21284. this.setFlatness(value);
  21285. break;
  21286. case "Font":
  21287. this.setFont(value);
  21288. break;
  21289. case "CA":
  21290. this.setStrokeAlpha(value);
  21291. break;
  21292. case "ca":
  21293. this.setFillAlpha(value);
  21294. break;
  21295. default:
  21296. (0, _util.warn)("Unimplemented graphic state operator ".concat(key));
  21297. break;
  21298. }
  21299. }
  21300. } catch (err) {
  21301. _iterator7.e(err);
  21302. } finally {
  21303. _iterator7.f();
  21304. }
  21305. }
  21306. }, {
  21307. key: "fill",
  21308. value: function fill() {
  21309. var current = this.current;
  21310. if (current.element) {
  21311. current.element.setAttributeNS(null, "fill", current.fillColor);
  21312. current.element.setAttributeNS(null, "fill-opacity", current.fillAlpha);
  21313. this.endPath();
  21314. }
  21315. }
  21316. }, {
  21317. key: "stroke",
  21318. value: function stroke() {
  21319. var current = this.current;
  21320. if (current.element) {
  21321. this._setStrokeAttributes(current.element);
  21322. current.element.setAttributeNS(null, "fill", "none");
  21323. this.endPath();
  21324. }
  21325. }
  21326. }, {
  21327. key: "_setStrokeAttributes",
  21328. value: function _setStrokeAttributes(element) {
  21329. var lineWidthScale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  21330. var current = this.current;
  21331. var dashArray = current.dashArray;
  21332. if (lineWidthScale !== 1 && dashArray.length > 0) {
  21333. dashArray = dashArray.map(function (value) {
  21334. return lineWidthScale * value;
  21335. });
  21336. }
  21337. element.setAttributeNS(null, "stroke", current.strokeColor);
  21338. element.setAttributeNS(null, "stroke-opacity", current.strokeAlpha);
  21339. element.setAttributeNS(null, "stroke-miterlimit", pf(current.miterLimit));
  21340. element.setAttributeNS(null, "stroke-linecap", current.lineCap);
  21341. element.setAttributeNS(null, "stroke-linejoin", current.lineJoin);
  21342. element.setAttributeNS(null, "stroke-width", pf(lineWidthScale * current.lineWidth) + "px");
  21343. element.setAttributeNS(null, "stroke-dasharray", dashArray.map(pf).join(" "));
  21344. element.setAttributeNS(null, "stroke-dashoffset", pf(lineWidthScale * current.dashPhase) + "px");
  21345. }
  21346. }, {
  21347. key: "eoFill",
  21348. value: function eoFill() {
  21349. if (this.current.element) {
  21350. this.current.element.setAttributeNS(null, "fill-rule", "evenodd");
  21351. }
  21352. this.fill();
  21353. }
  21354. }, {
  21355. key: "fillStroke",
  21356. value: function fillStroke() {
  21357. this.stroke();
  21358. this.fill();
  21359. }
  21360. }, {
  21361. key: "eoFillStroke",
  21362. value: function eoFillStroke() {
  21363. if (this.current.element) {
  21364. this.current.element.setAttributeNS(null, "fill-rule", "evenodd");
  21365. }
  21366. this.fillStroke();
  21367. }
  21368. }, {
  21369. key: "closeStroke",
  21370. value: function closeStroke() {
  21371. this.closePath();
  21372. this.stroke();
  21373. }
  21374. }, {
  21375. key: "closeFillStroke",
  21376. value: function closeFillStroke() {
  21377. this.closePath();
  21378. this.fillStroke();
  21379. }
  21380. }, {
  21381. key: "closeEOFillStroke",
  21382. value: function closeEOFillStroke() {
  21383. this.closePath();
  21384. this.eoFillStroke();
  21385. }
  21386. }, {
  21387. key: "paintSolidColorImageMask",
  21388. value: function paintSolidColorImageMask() {
  21389. var rect = this.svgFactory.createElement("svg:rect");
  21390. rect.setAttributeNS(null, "x", "0");
  21391. rect.setAttributeNS(null, "y", "0");
  21392. rect.setAttributeNS(null, "width", "1px");
  21393. rect.setAttributeNS(null, "height", "1px");
  21394. rect.setAttributeNS(null, "fill", this.current.fillColor);
  21395. this._ensureTransformGroup().appendChild(rect);
  21396. }
  21397. }, {
  21398. key: "paintImageXObject",
  21399. value: function paintImageXObject(objId) {
  21400. var imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
  21401. if (!imgData) {
  21402. (0, _util.warn)("Dependent image with object ID ".concat(objId, " is not ready yet"));
  21403. return;
  21404. }
  21405. this.paintInlineImageXObject(imgData);
  21406. }
  21407. }, {
  21408. key: "paintInlineImageXObject",
  21409. value: function paintInlineImageXObject(imgData, mask) {
  21410. var width = imgData.width;
  21411. var height = imgData.height;
  21412. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema, !!mask);
  21413. var cliprect = this.svgFactory.createElement("svg:rect");
  21414. cliprect.setAttributeNS(null, "x", "0");
  21415. cliprect.setAttributeNS(null, "y", "0");
  21416. cliprect.setAttributeNS(null, "width", pf(width));
  21417. cliprect.setAttributeNS(null, "height", pf(height));
  21418. this.current.element = cliprect;
  21419. this.clip("nonzero");
  21420. var imgEl = this.svgFactory.createElement("svg:image");
  21421. imgEl.setAttributeNS(XLINK_NS, "xlink:href", imgSrc);
  21422. imgEl.setAttributeNS(null, "x", "0");
  21423. imgEl.setAttributeNS(null, "y", pf(-height));
  21424. imgEl.setAttributeNS(null, "width", pf(width) + "px");
  21425. imgEl.setAttributeNS(null, "height", pf(height) + "px");
  21426. imgEl.setAttributeNS(null, "transform", "scale(".concat(pf(1 / width), " ").concat(pf(-1 / height), ")"));
  21427. if (mask) {
  21428. mask.appendChild(imgEl);
  21429. } else {
  21430. this._ensureTransformGroup().appendChild(imgEl);
  21431. }
  21432. }
  21433. }, {
  21434. key: "paintImageMaskXObject",
  21435. value: function paintImageMaskXObject(imgData) {
  21436. var current = this.current;
  21437. var width = imgData.width;
  21438. var height = imgData.height;
  21439. var fillColor = current.fillColor;
  21440. current.maskId = "mask".concat(maskCount++);
  21441. var mask = this.svgFactory.createElement("svg:mask");
  21442. mask.setAttributeNS(null, "id", current.maskId);
  21443. var rect = this.svgFactory.createElement("svg:rect");
  21444. rect.setAttributeNS(null, "x", "0");
  21445. rect.setAttributeNS(null, "y", "0");
  21446. rect.setAttributeNS(null, "width", pf(width));
  21447. rect.setAttributeNS(null, "height", pf(height));
  21448. rect.setAttributeNS(null, "fill", fillColor);
  21449. rect.setAttributeNS(null, "mask", "url(#".concat(current.maskId, ")"));
  21450. this.defs.appendChild(mask);
  21451. this._ensureTransformGroup().appendChild(rect);
  21452. this.paintInlineImageXObject(imgData, mask);
  21453. }
  21454. }, {
  21455. key: "paintFormXObjectBegin",
  21456. value: function paintFormXObjectBegin(matrix, bbox) {
  21457. if (Array.isArray(matrix) && matrix.length === 6) {
  21458. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  21459. }
  21460. if (bbox) {
  21461. var width = bbox[2] - bbox[0];
  21462. var height = bbox[3] - bbox[1];
  21463. var cliprect = this.svgFactory.createElement("svg:rect");
  21464. cliprect.setAttributeNS(null, "x", bbox[0]);
  21465. cliprect.setAttributeNS(null, "y", bbox[1]);
  21466. cliprect.setAttributeNS(null, "width", pf(width));
  21467. cliprect.setAttributeNS(null, "height", pf(height));
  21468. this.current.element = cliprect;
  21469. this.clip("nonzero");
  21470. this.endPath();
  21471. }
  21472. }
  21473. }, {
  21474. key: "paintFormXObjectEnd",
  21475. value: function paintFormXObjectEnd() {}
  21476. }, {
  21477. key: "_initialize",
  21478. value: function _initialize(viewport) {
  21479. var svg = this.svgFactory.create(viewport.width, viewport.height);
  21480. var definitions = this.svgFactory.createElement("svg:defs");
  21481. svg.appendChild(definitions);
  21482. this.defs = definitions;
  21483. var rootGroup = this.svgFactory.createElement("svg:g");
  21484. rootGroup.setAttributeNS(null, "transform", pm(viewport.transform));
  21485. svg.appendChild(rootGroup);
  21486. this.svg = rootGroup;
  21487. return svg;
  21488. }
  21489. }, {
  21490. key: "_ensureClipGroup",
  21491. value: function _ensureClipGroup() {
  21492. if (!this.current.clipGroup) {
  21493. var clipGroup = this.svgFactory.createElement("svg:g");
  21494. clipGroup.setAttributeNS(null, "clip-path", this.current.activeClipUrl);
  21495. this.svg.appendChild(clipGroup);
  21496. this.current.clipGroup = clipGroup;
  21497. }
  21498. return this.current.clipGroup;
  21499. }
  21500. }, {
  21501. key: "_ensureTransformGroup",
  21502. value: function _ensureTransformGroup() {
  21503. if (!this.tgrp) {
  21504. this.tgrp = this.svgFactory.createElement("svg:g");
  21505. this.tgrp.setAttributeNS(null, "transform", pm(this.transformMatrix));
  21506. if (this.current.activeClipUrl) {
  21507. this._ensureClipGroup().appendChild(this.tgrp);
  21508. } else {
  21509. this.svg.appendChild(this.tgrp);
  21510. }
  21511. }
  21512. return this.tgrp;
  21513. }
  21514. }]);
  21515. return SVGGraphics;
  21516. }();
  21517. }
  21518. /***/ }),
  21519. /* 219 */
  21520. /***/ (function(module, exports, __w_pdfjs_require__) {
  21521. "use strict";
  21522. Object.defineProperty(exports, "__esModule", {
  21523. value: true
  21524. });
  21525. exports.PDFNodeStream = void 0;
  21526. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(2));
  21527. var _util = __w_pdfjs_require__(5);
  21528. var _network_utils = __w_pdfjs_require__(220);
  21529. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  21530. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  21531. 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); }
  21532. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  21533. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  21534. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  21535. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  21536. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  21537. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  21538. 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); } }
  21539. 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); }); }; }
  21540. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21541. 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); } }
  21542. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  21543. ;
  21544. var fs = require("fs");
  21545. var http = require("http");
  21546. var https = require("https");
  21547. var url = require("url");
  21548. var fileUriRegex = /^file:\/\/\/[a-zA-Z]:\//;
  21549. function parseUrl(sourceUrl) {
  21550. var parsedUrl = url.parse(sourceUrl);
  21551. if (parsedUrl.protocol === "file:" || parsedUrl.host) {
  21552. return parsedUrl;
  21553. }
  21554. if (/^[a-z]:[/\\]/i.test(sourceUrl)) {
  21555. return url.parse("file:///".concat(sourceUrl));
  21556. }
  21557. if (!parsedUrl.host) {
  21558. parsedUrl.protocol = "file:";
  21559. }
  21560. return parsedUrl;
  21561. }
  21562. var PDFNodeStream = /*#__PURE__*/function () {
  21563. function PDFNodeStream(source) {
  21564. _classCallCheck(this, PDFNodeStream);
  21565. this.source = source;
  21566. this.url = parseUrl(source.url);
  21567. this.isHttp = this.url.protocol === "http:" || this.url.protocol === "https:";
  21568. this.isFsUrl = this.url.protocol === "file:";
  21569. this.httpHeaders = this.isHttp && source.httpHeaders || {};
  21570. this._fullRequestReader = null;
  21571. this._rangeRequestReaders = [];
  21572. }
  21573. _createClass(PDFNodeStream, [{
  21574. key: "getFullReader",
  21575. value: function getFullReader() {
  21576. (0, _util.assert)(!this._fullRequestReader, "PDFNodeStream.getFullReader can only be called once.");
  21577. this._fullRequestReader = this.isFsUrl ? new PDFNodeStreamFsFullReader(this) : new PDFNodeStreamFullReader(this);
  21578. return this._fullRequestReader;
  21579. }
  21580. }, {
  21581. key: "getRangeReader",
  21582. value: function getRangeReader(start, end) {
  21583. if (end <= this._progressiveDataLength) {
  21584. return null;
  21585. }
  21586. var rangeReader = this.isFsUrl ? new PDFNodeStreamFsRangeReader(this, start, end) : new PDFNodeStreamRangeReader(this, start, end);
  21587. this._rangeRequestReaders.push(rangeReader);
  21588. return rangeReader;
  21589. }
  21590. }, {
  21591. key: "cancelAllRequests",
  21592. value: function cancelAllRequests(reason) {
  21593. if (this._fullRequestReader) {
  21594. this._fullRequestReader.cancel(reason);
  21595. }
  21596. var readers = this._rangeRequestReaders.slice(0);
  21597. readers.forEach(function (reader) {
  21598. reader.cancel(reason);
  21599. });
  21600. }
  21601. }, {
  21602. key: "_progressiveDataLength",
  21603. get: function get() {
  21604. return this._fullRequestReader ? this._fullRequestReader._loaded : 0;
  21605. }
  21606. }]);
  21607. return PDFNodeStream;
  21608. }();
  21609. exports.PDFNodeStream = PDFNodeStream;
  21610. var BaseFullReader = /*#__PURE__*/function () {
  21611. function BaseFullReader(stream) {
  21612. _classCallCheck(this, BaseFullReader);
  21613. this._url = stream.url;
  21614. this._done = false;
  21615. this._storedError = null;
  21616. this.onProgress = null;
  21617. var source = stream.source;
  21618. this._contentLength = source.length;
  21619. this._loaded = 0;
  21620. this._filename = null;
  21621. this._disableRange = source.disableRange || false;
  21622. this._rangeChunkSize = source.rangeChunkSize;
  21623. if (!this._rangeChunkSize && !this._disableRange) {
  21624. this._disableRange = true;
  21625. }
  21626. this._isStreamingSupported = !source.disableStream;
  21627. this._isRangeSupported = !source.disableRange;
  21628. this._readableStream = null;
  21629. this._readCapability = (0, _util.createPromiseCapability)();
  21630. this._headersCapability = (0, _util.createPromiseCapability)();
  21631. }
  21632. _createClass(BaseFullReader, [{
  21633. key: "read",
  21634. value: function () {
  21635. var _read = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  21636. var chunk, buffer;
  21637. return _regenerator["default"].wrap(function _callee$(_context) {
  21638. while (1) {
  21639. switch (_context.prev = _context.next) {
  21640. case 0:
  21641. _context.next = 2;
  21642. return this._readCapability.promise;
  21643. case 2:
  21644. if (!this._done) {
  21645. _context.next = 4;
  21646. break;
  21647. }
  21648. return _context.abrupt("return", {
  21649. value: undefined,
  21650. done: true
  21651. });
  21652. case 4:
  21653. if (!this._storedError) {
  21654. _context.next = 6;
  21655. break;
  21656. }
  21657. throw this._storedError;
  21658. case 6:
  21659. chunk = this._readableStream.read();
  21660. if (!(chunk === null)) {
  21661. _context.next = 10;
  21662. break;
  21663. }
  21664. this._readCapability = (0, _util.createPromiseCapability)();
  21665. return _context.abrupt("return", this.read());
  21666. case 10:
  21667. this._loaded += chunk.length;
  21668. if (this.onProgress) {
  21669. this.onProgress({
  21670. loaded: this._loaded,
  21671. total: this._contentLength
  21672. });
  21673. }
  21674. buffer = new Uint8Array(chunk).buffer;
  21675. return _context.abrupt("return", {
  21676. value: buffer,
  21677. done: false
  21678. });
  21679. case 14:
  21680. case "end":
  21681. return _context.stop();
  21682. }
  21683. }
  21684. }, _callee, this);
  21685. }));
  21686. function read() {
  21687. return _read.apply(this, arguments);
  21688. }
  21689. return read;
  21690. }()
  21691. }, {
  21692. key: "cancel",
  21693. value: function cancel(reason) {
  21694. if (!this._readableStream) {
  21695. this._error(reason);
  21696. return;
  21697. }
  21698. this._readableStream.destroy(reason);
  21699. }
  21700. }, {
  21701. key: "_error",
  21702. value: function _error(reason) {
  21703. this._storedError = reason;
  21704. this._readCapability.resolve();
  21705. }
  21706. }, {
  21707. key: "_setReadableStream",
  21708. value: function _setReadableStream(readableStream) {
  21709. var _this = this;
  21710. this._readableStream = readableStream;
  21711. readableStream.on("readable", function () {
  21712. _this._readCapability.resolve();
  21713. });
  21714. readableStream.on("end", function () {
  21715. readableStream.destroy();
  21716. _this._done = true;
  21717. _this._readCapability.resolve();
  21718. });
  21719. readableStream.on("error", function (reason) {
  21720. _this._error(reason);
  21721. });
  21722. if (!this._isStreamingSupported && this._isRangeSupported) {
  21723. this._error(new _util.AbortException("streaming is disabled"));
  21724. }
  21725. if (this._storedError) {
  21726. this._readableStream.destroy(this._storedError);
  21727. }
  21728. }
  21729. }, {
  21730. key: "headersReady",
  21731. get: function get() {
  21732. return this._headersCapability.promise;
  21733. }
  21734. }, {
  21735. key: "filename",
  21736. get: function get() {
  21737. return this._filename;
  21738. }
  21739. }, {
  21740. key: "contentLength",
  21741. get: function get() {
  21742. return this._contentLength;
  21743. }
  21744. }, {
  21745. key: "isRangeSupported",
  21746. get: function get() {
  21747. return this._isRangeSupported;
  21748. }
  21749. }, {
  21750. key: "isStreamingSupported",
  21751. get: function get() {
  21752. return this._isStreamingSupported;
  21753. }
  21754. }]);
  21755. return BaseFullReader;
  21756. }();
  21757. var BaseRangeReader = /*#__PURE__*/function () {
  21758. function BaseRangeReader(stream) {
  21759. _classCallCheck(this, BaseRangeReader);
  21760. this._url = stream.url;
  21761. this._done = false;
  21762. this._storedError = null;
  21763. this.onProgress = null;
  21764. this._loaded = 0;
  21765. this._readableStream = null;
  21766. this._readCapability = (0, _util.createPromiseCapability)();
  21767. var source = stream.source;
  21768. this._isStreamingSupported = !source.disableStream;
  21769. }
  21770. _createClass(BaseRangeReader, [{
  21771. key: "read",
  21772. value: function () {
  21773. var _read2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  21774. var chunk, buffer;
  21775. return _regenerator["default"].wrap(function _callee2$(_context2) {
  21776. while (1) {
  21777. switch (_context2.prev = _context2.next) {
  21778. case 0:
  21779. _context2.next = 2;
  21780. return this._readCapability.promise;
  21781. case 2:
  21782. if (!this._done) {
  21783. _context2.next = 4;
  21784. break;
  21785. }
  21786. return _context2.abrupt("return", {
  21787. value: undefined,
  21788. done: true
  21789. });
  21790. case 4:
  21791. if (!this._storedError) {
  21792. _context2.next = 6;
  21793. break;
  21794. }
  21795. throw this._storedError;
  21796. case 6:
  21797. chunk = this._readableStream.read();
  21798. if (!(chunk === null)) {
  21799. _context2.next = 10;
  21800. break;
  21801. }
  21802. this._readCapability = (0, _util.createPromiseCapability)();
  21803. return _context2.abrupt("return", this.read());
  21804. case 10:
  21805. this._loaded += chunk.length;
  21806. if (this.onProgress) {
  21807. this.onProgress({
  21808. loaded: this._loaded
  21809. });
  21810. }
  21811. buffer = new Uint8Array(chunk).buffer;
  21812. return _context2.abrupt("return", {
  21813. value: buffer,
  21814. done: false
  21815. });
  21816. case 14:
  21817. case "end":
  21818. return _context2.stop();
  21819. }
  21820. }
  21821. }, _callee2, this);
  21822. }));
  21823. function read() {
  21824. return _read2.apply(this, arguments);
  21825. }
  21826. return read;
  21827. }()
  21828. }, {
  21829. key: "cancel",
  21830. value: function cancel(reason) {
  21831. if (!this._readableStream) {
  21832. this._error(reason);
  21833. return;
  21834. }
  21835. this._readableStream.destroy(reason);
  21836. }
  21837. }, {
  21838. key: "_error",
  21839. value: function _error(reason) {
  21840. this._storedError = reason;
  21841. this._readCapability.resolve();
  21842. }
  21843. }, {
  21844. key: "_setReadableStream",
  21845. value: function _setReadableStream(readableStream) {
  21846. var _this2 = this;
  21847. this._readableStream = readableStream;
  21848. readableStream.on("readable", function () {
  21849. _this2._readCapability.resolve();
  21850. });
  21851. readableStream.on("end", function () {
  21852. readableStream.destroy();
  21853. _this2._done = true;
  21854. _this2._readCapability.resolve();
  21855. });
  21856. readableStream.on("error", function (reason) {
  21857. _this2._error(reason);
  21858. });
  21859. if (this._storedError) {
  21860. this._readableStream.destroy(this._storedError);
  21861. }
  21862. }
  21863. }, {
  21864. key: "isStreamingSupported",
  21865. get: function get() {
  21866. return this._isStreamingSupported;
  21867. }
  21868. }]);
  21869. return BaseRangeReader;
  21870. }();
  21871. function createRequestOptions(parsedUrl, headers) {
  21872. return {
  21873. protocol: parsedUrl.protocol,
  21874. auth: parsedUrl.auth,
  21875. host: parsedUrl.hostname,
  21876. port: parsedUrl.port,
  21877. path: parsedUrl.path,
  21878. method: "GET",
  21879. headers: headers
  21880. };
  21881. }
  21882. var PDFNodeStreamFullReader = /*#__PURE__*/function (_BaseFullReader) {
  21883. _inherits(PDFNodeStreamFullReader, _BaseFullReader);
  21884. var _super = _createSuper(PDFNodeStreamFullReader);
  21885. function PDFNodeStreamFullReader(stream) {
  21886. var _this3;
  21887. _classCallCheck(this, PDFNodeStreamFullReader);
  21888. _this3 = _super.call(this, stream);
  21889. var handleResponse = function handleResponse(response) {
  21890. if (response.statusCode === 404) {
  21891. var error = new _util.MissingPDFException("Missing PDF \"".concat(_this3._url, "\"."));
  21892. _this3._storedError = error;
  21893. _this3._headersCapability.reject(error);
  21894. return;
  21895. }
  21896. _this3._headersCapability.resolve();
  21897. _this3._setReadableStream(response);
  21898. var getResponseHeader = function getResponseHeader(name) {
  21899. return _this3._readableStream.headers[name.toLowerCase()];
  21900. };
  21901. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  21902. getResponseHeader: getResponseHeader,
  21903. isHttp: stream.isHttp,
  21904. rangeChunkSize: _this3._rangeChunkSize,
  21905. disableRange: _this3._disableRange
  21906. }),
  21907. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  21908. suggestedLength = _validateRangeRequest.suggestedLength;
  21909. _this3._isRangeSupported = allowRangeRequests;
  21910. _this3._contentLength = suggestedLength || _this3._contentLength;
  21911. _this3._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  21912. };
  21913. _this3._request = null;
  21914. if (_this3._url.protocol === "http:") {
  21915. _this3._request = http.request(createRequestOptions(_this3._url, stream.httpHeaders), handleResponse);
  21916. } else {
  21917. _this3._request = https.request(createRequestOptions(_this3._url, stream.httpHeaders), handleResponse);
  21918. }
  21919. _this3._request.on("error", function (reason) {
  21920. _this3._storedError = reason;
  21921. _this3._headersCapability.reject(reason);
  21922. });
  21923. _this3._request.end();
  21924. return _this3;
  21925. }
  21926. return PDFNodeStreamFullReader;
  21927. }(BaseFullReader);
  21928. var PDFNodeStreamRangeReader = /*#__PURE__*/function (_BaseRangeReader) {
  21929. _inherits(PDFNodeStreamRangeReader, _BaseRangeReader);
  21930. var _super2 = _createSuper(PDFNodeStreamRangeReader);
  21931. function PDFNodeStreamRangeReader(stream, start, end) {
  21932. var _this4;
  21933. _classCallCheck(this, PDFNodeStreamRangeReader);
  21934. _this4 = _super2.call(this, stream);
  21935. _this4._httpHeaders = {};
  21936. for (var property in stream.httpHeaders) {
  21937. var value = stream.httpHeaders[property];
  21938. if (typeof value === "undefined") {
  21939. continue;
  21940. }
  21941. _this4._httpHeaders[property] = value;
  21942. }
  21943. _this4._httpHeaders.Range = "bytes=".concat(start, "-").concat(end - 1);
  21944. var handleResponse = function handleResponse(response) {
  21945. if (response.statusCode === 404) {
  21946. var error = new _util.MissingPDFException("Missing PDF \"".concat(_this4._url, "\"."));
  21947. _this4._storedError = error;
  21948. return;
  21949. }
  21950. _this4._setReadableStream(response);
  21951. };
  21952. _this4._request = null;
  21953. if (_this4._url.protocol === "http:") {
  21954. _this4._request = http.request(createRequestOptions(_this4._url, _this4._httpHeaders), handleResponse);
  21955. } else {
  21956. _this4._request = https.request(createRequestOptions(_this4._url, _this4._httpHeaders), handleResponse);
  21957. }
  21958. _this4._request.on("error", function (reason) {
  21959. _this4._storedError = reason;
  21960. });
  21961. _this4._request.end();
  21962. return _this4;
  21963. }
  21964. return PDFNodeStreamRangeReader;
  21965. }(BaseRangeReader);
  21966. var PDFNodeStreamFsFullReader = /*#__PURE__*/function (_BaseFullReader2) {
  21967. _inherits(PDFNodeStreamFsFullReader, _BaseFullReader2);
  21968. var _super3 = _createSuper(PDFNodeStreamFsFullReader);
  21969. function PDFNodeStreamFsFullReader(stream) {
  21970. var _this5;
  21971. _classCallCheck(this, PDFNodeStreamFsFullReader);
  21972. _this5 = _super3.call(this, stream);
  21973. var path = decodeURIComponent(_this5._url.path);
  21974. if (fileUriRegex.test(_this5._url.href)) {
  21975. path = path.replace(/^\//, "");
  21976. }
  21977. fs.lstat(path, function (error, stat) {
  21978. if (error) {
  21979. if (error.code === "ENOENT") {
  21980. error = new _util.MissingPDFException("Missing PDF \"".concat(path, "\"."));
  21981. }
  21982. _this5._storedError = error;
  21983. _this5._headersCapability.reject(error);
  21984. return;
  21985. }
  21986. _this5._contentLength = stat.size;
  21987. _this5._setReadableStream(fs.createReadStream(path));
  21988. _this5._headersCapability.resolve();
  21989. });
  21990. return _this5;
  21991. }
  21992. return PDFNodeStreamFsFullReader;
  21993. }(BaseFullReader);
  21994. var PDFNodeStreamFsRangeReader = /*#__PURE__*/function (_BaseRangeReader2) {
  21995. _inherits(PDFNodeStreamFsRangeReader, _BaseRangeReader2);
  21996. var _super4 = _createSuper(PDFNodeStreamFsRangeReader);
  21997. function PDFNodeStreamFsRangeReader(stream, start, end) {
  21998. var _this6;
  21999. _classCallCheck(this, PDFNodeStreamFsRangeReader);
  22000. _this6 = _super4.call(this, stream);
  22001. var path = decodeURIComponent(_this6._url.path);
  22002. if (fileUriRegex.test(_this6._url.href)) {
  22003. path = path.replace(/^\//, "");
  22004. }
  22005. _this6._setReadableStream(fs.createReadStream(path, {
  22006. start: start,
  22007. end: end - 1
  22008. }));
  22009. return _this6;
  22010. }
  22011. return PDFNodeStreamFsRangeReader;
  22012. }(BaseRangeReader);
  22013. /***/ }),
  22014. /* 220 */
  22015. /***/ (function(module, exports, __w_pdfjs_require__) {
  22016. "use strict";
  22017. Object.defineProperty(exports, "__esModule", {
  22018. value: true
  22019. });
  22020. exports.createResponseStatusError = createResponseStatusError;
  22021. exports.extractFilenameFromHeader = extractFilenameFromHeader;
  22022. exports.validateRangeRequestCapabilities = validateRangeRequestCapabilities;
  22023. exports.validateResponseStatus = validateResponseStatus;
  22024. var _util = __w_pdfjs_require__(5);
  22025. var _content_disposition = __w_pdfjs_require__(221);
  22026. function validateRangeRequestCapabilities(_ref) {
  22027. var getResponseHeader = _ref.getResponseHeader,
  22028. isHttp = _ref.isHttp,
  22029. rangeChunkSize = _ref.rangeChunkSize,
  22030. disableRange = _ref.disableRange;
  22031. (0, _util.assert)(rangeChunkSize > 0, "Range chunk size must be larger than zero");
  22032. var returnValues = {
  22033. allowRangeRequests: false,
  22034. suggestedLength: undefined
  22035. };
  22036. var length = parseInt(getResponseHeader("Content-Length"), 10);
  22037. if (!Number.isInteger(length)) {
  22038. return returnValues;
  22039. }
  22040. returnValues.suggestedLength = length;
  22041. if (length <= 2 * rangeChunkSize) {
  22042. return returnValues;
  22043. }
  22044. if (disableRange || !isHttp) {
  22045. return returnValues;
  22046. }
  22047. if (getResponseHeader("Accept-Ranges") !== "bytes") {
  22048. return returnValues;
  22049. }
  22050. var contentEncoding = getResponseHeader("Content-Encoding") || "identity";
  22051. if (contentEncoding !== "identity") {
  22052. return returnValues;
  22053. }
  22054. returnValues.allowRangeRequests = true;
  22055. return returnValues;
  22056. }
  22057. function extractFilenameFromHeader(getResponseHeader) {
  22058. var contentDisposition = getResponseHeader("Content-Disposition");
  22059. if (contentDisposition) {
  22060. var filename = (0, _content_disposition.getFilenameFromContentDispositionHeader)(contentDisposition);
  22061. if (filename.includes("%")) {
  22062. try {
  22063. filename = decodeURIComponent(filename);
  22064. } catch (ex) {}
  22065. }
  22066. if (/\.pdf$/i.test(filename)) {
  22067. return filename;
  22068. }
  22069. }
  22070. return null;
  22071. }
  22072. function createResponseStatusError(status, url) {
  22073. if (status === 404 || status === 0 && url.startsWith("file:")) {
  22074. return new _util.MissingPDFException('Missing PDF "' + url + '".');
  22075. }
  22076. return new _util.UnexpectedResponseException("Unexpected server response (" + status + ') while retrieving PDF "' + url + '".', status);
  22077. }
  22078. function validateResponseStatus(status) {
  22079. return status === 200 || status === 206;
  22080. }
  22081. /***/ }),
  22082. /* 221 */
  22083. /***/ (function(module, exports, __w_pdfjs_require__) {
  22084. "use strict";
  22085. Object.defineProperty(exports, "__esModule", {
  22086. value: true
  22087. });
  22088. exports.getFilenameFromContentDispositionHeader = getFilenameFromContentDispositionHeader;
  22089. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  22090. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  22091. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  22092. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  22093. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  22094. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  22095. function getFilenameFromContentDispositionHeader(contentDisposition) {
  22096. var needsEncodingFixup = true;
  22097. var tmp = toParamRegExp("filename\\*", "i").exec(contentDisposition);
  22098. if (tmp) {
  22099. tmp = tmp[1];
  22100. var filename = rfc2616unquote(tmp);
  22101. filename = unescape(filename);
  22102. filename = rfc5987decode(filename);
  22103. filename = rfc2047decode(filename);
  22104. return fixupEncoding(filename);
  22105. }
  22106. tmp = rfc2231getparam(contentDisposition);
  22107. if (tmp) {
  22108. var _filename = rfc2047decode(tmp);
  22109. return fixupEncoding(_filename);
  22110. }
  22111. tmp = toParamRegExp("filename", "i").exec(contentDisposition);
  22112. if (tmp) {
  22113. tmp = tmp[1];
  22114. var _filename2 = rfc2616unquote(tmp);
  22115. _filename2 = rfc2047decode(_filename2);
  22116. return fixupEncoding(_filename2);
  22117. }
  22118. function toParamRegExp(attributePattern, flags) {
  22119. return new RegExp("(?:^|;)\\s*" + attributePattern + "\\s*=\\s*" + "(" + '[^";\\s][^;\\s]*' + "|" + '"(?:[^"\\\\]|\\\\"?)+"?' + ")", flags);
  22120. }
  22121. function textdecode(encoding, value) {
  22122. if (encoding) {
  22123. if (!/^[\x00-\xFF]+$/.test(value)) {
  22124. return value;
  22125. }
  22126. try {
  22127. var decoder = new TextDecoder(encoding, {
  22128. fatal: true
  22129. });
  22130. var bytes = Array.from(value, function (ch) {
  22131. return ch.charCodeAt(0) & 0xff;
  22132. });
  22133. value = decoder.decode(new Uint8Array(bytes));
  22134. needsEncodingFixup = false;
  22135. } catch (e) {
  22136. if (/^utf-?8$/i.test(encoding)) {
  22137. try {
  22138. value = decodeURIComponent(escape(value));
  22139. needsEncodingFixup = false;
  22140. } catch (err) {}
  22141. }
  22142. }
  22143. }
  22144. return value;
  22145. }
  22146. function fixupEncoding(value) {
  22147. if (needsEncodingFixup && /[\x80-\xff]/.test(value)) {
  22148. value = textdecode("utf-8", value);
  22149. if (needsEncodingFixup) {
  22150. value = textdecode("iso-8859-1", value);
  22151. }
  22152. }
  22153. return value;
  22154. }
  22155. function rfc2231getparam(contentDispositionStr) {
  22156. var matches = [];
  22157. var match;
  22158. var iter = toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)", "ig");
  22159. while ((match = iter.exec(contentDispositionStr)) !== null) {
  22160. var _match = match,
  22161. _match2 = _slicedToArray(_match, 4),
  22162. n = _match2[1],
  22163. quot = _match2[2],
  22164. part = _match2[3];
  22165. n = parseInt(n, 10);
  22166. if (n in matches) {
  22167. if (n === 0) {
  22168. break;
  22169. }
  22170. continue;
  22171. }
  22172. matches[n] = [quot, part];
  22173. }
  22174. var parts = [];
  22175. for (var _n2 = 0; _n2 < matches.length; ++_n2) {
  22176. if (!(_n2 in matches)) {
  22177. break;
  22178. }
  22179. var _matches$_n = _slicedToArray(matches[_n2], 2),
  22180. _quot = _matches$_n[0],
  22181. _part = _matches$_n[1];
  22182. _part = rfc2616unquote(_part);
  22183. if (_quot) {
  22184. _part = unescape(_part);
  22185. if (_n2 === 0) {
  22186. _part = rfc5987decode(_part);
  22187. }
  22188. }
  22189. parts.push(_part);
  22190. }
  22191. return parts.join("");
  22192. }
  22193. function rfc2616unquote(value) {
  22194. if (value.startsWith('"')) {
  22195. var parts = value.slice(1).split('\\"');
  22196. for (var i = 0; i < parts.length; ++i) {
  22197. var quotindex = parts[i].indexOf('"');
  22198. if (quotindex !== -1) {
  22199. parts[i] = parts[i].slice(0, quotindex);
  22200. parts.length = i + 1;
  22201. }
  22202. parts[i] = parts[i].replace(/\\(.)/g, "$1");
  22203. }
  22204. value = parts.join('"');
  22205. }
  22206. return value;
  22207. }
  22208. function rfc5987decode(extvalue) {
  22209. var encodingend = extvalue.indexOf("'");
  22210. if (encodingend === -1) {
  22211. return extvalue;
  22212. }
  22213. var encoding = extvalue.slice(0, encodingend);
  22214. var langvalue = extvalue.slice(encodingend + 1);
  22215. var value = langvalue.replace(/^[^']*'/, "");
  22216. return textdecode(encoding, value);
  22217. }
  22218. function rfc2047decode(value) {
  22219. if (!value.startsWith("=?") || /[\x00-\x19\x80-\xff]/.test(value)) {
  22220. return value;
  22221. }
  22222. return value.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g, function (matches, charset, encoding, text) {
  22223. if (encoding === "q" || encoding === "Q") {
  22224. text = text.replace(/_/g, " ");
  22225. text = text.replace(/=([0-9a-fA-F]{2})/g, function (match, hex) {
  22226. return String.fromCharCode(parseInt(hex, 16));
  22227. });
  22228. return textdecode(charset, text);
  22229. }
  22230. try {
  22231. text = atob(text);
  22232. } catch (e) {}
  22233. return textdecode(charset, text);
  22234. });
  22235. }
  22236. return "";
  22237. }
  22238. /***/ }),
  22239. /* 222 */
  22240. /***/ (function(module, exports, __w_pdfjs_require__) {
  22241. "use strict";
  22242. Object.defineProperty(exports, "__esModule", {
  22243. value: true
  22244. });
  22245. exports.PDFNetworkStream = void 0;
  22246. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(2));
  22247. var _util = __w_pdfjs_require__(5);
  22248. var _network_utils = __w_pdfjs_require__(220);
  22249. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  22250. 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); } }
  22251. 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); }); }; }
  22252. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22253. 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); } }
  22254. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  22255. ;
  22256. var OK_RESPONSE = 200;
  22257. var PARTIAL_CONTENT_RESPONSE = 206;
  22258. function getArrayBuffer(xhr) {
  22259. var data = xhr.response;
  22260. if (typeof data !== "string") {
  22261. return data;
  22262. }
  22263. var array = (0, _util.stringToBytes)(data);
  22264. return array.buffer;
  22265. }
  22266. var NetworkManager = /*#__PURE__*/function () {
  22267. function NetworkManager(url, args) {
  22268. _classCallCheck(this, NetworkManager);
  22269. this.url = url;
  22270. args = args || {};
  22271. this.isHttp = /^https?:/i.test(url);
  22272. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  22273. this.withCredentials = args.withCredentials || false;
  22274. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  22275. return new XMLHttpRequest();
  22276. };
  22277. this.currXhrId = 0;
  22278. this.pendingRequests = Object.create(null);
  22279. }
  22280. _createClass(NetworkManager, [{
  22281. key: "requestRange",
  22282. value: function requestRange(begin, end, listeners) {
  22283. var args = {
  22284. begin: begin,
  22285. end: end
  22286. };
  22287. for (var prop in listeners) {
  22288. args[prop] = listeners[prop];
  22289. }
  22290. return this.request(args);
  22291. }
  22292. }, {
  22293. key: "requestFull",
  22294. value: function requestFull(listeners) {
  22295. return this.request(listeners);
  22296. }
  22297. }, {
  22298. key: "request",
  22299. value: function request(args) {
  22300. var xhr = this.getXhr();
  22301. var xhrId = this.currXhrId++;
  22302. var pendingRequest = this.pendingRequests[xhrId] = {
  22303. xhr: xhr
  22304. };
  22305. xhr.open("GET", this.url);
  22306. xhr.withCredentials = this.withCredentials;
  22307. for (var property in this.httpHeaders) {
  22308. var value = this.httpHeaders[property];
  22309. if (typeof value === "undefined") {
  22310. continue;
  22311. }
  22312. xhr.setRequestHeader(property, value);
  22313. }
  22314. if (this.isHttp && "begin" in args && "end" in args) {
  22315. xhr.setRequestHeader("Range", "bytes=".concat(args.begin, "-").concat(args.end - 1));
  22316. pendingRequest.expectedStatus = PARTIAL_CONTENT_RESPONSE;
  22317. } else {
  22318. pendingRequest.expectedStatus = OK_RESPONSE;
  22319. }
  22320. xhr.responseType = "arraybuffer";
  22321. if (args.onError) {
  22322. xhr.onerror = function (evt) {
  22323. args.onError(xhr.status);
  22324. };
  22325. }
  22326. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  22327. xhr.onprogress = this.onProgress.bind(this, xhrId);
  22328. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  22329. pendingRequest.onDone = args.onDone;
  22330. pendingRequest.onError = args.onError;
  22331. pendingRequest.onProgress = args.onProgress;
  22332. xhr.send(null);
  22333. return xhrId;
  22334. }
  22335. }, {
  22336. key: "onProgress",
  22337. value: function onProgress(xhrId, evt) {
  22338. var pendingRequest = this.pendingRequests[xhrId];
  22339. if (!pendingRequest) {
  22340. return;
  22341. }
  22342. if (pendingRequest.onProgress) {
  22343. pendingRequest.onProgress(evt);
  22344. }
  22345. }
  22346. }, {
  22347. key: "onStateChange",
  22348. value: function onStateChange(xhrId, evt) {
  22349. var pendingRequest = this.pendingRequests[xhrId];
  22350. if (!pendingRequest) {
  22351. return;
  22352. }
  22353. var xhr = pendingRequest.xhr;
  22354. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  22355. pendingRequest.onHeadersReceived();
  22356. delete pendingRequest.onHeadersReceived;
  22357. }
  22358. if (xhr.readyState !== 4) {
  22359. return;
  22360. }
  22361. if (!(xhrId in this.pendingRequests)) {
  22362. return;
  22363. }
  22364. delete this.pendingRequests[xhrId];
  22365. if (xhr.status === 0 && this.isHttp) {
  22366. if (pendingRequest.onError) {
  22367. pendingRequest.onError(xhr.status);
  22368. }
  22369. return;
  22370. }
  22371. var xhrStatus = xhr.status || OK_RESPONSE;
  22372. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  22373. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  22374. if (pendingRequest.onError) {
  22375. pendingRequest.onError(xhr.status);
  22376. }
  22377. return;
  22378. }
  22379. var chunk = getArrayBuffer(xhr);
  22380. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  22381. var rangeHeader = xhr.getResponseHeader("Content-Range");
  22382. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  22383. pendingRequest.onDone({
  22384. begin: parseInt(matches[1], 10),
  22385. chunk: chunk
  22386. });
  22387. } else if (chunk) {
  22388. pendingRequest.onDone({
  22389. begin: 0,
  22390. chunk: chunk
  22391. });
  22392. } else if (pendingRequest.onError) {
  22393. pendingRequest.onError(xhr.status);
  22394. }
  22395. }
  22396. }, {
  22397. key: "getRequestXhr",
  22398. value: function getRequestXhr(xhrId) {
  22399. return this.pendingRequests[xhrId].xhr;
  22400. }
  22401. }, {
  22402. key: "isPendingRequest",
  22403. value: function isPendingRequest(xhrId) {
  22404. return xhrId in this.pendingRequests;
  22405. }
  22406. }, {
  22407. key: "abortRequest",
  22408. value: function abortRequest(xhrId) {
  22409. var xhr = this.pendingRequests[xhrId].xhr;
  22410. delete this.pendingRequests[xhrId];
  22411. xhr.abort();
  22412. }
  22413. }]);
  22414. return NetworkManager;
  22415. }();
  22416. var PDFNetworkStream = /*#__PURE__*/function () {
  22417. function PDFNetworkStream(source) {
  22418. _classCallCheck(this, PDFNetworkStream);
  22419. this._source = source;
  22420. this._manager = new NetworkManager(source.url, {
  22421. httpHeaders: source.httpHeaders,
  22422. withCredentials: source.withCredentials
  22423. });
  22424. this._rangeChunkSize = source.rangeChunkSize;
  22425. this._fullRequestReader = null;
  22426. this._rangeRequestReaders = [];
  22427. }
  22428. _createClass(PDFNetworkStream, [{
  22429. key: "_onRangeRequestReaderClosed",
  22430. value: function _onRangeRequestReaderClosed(reader) {
  22431. var i = this._rangeRequestReaders.indexOf(reader);
  22432. if (i >= 0) {
  22433. this._rangeRequestReaders.splice(i, 1);
  22434. }
  22435. }
  22436. }, {
  22437. key: "getFullReader",
  22438. value: function getFullReader() {
  22439. (0, _util.assert)(!this._fullRequestReader, "PDFNetworkStream.getFullReader can only be called once.");
  22440. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._source);
  22441. return this._fullRequestReader;
  22442. }
  22443. }, {
  22444. key: "getRangeReader",
  22445. value: function getRangeReader(begin, end) {
  22446. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  22447. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  22448. this._rangeRequestReaders.push(reader);
  22449. return reader;
  22450. }
  22451. }, {
  22452. key: "cancelAllRequests",
  22453. value: function cancelAllRequests(reason) {
  22454. if (this._fullRequestReader) {
  22455. this._fullRequestReader.cancel(reason);
  22456. }
  22457. var readers = this._rangeRequestReaders.slice(0);
  22458. readers.forEach(function (reader) {
  22459. reader.cancel(reason);
  22460. });
  22461. }
  22462. }]);
  22463. return PDFNetworkStream;
  22464. }();
  22465. exports.PDFNetworkStream = PDFNetworkStream;
  22466. var PDFNetworkStreamFullRequestReader = /*#__PURE__*/function () {
  22467. function PDFNetworkStreamFullRequestReader(manager, source) {
  22468. _classCallCheck(this, PDFNetworkStreamFullRequestReader);
  22469. this._manager = manager;
  22470. var args = {
  22471. onHeadersReceived: this._onHeadersReceived.bind(this),
  22472. onDone: this._onDone.bind(this),
  22473. onError: this._onError.bind(this),
  22474. onProgress: this._onProgress.bind(this)
  22475. };
  22476. this._url = source.url;
  22477. this._fullRequestId = manager.requestFull(args);
  22478. this._headersReceivedCapability = (0, _util.createPromiseCapability)();
  22479. this._disableRange = source.disableRange || false;
  22480. this._contentLength = source.length;
  22481. this._rangeChunkSize = source.rangeChunkSize;
  22482. if (!this._rangeChunkSize && !this._disableRange) {
  22483. this._disableRange = true;
  22484. }
  22485. this._isStreamingSupported = false;
  22486. this._isRangeSupported = false;
  22487. this._cachedChunks = [];
  22488. this._requests = [];
  22489. this._done = false;
  22490. this._storedError = undefined;
  22491. this._filename = null;
  22492. this.onProgress = null;
  22493. }
  22494. _createClass(PDFNetworkStreamFullRequestReader, [{
  22495. key: "_onHeadersReceived",
  22496. value: function _onHeadersReceived() {
  22497. var fullRequestXhrId = this._fullRequestId;
  22498. var fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);
  22499. var getResponseHeader = function getResponseHeader(name) {
  22500. return fullRequestXhr.getResponseHeader(name);
  22501. };
  22502. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  22503. getResponseHeader: getResponseHeader,
  22504. isHttp: this._manager.isHttp,
  22505. rangeChunkSize: this._rangeChunkSize,
  22506. disableRange: this._disableRange
  22507. }),
  22508. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  22509. suggestedLength = _validateRangeRequest.suggestedLength;
  22510. if (allowRangeRequests) {
  22511. this._isRangeSupported = true;
  22512. }
  22513. this._contentLength = suggestedLength || this._contentLength;
  22514. this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  22515. if (this._isRangeSupported) {
  22516. this._manager.abortRequest(fullRequestXhrId);
  22517. }
  22518. this._headersReceivedCapability.resolve();
  22519. }
  22520. }, {
  22521. key: "_onDone",
  22522. value: function _onDone(args) {
  22523. if (args) {
  22524. if (this._requests.length > 0) {
  22525. var requestCapability = this._requests.shift();
  22526. requestCapability.resolve({
  22527. value: args.chunk,
  22528. done: false
  22529. });
  22530. } else {
  22531. this._cachedChunks.push(args.chunk);
  22532. }
  22533. }
  22534. this._done = true;
  22535. if (this._cachedChunks.length > 0) {
  22536. return;
  22537. }
  22538. this._requests.forEach(function (requestCapability) {
  22539. requestCapability.resolve({
  22540. value: undefined,
  22541. done: true
  22542. });
  22543. });
  22544. this._requests = [];
  22545. }
  22546. }, {
  22547. key: "_onError",
  22548. value: function _onError(status) {
  22549. var url = this._url;
  22550. var exception = (0, _network_utils.createResponseStatusError)(status, url);
  22551. this._storedError = exception;
  22552. this._headersReceivedCapability.reject(exception);
  22553. this._requests.forEach(function (requestCapability) {
  22554. requestCapability.reject(exception);
  22555. });
  22556. this._requests = [];
  22557. this._cachedChunks = [];
  22558. }
  22559. }, {
  22560. key: "_onProgress",
  22561. value: function _onProgress(data) {
  22562. if (this.onProgress) {
  22563. this.onProgress({
  22564. loaded: data.loaded,
  22565. total: data.lengthComputable ? data.total : this._contentLength
  22566. });
  22567. }
  22568. }
  22569. }, {
  22570. key: "read",
  22571. value: function () {
  22572. var _read = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  22573. var chunk, requestCapability;
  22574. return _regenerator["default"].wrap(function _callee$(_context) {
  22575. while (1) {
  22576. switch (_context.prev = _context.next) {
  22577. case 0:
  22578. if (!this._storedError) {
  22579. _context.next = 2;
  22580. break;
  22581. }
  22582. throw this._storedError;
  22583. case 2:
  22584. if (!(this._cachedChunks.length > 0)) {
  22585. _context.next = 5;
  22586. break;
  22587. }
  22588. chunk = this._cachedChunks.shift();
  22589. return _context.abrupt("return", {
  22590. value: chunk,
  22591. done: false
  22592. });
  22593. case 5:
  22594. if (!this._done) {
  22595. _context.next = 7;
  22596. break;
  22597. }
  22598. return _context.abrupt("return", {
  22599. value: undefined,
  22600. done: true
  22601. });
  22602. case 7:
  22603. requestCapability = (0, _util.createPromiseCapability)();
  22604. this._requests.push(requestCapability);
  22605. return _context.abrupt("return", requestCapability.promise);
  22606. case 10:
  22607. case "end":
  22608. return _context.stop();
  22609. }
  22610. }
  22611. }, _callee, this);
  22612. }));
  22613. function read() {
  22614. return _read.apply(this, arguments);
  22615. }
  22616. return read;
  22617. }()
  22618. }, {
  22619. key: "cancel",
  22620. value: function cancel(reason) {
  22621. this._done = true;
  22622. this._headersReceivedCapability.reject(reason);
  22623. this._requests.forEach(function (requestCapability) {
  22624. requestCapability.resolve({
  22625. value: undefined,
  22626. done: true
  22627. });
  22628. });
  22629. this._requests = [];
  22630. if (this._manager.isPendingRequest(this._fullRequestId)) {
  22631. this._manager.abortRequest(this._fullRequestId);
  22632. }
  22633. this._fullRequestReader = null;
  22634. }
  22635. }, {
  22636. key: "filename",
  22637. get: function get() {
  22638. return this._filename;
  22639. }
  22640. }, {
  22641. key: "isRangeSupported",
  22642. get: function get() {
  22643. return this._isRangeSupported;
  22644. }
  22645. }, {
  22646. key: "isStreamingSupported",
  22647. get: function get() {
  22648. return this._isStreamingSupported;
  22649. }
  22650. }, {
  22651. key: "contentLength",
  22652. get: function get() {
  22653. return this._contentLength;
  22654. }
  22655. }, {
  22656. key: "headersReady",
  22657. get: function get() {
  22658. return this._headersReceivedCapability.promise;
  22659. }
  22660. }]);
  22661. return PDFNetworkStreamFullRequestReader;
  22662. }();
  22663. var PDFNetworkStreamRangeRequestReader = /*#__PURE__*/function () {
  22664. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  22665. _classCallCheck(this, PDFNetworkStreamRangeRequestReader);
  22666. this._manager = manager;
  22667. var args = {
  22668. onDone: this._onDone.bind(this),
  22669. onProgress: this._onProgress.bind(this)
  22670. };
  22671. this._requestId = manager.requestRange(begin, end, args);
  22672. this._requests = [];
  22673. this._queuedChunk = null;
  22674. this._done = false;
  22675. this.onProgress = null;
  22676. this.onClosed = null;
  22677. }
  22678. _createClass(PDFNetworkStreamRangeRequestReader, [{
  22679. key: "_close",
  22680. value: function _close() {
  22681. if (this.onClosed) {
  22682. this.onClosed(this);
  22683. }
  22684. }
  22685. }, {
  22686. key: "_onDone",
  22687. value: function _onDone(data) {
  22688. var chunk = data.chunk;
  22689. if (this._requests.length > 0) {
  22690. var requestCapability = this._requests.shift();
  22691. requestCapability.resolve({
  22692. value: chunk,
  22693. done: false
  22694. });
  22695. } else {
  22696. this._queuedChunk = chunk;
  22697. }
  22698. this._done = true;
  22699. this._requests.forEach(function (requestCapability) {
  22700. requestCapability.resolve({
  22701. value: undefined,
  22702. done: true
  22703. });
  22704. });
  22705. this._requests = [];
  22706. this._close();
  22707. }
  22708. }, {
  22709. key: "_onProgress",
  22710. value: function _onProgress(evt) {
  22711. if (!this.isStreamingSupported && this.onProgress) {
  22712. this.onProgress({
  22713. loaded: evt.loaded
  22714. });
  22715. }
  22716. }
  22717. }, {
  22718. key: "read",
  22719. value: function () {
  22720. var _read2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  22721. var chunk, requestCapability;
  22722. return _regenerator["default"].wrap(function _callee2$(_context2) {
  22723. while (1) {
  22724. switch (_context2.prev = _context2.next) {
  22725. case 0:
  22726. if (!(this._queuedChunk !== null)) {
  22727. _context2.next = 4;
  22728. break;
  22729. }
  22730. chunk = this._queuedChunk;
  22731. this._queuedChunk = null;
  22732. return _context2.abrupt("return", {
  22733. value: chunk,
  22734. done: false
  22735. });
  22736. case 4:
  22737. if (!this._done) {
  22738. _context2.next = 6;
  22739. break;
  22740. }
  22741. return _context2.abrupt("return", {
  22742. value: undefined,
  22743. done: true
  22744. });
  22745. case 6:
  22746. requestCapability = (0, _util.createPromiseCapability)();
  22747. this._requests.push(requestCapability);
  22748. return _context2.abrupt("return", requestCapability.promise);
  22749. case 9:
  22750. case "end":
  22751. return _context2.stop();
  22752. }
  22753. }
  22754. }, _callee2, this);
  22755. }));
  22756. function read() {
  22757. return _read2.apply(this, arguments);
  22758. }
  22759. return read;
  22760. }()
  22761. }, {
  22762. key: "cancel",
  22763. value: function cancel(reason) {
  22764. this._done = true;
  22765. this._requests.forEach(function (requestCapability) {
  22766. requestCapability.resolve({
  22767. value: undefined,
  22768. done: true
  22769. });
  22770. });
  22771. this._requests = [];
  22772. if (this._manager.isPendingRequest(this._requestId)) {
  22773. this._manager.abortRequest(this._requestId);
  22774. }
  22775. this._close();
  22776. }
  22777. }, {
  22778. key: "isStreamingSupported",
  22779. get: function get() {
  22780. return false;
  22781. }
  22782. }]);
  22783. return PDFNetworkStreamRangeRequestReader;
  22784. }();
  22785. /***/ }),
  22786. /* 223 */
  22787. /***/ (function(module, exports, __w_pdfjs_require__) {
  22788. "use strict";
  22789. Object.defineProperty(exports, "__esModule", {
  22790. value: true
  22791. });
  22792. exports.PDFFetchStream = void 0;
  22793. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(2));
  22794. var _util = __w_pdfjs_require__(5);
  22795. var _network_utils = __w_pdfjs_require__(220);
  22796. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  22797. 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); } }
  22798. 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); }); }; }
  22799. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22800. 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); } }
  22801. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  22802. ;
  22803. function createFetchOptions(headers, withCredentials, abortController) {
  22804. return {
  22805. method: "GET",
  22806. headers: headers,
  22807. signal: abortController && abortController.signal,
  22808. mode: "cors",
  22809. credentials: withCredentials ? "include" : "same-origin",
  22810. redirect: "follow"
  22811. };
  22812. }
  22813. function createHeaders(httpHeaders) {
  22814. var headers = new Headers();
  22815. for (var property in httpHeaders) {
  22816. var value = httpHeaders[property];
  22817. if (typeof value === "undefined") {
  22818. continue;
  22819. }
  22820. headers.append(property, value);
  22821. }
  22822. return headers;
  22823. }
  22824. var PDFFetchStream = /*#__PURE__*/function () {
  22825. function PDFFetchStream(source) {
  22826. _classCallCheck(this, PDFFetchStream);
  22827. this.source = source;
  22828. this.isHttp = /^https?:/i.test(source.url);
  22829. this.httpHeaders = this.isHttp && source.httpHeaders || {};
  22830. this._fullRequestReader = null;
  22831. this._rangeRequestReaders = [];
  22832. }
  22833. _createClass(PDFFetchStream, [{
  22834. key: "getFullReader",
  22835. value: function getFullReader() {
  22836. (0, _util.assert)(!this._fullRequestReader, "PDFFetchStream.getFullReader can only be called once.");
  22837. this._fullRequestReader = new PDFFetchStreamReader(this);
  22838. return this._fullRequestReader;
  22839. }
  22840. }, {
  22841. key: "getRangeReader",
  22842. value: function getRangeReader(begin, end) {
  22843. if (end <= this._progressiveDataLength) {
  22844. return null;
  22845. }
  22846. var reader = new PDFFetchStreamRangeReader(this, begin, end);
  22847. this._rangeRequestReaders.push(reader);
  22848. return reader;
  22849. }
  22850. }, {
  22851. key: "cancelAllRequests",
  22852. value: function cancelAllRequests(reason) {
  22853. if (this._fullRequestReader) {
  22854. this._fullRequestReader.cancel(reason);
  22855. }
  22856. var readers = this._rangeRequestReaders.slice(0);
  22857. readers.forEach(function (reader) {
  22858. reader.cancel(reason);
  22859. });
  22860. }
  22861. }, {
  22862. key: "_progressiveDataLength",
  22863. get: function get() {
  22864. return this._fullRequestReader ? this._fullRequestReader._loaded : 0;
  22865. }
  22866. }]);
  22867. return PDFFetchStream;
  22868. }();
  22869. exports.PDFFetchStream = PDFFetchStream;
  22870. var PDFFetchStreamReader = /*#__PURE__*/function () {
  22871. function PDFFetchStreamReader(stream) {
  22872. var _this = this;
  22873. _classCallCheck(this, PDFFetchStreamReader);
  22874. this._stream = stream;
  22875. this._reader = null;
  22876. this._loaded = 0;
  22877. this._filename = null;
  22878. var source = stream.source;
  22879. this._withCredentials = source.withCredentials || false;
  22880. this._contentLength = source.length;
  22881. this._headersCapability = (0, _util.createPromiseCapability)();
  22882. this._disableRange = source.disableRange || false;
  22883. this._rangeChunkSize = source.rangeChunkSize;
  22884. if (!this._rangeChunkSize && !this._disableRange) {
  22885. this._disableRange = true;
  22886. }
  22887. if (typeof AbortController !== "undefined") {
  22888. this._abortController = new AbortController();
  22889. }
  22890. this._isStreamingSupported = !source.disableStream;
  22891. this._isRangeSupported = !source.disableRange;
  22892. this._headers = createHeaders(this._stream.httpHeaders);
  22893. var url = source.url;
  22894. fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(function (response) {
  22895. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  22896. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  22897. }
  22898. _this._reader = response.body.getReader();
  22899. _this._headersCapability.resolve();
  22900. var getResponseHeader = function getResponseHeader(name) {
  22901. return response.headers.get(name);
  22902. };
  22903. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  22904. getResponseHeader: getResponseHeader,
  22905. isHttp: _this._stream.isHttp,
  22906. rangeChunkSize: _this._rangeChunkSize,
  22907. disableRange: _this._disableRange
  22908. }),
  22909. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  22910. suggestedLength = _validateRangeRequest.suggestedLength;
  22911. _this._isRangeSupported = allowRangeRequests;
  22912. _this._contentLength = suggestedLength || _this._contentLength;
  22913. _this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  22914. if (!_this._isStreamingSupported && _this._isRangeSupported) {
  22915. _this.cancel(new _util.AbortException("Streaming is disabled."));
  22916. }
  22917. })["catch"](this._headersCapability.reject);
  22918. this.onProgress = null;
  22919. }
  22920. _createClass(PDFFetchStreamReader, [{
  22921. key: "read",
  22922. value: function () {
  22923. var _read = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  22924. var _yield$this$_reader$r, value, done, buffer;
  22925. return _regenerator["default"].wrap(function _callee$(_context) {
  22926. while (1) {
  22927. switch (_context.prev = _context.next) {
  22928. case 0:
  22929. _context.next = 2;
  22930. return this._headersCapability.promise;
  22931. case 2:
  22932. _context.next = 4;
  22933. return this._reader.read();
  22934. case 4:
  22935. _yield$this$_reader$r = _context.sent;
  22936. value = _yield$this$_reader$r.value;
  22937. done = _yield$this$_reader$r.done;
  22938. if (!done) {
  22939. _context.next = 9;
  22940. break;
  22941. }
  22942. return _context.abrupt("return", {
  22943. value: value,
  22944. done: done
  22945. });
  22946. case 9:
  22947. this._loaded += value.byteLength;
  22948. if (this.onProgress) {
  22949. this.onProgress({
  22950. loaded: this._loaded,
  22951. total: this._contentLength
  22952. });
  22953. }
  22954. buffer = new Uint8Array(value).buffer;
  22955. return _context.abrupt("return", {
  22956. value: buffer,
  22957. done: false
  22958. });
  22959. case 13:
  22960. case "end":
  22961. return _context.stop();
  22962. }
  22963. }
  22964. }, _callee, this);
  22965. }));
  22966. function read() {
  22967. return _read.apply(this, arguments);
  22968. }
  22969. return read;
  22970. }()
  22971. }, {
  22972. key: "cancel",
  22973. value: function cancel(reason) {
  22974. if (this._reader) {
  22975. this._reader.cancel(reason);
  22976. }
  22977. if (this._abortController) {
  22978. this._abortController.abort();
  22979. }
  22980. }
  22981. }, {
  22982. key: "headersReady",
  22983. get: function get() {
  22984. return this._headersCapability.promise;
  22985. }
  22986. }, {
  22987. key: "filename",
  22988. get: function get() {
  22989. return this._filename;
  22990. }
  22991. }, {
  22992. key: "contentLength",
  22993. get: function get() {
  22994. return this._contentLength;
  22995. }
  22996. }, {
  22997. key: "isRangeSupported",
  22998. get: function get() {
  22999. return this._isRangeSupported;
  23000. }
  23001. }, {
  23002. key: "isStreamingSupported",
  23003. get: function get() {
  23004. return this._isStreamingSupported;
  23005. }
  23006. }]);
  23007. return PDFFetchStreamReader;
  23008. }();
  23009. var PDFFetchStreamRangeReader = /*#__PURE__*/function () {
  23010. function PDFFetchStreamRangeReader(stream, begin, end) {
  23011. var _this2 = this;
  23012. _classCallCheck(this, PDFFetchStreamRangeReader);
  23013. this._stream = stream;
  23014. this._reader = null;
  23015. this._loaded = 0;
  23016. var source = stream.source;
  23017. this._withCredentials = source.withCredentials || false;
  23018. this._readCapability = (0, _util.createPromiseCapability)();
  23019. this._isStreamingSupported = !source.disableStream;
  23020. if (typeof AbortController !== "undefined") {
  23021. this._abortController = new AbortController();
  23022. }
  23023. this._headers = createHeaders(this._stream.httpHeaders);
  23024. this._headers.append("Range", "bytes=".concat(begin, "-").concat(end - 1));
  23025. var url = source.url;
  23026. fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(function (response) {
  23027. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  23028. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  23029. }
  23030. _this2._readCapability.resolve();
  23031. _this2._reader = response.body.getReader();
  23032. })["catch"](function (reason) {
  23033. if (reason && reason.name === "AbortError") {
  23034. return;
  23035. }
  23036. throw reason;
  23037. });
  23038. this.onProgress = null;
  23039. }
  23040. _createClass(PDFFetchStreamRangeReader, [{
  23041. key: "read",
  23042. value: function () {
  23043. var _read2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  23044. var _yield$this$_reader$r2, value, done, buffer;
  23045. return _regenerator["default"].wrap(function _callee2$(_context2) {
  23046. while (1) {
  23047. switch (_context2.prev = _context2.next) {
  23048. case 0:
  23049. _context2.next = 2;
  23050. return this._readCapability.promise;
  23051. case 2:
  23052. _context2.next = 4;
  23053. return this._reader.read();
  23054. case 4:
  23055. _yield$this$_reader$r2 = _context2.sent;
  23056. value = _yield$this$_reader$r2.value;
  23057. done = _yield$this$_reader$r2.done;
  23058. if (!done) {
  23059. _context2.next = 9;
  23060. break;
  23061. }
  23062. return _context2.abrupt("return", {
  23063. value: value,
  23064. done: done
  23065. });
  23066. case 9:
  23067. this._loaded += value.byteLength;
  23068. if (this.onProgress) {
  23069. this.onProgress({
  23070. loaded: this._loaded
  23071. });
  23072. }
  23073. buffer = new Uint8Array(value).buffer;
  23074. return _context2.abrupt("return", {
  23075. value: buffer,
  23076. done: false
  23077. });
  23078. case 13:
  23079. case "end":
  23080. return _context2.stop();
  23081. }
  23082. }
  23083. }, _callee2, this);
  23084. }));
  23085. function read() {
  23086. return _read2.apply(this, arguments);
  23087. }
  23088. return read;
  23089. }()
  23090. }, {
  23091. key: "cancel",
  23092. value: function cancel(reason) {
  23093. if (this._reader) {
  23094. this._reader.cancel(reason);
  23095. }
  23096. if (this._abortController) {
  23097. this._abortController.abort();
  23098. }
  23099. }
  23100. }, {
  23101. key: "isStreamingSupported",
  23102. get: function get() {
  23103. return this._isStreamingSupported;
  23104. }
  23105. }]);
  23106. return PDFFetchStreamRangeReader;
  23107. }();
  23108. /***/ })
  23109. /******/ ]);
  23110. });
  23111. //# sourceMappingURL=pdf.js.map