2
0

pdf.image_decoders.js 374 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2021 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. (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/image_decoders/pdf.image_decoders", [], factory);
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/image_decoders/pdf.image_decoders"] = factory();
  29. else
  30. root["pdfjs-dist/image_decoders/pdf.image_decoders"] = root.pdfjsImageDecoders = factory();
  31. })(this, function() {
  32. return /******/ (() => { // webpackBootstrap
  33. /******/ var __webpack_modules__ = ([
  34. /* 0 */,
  35. /* 1 */
  36. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  37. "use strict";
  38. Object.defineProperty(exports, "__esModule", ({
  39. value: true
  40. }));
  41. exports.VerbosityLevel = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.UNSUPPORTED_FEATURES = exports.TextRenderingMode = exports.StreamType = exports.RenderingIntentFlag = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.PageActionEventType = exports.OPS = exports.MissingPDFException = exports.IsLittleEndianCached = exports.IsEvalSupportedCached = exports.InvalidPDFException = exports.ImageKind = exports.IDENTITY_MATRIX = exports.FormatError = exports.FontType = exports.FONT_IDENTITY_MATRIX = exports.DocumentActionEventType = exports.CMapCompressionType = exports.BaseException = exports.AnnotationType = exports.AnnotationStateModelType = exports.AnnotationReviewState = exports.AnnotationReplyType = exports.AnnotationMode = exports.AnnotationMarkedState = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.AnnotationActionEventType = exports.AbortException = void 0;
  42. exports.arrayByteLength = arrayByteLength;
  43. exports.arraysToBytes = arraysToBytes;
  44. exports.assert = assert;
  45. exports.bytesToString = bytesToString;
  46. exports.createObjectURL = createObjectURL;
  47. exports.createPromiseCapability = createPromiseCapability;
  48. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  49. exports.escapeString = escapeString;
  50. exports.getModificationDate = getModificationDate;
  51. exports.getVerbosityLevel = getVerbosityLevel;
  52. exports.info = info;
  53. exports.isArrayBuffer = isArrayBuffer;
  54. exports.isArrayEqual = isArrayEqual;
  55. exports.isAscii = isAscii;
  56. exports.isBool = isBool;
  57. exports.isNum = isNum;
  58. exports.isSameOrigin = isSameOrigin;
  59. exports.isString = isString;
  60. exports.objectFromMap = objectFromMap;
  61. exports.objectSize = objectSize;
  62. exports.removeNullCharacters = removeNullCharacters;
  63. exports.setVerbosityLevel = setVerbosityLevel;
  64. exports.shadow = shadow;
  65. exports.string32 = string32;
  66. exports.stringToBytes = stringToBytes;
  67. exports.stringToPDFString = stringToPDFString;
  68. exports.stringToUTF16BEString = stringToUTF16BEString;
  69. exports.stringToUTF8String = stringToUTF8String;
  70. exports.unreachable = unreachable;
  71. exports.utf8StringToString = utf8StringToString;
  72. exports.warn = warn;
  73. __w_pdfjs_require__(2);
  74. 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); } }
  75. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  76. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  77. 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."); }
  78. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
  79. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  80. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  81. 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."); }
  82. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  83. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  84. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  85. 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); }
  86. 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; }
  87. 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); }
  88. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  89. 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); }
  90. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  91. 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); }; }
  92. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  93. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  94. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  95. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  96. var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  97. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  98. var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  99. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  100. var RenderingIntentFlag = {
  101. ANY: 0x01,
  102. DISPLAY: 0x02,
  103. PRINT: 0x04,
  104. ANNOTATIONS_FORMS: 0x10,
  105. ANNOTATIONS_STORAGE: 0x20,
  106. ANNOTATIONS_DISABLE: 0x40,
  107. OPLIST: 0x100
  108. };
  109. exports.RenderingIntentFlag = RenderingIntentFlag;
  110. var AnnotationMode = {
  111. DISABLE: 0,
  112. ENABLE: 1,
  113. ENABLE_FORMS: 2,
  114. ENABLE_STORAGE: 3
  115. };
  116. exports.AnnotationMode = AnnotationMode;
  117. var PermissionFlag = {
  118. PRINT: 0x04,
  119. MODIFY_CONTENTS: 0x08,
  120. COPY: 0x10,
  121. MODIFY_ANNOTATIONS: 0x20,
  122. FILL_INTERACTIVE_FORMS: 0x100,
  123. COPY_FOR_ACCESSIBILITY: 0x200,
  124. ASSEMBLE: 0x400,
  125. PRINT_HIGH_QUALITY: 0x800
  126. };
  127. exports.PermissionFlag = PermissionFlag;
  128. var TextRenderingMode = {
  129. FILL: 0,
  130. STROKE: 1,
  131. FILL_STROKE: 2,
  132. INVISIBLE: 3,
  133. FILL_ADD_TO_PATH: 4,
  134. STROKE_ADD_TO_PATH: 5,
  135. FILL_STROKE_ADD_TO_PATH: 6,
  136. ADD_TO_PATH: 7,
  137. FILL_STROKE_MASK: 3,
  138. ADD_TO_PATH_FLAG: 4
  139. };
  140. exports.TextRenderingMode = TextRenderingMode;
  141. var ImageKind = {
  142. GRAYSCALE_1BPP: 1,
  143. RGB_24BPP: 2,
  144. RGBA_32BPP: 3
  145. };
  146. exports.ImageKind = ImageKind;
  147. var AnnotationType = {
  148. TEXT: 1,
  149. LINK: 2,
  150. FREETEXT: 3,
  151. LINE: 4,
  152. SQUARE: 5,
  153. CIRCLE: 6,
  154. POLYGON: 7,
  155. POLYLINE: 8,
  156. HIGHLIGHT: 9,
  157. UNDERLINE: 10,
  158. SQUIGGLY: 11,
  159. STRIKEOUT: 12,
  160. STAMP: 13,
  161. CARET: 14,
  162. INK: 15,
  163. POPUP: 16,
  164. FILEATTACHMENT: 17,
  165. SOUND: 18,
  166. MOVIE: 19,
  167. WIDGET: 20,
  168. SCREEN: 21,
  169. PRINTERMARK: 22,
  170. TRAPNET: 23,
  171. WATERMARK: 24,
  172. THREED: 25,
  173. REDACT: 26
  174. };
  175. exports.AnnotationType = AnnotationType;
  176. var AnnotationStateModelType = {
  177. MARKED: "Marked",
  178. REVIEW: "Review"
  179. };
  180. exports.AnnotationStateModelType = AnnotationStateModelType;
  181. var AnnotationMarkedState = {
  182. MARKED: "Marked",
  183. UNMARKED: "Unmarked"
  184. };
  185. exports.AnnotationMarkedState = AnnotationMarkedState;
  186. var AnnotationReviewState = {
  187. ACCEPTED: "Accepted",
  188. REJECTED: "Rejected",
  189. CANCELLED: "Cancelled",
  190. COMPLETED: "Completed",
  191. NONE: "None"
  192. };
  193. exports.AnnotationReviewState = AnnotationReviewState;
  194. var AnnotationReplyType = {
  195. GROUP: "Group",
  196. REPLY: "R"
  197. };
  198. exports.AnnotationReplyType = AnnotationReplyType;
  199. var AnnotationFlag = {
  200. INVISIBLE: 0x01,
  201. HIDDEN: 0x02,
  202. PRINT: 0x04,
  203. NOZOOM: 0x08,
  204. NOROTATE: 0x10,
  205. NOVIEW: 0x20,
  206. READONLY: 0x40,
  207. LOCKED: 0x80,
  208. TOGGLENOVIEW: 0x100,
  209. LOCKEDCONTENTS: 0x200
  210. };
  211. exports.AnnotationFlag = AnnotationFlag;
  212. var AnnotationFieldFlag = {
  213. READONLY: 0x0000001,
  214. REQUIRED: 0x0000002,
  215. NOEXPORT: 0x0000004,
  216. MULTILINE: 0x0001000,
  217. PASSWORD: 0x0002000,
  218. NOTOGGLETOOFF: 0x0004000,
  219. RADIO: 0x0008000,
  220. PUSHBUTTON: 0x0010000,
  221. COMBO: 0x0020000,
  222. EDIT: 0x0040000,
  223. SORT: 0x0080000,
  224. FILESELECT: 0x0100000,
  225. MULTISELECT: 0x0200000,
  226. DONOTSPELLCHECK: 0x0400000,
  227. DONOTSCROLL: 0x0800000,
  228. COMB: 0x1000000,
  229. RICHTEXT: 0x2000000,
  230. RADIOSINUNISON: 0x2000000,
  231. COMMITONSELCHANGE: 0x4000000
  232. };
  233. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  234. var AnnotationBorderStyleType = {
  235. SOLID: 1,
  236. DASHED: 2,
  237. BEVELED: 3,
  238. INSET: 4,
  239. UNDERLINE: 5
  240. };
  241. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  242. var AnnotationActionEventType = {
  243. E: "Mouse Enter",
  244. X: "Mouse Exit",
  245. D: "Mouse Down",
  246. U: "Mouse Up",
  247. Fo: "Focus",
  248. Bl: "Blur",
  249. PO: "PageOpen",
  250. PC: "PageClose",
  251. PV: "PageVisible",
  252. PI: "PageInvisible",
  253. K: "Keystroke",
  254. F: "Format",
  255. V: "Validate",
  256. C: "Calculate"
  257. };
  258. exports.AnnotationActionEventType = AnnotationActionEventType;
  259. var DocumentActionEventType = {
  260. WC: "WillClose",
  261. WS: "WillSave",
  262. DS: "DidSave",
  263. WP: "WillPrint",
  264. DP: "DidPrint"
  265. };
  266. exports.DocumentActionEventType = DocumentActionEventType;
  267. var PageActionEventType = {
  268. O: "PageOpen",
  269. C: "PageClose"
  270. };
  271. exports.PageActionEventType = PageActionEventType;
  272. var StreamType = {
  273. UNKNOWN: "UNKNOWN",
  274. FLATE: "FLATE",
  275. LZW: "LZW",
  276. DCT: "DCT",
  277. JPX: "JPX",
  278. JBIG: "JBIG",
  279. A85: "A85",
  280. AHX: "AHX",
  281. CCF: "CCF",
  282. RLX: "RLX"
  283. };
  284. exports.StreamType = StreamType;
  285. var FontType = {
  286. UNKNOWN: "UNKNOWN",
  287. TYPE1: "TYPE1",
  288. TYPE1STANDARD: "TYPE1STANDARD",
  289. TYPE1C: "TYPE1C",
  290. CIDFONTTYPE0: "CIDFONTTYPE0",
  291. CIDFONTTYPE0C: "CIDFONTTYPE0C",
  292. TRUETYPE: "TRUETYPE",
  293. CIDFONTTYPE2: "CIDFONTTYPE2",
  294. TYPE3: "TYPE3",
  295. OPENTYPE: "OPENTYPE",
  296. TYPE0: "TYPE0",
  297. MMTYPE1: "MMTYPE1"
  298. };
  299. exports.FontType = FontType;
  300. var VerbosityLevel = {
  301. ERRORS: 0,
  302. WARNINGS: 1,
  303. INFOS: 5
  304. };
  305. exports.VerbosityLevel = VerbosityLevel;
  306. var CMapCompressionType = {
  307. NONE: 0,
  308. BINARY: 1,
  309. STREAM: 2
  310. };
  311. exports.CMapCompressionType = CMapCompressionType;
  312. var OPS = {
  313. dependency: 1,
  314. setLineWidth: 2,
  315. setLineCap: 3,
  316. setLineJoin: 4,
  317. setMiterLimit: 5,
  318. setDash: 6,
  319. setRenderingIntent: 7,
  320. setFlatness: 8,
  321. setGState: 9,
  322. save: 10,
  323. restore: 11,
  324. transform: 12,
  325. moveTo: 13,
  326. lineTo: 14,
  327. curveTo: 15,
  328. curveTo2: 16,
  329. curveTo3: 17,
  330. closePath: 18,
  331. rectangle: 19,
  332. stroke: 20,
  333. closeStroke: 21,
  334. fill: 22,
  335. eoFill: 23,
  336. fillStroke: 24,
  337. eoFillStroke: 25,
  338. closeFillStroke: 26,
  339. closeEOFillStroke: 27,
  340. endPath: 28,
  341. clip: 29,
  342. eoClip: 30,
  343. beginText: 31,
  344. endText: 32,
  345. setCharSpacing: 33,
  346. setWordSpacing: 34,
  347. setHScale: 35,
  348. setLeading: 36,
  349. setFont: 37,
  350. setTextRenderingMode: 38,
  351. setTextRise: 39,
  352. moveText: 40,
  353. setLeadingMoveText: 41,
  354. setTextMatrix: 42,
  355. nextLine: 43,
  356. showText: 44,
  357. showSpacedText: 45,
  358. nextLineShowText: 46,
  359. nextLineSetSpacingShowText: 47,
  360. setCharWidth: 48,
  361. setCharWidthAndBounds: 49,
  362. setStrokeColorSpace: 50,
  363. setFillColorSpace: 51,
  364. setStrokeColor: 52,
  365. setStrokeColorN: 53,
  366. setFillColor: 54,
  367. setFillColorN: 55,
  368. setStrokeGray: 56,
  369. setFillGray: 57,
  370. setStrokeRGBColor: 58,
  371. setFillRGBColor: 59,
  372. setStrokeCMYKColor: 60,
  373. setFillCMYKColor: 61,
  374. shadingFill: 62,
  375. beginInlineImage: 63,
  376. beginImageData: 64,
  377. endInlineImage: 65,
  378. paintXObject: 66,
  379. markPoint: 67,
  380. markPointProps: 68,
  381. beginMarkedContent: 69,
  382. beginMarkedContentProps: 70,
  383. endMarkedContent: 71,
  384. beginCompat: 72,
  385. endCompat: 73,
  386. paintFormXObjectBegin: 74,
  387. paintFormXObjectEnd: 75,
  388. beginGroup: 76,
  389. endGroup: 77,
  390. beginAnnotations: 78,
  391. endAnnotations: 79,
  392. beginAnnotation: 80,
  393. endAnnotation: 81,
  394. paintJpegXObject: 82,
  395. paintImageMaskXObject: 83,
  396. paintImageMaskXObjectGroup: 84,
  397. paintImageXObject: 85,
  398. paintInlineImageXObject: 86,
  399. paintInlineImageXObjectGroup: 87,
  400. paintImageXObjectRepeat: 88,
  401. paintImageMaskXObjectRepeat: 89,
  402. paintSolidColorImageMask: 90,
  403. constructPath: 91
  404. };
  405. exports.OPS = OPS;
  406. var UNSUPPORTED_FEATURES = {
  407. unknown: "unknown",
  408. forms: "forms",
  409. javaScript: "javaScript",
  410. signatures: "signatures",
  411. smask: "smask",
  412. shadingPattern: "shadingPattern",
  413. font: "font",
  414. errorTilingPattern: "errorTilingPattern",
  415. errorExtGState: "errorExtGState",
  416. errorXObject: "errorXObject",
  417. errorFontLoadType3: "errorFontLoadType3",
  418. errorFontState: "errorFontState",
  419. errorFontMissing: "errorFontMissing",
  420. errorFontTranslate: "errorFontTranslate",
  421. errorColorSpace: "errorColorSpace",
  422. errorOperatorList: "errorOperatorList",
  423. errorFontToUnicode: "errorFontToUnicode",
  424. errorFontLoadNative: "errorFontLoadNative",
  425. errorFontBuildPath: "errorFontBuildPath",
  426. errorFontGetPath: "errorFontGetPath",
  427. errorMarkedContent: "errorMarkedContent",
  428. errorContentSubStream: "errorContentSubStream"
  429. };
  430. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  431. var PasswordResponses = {
  432. NEED_PASSWORD: 1,
  433. INCORRECT_PASSWORD: 2
  434. };
  435. exports.PasswordResponses = PasswordResponses;
  436. var verbosity = VerbosityLevel.WARNINGS;
  437. function setVerbosityLevel(level) {
  438. if (Number.isInteger(level)) {
  439. verbosity = level;
  440. }
  441. }
  442. function getVerbosityLevel() {
  443. return verbosity;
  444. }
  445. function info(msg) {
  446. if (verbosity >= VerbosityLevel.INFOS) {
  447. console.log("Info: ".concat(msg));
  448. }
  449. }
  450. function warn(msg) {
  451. if (verbosity >= VerbosityLevel.WARNINGS) {
  452. console.log("Warning: ".concat(msg));
  453. }
  454. }
  455. function unreachable(msg) {
  456. throw new Error(msg);
  457. }
  458. function assert(cond, msg) {
  459. if (!cond) {
  460. unreachable(msg);
  461. }
  462. }
  463. function isSameOrigin(baseUrl, otherUrl) {
  464. var base;
  465. try {
  466. base = new URL(baseUrl);
  467. if (!base.origin || base.origin === "null") {
  468. return false;
  469. }
  470. } catch (e) {
  471. return false;
  472. }
  473. var other = new URL(otherUrl, base);
  474. return base.origin === other.origin;
  475. }
  476. function _isValidProtocol(url) {
  477. if (!url) {
  478. return false;
  479. }
  480. switch (url.protocol) {
  481. case "http:":
  482. case "https:":
  483. case "ftp:":
  484. case "mailto:":
  485. case "tel:":
  486. return true;
  487. default:
  488. return false;
  489. }
  490. }
  491. function createValidAbsoluteUrl(url) {
  492. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  493. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  494. if (!url) {
  495. return null;
  496. }
  497. try {
  498. if (options && typeof url === "string") {
  499. if (options.addDefaultProtocol && url.startsWith("www.")) {
  500. var dots = url.match(/\./g);
  501. if (dots && dots.length >= 2) {
  502. url = "http://".concat(url);
  503. }
  504. }
  505. if (options.tryConvertEncoding) {
  506. try {
  507. url = stringToUTF8String(url);
  508. } catch (ex) {}
  509. }
  510. }
  511. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  512. if (_isValidProtocol(absoluteUrl)) {
  513. return absoluteUrl;
  514. }
  515. } catch (ex) {}
  516. return null;
  517. }
  518. function shadow(obj, prop, value) {
  519. Object.defineProperty(obj, prop, {
  520. value: value,
  521. enumerable: true,
  522. configurable: true,
  523. writable: false
  524. });
  525. return value;
  526. }
  527. var BaseException = function BaseExceptionClosure() {
  528. function BaseException(message, name) {
  529. if (this.constructor === BaseException) {
  530. unreachable("Cannot initialize BaseException.");
  531. }
  532. this.message = message;
  533. this.name = name;
  534. }
  535. BaseException.prototype = new Error();
  536. BaseException.constructor = BaseException;
  537. return BaseException;
  538. }();
  539. exports.BaseException = BaseException;
  540. var PasswordException = /*#__PURE__*/function (_BaseException) {
  541. _inherits(PasswordException, _BaseException);
  542. var _super = _createSuper(PasswordException);
  543. function PasswordException(msg, code) {
  544. var _this;
  545. _classCallCheck(this, PasswordException);
  546. _this = _super.call(this, msg, "PasswordException");
  547. _this.code = code;
  548. return _this;
  549. }
  550. return PasswordException;
  551. }(BaseException);
  552. exports.PasswordException = PasswordException;
  553. var UnknownErrorException = /*#__PURE__*/function (_BaseException2) {
  554. _inherits(UnknownErrorException, _BaseException2);
  555. var _super2 = _createSuper(UnknownErrorException);
  556. function UnknownErrorException(msg, details) {
  557. var _this2;
  558. _classCallCheck(this, UnknownErrorException);
  559. _this2 = _super2.call(this, msg, "UnknownErrorException");
  560. _this2.details = details;
  561. return _this2;
  562. }
  563. return UnknownErrorException;
  564. }(BaseException);
  565. exports.UnknownErrorException = UnknownErrorException;
  566. var InvalidPDFException = /*#__PURE__*/function (_BaseException3) {
  567. _inherits(InvalidPDFException, _BaseException3);
  568. var _super3 = _createSuper(InvalidPDFException);
  569. function InvalidPDFException(msg) {
  570. _classCallCheck(this, InvalidPDFException);
  571. return _super3.call(this, msg, "InvalidPDFException");
  572. }
  573. return InvalidPDFException;
  574. }(BaseException);
  575. exports.InvalidPDFException = InvalidPDFException;
  576. var MissingPDFException = /*#__PURE__*/function (_BaseException4) {
  577. _inherits(MissingPDFException, _BaseException4);
  578. var _super4 = _createSuper(MissingPDFException);
  579. function MissingPDFException(msg) {
  580. _classCallCheck(this, MissingPDFException);
  581. return _super4.call(this, msg, "MissingPDFException");
  582. }
  583. return MissingPDFException;
  584. }(BaseException);
  585. exports.MissingPDFException = MissingPDFException;
  586. var UnexpectedResponseException = /*#__PURE__*/function (_BaseException5) {
  587. _inherits(UnexpectedResponseException, _BaseException5);
  588. var _super5 = _createSuper(UnexpectedResponseException);
  589. function UnexpectedResponseException(msg, status) {
  590. var _this3;
  591. _classCallCheck(this, UnexpectedResponseException);
  592. _this3 = _super5.call(this, msg, "UnexpectedResponseException");
  593. _this3.status = status;
  594. return _this3;
  595. }
  596. return UnexpectedResponseException;
  597. }(BaseException);
  598. exports.UnexpectedResponseException = UnexpectedResponseException;
  599. var FormatError = /*#__PURE__*/function (_BaseException6) {
  600. _inherits(FormatError, _BaseException6);
  601. var _super6 = _createSuper(FormatError);
  602. function FormatError(msg) {
  603. _classCallCheck(this, FormatError);
  604. return _super6.call(this, msg, "FormatError");
  605. }
  606. return FormatError;
  607. }(BaseException);
  608. exports.FormatError = FormatError;
  609. var AbortException = /*#__PURE__*/function (_BaseException7) {
  610. _inherits(AbortException, _BaseException7);
  611. var _super7 = _createSuper(AbortException);
  612. function AbortException(msg) {
  613. _classCallCheck(this, AbortException);
  614. return _super7.call(this, msg, "AbortException");
  615. }
  616. return AbortException;
  617. }(BaseException);
  618. exports.AbortException = AbortException;
  619. var NullCharactersRegExp = /\x00+/g;
  620. var InvisibleCharactersRegExp = /[\x01-\x1F]/g;
  621. function removeNullCharacters(str) {
  622. var replaceInvisible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  623. if (typeof str !== "string") {
  624. warn("The argument for removeNullCharacters must be a string.");
  625. return str;
  626. }
  627. if (replaceInvisible) {
  628. str = str.replace(InvisibleCharactersRegExp, " ");
  629. }
  630. return str.replace(NullCharactersRegExp, "");
  631. }
  632. function bytesToString(bytes) {
  633. assert(bytes !== null && _typeof(bytes) === "object" && bytes.length !== undefined, "Invalid argument for bytesToString");
  634. var length = bytes.length;
  635. var MAX_ARGUMENT_COUNT = 8192;
  636. if (length < MAX_ARGUMENT_COUNT) {
  637. return String.fromCharCode.apply(null, bytes);
  638. }
  639. var strBuf = [];
  640. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  641. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  642. var chunk = bytes.subarray(i, chunkEnd);
  643. strBuf.push(String.fromCharCode.apply(null, chunk));
  644. }
  645. return strBuf.join("");
  646. }
  647. function stringToBytes(str) {
  648. assert(typeof str === "string", "Invalid argument for stringToBytes");
  649. var length = str.length;
  650. var bytes = new Uint8Array(length);
  651. for (var i = 0; i < length; ++i) {
  652. bytes[i] = str.charCodeAt(i) & 0xff;
  653. }
  654. return bytes;
  655. }
  656. function arrayByteLength(arr) {
  657. if (arr.length !== undefined) {
  658. return arr.length;
  659. }
  660. assert(arr.byteLength !== undefined, "arrayByteLength - invalid argument.");
  661. return arr.byteLength;
  662. }
  663. function arraysToBytes(arr) {
  664. var length = arr.length;
  665. if (length === 1 && arr[0] instanceof Uint8Array) {
  666. return arr[0];
  667. }
  668. var resultLength = 0;
  669. for (var i = 0; i < length; i++) {
  670. resultLength += arrayByteLength(arr[i]);
  671. }
  672. var pos = 0;
  673. var data = new Uint8Array(resultLength);
  674. for (var _i = 0; _i < length; _i++) {
  675. var item = arr[_i];
  676. if (!(item instanceof Uint8Array)) {
  677. if (typeof item === "string") {
  678. item = stringToBytes(item);
  679. } else {
  680. item = new Uint8Array(item);
  681. }
  682. }
  683. var itemLength = item.byteLength;
  684. data.set(item, pos);
  685. pos += itemLength;
  686. }
  687. return data;
  688. }
  689. function string32(value) {
  690. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  691. }
  692. function objectSize(obj) {
  693. return Object.keys(obj).length;
  694. }
  695. function objectFromMap(map) {
  696. var obj = Object.create(null);
  697. var _iterator = _createForOfIteratorHelper(map),
  698. _step;
  699. try {
  700. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  701. var _step$value = _slicedToArray(_step.value, 2),
  702. key = _step$value[0],
  703. value = _step$value[1];
  704. obj[key] = value;
  705. }
  706. } catch (err) {
  707. _iterator.e(err);
  708. } finally {
  709. _iterator.f();
  710. }
  711. return obj;
  712. }
  713. function isLittleEndian() {
  714. var buffer8 = new Uint8Array(4);
  715. buffer8[0] = 1;
  716. var view32 = new Uint32Array(buffer8.buffer, 0, 1);
  717. return view32[0] === 1;
  718. }
  719. var IsLittleEndianCached = {
  720. get value() {
  721. return shadow(this, "value", isLittleEndian());
  722. }
  723. };
  724. exports.IsLittleEndianCached = IsLittleEndianCached;
  725. function isEvalSupported() {
  726. try {
  727. new Function("");
  728. return true;
  729. } catch (e) {
  730. return false;
  731. }
  732. }
  733. var IsEvalSupportedCached = {
  734. get value() {
  735. return shadow(this, "value", isEvalSupported());
  736. }
  737. };
  738. exports.IsEvalSupportedCached = IsEvalSupportedCached;
  739. var hexNumbers = _toConsumableArray(Array(256).keys()).map(function (n) {
  740. return n.toString(16).padStart(2, "0");
  741. });
  742. var Util = /*#__PURE__*/function () {
  743. function Util() {
  744. _classCallCheck(this, Util);
  745. }
  746. _createClass(Util, null, [{
  747. key: "makeHexColor",
  748. value: function makeHexColor(r, g, b) {
  749. return "#".concat(hexNumbers[r]).concat(hexNumbers[g]).concat(hexNumbers[b]);
  750. }
  751. }, {
  752. key: "transform",
  753. value: function transform(m1, m2) {
  754. 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]];
  755. }
  756. }, {
  757. key: "applyTransform",
  758. value: function applyTransform(p, m) {
  759. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  760. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  761. return [xt, yt];
  762. }
  763. }, {
  764. key: "applyInverseTransform",
  765. value: function applyInverseTransform(p, m) {
  766. var d = m[0] * m[3] - m[1] * m[2];
  767. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  768. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  769. return [xt, yt];
  770. }
  771. }, {
  772. key: "getAxialAlignedBoundingBox",
  773. value: function getAxialAlignedBoundingBox(r, m) {
  774. var p1 = Util.applyTransform(r, m);
  775. var p2 = Util.applyTransform(r.slice(2, 4), m);
  776. var p3 = Util.applyTransform([r[0], r[3]], m);
  777. var p4 = Util.applyTransform([r[2], r[1]], m);
  778. 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])];
  779. }
  780. }, {
  781. key: "inverseTransform",
  782. value: function inverseTransform(m) {
  783. var d = m[0] * m[3] - m[1] * m[2];
  784. return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
  785. }
  786. }, {
  787. key: "apply3dTransform",
  788. value: function apply3dTransform(m, v) {
  789. 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]];
  790. }
  791. }, {
  792. key: "singularValueDecompose2dScale",
  793. value: function singularValueDecompose2dScale(m) {
  794. var transpose = [m[0], m[2], m[1], m[3]];
  795. var a = m[0] * transpose[0] + m[1] * transpose[2];
  796. var b = m[0] * transpose[1] + m[1] * transpose[3];
  797. var c = m[2] * transpose[0] + m[3] * transpose[2];
  798. var d = m[2] * transpose[1] + m[3] * transpose[3];
  799. var first = (a + d) / 2;
  800. var second = Math.sqrt(Math.pow(a + d, 2) - 4 * (a * d - c * b)) / 2;
  801. var sx = first + second || 1;
  802. var sy = first - second || 1;
  803. return [Math.sqrt(sx), Math.sqrt(sy)];
  804. }
  805. }, {
  806. key: "normalizeRect",
  807. value: function normalizeRect(rect) {
  808. var r = rect.slice(0);
  809. if (rect[0] > rect[2]) {
  810. r[0] = rect[2];
  811. r[2] = rect[0];
  812. }
  813. if (rect[1] > rect[3]) {
  814. r[1] = rect[3];
  815. r[3] = rect[1];
  816. }
  817. return r;
  818. }
  819. }, {
  820. key: "intersect",
  821. value: function intersect(rect1, rect2) {
  822. function compare(a, b) {
  823. return a - b;
  824. }
  825. var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare);
  826. var orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare);
  827. var result = [];
  828. rect1 = Util.normalizeRect(rect1);
  829. rect2 = Util.normalizeRect(rect2);
  830. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  831. result[0] = orderedX[1];
  832. result[2] = orderedX[2];
  833. } else {
  834. return null;
  835. }
  836. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  837. result[1] = orderedY[1];
  838. result[3] = orderedY[2];
  839. } else {
  840. return null;
  841. }
  842. return result;
  843. }
  844. }, {
  845. key: "bezierBoundingBox",
  846. value: function bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3) {
  847. var tvalues = [],
  848. bounds = [[], []];
  849. var a, b, c, t, t1, t2, b2ac, sqrtb2ac;
  850. for (var i = 0; i < 2; ++i) {
  851. if (i === 0) {
  852. b = 6 * x0 - 12 * x1 + 6 * x2;
  853. a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;
  854. c = 3 * x1 - 3 * x0;
  855. } else {
  856. b = 6 * y0 - 12 * y1 + 6 * y2;
  857. a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;
  858. c = 3 * y1 - 3 * y0;
  859. }
  860. if (Math.abs(a) < 1e-12) {
  861. if (Math.abs(b) < 1e-12) {
  862. continue;
  863. }
  864. t = -c / b;
  865. if (0 < t && t < 1) {
  866. tvalues.push(t);
  867. }
  868. continue;
  869. }
  870. b2ac = b * b - 4 * c * a;
  871. sqrtb2ac = Math.sqrt(b2ac);
  872. if (b2ac < 0) {
  873. continue;
  874. }
  875. t1 = (-b + sqrtb2ac) / (2 * a);
  876. if (0 < t1 && t1 < 1) {
  877. tvalues.push(t1);
  878. }
  879. t2 = (-b - sqrtb2ac) / (2 * a);
  880. if (0 < t2 && t2 < 1) {
  881. tvalues.push(t2);
  882. }
  883. }
  884. var j = tvalues.length,
  885. mt;
  886. var jlen = j;
  887. while (j--) {
  888. t = tvalues[j];
  889. mt = 1 - t;
  890. bounds[0][j] = mt * mt * mt * x0 + 3 * mt * mt * t * x1 + 3 * mt * t * t * x2 + t * t * t * x3;
  891. bounds[1][j] = mt * mt * mt * y0 + 3 * mt * mt * t * y1 + 3 * mt * t * t * y2 + t * t * t * y3;
  892. }
  893. bounds[0][jlen] = x0;
  894. bounds[1][jlen] = y0;
  895. bounds[0][jlen + 1] = x3;
  896. bounds[1][jlen + 1] = y3;
  897. bounds[0].length = bounds[1].length = jlen + 2;
  898. return [Math.min.apply(Math, _toConsumableArray(bounds[0])), Math.min.apply(Math, _toConsumableArray(bounds[1])), Math.max.apply(Math, _toConsumableArray(bounds[0])), Math.max.apply(Math, _toConsumableArray(bounds[1]))];
  899. }
  900. }]);
  901. return Util;
  902. }();
  903. exports.Util = Util;
  904. 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];
  905. function stringToPDFString(str) {
  906. var length = str.length,
  907. strBuf = [];
  908. if (str[0] === "\xFE" && str[1] === "\xFF") {
  909. for (var i = 2; i < length; i += 2) {
  910. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  911. }
  912. } else if (str[0] === "\xFF" && str[1] === "\xFE") {
  913. for (var _i2 = 2; _i2 < length; _i2 += 2) {
  914. strBuf.push(String.fromCharCode(str.charCodeAt(_i2 + 1) << 8 | str.charCodeAt(_i2)));
  915. }
  916. } else {
  917. for (var _i3 = 0; _i3 < length; ++_i3) {
  918. var code = PDFStringTranslateTable[str.charCodeAt(_i3)];
  919. strBuf.push(code ? String.fromCharCode(code) : str.charAt(_i3));
  920. }
  921. }
  922. return strBuf.join("");
  923. }
  924. function escapeString(str) {
  925. return str.replace(/([()\\\n\r])/g, function (match) {
  926. if (match === "\n") {
  927. return "\\n";
  928. } else if (match === "\r") {
  929. return "\\r";
  930. }
  931. return "\\".concat(match);
  932. });
  933. }
  934. function isAscii(str) {
  935. return /^[\x00-\x7F]*$/.test(str);
  936. }
  937. function stringToUTF16BEString(str) {
  938. var buf = ["\xFE\xFF"];
  939. for (var i = 0, ii = str.length; i < ii; i++) {
  940. var _char = str.charCodeAt(i);
  941. buf.push(String.fromCharCode(_char >> 8 & 0xff), String.fromCharCode(_char & 0xff));
  942. }
  943. return buf.join("");
  944. }
  945. function stringToUTF8String(str) {
  946. return decodeURIComponent(escape(str));
  947. }
  948. function utf8StringToString(str) {
  949. return unescape(encodeURIComponent(str));
  950. }
  951. function isBool(v) {
  952. return typeof v === "boolean";
  953. }
  954. function isNum(v) {
  955. return typeof v === "number";
  956. }
  957. function isString(v) {
  958. return typeof v === "string";
  959. }
  960. function isArrayBuffer(v) {
  961. return _typeof(v) === "object" && v !== null && v.byteLength !== undefined;
  962. }
  963. function isArrayEqual(arr1, arr2) {
  964. if (arr1.length !== arr2.length) {
  965. return false;
  966. }
  967. for (var i = 0, ii = arr1.length; i < ii; i++) {
  968. if (arr1[i] !== arr2[i]) {
  969. return false;
  970. }
  971. }
  972. return true;
  973. }
  974. function getModificationDate() {
  975. var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
  976. var buffer = [date.getUTCFullYear().toString(), (date.getUTCMonth() + 1).toString().padStart(2, "0"), date.getUTCDate().toString().padStart(2, "0"), date.getUTCHours().toString().padStart(2, "0"), date.getUTCMinutes().toString().padStart(2, "0"), date.getUTCSeconds().toString().padStart(2, "0")];
  977. return buffer.join("");
  978. }
  979. function createPromiseCapability() {
  980. var capability = Object.create(null);
  981. var isSettled = false;
  982. Object.defineProperty(capability, "settled", {
  983. get: function get() {
  984. return isSettled;
  985. }
  986. });
  987. capability.promise = new Promise(function (resolve, reject) {
  988. capability.resolve = function (data) {
  989. isSettled = true;
  990. resolve(data);
  991. };
  992. capability.reject = function (reason) {
  993. isSettled = true;
  994. reject(reason);
  995. };
  996. });
  997. return capability;
  998. }
  999. function createObjectURL(data) {
  1000. var contentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
  1001. var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  1002. if (URL.createObjectURL && typeof Blob !== "undefined" && !forceDataSchema) {
  1003. return URL.createObjectURL(new Blob([data], {
  1004. type: contentType
  1005. }));
  1006. }
  1007. var digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  1008. var buffer = "data:".concat(contentType, ";base64,");
  1009. for (var i = 0, ii = data.length; i < ii; i += 3) {
  1010. var b1 = data[i] & 0xff;
  1011. var b2 = data[i + 1] & 0xff;
  1012. var b3 = data[i + 2] & 0xff;
  1013. var d1 = b1 >> 2,
  1014. d2 = (b1 & 3) << 4 | b2 >> 4;
  1015. var d3 = i + 1 < ii ? (b2 & 0xf) << 2 | b3 >> 6 : 64;
  1016. var d4 = i + 2 < ii ? b3 & 0x3f : 64;
  1017. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  1018. }
  1019. return buffer;
  1020. }
  1021. /***/ }),
  1022. /* 2 */
  1023. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1024. "use strict";
  1025. var _is_node = __w_pdfjs_require__(3);
  1026. if (typeof globalThis === "undefined" || !globalThis._pdfjsCompatibilityChecked) {
  1027. if (typeof globalThis === "undefined" || globalThis.Math !== Math) {
  1028. globalThis = __w_pdfjs_require__(4);
  1029. }
  1030. globalThis._pdfjsCompatibilityChecked = true;
  1031. (function checkNodeBtoa() {
  1032. if (globalThis.btoa || !_is_node.isNodeJS) {
  1033. return;
  1034. }
  1035. globalThis.btoa = function (chars) {
  1036. return Buffer.from(chars, "binary").toString("base64");
  1037. };
  1038. })();
  1039. (function checkNodeAtob() {
  1040. if (globalThis.atob || !_is_node.isNodeJS) {
  1041. return;
  1042. }
  1043. globalThis.atob = function (input) {
  1044. return Buffer.from(input, "base64").toString("binary");
  1045. };
  1046. })();
  1047. (function checkDOMMatrix() {
  1048. if (globalThis.DOMMatrix || !_is_node.isNodeJS) {
  1049. return;
  1050. }
  1051. globalThis.DOMMatrix = __w_pdfjs_require__(66);
  1052. })();
  1053. (function checkObjectFromEntries() {
  1054. if (Object.fromEntries) {
  1055. return;
  1056. }
  1057. __w_pdfjs_require__(67);
  1058. })();
  1059. (function checkPromise() {})();
  1060. (function checkReadableStream() {})();
  1061. }
  1062. /***/ }),
  1063. /* 3 */
  1064. /***/ ((__unused_webpack_module, exports) => {
  1065. "use strict";
  1066. Object.defineProperty(exports, "__esModule", ({
  1067. value: true
  1068. }));
  1069. exports.isNodeJS = void 0;
  1070. 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); }
  1071. var isNodeJS = (typeof process === "undefined" ? "undefined" : _typeof(process)) === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
  1072. exports.isNodeJS = isNodeJS;
  1073. /***/ }),
  1074. /* 4 */
  1075. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1076. __w_pdfjs_require__(5);
  1077. module.exports = __w_pdfjs_require__(7);
  1078. /***/ }),
  1079. /* 5 */
  1080. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1081. var $ = __w_pdfjs_require__(6);
  1082. var global = __w_pdfjs_require__(7);
  1083. $({ global: true }, { globalThis: global });
  1084. /***/ }),
  1085. /* 6 */
  1086. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1087. var global = __w_pdfjs_require__(7);
  1088. var getOwnPropertyDescriptor = (__w_pdfjs_require__(8).f);
  1089. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  1090. var redefine = __w_pdfjs_require__(47);
  1091. var setGlobal = __w_pdfjs_require__(38);
  1092. var copyConstructorProperties = __w_pdfjs_require__(54);
  1093. var isForced = __w_pdfjs_require__(65);
  1094. module.exports = function (options, source) {
  1095. var TARGET = options.target;
  1096. var GLOBAL = options.global;
  1097. var STATIC = options.stat;
  1098. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  1099. if (GLOBAL) {
  1100. target = global;
  1101. } else if (STATIC) {
  1102. target = global[TARGET] || setGlobal(TARGET, {});
  1103. } else {
  1104. target = (global[TARGET] || {}).prototype;
  1105. }
  1106. if (target)
  1107. for (key in source) {
  1108. sourceProperty = source[key];
  1109. if (options.noTargetGet) {
  1110. descriptor = getOwnPropertyDescriptor(target, key);
  1111. targetProperty = descriptor && descriptor.value;
  1112. } else
  1113. targetProperty = target[key];
  1114. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  1115. if (!FORCED && targetProperty !== undefined) {
  1116. if (typeof sourceProperty == typeof targetProperty)
  1117. continue;
  1118. copyConstructorProperties(sourceProperty, targetProperty);
  1119. }
  1120. if (options.sham || targetProperty && targetProperty.sham) {
  1121. createNonEnumerableProperty(sourceProperty, 'sham', true);
  1122. }
  1123. redefine(target, key, sourceProperty, options);
  1124. }
  1125. };
  1126. /***/ }),
  1127. /* 7 */
  1128. /***/ ((module) => {
  1129. var check = function (it) {
  1130. return it && it.Math == Math && it;
  1131. };
  1132. module.exports = check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || check(typeof self == 'object' && self) || check(typeof global == 'object' && global) || (function () {
  1133. return this;
  1134. }()) || Function('return this')();
  1135. /***/ }),
  1136. /* 8 */
  1137. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1138. var DESCRIPTORS = __w_pdfjs_require__(9);
  1139. var call = __w_pdfjs_require__(11);
  1140. var propertyIsEnumerableModule = __w_pdfjs_require__(12);
  1141. var createPropertyDescriptor = __w_pdfjs_require__(13);
  1142. var toIndexedObject = __w_pdfjs_require__(14);
  1143. var toPropertyKey = __w_pdfjs_require__(19);
  1144. var hasOwn = __w_pdfjs_require__(39);
  1145. var IE8_DOM_DEFINE = __w_pdfjs_require__(42);
  1146. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  1147. exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  1148. O = toIndexedObject(O);
  1149. P = toPropertyKey(P);
  1150. if (IE8_DOM_DEFINE)
  1151. try {
  1152. return $getOwnPropertyDescriptor(O, P);
  1153. } catch (error) {
  1154. }
  1155. if (hasOwn(O, P))
  1156. return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
  1157. };
  1158. /***/ }),
  1159. /* 9 */
  1160. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1161. var fails = __w_pdfjs_require__(10);
  1162. module.exports = !fails(function () {
  1163. return Object.defineProperty({}, 1, {
  1164. get: function () {
  1165. return 7;
  1166. }
  1167. })[1] != 7;
  1168. });
  1169. /***/ }),
  1170. /* 10 */
  1171. /***/ ((module) => {
  1172. module.exports = function (exec) {
  1173. try {
  1174. return !!exec();
  1175. } catch (error) {
  1176. return true;
  1177. }
  1178. };
  1179. /***/ }),
  1180. /* 11 */
  1181. /***/ ((module) => {
  1182. var call = Function.prototype.call;
  1183. module.exports = call.bind ? call.bind(call) : function () {
  1184. return call.apply(call, arguments);
  1185. };
  1186. /***/ }),
  1187. /* 12 */
  1188. /***/ ((__unused_webpack_module, exports) => {
  1189. "use strict";
  1190. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  1191. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  1192. var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  1193. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  1194. var descriptor = getOwnPropertyDescriptor(this, V);
  1195. return !!descriptor && descriptor.enumerable;
  1196. } : $propertyIsEnumerable;
  1197. /***/ }),
  1198. /* 13 */
  1199. /***/ ((module) => {
  1200. module.exports = function (bitmap, value) {
  1201. return {
  1202. enumerable: !(bitmap & 1),
  1203. configurable: !(bitmap & 2),
  1204. writable: !(bitmap & 4),
  1205. value: value
  1206. };
  1207. };
  1208. /***/ }),
  1209. /* 14 */
  1210. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1211. var IndexedObject = __w_pdfjs_require__(15);
  1212. var requireObjectCoercible = __w_pdfjs_require__(18);
  1213. module.exports = function (it) {
  1214. return IndexedObject(requireObjectCoercible(it));
  1215. };
  1216. /***/ }),
  1217. /* 15 */
  1218. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1219. var global = __w_pdfjs_require__(7);
  1220. var uncurryThis = __w_pdfjs_require__(16);
  1221. var fails = __w_pdfjs_require__(10);
  1222. var classof = __w_pdfjs_require__(17);
  1223. var Object = global.Object;
  1224. var split = uncurryThis(''.split);
  1225. module.exports = fails(function () {
  1226. return !Object('z').propertyIsEnumerable(0);
  1227. }) ? function (it) {
  1228. return classof(it) == 'String' ? split(it, '') : Object(it);
  1229. } : Object;
  1230. /***/ }),
  1231. /* 16 */
  1232. /***/ ((module) => {
  1233. var FunctionPrototype = Function.prototype;
  1234. var bind = FunctionPrototype.bind;
  1235. var call = FunctionPrototype.call;
  1236. var callBind = bind && bind.bind(call);
  1237. module.exports = bind ? function (fn) {
  1238. return fn && callBind(call, fn);
  1239. } : function (fn) {
  1240. return fn && function () {
  1241. return call.apply(fn, arguments);
  1242. };
  1243. };
  1244. /***/ }),
  1245. /* 17 */
  1246. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1247. var uncurryThis = __w_pdfjs_require__(16);
  1248. var toString = uncurryThis({}.toString);
  1249. var stringSlice = uncurryThis(''.slice);
  1250. module.exports = function (it) {
  1251. return stringSlice(toString(it), 8, -1);
  1252. };
  1253. /***/ }),
  1254. /* 18 */
  1255. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1256. var global = __w_pdfjs_require__(7);
  1257. var TypeError = global.TypeError;
  1258. module.exports = function (it) {
  1259. if (it == undefined)
  1260. throw TypeError("Can't call method on " + it);
  1261. return it;
  1262. };
  1263. /***/ }),
  1264. /* 19 */
  1265. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1266. var toPrimitive = __w_pdfjs_require__(20);
  1267. var isSymbol = __w_pdfjs_require__(23);
  1268. module.exports = function (argument) {
  1269. var key = toPrimitive(argument, 'string');
  1270. return isSymbol(key) ? key : key + '';
  1271. };
  1272. /***/ }),
  1273. /* 20 */
  1274. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1275. var global = __w_pdfjs_require__(7);
  1276. var call = __w_pdfjs_require__(11);
  1277. var isObject = __w_pdfjs_require__(21);
  1278. var isSymbol = __w_pdfjs_require__(23);
  1279. var getMethod = __w_pdfjs_require__(30);
  1280. var ordinaryToPrimitive = __w_pdfjs_require__(33);
  1281. var wellKnownSymbol = __w_pdfjs_require__(34);
  1282. var TypeError = global.TypeError;
  1283. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  1284. module.exports = function (input, pref) {
  1285. if (!isObject(input) || isSymbol(input))
  1286. return input;
  1287. var exoticToPrim = getMethod(input, TO_PRIMITIVE);
  1288. var result;
  1289. if (exoticToPrim) {
  1290. if (pref === undefined)
  1291. pref = 'default';
  1292. result = call(exoticToPrim, input, pref);
  1293. if (!isObject(result) || isSymbol(result))
  1294. return result;
  1295. throw TypeError("Can't convert object to primitive value");
  1296. }
  1297. if (pref === undefined)
  1298. pref = 'number';
  1299. return ordinaryToPrimitive(input, pref);
  1300. };
  1301. /***/ }),
  1302. /* 21 */
  1303. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1304. var isCallable = __w_pdfjs_require__(22);
  1305. module.exports = function (it) {
  1306. return typeof it == 'object' ? it !== null : isCallable(it);
  1307. };
  1308. /***/ }),
  1309. /* 22 */
  1310. /***/ ((module) => {
  1311. module.exports = function (argument) {
  1312. return typeof argument == 'function';
  1313. };
  1314. /***/ }),
  1315. /* 23 */
  1316. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1317. var global = __w_pdfjs_require__(7);
  1318. var getBuiltIn = __w_pdfjs_require__(24);
  1319. var isCallable = __w_pdfjs_require__(22);
  1320. var isPrototypeOf = __w_pdfjs_require__(25);
  1321. var USE_SYMBOL_AS_UID = __w_pdfjs_require__(26);
  1322. var Object = global.Object;
  1323. module.exports = USE_SYMBOL_AS_UID ? function (it) {
  1324. return typeof it == 'symbol';
  1325. } : function (it) {
  1326. var $Symbol = getBuiltIn('Symbol');
  1327. return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, Object(it));
  1328. };
  1329. /***/ }),
  1330. /* 24 */
  1331. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1332. var global = __w_pdfjs_require__(7);
  1333. var isCallable = __w_pdfjs_require__(22);
  1334. var aFunction = function (argument) {
  1335. return isCallable(argument) ? argument : undefined;
  1336. };
  1337. module.exports = function (namespace, method) {
  1338. return arguments.length < 2 ? aFunction(global[namespace]) : global[namespace] && global[namespace][method];
  1339. };
  1340. /***/ }),
  1341. /* 25 */
  1342. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1343. var uncurryThis = __w_pdfjs_require__(16);
  1344. module.exports = uncurryThis({}.isPrototypeOf);
  1345. /***/ }),
  1346. /* 26 */
  1347. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1348. var NATIVE_SYMBOL = __w_pdfjs_require__(27);
  1349. module.exports = NATIVE_SYMBOL && !Symbol.sham && typeof Symbol.iterator == 'symbol';
  1350. /***/ }),
  1351. /* 27 */
  1352. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1353. var V8_VERSION = __w_pdfjs_require__(28);
  1354. var fails = __w_pdfjs_require__(10);
  1355. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  1356. var symbol = Symbol();
  1357. return !String(symbol) || !(Object(symbol) instanceof Symbol) || !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  1358. });
  1359. /***/ }),
  1360. /* 28 */
  1361. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1362. var global = __w_pdfjs_require__(7);
  1363. var userAgent = __w_pdfjs_require__(29);
  1364. var process = global.process;
  1365. var Deno = global.Deno;
  1366. var versions = process && process.versions || Deno && Deno.version;
  1367. var v8 = versions && versions.v8;
  1368. var match, version;
  1369. if (v8) {
  1370. match = v8.split('.');
  1371. version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
  1372. }
  1373. if (!version && userAgent) {
  1374. match = userAgent.match(/Edge\/(\d+)/);
  1375. if (!match || match[1] >= 74) {
  1376. match = userAgent.match(/Chrome\/(\d+)/);
  1377. if (match)
  1378. version = +match[1];
  1379. }
  1380. }
  1381. module.exports = version;
  1382. /***/ }),
  1383. /* 29 */
  1384. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1385. var getBuiltIn = __w_pdfjs_require__(24);
  1386. module.exports = getBuiltIn('navigator', 'userAgent') || '';
  1387. /***/ }),
  1388. /* 30 */
  1389. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1390. var aCallable = __w_pdfjs_require__(31);
  1391. module.exports = function (V, P) {
  1392. var func = V[P];
  1393. return func == null ? undefined : aCallable(func);
  1394. };
  1395. /***/ }),
  1396. /* 31 */
  1397. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1398. var global = __w_pdfjs_require__(7);
  1399. var isCallable = __w_pdfjs_require__(22);
  1400. var tryToString = __w_pdfjs_require__(32);
  1401. var TypeError = global.TypeError;
  1402. module.exports = function (argument) {
  1403. if (isCallable(argument))
  1404. return argument;
  1405. throw TypeError(tryToString(argument) + ' is not a function');
  1406. };
  1407. /***/ }),
  1408. /* 32 */
  1409. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1410. var global = __w_pdfjs_require__(7);
  1411. var String = global.String;
  1412. module.exports = function (argument) {
  1413. try {
  1414. return String(argument);
  1415. } catch (error) {
  1416. return 'Object';
  1417. }
  1418. };
  1419. /***/ }),
  1420. /* 33 */
  1421. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1422. var global = __w_pdfjs_require__(7);
  1423. var call = __w_pdfjs_require__(11);
  1424. var isCallable = __w_pdfjs_require__(22);
  1425. var isObject = __w_pdfjs_require__(21);
  1426. var TypeError = global.TypeError;
  1427. module.exports = function (input, pref) {
  1428. var fn, val;
  1429. if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input)))
  1430. return val;
  1431. if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input)))
  1432. return val;
  1433. if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input)))
  1434. return val;
  1435. throw TypeError("Can't convert object to primitive value");
  1436. };
  1437. /***/ }),
  1438. /* 34 */
  1439. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1440. var global = __w_pdfjs_require__(7);
  1441. var shared = __w_pdfjs_require__(35);
  1442. var hasOwn = __w_pdfjs_require__(39);
  1443. var uid = __w_pdfjs_require__(41);
  1444. var NATIVE_SYMBOL = __w_pdfjs_require__(27);
  1445. var USE_SYMBOL_AS_UID = __w_pdfjs_require__(26);
  1446. var WellKnownSymbolsStore = shared('wks');
  1447. var Symbol = global.Symbol;
  1448. var symbolFor = Symbol && Symbol['for'];
  1449. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;
  1450. module.exports = function (name) {
  1451. if (!hasOwn(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
  1452. var description = 'Symbol.' + name;
  1453. if (NATIVE_SYMBOL && hasOwn(Symbol, name)) {
  1454. WellKnownSymbolsStore[name] = Symbol[name];
  1455. } else if (USE_SYMBOL_AS_UID && symbolFor) {
  1456. WellKnownSymbolsStore[name] = symbolFor(description);
  1457. } else {
  1458. WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
  1459. }
  1460. }
  1461. return WellKnownSymbolsStore[name];
  1462. };
  1463. /***/ }),
  1464. /* 35 */
  1465. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1466. var IS_PURE = __w_pdfjs_require__(36);
  1467. var store = __w_pdfjs_require__(37);
  1468. (module.exports = function (key, value) {
  1469. return store[key] || (store[key] = value !== undefined ? value : {});
  1470. })('versions', []).push({
  1471. version: '3.19.3',
  1472. mode: IS_PURE ? 'pure' : 'global',
  1473. copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
  1474. });
  1475. /***/ }),
  1476. /* 36 */
  1477. /***/ ((module) => {
  1478. module.exports = false;
  1479. /***/ }),
  1480. /* 37 */
  1481. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1482. var global = __w_pdfjs_require__(7);
  1483. var setGlobal = __w_pdfjs_require__(38);
  1484. var SHARED = '__core-js_shared__';
  1485. var store = global[SHARED] || setGlobal(SHARED, {});
  1486. module.exports = store;
  1487. /***/ }),
  1488. /* 38 */
  1489. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1490. var global = __w_pdfjs_require__(7);
  1491. var defineProperty = Object.defineProperty;
  1492. module.exports = function (key, value) {
  1493. try {
  1494. defineProperty(global, key, {
  1495. value: value,
  1496. configurable: true,
  1497. writable: true
  1498. });
  1499. } catch (error) {
  1500. global[key] = value;
  1501. }
  1502. return value;
  1503. };
  1504. /***/ }),
  1505. /* 39 */
  1506. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1507. var uncurryThis = __w_pdfjs_require__(16);
  1508. var toObject = __w_pdfjs_require__(40);
  1509. var hasOwnProperty = uncurryThis({}.hasOwnProperty);
  1510. module.exports = Object.hasOwn || function hasOwn(it, key) {
  1511. return hasOwnProperty(toObject(it), key);
  1512. };
  1513. /***/ }),
  1514. /* 40 */
  1515. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1516. var global = __w_pdfjs_require__(7);
  1517. var requireObjectCoercible = __w_pdfjs_require__(18);
  1518. var Object = global.Object;
  1519. module.exports = function (argument) {
  1520. return Object(requireObjectCoercible(argument));
  1521. };
  1522. /***/ }),
  1523. /* 41 */
  1524. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1525. var uncurryThis = __w_pdfjs_require__(16);
  1526. var id = 0;
  1527. var postfix = Math.random();
  1528. var toString = uncurryThis(1.0.toString);
  1529. module.exports = function (key) {
  1530. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
  1531. };
  1532. /***/ }),
  1533. /* 42 */
  1534. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1535. var DESCRIPTORS = __w_pdfjs_require__(9);
  1536. var fails = __w_pdfjs_require__(10);
  1537. var createElement = __w_pdfjs_require__(43);
  1538. module.exports = !DESCRIPTORS && !fails(function () {
  1539. return Object.defineProperty(createElement('div'), 'a', {
  1540. get: function () {
  1541. return 7;
  1542. }
  1543. }).a != 7;
  1544. });
  1545. /***/ }),
  1546. /* 43 */
  1547. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1548. var global = __w_pdfjs_require__(7);
  1549. var isObject = __w_pdfjs_require__(21);
  1550. var document = global.document;
  1551. var EXISTS = isObject(document) && isObject(document.createElement);
  1552. module.exports = function (it) {
  1553. return EXISTS ? document.createElement(it) : {};
  1554. };
  1555. /***/ }),
  1556. /* 44 */
  1557. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1558. var DESCRIPTORS = __w_pdfjs_require__(9);
  1559. var definePropertyModule = __w_pdfjs_require__(45);
  1560. var createPropertyDescriptor = __w_pdfjs_require__(13);
  1561. module.exports = DESCRIPTORS ? function (object, key, value) {
  1562. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  1563. } : function (object, key, value) {
  1564. object[key] = value;
  1565. return object;
  1566. };
  1567. /***/ }),
  1568. /* 45 */
  1569. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1570. var global = __w_pdfjs_require__(7);
  1571. var DESCRIPTORS = __w_pdfjs_require__(9);
  1572. var IE8_DOM_DEFINE = __w_pdfjs_require__(42);
  1573. var anObject = __w_pdfjs_require__(46);
  1574. var toPropertyKey = __w_pdfjs_require__(19);
  1575. var TypeError = global.TypeError;
  1576. var $defineProperty = Object.defineProperty;
  1577. exports.f = DESCRIPTORS ? $defineProperty : function defineProperty(O, P, Attributes) {
  1578. anObject(O);
  1579. P = toPropertyKey(P);
  1580. anObject(Attributes);
  1581. if (IE8_DOM_DEFINE)
  1582. try {
  1583. return $defineProperty(O, P, Attributes);
  1584. } catch (error) {
  1585. }
  1586. if ('get' in Attributes || 'set' in Attributes)
  1587. throw TypeError('Accessors not supported');
  1588. if ('value' in Attributes)
  1589. O[P] = Attributes.value;
  1590. return O;
  1591. };
  1592. /***/ }),
  1593. /* 46 */
  1594. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1595. var global = __w_pdfjs_require__(7);
  1596. var isObject = __w_pdfjs_require__(21);
  1597. var String = global.String;
  1598. var TypeError = global.TypeError;
  1599. module.exports = function (argument) {
  1600. if (isObject(argument))
  1601. return argument;
  1602. throw TypeError(String(argument) + ' is not an object');
  1603. };
  1604. /***/ }),
  1605. /* 47 */
  1606. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1607. var global = __w_pdfjs_require__(7);
  1608. var isCallable = __w_pdfjs_require__(22);
  1609. var hasOwn = __w_pdfjs_require__(39);
  1610. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  1611. var setGlobal = __w_pdfjs_require__(38);
  1612. var inspectSource = __w_pdfjs_require__(48);
  1613. var InternalStateModule = __w_pdfjs_require__(49);
  1614. var CONFIGURABLE_FUNCTION_NAME = (__w_pdfjs_require__(53).CONFIGURABLE);
  1615. var getInternalState = InternalStateModule.get;
  1616. var enforceInternalState = InternalStateModule.enforce;
  1617. var TEMPLATE = String(String).split('String');
  1618. (module.exports = function (O, key, value, options) {
  1619. var unsafe = options ? !!options.unsafe : false;
  1620. var simple = options ? !!options.enumerable : false;
  1621. var noTargetGet = options ? !!options.noTargetGet : false;
  1622. var name = options && options.name !== undefined ? options.name : key;
  1623. var state;
  1624. if (isCallable(value)) {
  1625. if (String(name).slice(0, 7) === 'Symbol(') {
  1626. name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
  1627. }
  1628. if (!hasOwn(value, 'name') || CONFIGURABLE_FUNCTION_NAME && value.name !== name) {
  1629. createNonEnumerableProperty(value, 'name', name);
  1630. }
  1631. state = enforceInternalState(value);
  1632. if (!state.source) {
  1633. state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
  1634. }
  1635. }
  1636. if (O === global) {
  1637. if (simple)
  1638. O[key] = value;
  1639. else
  1640. setGlobal(key, value);
  1641. return;
  1642. } else if (!unsafe) {
  1643. delete O[key];
  1644. } else if (!noTargetGet && O[key]) {
  1645. simple = true;
  1646. }
  1647. if (simple)
  1648. O[key] = value;
  1649. else
  1650. createNonEnumerableProperty(O, key, value);
  1651. })(Function.prototype, 'toString', function toString() {
  1652. return isCallable(this) && getInternalState(this).source || inspectSource(this);
  1653. });
  1654. /***/ }),
  1655. /* 48 */
  1656. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1657. var uncurryThis = __w_pdfjs_require__(16);
  1658. var isCallable = __w_pdfjs_require__(22);
  1659. var store = __w_pdfjs_require__(37);
  1660. var functionToString = uncurryThis(Function.toString);
  1661. if (!isCallable(store.inspectSource)) {
  1662. store.inspectSource = function (it) {
  1663. return functionToString(it);
  1664. };
  1665. }
  1666. module.exports = store.inspectSource;
  1667. /***/ }),
  1668. /* 49 */
  1669. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1670. var NATIVE_WEAK_MAP = __w_pdfjs_require__(50);
  1671. var global = __w_pdfjs_require__(7);
  1672. var uncurryThis = __w_pdfjs_require__(16);
  1673. var isObject = __w_pdfjs_require__(21);
  1674. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  1675. var hasOwn = __w_pdfjs_require__(39);
  1676. var shared = __w_pdfjs_require__(37);
  1677. var sharedKey = __w_pdfjs_require__(51);
  1678. var hiddenKeys = __w_pdfjs_require__(52);
  1679. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  1680. var TypeError = global.TypeError;
  1681. var WeakMap = global.WeakMap;
  1682. var set, get, has;
  1683. var enforce = function (it) {
  1684. return has(it) ? get(it) : set(it, {});
  1685. };
  1686. var getterFor = function (TYPE) {
  1687. return function (it) {
  1688. var state;
  1689. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  1690. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  1691. }
  1692. return state;
  1693. };
  1694. };
  1695. if (NATIVE_WEAK_MAP || shared.state) {
  1696. var store = shared.state || (shared.state = new WeakMap());
  1697. var wmget = uncurryThis(store.get);
  1698. var wmhas = uncurryThis(store.has);
  1699. var wmset = uncurryThis(store.set);
  1700. set = function (it, metadata) {
  1701. if (wmhas(store, it))
  1702. throw new TypeError(OBJECT_ALREADY_INITIALIZED);
  1703. metadata.facade = it;
  1704. wmset(store, it, metadata);
  1705. return metadata;
  1706. };
  1707. get = function (it) {
  1708. return wmget(store, it) || {};
  1709. };
  1710. has = function (it) {
  1711. return wmhas(store, it);
  1712. };
  1713. } else {
  1714. var STATE = sharedKey('state');
  1715. hiddenKeys[STATE] = true;
  1716. set = function (it, metadata) {
  1717. if (hasOwn(it, STATE))
  1718. throw new TypeError(OBJECT_ALREADY_INITIALIZED);
  1719. metadata.facade = it;
  1720. createNonEnumerableProperty(it, STATE, metadata);
  1721. return metadata;
  1722. };
  1723. get = function (it) {
  1724. return hasOwn(it, STATE) ? it[STATE] : {};
  1725. };
  1726. has = function (it) {
  1727. return hasOwn(it, STATE);
  1728. };
  1729. }
  1730. module.exports = {
  1731. set: set,
  1732. get: get,
  1733. has: has,
  1734. enforce: enforce,
  1735. getterFor: getterFor
  1736. };
  1737. /***/ }),
  1738. /* 50 */
  1739. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1740. var global = __w_pdfjs_require__(7);
  1741. var isCallable = __w_pdfjs_require__(22);
  1742. var inspectSource = __w_pdfjs_require__(48);
  1743. var WeakMap = global.WeakMap;
  1744. module.exports = isCallable(WeakMap) && /native code/.test(inspectSource(WeakMap));
  1745. /***/ }),
  1746. /* 51 */
  1747. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1748. var shared = __w_pdfjs_require__(35);
  1749. var uid = __w_pdfjs_require__(41);
  1750. var keys = shared('keys');
  1751. module.exports = function (key) {
  1752. return keys[key] || (keys[key] = uid(key));
  1753. };
  1754. /***/ }),
  1755. /* 52 */
  1756. /***/ ((module) => {
  1757. module.exports = {};
  1758. /***/ }),
  1759. /* 53 */
  1760. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1761. var DESCRIPTORS = __w_pdfjs_require__(9);
  1762. var hasOwn = __w_pdfjs_require__(39);
  1763. var FunctionPrototype = Function.prototype;
  1764. var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
  1765. var EXISTS = hasOwn(FunctionPrototype, 'name');
  1766. var PROPER = EXISTS && function something() {
  1767. }.name === 'something';
  1768. var CONFIGURABLE = EXISTS && (!DESCRIPTORS || DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable);
  1769. module.exports = {
  1770. EXISTS: EXISTS,
  1771. PROPER: PROPER,
  1772. CONFIGURABLE: CONFIGURABLE
  1773. };
  1774. /***/ }),
  1775. /* 54 */
  1776. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1777. var hasOwn = __w_pdfjs_require__(39);
  1778. var ownKeys = __w_pdfjs_require__(55);
  1779. var getOwnPropertyDescriptorModule = __w_pdfjs_require__(8);
  1780. var definePropertyModule = __w_pdfjs_require__(45);
  1781. module.exports = function (target, source) {
  1782. var keys = ownKeys(source);
  1783. var defineProperty = definePropertyModule.f;
  1784. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  1785. for (var i = 0; i < keys.length; i++) {
  1786. var key = keys[i];
  1787. if (!hasOwn(target, key))
  1788. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  1789. }
  1790. };
  1791. /***/ }),
  1792. /* 55 */
  1793. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1794. var getBuiltIn = __w_pdfjs_require__(24);
  1795. var uncurryThis = __w_pdfjs_require__(16);
  1796. var getOwnPropertyNamesModule = __w_pdfjs_require__(56);
  1797. var getOwnPropertySymbolsModule = __w_pdfjs_require__(64);
  1798. var anObject = __w_pdfjs_require__(46);
  1799. var concat = uncurryThis([].concat);
  1800. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  1801. var keys = getOwnPropertyNamesModule.f(anObject(it));
  1802. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  1803. return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
  1804. };
  1805. /***/ }),
  1806. /* 56 */
  1807. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1808. var internalObjectKeys = __w_pdfjs_require__(57);
  1809. var enumBugKeys = __w_pdfjs_require__(63);
  1810. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  1811. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  1812. return internalObjectKeys(O, hiddenKeys);
  1813. };
  1814. /***/ }),
  1815. /* 57 */
  1816. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1817. var uncurryThis = __w_pdfjs_require__(16);
  1818. var hasOwn = __w_pdfjs_require__(39);
  1819. var toIndexedObject = __w_pdfjs_require__(14);
  1820. var indexOf = (__w_pdfjs_require__(58).indexOf);
  1821. var hiddenKeys = __w_pdfjs_require__(52);
  1822. var push = uncurryThis([].push);
  1823. module.exports = function (object, names) {
  1824. var O = toIndexedObject(object);
  1825. var i = 0;
  1826. var result = [];
  1827. var key;
  1828. for (key in O)
  1829. !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
  1830. while (names.length > i)
  1831. if (hasOwn(O, key = names[i++])) {
  1832. ~indexOf(result, key) || push(result, key);
  1833. }
  1834. return result;
  1835. };
  1836. /***/ }),
  1837. /* 58 */
  1838. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1839. var toIndexedObject = __w_pdfjs_require__(14);
  1840. var toAbsoluteIndex = __w_pdfjs_require__(59);
  1841. var lengthOfArrayLike = __w_pdfjs_require__(61);
  1842. var createMethod = function (IS_INCLUDES) {
  1843. return function ($this, el, fromIndex) {
  1844. var O = toIndexedObject($this);
  1845. var length = lengthOfArrayLike(O);
  1846. var index = toAbsoluteIndex(fromIndex, length);
  1847. var value;
  1848. if (IS_INCLUDES && el != el)
  1849. while (length > index) {
  1850. value = O[index++];
  1851. if (value != value)
  1852. return true;
  1853. }
  1854. else
  1855. for (; length > index; index++) {
  1856. if ((IS_INCLUDES || index in O) && O[index] === el)
  1857. return IS_INCLUDES || index || 0;
  1858. }
  1859. return !IS_INCLUDES && -1;
  1860. };
  1861. };
  1862. module.exports = {
  1863. includes: createMethod(true),
  1864. indexOf: createMethod(false)
  1865. };
  1866. /***/ }),
  1867. /* 59 */
  1868. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1869. var toIntegerOrInfinity = __w_pdfjs_require__(60);
  1870. var max = Math.max;
  1871. var min = Math.min;
  1872. module.exports = function (index, length) {
  1873. var integer = toIntegerOrInfinity(index);
  1874. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  1875. };
  1876. /***/ }),
  1877. /* 60 */
  1878. /***/ ((module) => {
  1879. var ceil = Math.ceil;
  1880. var floor = Math.floor;
  1881. module.exports = function (argument) {
  1882. var number = +argument;
  1883. return number !== number || number === 0 ? 0 : (number > 0 ? floor : ceil)(number);
  1884. };
  1885. /***/ }),
  1886. /* 61 */
  1887. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1888. var toLength = __w_pdfjs_require__(62);
  1889. module.exports = function (obj) {
  1890. return toLength(obj.length);
  1891. };
  1892. /***/ }),
  1893. /* 62 */
  1894. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1895. var toIntegerOrInfinity = __w_pdfjs_require__(60);
  1896. var min = Math.min;
  1897. module.exports = function (argument) {
  1898. return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0;
  1899. };
  1900. /***/ }),
  1901. /* 63 */
  1902. /***/ ((module) => {
  1903. module.exports = [
  1904. 'constructor',
  1905. 'hasOwnProperty',
  1906. 'isPrototypeOf',
  1907. 'propertyIsEnumerable',
  1908. 'toLocaleString',
  1909. 'toString',
  1910. 'valueOf'
  1911. ];
  1912. /***/ }),
  1913. /* 64 */
  1914. /***/ ((__unused_webpack_module, exports) => {
  1915. exports.f = Object.getOwnPropertySymbols;
  1916. /***/ }),
  1917. /* 65 */
  1918. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1919. var fails = __w_pdfjs_require__(10);
  1920. var isCallable = __w_pdfjs_require__(22);
  1921. var replacement = /#|\.prototype\./;
  1922. var isForced = function (feature, detection) {
  1923. var value = data[normalize(feature)];
  1924. return value == POLYFILL ? true : value == NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection;
  1925. };
  1926. var normalize = isForced.normalize = function (string) {
  1927. return String(string).replace(replacement, '.').toLowerCase();
  1928. };
  1929. var data = isForced.data = {};
  1930. var NATIVE = isForced.NATIVE = 'N';
  1931. var POLYFILL = isForced.POLYFILL = 'P';
  1932. module.exports = isForced;
  1933. /***/ }),
  1934. /* 66 */
  1935. /***/ ((module, exports, __w_pdfjs_require__) => {
  1936. "use strict";
  1937. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;
  1938. 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); }
  1939. (function (global, factory) {
  1940. ( false ? 0 : _typeof(exports)) === 'object' && "object" !== 'undefined' ? module.exports = factory() : true ? !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  1941. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  1942. (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __w_pdfjs_require__, exports, module)) :
  1943. __WEBPACK_AMD_DEFINE_FACTORY__),
  1944. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : (0);
  1945. })(void 0, function () {
  1946. 'use strict';
  1947. function fromArray(array) {
  1948. var m = new CSSMatrix();
  1949. var a = Array.from(array);
  1950. if (!a.every(function (n) {
  1951. return !Number.isNaN(n);
  1952. })) {
  1953. throw TypeError("CSSMatrix: \"" + array + "\" must only have numbers.");
  1954. }
  1955. if (a.length === 16) {
  1956. var m11 = a[0];
  1957. var m12 = a[1];
  1958. var m13 = a[2];
  1959. var m14 = a[3];
  1960. var m21 = a[4];
  1961. var m22 = a[5];
  1962. var m23 = a[6];
  1963. var m24 = a[7];
  1964. var m31 = a[8];
  1965. var m32 = a[9];
  1966. var m33 = a[10];
  1967. var m34 = a[11];
  1968. var m41 = a[12];
  1969. var m42 = a[13];
  1970. var m43 = a[14];
  1971. var m44 = a[15];
  1972. m.m11 = m11;
  1973. m.a = m11;
  1974. m.m21 = m21;
  1975. m.c = m21;
  1976. m.m31 = m31;
  1977. m.m41 = m41;
  1978. m.e = m41;
  1979. m.m12 = m12;
  1980. m.b = m12;
  1981. m.m22 = m22;
  1982. m.d = m22;
  1983. m.m32 = m32;
  1984. m.m42 = m42;
  1985. m.f = m42;
  1986. m.m13 = m13;
  1987. m.m23 = m23;
  1988. m.m33 = m33;
  1989. m.m43 = m43;
  1990. m.m14 = m14;
  1991. m.m24 = m24;
  1992. m.m34 = m34;
  1993. m.m44 = m44;
  1994. } else if (a.length === 6) {
  1995. var M11 = a[0];
  1996. var M12 = a[1];
  1997. var M21 = a[2];
  1998. var M22 = a[3];
  1999. var M41 = a[4];
  2000. var M42 = a[5];
  2001. m.m11 = M11;
  2002. m.a = M11;
  2003. m.m12 = M12;
  2004. m.b = M12;
  2005. m.m21 = M21;
  2006. m.c = M21;
  2007. m.m22 = M22;
  2008. m.d = M22;
  2009. m.m41 = M41;
  2010. m.e = M41;
  2011. m.m42 = M42;
  2012. m.f = M42;
  2013. } else {
  2014. throw new TypeError('CSSMatrix: expecting an Array of 6/16 values.');
  2015. }
  2016. return m;
  2017. }
  2018. function fromMatrix(m) {
  2019. var keys = Object.keys(new CSSMatrix());
  2020. if (_typeof(m) === 'object' && keys.every(function (k) {
  2021. return k in m;
  2022. })) {
  2023. return fromArray([m.m11, m.m12, m.m13, m.m14, m.m21, m.m22, m.m23, m.m24, m.m31, m.m32, m.m33, m.m34, m.m41, m.m42, m.m43, m.m44]);
  2024. }
  2025. throw TypeError("CSSMatrix: \"" + m + "\" is not a DOMMatrix / CSSMatrix / JSON compatible object.");
  2026. }
  2027. function fromString(source) {
  2028. if (typeof source !== 'string') {
  2029. throw TypeError("CSSMatrix: \"" + source + "\" is not a string.");
  2030. }
  2031. var str = String(source).replace(/\s/g, '');
  2032. var m = new CSSMatrix();
  2033. var invalidStringError = "CSSMatrix: invalid transform string \"" + source + "\"";
  2034. str.split(')').filter(function (f) {
  2035. return f;
  2036. }).forEach(function (tf) {
  2037. var ref = tf.split('(');
  2038. var prop = ref[0];
  2039. var value = ref[1];
  2040. if (!value) {
  2041. throw TypeError(invalidStringError);
  2042. }
  2043. var components = value.split(',').map(function (n) {
  2044. return n.includes('rad') ? parseFloat(n) * (180 / Math.PI) : parseFloat(n);
  2045. });
  2046. var x = components[0];
  2047. var y = components[1];
  2048. var z = components[2];
  2049. var a = components[3];
  2050. var xyz = [x, y, z];
  2051. var xyza = [x, y, z, a];
  2052. if (prop === 'perspective' && x && [y, z].every(function (n) {
  2053. return n === undefined;
  2054. })) {
  2055. m.m34 = -1 / x;
  2056. } else if (prop.includes('matrix') && [6, 16].includes(components.length) && components.every(function (n) {
  2057. return !Number.isNaN(+n);
  2058. })) {
  2059. var values = components.map(function (n) {
  2060. return Math.abs(n) < 1e-6 ? 0 : n;
  2061. });
  2062. m = m.multiply(fromArray(values));
  2063. } else if (prop === 'translate3d' && xyz.every(function (n) {
  2064. return !Number.isNaN(+n);
  2065. })) {
  2066. m = m.translate(x, y, z);
  2067. } else if (prop === 'translate' && x && z === undefined) {
  2068. m = m.translate(x, y || 0, 0);
  2069. } else if (prop === 'rotate3d' && xyza.every(function (n) {
  2070. return !Number.isNaN(+n);
  2071. }) && a) {
  2072. m = m.rotateAxisAngle(x, y, z, a);
  2073. } else if (prop === 'rotate' && x && [y, z].every(function (n) {
  2074. return n === undefined;
  2075. })) {
  2076. m = m.rotate(0, 0, x);
  2077. } else if (prop === 'scale3d' && xyz.every(function (n) {
  2078. return !Number.isNaN(+n);
  2079. }) && xyz.some(function (n) {
  2080. return n !== 1;
  2081. })) {
  2082. m = m.scale(x, y, z);
  2083. } else if (prop === 'scale' && !Number.isNaN(x) && x !== 1 && z === undefined) {
  2084. var nosy = Number.isNaN(+y);
  2085. var sy = nosy ? x : y;
  2086. m = m.scale(x, sy, 1);
  2087. } else if (prop === 'skew' && x && z === undefined) {
  2088. m = m.skewX(x);
  2089. m = y ? m.skewY(y) : m;
  2090. } else if (/[XYZ]/.test(prop) && x && [y, z].every(function (n) {
  2091. return n === undefined;
  2092. }) && ['translate', 'rotate', 'scale', 'skew'].some(function (p) {
  2093. return prop.includes(p);
  2094. })) {
  2095. if (['skewX', 'skewY'].includes(prop)) {
  2096. m = m[prop](x);
  2097. } else {
  2098. var fn = prop.replace(/[XYZ]/, '');
  2099. var axis = prop.replace(fn, '');
  2100. var idx = ['X', 'Y', 'Z'].indexOf(axis);
  2101. var axeValues = [idx === 0 ? x : 0, idx === 1 ? x : 0, idx === 2 ? x : 0];
  2102. m = m[fn].apply(m, axeValues);
  2103. }
  2104. } else {
  2105. throw TypeError(invalidStringError);
  2106. }
  2107. });
  2108. return m;
  2109. }
  2110. function Translate(x, y, z) {
  2111. var m = new CSSMatrix();
  2112. m.m41 = x;
  2113. m.e = x;
  2114. m.m42 = y;
  2115. m.f = y;
  2116. m.m43 = z;
  2117. return m;
  2118. }
  2119. function Rotate(rx, ry, rz) {
  2120. var m = new CSSMatrix();
  2121. var degToRad = Math.PI / 180;
  2122. var radX = rx * degToRad;
  2123. var radY = ry * degToRad;
  2124. var radZ = rz * degToRad;
  2125. var cosx = Math.cos(radX);
  2126. var sinx = -Math.sin(radX);
  2127. var cosy = Math.cos(radY);
  2128. var siny = -Math.sin(radY);
  2129. var cosz = Math.cos(radZ);
  2130. var sinz = -Math.sin(radZ);
  2131. var m11 = cosy * cosz;
  2132. var m12 = -cosy * sinz;
  2133. m.m11 = m11;
  2134. m.a = m11;
  2135. m.m12 = m12;
  2136. m.b = m12;
  2137. m.m13 = siny;
  2138. var m21 = sinx * siny * cosz + cosx * sinz;
  2139. m.m21 = m21;
  2140. m.c = m21;
  2141. var m22 = cosx * cosz - sinx * siny * sinz;
  2142. m.m22 = m22;
  2143. m.d = m22;
  2144. m.m23 = -sinx * cosy;
  2145. m.m31 = sinx * sinz - cosx * siny * cosz;
  2146. m.m32 = sinx * cosz + cosx * siny * sinz;
  2147. m.m33 = cosx * cosy;
  2148. return m;
  2149. }
  2150. function RotateAxisAngle(x, y, z, alpha) {
  2151. var m = new CSSMatrix();
  2152. var angle = alpha * (Math.PI / 360);
  2153. var sinA = Math.sin(angle);
  2154. var cosA = Math.cos(angle);
  2155. var sinA2 = sinA * sinA;
  2156. var length = Math.sqrt(x * x + y * y + z * z);
  2157. var X = x;
  2158. var Y = y;
  2159. var Z = z;
  2160. if (length === 0) {
  2161. X = 0;
  2162. Y = 0;
  2163. Z = 1;
  2164. } else {
  2165. X /= length;
  2166. Y /= length;
  2167. Z /= length;
  2168. }
  2169. var x2 = X * X;
  2170. var y2 = Y * Y;
  2171. var z2 = Z * Z;
  2172. var m11 = 1 - 2 * (y2 + z2) * sinA2;
  2173. m.m11 = m11;
  2174. m.a = m11;
  2175. var m12 = 2 * (X * Y * sinA2 + Z * sinA * cosA);
  2176. m.m12 = m12;
  2177. m.b = m12;
  2178. m.m13 = 2 * (X * Z * sinA2 - Y * sinA * cosA);
  2179. var m21 = 2 * (Y * X * sinA2 - Z * sinA * cosA);
  2180. m.m21 = m21;
  2181. m.c = m21;
  2182. var m22 = 1 - 2 * (z2 + x2) * sinA2;
  2183. m.m22 = m22;
  2184. m.d = m22;
  2185. m.m23 = 2 * (Y * Z * sinA2 + X * sinA * cosA);
  2186. m.m31 = 2 * (Z * X * sinA2 + Y * sinA * cosA);
  2187. m.m32 = 2 * (Z * Y * sinA2 - X * sinA * cosA);
  2188. m.m33 = 1 - 2 * (x2 + y2) * sinA2;
  2189. return m;
  2190. }
  2191. function Scale(x, y, z) {
  2192. var m = new CSSMatrix();
  2193. m.m11 = x;
  2194. m.a = x;
  2195. m.m22 = y;
  2196. m.d = y;
  2197. m.m33 = z;
  2198. return m;
  2199. }
  2200. function SkewX(angle) {
  2201. var m = new CSSMatrix();
  2202. var radA = angle * Math.PI / 180;
  2203. var t = Math.tan(radA);
  2204. m.m21 = t;
  2205. m.c = t;
  2206. return m;
  2207. }
  2208. function SkewY(angle) {
  2209. var m = new CSSMatrix();
  2210. var radA = angle * Math.PI / 180;
  2211. var t = Math.tan(radA);
  2212. m.m12 = t;
  2213. m.b = t;
  2214. return m;
  2215. }
  2216. function Multiply(m1, m2) {
  2217. var m11 = m2.m11 * m1.m11 + m2.m12 * m1.m21 + m2.m13 * m1.m31 + m2.m14 * m1.m41;
  2218. var m12 = m2.m11 * m1.m12 + m2.m12 * m1.m22 + m2.m13 * m1.m32 + m2.m14 * m1.m42;
  2219. var m13 = m2.m11 * m1.m13 + m2.m12 * m1.m23 + m2.m13 * m1.m33 + m2.m14 * m1.m43;
  2220. var m14 = m2.m11 * m1.m14 + m2.m12 * m1.m24 + m2.m13 * m1.m34 + m2.m14 * m1.m44;
  2221. var m21 = m2.m21 * m1.m11 + m2.m22 * m1.m21 + m2.m23 * m1.m31 + m2.m24 * m1.m41;
  2222. var m22 = m2.m21 * m1.m12 + m2.m22 * m1.m22 + m2.m23 * m1.m32 + m2.m24 * m1.m42;
  2223. var m23 = m2.m21 * m1.m13 + m2.m22 * m1.m23 + m2.m23 * m1.m33 + m2.m24 * m1.m43;
  2224. var m24 = m2.m21 * m1.m14 + m2.m22 * m1.m24 + m2.m23 * m1.m34 + m2.m24 * m1.m44;
  2225. var m31 = m2.m31 * m1.m11 + m2.m32 * m1.m21 + m2.m33 * m1.m31 + m2.m34 * m1.m41;
  2226. var m32 = m2.m31 * m1.m12 + m2.m32 * m1.m22 + m2.m33 * m1.m32 + m2.m34 * m1.m42;
  2227. var m33 = m2.m31 * m1.m13 + m2.m32 * m1.m23 + m2.m33 * m1.m33 + m2.m34 * m1.m43;
  2228. var m34 = m2.m31 * m1.m14 + m2.m32 * m1.m24 + m2.m33 * m1.m34 + m2.m34 * m1.m44;
  2229. var m41 = m2.m41 * m1.m11 + m2.m42 * m1.m21 + m2.m43 * m1.m31 + m2.m44 * m1.m41;
  2230. var m42 = m2.m41 * m1.m12 + m2.m42 * m1.m22 + m2.m43 * m1.m32 + m2.m44 * m1.m42;
  2231. var m43 = m2.m41 * m1.m13 + m2.m42 * m1.m23 + m2.m43 * m1.m33 + m2.m44 * m1.m43;
  2232. var m44 = m2.m41 * m1.m14 + m2.m42 * m1.m24 + m2.m43 * m1.m34 + m2.m44 * m1.m44;
  2233. return fromArray([m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44]);
  2234. }
  2235. var CSSMatrix = function CSSMatrix() {
  2236. var args = [],
  2237. len = arguments.length;
  2238. while (len--) {
  2239. args[len] = arguments[len];
  2240. }
  2241. var m = this;
  2242. m.a = 1;
  2243. m.b = 0;
  2244. m.c = 0;
  2245. m.d = 1;
  2246. m.e = 0;
  2247. m.f = 0;
  2248. m.m11 = 1;
  2249. m.m12 = 0;
  2250. m.m13 = 0;
  2251. m.m14 = 0;
  2252. m.m21 = 0;
  2253. m.m22 = 1;
  2254. m.m23 = 0;
  2255. m.m24 = 0;
  2256. m.m31 = 0;
  2257. m.m32 = 0;
  2258. m.m33 = 1;
  2259. m.m34 = 0;
  2260. m.m41 = 0;
  2261. m.m42 = 0;
  2262. m.m43 = 0;
  2263. m.m44 = 1;
  2264. if (args && args.length) {
  2265. var ARGS = [16, 6].some(function (l) {
  2266. return l === args.length;
  2267. }) ? args : args[0];
  2268. return m.setMatrixValue(ARGS);
  2269. }
  2270. return m;
  2271. };
  2272. var prototypeAccessors = {
  2273. isIdentity: {
  2274. configurable: true
  2275. },
  2276. is2D: {
  2277. configurable: true
  2278. }
  2279. };
  2280. prototypeAccessors.isIdentity.set = function (value) {
  2281. this.isIdentity = value;
  2282. };
  2283. prototypeAccessors.isIdentity.get = function () {
  2284. var m = this;
  2285. return m.m11 === 1 && m.m12 === 0 && m.m13 === 0 && m.m14 === 0 && m.m21 === 0 && m.m22 === 1 && m.m23 === 0 && m.m24 === 0 && m.m31 === 0 && m.m32 === 0 && m.m33 === 1 && m.m34 === 0 && m.m41 === 0 && m.m42 === 0 && m.m43 === 0 && m.m44 === 1;
  2286. };
  2287. prototypeAccessors.is2D.get = function () {
  2288. var m = this;
  2289. return m.m31 === 0 && m.m32 === 0 && m.m33 === 1 && m.m34 === 0 && m.m43 === 0 && m.m44 === 1;
  2290. };
  2291. prototypeAccessors.is2D.set = function (value) {
  2292. this.is2D = value;
  2293. };
  2294. CSSMatrix.prototype.setMatrixValue = function setMatrixValue(source) {
  2295. var m = this;
  2296. if ([Array, Float64Array, Float32Array].some(function (a) {
  2297. return source instanceof a;
  2298. })) {
  2299. return fromArray(source);
  2300. }
  2301. if (typeof source === 'string' && source.length && source !== 'none') {
  2302. return fromString(source);
  2303. }
  2304. if (_typeof(source) === 'object') {
  2305. return fromMatrix(source);
  2306. }
  2307. return m;
  2308. };
  2309. CSSMatrix.prototype.toArray = function toArray() {
  2310. var m = this;
  2311. var pow = Math.pow(10, 6);
  2312. var result;
  2313. if (m.is2D) {
  2314. result = [m.a, m.b, m.c, m.d, m.e, m.f];
  2315. } else {
  2316. result = [m.m11, m.m12, m.m13, m.m14, m.m21, m.m22, m.m23, m.m24, m.m31, m.m32, m.m33, m.m34, m.m41, m.m42, m.m43, m.m44];
  2317. }
  2318. return result.map(function (n) {
  2319. return Math.abs(n) < 1e-6 ? 0 : (n * pow >> 0) / pow;
  2320. });
  2321. };
  2322. CSSMatrix.prototype.toString = function toString() {
  2323. var m = this;
  2324. var values = m.toArray();
  2325. var type = m.is2D ? 'matrix' : 'matrix3d';
  2326. return type + "(" + values + ")";
  2327. };
  2328. CSSMatrix.prototype.toJSON = function toJSON() {
  2329. var m = this;
  2330. var is2D = m.is2D;
  2331. var isIdentity = m.isIdentity;
  2332. return Object.assign({}, m, {
  2333. is2D: is2D,
  2334. isIdentity: isIdentity
  2335. });
  2336. };
  2337. CSSMatrix.prototype.multiply = function multiply(m2) {
  2338. return Multiply(this, m2);
  2339. };
  2340. CSSMatrix.prototype.translate = function translate(x, y, z) {
  2341. var X = x;
  2342. var Y = y;
  2343. var Z = z;
  2344. if (Z === undefined) {
  2345. Z = 0;
  2346. }
  2347. if (Y === undefined) {
  2348. Y = 0;
  2349. }
  2350. return Multiply(this, Translate(X, Y, Z));
  2351. };
  2352. CSSMatrix.prototype.scale = function scale(x, y, z) {
  2353. var X = x;
  2354. var Y = y;
  2355. var Z = z;
  2356. if (Y === undefined) {
  2357. Y = x;
  2358. }
  2359. if (Z === undefined) {
  2360. Z = 1;
  2361. }
  2362. return Multiply(this, Scale(X, Y, Z));
  2363. };
  2364. CSSMatrix.prototype.rotate = function rotate(rx, ry, rz) {
  2365. var RX = rx;
  2366. var RY = ry;
  2367. var RZ = rz;
  2368. if (RY === undefined) {
  2369. RY = 0;
  2370. }
  2371. if (RZ === undefined) {
  2372. RZ = RX;
  2373. RX = 0;
  2374. }
  2375. return Multiply(this, Rotate(RX, RY, RZ));
  2376. };
  2377. CSSMatrix.prototype.rotateAxisAngle = function rotateAxisAngle(x, y, z, angle) {
  2378. if ([x, y, z, angle].some(function (n) {
  2379. return Number.isNaN(n);
  2380. })) {
  2381. throw new TypeError('CSSMatrix: expecting 4 values');
  2382. }
  2383. return Multiply(this, RotateAxisAngle(x, y, z, angle));
  2384. };
  2385. CSSMatrix.prototype.skewX = function skewX(angle) {
  2386. return Multiply(this, SkewX(angle));
  2387. };
  2388. CSSMatrix.prototype.skewY = function skewY(angle) {
  2389. return Multiply(this, SkewY(angle));
  2390. };
  2391. CSSMatrix.prototype.transformPoint = function transformPoint(v) {
  2392. var M = this;
  2393. var m = Translate(v.x, v.y, v.z);
  2394. m.m44 = v.w || 1;
  2395. m = M.multiply(m);
  2396. return {
  2397. x: m.m41,
  2398. y: m.m42,
  2399. z: m.m43,
  2400. w: m.m44
  2401. };
  2402. };
  2403. CSSMatrix.prototype.transform = function transform(t) {
  2404. var m = this;
  2405. var x = m.m11 * t.x + m.m12 * t.y + m.m13 * t.z + m.m14 * t.w;
  2406. var y = m.m21 * t.x + m.m22 * t.y + m.m23 * t.z + m.m24 * t.w;
  2407. var z = m.m31 * t.x + m.m32 * t.y + m.m33 * t.z + m.m34 * t.w;
  2408. var w = m.m41 * t.x + m.m42 * t.y + m.m43 * t.z + m.m44 * t.w;
  2409. return {
  2410. x: x / w,
  2411. y: y / w,
  2412. z: z / w,
  2413. w: w
  2414. };
  2415. };
  2416. Object.defineProperties(CSSMatrix.prototype, prototypeAccessors);
  2417. Object.assign(CSSMatrix, {
  2418. Translate: Translate,
  2419. Rotate: Rotate,
  2420. RotateAxisAngle: RotateAxisAngle,
  2421. Scale: Scale,
  2422. SkewX: SkewX,
  2423. SkewY: SkewY,
  2424. Multiply: Multiply,
  2425. fromArray: fromArray,
  2426. fromMatrix: fromMatrix,
  2427. fromString: fromString
  2428. });
  2429. var version = "0.0.24";
  2430. var Version = version;
  2431. Object.assign(CSSMatrix, {
  2432. Version: Version
  2433. });
  2434. return CSSMatrix;
  2435. });
  2436. /***/ }),
  2437. /* 67 */
  2438. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2439. __w_pdfjs_require__(68);
  2440. __w_pdfjs_require__(83);
  2441. var path = __w_pdfjs_require__(93);
  2442. module.exports = path.Object.fromEntries;
  2443. /***/ }),
  2444. /* 68 */
  2445. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2446. "use strict";
  2447. var toIndexedObject = __w_pdfjs_require__(14);
  2448. var addToUnscopables = __w_pdfjs_require__(69);
  2449. var Iterators = __w_pdfjs_require__(74);
  2450. var InternalStateModule = __w_pdfjs_require__(49);
  2451. var defineIterator = __w_pdfjs_require__(75);
  2452. var ARRAY_ITERATOR = 'Array Iterator';
  2453. var setInternalState = InternalStateModule.set;
  2454. var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);
  2455. module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
  2456. setInternalState(this, {
  2457. type: ARRAY_ITERATOR,
  2458. target: toIndexedObject(iterated),
  2459. index: 0,
  2460. kind: kind
  2461. });
  2462. }, function () {
  2463. var state = getInternalState(this);
  2464. var target = state.target;
  2465. var kind = state.kind;
  2466. var index = state.index++;
  2467. if (!target || index >= target.length) {
  2468. state.target = undefined;
  2469. return {
  2470. value: undefined,
  2471. done: true
  2472. };
  2473. }
  2474. if (kind == 'keys')
  2475. return {
  2476. value: index,
  2477. done: false
  2478. };
  2479. if (kind == 'values')
  2480. return {
  2481. value: target[index],
  2482. done: false
  2483. };
  2484. return {
  2485. value: [
  2486. index,
  2487. target[index]
  2488. ],
  2489. done: false
  2490. };
  2491. }, 'values');
  2492. Iterators.Arguments = Iterators.Array;
  2493. addToUnscopables('keys');
  2494. addToUnscopables('values');
  2495. addToUnscopables('entries');
  2496. /***/ }),
  2497. /* 69 */
  2498. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2499. var wellKnownSymbol = __w_pdfjs_require__(34);
  2500. var create = __w_pdfjs_require__(70);
  2501. var definePropertyModule = __w_pdfjs_require__(45);
  2502. var UNSCOPABLES = wellKnownSymbol('unscopables');
  2503. var ArrayPrototype = Array.prototype;
  2504. if (ArrayPrototype[UNSCOPABLES] == undefined) {
  2505. definePropertyModule.f(ArrayPrototype, UNSCOPABLES, {
  2506. configurable: true,
  2507. value: create(null)
  2508. });
  2509. }
  2510. module.exports = function (key) {
  2511. ArrayPrototype[UNSCOPABLES][key] = true;
  2512. };
  2513. /***/ }),
  2514. /* 70 */
  2515. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2516. var anObject = __w_pdfjs_require__(46);
  2517. var defineProperties = __w_pdfjs_require__(71);
  2518. var enumBugKeys = __w_pdfjs_require__(63);
  2519. var hiddenKeys = __w_pdfjs_require__(52);
  2520. var html = __w_pdfjs_require__(73);
  2521. var documentCreateElement = __w_pdfjs_require__(43);
  2522. var sharedKey = __w_pdfjs_require__(51);
  2523. var GT = '>';
  2524. var LT = '<';
  2525. var PROTOTYPE = 'prototype';
  2526. var SCRIPT = 'script';
  2527. var IE_PROTO = sharedKey('IE_PROTO');
  2528. var EmptyConstructor = function () {
  2529. };
  2530. var scriptTag = function (content) {
  2531. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  2532. };
  2533. var NullProtoObjectViaActiveX = function (activeXDocument) {
  2534. activeXDocument.write(scriptTag(''));
  2535. activeXDocument.close();
  2536. var temp = activeXDocument.parentWindow.Object;
  2537. activeXDocument = null;
  2538. return temp;
  2539. };
  2540. var NullProtoObjectViaIFrame = function () {
  2541. var iframe = documentCreateElement('iframe');
  2542. var JS = 'java' + SCRIPT + ':';
  2543. var iframeDocument;
  2544. iframe.style.display = 'none';
  2545. html.appendChild(iframe);
  2546. iframe.src = String(JS);
  2547. iframeDocument = iframe.contentWindow.document;
  2548. iframeDocument.open();
  2549. iframeDocument.write(scriptTag('document.F=Object'));
  2550. iframeDocument.close();
  2551. return iframeDocument.F;
  2552. };
  2553. var activeXDocument;
  2554. var NullProtoObject = function () {
  2555. try {
  2556. activeXDocument = new ActiveXObject('htmlfile');
  2557. } catch (error) {
  2558. }
  2559. NullProtoObject = typeof document != 'undefined' ? document.domain && activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame() : NullProtoObjectViaActiveX(activeXDocument);
  2560. var length = enumBugKeys.length;
  2561. while (length--)
  2562. delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  2563. return NullProtoObject();
  2564. };
  2565. hiddenKeys[IE_PROTO] = true;
  2566. module.exports = Object.create || function create(O, Properties) {
  2567. var result;
  2568. if (O !== null) {
  2569. EmptyConstructor[PROTOTYPE] = anObject(O);
  2570. result = new EmptyConstructor();
  2571. EmptyConstructor[PROTOTYPE] = null;
  2572. result[IE_PROTO] = O;
  2573. } else
  2574. result = NullProtoObject();
  2575. return Properties === undefined ? result : defineProperties(result, Properties);
  2576. };
  2577. /***/ }),
  2578. /* 71 */
  2579. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2580. var DESCRIPTORS = __w_pdfjs_require__(9);
  2581. var definePropertyModule = __w_pdfjs_require__(45);
  2582. var anObject = __w_pdfjs_require__(46);
  2583. var toIndexedObject = __w_pdfjs_require__(14);
  2584. var objectKeys = __w_pdfjs_require__(72);
  2585. module.exports = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
  2586. anObject(O);
  2587. var props = toIndexedObject(Properties);
  2588. var keys = objectKeys(Properties);
  2589. var length = keys.length;
  2590. var index = 0;
  2591. var key;
  2592. while (length > index)
  2593. definePropertyModule.f(O, key = keys[index++], props[key]);
  2594. return O;
  2595. };
  2596. /***/ }),
  2597. /* 72 */
  2598. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2599. var internalObjectKeys = __w_pdfjs_require__(57);
  2600. var enumBugKeys = __w_pdfjs_require__(63);
  2601. module.exports = Object.keys || function keys(O) {
  2602. return internalObjectKeys(O, enumBugKeys);
  2603. };
  2604. /***/ }),
  2605. /* 73 */
  2606. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2607. var getBuiltIn = __w_pdfjs_require__(24);
  2608. module.exports = getBuiltIn('document', 'documentElement');
  2609. /***/ }),
  2610. /* 74 */
  2611. /***/ ((module) => {
  2612. module.exports = {};
  2613. /***/ }),
  2614. /* 75 */
  2615. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2616. "use strict";
  2617. var $ = __w_pdfjs_require__(6);
  2618. var call = __w_pdfjs_require__(11);
  2619. var IS_PURE = __w_pdfjs_require__(36);
  2620. var FunctionName = __w_pdfjs_require__(53);
  2621. var isCallable = __w_pdfjs_require__(22);
  2622. var createIteratorConstructor = __w_pdfjs_require__(76);
  2623. var getPrototypeOf = __w_pdfjs_require__(78);
  2624. var setPrototypeOf = __w_pdfjs_require__(81);
  2625. var setToStringTag = __w_pdfjs_require__(80);
  2626. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  2627. var redefine = __w_pdfjs_require__(47);
  2628. var wellKnownSymbol = __w_pdfjs_require__(34);
  2629. var Iterators = __w_pdfjs_require__(74);
  2630. var IteratorsCore = __w_pdfjs_require__(77);
  2631. var PROPER_FUNCTION_NAME = FunctionName.PROPER;
  2632. var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
  2633. var IteratorPrototype = IteratorsCore.IteratorPrototype;
  2634. var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
  2635. var ITERATOR = wellKnownSymbol('iterator');
  2636. var KEYS = 'keys';
  2637. var VALUES = 'values';
  2638. var ENTRIES = 'entries';
  2639. var returnThis = function () {
  2640. return this;
  2641. };
  2642. module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  2643. createIteratorConstructor(IteratorConstructor, NAME, next);
  2644. var getIterationMethod = function (KIND) {
  2645. if (KIND === DEFAULT && defaultIterator)
  2646. return defaultIterator;
  2647. if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype)
  2648. return IterablePrototype[KIND];
  2649. switch (KIND) {
  2650. case KEYS:
  2651. return function keys() {
  2652. return new IteratorConstructor(this, KIND);
  2653. };
  2654. case VALUES:
  2655. return function values() {
  2656. return new IteratorConstructor(this, KIND);
  2657. };
  2658. case ENTRIES:
  2659. return function entries() {
  2660. return new IteratorConstructor(this, KIND);
  2661. };
  2662. }
  2663. return function () {
  2664. return new IteratorConstructor(this);
  2665. };
  2666. };
  2667. var TO_STRING_TAG = NAME + ' Iterator';
  2668. var INCORRECT_VALUES_NAME = false;
  2669. var IterablePrototype = Iterable.prototype;
  2670. var nativeIterator = IterablePrototype[ITERATOR] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT];
  2671. var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
  2672. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  2673. var CurrentIteratorPrototype, methods, KEY;
  2674. if (anyNativeIterator) {
  2675. CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
  2676. if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
  2677. if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
  2678. if (setPrototypeOf) {
  2679. setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
  2680. } else if (!isCallable(CurrentIteratorPrototype[ITERATOR])) {
  2681. redefine(CurrentIteratorPrototype, ITERATOR, returnThis);
  2682. }
  2683. }
  2684. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
  2685. if (IS_PURE)
  2686. Iterators[TO_STRING_TAG] = returnThis;
  2687. }
  2688. }
  2689. if (PROPER_FUNCTION_NAME && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  2690. if (!IS_PURE && CONFIGURABLE_FUNCTION_NAME) {
  2691. createNonEnumerableProperty(IterablePrototype, 'name', VALUES);
  2692. } else {
  2693. INCORRECT_VALUES_NAME = true;
  2694. defaultIterator = function values() {
  2695. return call(nativeIterator, this);
  2696. };
  2697. }
  2698. }
  2699. if (DEFAULT) {
  2700. methods = {
  2701. values: getIterationMethod(VALUES),
  2702. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  2703. entries: getIterationMethod(ENTRIES)
  2704. };
  2705. if (FORCED)
  2706. for (KEY in methods) {
  2707. if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  2708. redefine(IterablePrototype, KEY, methods[KEY]);
  2709. }
  2710. }
  2711. else
  2712. $({
  2713. target: NAME,
  2714. proto: true,
  2715. forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME
  2716. }, methods);
  2717. }
  2718. if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
  2719. redefine(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT });
  2720. }
  2721. Iterators[NAME] = defaultIterator;
  2722. return methods;
  2723. };
  2724. /***/ }),
  2725. /* 76 */
  2726. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2727. "use strict";
  2728. var IteratorPrototype = (__w_pdfjs_require__(77).IteratorPrototype);
  2729. var create = __w_pdfjs_require__(70);
  2730. var createPropertyDescriptor = __w_pdfjs_require__(13);
  2731. var setToStringTag = __w_pdfjs_require__(80);
  2732. var Iterators = __w_pdfjs_require__(74);
  2733. var returnThis = function () {
  2734. return this;
  2735. };
  2736. module.exports = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {
  2737. var TO_STRING_TAG = NAME + ' Iterator';
  2738. IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) });
  2739. setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
  2740. Iterators[TO_STRING_TAG] = returnThis;
  2741. return IteratorConstructor;
  2742. };
  2743. /***/ }),
  2744. /* 77 */
  2745. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2746. "use strict";
  2747. var fails = __w_pdfjs_require__(10);
  2748. var isCallable = __w_pdfjs_require__(22);
  2749. var create = __w_pdfjs_require__(70);
  2750. var getPrototypeOf = __w_pdfjs_require__(78);
  2751. var redefine = __w_pdfjs_require__(47);
  2752. var wellKnownSymbol = __w_pdfjs_require__(34);
  2753. var IS_PURE = __w_pdfjs_require__(36);
  2754. var ITERATOR = wellKnownSymbol('iterator');
  2755. var BUGGY_SAFARI_ITERATORS = false;
  2756. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  2757. if ([].keys) {
  2758. arrayIterator = [].keys();
  2759. if (!('next' in arrayIterator))
  2760. BUGGY_SAFARI_ITERATORS = true;
  2761. else {
  2762. PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
  2763. if (PrototypeOfArrayIteratorPrototype !== Object.prototype)
  2764. IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  2765. }
  2766. }
  2767. var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () {
  2768. var test = {};
  2769. return IteratorPrototype[ITERATOR].call(test) !== test;
  2770. });
  2771. if (NEW_ITERATOR_PROTOTYPE)
  2772. IteratorPrototype = {};
  2773. else if (IS_PURE)
  2774. IteratorPrototype = create(IteratorPrototype);
  2775. if (!isCallable(IteratorPrototype[ITERATOR])) {
  2776. redefine(IteratorPrototype, ITERATOR, function () {
  2777. return this;
  2778. });
  2779. }
  2780. module.exports = {
  2781. IteratorPrototype: IteratorPrototype,
  2782. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  2783. };
  2784. /***/ }),
  2785. /* 78 */
  2786. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2787. var global = __w_pdfjs_require__(7);
  2788. var hasOwn = __w_pdfjs_require__(39);
  2789. var isCallable = __w_pdfjs_require__(22);
  2790. var toObject = __w_pdfjs_require__(40);
  2791. var sharedKey = __w_pdfjs_require__(51);
  2792. var CORRECT_PROTOTYPE_GETTER = __w_pdfjs_require__(79);
  2793. var IE_PROTO = sharedKey('IE_PROTO');
  2794. var Object = global.Object;
  2795. var ObjectPrototype = Object.prototype;
  2796. module.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {
  2797. var object = toObject(O);
  2798. if (hasOwn(object, IE_PROTO))
  2799. return object[IE_PROTO];
  2800. var constructor = object.constructor;
  2801. if (isCallable(constructor) && object instanceof constructor) {
  2802. return constructor.prototype;
  2803. }
  2804. return object instanceof Object ? ObjectPrototype : null;
  2805. };
  2806. /***/ }),
  2807. /* 79 */
  2808. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2809. var fails = __w_pdfjs_require__(10);
  2810. module.exports = !fails(function () {
  2811. function F() {
  2812. }
  2813. F.prototype.constructor = null;
  2814. return Object.getPrototypeOf(new F()) !== F.prototype;
  2815. });
  2816. /***/ }),
  2817. /* 80 */
  2818. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2819. var defineProperty = (__w_pdfjs_require__(45).f);
  2820. var hasOwn = __w_pdfjs_require__(39);
  2821. var wellKnownSymbol = __w_pdfjs_require__(34);
  2822. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  2823. module.exports = function (it, TAG, STATIC) {
  2824. if (it && !hasOwn(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {
  2825. defineProperty(it, TO_STRING_TAG, {
  2826. configurable: true,
  2827. value: TAG
  2828. });
  2829. }
  2830. };
  2831. /***/ }),
  2832. /* 81 */
  2833. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2834. var uncurryThis = __w_pdfjs_require__(16);
  2835. var anObject = __w_pdfjs_require__(46);
  2836. var aPossiblePrototype = __w_pdfjs_require__(82);
  2837. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? (function () {
  2838. var CORRECT_SETTER = false;
  2839. var test = {};
  2840. var setter;
  2841. try {
  2842. setter = uncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
  2843. setter(test, []);
  2844. CORRECT_SETTER = test instanceof Array;
  2845. } catch (error) {
  2846. }
  2847. return function setPrototypeOf(O, proto) {
  2848. anObject(O);
  2849. aPossiblePrototype(proto);
  2850. if (CORRECT_SETTER)
  2851. setter(O, proto);
  2852. else
  2853. O.__proto__ = proto;
  2854. return O;
  2855. };
  2856. }()) : undefined);
  2857. /***/ }),
  2858. /* 82 */
  2859. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2860. var global = __w_pdfjs_require__(7);
  2861. var isCallable = __w_pdfjs_require__(22);
  2862. var String = global.String;
  2863. var TypeError = global.TypeError;
  2864. module.exports = function (argument) {
  2865. if (typeof argument == 'object' || isCallable(argument))
  2866. return argument;
  2867. throw TypeError("Can't set " + String(argument) + ' as a prototype');
  2868. };
  2869. /***/ }),
  2870. /* 83 */
  2871. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2872. var $ = __w_pdfjs_require__(6);
  2873. var iterate = __w_pdfjs_require__(84);
  2874. var createProperty = __w_pdfjs_require__(92);
  2875. $({
  2876. target: 'Object',
  2877. stat: true
  2878. }, {
  2879. fromEntries: function fromEntries(iterable) {
  2880. var obj = {};
  2881. iterate(iterable, function (k, v) {
  2882. createProperty(obj, k, v);
  2883. }, { AS_ENTRIES: true });
  2884. return obj;
  2885. }
  2886. });
  2887. /***/ }),
  2888. /* 84 */
  2889. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2890. var global = __w_pdfjs_require__(7);
  2891. var bind = __w_pdfjs_require__(85);
  2892. var call = __w_pdfjs_require__(11);
  2893. var anObject = __w_pdfjs_require__(46);
  2894. var tryToString = __w_pdfjs_require__(32);
  2895. var isArrayIteratorMethod = __w_pdfjs_require__(86);
  2896. var lengthOfArrayLike = __w_pdfjs_require__(61);
  2897. var isPrototypeOf = __w_pdfjs_require__(25);
  2898. var getIterator = __w_pdfjs_require__(87);
  2899. var getIteratorMethod = __w_pdfjs_require__(88);
  2900. var iteratorClose = __w_pdfjs_require__(91);
  2901. var TypeError = global.TypeError;
  2902. var Result = function (stopped, result) {
  2903. this.stopped = stopped;
  2904. this.result = result;
  2905. };
  2906. var ResultPrototype = Result.prototype;
  2907. module.exports = function (iterable, unboundFunction, options) {
  2908. var that = options && options.that;
  2909. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  2910. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  2911. var INTERRUPTED = !!(options && options.INTERRUPTED);
  2912. var fn = bind(unboundFunction, that);
  2913. var iterator, iterFn, index, length, result, next, step;
  2914. var stop = function (condition) {
  2915. if (iterator)
  2916. iteratorClose(iterator, 'normal', condition);
  2917. return new Result(true, condition);
  2918. };
  2919. var callFn = function (value) {
  2920. if (AS_ENTRIES) {
  2921. anObject(value);
  2922. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  2923. }
  2924. return INTERRUPTED ? fn(value, stop) : fn(value);
  2925. };
  2926. if (IS_ITERATOR) {
  2927. iterator = iterable;
  2928. } else {
  2929. iterFn = getIteratorMethod(iterable);
  2930. if (!iterFn)
  2931. throw TypeError(tryToString(iterable) + ' is not iterable');
  2932. if (isArrayIteratorMethod(iterFn)) {
  2933. for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
  2934. result = callFn(iterable[index]);
  2935. if (result && isPrototypeOf(ResultPrototype, result))
  2936. return result;
  2937. }
  2938. return new Result(false);
  2939. }
  2940. iterator = getIterator(iterable, iterFn);
  2941. }
  2942. next = iterator.next;
  2943. while (!(step = call(next, iterator)).done) {
  2944. try {
  2945. result = callFn(step.value);
  2946. } catch (error) {
  2947. iteratorClose(iterator, 'throw', error);
  2948. }
  2949. if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result))
  2950. return result;
  2951. }
  2952. return new Result(false);
  2953. };
  2954. /***/ }),
  2955. /* 85 */
  2956. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2957. var uncurryThis = __w_pdfjs_require__(16);
  2958. var aCallable = __w_pdfjs_require__(31);
  2959. var bind = uncurryThis(uncurryThis.bind);
  2960. module.exports = function (fn, that) {
  2961. aCallable(fn);
  2962. return that === undefined ? fn : bind ? bind(fn, that) : function () {
  2963. return fn.apply(that, arguments);
  2964. };
  2965. };
  2966. /***/ }),
  2967. /* 86 */
  2968. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2969. var wellKnownSymbol = __w_pdfjs_require__(34);
  2970. var Iterators = __w_pdfjs_require__(74);
  2971. var ITERATOR = wellKnownSymbol('iterator');
  2972. var ArrayPrototype = Array.prototype;
  2973. module.exports = function (it) {
  2974. return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
  2975. };
  2976. /***/ }),
  2977. /* 87 */
  2978. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2979. var global = __w_pdfjs_require__(7);
  2980. var call = __w_pdfjs_require__(11);
  2981. var aCallable = __w_pdfjs_require__(31);
  2982. var anObject = __w_pdfjs_require__(46);
  2983. var tryToString = __w_pdfjs_require__(32);
  2984. var getIteratorMethod = __w_pdfjs_require__(88);
  2985. var TypeError = global.TypeError;
  2986. module.exports = function (argument, usingIterator) {
  2987. var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;
  2988. if (aCallable(iteratorMethod))
  2989. return anObject(call(iteratorMethod, argument));
  2990. throw TypeError(tryToString(argument) + ' is not iterable');
  2991. };
  2992. /***/ }),
  2993. /* 88 */
  2994. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2995. var classof = __w_pdfjs_require__(89);
  2996. var getMethod = __w_pdfjs_require__(30);
  2997. var Iterators = __w_pdfjs_require__(74);
  2998. var wellKnownSymbol = __w_pdfjs_require__(34);
  2999. var ITERATOR = wellKnownSymbol('iterator');
  3000. module.exports = function (it) {
  3001. if (it != undefined)
  3002. return getMethod(it, ITERATOR) || getMethod(it, '@@iterator') || Iterators[classof(it)];
  3003. };
  3004. /***/ }),
  3005. /* 89 */
  3006. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3007. var global = __w_pdfjs_require__(7);
  3008. var TO_STRING_TAG_SUPPORT = __w_pdfjs_require__(90);
  3009. var isCallable = __w_pdfjs_require__(22);
  3010. var classofRaw = __w_pdfjs_require__(17);
  3011. var wellKnownSymbol = __w_pdfjs_require__(34);
  3012. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  3013. var Object = global.Object;
  3014. var CORRECT_ARGUMENTS = classofRaw((function () {
  3015. return arguments;
  3016. }())) == 'Arguments';
  3017. var tryGet = function (it, key) {
  3018. try {
  3019. return it[key];
  3020. } catch (error) {
  3021. }
  3022. };
  3023. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  3024. var O, tag, result;
  3025. 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' && isCallable(O.callee) ? 'Arguments' : result;
  3026. };
  3027. /***/ }),
  3028. /* 90 */
  3029. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3030. var wellKnownSymbol = __w_pdfjs_require__(34);
  3031. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  3032. var test = {};
  3033. test[TO_STRING_TAG] = 'z';
  3034. module.exports = String(test) === '[object z]';
  3035. /***/ }),
  3036. /* 91 */
  3037. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3038. var call = __w_pdfjs_require__(11);
  3039. var anObject = __w_pdfjs_require__(46);
  3040. var getMethod = __w_pdfjs_require__(30);
  3041. module.exports = function (iterator, kind, value) {
  3042. var innerResult, innerError;
  3043. anObject(iterator);
  3044. try {
  3045. innerResult = getMethod(iterator, 'return');
  3046. if (!innerResult) {
  3047. if (kind === 'throw')
  3048. throw value;
  3049. return value;
  3050. }
  3051. innerResult = call(innerResult, iterator);
  3052. } catch (error) {
  3053. innerError = true;
  3054. innerResult = error;
  3055. }
  3056. if (kind === 'throw')
  3057. throw value;
  3058. if (innerError)
  3059. throw innerResult;
  3060. anObject(innerResult);
  3061. return value;
  3062. };
  3063. /***/ }),
  3064. /* 92 */
  3065. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3066. "use strict";
  3067. var toPropertyKey = __w_pdfjs_require__(19);
  3068. var definePropertyModule = __w_pdfjs_require__(45);
  3069. var createPropertyDescriptor = __w_pdfjs_require__(13);
  3070. module.exports = function (object, key, value) {
  3071. var propertyKey = toPropertyKey(key);
  3072. if (propertyKey in object)
  3073. definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
  3074. else
  3075. object[propertyKey] = value;
  3076. };
  3077. /***/ }),
  3078. /* 93 */
  3079. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3080. var global = __w_pdfjs_require__(7);
  3081. module.exports = global;
  3082. /***/ }),
  3083. /* 94 */
  3084. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  3085. "use strict";
  3086. 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); }
  3087. Object.defineProperty(exports, "__esModule", ({
  3088. value: true
  3089. }));
  3090. exports.Jbig2Image = void 0;
  3091. var _util = __w_pdfjs_require__(1);
  3092. var _core_utils = __w_pdfjs_require__(95);
  3093. var _arithmetic_decoder = __w_pdfjs_require__(100);
  3094. var _ccitt = __w_pdfjs_require__(101);
  3095. 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); } }
  3096. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3097. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3098. 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); }
  3099. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3100. 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); }; }
  3101. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  3102. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  3103. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3104. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  3105. var Jbig2Error = /*#__PURE__*/function (_BaseException) {
  3106. _inherits(Jbig2Error, _BaseException);
  3107. var _super = _createSuper(Jbig2Error);
  3108. function Jbig2Error(msg) {
  3109. _classCallCheck(this, Jbig2Error);
  3110. return _super.call(this, "JBIG2 error: ".concat(msg), "Jbig2Error");
  3111. }
  3112. return Jbig2Error;
  3113. }(_util.BaseException);
  3114. var ContextCache = /*#__PURE__*/function () {
  3115. function ContextCache() {
  3116. _classCallCheck(this, ContextCache);
  3117. }
  3118. _createClass(ContextCache, [{
  3119. key: "getContexts",
  3120. value: function getContexts(id) {
  3121. if (id in this) {
  3122. return this[id];
  3123. }
  3124. return this[id] = new Int8Array(1 << 16);
  3125. }
  3126. }]);
  3127. return ContextCache;
  3128. }();
  3129. var DecodingContext = /*#__PURE__*/function () {
  3130. function DecodingContext(data, start, end) {
  3131. _classCallCheck(this, DecodingContext);
  3132. this.data = data;
  3133. this.start = start;
  3134. this.end = end;
  3135. }
  3136. _createClass(DecodingContext, [{
  3137. key: "decoder",
  3138. get: function get() {
  3139. var decoder = new _arithmetic_decoder.ArithmeticDecoder(this.data, this.start, this.end);
  3140. return (0, _util.shadow)(this, "decoder", decoder);
  3141. }
  3142. }, {
  3143. key: "contextCache",
  3144. get: function get() {
  3145. var cache = new ContextCache();
  3146. return (0, _util.shadow)(this, "contextCache", cache);
  3147. }
  3148. }]);
  3149. return DecodingContext;
  3150. }();
  3151. function decodeInteger(contextCache, procedure, decoder) {
  3152. var contexts = contextCache.getContexts(procedure);
  3153. var prev = 1;
  3154. function readBits(length) {
  3155. var v = 0;
  3156. for (var i = 0; i < length; i++) {
  3157. var bit = decoder.readBit(contexts, prev);
  3158. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  3159. v = v << 1 | bit;
  3160. }
  3161. return v >>> 0;
  3162. }
  3163. var sign = readBits(1);
  3164. var value = readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(32) + 4436 : readBits(12) + 340 : readBits(8) + 84 : readBits(6) + 20 : readBits(4) + 4 : readBits(2);
  3165. if (sign === 0) {
  3166. return value;
  3167. } else if (value > 0) {
  3168. return -value;
  3169. }
  3170. return null;
  3171. }
  3172. function decodeIAID(contextCache, decoder, codeLength) {
  3173. var contexts = contextCache.getContexts("IAID");
  3174. var prev = 1;
  3175. for (var i = 0; i < codeLength; i++) {
  3176. var bit = decoder.readBit(contexts, prev);
  3177. prev = prev << 1 | bit;
  3178. }
  3179. if (codeLength < 31) {
  3180. return prev & (1 << codeLength) - 1;
  3181. }
  3182. return prev & 0x7fffffff;
  3183. }
  3184. var SegmentTypes = ["SymbolDictionary", null, null, null, "IntermediateTextRegion", null, "ImmediateTextRegion", "ImmediateLosslessTextRegion", null, null, null, null, null, null, null, null, "PatternDictionary", null, null, null, "IntermediateHalftoneRegion", null, "ImmediateHalftoneRegion", "ImmediateLosslessHalftoneRegion", null, null, null, null, null, null, null, null, null, null, null, null, "IntermediateGenericRegion", null, "ImmediateGenericRegion", "ImmediateLosslessGenericRegion", "IntermediateGenericRefinementRegion", null, "ImmediateGenericRefinementRegion", "ImmediateLosslessGenericRefinementRegion", null, null, null, null, "PageInformation", "EndOfPage", "EndOfStripe", "EndOfFile", "Profiles", "Tables", null, null, null, null, null, null, null, null, "Extension"];
  3185. var CodingTemplates = [[{
  3186. x: -1,
  3187. y: -2
  3188. }, {
  3189. x: 0,
  3190. y: -2
  3191. }, {
  3192. x: 1,
  3193. y: -2
  3194. }, {
  3195. x: -2,
  3196. y: -1
  3197. }, {
  3198. x: -1,
  3199. y: -1
  3200. }, {
  3201. x: 0,
  3202. y: -1
  3203. }, {
  3204. x: 1,
  3205. y: -1
  3206. }, {
  3207. x: 2,
  3208. y: -1
  3209. }, {
  3210. x: -4,
  3211. y: 0
  3212. }, {
  3213. x: -3,
  3214. y: 0
  3215. }, {
  3216. x: -2,
  3217. y: 0
  3218. }, {
  3219. x: -1,
  3220. y: 0
  3221. }], [{
  3222. x: -1,
  3223. y: -2
  3224. }, {
  3225. x: 0,
  3226. y: -2
  3227. }, {
  3228. x: 1,
  3229. y: -2
  3230. }, {
  3231. x: 2,
  3232. y: -2
  3233. }, {
  3234. x: -2,
  3235. y: -1
  3236. }, {
  3237. x: -1,
  3238. y: -1
  3239. }, {
  3240. x: 0,
  3241. y: -1
  3242. }, {
  3243. x: 1,
  3244. y: -1
  3245. }, {
  3246. x: 2,
  3247. y: -1
  3248. }, {
  3249. x: -3,
  3250. y: 0
  3251. }, {
  3252. x: -2,
  3253. y: 0
  3254. }, {
  3255. x: -1,
  3256. y: 0
  3257. }], [{
  3258. x: -1,
  3259. y: -2
  3260. }, {
  3261. x: 0,
  3262. y: -2
  3263. }, {
  3264. x: 1,
  3265. y: -2
  3266. }, {
  3267. x: -2,
  3268. y: -1
  3269. }, {
  3270. x: -1,
  3271. y: -1
  3272. }, {
  3273. x: 0,
  3274. y: -1
  3275. }, {
  3276. x: 1,
  3277. y: -1
  3278. }, {
  3279. x: -2,
  3280. y: 0
  3281. }, {
  3282. x: -1,
  3283. y: 0
  3284. }], [{
  3285. x: -3,
  3286. y: -1
  3287. }, {
  3288. x: -2,
  3289. y: -1
  3290. }, {
  3291. x: -1,
  3292. y: -1
  3293. }, {
  3294. x: 0,
  3295. y: -1
  3296. }, {
  3297. x: 1,
  3298. y: -1
  3299. }, {
  3300. x: -4,
  3301. y: 0
  3302. }, {
  3303. x: -3,
  3304. y: 0
  3305. }, {
  3306. x: -2,
  3307. y: 0
  3308. }, {
  3309. x: -1,
  3310. y: 0
  3311. }]];
  3312. var RefinementTemplates = [{
  3313. coding: [{
  3314. x: 0,
  3315. y: -1
  3316. }, {
  3317. x: 1,
  3318. y: -1
  3319. }, {
  3320. x: -1,
  3321. y: 0
  3322. }],
  3323. reference: [{
  3324. x: 0,
  3325. y: -1
  3326. }, {
  3327. x: 1,
  3328. y: -1
  3329. }, {
  3330. x: -1,
  3331. y: 0
  3332. }, {
  3333. x: 0,
  3334. y: 0
  3335. }, {
  3336. x: 1,
  3337. y: 0
  3338. }, {
  3339. x: -1,
  3340. y: 1
  3341. }, {
  3342. x: 0,
  3343. y: 1
  3344. }, {
  3345. x: 1,
  3346. y: 1
  3347. }]
  3348. }, {
  3349. coding: [{
  3350. x: -1,
  3351. y: -1
  3352. }, {
  3353. x: 0,
  3354. y: -1
  3355. }, {
  3356. x: 1,
  3357. y: -1
  3358. }, {
  3359. x: -1,
  3360. y: 0
  3361. }],
  3362. reference: [{
  3363. x: 0,
  3364. y: -1
  3365. }, {
  3366. x: -1,
  3367. y: 0
  3368. }, {
  3369. x: 0,
  3370. y: 0
  3371. }, {
  3372. x: 1,
  3373. y: 0
  3374. }, {
  3375. x: 0,
  3376. y: 1
  3377. }, {
  3378. x: 1,
  3379. y: 1
  3380. }]
  3381. }];
  3382. var ReusedContexts = [0x9b25, 0x0795, 0x00e5, 0x0195];
  3383. var RefinementReusedContexts = [0x0020, 0x0008];
  3384. function decodeBitmapTemplate0(width, height, decodingContext) {
  3385. var decoder = decodingContext.decoder;
  3386. var contexts = decodingContext.contextCache.getContexts("GB");
  3387. var bitmap = [];
  3388. var contextLabel, i, j, pixel, row, row1, row2;
  3389. var OLD_PIXEL_MASK = 0x7bf7;
  3390. for (i = 0; i < height; i++) {
  3391. row = bitmap[i] = new Uint8Array(width);
  3392. row1 = i < 1 ? row : bitmap[i - 1];
  3393. row2 = i < 2 ? row : bitmap[i - 2];
  3394. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  3395. for (j = 0; j < width; j++) {
  3396. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  3397. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  3398. }
  3399. }
  3400. return bitmap;
  3401. }
  3402. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  3403. if (mmr) {
  3404. var input = new Reader(decodingContext.data, decodingContext.start, decodingContext.end);
  3405. return decodeMMRBitmap(input, width, height, false);
  3406. }
  3407. if (templateIndex === 0 && !skip && !prediction && at.length === 4 && at[0].x === 3 && at[0].y === -1 && at[1].x === -3 && at[1].y === -1 && at[2].x === 2 && at[2].y === -2 && at[3].x === -2 && at[3].y === -2) {
  3408. return decodeBitmapTemplate0(width, height, decodingContext);
  3409. }
  3410. var useskip = !!skip;
  3411. var template = CodingTemplates[templateIndex].concat(at);
  3412. template.sort(function (a, b) {
  3413. return a.y - b.y || a.x - b.x;
  3414. });
  3415. var templateLength = template.length;
  3416. var templateX = new Int8Array(templateLength);
  3417. var templateY = new Int8Array(templateLength);
  3418. var changingTemplateEntries = [];
  3419. var reuseMask = 0,
  3420. minX = 0,
  3421. maxX = 0,
  3422. minY = 0;
  3423. var c, k;
  3424. for (k = 0; k < templateLength; k++) {
  3425. templateX[k] = template[k].x;
  3426. templateY[k] = template[k].y;
  3427. minX = Math.min(minX, template[k].x);
  3428. maxX = Math.max(maxX, template[k].x);
  3429. minY = Math.min(minY, template[k].y);
  3430. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  3431. reuseMask |= 1 << templateLength - 1 - k;
  3432. } else {
  3433. changingTemplateEntries.push(k);
  3434. }
  3435. }
  3436. var changingEntriesLength = changingTemplateEntries.length;
  3437. var changingTemplateX = new Int8Array(changingEntriesLength);
  3438. var changingTemplateY = new Int8Array(changingEntriesLength);
  3439. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  3440. for (c = 0; c < changingEntriesLength; c++) {
  3441. k = changingTemplateEntries[c];
  3442. changingTemplateX[c] = template[k].x;
  3443. changingTemplateY[c] = template[k].y;
  3444. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  3445. }
  3446. var sbb_left = -minX;
  3447. var sbb_top = -minY;
  3448. var sbb_right = width - maxX;
  3449. var pseudoPixelContext = ReusedContexts[templateIndex];
  3450. var row = new Uint8Array(width);
  3451. var bitmap = [];
  3452. var decoder = decodingContext.decoder;
  3453. var contexts = decodingContext.contextCache.getContexts("GB");
  3454. var ltp = 0,
  3455. j,
  3456. i0,
  3457. j0,
  3458. contextLabel = 0,
  3459. bit,
  3460. shift;
  3461. for (var i = 0; i < height; i++) {
  3462. if (prediction) {
  3463. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  3464. ltp ^= sltp;
  3465. if (ltp) {
  3466. bitmap.push(row);
  3467. continue;
  3468. }
  3469. }
  3470. row = new Uint8Array(row);
  3471. bitmap.push(row);
  3472. for (j = 0; j < width; j++) {
  3473. if (useskip && skip[i][j]) {
  3474. row[j] = 0;
  3475. continue;
  3476. }
  3477. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  3478. contextLabel = contextLabel << 1 & reuseMask;
  3479. for (k = 0; k < changingEntriesLength; k++) {
  3480. i0 = i + changingTemplateY[k];
  3481. j0 = j + changingTemplateX[k];
  3482. bit = bitmap[i0][j0];
  3483. if (bit) {
  3484. bit = changingTemplateBit[k];
  3485. contextLabel |= bit;
  3486. }
  3487. }
  3488. } else {
  3489. contextLabel = 0;
  3490. shift = templateLength - 1;
  3491. for (k = 0; k < templateLength; k++, shift--) {
  3492. j0 = j + templateX[k];
  3493. if (j0 >= 0 && j0 < width) {
  3494. i0 = i + templateY[k];
  3495. if (i0 >= 0) {
  3496. bit = bitmap[i0][j0];
  3497. if (bit) {
  3498. contextLabel |= bit << shift;
  3499. }
  3500. }
  3501. }
  3502. }
  3503. }
  3504. var pixel = decoder.readBit(contexts, contextLabel);
  3505. row[j] = pixel;
  3506. }
  3507. }
  3508. return bitmap;
  3509. }
  3510. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  3511. var codingTemplate = RefinementTemplates[templateIndex].coding;
  3512. if (templateIndex === 0) {
  3513. codingTemplate = codingTemplate.concat([at[0]]);
  3514. }
  3515. var codingTemplateLength = codingTemplate.length;
  3516. var codingTemplateX = new Int32Array(codingTemplateLength);
  3517. var codingTemplateY = new Int32Array(codingTemplateLength);
  3518. var k;
  3519. for (k = 0; k < codingTemplateLength; k++) {
  3520. codingTemplateX[k] = codingTemplate[k].x;
  3521. codingTemplateY[k] = codingTemplate[k].y;
  3522. }
  3523. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  3524. if (templateIndex === 0) {
  3525. referenceTemplate = referenceTemplate.concat([at[1]]);
  3526. }
  3527. var referenceTemplateLength = referenceTemplate.length;
  3528. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  3529. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  3530. for (k = 0; k < referenceTemplateLength; k++) {
  3531. referenceTemplateX[k] = referenceTemplate[k].x;
  3532. referenceTemplateY[k] = referenceTemplate[k].y;
  3533. }
  3534. var referenceWidth = referenceBitmap[0].length;
  3535. var referenceHeight = referenceBitmap.length;
  3536. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  3537. var bitmap = [];
  3538. var decoder = decodingContext.decoder;
  3539. var contexts = decodingContext.contextCache.getContexts("GR");
  3540. var ltp = 0;
  3541. for (var i = 0; i < height; i++) {
  3542. if (prediction) {
  3543. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  3544. ltp ^= sltp;
  3545. if (ltp) {
  3546. throw new Jbig2Error("prediction is not supported");
  3547. }
  3548. }
  3549. var row = new Uint8Array(width);
  3550. bitmap.push(row);
  3551. for (var j = 0; j < width; j++) {
  3552. var i0 = void 0,
  3553. j0 = void 0;
  3554. var contextLabel = 0;
  3555. for (k = 0; k < codingTemplateLength; k++) {
  3556. i0 = i + codingTemplateY[k];
  3557. j0 = j + codingTemplateX[k];
  3558. if (i0 < 0 || j0 < 0 || j0 >= width) {
  3559. contextLabel <<= 1;
  3560. } else {
  3561. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  3562. }
  3563. }
  3564. for (k = 0; k < referenceTemplateLength; k++) {
  3565. i0 = i + referenceTemplateY[k] - offsetY;
  3566. j0 = j + referenceTemplateX[k] - offsetX;
  3567. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  3568. contextLabel <<= 1;
  3569. } else {
  3570. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  3571. }
  3572. }
  3573. var pixel = decoder.readBit(contexts, contextLabel);
  3574. row[j] = pixel;
  3575. }
  3576. }
  3577. return bitmap;
  3578. }
  3579. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext, huffmanInput) {
  3580. if (huffman && refinement) {
  3581. throw new Jbig2Error("symbol refinement with Huffman is not supported");
  3582. }
  3583. var newSymbols = [];
  3584. var currentHeight = 0;
  3585. var symbolCodeLength = (0, _core_utils.log2)(symbols.length + numberOfNewSymbols);
  3586. var decoder = decodingContext.decoder;
  3587. var contextCache = decodingContext.contextCache;
  3588. var tableB1, symbolWidths;
  3589. if (huffman) {
  3590. tableB1 = getStandardTable(1);
  3591. symbolWidths = [];
  3592. symbolCodeLength = Math.max(symbolCodeLength, 1);
  3593. }
  3594. while (newSymbols.length < numberOfNewSymbols) {
  3595. var deltaHeight = huffman ? huffmanTables.tableDeltaHeight.decode(huffmanInput) : decodeInteger(contextCache, "IADH", decoder);
  3596. currentHeight += deltaHeight;
  3597. var currentWidth = 0,
  3598. totalWidth = 0;
  3599. var firstSymbol = huffman ? symbolWidths.length : 0;
  3600. while (true) {
  3601. var deltaWidth = huffman ? huffmanTables.tableDeltaWidth.decode(huffmanInput) : decodeInteger(contextCache, "IADW", decoder);
  3602. if (deltaWidth === null) {
  3603. break;
  3604. }
  3605. currentWidth += deltaWidth;
  3606. totalWidth += currentWidth;
  3607. var bitmap = void 0;
  3608. if (refinement) {
  3609. var numberOfInstances = decodeInteger(contextCache, "IAAI", decoder);
  3610. if (numberOfInstances > 1) {
  3611. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext, 0, huffmanInput);
  3612. } else {
  3613. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  3614. var rdx = decodeInteger(contextCache, "IARDX", decoder);
  3615. var rdy = decodeInteger(contextCache, "IARDY", decoder);
  3616. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  3617. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  3618. }
  3619. newSymbols.push(bitmap);
  3620. } else if (huffman) {
  3621. symbolWidths.push(currentWidth);
  3622. } else {
  3623. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  3624. newSymbols.push(bitmap);
  3625. }
  3626. }
  3627. if (huffman && !refinement) {
  3628. var bitmapSize = huffmanTables.tableBitmapSize.decode(huffmanInput);
  3629. huffmanInput.byteAlign();
  3630. var collectiveBitmap = void 0;
  3631. if (bitmapSize === 0) {
  3632. collectiveBitmap = readUncompressedBitmap(huffmanInput, totalWidth, currentHeight);
  3633. } else {
  3634. var originalEnd = huffmanInput.end;
  3635. var bitmapEnd = huffmanInput.position + bitmapSize;
  3636. huffmanInput.end = bitmapEnd;
  3637. collectiveBitmap = decodeMMRBitmap(huffmanInput, totalWidth, currentHeight, false);
  3638. huffmanInput.end = originalEnd;
  3639. huffmanInput.position = bitmapEnd;
  3640. }
  3641. var numberOfSymbolsDecoded = symbolWidths.length;
  3642. if (firstSymbol === numberOfSymbolsDecoded - 1) {
  3643. newSymbols.push(collectiveBitmap);
  3644. } else {
  3645. var _i = void 0,
  3646. y = void 0,
  3647. xMin = 0,
  3648. xMax = void 0,
  3649. bitmapWidth = void 0,
  3650. symbolBitmap = void 0;
  3651. for (_i = firstSymbol; _i < numberOfSymbolsDecoded; _i++) {
  3652. bitmapWidth = symbolWidths[_i];
  3653. xMax = xMin + bitmapWidth;
  3654. symbolBitmap = [];
  3655. for (y = 0; y < currentHeight; y++) {
  3656. symbolBitmap.push(collectiveBitmap[y].subarray(xMin, xMax));
  3657. }
  3658. newSymbols.push(symbolBitmap);
  3659. xMin = xMax;
  3660. }
  3661. }
  3662. }
  3663. }
  3664. var exportedSymbols = [],
  3665. flags = [];
  3666. var currentFlag = false,
  3667. i,
  3668. ii;
  3669. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  3670. while (flags.length < totalSymbolsLength) {
  3671. var runLength = huffman ? tableB1.decode(huffmanInput) : decodeInteger(contextCache, "IAEX", decoder);
  3672. while (runLength--) {
  3673. flags.push(currentFlag);
  3674. }
  3675. currentFlag = !currentFlag;
  3676. }
  3677. for (i = 0, ii = symbols.length; i < ii; i++) {
  3678. if (flags[i]) {
  3679. exportedSymbols.push(symbols[i]);
  3680. }
  3681. }
  3682. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  3683. if (flags[i]) {
  3684. exportedSymbols.push(newSymbols[j]);
  3685. }
  3686. }
  3687. return exportedSymbols;
  3688. }
  3689. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext, logStripSize, huffmanInput) {
  3690. if (huffman && refinement) {
  3691. throw new Jbig2Error("refinement with Huffman is not supported");
  3692. }
  3693. var bitmap = [];
  3694. var i, row;
  3695. for (i = 0; i < height; i++) {
  3696. row = new Uint8Array(width);
  3697. if (defaultPixelValue) {
  3698. for (var j = 0; j < width; j++) {
  3699. row[j] = defaultPixelValue;
  3700. }
  3701. }
  3702. bitmap.push(row);
  3703. }
  3704. var decoder = decodingContext.decoder;
  3705. var contextCache = decodingContext.contextCache;
  3706. var stripT = huffman ? -huffmanTables.tableDeltaT.decode(huffmanInput) : -decodeInteger(contextCache, "IADT", decoder);
  3707. var firstS = 0;
  3708. i = 0;
  3709. while (i < numberOfSymbolInstances) {
  3710. var deltaT = huffman ? huffmanTables.tableDeltaT.decode(huffmanInput) : decodeInteger(contextCache, "IADT", decoder);
  3711. stripT += deltaT;
  3712. var deltaFirstS = huffman ? huffmanTables.tableFirstS.decode(huffmanInput) : decodeInteger(contextCache, "IAFS", decoder);
  3713. firstS += deltaFirstS;
  3714. var currentS = firstS;
  3715. do {
  3716. var currentT = 0;
  3717. if (stripSize > 1) {
  3718. currentT = huffman ? huffmanInput.readBits(logStripSize) : decodeInteger(contextCache, "IAIT", decoder);
  3719. }
  3720. var t = stripSize * stripT + currentT;
  3721. var symbolId = huffman ? huffmanTables.symbolIDTable.decode(huffmanInput) : decodeIAID(contextCache, decoder, symbolCodeLength);
  3722. var applyRefinement = refinement && (huffman ? huffmanInput.readBit() : decodeInteger(contextCache, "IARI", decoder));
  3723. var symbolBitmap = inputSymbols[symbolId];
  3724. var symbolWidth = symbolBitmap[0].length;
  3725. var symbolHeight = symbolBitmap.length;
  3726. if (applyRefinement) {
  3727. var rdw = decodeInteger(contextCache, "IARDW", decoder);
  3728. var rdh = decodeInteger(contextCache, "IARDH", decoder);
  3729. var rdx = decodeInteger(contextCache, "IARDX", decoder);
  3730. var rdy = decodeInteger(contextCache, "IARDY", decoder);
  3731. symbolWidth += rdw;
  3732. symbolHeight += rdh;
  3733. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  3734. }
  3735. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight - 1);
  3736. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth - 1 : 0);
  3737. var s2 = void 0,
  3738. t2 = void 0,
  3739. symbolRow = void 0;
  3740. if (transposed) {
  3741. for (s2 = 0; s2 < symbolHeight; s2++) {
  3742. row = bitmap[offsetS + s2];
  3743. if (!row) {
  3744. continue;
  3745. }
  3746. symbolRow = symbolBitmap[s2];
  3747. var maxWidth = Math.min(width - offsetT, symbolWidth);
  3748. switch (combinationOperator) {
  3749. case 0:
  3750. for (t2 = 0; t2 < maxWidth; t2++) {
  3751. row[offsetT + t2] |= symbolRow[t2];
  3752. }
  3753. break;
  3754. case 2:
  3755. for (t2 = 0; t2 < maxWidth; t2++) {
  3756. row[offsetT + t2] ^= symbolRow[t2];
  3757. }
  3758. break;
  3759. default:
  3760. throw new Jbig2Error("operator ".concat(combinationOperator, " is not supported"));
  3761. }
  3762. }
  3763. currentS += symbolHeight - 1;
  3764. } else {
  3765. for (t2 = 0; t2 < symbolHeight; t2++) {
  3766. row = bitmap[offsetT + t2];
  3767. if (!row) {
  3768. continue;
  3769. }
  3770. symbolRow = symbolBitmap[t2];
  3771. switch (combinationOperator) {
  3772. case 0:
  3773. for (s2 = 0; s2 < symbolWidth; s2++) {
  3774. row[offsetS + s2] |= symbolRow[s2];
  3775. }
  3776. break;
  3777. case 2:
  3778. for (s2 = 0; s2 < symbolWidth; s2++) {
  3779. row[offsetS + s2] ^= symbolRow[s2];
  3780. }
  3781. break;
  3782. default:
  3783. throw new Jbig2Error("operator ".concat(combinationOperator, " is not supported"));
  3784. }
  3785. }
  3786. currentS += symbolWidth - 1;
  3787. }
  3788. i++;
  3789. var deltaS = huffman ? huffmanTables.tableDeltaS.decode(huffmanInput) : decodeInteger(contextCache, "IADS", decoder);
  3790. if (deltaS === null) {
  3791. break;
  3792. }
  3793. currentS += deltaS + dsOffset;
  3794. } while (true);
  3795. }
  3796. return bitmap;
  3797. }
  3798. function decodePatternDictionary(mmr, patternWidth, patternHeight, maxPatternIndex, template, decodingContext) {
  3799. var at = [];
  3800. if (!mmr) {
  3801. at.push({
  3802. x: -patternWidth,
  3803. y: 0
  3804. });
  3805. if (template === 0) {
  3806. at.push({
  3807. x: -3,
  3808. y: -1
  3809. }, {
  3810. x: 2,
  3811. y: -2
  3812. }, {
  3813. x: -2,
  3814. y: -2
  3815. });
  3816. }
  3817. }
  3818. var collectiveWidth = (maxPatternIndex + 1) * patternWidth;
  3819. var collectiveBitmap = decodeBitmap(mmr, collectiveWidth, patternHeight, template, false, null, at, decodingContext);
  3820. var patterns = [];
  3821. for (var i = 0; i <= maxPatternIndex; i++) {
  3822. var patternBitmap = [];
  3823. var xMin = patternWidth * i;
  3824. var xMax = xMin + patternWidth;
  3825. for (var y = 0; y < patternHeight; y++) {
  3826. patternBitmap.push(collectiveBitmap[y].subarray(xMin, xMax));
  3827. }
  3828. patterns.push(patternBitmap);
  3829. }
  3830. return patterns;
  3831. }
  3832. function decodeHalftoneRegion(mmr, patterns, template, regionWidth, regionHeight, defaultPixelValue, enableSkip, combinationOperator, gridWidth, gridHeight, gridOffsetX, gridOffsetY, gridVectorX, gridVectorY, decodingContext) {
  3833. var skip = null;
  3834. if (enableSkip) {
  3835. throw new Jbig2Error("skip is not supported");
  3836. }
  3837. if (combinationOperator !== 0) {
  3838. throw new Jbig2Error("operator \"".concat(combinationOperator, "\" is not supported in halftone region"));
  3839. }
  3840. var regionBitmap = [];
  3841. var i, j, row;
  3842. for (i = 0; i < regionHeight; i++) {
  3843. row = new Uint8Array(regionWidth);
  3844. if (defaultPixelValue) {
  3845. for (j = 0; j < regionWidth; j++) {
  3846. row[j] = defaultPixelValue;
  3847. }
  3848. }
  3849. regionBitmap.push(row);
  3850. }
  3851. var numberOfPatterns = patterns.length;
  3852. var pattern0 = patterns[0];
  3853. var patternWidth = pattern0[0].length,
  3854. patternHeight = pattern0.length;
  3855. var bitsPerValue = (0, _core_utils.log2)(numberOfPatterns);
  3856. var at = [];
  3857. if (!mmr) {
  3858. at.push({
  3859. x: template <= 1 ? 3 : 2,
  3860. y: -1
  3861. });
  3862. if (template === 0) {
  3863. at.push({
  3864. x: -3,
  3865. y: -1
  3866. }, {
  3867. x: 2,
  3868. y: -2
  3869. }, {
  3870. x: -2,
  3871. y: -2
  3872. });
  3873. }
  3874. }
  3875. var grayScaleBitPlanes = [];
  3876. var mmrInput, bitmap;
  3877. if (mmr) {
  3878. mmrInput = new Reader(decodingContext.data, decodingContext.start, decodingContext.end);
  3879. }
  3880. for (i = bitsPerValue - 1; i >= 0; i--) {
  3881. if (mmr) {
  3882. bitmap = decodeMMRBitmap(mmrInput, gridWidth, gridHeight, true);
  3883. } else {
  3884. bitmap = decodeBitmap(false, gridWidth, gridHeight, template, false, skip, at, decodingContext);
  3885. }
  3886. grayScaleBitPlanes[i] = bitmap;
  3887. }
  3888. var mg, ng, bit, patternIndex, patternBitmap, x, y, patternRow, regionRow;
  3889. for (mg = 0; mg < gridHeight; mg++) {
  3890. for (ng = 0; ng < gridWidth; ng++) {
  3891. bit = 0;
  3892. patternIndex = 0;
  3893. for (j = bitsPerValue - 1; j >= 0; j--) {
  3894. bit ^= grayScaleBitPlanes[j][mg][ng];
  3895. patternIndex |= bit << j;
  3896. }
  3897. patternBitmap = patterns[patternIndex];
  3898. x = gridOffsetX + mg * gridVectorY + ng * gridVectorX >> 8;
  3899. y = gridOffsetY + mg * gridVectorX - ng * gridVectorY >> 8;
  3900. if (x >= 0 && x + patternWidth <= regionWidth && y >= 0 && y + patternHeight <= regionHeight) {
  3901. for (i = 0; i < patternHeight; i++) {
  3902. regionRow = regionBitmap[y + i];
  3903. patternRow = patternBitmap[i];
  3904. for (j = 0; j < patternWidth; j++) {
  3905. regionRow[x + j] |= patternRow[j];
  3906. }
  3907. }
  3908. } else {
  3909. var regionX = void 0,
  3910. regionY = void 0;
  3911. for (i = 0; i < patternHeight; i++) {
  3912. regionY = y + i;
  3913. if (regionY < 0 || regionY >= regionHeight) {
  3914. continue;
  3915. }
  3916. regionRow = regionBitmap[regionY];
  3917. patternRow = patternBitmap[i];
  3918. for (j = 0; j < patternWidth; j++) {
  3919. regionX = x + j;
  3920. if (regionX >= 0 && regionX < regionWidth) {
  3921. regionRow[regionX] |= patternRow[j];
  3922. }
  3923. }
  3924. }
  3925. }
  3926. }
  3927. }
  3928. return regionBitmap;
  3929. }
  3930. function readSegmentHeader(data, start) {
  3931. var segmentHeader = {};
  3932. segmentHeader.number = (0, _core_utils.readUint32)(data, start);
  3933. var flags = data[start + 4];
  3934. var segmentType = flags & 0x3f;
  3935. if (!SegmentTypes[segmentType]) {
  3936. throw new Jbig2Error("invalid segment type: " + segmentType);
  3937. }
  3938. segmentHeader.type = segmentType;
  3939. segmentHeader.typeName = SegmentTypes[segmentType];
  3940. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  3941. var pageAssociationFieldSize = !!(flags & 0x40);
  3942. var referredFlags = data[start + 5];
  3943. var referredToCount = referredFlags >> 5 & 7;
  3944. var retainBits = [referredFlags & 31];
  3945. var position = start + 6;
  3946. if (referredFlags === 7) {
  3947. referredToCount = (0, _core_utils.readUint32)(data, position - 1) & 0x1fffffff;
  3948. position += 3;
  3949. var bytes = referredToCount + 7 >> 3;
  3950. retainBits[0] = data[position++];
  3951. while (--bytes > 0) {
  3952. retainBits.push(data[position++]);
  3953. }
  3954. } else if (referredFlags === 5 || referredFlags === 6) {
  3955. throw new Jbig2Error("invalid referred-to flags");
  3956. }
  3957. segmentHeader.retainBits = retainBits;
  3958. var referredToSegmentNumberSize = 4;
  3959. if (segmentHeader.number <= 256) {
  3960. referredToSegmentNumberSize = 1;
  3961. } else if (segmentHeader.number <= 65536) {
  3962. referredToSegmentNumberSize = 2;
  3963. }
  3964. var referredTo = [];
  3965. var i, ii;
  3966. for (i = 0; i < referredToCount; i++) {
  3967. var number = void 0;
  3968. if (referredToSegmentNumberSize === 1) {
  3969. number = data[position];
  3970. } else if (referredToSegmentNumberSize === 2) {
  3971. number = (0, _core_utils.readUint16)(data, position);
  3972. } else {
  3973. number = (0, _core_utils.readUint32)(data, position);
  3974. }
  3975. referredTo.push(number);
  3976. position += referredToSegmentNumberSize;
  3977. }
  3978. segmentHeader.referredTo = referredTo;
  3979. if (!pageAssociationFieldSize) {
  3980. segmentHeader.pageAssociation = data[position++];
  3981. } else {
  3982. segmentHeader.pageAssociation = (0, _core_utils.readUint32)(data, position);
  3983. position += 4;
  3984. }
  3985. segmentHeader.length = (0, _core_utils.readUint32)(data, position);
  3986. position += 4;
  3987. if (segmentHeader.length === 0xffffffff) {
  3988. if (segmentType === 38) {
  3989. var genericRegionInfo = readRegionSegmentInformation(data, position);
  3990. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  3991. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  3992. var searchPatternLength = 6;
  3993. var searchPattern = new Uint8Array(searchPatternLength);
  3994. if (!genericRegionMmr) {
  3995. searchPattern[0] = 0xff;
  3996. searchPattern[1] = 0xac;
  3997. }
  3998. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xff;
  3999. searchPattern[3] = genericRegionInfo.height >> 16 & 0xff;
  4000. searchPattern[4] = genericRegionInfo.height >> 8 & 0xff;
  4001. searchPattern[5] = genericRegionInfo.height & 0xff;
  4002. for (i = position, ii = data.length; i < ii; i++) {
  4003. var j = 0;
  4004. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  4005. j++;
  4006. }
  4007. if (j === searchPatternLength) {
  4008. segmentHeader.length = i + searchPatternLength;
  4009. break;
  4010. }
  4011. }
  4012. if (segmentHeader.length === 0xffffffff) {
  4013. throw new Jbig2Error("segment end was not found");
  4014. }
  4015. } else {
  4016. throw new Jbig2Error("invalid unknown segment length");
  4017. }
  4018. }
  4019. segmentHeader.headerEnd = position;
  4020. return segmentHeader;
  4021. }
  4022. function readSegments(header, data, start, end) {
  4023. var segments = [];
  4024. var position = start;
  4025. while (position < end) {
  4026. var segmentHeader = readSegmentHeader(data, position);
  4027. position = segmentHeader.headerEnd;
  4028. var segment = {
  4029. header: segmentHeader,
  4030. data: data
  4031. };
  4032. if (!header.randomAccess) {
  4033. segment.start = position;
  4034. position += segmentHeader.length;
  4035. segment.end = position;
  4036. }
  4037. segments.push(segment);
  4038. if (segmentHeader.type === 51) {
  4039. break;
  4040. }
  4041. }
  4042. if (header.randomAccess) {
  4043. for (var i = 0, ii = segments.length; i < ii; i++) {
  4044. segments[i].start = position;
  4045. position += segments[i].header.length;
  4046. segments[i].end = position;
  4047. }
  4048. }
  4049. return segments;
  4050. }
  4051. function readRegionSegmentInformation(data, start) {
  4052. return {
  4053. width: (0, _core_utils.readUint32)(data, start),
  4054. height: (0, _core_utils.readUint32)(data, start + 4),
  4055. x: (0, _core_utils.readUint32)(data, start + 8),
  4056. y: (0, _core_utils.readUint32)(data, start + 12),
  4057. combinationOperator: data[start + 16] & 7
  4058. };
  4059. }
  4060. var RegionSegmentInformationFieldLength = 17;
  4061. function processSegment(segment, visitor) {
  4062. var header = segment.header;
  4063. var data = segment.data,
  4064. end = segment.end;
  4065. var position = segment.start;
  4066. var args, at, i, atLength;
  4067. switch (header.type) {
  4068. case 0:
  4069. var dictionary = {};
  4070. var dictionaryFlags = (0, _core_utils.readUint16)(data, position);
  4071. dictionary.huffman = !!(dictionaryFlags & 1);
  4072. dictionary.refinement = !!(dictionaryFlags & 2);
  4073. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  4074. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  4075. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  4076. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  4077. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  4078. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  4079. dictionary.template = dictionaryFlags >> 10 & 3;
  4080. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  4081. position += 2;
  4082. if (!dictionary.huffman) {
  4083. atLength = dictionary.template === 0 ? 4 : 1;
  4084. at = [];
  4085. for (i = 0; i < atLength; i++) {
  4086. at.push({
  4087. x: (0, _core_utils.readInt8)(data, position),
  4088. y: (0, _core_utils.readInt8)(data, position + 1)
  4089. });
  4090. position += 2;
  4091. }
  4092. dictionary.at = at;
  4093. }
  4094. if (dictionary.refinement && !dictionary.refinementTemplate) {
  4095. at = [];
  4096. for (i = 0; i < 2; i++) {
  4097. at.push({
  4098. x: (0, _core_utils.readInt8)(data, position),
  4099. y: (0, _core_utils.readInt8)(data, position + 1)
  4100. });
  4101. position += 2;
  4102. }
  4103. dictionary.refinementAt = at;
  4104. }
  4105. dictionary.numberOfExportedSymbols = (0, _core_utils.readUint32)(data, position);
  4106. position += 4;
  4107. dictionary.numberOfNewSymbols = (0, _core_utils.readUint32)(data, position);
  4108. position += 4;
  4109. args = [dictionary, header.number, header.referredTo, data, position, end];
  4110. break;
  4111. case 6:
  4112. case 7:
  4113. var textRegion = {};
  4114. textRegion.info = readRegionSegmentInformation(data, position);
  4115. position += RegionSegmentInformationFieldLength;
  4116. var textRegionSegmentFlags = (0, _core_utils.readUint16)(data, position);
  4117. position += 2;
  4118. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  4119. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  4120. textRegion.logStripSize = textRegionSegmentFlags >> 2 & 3;
  4121. textRegion.stripSize = 1 << textRegion.logStripSize;
  4122. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  4123. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  4124. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  4125. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  4126. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  4127. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  4128. if (textRegion.huffman) {
  4129. var textRegionHuffmanFlags = (0, _core_utils.readUint16)(data, position);
  4130. position += 2;
  4131. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  4132. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  4133. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  4134. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  4135. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  4136. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  4137. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  4138. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 0x4000);
  4139. }
  4140. if (textRegion.refinement && !textRegion.refinementTemplate) {
  4141. at = [];
  4142. for (i = 0; i < 2; i++) {
  4143. at.push({
  4144. x: (0, _core_utils.readInt8)(data, position),
  4145. y: (0, _core_utils.readInt8)(data, position + 1)
  4146. });
  4147. position += 2;
  4148. }
  4149. textRegion.refinementAt = at;
  4150. }
  4151. textRegion.numberOfSymbolInstances = (0, _core_utils.readUint32)(data, position);
  4152. position += 4;
  4153. args = [textRegion, header.referredTo, data, position, end];
  4154. break;
  4155. case 16:
  4156. var patternDictionary = {};
  4157. var patternDictionaryFlags = data[position++];
  4158. patternDictionary.mmr = !!(patternDictionaryFlags & 1);
  4159. patternDictionary.template = patternDictionaryFlags >> 1 & 3;
  4160. patternDictionary.patternWidth = data[position++];
  4161. patternDictionary.patternHeight = data[position++];
  4162. patternDictionary.maxPatternIndex = (0, _core_utils.readUint32)(data, position);
  4163. position += 4;
  4164. args = [patternDictionary, header.number, data, position, end];
  4165. break;
  4166. case 22:
  4167. case 23:
  4168. var halftoneRegion = {};
  4169. halftoneRegion.info = readRegionSegmentInformation(data, position);
  4170. position += RegionSegmentInformationFieldLength;
  4171. var halftoneRegionFlags = data[position++];
  4172. halftoneRegion.mmr = !!(halftoneRegionFlags & 1);
  4173. halftoneRegion.template = halftoneRegionFlags >> 1 & 3;
  4174. halftoneRegion.enableSkip = !!(halftoneRegionFlags & 8);
  4175. halftoneRegion.combinationOperator = halftoneRegionFlags >> 4 & 7;
  4176. halftoneRegion.defaultPixelValue = halftoneRegionFlags >> 7 & 1;
  4177. halftoneRegion.gridWidth = (0, _core_utils.readUint32)(data, position);
  4178. position += 4;
  4179. halftoneRegion.gridHeight = (0, _core_utils.readUint32)(data, position);
  4180. position += 4;
  4181. halftoneRegion.gridOffsetX = (0, _core_utils.readUint32)(data, position) & 0xffffffff;
  4182. position += 4;
  4183. halftoneRegion.gridOffsetY = (0, _core_utils.readUint32)(data, position) & 0xffffffff;
  4184. position += 4;
  4185. halftoneRegion.gridVectorX = (0, _core_utils.readUint16)(data, position);
  4186. position += 2;
  4187. halftoneRegion.gridVectorY = (0, _core_utils.readUint16)(data, position);
  4188. position += 2;
  4189. args = [halftoneRegion, header.referredTo, data, position, end];
  4190. break;
  4191. case 38:
  4192. case 39:
  4193. var genericRegion = {};
  4194. genericRegion.info = readRegionSegmentInformation(data, position);
  4195. position += RegionSegmentInformationFieldLength;
  4196. var genericRegionSegmentFlags = data[position++];
  4197. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  4198. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  4199. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  4200. if (!genericRegion.mmr) {
  4201. atLength = genericRegion.template === 0 ? 4 : 1;
  4202. at = [];
  4203. for (i = 0; i < atLength; i++) {
  4204. at.push({
  4205. x: (0, _core_utils.readInt8)(data, position),
  4206. y: (0, _core_utils.readInt8)(data, position + 1)
  4207. });
  4208. position += 2;
  4209. }
  4210. genericRegion.at = at;
  4211. }
  4212. args = [genericRegion, data, position, end];
  4213. break;
  4214. case 48:
  4215. var pageInfo = {
  4216. width: (0, _core_utils.readUint32)(data, position),
  4217. height: (0, _core_utils.readUint32)(data, position + 4),
  4218. resolutionX: (0, _core_utils.readUint32)(data, position + 8),
  4219. resolutionY: (0, _core_utils.readUint32)(data, position + 12)
  4220. };
  4221. if (pageInfo.height === 0xffffffff) {
  4222. delete pageInfo.height;
  4223. }
  4224. var pageSegmentFlags = data[position + 16];
  4225. (0, _core_utils.readUint16)(data, position + 17);
  4226. pageInfo.lossless = !!(pageSegmentFlags & 1);
  4227. pageInfo.refinement = !!(pageSegmentFlags & 2);
  4228. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  4229. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  4230. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  4231. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  4232. args = [pageInfo];
  4233. break;
  4234. case 49:
  4235. break;
  4236. case 50:
  4237. break;
  4238. case 51:
  4239. break;
  4240. case 53:
  4241. args = [header.number, data, position, end];
  4242. break;
  4243. case 62:
  4244. break;
  4245. default:
  4246. throw new Jbig2Error("segment type ".concat(header.typeName, "(").concat(header.type, ")") + " is not implemented");
  4247. }
  4248. var callbackName = "on" + header.typeName;
  4249. if (callbackName in visitor) {
  4250. visitor[callbackName].apply(visitor, args);
  4251. }
  4252. }
  4253. function processSegments(segments, visitor) {
  4254. for (var i = 0, ii = segments.length; i < ii; i++) {
  4255. processSegment(segments[i], visitor);
  4256. }
  4257. }
  4258. function parseJbig2Chunks(chunks) {
  4259. var visitor = new SimpleSegmentVisitor();
  4260. for (var i = 0, ii = chunks.length; i < ii; i++) {
  4261. var chunk = chunks[i];
  4262. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  4263. processSegments(segments, visitor);
  4264. }
  4265. return visitor.buffer;
  4266. }
  4267. function parseJbig2(data) {
  4268. var end = data.length;
  4269. var position = 0;
  4270. if (data[position] !== 0x97 || data[position + 1] !== 0x4a || data[position + 2] !== 0x42 || data[position + 3] !== 0x32 || data[position + 4] !== 0x0d || data[position + 5] !== 0x0a || data[position + 6] !== 0x1a || data[position + 7] !== 0x0a) {
  4271. throw new Jbig2Error("parseJbig2 - invalid header.");
  4272. }
  4273. var header = Object.create(null);
  4274. position += 8;
  4275. var flags = data[position++];
  4276. header.randomAccess = !(flags & 1);
  4277. if (!(flags & 2)) {
  4278. header.numberOfPages = (0, _core_utils.readUint32)(data, position);
  4279. position += 4;
  4280. }
  4281. var segments = readSegments(header, data, position, end);
  4282. var visitor = new SimpleSegmentVisitor();
  4283. processSegments(segments, visitor);
  4284. var _visitor$currentPageI = visitor.currentPageInfo,
  4285. width = _visitor$currentPageI.width,
  4286. height = _visitor$currentPageI.height;
  4287. var bitPacked = visitor.buffer;
  4288. var imgData = new Uint8ClampedArray(width * height);
  4289. var q = 0,
  4290. k = 0;
  4291. for (var i = 0; i < height; i++) {
  4292. var mask = 0,
  4293. buffer = void 0;
  4294. for (var j = 0; j < width; j++) {
  4295. if (!mask) {
  4296. mask = 128;
  4297. buffer = bitPacked[k++];
  4298. }
  4299. imgData[q++] = buffer & mask ? 0 : 255;
  4300. mask >>= 1;
  4301. }
  4302. }
  4303. return {
  4304. imgData: imgData,
  4305. width: width,
  4306. height: height
  4307. };
  4308. }
  4309. var SimpleSegmentVisitor = /*#__PURE__*/function () {
  4310. function SimpleSegmentVisitor() {
  4311. _classCallCheck(this, SimpleSegmentVisitor);
  4312. }
  4313. _createClass(SimpleSegmentVisitor, [{
  4314. key: "onPageInformation",
  4315. value: function onPageInformation(info) {
  4316. this.currentPageInfo = info;
  4317. var rowSize = info.width + 7 >> 3;
  4318. var buffer = new Uint8ClampedArray(rowSize * info.height);
  4319. if (info.defaultPixelValue) {
  4320. for (var i = 0, ii = buffer.length; i < ii; i++) {
  4321. buffer[i] = 0xff;
  4322. }
  4323. }
  4324. this.buffer = buffer;
  4325. }
  4326. }, {
  4327. key: "drawBitmap",
  4328. value: function drawBitmap(regionInfo, bitmap) {
  4329. var pageInfo = this.currentPageInfo;
  4330. var width = regionInfo.width,
  4331. height = regionInfo.height;
  4332. var rowSize = pageInfo.width + 7 >> 3;
  4333. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  4334. var buffer = this.buffer;
  4335. var mask0 = 128 >> (regionInfo.x & 7);
  4336. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  4337. var i, j, mask, offset;
  4338. switch (combinationOperator) {
  4339. case 0:
  4340. for (i = 0; i < height; i++) {
  4341. mask = mask0;
  4342. offset = offset0;
  4343. for (j = 0; j < width; j++) {
  4344. if (bitmap[i][j]) {
  4345. buffer[offset] |= mask;
  4346. }
  4347. mask >>= 1;
  4348. if (!mask) {
  4349. mask = 128;
  4350. offset++;
  4351. }
  4352. }
  4353. offset0 += rowSize;
  4354. }
  4355. break;
  4356. case 2:
  4357. for (i = 0; i < height; i++) {
  4358. mask = mask0;
  4359. offset = offset0;
  4360. for (j = 0; j < width; j++) {
  4361. if (bitmap[i][j]) {
  4362. buffer[offset] ^= mask;
  4363. }
  4364. mask >>= 1;
  4365. if (!mask) {
  4366. mask = 128;
  4367. offset++;
  4368. }
  4369. }
  4370. offset0 += rowSize;
  4371. }
  4372. break;
  4373. default:
  4374. throw new Jbig2Error("operator ".concat(combinationOperator, " is not supported"));
  4375. }
  4376. }
  4377. }, {
  4378. key: "onImmediateGenericRegion",
  4379. value: function onImmediateGenericRegion(region, data, start, end) {
  4380. var regionInfo = region.info;
  4381. var decodingContext = new DecodingContext(data, start, end);
  4382. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  4383. this.drawBitmap(regionInfo, bitmap);
  4384. }
  4385. }, {
  4386. key: "onImmediateLosslessGenericRegion",
  4387. value: function onImmediateLosslessGenericRegion() {
  4388. this.onImmediateGenericRegion.apply(this, arguments);
  4389. }
  4390. }, {
  4391. key: "onSymbolDictionary",
  4392. value: function onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  4393. var huffmanTables, huffmanInput;
  4394. if (dictionary.huffman) {
  4395. huffmanTables = getSymbolDictionaryHuffmanTables(dictionary, referredSegments, this.customTables);
  4396. huffmanInput = new Reader(data, start, end);
  4397. }
  4398. var symbols = this.symbols;
  4399. if (!symbols) {
  4400. this.symbols = symbols = {};
  4401. }
  4402. var inputSymbols = [];
  4403. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  4404. var referredSymbols = symbols[referredSegments[i]];
  4405. if (referredSymbols) {
  4406. inputSymbols = inputSymbols.concat(referredSymbols);
  4407. }
  4408. }
  4409. var decodingContext = new DecodingContext(data, start, end);
  4410. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext, huffmanInput);
  4411. }
  4412. }, {
  4413. key: "onImmediateTextRegion",
  4414. value: function onImmediateTextRegion(region, referredSegments, data, start, end) {
  4415. var regionInfo = region.info;
  4416. var huffmanTables, huffmanInput;
  4417. var symbols = this.symbols;
  4418. var inputSymbols = [];
  4419. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  4420. var referredSymbols = symbols[referredSegments[i]];
  4421. if (referredSymbols) {
  4422. inputSymbols = inputSymbols.concat(referredSymbols);
  4423. }
  4424. }
  4425. var symbolCodeLength = (0, _core_utils.log2)(inputSymbols.length);
  4426. if (region.huffman) {
  4427. huffmanInput = new Reader(data, start, end);
  4428. huffmanTables = getTextRegionHuffmanTables(region, referredSegments, this.customTables, inputSymbols.length, huffmanInput);
  4429. }
  4430. var decodingContext = new DecodingContext(data, start, end);
  4431. var bitmap = decodeTextRegion(region.huffman, region.refinement, regionInfo.width, regionInfo.height, region.defaultPixelValue, region.numberOfSymbolInstances, region.stripSize, inputSymbols, symbolCodeLength, region.transposed, region.dsOffset, region.referenceCorner, region.combinationOperator, huffmanTables, region.refinementTemplate, region.refinementAt, decodingContext, region.logStripSize, huffmanInput);
  4432. this.drawBitmap(regionInfo, bitmap);
  4433. }
  4434. }, {
  4435. key: "onImmediateLosslessTextRegion",
  4436. value: function onImmediateLosslessTextRegion() {
  4437. this.onImmediateTextRegion.apply(this, arguments);
  4438. }
  4439. }, {
  4440. key: "onPatternDictionary",
  4441. value: function onPatternDictionary(dictionary, currentSegment, data, start, end) {
  4442. var patterns = this.patterns;
  4443. if (!patterns) {
  4444. this.patterns = patterns = {};
  4445. }
  4446. var decodingContext = new DecodingContext(data, start, end);
  4447. patterns[currentSegment] = decodePatternDictionary(dictionary.mmr, dictionary.patternWidth, dictionary.patternHeight, dictionary.maxPatternIndex, dictionary.template, decodingContext);
  4448. }
  4449. }, {
  4450. key: "onImmediateHalftoneRegion",
  4451. value: function onImmediateHalftoneRegion(region, referredSegments, data, start, end) {
  4452. var patterns = this.patterns[referredSegments[0]];
  4453. var regionInfo = region.info;
  4454. var decodingContext = new DecodingContext(data, start, end);
  4455. var bitmap = decodeHalftoneRegion(region.mmr, patterns, region.template, regionInfo.width, regionInfo.height, region.defaultPixelValue, region.enableSkip, region.combinationOperator, region.gridWidth, region.gridHeight, region.gridOffsetX, region.gridOffsetY, region.gridVectorX, region.gridVectorY, decodingContext);
  4456. this.drawBitmap(regionInfo, bitmap);
  4457. }
  4458. }, {
  4459. key: "onImmediateLosslessHalftoneRegion",
  4460. value: function onImmediateLosslessHalftoneRegion() {
  4461. this.onImmediateHalftoneRegion.apply(this, arguments);
  4462. }
  4463. }, {
  4464. key: "onTables",
  4465. value: function onTables(currentSegment, data, start, end) {
  4466. var customTables = this.customTables;
  4467. if (!customTables) {
  4468. this.customTables = customTables = {};
  4469. }
  4470. customTables[currentSegment] = decodeTablesSegment(data, start, end);
  4471. }
  4472. }]);
  4473. return SimpleSegmentVisitor;
  4474. }();
  4475. var HuffmanLine = function HuffmanLine(lineData) {
  4476. _classCallCheck(this, HuffmanLine);
  4477. if (lineData.length === 2) {
  4478. this.isOOB = true;
  4479. this.rangeLow = 0;
  4480. this.prefixLength = lineData[0];
  4481. this.rangeLength = 0;
  4482. this.prefixCode = lineData[1];
  4483. this.isLowerRange = false;
  4484. } else {
  4485. this.isOOB = false;
  4486. this.rangeLow = lineData[0];
  4487. this.prefixLength = lineData[1];
  4488. this.rangeLength = lineData[2];
  4489. this.prefixCode = lineData[3];
  4490. this.isLowerRange = lineData[4] === "lower";
  4491. }
  4492. };
  4493. var HuffmanTreeNode = /*#__PURE__*/function () {
  4494. function HuffmanTreeNode(line) {
  4495. _classCallCheck(this, HuffmanTreeNode);
  4496. this.children = [];
  4497. if (line) {
  4498. this.isLeaf = true;
  4499. this.rangeLength = line.rangeLength;
  4500. this.rangeLow = line.rangeLow;
  4501. this.isLowerRange = line.isLowerRange;
  4502. this.isOOB = line.isOOB;
  4503. } else {
  4504. this.isLeaf = false;
  4505. }
  4506. }
  4507. _createClass(HuffmanTreeNode, [{
  4508. key: "buildTree",
  4509. value: function buildTree(line, shift) {
  4510. var bit = line.prefixCode >> shift & 1;
  4511. if (shift <= 0) {
  4512. this.children[bit] = new HuffmanTreeNode(line);
  4513. } else {
  4514. var node = this.children[bit];
  4515. if (!node) {
  4516. this.children[bit] = node = new HuffmanTreeNode(null);
  4517. }
  4518. node.buildTree(line, shift - 1);
  4519. }
  4520. }
  4521. }, {
  4522. key: "decodeNode",
  4523. value: function decodeNode(reader) {
  4524. if (this.isLeaf) {
  4525. if (this.isOOB) {
  4526. return null;
  4527. }
  4528. var htOffset = reader.readBits(this.rangeLength);
  4529. return this.rangeLow + (this.isLowerRange ? -htOffset : htOffset);
  4530. }
  4531. var node = this.children[reader.readBit()];
  4532. if (!node) {
  4533. throw new Jbig2Error("invalid Huffman data");
  4534. }
  4535. return node.decodeNode(reader);
  4536. }
  4537. }]);
  4538. return HuffmanTreeNode;
  4539. }();
  4540. var HuffmanTable = /*#__PURE__*/function () {
  4541. function HuffmanTable(lines, prefixCodesDone) {
  4542. _classCallCheck(this, HuffmanTable);
  4543. if (!prefixCodesDone) {
  4544. this.assignPrefixCodes(lines);
  4545. }
  4546. this.rootNode = new HuffmanTreeNode(null);
  4547. for (var i = 0, ii = lines.length; i < ii; i++) {
  4548. var line = lines[i];
  4549. if (line.prefixLength > 0) {
  4550. this.rootNode.buildTree(line, line.prefixLength - 1);
  4551. }
  4552. }
  4553. }
  4554. _createClass(HuffmanTable, [{
  4555. key: "decode",
  4556. value: function decode(reader) {
  4557. return this.rootNode.decodeNode(reader);
  4558. }
  4559. }, {
  4560. key: "assignPrefixCodes",
  4561. value: function assignPrefixCodes(lines) {
  4562. var linesLength = lines.length;
  4563. var prefixLengthMax = 0;
  4564. for (var i = 0; i < linesLength; i++) {
  4565. prefixLengthMax = Math.max(prefixLengthMax, lines[i].prefixLength);
  4566. }
  4567. var histogram = new Uint32Array(prefixLengthMax + 1);
  4568. for (var _i2 = 0; _i2 < linesLength; _i2++) {
  4569. histogram[lines[_i2].prefixLength]++;
  4570. }
  4571. var currentLength = 1,
  4572. firstCode = 0,
  4573. currentCode,
  4574. currentTemp,
  4575. line;
  4576. histogram[0] = 0;
  4577. while (currentLength <= prefixLengthMax) {
  4578. firstCode = firstCode + histogram[currentLength - 1] << 1;
  4579. currentCode = firstCode;
  4580. currentTemp = 0;
  4581. while (currentTemp < linesLength) {
  4582. line = lines[currentTemp];
  4583. if (line.prefixLength === currentLength) {
  4584. line.prefixCode = currentCode;
  4585. currentCode++;
  4586. }
  4587. currentTemp++;
  4588. }
  4589. currentLength++;
  4590. }
  4591. }
  4592. }]);
  4593. return HuffmanTable;
  4594. }();
  4595. function decodeTablesSegment(data, start, end) {
  4596. var flags = data[start];
  4597. var lowestValue = (0, _core_utils.readUint32)(data, start + 1) & 0xffffffff;
  4598. var highestValue = (0, _core_utils.readUint32)(data, start + 5) & 0xffffffff;
  4599. var reader = new Reader(data, start + 9, end);
  4600. var prefixSizeBits = (flags >> 1 & 7) + 1;
  4601. var rangeSizeBits = (flags >> 4 & 7) + 1;
  4602. var lines = [];
  4603. var prefixLength,
  4604. rangeLength,
  4605. currentRangeLow = lowestValue;
  4606. do {
  4607. prefixLength = reader.readBits(prefixSizeBits);
  4608. rangeLength = reader.readBits(rangeSizeBits);
  4609. lines.push(new HuffmanLine([currentRangeLow, prefixLength, rangeLength, 0]));
  4610. currentRangeLow += 1 << rangeLength;
  4611. } while (currentRangeLow < highestValue);
  4612. prefixLength = reader.readBits(prefixSizeBits);
  4613. lines.push(new HuffmanLine([lowestValue - 1, prefixLength, 32, 0, "lower"]));
  4614. prefixLength = reader.readBits(prefixSizeBits);
  4615. lines.push(new HuffmanLine([highestValue, prefixLength, 32, 0]));
  4616. if (flags & 1) {
  4617. prefixLength = reader.readBits(prefixSizeBits);
  4618. lines.push(new HuffmanLine([prefixLength, 0]));
  4619. }
  4620. return new HuffmanTable(lines, false);
  4621. }
  4622. var standardTablesCache = {};
  4623. function getStandardTable(number) {
  4624. var table = standardTablesCache[number];
  4625. if (table) {
  4626. return table;
  4627. }
  4628. var lines;
  4629. switch (number) {
  4630. case 1:
  4631. lines = [[0, 1, 4, 0x0], [16, 2, 8, 0x2], [272, 3, 16, 0x6], [65808, 3, 32, 0x7]];
  4632. break;
  4633. case 2:
  4634. lines = [[0, 1, 0, 0x0], [1, 2, 0, 0x2], [2, 3, 0, 0x6], [3, 4, 3, 0xe], [11, 5, 6, 0x1e], [75, 6, 32, 0x3e], [6, 0x3f]];
  4635. break;
  4636. case 3:
  4637. lines = [[-256, 8, 8, 0xfe], [0, 1, 0, 0x0], [1, 2, 0, 0x2], [2, 3, 0, 0x6], [3, 4, 3, 0xe], [11, 5, 6, 0x1e], [-257, 8, 32, 0xff, "lower"], [75, 7, 32, 0x7e], [6, 0x3e]];
  4638. break;
  4639. case 4:
  4640. lines = [[1, 1, 0, 0x0], [2, 2, 0, 0x2], [3, 3, 0, 0x6], [4, 4, 3, 0xe], [12, 5, 6, 0x1e], [76, 5, 32, 0x1f]];
  4641. break;
  4642. case 5:
  4643. lines = [[-255, 7, 8, 0x7e], [1, 1, 0, 0x0], [2, 2, 0, 0x2], [3, 3, 0, 0x6], [4, 4, 3, 0xe], [12, 5, 6, 0x1e], [-256, 7, 32, 0x7f, "lower"], [76, 6, 32, 0x3e]];
  4644. break;
  4645. case 6:
  4646. lines = [[-2048, 5, 10, 0x1c], [-1024, 4, 9, 0x8], [-512, 4, 8, 0x9], [-256, 4, 7, 0xa], [-128, 5, 6, 0x1d], [-64, 5, 5, 0x1e], [-32, 4, 5, 0xb], [0, 2, 7, 0x0], [128, 3, 7, 0x2], [256, 3, 8, 0x3], [512, 4, 9, 0xc], [1024, 4, 10, 0xd], [-2049, 6, 32, 0x3e, "lower"], [2048, 6, 32, 0x3f]];
  4647. break;
  4648. case 7:
  4649. lines = [[-1024, 4, 9, 0x8], [-512, 3, 8, 0x0], [-256, 4, 7, 0x9], [-128, 5, 6, 0x1a], [-64, 5, 5, 0x1b], [-32, 4, 5, 0xa], [0, 4, 5, 0xb], [32, 5, 5, 0x1c], [64, 5, 6, 0x1d], [128, 4, 7, 0xc], [256, 3, 8, 0x1], [512, 3, 9, 0x2], [1024, 3, 10, 0x3], [-1025, 5, 32, 0x1e, "lower"], [2048, 5, 32, 0x1f]];
  4650. break;
  4651. case 8:
  4652. lines = [[-15, 8, 3, 0xfc], [-7, 9, 1, 0x1fc], [-5, 8, 1, 0xfd], [-3, 9, 0, 0x1fd], [-2, 7, 0, 0x7c], [-1, 4, 0, 0xa], [0, 2, 1, 0x0], [2, 5, 0, 0x1a], [3, 6, 0, 0x3a], [4, 3, 4, 0x4], [20, 6, 1, 0x3b], [22, 4, 4, 0xb], [38, 4, 5, 0xc], [70, 5, 6, 0x1b], [134, 5, 7, 0x1c], [262, 6, 7, 0x3c], [390, 7, 8, 0x7d], [646, 6, 10, 0x3d], [-16, 9, 32, 0x1fe, "lower"], [1670, 9, 32, 0x1ff], [2, 0x1]];
  4653. break;
  4654. case 9:
  4655. lines = [[-31, 8, 4, 0xfc], [-15, 9, 2, 0x1fc], [-11, 8, 2, 0xfd], [-7, 9, 1, 0x1fd], [-5, 7, 1, 0x7c], [-3, 4, 1, 0xa], [-1, 3, 1, 0x2], [1, 3, 1, 0x3], [3, 5, 1, 0x1a], [5, 6, 1, 0x3a], [7, 3, 5, 0x4], [39, 6, 2, 0x3b], [43, 4, 5, 0xb], [75, 4, 6, 0xc], [139, 5, 7, 0x1b], [267, 5, 8, 0x1c], [523, 6, 8, 0x3c], [779, 7, 9, 0x7d], [1291, 6, 11, 0x3d], [-32, 9, 32, 0x1fe, "lower"], [3339, 9, 32, 0x1ff], [2, 0x0]];
  4656. break;
  4657. case 10:
  4658. lines = [[-21, 7, 4, 0x7a], [-5, 8, 0, 0xfc], [-4, 7, 0, 0x7b], [-3, 5, 0, 0x18], [-2, 2, 2, 0x0], [2, 5, 0, 0x19], [3, 6, 0, 0x36], [4, 7, 0, 0x7c], [5, 8, 0, 0xfd], [6, 2, 6, 0x1], [70, 5, 5, 0x1a], [102, 6, 5, 0x37], [134, 6, 6, 0x38], [198, 6, 7, 0x39], [326, 6, 8, 0x3a], [582, 6, 9, 0x3b], [1094, 6, 10, 0x3c], [2118, 7, 11, 0x7d], [-22, 8, 32, 0xfe, "lower"], [4166, 8, 32, 0xff], [2, 0x2]];
  4659. break;
  4660. case 11:
  4661. lines = [[1, 1, 0, 0x0], [2, 2, 1, 0x2], [4, 4, 0, 0xc], [5, 4, 1, 0xd], [7, 5, 1, 0x1c], [9, 5, 2, 0x1d], [13, 6, 2, 0x3c], [17, 7, 2, 0x7a], [21, 7, 3, 0x7b], [29, 7, 4, 0x7c], [45, 7, 5, 0x7d], [77, 7, 6, 0x7e], [141, 7, 32, 0x7f]];
  4662. break;
  4663. case 12:
  4664. lines = [[1, 1, 0, 0x0], [2, 2, 0, 0x2], [3, 3, 1, 0x6], [5, 5, 0, 0x1c], [6, 5, 1, 0x1d], [8, 6, 1, 0x3c], [10, 7, 0, 0x7a], [11, 7, 1, 0x7b], [13, 7, 2, 0x7c], [17, 7, 3, 0x7d], [25, 7, 4, 0x7e], [41, 8, 5, 0xfe], [73, 8, 32, 0xff]];
  4665. break;
  4666. case 13:
  4667. lines = [[1, 1, 0, 0x0], [2, 3, 0, 0x4], [3, 4, 0, 0xc], [4, 5, 0, 0x1c], [5, 4, 1, 0xd], [7, 3, 3, 0x5], [15, 6, 1, 0x3a], [17, 6, 2, 0x3b], [21, 6, 3, 0x3c], [29, 6, 4, 0x3d], [45, 6, 5, 0x3e], [77, 7, 6, 0x7e], [141, 7, 32, 0x7f]];
  4668. break;
  4669. case 14:
  4670. lines = [[-2, 3, 0, 0x4], [-1, 3, 0, 0x5], [0, 1, 0, 0x0], [1, 3, 0, 0x6], [2, 3, 0, 0x7]];
  4671. break;
  4672. case 15:
  4673. lines = [[-24, 7, 4, 0x7c], [-8, 6, 2, 0x3c], [-4, 5, 1, 0x1c], [-2, 4, 0, 0xc], [-1, 3, 0, 0x4], [0, 1, 0, 0x0], [1, 3, 0, 0x5], [2, 4, 0, 0xd], [3, 5, 1, 0x1d], [5, 6, 2, 0x3d], [9, 7, 4, 0x7d], [-25, 7, 32, 0x7e, "lower"], [25, 7, 32, 0x7f]];
  4674. break;
  4675. default:
  4676. throw new Jbig2Error("standard table B.".concat(number, " does not exist"));
  4677. }
  4678. for (var i = 0, ii = lines.length; i < ii; i++) {
  4679. lines[i] = new HuffmanLine(lines[i]);
  4680. }
  4681. table = new HuffmanTable(lines, true);
  4682. standardTablesCache[number] = table;
  4683. return table;
  4684. }
  4685. var Reader = /*#__PURE__*/function () {
  4686. function Reader(data, start, end) {
  4687. _classCallCheck(this, Reader);
  4688. this.data = data;
  4689. this.start = start;
  4690. this.end = end;
  4691. this.position = start;
  4692. this.shift = -1;
  4693. this.currentByte = 0;
  4694. }
  4695. _createClass(Reader, [{
  4696. key: "readBit",
  4697. value: function readBit() {
  4698. if (this.shift < 0) {
  4699. if (this.position >= this.end) {
  4700. throw new Jbig2Error("end of data while reading bit");
  4701. }
  4702. this.currentByte = this.data[this.position++];
  4703. this.shift = 7;
  4704. }
  4705. var bit = this.currentByte >> this.shift & 1;
  4706. this.shift--;
  4707. return bit;
  4708. }
  4709. }, {
  4710. key: "readBits",
  4711. value: function readBits(numBits) {
  4712. var result = 0,
  4713. i;
  4714. for (i = numBits - 1; i >= 0; i--) {
  4715. result |= this.readBit() << i;
  4716. }
  4717. return result;
  4718. }
  4719. }, {
  4720. key: "byteAlign",
  4721. value: function byteAlign() {
  4722. this.shift = -1;
  4723. }
  4724. }, {
  4725. key: "next",
  4726. value: function next() {
  4727. if (this.position >= this.end) {
  4728. return -1;
  4729. }
  4730. return this.data[this.position++];
  4731. }
  4732. }]);
  4733. return Reader;
  4734. }();
  4735. function getCustomHuffmanTable(index, referredTo, customTables) {
  4736. var currentIndex = 0;
  4737. for (var i = 0, ii = referredTo.length; i < ii; i++) {
  4738. var table = customTables[referredTo[i]];
  4739. if (table) {
  4740. if (index === currentIndex) {
  4741. return table;
  4742. }
  4743. currentIndex++;
  4744. }
  4745. }
  4746. throw new Jbig2Error("can't find custom Huffman table");
  4747. }
  4748. function getTextRegionHuffmanTables(textRegion, referredTo, customTables, numberOfSymbols, reader) {
  4749. var codes = [];
  4750. for (var i = 0; i <= 34; i++) {
  4751. var codeLength = reader.readBits(4);
  4752. codes.push(new HuffmanLine([i, codeLength, 0, 0]));
  4753. }
  4754. var runCodesTable = new HuffmanTable(codes, false);
  4755. codes.length = 0;
  4756. for (var _i3 = 0; _i3 < numberOfSymbols;) {
  4757. var _codeLength = runCodesTable.decode(reader);
  4758. if (_codeLength >= 32) {
  4759. var repeatedLength = void 0,
  4760. numberOfRepeats = void 0,
  4761. j = void 0;
  4762. switch (_codeLength) {
  4763. case 32:
  4764. if (_i3 === 0) {
  4765. throw new Jbig2Error("no previous value in symbol ID table");
  4766. }
  4767. numberOfRepeats = reader.readBits(2) + 3;
  4768. repeatedLength = codes[_i3 - 1].prefixLength;
  4769. break;
  4770. case 33:
  4771. numberOfRepeats = reader.readBits(3) + 3;
  4772. repeatedLength = 0;
  4773. break;
  4774. case 34:
  4775. numberOfRepeats = reader.readBits(7) + 11;
  4776. repeatedLength = 0;
  4777. break;
  4778. default:
  4779. throw new Jbig2Error("invalid code length in symbol ID table");
  4780. }
  4781. for (j = 0; j < numberOfRepeats; j++) {
  4782. codes.push(new HuffmanLine([_i3, repeatedLength, 0, 0]));
  4783. _i3++;
  4784. }
  4785. } else {
  4786. codes.push(new HuffmanLine([_i3, _codeLength, 0, 0]));
  4787. _i3++;
  4788. }
  4789. }
  4790. reader.byteAlign();
  4791. var symbolIDTable = new HuffmanTable(codes, false);
  4792. var customIndex = 0,
  4793. tableFirstS,
  4794. tableDeltaS,
  4795. tableDeltaT;
  4796. switch (textRegion.huffmanFS) {
  4797. case 0:
  4798. case 1:
  4799. tableFirstS = getStandardTable(textRegion.huffmanFS + 6);
  4800. break;
  4801. case 3:
  4802. tableFirstS = getCustomHuffmanTable(customIndex, referredTo, customTables);
  4803. customIndex++;
  4804. break;
  4805. default:
  4806. throw new Jbig2Error("invalid Huffman FS selector");
  4807. }
  4808. switch (textRegion.huffmanDS) {
  4809. case 0:
  4810. case 1:
  4811. case 2:
  4812. tableDeltaS = getStandardTable(textRegion.huffmanDS + 8);
  4813. break;
  4814. case 3:
  4815. tableDeltaS = getCustomHuffmanTable(customIndex, referredTo, customTables);
  4816. customIndex++;
  4817. break;
  4818. default:
  4819. throw new Jbig2Error("invalid Huffman DS selector");
  4820. }
  4821. switch (textRegion.huffmanDT) {
  4822. case 0:
  4823. case 1:
  4824. case 2:
  4825. tableDeltaT = getStandardTable(textRegion.huffmanDT + 11);
  4826. break;
  4827. case 3:
  4828. tableDeltaT = getCustomHuffmanTable(customIndex, referredTo, customTables);
  4829. customIndex++;
  4830. break;
  4831. default:
  4832. throw new Jbig2Error("invalid Huffman DT selector");
  4833. }
  4834. if (textRegion.refinement) {
  4835. throw new Jbig2Error("refinement with Huffman is not supported");
  4836. }
  4837. return {
  4838. symbolIDTable: symbolIDTable,
  4839. tableFirstS: tableFirstS,
  4840. tableDeltaS: tableDeltaS,
  4841. tableDeltaT: tableDeltaT
  4842. };
  4843. }
  4844. function getSymbolDictionaryHuffmanTables(dictionary, referredTo, customTables) {
  4845. var customIndex = 0,
  4846. tableDeltaHeight,
  4847. tableDeltaWidth;
  4848. switch (dictionary.huffmanDHSelector) {
  4849. case 0:
  4850. case 1:
  4851. tableDeltaHeight = getStandardTable(dictionary.huffmanDHSelector + 4);
  4852. break;
  4853. case 3:
  4854. tableDeltaHeight = getCustomHuffmanTable(customIndex, referredTo, customTables);
  4855. customIndex++;
  4856. break;
  4857. default:
  4858. throw new Jbig2Error("invalid Huffman DH selector");
  4859. }
  4860. switch (dictionary.huffmanDWSelector) {
  4861. case 0:
  4862. case 1:
  4863. tableDeltaWidth = getStandardTable(dictionary.huffmanDWSelector + 2);
  4864. break;
  4865. case 3:
  4866. tableDeltaWidth = getCustomHuffmanTable(customIndex, referredTo, customTables);
  4867. customIndex++;
  4868. break;
  4869. default:
  4870. throw new Jbig2Error("invalid Huffman DW selector");
  4871. }
  4872. var tableBitmapSize, tableAggregateInstances;
  4873. if (dictionary.bitmapSizeSelector) {
  4874. tableBitmapSize = getCustomHuffmanTable(customIndex, referredTo, customTables);
  4875. customIndex++;
  4876. } else {
  4877. tableBitmapSize = getStandardTable(1);
  4878. }
  4879. if (dictionary.aggregationInstancesSelector) {
  4880. tableAggregateInstances = getCustomHuffmanTable(customIndex, referredTo, customTables);
  4881. } else {
  4882. tableAggregateInstances = getStandardTable(1);
  4883. }
  4884. return {
  4885. tableDeltaHeight: tableDeltaHeight,
  4886. tableDeltaWidth: tableDeltaWidth,
  4887. tableBitmapSize: tableBitmapSize,
  4888. tableAggregateInstances: tableAggregateInstances
  4889. };
  4890. }
  4891. function readUncompressedBitmap(reader, width, height) {
  4892. var bitmap = [];
  4893. for (var y = 0; y < height; y++) {
  4894. var row = new Uint8Array(width);
  4895. bitmap.push(row);
  4896. for (var x = 0; x < width; x++) {
  4897. row[x] = reader.readBit();
  4898. }
  4899. reader.byteAlign();
  4900. }
  4901. return bitmap;
  4902. }
  4903. function decodeMMRBitmap(input, width, height, endOfBlock) {
  4904. var params = {
  4905. K: -1,
  4906. Columns: width,
  4907. Rows: height,
  4908. BlackIs1: true,
  4909. EndOfBlock: endOfBlock
  4910. };
  4911. var decoder = new _ccitt.CCITTFaxDecoder(input, params);
  4912. var bitmap = [];
  4913. var currentByte,
  4914. eof = false;
  4915. for (var y = 0; y < height; y++) {
  4916. var row = new Uint8Array(width);
  4917. bitmap.push(row);
  4918. var shift = -1;
  4919. for (var x = 0; x < width; x++) {
  4920. if (shift < 0) {
  4921. currentByte = decoder.readNextChar();
  4922. if (currentByte === -1) {
  4923. currentByte = 0;
  4924. eof = true;
  4925. }
  4926. shift = 7;
  4927. }
  4928. row[x] = currentByte >> shift & 1;
  4929. shift--;
  4930. }
  4931. }
  4932. if (endOfBlock && !eof) {
  4933. var lookForEOFLimit = 5;
  4934. for (var i = 0; i < lookForEOFLimit; i++) {
  4935. if (decoder.readNextChar() === -1) {
  4936. break;
  4937. }
  4938. }
  4939. }
  4940. return bitmap;
  4941. }
  4942. var Jbig2Image = /*#__PURE__*/function () {
  4943. function Jbig2Image() {
  4944. _classCallCheck(this, Jbig2Image);
  4945. }
  4946. _createClass(Jbig2Image, [{
  4947. key: "parseChunks",
  4948. value: function parseChunks(chunks) {
  4949. return parseJbig2Chunks(chunks);
  4950. }
  4951. }, {
  4952. key: "parse",
  4953. value: function parse(data) {
  4954. var _parseJbig = parseJbig2(data),
  4955. imgData = _parseJbig.imgData,
  4956. width = _parseJbig.width,
  4957. height = _parseJbig.height;
  4958. this.width = width;
  4959. this.height = height;
  4960. return imgData;
  4961. }
  4962. }]);
  4963. return Jbig2Image;
  4964. }();
  4965. exports.Jbig2Image = Jbig2Image;
  4966. /***/ }),
  4967. /* 95 */
  4968. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  4969. "use strict";
  4970. 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); }
  4971. Object.defineProperty(exports, "__esModule", ({
  4972. value: true
  4973. }));
  4974. exports.XRefParseException = exports.XRefEntryException = exports.ParserEOFException = exports.MissingDataException = exports.DocStats = void 0;
  4975. exports.collectActions = collectActions;
  4976. exports.encodeToXmlString = encodeToXmlString;
  4977. exports.escapePDFName = escapePDFName;
  4978. exports.getArrayLookupTableFactory = getArrayLookupTableFactory;
  4979. exports.getInheritableProperty = getInheritableProperty;
  4980. exports.getLookupTableFactory = getLookupTableFactory;
  4981. exports.isWhiteSpace = isWhiteSpace;
  4982. exports.log2 = log2;
  4983. exports.parseXFAPath = parseXFAPath;
  4984. exports.readInt8 = readInt8;
  4985. exports.readUint16 = readUint16;
  4986. exports.readUint32 = readUint32;
  4987. exports.recoverJsURL = recoverJsURL;
  4988. exports.toRomanNumerals = toRomanNumerals;
  4989. exports.validateCSSFont = validateCSSFont;
  4990. var _util = __w_pdfjs_require__(1);
  4991. var _primitives = __w_pdfjs_require__(96);
  4992. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  4993. 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); }
  4994. 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; }
  4995. 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); } }
  4996. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4997. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4998. 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); }
  4999. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  5000. 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); }; }
  5001. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  5002. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  5003. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  5004. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  5005. function getLookupTableFactory(initializer) {
  5006. var lookup;
  5007. return function () {
  5008. if (initializer) {
  5009. lookup = Object.create(null);
  5010. initializer(lookup);
  5011. initializer = null;
  5012. }
  5013. return lookup;
  5014. };
  5015. }
  5016. function getArrayLookupTableFactory(initializer) {
  5017. var lookup;
  5018. return function () {
  5019. if (initializer) {
  5020. var arr = initializer();
  5021. initializer = null;
  5022. lookup = Object.create(null);
  5023. for (var i = 0, ii = arr.length; i < ii; i += 2) {
  5024. lookup[arr[i]] = arr[i + 1];
  5025. }
  5026. arr = null;
  5027. }
  5028. return lookup;
  5029. };
  5030. }
  5031. var MissingDataException = /*#__PURE__*/function (_BaseException) {
  5032. _inherits(MissingDataException, _BaseException);
  5033. var _super = _createSuper(MissingDataException);
  5034. function MissingDataException(begin, end) {
  5035. var _this;
  5036. _classCallCheck(this, MissingDataException);
  5037. _this = _super.call(this, "Missing data [".concat(begin, ", ").concat(end, ")"), "MissingDataException");
  5038. _this.begin = begin;
  5039. _this.end = end;
  5040. return _this;
  5041. }
  5042. return MissingDataException;
  5043. }(_util.BaseException);
  5044. exports.MissingDataException = MissingDataException;
  5045. var ParserEOFException = /*#__PURE__*/function (_BaseException2) {
  5046. _inherits(ParserEOFException, _BaseException2);
  5047. var _super2 = _createSuper(ParserEOFException);
  5048. function ParserEOFException(msg) {
  5049. _classCallCheck(this, ParserEOFException);
  5050. return _super2.call(this, msg, "ParserEOFException");
  5051. }
  5052. return ParserEOFException;
  5053. }(_util.BaseException);
  5054. exports.ParserEOFException = ParserEOFException;
  5055. var XRefEntryException = /*#__PURE__*/function (_BaseException3) {
  5056. _inherits(XRefEntryException, _BaseException3);
  5057. var _super3 = _createSuper(XRefEntryException);
  5058. function XRefEntryException(msg) {
  5059. _classCallCheck(this, XRefEntryException);
  5060. return _super3.call(this, msg, "XRefEntryException");
  5061. }
  5062. return XRefEntryException;
  5063. }(_util.BaseException);
  5064. exports.XRefEntryException = XRefEntryException;
  5065. var XRefParseException = /*#__PURE__*/function (_BaseException4) {
  5066. _inherits(XRefParseException, _BaseException4);
  5067. var _super4 = _createSuper(XRefParseException);
  5068. function XRefParseException(msg) {
  5069. _classCallCheck(this, XRefParseException);
  5070. return _super4.call(this, msg, "XRefParseException");
  5071. }
  5072. return XRefParseException;
  5073. }(_util.BaseException);
  5074. exports.XRefParseException = XRefParseException;
  5075. var DocStats = /*#__PURE__*/function () {
  5076. function DocStats(handler) {
  5077. _classCallCheck(this, DocStats);
  5078. this._handler = handler;
  5079. this._streamTypes = new Set();
  5080. this._fontTypes = new Set();
  5081. }
  5082. _createClass(DocStats, [{
  5083. key: "_send",
  5084. value: function _send() {
  5085. var streamTypes = Object.create(null),
  5086. fontTypes = Object.create(null);
  5087. var _iterator = _createForOfIteratorHelper(this._streamTypes),
  5088. _step;
  5089. try {
  5090. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5091. var type = _step.value;
  5092. streamTypes[type] = true;
  5093. }
  5094. } catch (err) {
  5095. _iterator.e(err);
  5096. } finally {
  5097. _iterator.f();
  5098. }
  5099. var _iterator2 = _createForOfIteratorHelper(this._fontTypes),
  5100. _step2;
  5101. try {
  5102. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  5103. var _type = _step2.value;
  5104. fontTypes[_type] = true;
  5105. }
  5106. } catch (err) {
  5107. _iterator2.e(err);
  5108. } finally {
  5109. _iterator2.f();
  5110. }
  5111. this._handler.send("DocStats", {
  5112. streamTypes: streamTypes,
  5113. fontTypes: fontTypes
  5114. });
  5115. }
  5116. }, {
  5117. key: "addStreamType",
  5118. value: function addStreamType(type) {
  5119. if (this._streamTypes.has(type)) {
  5120. return;
  5121. }
  5122. this._streamTypes.add(type);
  5123. this._send();
  5124. }
  5125. }, {
  5126. key: "addFontType",
  5127. value: function addFontType(type) {
  5128. if (this._fontTypes.has(type)) {
  5129. return;
  5130. }
  5131. this._fontTypes.add(type);
  5132. this._send();
  5133. }
  5134. }]);
  5135. return DocStats;
  5136. }();
  5137. exports.DocStats = DocStats;
  5138. function getInheritableProperty(_ref) {
  5139. var dict = _ref.dict,
  5140. key = _ref.key,
  5141. _ref$getArray = _ref.getArray,
  5142. getArray = _ref$getArray === void 0 ? false : _ref$getArray,
  5143. _ref$stopWhenFound = _ref.stopWhenFound,
  5144. stopWhenFound = _ref$stopWhenFound === void 0 ? true : _ref$stopWhenFound;
  5145. var values;
  5146. var visited = new _primitives.RefSet();
  5147. while (dict instanceof _primitives.Dict && !(dict.objId && visited.has(dict.objId))) {
  5148. if (dict.objId) {
  5149. visited.put(dict.objId);
  5150. }
  5151. var value = getArray ? dict.getArray(key) : dict.get(key);
  5152. if (value !== undefined) {
  5153. if (stopWhenFound) {
  5154. return value;
  5155. }
  5156. if (!values) {
  5157. values = [];
  5158. }
  5159. values.push(value);
  5160. }
  5161. dict = dict.get("Parent");
  5162. }
  5163. return values;
  5164. }
  5165. var ROMAN_NUMBER_MAP = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM", "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC", "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"];
  5166. function toRomanNumerals(number) {
  5167. var lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5168. (0, _util.assert)(Number.isInteger(number) && number > 0, "The number should be a positive integer.");
  5169. var romanBuf = [];
  5170. var pos;
  5171. while (number >= 1000) {
  5172. number -= 1000;
  5173. romanBuf.push("M");
  5174. }
  5175. pos = number / 100 | 0;
  5176. number %= 100;
  5177. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  5178. pos = number / 10 | 0;
  5179. number %= 10;
  5180. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  5181. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  5182. var romanStr = romanBuf.join("");
  5183. return lowerCase ? romanStr.toLowerCase() : romanStr;
  5184. }
  5185. function log2(x) {
  5186. if (x <= 0) {
  5187. return 0;
  5188. }
  5189. return Math.ceil(Math.log2(x));
  5190. }
  5191. function readInt8(data, offset) {
  5192. return data[offset] << 24 >> 24;
  5193. }
  5194. function readUint16(data, offset) {
  5195. return data[offset] << 8 | data[offset + 1];
  5196. }
  5197. function readUint32(data, offset) {
  5198. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  5199. }
  5200. function isWhiteSpace(ch) {
  5201. return ch === 0x20 || ch === 0x09 || ch === 0x0d || ch === 0x0a;
  5202. }
  5203. function parseXFAPath(path) {
  5204. var positionPattern = /(.+)\[(\d+)\]$/;
  5205. return path.split(".").map(function (component) {
  5206. var m = component.match(positionPattern);
  5207. if (m) {
  5208. return {
  5209. name: m[1],
  5210. pos: parseInt(m[2], 10)
  5211. };
  5212. }
  5213. return {
  5214. name: component,
  5215. pos: 0
  5216. };
  5217. });
  5218. }
  5219. function escapePDFName(str) {
  5220. var buffer = [];
  5221. var start = 0;
  5222. for (var i = 0, ii = str.length; i < ii; i++) {
  5223. var _char = str.charCodeAt(i);
  5224. if (_char < 0x21 || _char > 0x7e || _char === 0x23 || _char === 0x28 || _char === 0x29 || _char === 0x3c || _char === 0x3e || _char === 0x5b || _char === 0x5d || _char === 0x7b || _char === 0x7d || _char === 0x2f || _char === 0x25) {
  5225. if (start < i) {
  5226. buffer.push(str.substring(start, i));
  5227. }
  5228. buffer.push("#".concat(_char.toString(16)));
  5229. start = i + 1;
  5230. }
  5231. }
  5232. if (buffer.length === 0) {
  5233. return str;
  5234. }
  5235. if (start < str.length) {
  5236. buffer.push(str.substring(start, str.length));
  5237. }
  5238. return buffer.join("");
  5239. }
  5240. function _collectJS(entry, xref, list, parents) {
  5241. if (!entry) {
  5242. return;
  5243. }
  5244. var parent = null;
  5245. if ((0, _primitives.isRef)(entry)) {
  5246. if (parents.has(entry)) {
  5247. return;
  5248. }
  5249. parent = entry;
  5250. parents.put(parent);
  5251. entry = xref.fetch(entry);
  5252. }
  5253. if (Array.isArray(entry)) {
  5254. var _iterator3 = _createForOfIteratorHelper(entry),
  5255. _step3;
  5256. try {
  5257. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  5258. var element = _step3.value;
  5259. _collectJS(element, xref, list, parents);
  5260. }
  5261. } catch (err) {
  5262. _iterator3.e(err);
  5263. } finally {
  5264. _iterator3.f();
  5265. }
  5266. } else if (entry instanceof _primitives.Dict) {
  5267. if ((0, _primitives.isName)(entry.get("S"), "JavaScript") && entry.has("JS")) {
  5268. var js = entry.get("JS");
  5269. var code;
  5270. if ((0, _primitives.isStream)(js)) {
  5271. code = js.getString();
  5272. } else {
  5273. code = js;
  5274. }
  5275. code = (0, _util.stringToPDFString)(code);
  5276. if (code) {
  5277. list.push(code);
  5278. }
  5279. }
  5280. _collectJS(entry.getRaw("Next"), xref, list, parents);
  5281. }
  5282. if (parent) {
  5283. parents.remove(parent);
  5284. }
  5285. }
  5286. function collectActions(xref, dict, eventType) {
  5287. var actions = Object.create(null);
  5288. var additionalActionsDicts = getInheritableProperty({
  5289. dict: dict,
  5290. key: "AA",
  5291. stopWhenFound: false
  5292. });
  5293. if (additionalActionsDicts) {
  5294. for (var i = additionalActionsDicts.length - 1; i >= 0; i--) {
  5295. var additionalActions = additionalActionsDicts[i];
  5296. if (!(additionalActions instanceof _primitives.Dict)) {
  5297. continue;
  5298. }
  5299. var _iterator4 = _createForOfIteratorHelper(additionalActions.getKeys()),
  5300. _step4;
  5301. try {
  5302. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  5303. var key = _step4.value;
  5304. var action = eventType[key];
  5305. if (!action) {
  5306. continue;
  5307. }
  5308. var actionDict = additionalActions.getRaw(key);
  5309. var parents = new _primitives.RefSet();
  5310. var list = [];
  5311. _collectJS(actionDict, xref, list, parents);
  5312. if (list.length > 0) {
  5313. actions[action] = list;
  5314. }
  5315. }
  5316. } catch (err) {
  5317. _iterator4.e(err);
  5318. } finally {
  5319. _iterator4.f();
  5320. }
  5321. }
  5322. }
  5323. if (dict.has("A")) {
  5324. var _actionDict = dict.get("A");
  5325. var _parents = new _primitives.RefSet();
  5326. var _list = [];
  5327. _collectJS(_actionDict, xref, _list, _parents);
  5328. if (_list.length > 0) {
  5329. actions.Action = _list;
  5330. }
  5331. }
  5332. return (0, _util.objectSize)(actions) > 0 ? actions : null;
  5333. }
  5334. var XMLEntities = {
  5335. 0x3c: "&lt;",
  5336. 0x3e: "&gt;",
  5337. 0x26: "&amp;",
  5338. 0x22: "&quot;",
  5339. 0x27: "&apos;"
  5340. };
  5341. function encodeToXmlString(str) {
  5342. var buffer = [];
  5343. var start = 0;
  5344. for (var i = 0, ii = str.length; i < ii; i++) {
  5345. var _char2 = str.codePointAt(i);
  5346. if (0x20 <= _char2 && _char2 <= 0x7e) {
  5347. var entity = XMLEntities[_char2];
  5348. if (entity) {
  5349. if (start < i) {
  5350. buffer.push(str.substring(start, i));
  5351. }
  5352. buffer.push(entity);
  5353. start = i + 1;
  5354. }
  5355. } else {
  5356. if (start < i) {
  5357. buffer.push(str.substring(start, i));
  5358. }
  5359. buffer.push("&#x".concat(_char2.toString(16).toUpperCase(), ";"));
  5360. if (_char2 > 0xd7ff && (_char2 < 0xe000 || _char2 > 0xfffd)) {
  5361. i++;
  5362. }
  5363. start = i + 1;
  5364. }
  5365. }
  5366. if (buffer.length === 0) {
  5367. return str;
  5368. }
  5369. if (start < str.length) {
  5370. buffer.push(str.substring(start, str.length));
  5371. }
  5372. return buffer.join("");
  5373. }
  5374. function validateCSSFont(cssFontInfo) {
  5375. var DEFAULT_CSS_FONT_OBLIQUE = "14";
  5376. var DEFAULT_CSS_FONT_WEIGHT = "400";
  5377. var CSS_FONT_WEIGHT_VALUES = new Set(["100", "200", "300", "400", "500", "600", "700", "800", "900", "1000", "normal", "bold", "bolder", "lighter"]);
  5378. var fontFamily = cssFontInfo.fontFamily,
  5379. fontWeight = cssFontInfo.fontWeight,
  5380. italicAngle = cssFontInfo.italicAngle;
  5381. if (/^".*"$/.test(fontFamily)) {
  5382. if (/[^\\]"/.test(fontFamily.slice(1, fontFamily.length - 1))) {
  5383. (0, _util.warn)("XFA - FontFamily contains some unescaped \": ".concat(fontFamily, "."));
  5384. return false;
  5385. }
  5386. } else if (/^'.*'$/.test(fontFamily)) {
  5387. if (/[^\\]'/.test(fontFamily.slice(1, fontFamily.length - 1))) {
  5388. (0, _util.warn)("XFA - FontFamily contains some unescaped ': ".concat(fontFamily, "."));
  5389. return false;
  5390. }
  5391. } else {
  5392. var _iterator5 = _createForOfIteratorHelper(fontFamily.split(/[ \t]+/)),
  5393. _step5;
  5394. try {
  5395. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  5396. var ident = _step5.value;
  5397. if (/^(\d|(-(\d|-)))/.test(ident) || !/^[\w-\\]+$/.test(ident)) {
  5398. (0, _util.warn)("XFA - FontFamily contains some invalid <custom-ident>: ".concat(fontFamily, "."));
  5399. return false;
  5400. }
  5401. }
  5402. } catch (err) {
  5403. _iterator5.e(err);
  5404. } finally {
  5405. _iterator5.f();
  5406. }
  5407. }
  5408. var weight = fontWeight ? fontWeight.toString() : "";
  5409. cssFontInfo.fontWeight = CSS_FONT_WEIGHT_VALUES.has(weight) ? weight : DEFAULT_CSS_FONT_WEIGHT;
  5410. var angle = parseFloat(italicAngle);
  5411. cssFontInfo.italicAngle = isNaN(angle) || angle < -90 || angle > 90 ? DEFAULT_CSS_FONT_OBLIQUE : italicAngle.toString();
  5412. return true;
  5413. }
  5414. function recoverJsURL(str) {
  5415. var URL_OPEN_METHODS = ["app.launchURL", "window.open", "xfa.host.gotoURL"];
  5416. var regex = new RegExp("^\\s*(" + URL_OPEN_METHODS.join("|").split(".").join("\\.") + ")\\((?:'|\")([^'\"]*)(?:'|\")(?:,\\s*(\\w+)\\)|\\))", "i");
  5417. var jsUrl = regex.exec(str);
  5418. if (jsUrl && jsUrl[2]) {
  5419. var url = jsUrl[2];
  5420. var newWindow = false;
  5421. if (jsUrl[3] === "true" && jsUrl[1] === "app.launchURL") {
  5422. newWindow = true;
  5423. }
  5424. return {
  5425. url: url,
  5426. newWindow: newWindow
  5427. };
  5428. }
  5429. return null;
  5430. }
  5431. /***/ }),
  5432. /* 96 */
  5433. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  5434. "use strict";
  5435. Object.defineProperty(exports, "__esModule", ({
  5436. value: true
  5437. }));
  5438. exports.RefSetCache = exports.RefSet = exports.Ref = exports.Name = exports.EOF = exports.Dict = exports.Cmd = exports.CIRCULAR_REF = void 0;
  5439. exports.clearPrimitiveCaches = clearPrimitiveCaches;
  5440. exports.isCmd = isCmd;
  5441. exports.isDict = isDict;
  5442. exports.isName = isName;
  5443. exports.isRef = isRef;
  5444. exports.isRefsEqual = isRefsEqual;
  5445. exports.isStream = isStream;
  5446. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(97));
  5447. var _util = __w_pdfjs_require__(1);
  5448. var _base_stream = __w_pdfjs_require__(99);
  5449. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5450. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  5451. 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."); }
  5452. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  5453. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  5454. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  5455. 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); }
  5456. 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; }
  5457. 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); } }
  5458. 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); }); }; }
  5459. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5460. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5461. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5462. var CIRCULAR_REF = Symbol("CIRCULAR_REF");
  5463. exports.CIRCULAR_REF = CIRCULAR_REF;
  5464. var EOF = Symbol("EOF");
  5465. exports.EOF = EOF;
  5466. var Name = function NameClosure() {
  5467. var nameCache = Object.create(null);
  5468. var Name = /*#__PURE__*/function () {
  5469. function Name(name) {
  5470. _classCallCheck(this, Name);
  5471. this.name = name;
  5472. }
  5473. _createClass(Name, null, [{
  5474. key: "get",
  5475. value: function get(name) {
  5476. var nameValue = nameCache[name];
  5477. return nameValue ? nameValue : nameCache[name] = new Name(name);
  5478. }
  5479. }, {
  5480. key: "_clearCache",
  5481. value: function _clearCache() {
  5482. nameCache = Object.create(null);
  5483. }
  5484. }]);
  5485. return Name;
  5486. }();
  5487. return Name;
  5488. }();
  5489. exports.Name = Name;
  5490. var Cmd = function CmdClosure() {
  5491. var cmdCache = Object.create(null);
  5492. var Cmd = /*#__PURE__*/function () {
  5493. function Cmd(cmd) {
  5494. _classCallCheck(this, Cmd);
  5495. this.cmd = cmd;
  5496. }
  5497. _createClass(Cmd, null, [{
  5498. key: "get",
  5499. value: function get(cmd) {
  5500. var cmdValue = cmdCache[cmd];
  5501. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  5502. }
  5503. }, {
  5504. key: "_clearCache",
  5505. value: function _clearCache() {
  5506. cmdCache = Object.create(null);
  5507. }
  5508. }]);
  5509. return Cmd;
  5510. }();
  5511. return Cmd;
  5512. }();
  5513. exports.Cmd = Cmd;
  5514. var nonSerializable = function nonSerializableClosure() {
  5515. return nonSerializable;
  5516. };
  5517. var Dict = /*#__PURE__*/function () {
  5518. function Dict() {
  5519. var xref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  5520. _classCallCheck(this, Dict);
  5521. this._map = Object.create(null);
  5522. this.xref = xref;
  5523. this.objId = null;
  5524. this.suppressEncryption = false;
  5525. this.__nonSerializable__ = nonSerializable;
  5526. }
  5527. _createClass(Dict, [{
  5528. key: "assignXref",
  5529. value: function assignXref(newXref) {
  5530. this.xref = newXref;
  5531. }
  5532. }, {
  5533. key: "size",
  5534. get: function get() {
  5535. return Object.keys(this._map).length;
  5536. }
  5537. }, {
  5538. key: "get",
  5539. value: function get(key1, key2, key3) {
  5540. var value = this._map[key1];
  5541. if (value === undefined && key2 !== undefined) {
  5542. value = this._map[key2];
  5543. if (value === undefined && key3 !== undefined) {
  5544. value = this._map[key3];
  5545. }
  5546. }
  5547. if (value instanceof Ref && this.xref) {
  5548. return this.xref.fetch(value, this.suppressEncryption);
  5549. }
  5550. return value;
  5551. }
  5552. }, {
  5553. key: "getAsync",
  5554. value: function () {
  5555. var _getAsync = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(key1, key2, key3) {
  5556. var value;
  5557. return _regenerator["default"].wrap(function _callee$(_context) {
  5558. while (1) {
  5559. switch (_context.prev = _context.next) {
  5560. case 0:
  5561. value = this._map[key1];
  5562. if (value === undefined && key2 !== undefined) {
  5563. value = this._map[key2];
  5564. if (value === undefined && key3 !== undefined) {
  5565. value = this._map[key3];
  5566. }
  5567. }
  5568. if (!(value instanceof Ref && this.xref)) {
  5569. _context.next = 4;
  5570. break;
  5571. }
  5572. return _context.abrupt("return", this.xref.fetchAsync(value, this.suppressEncryption));
  5573. case 4:
  5574. return _context.abrupt("return", value);
  5575. case 5:
  5576. case "end":
  5577. return _context.stop();
  5578. }
  5579. }
  5580. }, _callee, this);
  5581. }));
  5582. function getAsync(_x, _x2, _x3) {
  5583. return _getAsync.apply(this, arguments);
  5584. }
  5585. return getAsync;
  5586. }()
  5587. }, {
  5588. key: "getArray",
  5589. value: function getArray(key1, key2, key3) {
  5590. var value = this._map[key1];
  5591. if (value === undefined && key2 !== undefined) {
  5592. value = this._map[key2];
  5593. if (value === undefined && key3 !== undefined) {
  5594. value = this._map[key3];
  5595. }
  5596. }
  5597. if (value instanceof Ref && this.xref) {
  5598. value = this.xref.fetch(value, this.suppressEncryption);
  5599. }
  5600. if (Array.isArray(value)) {
  5601. value = value.slice();
  5602. for (var i = 0, ii = value.length; i < ii; i++) {
  5603. if (value[i] instanceof Ref && this.xref) {
  5604. value[i] = this.xref.fetch(value[i], this.suppressEncryption);
  5605. }
  5606. }
  5607. }
  5608. return value;
  5609. }
  5610. }, {
  5611. key: "getRaw",
  5612. value: function getRaw(key) {
  5613. return this._map[key];
  5614. }
  5615. }, {
  5616. key: "getKeys",
  5617. value: function getKeys() {
  5618. return Object.keys(this._map);
  5619. }
  5620. }, {
  5621. key: "getRawValues",
  5622. value: function getRawValues() {
  5623. return Object.values(this._map);
  5624. }
  5625. }, {
  5626. key: "set",
  5627. value: function set(key, value) {
  5628. this._map[key] = value;
  5629. }
  5630. }, {
  5631. key: "has",
  5632. value: function has(key) {
  5633. return this._map[key] !== undefined;
  5634. }
  5635. }, {
  5636. key: "forEach",
  5637. value: function forEach(callback) {
  5638. for (var key in this._map) {
  5639. callback(key, this.get(key));
  5640. }
  5641. }
  5642. }], [{
  5643. key: "empty",
  5644. get: function get() {
  5645. var emptyDict = new Dict(null);
  5646. emptyDict.set = function (key, value) {
  5647. (0, _util.unreachable)("Should not call `set` on the empty dictionary.");
  5648. };
  5649. return (0, _util.shadow)(this, "empty", emptyDict);
  5650. }
  5651. }, {
  5652. key: "merge",
  5653. value: function merge(_ref) {
  5654. var xref = _ref.xref,
  5655. dictArray = _ref.dictArray,
  5656. _ref$mergeSubDicts = _ref.mergeSubDicts,
  5657. mergeSubDicts = _ref$mergeSubDicts === void 0 ? false : _ref$mergeSubDicts;
  5658. var mergedDict = new Dict(xref),
  5659. properties = new Map();
  5660. var _iterator = _createForOfIteratorHelper(dictArray),
  5661. _step;
  5662. try {
  5663. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5664. var dict = _step.value;
  5665. if (!(dict instanceof Dict)) {
  5666. continue;
  5667. }
  5668. for (var _i = 0, _Object$entries = Object.entries(dict._map); _i < _Object$entries.length; _i++) {
  5669. var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
  5670. key = _Object$entries$_i[0],
  5671. value = _Object$entries$_i[1];
  5672. var property = properties.get(key);
  5673. if (property === undefined) {
  5674. property = [];
  5675. properties.set(key, property);
  5676. } else if (!mergeSubDicts || !(value instanceof Dict)) {
  5677. continue;
  5678. }
  5679. property.push(value);
  5680. }
  5681. }
  5682. } catch (err) {
  5683. _iterator.e(err);
  5684. } finally {
  5685. _iterator.f();
  5686. }
  5687. var _iterator2 = _createForOfIteratorHelper(properties),
  5688. _step2;
  5689. try {
  5690. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  5691. var _step2$value = _slicedToArray(_step2.value, 2),
  5692. name = _step2$value[0],
  5693. values = _step2$value[1];
  5694. if (values.length === 1 || !(values[0] instanceof Dict)) {
  5695. mergedDict._map[name] = values[0];
  5696. continue;
  5697. }
  5698. var subDict = new Dict(xref);
  5699. var _iterator3 = _createForOfIteratorHelper(values),
  5700. _step3;
  5701. try {
  5702. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  5703. var _dict = _step3.value;
  5704. for (var _i2 = 0, _Object$entries2 = Object.entries(_dict._map); _i2 < _Object$entries2.length; _i2++) {
  5705. var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
  5706. _key = _Object$entries2$_i[0],
  5707. _value = _Object$entries2$_i[1];
  5708. if (subDict._map[_key] === undefined) {
  5709. subDict._map[_key] = _value;
  5710. }
  5711. }
  5712. }
  5713. } catch (err) {
  5714. _iterator3.e(err);
  5715. } finally {
  5716. _iterator3.f();
  5717. }
  5718. if (subDict.size > 0) {
  5719. mergedDict._map[name] = subDict;
  5720. }
  5721. }
  5722. } catch (err) {
  5723. _iterator2.e(err);
  5724. } finally {
  5725. _iterator2.f();
  5726. }
  5727. properties.clear();
  5728. return mergedDict.size > 0 ? mergedDict : Dict.empty;
  5729. }
  5730. }]);
  5731. return Dict;
  5732. }();
  5733. exports.Dict = Dict;
  5734. var Ref = function RefClosure() {
  5735. var refCache = Object.create(null);
  5736. var Ref = /*#__PURE__*/function () {
  5737. function Ref(num, gen) {
  5738. _classCallCheck(this, Ref);
  5739. this.num = num;
  5740. this.gen = gen;
  5741. }
  5742. _createClass(Ref, [{
  5743. key: "toString",
  5744. value: function toString() {
  5745. if (this.gen === 0) {
  5746. return "".concat(this.num, "R");
  5747. }
  5748. return "".concat(this.num, "R").concat(this.gen);
  5749. }
  5750. }], [{
  5751. key: "get",
  5752. value: function get(num, gen) {
  5753. var key = gen === 0 ? "".concat(num, "R") : "".concat(num, "R").concat(gen);
  5754. var refValue = refCache[key];
  5755. return refValue ? refValue : refCache[key] = new Ref(num, gen);
  5756. }
  5757. }, {
  5758. key: "_clearCache",
  5759. value: function _clearCache() {
  5760. refCache = Object.create(null);
  5761. }
  5762. }]);
  5763. return Ref;
  5764. }();
  5765. return Ref;
  5766. }();
  5767. exports.Ref = Ref;
  5768. var RefSet = /*#__PURE__*/function () {
  5769. function RefSet() {
  5770. var parent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  5771. _classCallCheck(this, RefSet);
  5772. this._set = new Set(parent && parent._set);
  5773. }
  5774. _createClass(RefSet, [{
  5775. key: "has",
  5776. value: function has(ref) {
  5777. return this._set.has(ref.toString());
  5778. }
  5779. }, {
  5780. key: "put",
  5781. value: function put(ref) {
  5782. this._set.add(ref.toString());
  5783. }
  5784. }, {
  5785. key: "remove",
  5786. value: function remove(ref) {
  5787. this._set["delete"](ref.toString());
  5788. }
  5789. }, {
  5790. key: "forEach",
  5791. value: function forEach(callback) {
  5792. var _iterator4 = _createForOfIteratorHelper(this._set.values()),
  5793. _step4;
  5794. try {
  5795. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  5796. var ref = _step4.value;
  5797. callback(ref);
  5798. }
  5799. } catch (err) {
  5800. _iterator4.e(err);
  5801. } finally {
  5802. _iterator4.f();
  5803. }
  5804. }
  5805. }, {
  5806. key: "clear",
  5807. value: function clear() {
  5808. this._set.clear();
  5809. }
  5810. }]);
  5811. return RefSet;
  5812. }();
  5813. exports.RefSet = RefSet;
  5814. var RefSetCache = /*#__PURE__*/function () {
  5815. function RefSetCache() {
  5816. _classCallCheck(this, RefSetCache);
  5817. this._map = new Map();
  5818. }
  5819. _createClass(RefSetCache, [{
  5820. key: "size",
  5821. get: function get() {
  5822. return this._map.size;
  5823. }
  5824. }, {
  5825. key: "get",
  5826. value: function get(ref) {
  5827. return this._map.get(ref.toString());
  5828. }
  5829. }, {
  5830. key: "has",
  5831. value: function has(ref) {
  5832. return this._map.has(ref.toString());
  5833. }
  5834. }, {
  5835. key: "put",
  5836. value: function put(ref, obj) {
  5837. this._map.set(ref.toString(), obj);
  5838. }
  5839. }, {
  5840. key: "putAlias",
  5841. value: function putAlias(ref, aliasRef) {
  5842. this._map.set(ref.toString(), this.get(aliasRef));
  5843. }
  5844. }, {
  5845. key: "forEach",
  5846. value: function forEach(callback) {
  5847. var _iterator5 = _createForOfIteratorHelper(this._map.values()),
  5848. _step5;
  5849. try {
  5850. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  5851. var value = _step5.value;
  5852. callback(value);
  5853. }
  5854. } catch (err) {
  5855. _iterator5.e(err);
  5856. } finally {
  5857. _iterator5.f();
  5858. }
  5859. }
  5860. }, {
  5861. key: "clear",
  5862. value: function clear() {
  5863. this._map.clear();
  5864. }
  5865. }]);
  5866. return RefSetCache;
  5867. }();
  5868. exports.RefSetCache = RefSetCache;
  5869. function isName(v, name) {
  5870. return v instanceof Name && (name === undefined || v.name === name);
  5871. }
  5872. function isCmd(v, cmd) {
  5873. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  5874. }
  5875. function isDict(v, type) {
  5876. return v instanceof Dict && (type === undefined || isName(v.get("Type"), type));
  5877. }
  5878. function isRef(v) {
  5879. return v instanceof Ref;
  5880. }
  5881. function isRefsEqual(v1, v2) {
  5882. return v1.num === v2.num && v1.gen === v2.gen;
  5883. }
  5884. function isStream(v) {
  5885. return v instanceof _base_stream.BaseStream;
  5886. }
  5887. function clearPrimitiveCaches() {
  5888. Cmd._clearCache();
  5889. Name._clearCache();
  5890. Ref._clearCache();
  5891. }
  5892. /***/ }),
  5893. /* 97 */
  5894. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5895. "use strict";
  5896. module.exports = __w_pdfjs_require__(98);
  5897. /***/ }),
  5898. /* 98 */
  5899. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5900. "use strict";
  5901. /* module decorator */ module = __w_pdfjs_require__.nmd(module);
  5902. 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); }
  5903. var runtime = function (exports) {
  5904. "use strict";
  5905. var Op = Object.prototype;
  5906. var hasOwn = Op.hasOwnProperty;
  5907. var undefined;
  5908. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  5909. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  5910. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  5911. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  5912. function define(obj, key, value) {
  5913. Object.defineProperty(obj, key, {
  5914. value: value,
  5915. enumerable: true,
  5916. configurable: true,
  5917. writable: true
  5918. });
  5919. return obj[key];
  5920. }
  5921. try {
  5922. define({}, "");
  5923. } catch (err) {
  5924. define = function define(obj, key, value) {
  5925. return obj[key] = value;
  5926. };
  5927. }
  5928. function wrap(innerFn, outerFn, self, tryLocsList) {
  5929. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  5930. var generator = Object.create(protoGenerator.prototype);
  5931. var context = new Context(tryLocsList || []);
  5932. generator._invoke = makeInvokeMethod(innerFn, self, context);
  5933. return generator;
  5934. }
  5935. exports.wrap = wrap;
  5936. function tryCatch(fn, obj, arg) {
  5937. try {
  5938. return {
  5939. type: "normal",
  5940. arg: fn.call(obj, arg)
  5941. };
  5942. } catch (err) {
  5943. return {
  5944. type: "throw",
  5945. arg: err
  5946. };
  5947. }
  5948. }
  5949. var GenStateSuspendedStart = "suspendedStart";
  5950. var GenStateSuspendedYield = "suspendedYield";
  5951. var GenStateExecuting = "executing";
  5952. var GenStateCompleted = "completed";
  5953. var ContinueSentinel = {};
  5954. function Generator() {}
  5955. function GeneratorFunction() {}
  5956. function GeneratorFunctionPrototype() {}
  5957. var IteratorPrototype = {};
  5958. define(IteratorPrototype, iteratorSymbol, function () {
  5959. return this;
  5960. });
  5961. var getProto = Object.getPrototypeOf;
  5962. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  5963. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  5964. IteratorPrototype = NativeIteratorPrototype;
  5965. }
  5966. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  5967. GeneratorFunction.prototype = GeneratorFunctionPrototype;
  5968. define(Gp, "constructor", GeneratorFunctionPrototype);
  5969. define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
  5970. GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
  5971. function defineIteratorMethods(prototype) {
  5972. ["next", "throw", "return"].forEach(function (method) {
  5973. define(prototype, method, function (arg) {
  5974. return this._invoke(method, arg);
  5975. });
  5976. });
  5977. }
  5978. exports.isGeneratorFunction = function (genFun) {
  5979. var ctor = typeof genFun === "function" && genFun.constructor;
  5980. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  5981. };
  5982. exports.mark = function (genFun) {
  5983. if (Object.setPrototypeOf) {
  5984. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  5985. } else {
  5986. genFun.__proto__ = GeneratorFunctionPrototype;
  5987. define(genFun, toStringTagSymbol, "GeneratorFunction");
  5988. }
  5989. genFun.prototype = Object.create(Gp);
  5990. return genFun;
  5991. };
  5992. exports.awrap = function (arg) {
  5993. return {
  5994. __await: arg
  5995. };
  5996. };
  5997. function AsyncIterator(generator, PromiseImpl) {
  5998. function invoke(method, arg, resolve, reject) {
  5999. var record = tryCatch(generator[method], generator, arg);
  6000. if (record.type === "throw") {
  6001. reject(record.arg);
  6002. } else {
  6003. var result = record.arg;
  6004. var value = result.value;
  6005. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  6006. return PromiseImpl.resolve(value.__await).then(function (value) {
  6007. invoke("next", value, resolve, reject);
  6008. }, function (err) {
  6009. invoke("throw", err, resolve, reject);
  6010. });
  6011. }
  6012. return PromiseImpl.resolve(value).then(function (unwrapped) {
  6013. result.value = unwrapped;
  6014. resolve(result);
  6015. }, function (error) {
  6016. return invoke("throw", error, resolve, reject);
  6017. });
  6018. }
  6019. }
  6020. var previousPromise;
  6021. function enqueue(method, arg) {
  6022. function callInvokeWithMethodAndArg() {
  6023. return new PromiseImpl(function (resolve, reject) {
  6024. invoke(method, arg, resolve, reject);
  6025. });
  6026. }
  6027. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  6028. }
  6029. this._invoke = enqueue;
  6030. }
  6031. defineIteratorMethods(AsyncIterator.prototype);
  6032. define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  6033. return this;
  6034. });
  6035. exports.AsyncIterator = AsyncIterator;
  6036. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  6037. if (PromiseImpl === void 0) PromiseImpl = Promise;
  6038. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  6039. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  6040. return result.done ? result.value : iter.next();
  6041. });
  6042. };
  6043. function makeInvokeMethod(innerFn, self, context) {
  6044. var state = GenStateSuspendedStart;
  6045. return function invoke(method, arg) {
  6046. if (state === GenStateExecuting) {
  6047. throw new Error("Generator is already running");
  6048. }
  6049. if (state === GenStateCompleted) {
  6050. if (method === "throw") {
  6051. throw arg;
  6052. }
  6053. return doneResult();
  6054. }
  6055. context.method = method;
  6056. context.arg = arg;
  6057. while (true) {
  6058. var delegate = context.delegate;
  6059. if (delegate) {
  6060. var delegateResult = maybeInvokeDelegate(delegate, context);
  6061. if (delegateResult) {
  6062. if (delegateResult === ContinueSentinel) continue;
  6063. return delegateResult;
  6064. }
  6065. }
  6066. if (context.method === "next") {
  6067. context.sent = context._sent = context.arg;
  6068. } else if (context.method === "throw") {
  6069. if (state === GenStateSuspendedStart) {
  6070. state = GenStateCompleted;
  6071. throw context.arg;
  6072. }
  6073. context.dispatchException(context.arg);
  6074. } else if (context.method === "return") {
  6075. context.abrupt("return", context.arg);
  6076. }
  6077. state = GenStateExecuting;
  6078. var record = tryCatch(innerFn, self, context);
  6079. if (record.type === "normal") {
  6080. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  6081. if (record.arg === ContinueSentinel) {
  6082. continue;
  6083. }
  6084. return {
  6085. value: record.arg,
  6086. done: context.done
  6087. };
  6088. } else if (record.type === "throw") {
  6089. state = GenStateCompleted;
  6090. context.method = "throw";
  6091. context.arg = record.arg;
  6092. }
  6093. }
  6094. };
  6095. }
  6096. function maybeInvokeDelegate(delegate, context) {
  6097. var method = delegate.iterator[context.method];
  6098. if (method === undefined) {
  6099. context.delegate = null;
  6100. if (context.method === "throw") {
  6101. if (delegate.iterator["return"]) {
  6102. context.method = "return";
  6103. context.arg = undefined;
  6104. maybeInvokeDelegate(delegate, context);
  6105. if (context.method === "throw") {
  6106. return ContinueSentinel;
  6107. }
  6108. }
  6109. context.method = "throw";
  6110. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  6111. }
  6112. return ContinueSentinel;
  6113. }
  6114. var record = tryCatch(method, delegate.iterator, context.arg);
  6115. if (record.type === "throw") {
  6116. context.method = "throw";
  6117. context.arg = record.arg;
  6118. context.delegate = null;
  6119. return ContinueSentinel;
  6120. }
  6121. var info = record.arg;
  6122. if (!info) {
  6123. context.method = "throw";
  6124. context.arg = new TypeError("iterator result is not an object");
  6125. context.delegate = null;
  6126. return ContinueSentinel;
  6127. }
  6128. if (info.done) {
  6129. context[delegate.resultName] = info.value;
  6130. context.next = delegate.nextLoc;
  6131. if (context.method !== "return") {
  6132. context.method = "next";
  6133. context.arg = undefined;
  6134. }
  6135. } else {
  6136. return info;
  6137. }
  6138. context.delegate = null;
  6139. return ContinueSentinel;
  6140. }
  6141. defineIteratorMethods(Gp);
  6142. define(Gp, toStringTagSymbol, "Generator");
  6143. define(Gp, iteratorSymbol, function () {
  6144. return this;
  6145. });
  6146. define(Gp, "toString", function () {
  6147. return "[object Generator]";
  6148. });
  6149. function pushTryEntry(locs) {
  6150. var entry = {
  6151. tryLoc: locs[0]
  6152. };
  6153. if (1 in locs) {
  6154. entry.catchLoc = locs[1];
  6155. }
  6156. if (2 in locs) {
  6157. entry.finallyLoc = locs[2];
  6158. entry.afterLoc = locs[3];
  6159. }
  6160. this.tryEntries.push(entry);
  6161. }
  6162. function resetTryEntry(entry) {
  6163. var record = entry.completion || {};
  6164. record.type = "normal";
  6165. delete record.arg;
  6166. entry.completion = record;
  6167. }
  6168. function Context(tryLocsList) {
  6169. this.tryEntries = [{
  6170. tryLoc: "root"
  6171. }];
  6172. tryLocsList.forEach(pushTryEntry, this);
  6173. this.reset(true);
  6174. }
  6175. exports.keys = function (object) {
  6176. var keys = [];
  6177. for (var key in object) {
  6178. keys.push(key);
  6179. }
  6180. keys.reverse();
  6181. return function next() {
  6182. while (keys.length) {
  6183. var key = keys.pop();
  6184. if (key in object) {
  6185. next.value = key;
  6186. next.done = false;
  6187. return next;
  6188. }
  6189. }
  6190. next.done = true;
  6191. return next;
  6192. };
  6193. };
  6194. function values(iterable) {
  6195. if (iterable) {
  6196. var iteratorMethod = iterable[iteratorSymbol];
  6197. if (iteratorMethod) {
  6198. return iteratorMethod.call(iterable);
  6199. }
  6200. if (typeof iterable.next === "function") {
  6201. return iterable;
  6202. }
  6203. if (!isNaN(iterable.length)) {
  6204. var i = -1,
  6205. next = function next() {
  6206. while (++i < iterable.length) {
  6207. if (hasOwn.call(iterable, i)) {
  6208. next.value = iterable[i];
  6209. next.done = false;
  6210. return next;
  6211. }
  6212. }
  6213. next.value = undefined;
  6214. next.done = true;
  6215. return next;
  6216. };
  6217. return next.next = next;
  6218. }
  6219. }
  6220. return {
  6221. next: doneResult
  6222. };
  6223. }
  6224. exports.values = values;
  6225. function doneResult() {
  6226. return {
  6227. value: undefined,
  6228. done: true
  6229. };
  6230. }
  6231. Context.prototype = {
  6232. constructor: Context,
  6233. reset: function reset(skipTempReset) {
  6234. this.prev = 0;
  6235. this.next = 0;
  6236. this.sent = this._sent = undefined;
  6237. this.done = false;
  6238. this.delegate = null;
  6239. this.method = "next";
  6240. this.arg = undefined;
  6241. this.tryEntries.forEach(resetTryEntry);
  6242. if (!skipTempReset) {
  6243. for (var name in this) {
  6244. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  6245. this[name] = undefined;
  6246. }
  6247. }
  6248. }
  6249. },
  6250. stop: function stop() {
  6251. this.done = true;
  6252. var rootEntry = this.tryEntries[0];
  6253. var rootRecord = rootEntry.completion;
  6254. if (rootRecord.type === "throw") {
  6255. throw rootRecord.arg;
  6256. }
  6257. return this.rval;
  6258. },
  6259. dispatchException: function dispatchException(exception) {
  6260. if (this.done) {
  6261. throw exception;
  6262. }
  6263. var context = this;
  6264. function handle(loc, caught) {
  6265. record.type = "throw";
  6266. record.arg = exception;
  6267. context.next = loc;
  6268. if (caught) {
  6269. context.method = "next";
  6270. context.arg = undefined;
  6271. }
  6272. return !!caught;
  6273. }
  6274. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  6275. var entry = this.tryEntries[i];
  6276. var record = entry.completion;
  6277. if (entry.tryLoc === "root") {
  6278. return handle("end");
  6279. }
  6280. if (entry.tryLoc <= this.prev) {
  6281. var hasCatch = hasOwn.call(entry, "catchLoc");
  6282. var hasFinally = hasOwn.call(entry, "finallyLoc");
  6283. if (hasCatch && hasFinally) {
  6284. if (this.prev < entry.catchLoc) {
  6285. return handle(entry.catchLoc, true);
  6286. } else if (this.prev < entry.finallyLoc) {
  6287. return handle(entry.finallyLoc);
  6288. }
  6289. } else if (hasCatch) {
  6290. if (this.prev < entry.catchLoc) {
  6291. return handle(entry.catchLoc, true);
  6292. }
  6293. } else if (hasFinally) {
  6294. if (this.prev < entry.finallyLoc) {
  6295. return handle(entry.finallyLoc);
  6296. }
  6297. } else {
  6298. throw new Error("try statement without catch or finally");
  6299. }
  6300. }
  6301. }
  6302. },
  6303. abrupt: function abrupt(type, arg) {
  6304. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  6305. var entry = this.tryEntries[i];
  6306. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  6307. var finallyEntry = entry;
  6308. break;
  6309. }
  6310. }
  6311. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  6312. finallyEntry = null;
  6313. }
  6314. var record = finallyEntry ? finallyEntry.completion : {};
  6315. record.type = type;
  6316. record.arg = arg;
  6317. if (finallyEntry) {
  6318. this.method = "next";
  6319. this.next = finallyEntry.finallyLoc;
  6320. return ContinueSentinel;
  6321. }
  6322. return this.complete(record);
  6323. },
  6324. complete: function complete(record, afterLoc) {
  6325. if (record.type === "throw") {
  6326. throw record.arg;
  6327. }
  6328. if (record.type === "break" || record.type === "continue") {
  6329. this.next = record.arg;
  6330. } else if (record.type === "return") {
  6331. this.rval = this.arg = record.arg;
  6332. this.method = "return";
  6333. this.next = "end";
  6334. } else if (record.type === "normal" && afterLoc) {
  6335. this.next = afterLoc;
  6336. }
  6337. return ContinueSentinel;
  6338. },
  6339. finish: function finish(finallyLoc) {
  6340. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  6341. var entry = this.tryEntries[i];
  6342. if (entry.finallyLoc === finallyLoc) {
  6343. this.complete(entry.completion, entry.afterLoc);
  6344. resetTryEntry(entry);
  6345. return ContinueSentinel;
  6346. }
  6347. }
  6348. },
  6349. "catch": function _catch(tryLoc) {
  6350. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  6351. var entry = this.tryEntries[i];
  6352. if (entry.tryLoc === tryLoc) {
  6353. var record = entry.completion;
  6354. if (record.type === "throw") {
  6355. var thrown = record.arg;
  6356. resetTryEntry(entry);
  6357. }
  6358. return thrown;
  6359. }
  6360. }
  6361. throw new Error("illegal catch attempt");
  6362. },
  6363. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  6364. this.delegate = {
  6365. iterator: values(iterable),
  6366. resultName: resultName,
  6367. nextLoc: nextLoc
  6368. };
  6369. if (this.method === "next") {
  6370. this.arg = undefined;
  6371. }
  6372. return ContinueSentinel;
  6373. }
  6374. };
  6375. return exports;
  6376. }(( false ? 0 : _typeof(module)) === "object" ? module.exports : {});
  6377. try {
  6378. regeneratorRuntime = runtime;
  6379. } catch (accidentalStrictMode) {
  6380. if ((typeof globalThis === "undefined" ? "undefined" : _typeof(globalThis)) === "object") {
  6381. globalThis.regeneratorRuntime = runtime;
  6382. } else {
  6383. Function("r", "regeneratorRuntime = r")(runtime);
  6384. }
  6385. }
  6386. /***/ }),
  6387. /* 99 */
  6388. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  6389. "use strict";
  6390. Object.defineProperty(exports, "__esModule", ({
  6391. value: true
  6392. }));
  6393. exports.BaseStream = void 0;
  6394. var _util = __w_pdfjs_require__(1);
  6395. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6396. 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); } }
  6397. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6398. var BaseStream = /*#__PURE__*/function () {
  6399. function BaseStream() {
  6400. _classCallCheck(this, BaseStream);
  6401. if (this.constructor === BaseStream) {
  6402. (0, _util.unreachable)("Cannot initialize BaseStream.");
  6403. }
  6404. }
  6405. _createClass(BaseStream, [{
  6406. key: "length",
  6407. get: function get() {
  6408. (0, _util.unreachable)("Abstract getter `length` accessed");
  6409. }
  6410. }, {
  6411. key: "isEmpty",
  6412. get: function get() {
  6413. (0, _util.unreachable)("Abstract getter `isEmpty` accessed");
  6414. }
  6415. }, {
  6416. key: "isDataLoaded",
  6417. get: function get() {
  6418. return (0, _util.shadow)(this, "isDataLoaded", true);
  6419. }
  6420. }, {
  6421. key: "getByte",
  6422. value: function getByte() {
  6423. (0, _util.unreachable)("Abstract method `getByte` called");
  6424. }
  6425. }, {
  6426. key: "getBytes",
  6427. value: function getBytes(length) {
  6428. var forceClamped = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6429. (0, _util.unreachable)("Abstract method `getBytes` called");
  6430. }
  6431. }, {
  6432. key: "peekByte",
  6433. value: function peekByte() {
  6434. var peekedByte = this.getByte();
  6435. if (peekedByte !== -1) {
  6436. this.pos--;
  6437. }
  6438. return peekedByte;
  6439. }
  6440. }, {
  6441. key: "peekBytes",
  6442. value: function peekBytes(length) {
  6443. var forceClamped = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6444. var bytes = this.getBytes(length, forceClamped);
  6445. this.pos -= bytes.length;
  6446. return bytes;
  6447. }
  6448. }, {
  6449. key: "getUint16",
  6450. value: function getUint16() {
  6451. var b0 = this.getByte();
  6452. var b1 = this.getByte();
  6453. if (b0 === -1 || b1 === -1) {
  6454. return -1;
  6455. }
  6456. return (b0 << 8) + b1;
  6457. }
  6458. }, {
  6459. key: "getInt32",
  6460. value: function getInt32() {
  6461. var b0 = this.getByte();
  6462. var b1 = this.getByte();
  6463. var b2 = this.getByte();
  6464. var b3 = this.getByte();
  6465. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  6466. }
  6467. }, {
  6468. key: "getByteRange",
  6469. value: function getByteRange(begin, end) {
  6470. (0, _util.unreachable)("Abstract method `getByteRange` called");
  6471. }
  6472. }, {
  6473. key: "getString",
  6474. value: function getString(length) {
  6475. return (0, _util.bytesToString)(this.getBytes(length, false));
  6476. }
  6477. }, {
  6478. key: "skip",
  6479. value: function skip(n) {
  6480. this.pos += n || 1;
  6481. }
  6482. }, {
  6483. key: "reset",
  6484. value: function reset() {
  6485. (0, _util.unreachable)("Abstract method `reset` called");
  6486. }
  6487. }, {
  6488. key: "moveStart",
  6489. value: function moveStart() {
  6490. (0, _util.unreachable)("Abstract method `moveStart` called");
  6491. }
  6492. }, {
  6493. key: "makeSubStream",
  6494. value: function makeSubStream(start, length) {
  6495. var dict = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6496. (0, _util.unreachable)("Abstract method `makeSubStream` called");
  6497. }
  6498. }, {
  6499. key: "getBaseStreams",
  6500. value: function getBaseStreams() {
  6501. return null;
  6502. }
  6503. }]);
  6504. return BaseStream;
  6505. }();
  6506. exports.BaseStream = BaseStream;
  6507. /***/ }),
  6508. /* 100 */
  6509. /***/ ((__unused_webpack_module, exports) => {
  6510. "use strict";
  6511. Object.defineProperty(exports, "__esModule", ({
  6512. value: true
  6513. }));
  6514. exports.ArithmeticDecoder = void 0;
  6515. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6516. 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); } }
  6517. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6518. var QeTable = [{
  6519. qe: 0x5601,
  6520. nmps: 1,
  6521. nlps: 1,
  6522. switchFlag: 1
  6523. }, {
  6524. qe: 0x3401,
  6525. nmps: 2,
  6526. nlps: 6,
  6527. switchFlag: 0
  6528. }, {
  6529. qe: 0x1801,
  6530. nmps: 3,
  6531. nlps: 9,
  6532. switchFlag: 0
  6533. }, {
  6534. qe: 0x0ac1,
  6535. nmps: 4,
  6536. nlps: 12,
  6537. switchFlag: 0
  6538. }, {
  6539. qe: 0x0521,
  6540. nmps: 5,
  6541. nlps: 29,
  6542. switchFlag: 0
  6543. }, {
  6544. qe: 0x0221,
  6545. nmps: 38,
  6546. nlps: 33,
  6547. switchFlag: 0
  6548. }, {
  6549. qe: 0x5601,
  6550. nmps: 7,
  6551. nlps: 6,
  6552. switchFlag: 1
  6553. }, {
  6554. qe: 0x5401,
  6555. nmps: 8,
  6556. nlps: 14,
  6557. switchFlag: 0
  6558. }, {
  6559. qe: 0x4801,
  6560. nmps: 9,
  6561. nlps: 14,
  6562. switchFlag: 0
  6563. }, {
  6564. qe: 0x3801,
  6565. nmps: 10,
  6566. nlps: 14,
  6567. switchFlag: 0
  6568. }, {
  6569. qe: 0x3001,
  6570. nmps: 11,
  6571. nlps: 17,
  6572. switchFlag: 0
  6573. }, {
  6574. qe: 0x2401,
  6575. nmps: 12,
  6576. nlps: 18,
  6577. switchFlag: 0
  6578. }, {
  6579. qe: 0x1c01,
  6580. nmps: 13,
  6581. nlps: 20,
  6582. switchFlag: 0
  6583. }, {
  6584. qe: 0x1601,
  6585. nmps: 29,
  6586. nlps: 21,
  6587. switchFlag: 0
  6588. }, {
  6589. qe: 0x5601,
  6590. nmps: 15,
  6591. nlps: 14,
  6592. switchFlag: 1
  6593. }, {
  6594. qe: 0x5401,
  6595. nmps: 16,
  6596. nlps: 14,
  6597. switchFlag: 0
  6598. }, {
  6599. qe: 0x5101,
  6600. nmps: 17,
  6601. nlps: 15,
  6602. switchFlag: 0
  6603. }, {
  6604. qe: 0x4801,
  6605. nmps: 18,
  6606. nlps: 16,
  6607. switchFlag: 0
  6608. }, {
  6609. qe: 0x3801,
  6610. nmps: 19,
  6611. nlps: 17,
  6612. switchFlag: 0
  6613. }, {
  6614. qe: 0x3401,
  6615. nmps: 20,
  6616. nlps: 18,
  6617. switchFlag: 0
  6618. }, {
  6619. qe: 0x3001,
  6620. nmps: 21,
  6621. nlps: 19,
  6622. switchFlag: 0
  6623. }, {
  6624. qe: 0x2801,
  6625. nmps: 22,
  6626. nlps: 19,
  6627. switchFlag: 0
  6628. }, {
  6629. qe: 0x2401,
  6630. nmps: 23,
  6631. nlps: 20,
  6632. switchFlag: 0
  6633. }, {
  6634. qe: 0x2201,
  6635. nmps: 24,
  6636. nlps: 21,
  6637. switchFlag: 0
  6638. }, {
  6639. qe: 0x1c01,
  6640. nmps: 25,
  6641. nlps: 22,
  6642. switchFlag: 0
  6643. }, {
  6644. qe: 0x1801,
  6645. nmps: 26,
  6646. nlps: 23,
  6647. switchFlag: 0
  6648. }, {
  6649. qe: 0x1601,
  6650. nmps: 27,
  6651. nlps: 24,
  6652. switchFlag: 0
  6653. }, {
  6654. qe: 0x1401,
  6655. nmps: 28,
  6656. nlps: 25,
  6657. switchFlag: 0
  6658. }, {
  6659. qe: 0x1201,
  6660. nmps: 29,
  6661. nlps: 26,
  6662. switchFlag: 0
  6663. }, {
  6664. qe: 0x1101,
  6665. nmps: 30,
  6666. nlps: 27,
  6667. switchFlag: 0
  6668. }, {
  6669. qe: 0x0ac1,
  6670. nmps: 31,
  6671. nlps: 28,
  6672. switchFlag: 0
  6673. }, {
  6674. qe: 0x09c1,
  6675. nmps: 32,
  6676. nlps: 29,
  6677. switchFlag: 0
  6678. }, {
  6679. qe: 0x08a1,
  6680. nmps: 33,
  6681. nlps: 30,
  6682. switchFlag: 0
  6683. }, {
  6684. qe: 0x0521,
  6685. nmps: 34,
  6686. nlps: 31,
  6687. switchFlag: 0
  6688. }, {
  6689. qe: 0x0441,
  6690. nmps: 35,
  6691. nlps: 32,
  6692. switchFlag: 0
  6693. }, {
  6694. qe: 0x02a1,
  6695. nmps: 36,
  6696. nlps: 33,
  6697. switchFlag: 0
  6698. }, {
  6699. qe: 0x0221,
  6700. nmps: 37,
  6701. nlps: 34,
  6702. switchFlag: 0
  6703. }, {
  6704. qe: 0x0141,
  6705. nmps: 38,
  6706. nlps: 35,
  6707. switchFlag: 0
  6708. }, {
  6709. qe: 0x0111,
  6710. nmps: 39,
  6711. nlps: 36,
  6712. switchFlag: 0
  6713. }, {
  6714. qe: 0x0085,
  6715. nmps: 40,
  6716. nlps: 37,
  6717. switchFlag: 0
  6718. }, {
  6719. qe: 0x0049,
  6720. nmps: 41,
  6721. nlps: 38,
  6722. switchFlag: 0
  6723. }, {
  6724. qe: 0x0025,
  6725. nmps: 42,
  6726. nlps: 39,
  6727. switchFlag: 0
  6728. }, {
  6729. qe: 0x0015,
  6730. nmps: 43,
  6731. nlps: 40,
  6732. switchFlag: 0
  6733. }, {
  6734. qe: 0x0009,
  6735. nmps: 44,
  6736. nlps: 41,
  6737. switchFlag: 0
  6738. }, {
  6739. qe: 0x0005,
  6740. nmps: 45,
  6741. nlps: 42,
  6742. switchFlag: 0
  6743. }, {
  6744. qe: 0x0001,
  6745. nmps: 45,
  6746. nlps: 43,
  6747. switchFlag: 0
  6748. }, {
  6749. qe: 0x5601,
  6750. nmps: 46,
  6751. nlps: 46,
  6752. switchFlag: 0
  6753. }];
  6754. var ArithmeticDecoder = /*#__PURE__*/function () {
  6755. function ArithmeticDecoder(data, start, end) {
  6756. _classCallCheck(this, ArithmeticDecoder);
  6757. this.data = data;
  6758. this.bp = start;
  6759. this.dataEnd = end;
  6760. this.chigh = data[start];
  6761. this.clow = 0;
  6762. this.byteIn();
  6763. this.chigh = this.chigh << 7 & 0xffff | this.clow >> 9 & 0x7f;
  6764. this.clow = this.clow << 7 & 0xffff;
  6765. this.ct -= 7;
  6766. this.a = 0x8000;
  6767. }
  6768. _createClass(ArithmeticDecoder, [{
  6769. key: "byteIn",
  6770. value: function byteIn() {
  6771. var data = this.data;
  6772. var bp = this.bp;
  6773. if (data[bp] === 0xff) {
  6774. if (data[bp + 1] > 0x8f) {
  6775. this.clow += 0xff00;
  6776. this.ct = 8;
  6777. } else {
  6778. bp++;
  6779. this.clow += data[bp] << 9;
  6780. this.ct = 7;
  6781. this.bp = bp;
  6782. }
  6783. } else {
  6784. bp++;
  6785. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xff00;
  6786. this.ct = 8;
  6787. this.bp = bp;
  6788. }
  6789. if (this.clow > 0xffff) {
  6790. this.chigh += this.clow >> 16;
  6791. this.clow &= 0xffff;
  6792. }
  6793. }
  6794. }, {
  6795. key: "readBit",
  6796. value: function readBit(contexts, pos) {
  6797. var cx_index = contexts[pos] >> 1,
  6798. cx_mps = contexts[pos] & 1;
  6799. var qeTableIcx = QeTable[cx_index];
  6800. var qeIcx = qeTableIcx.qe;
  6801. var d;
  6802. var a = this.a - qeIcx;
  6803. if (this.chigh < qeIcx) {
  6804. if (a < qeIcx) {
  6805. a = qeIcx;
  6806. d = cx_mps;
  6807. cx_index = qeTableIcx.nmps;
  6808. } else {
  6809. a = qeIcx;
  6810. d = 1 ^ cx_mps;
  6811. if (qeTableIcx.switchFlag === 1) {
  6812. cx_mps = d;
  6813. }
  6814. cx_index = qeTableIcx.nlps;
  6815. }
  6816. } else {
  6817. this.chigh -= qeIcx;
  6818. if ((a & 0x8000) !== 0) {
  6819. this.a = a;
  6820. return cx_mps;
  6821. }
  6822. if (a < qeIcx) {
  6823. d = 1 ^ cx_mps;
  6824. if (qeTableIcx.switchFlag === 1) {
  6825. cx_mps = d;
  6826. }
  6827. cx_index = qeTableIcx.nlps;
  6828. } else {
  6829. d = cx_mps;
  6830. cx_index = qeTableIcx.nmps;
  6831. }
  6832. }
  6833. do {
  6834. if (this.ct === 0) {
  6835. this.byteIn();
  6836. }
  6837. a <<= 1;
  6838. this.chigh = this.chigh << 1 & 0xffff | this.clow >> 15 & 1;
  6839. this.clow = this.clow << 1 & 0xffff;
  6840. this.ct--;
  6841. } while ((a & 0x8000) === 0);
  6842. this.a = a;
  6843. contexts[pos] = cx_index << 1 | cx_mps;
  6844. return d;
  6845. }
  6846. }]);
  6847. return ArithmeticDecoder;
  6848. }();
  6849. exports.ArithmeticDecoder = ArithmeticDecoder;
  6850. /***/ }),
  6851. /* 101 */
  6852. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  6853. "use strict";
  6854. Object.defineProperty(exports, "__esModule", ({
  6855. value: true
  6856. }));
  6857. exports.CCITTFaxDecoder = void 0;
  6858. var _util = __w_pdfjs_require__(1);
  6859. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6860. 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); } }
  6861. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6862. var ccittEOL = -2;
  6863. var ccittEOF = -1;
  6864. var twoDimPass = 0;
  6865. var twoDimHoriz = 1;
  6866. var twoDimVert0 = 2;
  6867. var twoDimVertR1 = 3;
  6868. var twoDimVertL1 = 4;
  6869. var twoDimVertR2 = 5;
  6870. var twoDimVertL2 = 6;
  6871. var twoDimVertR3 = 7;
  6872. var twoDimVertL3 = 8;
  6873. var twoDimTable = [[-1, -1], [-1, -1], [7, twoDimVertL3], [7, twoDimVertR3], [6, twoDimVertL2], [6, twoDimVertL2], [6, twoDimVertR2], [6, twoDimVertR2], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0]];
  6874. var whiteTable1 = [[-1, -1], [12, ccittEOL], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [11, 1792], [11, 1792], [12, 1984], [12, 2048], [12, 2112], [12, 2176], [12, 2240], [12, 2304], [11, 1856], [11, 1856], [11, 1920], [11, 1920], [12, 2368], [12, 2432], [12, 2496], [12, 2560]];
  6875. var whiteTable2 = [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [8, 29], [8, 29], [8, 30], [8, 30], [8, 45], [8, 45], [8, 46], [8, 46], [7, 22], [7, 22], [7, 22], [7, 22], [7, 23], [7, 23], [7, 23], [7, 23], [8, 47], [8, 47], [8, 48], [8, 48], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [7, 20], [7, 20], [7, 20], [7, 20], [8, 33], [8, 33], [8, 34], [8, 34], [8, 35], [8, 35], [8, 36], [8, 36], [8, 37], [8, 37], [8, 38], [8, 38], [7, 19], [7, 19], [7, 19], [7, 19], [8, 31], [8, 31], [8, 32], [8, 32], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [8, 53], [8, 53], [8, 54], [8, 54], [7, 26], [7, 26], [7, 26], [7, 26], [8, 39], [8, 39], [8, 40], [8, 40], [8, 41], [8, 41], [8, 42], [8, 42], [8, 43], [8, 43], [8, 44], [8, 44], [7, 21], [7, 21], [7, 21], [7, 21], [7, 28], [7, 28], [7, 28], [7, 28], [8, 61], [8, 61], [8, 62], [8, 62], [8, 63], [8, 63], [8, 0], [8, 0], [8, 320], [8, 320], [8, 384], [8, 384], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [7, 27], [7, 27], [7, 27], [7, 27], [8, 59], [8, 59], [8, 60], [8, 60], [9, 1472], [9, 1536], [9, 1600], [9, 1728], [7, 18], [7, 18], [7, 18], [7, 18], [7, 24], [7, 24], [7, 24], [7, 24], [8, 49], [8, 49], [8, 50], [8, 50], [8, 51], [8, 51], [8, 52], [8, 52], [7, 25], [7, 25], [7, 25], [7, 25], [8, 55], [8, 55], [8, 56], [8, 56], [8, 57], [8, 57], [8, 58], [8, 58], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [8, 448], [8, 448], [8, 512], [8, 512], [9, 704], [9, 768], [8, 640], [8, 640], [8, 576], [8, 576], [9, 832], [9, 896], [9, 960], [9, 1024], [9, 1088], [9, 1152], [9, 1216], [9, 1280], [9, 1344], [9, 1408], [7, 256], [7, 256], [7, 256], [7, 256], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7]];
  6876. var blackTable1 = [[-1, -1], [-1, -1], [12, ccittEOL], [12, ccittEOL], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [11, 1792], [11, 1792], [11, 1792], [11, 1792], [12, 1984], [12, 1984], [12, 2048], [12, 2048], [12, 2112], [12, 2112], [12, 2176], [12, 2176], [12, 2240], [12, 2240], [12, 2304], [12, 2304], [11, 1856], [11, 1856], [11, 1856], [11, 1856], [11, 1920], [11, 1920], [11, 1920], [11, 1920], [12, 2368], [12, 2368], [12, 2432], [12, 2432], [12, 2496], [12, 2496], [12, 2560], [12, 2560], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [12, 52], [12, 52], [13, 640], [13, 704], [13, 768], [13, 832], [12, 55], [12, 55], [12, 56], [12, 56], [13, 1280], [13, 1344], [13, 1408], [13, 1472], [12, 59], [12, 59], [12, 60], [12, 60], [13, 1536], [13, 1600], [11, 24], [11, 24], [11, 24], [11, 24], [11, 25], [11, 25], [11, 25], [11, 25], [13, 1664], [13, 1728], [12, 320], [12, 320], [12, 384], [12, 384], [12, 448], [12, 448], [13, 512], [13, 576], [12, 53], [12, 53], [12, 54], [12, 54], [13, 896], [13, 960], [13, 1024], [13, 1088], [13, 1152], [13, 1216], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64]];
  6877. var blackTable2 = [[8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [11, 23], [11, 23], [12, 50], [12, 51], [12, 44], [12, 45], [12, 46], [12, 47], [12, 57], [12, 58], [12, 61], [12, 256], [10, 16], [10, 16], [10, 16], [10, 16], [10, 17], [10, 17], [10, 17], [10, 17], [12, 48], [12, 49], [12, 62], [12, 63], [12, 30], [12, 31], [12, 32], [12, 33], [12, 40], [12, 41], [11, 22], [11, 22], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [12, 128], [12, 192], [12, 26], [12, 27], [12, 28], [12, 29], [11, 19], [11, 19], [11, 20], [11, 20], [12, 34], [12, 35], [12, 36], [12, 37], [12, 38], [12, 39], [11, 21], [11, 21], [12, 42], [12, 43], [10, 0], [10, 0], [10, 0], [10, 0], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12]];
  6878. var blackTable3 = [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [6, 9], [6, 8], [5, 7], [5, 7], [4, 6], [4, 6], [4, 6], [4, 6], [4, 5], [4, 5], [4, 5], [4, 5], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]];
  6879. var CCITTFaxDecoder = /*#__PURE__*/function () {
  6880. function CCITTFaxDecoder(source) {
  6881. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6882. _classCallCheck(this, CCITTFaxDecoder);
  6883. if (!source || typeof source.next !== "function") {
  6884. throw new Error('CCITTFaxDecoder - invalid "source" parameter.');
  6885. }
  6886. this.source = source;
  6887. this.eof = false;
  6888. this.encoding = options.K || 0;
  6889. this.eoline = options.EndOfLine || false;
  6890. this.byteAlign = options.EncodedByteAlign || false;
  6891. this.columns = options.Columns || 1728;
  6892. this.rows = options.Rows || 0;
  6893. var eoblock = options.EndOfBlock;
  6894. if (eoblock === null || eoblock === undefined) {
  6895. eoblock = true;
  6896. }
  6897. this.eoblock = eoblock;
  6898. this.black = options.BlackIs1 || false;
  6899. this.codingLine = new Uint32Array(this.columns + 1);
  6900. this.refLine = new Uint32Array(this.columns + 2);
  6901. this.codingLine[0] = this.columns;
  6902. this.codingPos = 0;
  6903. this.row = 0;
  6904. this.nextLine2D = this.encoding < 0;
  6905. this.inputBits = 0;
  6906. this.inputBuf = 0;
  6907. this.outputBits = 0;
  6908. this.rowsDone = false;
  6909. var code1;
  6910. while ((code1 = this._lookBits(12)) === 0) {
  6911. this._eatBits(1);
  6912. }
  6913. if (code1 === 1) {
  6914. this._eatBits(12);
  6915. }
  6916. if (this.encoding > 0) {
  6917. this.nextLine2D = !this._lookBits(1);
  6918. this._eatBits(1);
  6919. }
  6920. }
  6921. _createClass(CCITTFaxDecoder, [{
  6922. key: "readNextChar",
  6923. value: function readNextChar() {
  6924. if (this.eof) {
  6925. return -1;
  6926. }
  6927. var refLine = this.refLine;
  6928. var codingLine = this.codingLine;
  6929. var columns = this.columns;
  6930. var refPos, blackPixels, bits, i;
  6931. if (this.outputBits === 0) {
  6932. if (this.rowsDone) {
  6933. this.eof = true;
  6934. }
  6935. if (this.eof) {
  6936. return -1;
  6937. }
  6938. this.err = false;
  6939. var code1, code2, code3;
  6940. if (this.nextLine2D) {
  6941. for (i = 0; codingLine[i] < columns; ++i) {
  6942. refLine[i] = codingLine[i];
  6943. }
  6944. refLine[i++] = columns;
  6945. refLine[i] = columns;
  6946. codingLine[0] = 0;
  6947. this.codingPos = 0;
  6948. refPos = 0;
  6949. blackPixels = 0;
  6950. while (codingLine[this.codingPos] < columns) {
  6951. code1 = this._getTwoDimCode();
  6952. switch (code1) {
  6953. case twoDimPass:
  6954. this._addPixels(refLine[refPos + 1], blackPixels);
  6955. if (refLine[refPos + 1] < columns) {
  6956. refPos += 2;
  6957. }
  6958. break;
  6959. case twoDimHoriz:
  6960. code1 = code2 = 0;
  6961. if (blackPixels) {
  6962. do {
  6963. code1 += code3 = this._getBlackCode();
  6964. } while (code3 >= 64);
  6965. do {
  6966. code2 += code3 = this._getWhiteCode();
  6967. } while (code3 >= 64);
  6968. } else {
  6969. do {
  6970. code1 += code3 = this._getWhiteCode();
  6971. } while (code3 >= 64);
  6972. do {
  6973. code2 += code3 = this._getBlackCode();
  6974. } while (code3 >= 64);
  6975. }
  6976. this._addPixels(codingLine[this.codingPos] + code1, blackPixels);
  6977. if (codingLine[this.codingPos] < columns) {
  6978. this._addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  6979. }
  6980. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  6981. refPos += 2;
  6982. }
  6983. break;
  6984. case twoDimVertR3:
  6985. this._addPixels(refLine[refPos] + 3, blackPixels);
  6986. blackPixels ^= 1;
  6987. if (codingLine[this.codingPos] < columns) {
  6988. ++refPos;
  6989. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  6990. refPos += 2;
  6991. }
  6992. }
  6993. break;
  6994. case twoDimVertR2:
  6995. this._addPixels(refLine[refPos] + 2, blackPixels);
  6996. blackPixels ^= 1;
  6997. if (codingLine[this.codingPos] < columns) {
  6998. ++refPos;
  6999. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7000. refPos += 2;
  7001. }
  7002. }
  7003. break;
  7004. case twoDimVertR1:
  7005. this._addPixels(refLine[refPos] + 1, blackPixels);
  7006. blackPixels ^= 1;
  7007. if (codingLine[this.codingPos] < columns) {
  7008. ++refPos;
  7009. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7010. refPos += 2;
  7011. }
  7012. }
  7013. break;
  7014. case twoDimVert0:
  7015. this._addPixels(refLine[refPos], blackPixels);
  7016. blackPixels ^= 1;
  7017. if (codingLine[this.codingPos] < columns) {
  7018. ++refPos;
  7019. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7020. refPos += 2;
  7021. }
  7022. }
  7023. break;
  7024. case twoDimVertL3:
  7025. this._addPixelsNeg(refLine[refPos] - 3, blackPixels);
  7026. blackPixels ^= 1;
  7027. if (codingLine[this.codingPos] < columns) {
  7028. if (refPos > 0) {
  7029. --refPos;
  7030. } else {
  7031. ++refPos;
  7032. }
  7033. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7034. refPos += 2;
  7035. }
  7036. }
  7037. break;
  7038. case twoDimVertL2:
  7039. this._addPixelsNeg(refLine[refPos] - 2, blackPixels);
  7040. blackPixels ^= 1;
  7041. if (codingLine[this.codingPos] < columns) {
  7042. if (refPos > 0) {
  7043. --refPos;
  7044. } else {
  7045. ++refPos;
  7046. }
  7047. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7048. refPos += 2;
  7049. }
  7050. }
  7051. break;
  7052. case twoDimVertL1:
  7053. this._addPixelsNeg(refLine[refPos] - 1, blackPixels);
  7054. blackPixels ^= 1;
  7055. if (codingLine[this.codingPos] < columns) {
  7056. if (refPos > 0) {
  7057. --refPos;
  7058. } else {
  7059. ++refPos;
  7060. }
  7061. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7062. refPos += 2;
  7063. }
  7064. }
  7065. break;
  7066. case ccittEOF:
  7067. this._addPixels(columns, 0);
  7068. this.eof = true;
  7069. break;
  7070. default:
  7071. (0, _util.info)("bad 2d code");
  7072. this._addPixels(columns, 0);
  7073. this.err = true;
  7074. }
  7075. }
  7076. } else {
  7077. codingLine[0] = 0;
  7078. this.codingPos = 0;
  7079. blackPixels = 0;
  7080. while (codingLine[this.codingPos] < columns) {
  7081. code1 = 0;
  7082. if (blackPixels) {
  7083. do {
  7084. code1 += code3 = this._getBlackCode();
  7085. } while (code3 >= 64);
  7086. } else {
  7087. do {
  7088. code1 += code3 = this._getWhiteCode();
  7089. } while (code3 >= 64);
  7090. }
  7091. this._addPixels(codingLine[this.codingPos] + code1, blackPixels);
  7092. blackPixels ^= 1;
  7093. }
  7094. }
  7095. var gotEOL = false;
  7096. if (this.byteAlign) {
  7097. this.inputBits &= ~7;
  7098. }
  7099. if (!this.eoblock && this.row === this.rows - 1) {
  7100. this.rowsDone = true;
  7101. } else {
  7102. code1 = this._lookBits(12);
  7103. if (this.eoline) {
  7104. while (code1 !== ccittEOF && code1 !== 1) {
  7105. this._eatBits(1);
  7106. code1 = this._lookBits(12);
  7107. }
  7108. } else {
  7109. while (code1 === 0) {
  7110. this._eatBits(1);
  7111. code1 = this._lookBits(12);
  7112. }
  7113. }
  7114. if (code1 === 1) {
  7115. this._eatBits(12);
  7116. gotEOL = true;
  7117. } else if (code1 === ccittEOF) {
  7118. this.eof = true;
  7119. }
  7120. }
  7121. if (!this.eof && this.encoding > 0 && !this.rowsDone) {
  7122. this.nextLine2D = !this._lookBits(1);
  7123. this._eatBits(1);
  7124. }
  7125. if (this.eoblock && gotEOL && this.byteAlign) {
  7126. code1 = this._lookBits(12);
  7127. if (code1 === 1) {
  7128. this._eatBits(12);
  7129. if (this.encoding > 0) {
  7130. this._lookBits(1);
  7131. this._eatBits(1);
  7132. }
  7133. if (this.encoding >= 0) {
  7134. for (i = 0; i < 4; ++i) {
  7135. code1 = this._lookBits(12);
  7136. if (code1 !== 1) {
  7137. (0, _util.info)("bad rtc code: " + code1);
  7138. }
  7139. this._eatBits(12);
  7140. if (this.encoding > 0) {
  7141. this._lookBits(1);
  7142. this._eatBits(1);
  7143. }
  7144. }
  7145. }
  7146. this.eof = true;
  7147. }
  7148. } else if (this.err && this.eoline) {
  7149. while (true) {
  7150. code1 = this._lookBits(13);
  7151. if (code1 === ccittEOF) {
  7152. this.eof = true;
  7153. return -1;
  7154. }
  7155. if (code1 >> 1 === 1) {
  7156. break;
  7157. }
  7158. this._eatBits(1);
  7159. }
  7160. this._eatBits(12);
  7161. if (this.encoding > 0) {
  7162. this._eatBits(1);
  7163. this.nextLine2D = !(code1 & 1);
  7164. }
  7165. }
  7166. if (codingLine[0] > 0) {
  7167. this.outputBits = codingLine[this.codingPos = 0];
  7168. } else {
  7169. this.outputBits = codingLine[this.codingPos = 1];
  7170. }
  7171. this.row++;
  7172. }
  7173. var c;
  7174. if (this.outputBits >= 8) {
  7175. c = this.codingPos & 1 ? 0 : 0xff;
  7176. this.outputBits -= 8;
  7177. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  7178. this.codingPos++;
  7179. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  7180. }
  7181. } else {
  7182. bits = 8;
  7183. c = 0;
  7184. do {
  7185. if (typeof this.outputBits !== "number") {
  7186. throw new _util.FormatError('Invalid /CCITTFaxDecode data, "outputBits" must be a number.');
  7187. }
  7188. if (this.outputBits > bits) {
  7189. c <<= bits;
  7190. if (!(this.codingPos & 1)) {
  7191. c |= 0xff >> 8 - bits;
  7192. }
  7193. this.outputBits -= bits;
  7194. bits = 0;
  7195. } else {
  7196. c <<= this.outputBits;
  7197. if (!(this.codingPos & 1)) {
  7198. c |= 0xff >> 8 - this.outputBits;
  7199. }
  7200. bits -= this.outputBits;
  7201. this.outputBits = 0;
  7202. if (codingLine[this.codingPos] < columns) {
  7203. this.codingPos++;
  7204. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  7205. } else if (bits > 0) {
  7206. c <<= bits;
  7207. bits = 0;
  7208. }
  7209. }
  7210. } while (bits);
  7211. }
  7212. if (this.black) {
  7213. c ^= 0xff;
  7214. }
  7215. return c;
  7216. }
  7217. }, {
  7218. key: "_addPixels",
  7219. value: function _addPixels(a1, blackPixels) {
  7220. var codingLine = this.codingLine;
  7221. var codingPos = this.codingPos;
  7222. if (a1 > codingLine[codingPos]) {
  7223. if (a1 > this.columns) {
  7224. (0, _util.info)("row is wrong length");
  7225. this.err = true;
  7226. a1 = this.columns;
  7227. }
  7228. if (codingPos & 1 ^ blackPixels) {
  7229. ++codingPos;
  7230. }
  7231. codingLine[codingPos] = a1;
  7232. }
  7233. this.codingPos = codingPos;
  7234. }
  7235. }, {
  7236. key: "_addPixelsNeg",
  7237. value: function _addPixelsNeg(a1, blackPixels) {
  7238. var codingLine = this.codingLine;
  7239. var codingPos = this.codingPos;
  7240. if (a1 > codingLine[codingPos]) {
  7241. if (a1 > this.columns) {
  7242. (0, _util.info)("row is wrong length");
  7243. this.err = true;
  7244. a1 = this.columns;
  7245. }
  7246. if (codingPos & 1 ^ blackPixels) {
  7247. ++codingPos;
  7248. }
  7249. codingLine[codingPos] = a1;
  7250. } else if (a1 < codingLine[codingPos]) {
  7251. if (a1 < 0) {
  7252. (0, _util.info)("invalid code");
  7253. this.err = true;
  7254. a1 = 0;
  7255. }
  7256. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  7257. --codingPos;
  7258. }
  7259. codingLine[codingPos] = a1;
  7260. }
  7261. this.codingPos = codingPos;
  7262. }
  7263. }, {
  7264. key: "_findTableCode",
  7265. value: function _findTableCode(start, end, table, limit) {
  7266. var limitValue = limit || 0;
  7267. for (var i = start; i <= end; ++i) {
  7268. var code = this._lookBits(i);
  7269. if (code === ccittEOF) {
  7270. return [true, 1, false];
  7271. }
  7272. if (i < end) {
  7273. code <<= end - i;
  7274. }
  7275. if (!limitValue || code >= limitValue) {
  7276. var p = table[code - limitValue];
  7277. if (p[0] === i) {
  7278. this._eatBits(i);
  7279. return [true, p[1], true];
  7280. }
  7281. }
  7282. }
  7283. return [false, 0, false];
  7284. }
  7285. }, {
  7286. key: "_getTwoDimCode",
  7287. value: function _getTwoDimCode() {
  7288. var code = 0;
  7289. var p;
  7290. if (this.eoblock) {
  7291. code = this._lookBits(7);
  7292. p = twoDimTable[code];
  7293. if (p && p[0] > 0) {
  7294. this._eatBits(p[0]);
  7295. return p[1];
  7296. }
  7297. } else {
  7298. var result = this._findTableCode(1, 7, twoDimTable);
  7299. if (result[0] && result[2]) {
  7300. return result[1];
  7301. }
  7302. }
  7303. (0, _util.info)("Bad two dim code");
  7304. return ccittEOF;
  7305. }
  7306. }, {
  7307. key: "_getWhiteCode",
  7308. value: function _getWhiteCode() {
  7309. var code = 0;
  7310. var p;
  7311. if (this.eoblock) {
  7312. code = this._lookBits(12);
  7313. if (code === ccittEOF) {
  7314. return 1;
  7315. }
  7316. if (code >> 5 === 0) {
  7317. p = whiteTable1[code];
  7318. } else {
  7319. p = whiteTable2[code >> 3];
  7320. }
  7321. if (p[0] > 0) {
  7322. this._eatBits(p[0]);
  7323. return p[1];
  7324. }
  7325. } else {
  7326. var result = this._findTableCode(1, 9, whiteTable2);
  7327. if (result[0]) {
  7328. return result[1];
  7329. }
  7330. result = this._findTableCode(11, 12, whiteTable1);
  7331. if (result[0]) {
  7332. return result[1];
  7333. }
  7334. }
  7335. (0, _util.info)("bad white code");
  7336. this._eatBits(1);
  7337. return 1;
  7338. }
  7339. }, {
  7340. key: "_getBlackCode",
  7341. value: function _getBlackCode() {
  7342. var code, p;
  7343. if (this.eoblock) {
  7344. code = this._lookBits(13);
  7345. if (code === ccittEOF) {
  7346. return 1;
  7347. }
  7348. if (code >> 7 === 0) {
  7349. p = blackTable1[code];
  7350. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  7351. p = blackTable2[(code >> 1) - 64];
  7352. } else {
  7353. p = blackTable3[code >> 7];
  7354. }
  7355. if (p[0] > 0) {
  7356. this._eatBits(p[0]);
  7357. return p[1];
  7358. }
  7359. } else {
  7360. var result = this._findTableCode(2, 6, blackTable3);
  7361. if (result[0]) {
  7362. return result[1];
  7363. }
  7364. result = this._findTableCode(7, 12, blackTable2, 64);
  7365. if (result[0]) {
  7366. return result[1];
  7367. }
  7368. result = this._findTableCode(10, 13, blackTable1);
  7369. if (result[0]) {
  7370. return result[1];
  7371. }
  7372. }
  7373. (0, _util.info)("bad black code");
  7374. this._eatBits(1);
  7375. return 1;
  7376. }
  7377. }, {
  7378. key: "_lookBits",
  7379. value: function _lookBits(n) {
  7380. var c;
  7381. while (this.inputBits < n) {
  7382. if ((c = this.source.next()) === -1) {
  7383. if (this.inputBits === 0) {
  7384. return ccittEOF;
  7385. }
  7386. return this.inputBuf << n - this.inputBits & 0xffff >> 16 - n;
  7387. }
  7388. this.inputBuf = this.inputBuf << 8 | c;
  7389. this.inputBits += 8;
  7390. }
  7391. return this.inputBuf >> this.inputBits - n & 0xffff >> 16 - n;
  7392. }
  7393. }, {
  7394. key: "_eatBits",
  7395. value: function _eatBits(n) {
  7396. if ((this.inputBits -= n) < 0) {
  7397. this.inputBits = 0;
  7398. }
  7399. }
  7400. }]);
  7401. return CCITTFaxDecoder;
  7402. }();
  7403. exports.CCITTFaxDecoder = CCITTFaxDecoder;
  7404. /***/ }),
  7405. /* 102 */
  7406. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  7407. "use strict";
  7408. Object.defineProperty(exports, "__esModule", ({
  7409. value: true
  7410. }));
  7411. exports.JpegImage = void 0;
  7412. var _util = __w_pdfjs_require__(1);
  7413. var _core_utils = __w_pdfjs_require__(95);
  7414. 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); } }
  7415. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7416. 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); }
  7417. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7418. 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); }
  7419. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7420. 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); }; }
  7421. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  7422. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7423. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  7424. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7425. var JpegError = /*#__PURE__*/function (_BaseException) {
  7426. _inherits(JpegError, _BaseException);
  7427. var _super = _createSuper(JpegError);
  7428. function JpegError(msg) {
  7429. _classCallCheck(this, JpegError);
  7430. return _super.call(this, "JPEG error: ".concat(msg), "JpegError");
  7431. }
  7432. return JpegError;
  7433. }(_util.BaseException);
  7434. var DNLMarkerError = /*#__PURE__*/function (_BaseException2) {
  7435. _inherits(DNLMarkerError, _BaseException2);
  7436. var _super2 = _createSuper(DNLMarkerError);
  7437. function DNLMarkerError(message, scanLines) {
  7438. var _this;
  7439. _classCallCheck(this, DNLMarkerError);
  7440. _this = _super2.call(this, message, "DNLMarkerError");
  7441. _this.scanLines = scanLines;
  7442. return _this;
  7443. }
  7444. return DNLMarkerError;
  7445. }(_util.BaseException);
  7446. var EOIMarkerError = /*#__PURE__*/function (_BaseException3) {
  7447. _inherits(EOIMarkerError, _BaseException3);
  7448. var _super3 = _createSuper(EOIMarkerError);
  7449. function EOIMarkerError(msg) {
  7450. _classCallCheck(this, EOIMarkerError);
  7451. return _super3.call(this, msg, "EOIMarkerError");
  7452. }
  7453. return EOIMarkerError;
  7454. }(_util.BaseException);
  7455. var dctZigZag = new Uint8Array([0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63]);
  7456. var dctCos1 = 4017;
  7457. var dctSin1 = 799;
  7458. var dctCos3 = 3406;
  7459. var dctSin3 = 2276;
  7460. var dctCos6 = 1567;
  7461. var dctSin6 = 3784;
  7462. var dctSqrt2 = 5793;
  7463. var dctSqrt1d2 = 2896;
  7464. function buildHuffmanTable(codeLengths, values) {
  7465. var k = 0,
  7466. i,
  7467. j,
  7468. length = 16;
  7469. while (length > 0 && !codeLengths[length - 1]) {
  7470. length--;
  7471. }
  7472. var code = [{
  7473. children: [],
  7474. index: 0
  7475. }];
  7476. var p = code[0],
  7477. q;
  7478. for (i = 0; i < length; i++) {
  7479. for (j = 0; j < codeLengths[i]; j++) {
  7480. p = code.pop();
  7481. p.children[p.index] = values[k];
  7482. while (p.index > 0) {
  7483. p = code.pop();
  7484. }
  7485. p.index++;
  7486. code.push(p);
  7487. while (code.length <= i) {
  7488. code.push(q = {
  7489. children: [],
  7490. index: 0
  7491. });
  7492. p.children[p.index] = q.children;
  7493. p = q;
  7494. }
  7495. k++;
  7496. }
  7497. if (i + 1 < length) {
  7498. code.push(q = {
  7499. children: [],
  7500. index: 0
  7501. });
  7502. p.children[p.index] = q.children;
  7503. p = q;
  7504. }
  7505. }
  7506. return code[0].children;
  7507. }
  7508. function getBlockBufferOffset(component, row, col) {
  7509. return 64 * ((component.blocksPerLine + 1) * row + col);
  7510. }
  7511. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  7512. var parseDNLMarker = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
  7513. var mcusPerLine = frame.mcusPerLine;
  7514. var progressive = frame.progressive;
  7515. var startOffset = offset;
  7516. var bitsData = 0,
  7517. bitsCount = 0;
  7518. function readBit() {
  7519. if (bitsCount > 0) {
  7520. bitsCount--;
  7521. return bitsData >> bitsCount & 1;
  7522. }
  7523. bitsData = data[offset++];
  7524. if (bitsData === 0xff) {
  7525. var nextByte = data[offset++];
  7526. if (nextByte) {
  7527. if (nextByte === 0xdc && parseDNLMarker) {
  7528. offset += 2;
  7529. var scanLines = (0, _core_utils.readUint16)(data, offset);
  7530. offset += 2;
  7531. if (scanLines > 0 && scanLines !== frame.scanLines) {
  7532. throw new DNLMarkerError("Found DNL marker (0xFFDC) while parsing scan data", scanLines);
  7533. }
  7534. } else if (nextByte === 0xd9) {
  7535. if (parseDNLMarker) {
  7536. var maybeScanLines = blockRow * (frame.precision === 8 ? 8 : 0);
  7537. if (maybeScanLines > 0 && Math.round(frame.scanLines / maybeScanLines) >= 10) {
  7538. throw new DNLMarkerError("Found EOI marker (0xFFD9) while parsing scan data, " + "possibly caused by incorrect `scanLines` parameter", maybeScanLines);
  7539. }
  7540. }
  7541. throw new EOIMarkerError("Found EOI marker (0xFFD9) while parsing scan data");
  7542. }
  7543. throw new JpegError("unexpected marker ".concat((bitsData << 8 | nextByte).toString(16)));
  7544. }
  7545. }
  7546. bitsCount = 7;
  7547. return bitsData >>> 7;
  7548. }
  7549. function decodeHuffman(tree) {
  7550. var node = tree;
  7551. while (true) {
  7552. node = node[readBit()];
  7553. switch (_typeof(node)) {
  7554. case "number":
  7555. return node;
  7556. case "object":
  7557. continue;
  7558. }
  7559. throw new JpegError("invalid huffman sequence");
  7560. }
  7561. }
  7562. function receive(length) {
  7563. var n = 0;
  7564. while (length > 0) {
  7565. n = n << 1 | readBit();
  7566. length--;
  7567. }
  7568. return n;
  7569. }
  7570. function receiveAndExtend(length) {
  7571. if (length === 1) {
  7572. return readBit() === 1 ? 1 : -1;
  7573. }
  7574. var n = receive(length);
  7575. if (n >= 1 << length - 1) {
  7576. return n;
  7577. }
  7578. return n + (-1 << length) + 1;
  7579. }
  7580. function decodeBaseline(component, blockOffset) {
  7581. var t = decodeHuffman(component.huffmanTableDC);
  7582. var diff = t === 0 ? 0 : receiveAndExtend(t);
  7583. component.blockData[blockOffset] = component.pred += diff;
  7584. var k = 1;
  7585. while (k < 64) {
  7586. var rs = decodeHuffman(component.huffmanTableAC);
  7587. var s = rs & 15,
  7588. r = rs >> 4;
  7589. if (s === 0) {
  7590. if (r < 15) {
  7591. break;
  7592. }
  7593. k += 16;
  7594. continue;
  7595. }
  7596. k += r;
  7597. var z = dctZigZag[k];
  7598. component.blockData[blockOffset + z] = receiveAndExtend(s);
  7599. k++;
  7600. }
  7601. }
  7602. function decodeDCFirst(component, blockOffset) {
  7603. var t = decodeHuffman(component.huffmanTableDC);
  7604. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  7605. component.blockData[blockOffset] = component.pred += diff;
  7606. }
  7607. function decodeDCSuccessive(component, blockOffset) {
  7608. component.blockData[blockOffset] |= readBit() << successive;
  7609. }
  7610. var eobrun = 0;
  7611. function decodeACFirst(component, blockOffset) {
  7612. if (eobrun > 0) {
  7613. eobrun--;
  7614. return;
  7615. }
  7616. var k = spectralStart;
  7617. var e = spectralEnd;
  7618. while (k <= e) {
  7619. var rs = decodeHuffman(component.huffmanTableAC);
  7620. var s = rs & 15,
  7621. r = rs >> 4;
  7622. if (s === 0) {
  7623. if (r < 15) {
  7624. eobrun = receive(r) + (1 << r) - 1;
  7625. break;
  7626. }
  7627. k += 16;
  7628. continue;
  7629. }
  7630. k += r;
  7631. var z = dctZigZag[k];
  7632. component.blockData[blockOffset + z] = receiveAndExtend(s) * (1 << successive);
  7633. k++;
  7634. }
  7635. }
  7636. var successiveACState = 0,
  7637. successiveACNextValue;
  7638. function decodeACSuccessive(component, blockOffset) {
  7639. var k = spectralStart;
  7640. var e = spectralEnd;
  7641. var r = 0;
  7642. var s;
  7643. var rs;
  7644. while (k <= e) {
  7645. var offsetZ = blockOffset + dctZigZag[k];
  7646. var sign = component.blockData[offsetZ] < 0 ? -1 : 1;
  7647. switch (successiveACState) {
  7648. case 0:
  7649. rs = decodeHuffman(component.huffmanTableAC);
  7650. s = rs & 15;
  7651. r = rs >> 4;
  7652. if (s === 0) {
  7653. if (r < 15) {
  7654. eobrun = receive(r) + (1 << r);
  7655. successiveACState = 4;
  7656. } else {
  7657. r = 16;
  7658. successiveACState = 1;
  7659. }
  7660. } else {
  7661. if (s !== 1) {
  7662. throw new JpegError("invalid ACn encoding");
  7663. }
  7664. successiveACNextValue = receiveAndExtend(s);
  7665. successiveACState = r ? 2 : 3;
  7666. }
  7667. continue;
  7668. case 1:
  7669. case 2:
  7670. if (component.blockData[offsetZ]) {
  7671. component.blockData[offsetZ] += sign * (readBit() << successive);
  7672. } else {
  7673. r--;
  7674. if (r === 0) {
  7675. successiveACState = successiveACState === 2 ? 3 : 0;
  7676. }
  7677. }
  7678. break;
  7679. case 3:
  7680. if (component.blockData[offsetZ]) {
  7681. component.blockData[offsetZ] += sign * (readBit() << successive);
  7682. } else {
  7683. component.blockData[offsetZ] = successiveACNextValue << successive;
  7684. successiveACState = 0;
  7685. }
  7686. break;
  7687. case 4:
  7688. if (component.blockData[offsetZ]) {
  7689. component.blockData[offsetZ] += sign * (readBit() << successive);
  7690. }
  7691. break;
  7692. }
  7693. k++;
  7694. }
  7695. if (successiveACState === 4) {
  7696. eobrun--;
  7697. if (eobrun === 0) {
  7698. successiveACState = 0;
  7699. }
  7700. }
  7701. }
  7702. var blockRow = 0;
  7703. function decodeMcu(component, decode, mcu, row, col) {
  7704. var mcuRow = mcu / mcusPerLine | 0;
  7705. var mcuCol = mcu % mcusPerLine;
  7706. blockRow = mcuRow * component.v + row;
  7707. var blockCol = mcuCol * component.h + col;
  7708. var blockOffset = getBlockBufferOffset(component, blockRow, blockCol);
  7709. decode(component, blockOffset);
  7710. }
  7711. function decodeBlock(component, decode, mcu) {
  7712. blockRow = mcu / component.blocksPerLine | 0;
  7713. var blockCol = mcu % component.blocksPerLine;
  7714. var blockOffset = getBlockBufferOffset(component, blockRow, blockCol);
  7715. decode(component, blockOffset);
  7716. }
  7717. var componentsLength = components.length;
  7718. var component, i, j, k, n;
  7719. var decodeFn;
  7720. if (progressive) {
  7721. if (spectralStart === 0) {
  7722. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  7723. } else {
  7724. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  7725. }
  7726. } else {
  7727. decodeFn = decodeBaseline;
  7728. }
  7729. var mcu = 0,
  7730. fileMarker;
  7731. var mcuExpected;
  7732. if (componentsLength === 1) {
  7733. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  7734. } else {
  7735. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  7736. }
  7737. var h, v;
  7738. while (mcu <= mcuExpected) {
  7739. var mcuToRead = resetInterval ? Math.min(mcuExpected - mcu, resetInterval) : mcuExpected;
  7740. if (mcuToRead > 0) {
  7741. for (i = 0; i < componentsLength; i++) {
  7742. components[i].pred = 0;
  7743. }
  7744. eobrun = 0;
  7745. if (componentsLength === 1) {
  7746. component = components[0];
  7747. for (n = 0; n < mcuToRead; n++) {
  7748. decodeBlock(component, decodeFn, mcu);
  7749. mcu++;
  7750. }
  7751. } else {
  7752. for (n = 0; n < mcuToRead; n++) {
  7753. for (i = 0; i < componentsLength; i++) {
  7754. component = components[i];
  7755. h = component.h;
  7756. v = component.v;
  7757. for (j = 0; j < v; j++) {
  7758. for (k = 0; k < h; k++) {
  7759. decodeMcu(component, decodeFn, mcu, j, k);
  7760. }
  7761. }
  7762. }
  7763. mcu++;
  7764. }
  7765. }
  7766. }
  7767. bitsCount = 0;
  7768. fileMarker = findNextFileMarker(data, offset);
  7769. if (!fileMarker) {
  7770. break;
  7771. }
  7772. if (fileMarker.invalid) {
  7773. var partialMsg = mcuToRead > 0 ? "unexpected" : "excessive";
  7774. (0, _util.warn)("decodeScan - ".concat(partialMsg, " MCU data, current marker is: ").concat(fileMarker.invalid));
  7775. offset = fileMarker.offset;
  7776. }
  7777. if (fileMarker.marker >= 0xffd0 && fileMarker.marker <= 0xffd7) {
  7778. offset += 2;
  7779. } else {
  7780. break;
  7781. }
  7782. }
  7783. return offset - startOffset;
  7784. }
  7785. function quantizeAndInverse(component, blockBufferOffset, p) {
  7786. var qt = component.quantizationTable,
  7787. blockData = component.blockData;
  7788. var v0, v1, v2, v3, v4, v5, v6, v7;
  7789. var p0, p1, p2, p3, p4, p5, p6, p7;
  7790. var t;
  7791. if (!qt) {
  7792. throw new JpegError("missing required Quantization Table.");
  7793. }
  7794. for (var row = 0; row < 64; row += 8) {
  7795. p0 = blockData[blockBufferOffset + row];
  7796. p1 = blockData[blockBufferOffset + row + 1];
  7797. p2 = blockData[blockBufferOffset + row + 2];
  7798. p3 = blockData[blockBufferOffset + row + 3];
  7799. p4 = blockData[blockBufferOffset + row + 4];
  7800. p5 = blockData[blockBufferOffset + row + 5];
  7801. p6 = blockData[blockBufferOffset + row + 6];
  7802. p7 = blockData[blockBufferOffset + row + 7];
  7803. p0 *= qt[row];
  7804. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  7805. t = dctSqrt2 * p0 + 512 >> 10;
  7806. p[row] = t;
  7807. p[row + 1] = t;
  7808. p[row + 2] = t;
  7809. p[row + 3] = t;
  7810. p[row + 4] = t;
  7811. p[row + 5] = t;
  7812. p[row + 6] = t;
  7813. p[row + 7] = t;
  7814. continue;
  7815. }
  7816. p1 *= qt[row + 1];
  7817. p2 *= qt[row + 2];
  7818. p3 *= qt[row + 3];
  7819. p4 *= qt[row + 4];
  7820. p5 *= qt[row + 5];
  7821. p6 *= qt[row + 6];
  7822. p7 *= qt[row + 7];
  7823. v0 = dctSqrt2 * p0 + 128 >> 8;
  7824. v1 = dctSqrt2 * p4 + 128 >> 8;
  7825. v2 = p2;
  7826. v3 = p6;
  7827. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  7828. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  7829. v5 = p3 << 4;
  7830. v6 = p5 << 4;
  7831. v0 = v0 + v1 + 1 >> 1;
  7832. v1 = v0 - v1;
  7833. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  7834. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  7835. v3 = t;
  7836. v4 = v4 + v6 + 1 >> 1;
  7837. v6 = v4 - v6;
  7838. v7 = v7 + v5 + 1 >> 1;
  7839. v5 = v7 - v5;
  7840. v0 = v0 + v3 + 1 >> 1;
  7841. v3 = v0 - v3;
  7842. v1 = v1 + v2 + 1 >> 1;
  7843. v2 = v1 - v2;
  7844. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  7845. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  7846. v7 = t;
  7847. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  7848. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  7849. v6 = t;
  7850. p[row] = v0 + v7;
  7851. p[row + 7] = v0 - v7;
  7852. p[row + 1] = v1 + v6;
  7853. p[row + 6] = v1 - v6;
  7854. p[row + 2] = v2 + v5;
  7855. p[row + 5] = v2 - v5;
  7856. p[row + 3] = v3 + v4;
  7857. p[row + 4] = v3 - v4;
  7858. }
  7859. for (var col = 0; col < 8; ++col) {
  7860. p0 = p[col];
  7861. p1 = p[col + 8];
  7862. p2 = p[col + 16];
  7863. p3 = p[col + 24];
  7864. p4 = p[col + 32];
  7865. p5 = p[col + 40];
  7866. p6 = p[col + 48];
  7867. p7 = p[col + 56];
  7868. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  7869. t = dctSqrt2 * p0 + 8192 >> 14;
  7870. if (t < -2040) {
  7871. t = 0;
  7872. } else if (t >= 2024) {
  7873. t = 255;
  7874. } else {
  7875. t = t + 2056 >> 4;
  7876. }
  7877. blockData[blockBufferOffset + col] = t;
  7878. blockData[blockBufferOffset + col + 8] = t;
  7879. blockData[blockBufferOffset + col + 16] = t;
  7880. blockData[blockBufferOffset + col + 24] = t;
  7881. blockData[blockBufferOffset + col + 32] = t;
  7882. blockData[blockBufferOffset + col + 40] = t;
  7883. blockData[blockBufferOffset + col + 48] = t;
  7884. blockData[blockBufferOffset + col + 56] = t;
  7885. continue;
  7886. }
  7887. v0 = dctSqrt2 * p0 + 2048 >> 12;
  7888. v1 = dctSqrt2 * p4 + 2048 >> 12;
  7889. v2 = p2;
  7890. v3 = p6;
  7891. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  7892. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  7893. v5 = p3;
  7894. v6 = p5;
  7895. v0 = (v0 + v1 + 1 >> 1) + 4112;
  7896. v1 = v0 - v1;
  7897. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  7898. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  7899. v3 = t;
  7900. v4 = v4 + v6 + 1 >> 1;
  7901. v6 = v4 - v6;
  7902. v7 = v7 + v5 + 1 >> 1;
  7903. v5 = v7 - v5;
  7904. v0 = v0 + v3 + 1 >> 1;
  7905. v3 = v0 - v3;
  7906. v1 = v1 + v2 + 1 >> 1;
  7907. v2 = v1 - v2;
  7908. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  7909. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  7910. v7 = t;
  7911. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  7912. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  7913. v6 = t;
  7914. p0 = v0 + v7;
  7915. p7 = v0 - v7;
  7916. p1 = v1 + v6;
  7917. p6 = v1 - v6;
  7918. p2 = v2 + v5;
  7919. p5 = v2 - v5;
  7920. p3 = v3 + v4;
  7921. p4 = v3 - v4;
  7922. if (p0 < 16) {
  7923. p0 = 0;
  7924. } else if (p0 >= 4080) {
  7925. p0 = 255;
  7926. } else {
  7927. p0 >>= 4;
  7928. }
  7929. if (p1 < 16) {
  7930. p1 = 0;
  7931. } else if (p1 >= 4080) {
  7932. p1 = 255;
  7933. } else {
  7934. p1 >>= 4;
  7935. }
  7936. if (p2 < 16) {
  7937. p2 = 0;
  7938. } else if (p2 >= 4080) {
  7939. p2 = 255;
  7940. } else {
  7941. p2 >>= 4;
  7942. }
  7943. if (p3 < 16) {
  7944. p3 = 0;
  7945. } else if (p3 >= 4080) {
  7946. p3 = 255;
  7947. } else {
  7948. p3 >>= 4;
  7949. }
  7950. if (p4 < 16) {
  7951. p4 = 0;
  7952. } else if (p4 >= 4080) {
  7953. p4 = 255;
  7954. } else {
  7955. p4 >>= 4;
  7956. }
  7957. if (p5 < 16) {
  7958. p5 = 0;
  7959. } else if (p5 >= 4080) {
  7960. p5 = 255;
  7961. } else {
  7962. p5 >>= 4;
  7963. }
  7964. if (p6 < 16) {
  7965. p6 = 0;
  7966. } else if (p6 >= 4080) {
  7967. p6 = 255;
  7968. } else {
  7969. p6 >>= 4;
  7970. }
  7971. if (p7 < 16) {
  7972. p7 = 0;
  7973. } else if (p7 >= 4080) {
  7974. p7 = 255;
  7975. } else {
  7976. p7 >>= 4;
  7977. }
  7978. blockData[blockBufferOffset + col] = p0;
  7979. blockData[blockBufferOffset + col + 8] = p1;
  7980. blockData[blockBufferOffset + col + 16] = p2;
  7981. blockData[blockBufferOffset + col + 24] = p3;
  7982. blockData[blockBufferOffset + col + 32] = p4;
  7983. blockData[blockBufferOffset + col + 40] = p5;
  7984. blockData[blockBufferOffset + col + 48] = p6;
  7985. blockData[blockBufferOffset + col + 56] = p7;
  7986. }
  7987. }
  7988. function buildComponentData(frame, component) {
  7989. var blocksPerLine = component.blocksPerLine;
  7990. var blocksPerColumn = component.blocksPerColumn;
  7991. var computationBuffer = new Int16Array(64);
  7992. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  7993. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  7994. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  7995. quantizeAndInverse(component, offset, computationBuffer);
  7996. }
  7997. }
  7998. return component.blockData;
  7999. }
  8000. function findNextFileMarker(data, currentPos) {
  8001. var startPos = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : currentPos;
  8002. var maxPos = data.length - 1;
  8003. var newPos = startPos < currentPos ? startPos : currentPos;
  8004. if (currentPos >= maxPos) {
  8005. return null;
  8006. }
  8007. var currentMarker = (0, _core_utils.readUint16)(data, currentPos);
  8008. if (currentMarker >= 0xffc0 && currentMarker <= 0xfffe) {
  8009. return {
  8010. invalid: null,
  8011. marker: currentMarker,
  8012. offset: currentPos
  8013. };
  8014. }
  8015. var newMarker = (0, _core_utils.readUint16)(data, newPos);
  8016. while (!(newMarker >= 0xffc0 && newMarker <= 0xfffe)) {
  8017. if (++newPos >= maxPos) {
  8018. return null;
  8019. }
  8020. newMarker = (0, _core_utils.readUint16)(data, newPos);
  8021. }
  8022. return {
  8023. invalid: currentMarker.toString(16),
  8024. marker: newMarker,
  8025. offset: newPos
  8026. };
  8027. }
  8028. var JpegImage = /*#__PURE__*/function () {
  8029. function JpegImage() {
  8030. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  8031. _ref$decodeTransform = _ref.decodeTransform,
  8032. decodeTransform = _ref$decodeTransform === void 0 ? null : _ref$decodeTransform,
  8033. _ref$colorTransform = _ref.colorTransform,
  8034. colorTransform = _ref$colorTransform === void 0 ? -1 : _ref$colorTransform;
  8035. _classCallCheck(this, JpegImage);
  8036. this._decodeTransform = decodeTransform;
  8037. this._colorTransform = colorTransform;
  8038. }
  8039. _createClass(JpegImage, [{
  8040. key: "parse",
  8041. value: function parse(data) {
  8042. var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  8043. _ref2$dnlScanLines = _ref2.dnlScanLines,
  8044. dnlScanLines = _ref2$dnlScanLines === void 0 ? null : _ref2$dnlScanLines;
  8045. function readDataBlock() {
  8046. var length = (0, _core_utils.readUint16)(data, offset);
  8047. offset += 2;
  8048. var endOffset = offset + length - 2;
  8049. var fileMarker = findNextFileMarker(data, endOffset, offset);
  8050. if (fileMarker && fileMarker.invalid) {
  8051. (0, _util.warn)("readDataBlock - incorrect length, current marker is: " + fileMarker.invalid);
  8052. endOffset = fileMarker.offset;
  8053. }
  8054. var array = data.subarray(offset, endOffset);
  8055. offset += array.length;
  8056. return array;
  8057. }
  8058. function prepareComponents(frame) {
  8059. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  8060. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  8061. for (var i = 0, ii = frame.components.length; i < ii; i++) {
  8062. var component = frame.components[i];
  8063. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  8064. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  8065. var blocksPerLineForMcu = mcusPerLine * component.h;
  8066. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  8067. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  8068. component.blockData = new Int16Array(blocksBufferSize);
  8069. component.blocksPerLine = blocksPerLine;
  8070. component.blocksPerColumn = blocksPerColumn;
  8071. }
  8072. frame.mcusPerLine = mcusPerLine;
  8073. frame.mcusPerColumn = mcusPerColumn;
  8074. }
  8075. var offset = 0;
  8076. var jfif = null;
  8077. var adobe = null;
  8078. var frame, resetInterval;
  8079. var numSOSMarkers = 0;
  8080. var quantizationTables = [];
  8081. var huffmanTablesAC = [],
  8082. huffmanTablesDC = [];
  8083. var fileMarker = (0, _core_utils.readUint16)(data, offset);
  8084. offset += 2;
  8085. if (fileMarker !== 0xffd8) {
  8086. throw new JpegError("SOI not found");
  8087. }
  8088. fileMarker = (0, _core_utils.readUint16)(data, offset);
  8089. offset += 2;
  8090. markerLoop: while (fileMarker !== 0xffd9) {
  8091. var i = void 0,
  8092. j = void 0,
  8093. l = void 0;
  8094. switch (fileMarker) {
  8095. case 0xffe0:
  8096. case 0xffe1:
  8097. case 0xffe2:
  8098. case 0xffe3:
  8099. case 0xffe4:
  8100. case 0xffe5:
  8101. case 0xffe6:
  8102. case 0xffe7:
  8103. case 0xffe8:
  8104. case 0xffe9:
  8105. case 0xffea:
  8106. case 0xffeb:
  8107. case 0xffec:
  8108. case 0xffed:
  8109. case 0xffee:
  8110. case 0xffef:
  8111. case 0xfffe:
  8112. var appData = readDataBlock();
  8113. if (fileMarker === 0xffe0) {
  8114. if (appData[0] === 0x4a && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  8115. jfif = {
  8116. version: {
  8117. major: appData[5],
  8118. minor: appData[6]
  8119. },
  8120. densityUnits: appData[7],
  8121. xDensity: appData[8] << 8 | appData[9],
  8122. yDensity: appData[10] << 8 | appData[11],
  8123. thumbWidth: appData[12],
  8124. thumbHeight: appData[13],
  8125. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  8126. };
  8127. }
  8128. }
  8129. if (fileMarker === 0xffee) {
  8130. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6f && appData[3] === 0x62 && appData[4] === 0x65) {
  8131. adobe = {
  8132. version: appData[5] << 8 | appData[6],
  8133. flags0: appData[7] << 8 | appData[8],
  8134. flags1: appData[9] << 8 | appData[10],
  8135. transformCode: appData[11]
  8136. };
  8137. }
  8138. }
  8139. break;
  8140. case 0xffdb:
  8141. var quantizationTablesLength = (0, _core_utils.readUint16)(data, offset);
  8142. offset += 2;
  8143. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  8144. var z = void 0;
  8145. while (offset < quantizationTablesEnd) {
  8146. var quantizationTableSpec = data[offset++];
  8147. var tableData = new Uint16Array(64);
  8148. if (quantizationTableSpec >> 4 === 0) {
  8149. for (j = 0; j < 64; j++) {
  8150. z = dctZigZag[j];
  8151. tableData[z] = data[offset++];
  8152. }
  8153. } else if (quantizationTableSpec >> 4 === 1) {
  8154. for (j = 0; j < 64; j++) {
  8155. z = dctZigZag[j];
  8156. tableData[z] = (0, _core_utils.readUint16)(data, offset);
  8157. offset += 2;
  8158. }
  8159. } else {
  8160. throw new JpegError("DQT - invalid table spec");
  8161. }
  8162. quantizationTables[quantizationTableSpec & 15] = tableData;
  8163. }
  8164. break;
  8165. case 0xffc0:
  8166. case 0xffc1:
  8167. case 0xffc2:
  8168. if (frame) {
  8169. throw new JpegError("Only single frame JPEGs supported");
  8170. }
  8171. offset += 2;
  8172. frame = {};
  8173. frame.extended = fileMarker === 0xffc1;
  8174. frame.progressive = fileMarker === 0xffc2;
  8175. frame.precision = data[offset++];
  8176. var sofScanLines = (0, _core_utils.readUint16)(data, offset);
  8177. offset += 2;
  8178. frame.scanLines = dnlScanLines || sofScanLines;
  8179. frame.samplesPerLine = (0, _core_utils.readUint16)(data, offset);
  8180. offset += 2;
  8181. frame.components = [];
  8182. frame.componentIds = {};
  8183. var componentsCount = data[offset++];
  8184. var maxH = 0,
  8185. maxV = 0;
  8186. for (i = 0; i < componentsCount; i++) {
  8187. var componentId = data[offset];
  8188. var h = data[offset + 1] >> 4;
  8189. var v = data[offset + 1] & 15;
  8190. if (maxH < h) {
  8191. maxH = h;
  8192. }
  8193. if (maxV < v) {
  8194. maxV = v;
  8195. }
  8196. var qId = data[offset + 2];
  8197. l = frame.components.push({
  8198. h: h,
  8199. v: v,
  8200. quantizationId: qId,
  8201. quantizationTable: null
  8202. });
  8203. frame.componentIds[componentId] = l - 1;
  8204. offset += 3;
  8205. }
  8206. frame.maxH = maxH;
  8207. frame.maxV = maxV;
  8208. prepareComponents(frame);
  8209. break;
  8210. case 0xffc4:
  8211. var huffmanLength = (0, _core_utils.readUint16)(data, offset);
  8212. offset += 2;
  8213. for (i = 2; i < huffmanLength;) {
  8214. var huffmanTableSpec = data[offset++];
  8215. var codeLengths = new Uint8Array(16);
  8216. var codeLengthSum = 0;
  8217. for (j = 0; j < 16; j++, offset++) {
  8218. codeLengthSum += codeLengths[j] = data[offset];
  8219. }
  8220. var huffmanValues = new Uint8Array(codeLengthSum);
  8221. for (j = 0; j < codeLengthSum; j++, offset++) {
  8222. huffmanValues[j] = data[offset];
  8223. }
  8224. i += 17 + codeLengthSum;
  8225. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  8226. }
  8227. break;
  8228. case 0xffdd:
  8229. offset += 2;
  8230. resetInterval = (0, _core_utils.readUint16)(data, offset);
  8231. offset += 2;
  8232. break;
  8233. case 0xffda:
  8234. var parseDNLMarker = ++numSOSMarkers === 1 && !dnlScanLines;
  8235. offset += 2;
  8236. var selectorsCount = data[offset++],
  8237. components = [];
  8238. for (i = 0; i < selectorsCount; i++) {
  8239. var index = data[offset++];
  8240. var componentIndex = frame.componentIds[index];
  8241. var component = frame.components[componentIndex];
  8242. component.index = index;
  8243. var tableSpec = data[offset++];
  8244. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  8245. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  8246. components.push(component);
  8247. }
  8248. var spectralStart = data[offset++],
  8249. spectralEnd = data[offset++],
  8250. successiveApproximation = data[offset++];
  8251. try {
  8252. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15, parseDNLMarker);
  8253. offset += processed;
  8254. } catch (ex) {
  8255. if (ex instanceof DNLMarkerError) {
  8256. (0, _util.warn)("".concat(ex.message, " -- attempting to re-parse the JPEG image."));
  8257. return this.parse(data, {
  8258. dnlScanLines: ex.scanLines
  8259. });
  8260. } else if (ex instanceof EOIMarkerError) {
  8261. (0, _util.warn)("".concat(ex.message, " -- ignoring the rest of the image data."));
  8262. break markerLoop;
  8263. }
  8264. throw ex;
  8265. }
  8266. break;
  8267. case 0xffdc:
  8268. offset += 4;
  8269. break;
  8270. case 0xffff:
  8271. if (data[offset] !== 0xff) {
  8272. offset--;
  8273. }
  8274. break;
  8275. default:
  8276. var nextFileMarker = findNextFileMarker(data, offset - 2, offset - 3);
  8277. if (nextFileMarker && nextFileMarker.invalid) {
  8278. (0, _util.warn)("JpegImage.parse - unexpected data, current marker is: " + nextFileMarker.invalid);
  8279. offset = nextFileMarker.offset;
  8280. break;
  8281. }
  8282. if (!nextFileMarker || offset >= data.length - 1) {
  8283. (0, _util.warn)("JpegImage.parse - reached the end of the image data " + "without finding an EOI marker (0xFFD9).");
  8284. break markerLoop;
  8285. }
  8286. throw new JpegError("JpegImage.parse - unknown marker: " + fileMarker.toString(16));
  8287. }
  8288. fileMarker = (0, _core_utils.readUint16)(data, offset);
  8289. offset += 2;
  8290. }
  8291. this.width = frame.samplesPerLine;
  8292. this.height = frame.scanLines;
  8293. this.jfif = jfif;
  8294. this.adobe = adobe;
  8295. this.components = [];
  8296. for (var _i = 0, ii = frame.components.length; _i < ii; _i++) {
  8297. var _component = frame.components[_i];
  8298. var quantizationTable = quantizationTables[_component.quantizationId];
  8299. if (quantizationTable) {
  8300. _component.quantizationTable = quantizationTable;
  8301. }
  8302. this.components.push({
  8303. index: _component.index,
  8304. output: buildComponentData(frame, _component),
  8305. scaleX: _component.h / frame.maxH,
  8306. scaleY: _component.v / frame.maxV,
  8307. blocksPerLine: _component.blocksPerLine,
  8308. blocksPerColumn: _component.blocksPerColumn
  8309. });
  8310. }
  8311. this.numComponents = this.components.length;
  8312. return undefined;
  8313. }
  8314. }, {
  8315. key: "_getLinearizedBlockData",
  8316. value: function _getLinearizedBlockData(width, height) {
  8317. var isSourcePDF = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8318. var scaleX = this.width / width,
  8319. scaleY = this.height / height;
  8320. var component, componentScaleX, componentScaleY, blocksPerScanline;
  8321. var x, y, i, j, k;
  8322. var index;
  8323. var offset = 0;
  8324. var output;
  8325. var numComponents = this.components.length;
  8326. var dataLength = width * height * numComponents;
  8327. var data = new Uint8ClampedArray(dataLength);
  8328. var xScaleBlockOffset = new Uint32Array(width);
  8329. var mask3LSB = 0xfffffff8;
  8330. var lastComponentScaleX;
  8331. for (i = 0; i < numComponents; i++) {
  8332. component = this.components[i];
  8333. componentScaleX = component.scaleX * scaleX;
  8334. componentScaleY = component.scaleY * scaleY;
  8335. offset = i;
  8336. output = component.output;
  8337. blocksPerScanline = component.blocksPerLine + 1 << 3;
  8338. if (componentScaleX !== lastComponentScaleX) {
  8339. for (x = 0; x < width; x++) {
  8340. j = 0 | x * componentScaleX;
  8341. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  8342. }
  8343. lastComponentScaleX = componentScaleX;
  8344. }
  8345. for (y = 0; y < height; y++) {
  8346. j = 0 | y * componentScaleY;
  8347. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  8348. for (x = 0; x < width; x++) {
  8349. data[offset] = output[index + xScaleBlockOffset[x]];
  8350. offset += numComponents;
  8351. }
  8352. }
  8353. }
  8354. var transform = this._decodeTransform;
  8355. if (!isSourcePDF && numComponents === 4 && !transform) {
  8356. transform = new Int32Array([-256, 255, -256, 255, -256, 255, -256, 255]);
  8357. }
  8358. if (transform) {
  8359. for (i = 0; i < dataLength;) {
  8360. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  8361. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  8362. }
  8363. }
  8364. }
  8365. return data;
  8366. }
  8367. }, {
  8368. key: "_isColorConversionNeeded",
  8369. get: function get() {
  8370. if (this.adobe) {
  8371. return !!this.adobe.transformCode;
  8372. }
  8373. if (this.numComponents === 3) {
  8374. if (this._colorTransform === 0) {
  8375. return false;
  8376. } else if (this.components[0].index === 0x52 && this.components[1].index === 0x47 && this.components[2].index === 0x42) {
  8377. return false;
  8378. }
  8379. return true;
  8380. }
  8381. if (this._colorTransform === 1) {
  8382. return true;
  8383. }
  8384. return false;
  8385. }
  8386. }, {
  8387. key: "_convertYccToRgb",
  8388. value: function _convertYccToRgb(data) {
  8389. var Y, Cb, Cr;
  8390. for (var i = 0, length = data.length; i < length; i += 3) {
  8391. Y = data[i];
  8392. Cb = data[i + 1];
  8393. Cr = data[i + 2];
  8394. data[i] = Y - 179.456 + 1.402 * Cr;
  8395. data[i + 1] = Y + 135.459 - 0.344 * Cb - 0.714 * Cr;
  8396. data[i + 2] = Y - 226.816 + 1.772 * Cb;
  8397. }
  8398. return data;
  8399. }
  8400. }, {
  8401. key: "_convertYcckToRgb",
  8402. value: function _convertYcckToRgb(data) {
  8403. var Y, Cb, Cr, k;
  8404. var offset = 0;
  8405. for (var i = 0, length = data.length; i < length; i += 4) {
  8406. Y = data[i];
  8407. Cb = data[i + 1];
  8408. Cr = data[i + 2];
  8409. k = data[i + 3];
  8410. data[offset++] = -122.67195406894 + Cb * (-6.60635669420364e-5 * Cb + 0.000437130475926232 * Cr - 5.4080610064599e-5 * Y + 0.00048449797120281 * k - 0.154362151871126) + Cr * (-0.000957964378445773 * Cr + 0.000817076911346625 * Y - 0.00477271405408747 * k + 1.53380253221734) + Y * (0.000961250184130688 * Y - 0.00266257332283933 * k + 0.48357088451265) + k * (-0.000336197177618394 * k + 0.484791561490776);
  8411. data[offset++] = 107.268039397724 + Cb * (2.19927104525741e-5 * Cb - 0.000640992018297945 * Cr + 0.000659397001245577 * Y + 0.000426105652938837 * k - 0.176491792462875) + Cr * (-0.000778269941513683 * Cr + 0.00130872261408275 * Y + 0.000770482631801132 * k - 0.151051492775562) + Y * (0.00126935368114843 * Y - 0.00265090189010898 * k + 0.25802910206845) + k * (-0.000318913117588328 * k - 0.213742400323665);
  8412. data[offset++] = -20.810012546947 + Cb * (-0.000570115196973677 * Cb - 2.63409051004589e-5 * Cr + 0.0020741088115012 * Y - 0.00288260236853442 * k + 0.814272968359295) + Cr * (-1.53496057440975e-5 * Cr - 0.000132689043961446 * Y + 0.000560833691242812 * k - 0.195152027534049) + Y * (0.00174418132927582 * Y - 0.00255243321439347 * k + 0.116935020465145) + k * (-0.000343531996510555 * k + 0.24165260232407);
  8413. }
  8414. return data.subarray(0, offset);
  8415. }
  8416. }, {
  8417. key: "_convertYcckToCmyk",
  8418. value: function _convertYcckToCmyk(data) {
  8419. var Y, Cb, Cr;
  8420. for (var i = 0, length = data.length; i < length; i += 4) {
  8421. Y = data[i];
  8422. Cb = data[i + 1];
  8423. Cr = data[i + 2];
  8424. data[i] = 434.456 - Y - 1.402 * Cr;
  8425. data[i + 1] = 119.541 - Y + 0.344 * Cb + 0.714 * Cr;
  8426. data[i + 2] = 481.816 - Y - 1.772 * Cb;
  8427. }
  8428. return data;
  8429. }
  8430. }, {
  8431. key: "_convertCmykToRgb",
  8432. value: function _convertCmykToRgb(data) {
  8433. var c, m, y, k;
  8434. var offset = 0;
  8435. for (var i = 0, length = data.length; i < length; i += 4) {
  8436. c = data[i];
  8437. m = data[i + 1];
  8438. y = data[i + 2];
  8439. k = data[i + 3];
  8440. data[offset++] = 255 + c * (-0.00006747147073602441 * c + 0.0008379262121013727 * m + 0.0002894718188643294 * y + 0.003264231057537806 * k - 1.1185611867203937) + m * (0.000026374107616089405 * m - 0.00008626949158638572 * y - 0.0002748769067499491 * k - 0.02155688794978967) + y * (-0.00003878099212869363 * y - 0.0003267808279485286 * k + 0.0686742238595345) - k * (0.0003361971776183937 * k + 0.7430659151342254);
  8441. data[offset++] = 255 + c * (0.00013596372813588848 * c + 0.000924537132573585 * m + 0.00010567359618683593 * y + 0.0004791864687436512 * k - 0.3109689587515875) + m * (-0.00023545346108370344 * m + 0.0002702845253534714 * y + 0.0020200308977307156 * k - 0.7488052167015494) + y * (0.00006834815998235662 * y + 0.00015168452363460973 * k - 0.09751927774728933) - k * (0.0003189131175883281 * k + 0.7364883807733168);
  8442. data[offset++] = 255 + c * (0.000013598650411385307 * c + 0.00012423956175490851 * m + 0.0004751985097583589 * y - 0.0000036729317476630422 * k - 0.05562186980264034) + m * (0.00016141380598724676 * m + 0.0009692239130725186 * y + 0.0007782692450036253 * k - 0.44015232367526463) + y * (5.068882914068769e-7 * y + 0.0017778369011375071 * k - 0.7591454649749609) - k * (0.0003435319965105553 * k + 0.7063770186160144);
  8443. }
  8444. return data.subarray(0, offset);
  8445. }
  8446. }, {
  8447. key: "getData",
  8448. value: function getData(_ref3) {
  8449. var width = _ref3.width,
  8450. height = _ref3.height,
  8451. _ref3$forceRGB = _ref3.forceRGB,
  8452. forceRGB = _ref3$forceRGB === void 0 ? false : _ref3$forceRGB,
  8453. _ref3$isSourcePDF = _ref3.isSourcePDF,
  8454. isSourcePDF = _ref3$isSourcePDF === void 0 ? false : _ref3$isSourcePDF;
  8455. if (this.numComponents > 4) {
  8456. throw new JpegError("Unsupported color mode");
  8457. }
  8458. var data = this._getLinearizedBlockData(width, height, isSourcePDF);
  8459. if (this.numComponents === 1 && forceRGB) {
  8460. var dataLength = data.length;
  8461. var rgbData = new Uint8ClampedArray(dataLength * 3);
  8462. var offset = 0;
  8463. for (var i = 0; i < dataLength; i++) {
  8464. var grayColor = data[i];
  8465. rgbData[offset++] = grayColor;
  8466. rgbData[offset++] = grayColor;
  8467. rgbData[offset++] = grayColor;
  8468. }
  8469. return rgbData;
  8470. } else if (this.numComponents === 3 && this._isColorConversionNeeded) {
  8471. return this._convertYccToRgb(data);
  8472. } else if (this.numComponents === 4) {
  8473. if (this._isColorConversionNeeded) {
  8474. if (forceRGB) {
  8475. return this._convertYcckToRgb(data);
  8476. }
  8477. return this._convertYcckToCmyk(data);
  8478. } else if (forceRGB) {
  8479. return this._convertCmykToRgb(data);
  8480. }
  8481. }
  8482. return data;
  8483. }
  8484. }]);
  8485. return JpegImage;
  8486. }();
  8487. exports.JpegImage = JpegImage;
  8488. /***/ }),
  8489. /* 103 */
  8490. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  8491. "use strict";
  8492. 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); }
  8493. Object.defineProperty(exports, "__esModule", ({
  8494. value: true
  8495. }));
  8496. exports.JpxImage = void 0;
  8497. var _util = __w_pdfjs_require__(1);
  8498. var _core_utils = __w_pdfjs_require__(95);
  8499. var _arithmetic_decoder = __w_pdfjs_require__(100);
  8500. 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); } }
  8501. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8502. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8503. 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); }
  8504. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8505. 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); }; }
  8506. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  8507. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8508. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  8509. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8510. var JpxError = /*#__PURE__*/function (_BaseException) {
  8511. _inherits(JpxError, _BaseException);
  8512. var _super = _createSuper(JpxError);
  8513. function JpxError(msg) {
  8514. _classCallCheck(this, JpxError);
  8515. return _super.call(this, "JPX error: ".concat(msg), "JpxError");
  8516. }
  8517. return JpxError;
  8518. }(_util.BaseException);
  8519. var SubbandsGainLog2 = {
  8520. LL: 0,
  8521. LH: 1,
  8522. HL: 1,
  8523. HH: 2
  8524. };
  8525. var JpxImage = /*#__PURE__*/function () {
  8526. function JpxImage() {
  8527. _classCallCheck(this, JpxImage);
  8528. this.failOnCorruptedImage = false;
  8529. }
  8530. _createClass(JpxImage, [{
  8531. key: "parse",
  8532. value: function parse(data) {
  8533. var head = (0, _core_utils.readUint16)(data, 0);
  8534. if (head === 0xff4f) {
  8535. this.parseCodestream(data, 0, data.length);
  8536. return;
  8537. }
  8538. var length = data.length;
  8539. var position = 0;
  8540. while (position < length) {
  8541. var headerSize = 8;
  8542. var lbox = (0, _core_utils.readUint32)(data, position);
  8543. var tbox = (0, _core_utils.readUint32)(data, position + 4);
  8544. position += headerSize;
  8545. if (lbox === 1) {
  8546. lbox = (0, _core_utils.readUint32)(data, position) * 4294967296 + (0, _core_utils.readUint32)(data, position + 4);
  8547. position += 8;
  8548. headerSize += 8;
  8549. }
  8550. if (lbox === 0) {
  8551. lbox = length - position + headerSize;
  8552. }
  8553. if (lbox < headerSize) {
  8554. throw new JpxError("Invalid box field size");
  8555. }
  8556. var dataLength = lbox - headerSize;
  8557. var jumpDataLength = true;
  8558. switch (tbox) {
  8559. case 0x6a703268:
  8560. jumpDataLength = false;
  8561. break;
  8562. case 0x636f6c72:
  8563. var method = data[position];
  8564. if (method === 1) {
  8565. var colorspace = (0, _core_utils.readUint32)(data, position + 3);
  8566. switch (colorspace) {
  8567. case 16:
  8568. case 17:
  8569. case 18:
  8570. break;
  8571. default:
  8572. (0, _util.warn)("Unknown colorspace " + colorspace);
  8573. break;
  8574. }
  8575. } else if (method === 2) {
  8576. (0, _util.info)("ICC profile not supported");
  8577. }
  8578. break;
  8579. case 0x6a703263:
  8580. this.parseCodestream(data, position, position + dataLength);
  8581. break;
  8582. case 0x6a502020:
  8583. if ((0, _core_utils.readUint32)(data, position) !== 0x0d0a870a) {
  8584. (0, _util.warn)("Invalid JP2 signature");
  8585. }
  8586. break;
  8587. case 0x6a501a1a:
  8588. case 0x66747970:
  8589. case 0x72726571:
  8590. case 0x72657320:
  8591. case 0x69686472:
  8592. break;
  8593. default:
  8594. var headerType = String.fromCharCode(tbox >> 24 & 0xff, tbox >> 16 & 0xff, tbox >> 8 & 0xff, tbox & 0xff);
  8595. (0, _util.warn)("Unsupported header type ".concat(tbox, " (").concat(headerType, ")."));
  8596. break;
  8597. }
  8598. if (jumpDataLength) {
  8599. position += dataLength;
  8600. }
  8601. }
  8602. }
  8603. }, {
  8604. key: "parseImageProperties",
  8605. value: function parseImageProperties(stream) {
  8606. var newByte = stream.getByte();
  8607. while (newByte >= 0) {
  8608. var oldByte = newByte;
  8609. newByte = stream.getByte();
  8610. var code = oldByte << 8 | newByte;
  8611. if (code === 0xff51) {
  8612. stream.skip(4);
  8613. var Xsiz = stream.getInt32() >>> 0;
  8614. var Ysiz = stream.getInt32() >>> 0;
  8615. var XOsiz = stream.getInt32() >>> 0;
  8616. var YOsiz = stream.getInt32() >>> 0;
  8617. stream.skip(16);
  8618. var Csiz = stream.getUint16();
  8619. this.width = Xsiz - XOsiz;
  8620. this.height = Ysiz - YOsiz;
  8621. this.componentsCount = Csiz;
  8622. this.bitsPerComponent = 8;
  8623. return;
  8624. }
  8625. }
  8626. throw new JpxError("No size marker found in JPX stream");
  8627. }
  8628. }, {
  8629. key: "parseCodestream",
  8630. value: function parseCodestream(data, start, end) {
  8631. var context = {};
  8632. var doNotRecover = false;
  8633. try {
  8634. var position = start;
  8635. while (position + 1 < end) {
  8636. var code = (0, _core_utils.readUint16)(data, position);
  8637. position += 2;
  8638. var length = 0,
  8639. j = void 0,
  8640. sqcd = void 0,
  8641. spqcds = void 0,
  8642. spqcdSize = void 0,
  8643. scalarExpounded = void 0,
  8644. tile = void 0;
  8645. switch (code) {
  8646. case 0xff4f:
  8647. context.mainHeader = true;
  8648. break;
  8649. case 0xffd9:
  8650. break;
  8651. case 0xff51:
  8652. length = (0, _core_utils.readUint16)(data, position);
  8653. var siz = {};
  8654. siz.Xsiz = (0, _core_utils.readUint32)(data, position + 4);
  8655. siz.Ysiz = (0, _core_utils.readUint32)(data, position + 8);
  8656. siz.XOsiz = (0, _core_utils.readUint32)(data, position + 12);
  8657. siz.YOsiz = (0, _core_utils.readUint32)(data, position + 16);
  8658. siz.XTsiz = (0, _core_utils.readUint32)(data, position + 20);
  8659. siz.YTsiz = (0, _core_utils.readUint32)(data, position + 24);
  8660. siz.XTOsiz = (0, _core_utils.readUint32)(data, position + 28);
  8661. siz.YTOsiz = (0, _core_utils.readUint32)(data, position + 32);
  8662. var componentsCount = (0, _core_utils.readUint16)(data, position + 36);
  8663. siz.Csiz = componentsCount;
  8664. var components = [];
  8665. j = position + 38;
  8666. for (var i = 0; i < componentsCount; i++) {
  8667. var component = {
  8668. precision: (data[j] & 0x7f) + 1,
  8669. isSigned: !!(data[j] & 0x80),
  8670. XRsiz: data[j + 1],
  8671. YRsiz: data[j + 2]
  8672. };
  8673. j += 3;
  8674. calculateComponentDimensions(component, siz);
  8675. components.push(component);
  8676. }
  8677. context.SIZ = siz;
  8678. context.components = components;
  8679. calculateTileGrids(context, components);
  8680. context.QCC = [];
  8681. context.COC = [];
  8682. break;
  8683. case 0xff5c:
  8684. length = (0, _core_utils.readUint16)(data, position);
  8685. var qcd = {};
  8686. j = position + 2;
  8687. sqcd = data[j++];
  8688. switch (sqcd & 0x1f) {
  8689. case 0:
  8690. spqcdSize = 8;
  8691. scalarExpounded = true;
  8692. break;
  8693. case 1:
  8694. spqcdSize = 16;
  8695. scalarExpounded = false;
  8696. break;
  8697. case 2:
  8698. spqcdSize = 16;
  8699. scalarExpounded = true;
  8700. break;
  8701. default:
  8702. throw new Error("Invalid SQcd value " + sqcd);
  8703. }
  8704. qcd.noQuantization = spqcdSize === 8;
  8705. qcd.scalarExpounded = scalarExpounded;
  8706. qcd.guardBits = sqcd >> 5;
  8707. spqcds = [];
  8708. while (j < length + position) {
  8709. var spqcd = {};
  8710. if (spqcdSize === 8) {
  8711. spqcd.epsilon = data[j++] >> 3;
  8712. spqcd.mu = 0;
  8713. } else {
  8714. spqcd.epsilon = data[j] >> 3;
  8715. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  8716. j += 2;
  8717. }
  8718. spqcds.push(spqcd);
  8719. }
  8720. qcd.SPqcds = spqcds;
  8721. if (context.mainHeader) {
  8722. context.QCD = qcd;
  8723. } else {
  8724. context.currentTile.QCD = qcd;
  8725. context.currentTile.QCC = [];
  8726. }
  8727. break;
  8728. case 0xff5d:
  8729. length = (0, _core_utils.readUint16)(data, position);
  8730. var qcc = {};
  8731. j = position + 2;
  8732. var cqcc = void 0;
  8733. if (context.SIZ.Csiz < 257) {
  8734. cqcc = data[j++];
  8735. } else {
  8736. cqcc = (0, _core_utils.readUint16)(data, j);
  8737. j += 2;
  8738. }
  8739. sqcd = data[j++];
  8740. switch (sqcd & 0x1f) {
  8741. case 0:
  8742. spqcdSize = 8;
  8743. scalarExpounded = true;
  8744. break;
  8745. case 1:
  8746. spqcdSize = 16;
  8747. scalarExpounded = false;
  8748. break;
  8749. case 2:
  8750. spqcdSize = 16;
  8751. scalarExpounded = true;
  8752. break;
  8753. default:
  8754. throw new Error("Invalid SQcd value " + sqcd);
  8755. }
  8756. qcc.noQuantization = spqcdSize === 8;
  8757. qcc.scalarExpounded = scalarExpounded;
  8758. qcc.guardBits = sqcd >> 5;
  8759. spqcds = [];
  8760. while (j < length + position) {
  8761. var _spqcd = {};
  8762. if (spqcdSize === 8) {
  8763. _spqcd.epsilon = data[j++] >> 3;
  8764. _spqcd.mu = 0;
  8765. } else {
  8766. _spqcd.epsilon = data[j] >> 3;
  8767. _spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  8768. j += 2;
  8769. }
  8770. spqcds.push(_spqcd);
  8771. }
  8772. qcc.SPqcds = spqcds;
  8773. if (context.mainHeader) {
  8774. context.QCC[cqcc] = qcc;
  8775. } else {
  8776. context.currentTile.QCC[cqcc] = qcc;
  8777. }
  8778. break;
  8779. case 0xff52:
  8780. length = (0, _core_utils.readUint16)(data, position);
  8781. var cod = {};
  8782. j = position + 2;
  8783. var scod = data[j++];
  8784. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  8785. cod.sopMarkerUsed = !!(scod & 2);
  8786. cod.ephMarkerUsed = !!(scod & 4);
  8787. cod.progressionOrder = data[j++];
  8788. cod.layersCount = (0, _core_utils.readUint16)(data, j);
  8789. j += 2;
  8790. cod.multipleComponentTransform = data[j++];
  8791. cod.decompositionLevelsCount = data[j++];
  8792. cod.xcb = (data[j++] & 0xf) + 2;
  8793. cod.ycb = (data[j++] & 0xf) + 2;
  8794. var blockStyle = data[j++];
  8795. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  8796. cod.resetContextProbabilities = !!(blockStyle & 2);
  8797. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  8798. cod.verticallyStripe = !!(blockStyle & 8);
  8799. cod.predictableTermination = !!(blockStyle & 16);
  8800. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  8801. cod.reversibleTransformation = data[j++];
  8802. if (cod.entropyCoderWithCustomPrecincts) {
  8803. var precinctsSizes = [];
  8804. while (j < length + position) {
  8805. var precinctsSize = data[j++];
  8806. precinctsSizes.push({
  8807. PPx: precinctsSize & 0xf,
  8808. PPy: precinctsSize >> 4
  8809. });
  8810. }
  8811. cod.precinctsSizes = precinctsSizes;
  8812. }
  8813. var unsupported = [];
  8814. if (cod.selectiveArithmeticCodingBypass) {
  8815. unsupported.push("selectiveArithmeticCodingBypass");
  8816. }
  8817. if (cod.resetContextProbabilities) {
  8818. unsupported.push("resetContextProbabilities");
  8819. }
  8820. if (cod.terminationOnEachCodingPass) {
  8821. unsupported.push("terminationOnEachCodingPass");
  8822. }
  8823. if (cod.verticallyStripe) {
  8824. unsupported.push("verticallyStripe");
  8825. }
  8826. if (cod.predictableTermination) {
  8827. unsupported.push("predictableTermination");
  8828. }
  8829. if (unsupported.length > 0) {
  8830. doNotRecover = true;
  8831. (0, _util.warn)("JPX: Unsupported COD options (".concat(unsupported.join(", "), ")."));
  8832. }
  8833. if (context.mainHeader) {
  8834. context.COD = cod;
  8835. } else {
  8836. context.currentTile.COD = cod;
  8837. context.currentTile.COC = [];
  8838. }
  8839. break;
  8840. case 0xff90:
  8841. length = (0, _core_utils.readUint16)(data, position);
  8842. tile = {};
  8843. tile.index = (0, _core_utils.readUint16)(data, position + 2);
  8844. tile.length = (0, _core_utils.readUint32)(data, position + 4);
  8845. tile.dataEnd = tile.length + position - 2;
  8846. tile.partIndex = data[position + 8];
  8847. tile.partsCount = data[position + 9];
  8848. context.mainHeader = false;
  8849. if (tile.partIndex === 0) {
  8850. tile.COD = context.COD;
  8851. tile.COC = context.COC.slice(0);
  8852. tile.QCD = context.QCD;
  8853. tile.QCC = context.QCC.slice(0);
  8854. }
  8855. context.currentTile = tile;
  8856. break;
  8857. case 0xff93:
  8858. tile = context.currentTile;
  8859. if (tile.partIndex === 0) {
  8860. initializeTile(context, tile.index);
  8861. buildPackets(context);
  8862. }
  8863. length = tile.dataEnd - position;
  8864. parseTilePackets(context, data, position, length);
  8865. break;
  8866. case 0xff53:
  8867. (0, _util.warn)("JPX: Codestream code 0xFF53 (COC) is not implemented.");
  8868. case 0xff55:
  8869. case 0xff57:
  8870. case 0xff58:
  8871. case 0xff64:
  8872. length = (0, _core_utils.readUint16)(data, position);
  8873. break;
  8874. default:
  8875. throw new Error("Unknown codestream code: " + code.toString(16));
  8876. }
  8877. position += length;
  8878. }
  8879. } catch (e) {
  8880. if (doNotRecover || this.failOnCorruptedImage) {
  8881. throw new JpxError(e.message);
  8882. } else {
  8883. (0, _util.warn)("JPX: Trying to recover from: \"".concat(e.message, "\"."));
  8884. }
  8885. }
  8886. this.tiles = transformComponents(context);
  8887. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  8888. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  8889. this.componentsCount = context.SIZ.Csiz;
  8890. }
  8891. }]);
  8892. return JpxImage;
  8893. }();
  8894. exports.JpxImage = JpxImage;
  8895. function calculateComponentDimensions(component, siz) {
  8896. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  8897. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  8898. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  8899. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  8900. component.width = component.x1 - component.x0;
  8901. component.height = component.y1 - component.y0;
  8902. }
  8903. function calculateTileGrids(context, components) {
  8904. var siz = context.SIZ;
  8905. var tiles = [];
  8906. var tile;
  8907. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  8908. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  8909. for (var q = 0; q < numYtiles; q++) {
  8910. for (var p = 0; p < numXtiles; p++) {
  8911. tile = {};
  8912. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  8913. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  8914. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  8915. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  8916. tile.width = tile.tx1 - tile.tx0;
  8917. tile.height = tile.ty1 - tile.ty0;
  8918. tile.components = [];
  8919. tiles.push(tile);
  8920. }
  8921. }
  8922. context.tiles = tiles;
  8923. var componentsCount = siz.Csiz;
  8924. for (var i = 0, ii = componentsCount; i < ii; i++) {
  8925. var component = components[i];
  8926. for (var j = 0, jj = tiles.length; j < jj; j++) {
  8927. var tileComponent = {};
  8928. tile = tiles[j];
  8929. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  8930. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  8931. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  8932. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  8933. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  8934. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  8935. tile.components[i] = tileComponent;
  8936. }
  8937. }
  8938. }
  8939. function getBlocksDimensions(context, component, r) {
  8940. var codOrCoc = component.codingStyleParameters;
  8941. var result = {};
  8942. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  8943. result.PPx = 15;
  8944. result.PPy = 15;
  8945. } else {
  8946. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  8947. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  8948. }
  8949. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  8950. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  8951. return result;
  8952. }
  8953. function buildPrecincts(context, resolution, dimensions) {
  8954. var precinctWidth = 1 << dimensions.PPx;
  8955. var precinctHeight = 1 << dimensions.PPy;
  8956. var isZeroRes = resolution.resLevel === 0;
  8957. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  8958. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  8959. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  8960. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  8961. var numprecincts = numprecinctswide * numprecinctshigh;
  8962. resolution.precinctParameters = {
  8963. precinctWidth: precinctWidth,
  8964. precinctHeight: precinctHeight,
  8965. numprecinctswide: numprecinctswide,
  8966. numprecinctshigh: numprecinctshigh,
  8967. numprecincts: numprecincts,
  8968. precinctWidthInSubband: precinctWidthInSubband,
  8969. precinctHeightInSubband: precinctHeightInSubband
  8970. };
  8971. }
  8972. function buildCodeblocks(context, subband, dimensions) {
  8973. var xcb_ = dimensions.xcb_;
  8974. var ycb_ = dimensions.ycb_;
  8975. var codeblockWidth = 1 << xcb_;
  8976. var codeblockHeight = 1 << ycb_;
  8977. var cbx0 = subband.tbx0 >> xcb_;
  8978. var cby0 = subband.tby0 >> ycb_;
  8979. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  8980. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  8981. var precinctParameters = subband.resolution.precinctParameters;
  8982. var codeblocks = [];
  8983. var precincts = [];
  8984. var i, j, codeblock, precinctNumber;
  8985. for (j = cby0; j < cby1; j++) {
  8986. for (i = cbx0; i < cbx1; i++) {
  8987. codeblock = {
  8988. cbx: i,
  8989. cby: j,
  8990. tbx0: codeblockWidth * i,
  8991. tby0: codeblockHeight * j,
  8992. tbx1: codeblockWidth * (i + 1),
  8993. tby1: codeblockHeight * (j + 1)
  8994. };
  8995. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  8996. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  8997. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  8998. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  8999. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  9000. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  9001. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  9002. codeblock.precinctNumber = precinctNumber;
  9003. codeblock.subbandType = subband.type;
  9004. codeblock.Lblock = 3;
  9005. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  9006. continue;
  9007. }
  9008. codeblocks.push(codeblock);
  9009. var precinct = precincts[precinctNumber];
  9010. if (precinct !== undefined) {
  9011. if (i < precinct.cbxMin) {
  9012. precinct.cbxMin = i;
  9013. } else if (i > precinct.cbxMax) {
  9014. precinct.cbxMax = i;
  9015. }
  9016. if (j < precinct.cbyMin) {
  9017. precinct.cbxMin = j;
  9018. } else if (j > precinct.cbyMax) {
  9019. precinct.cbyMax = j;
  9020. }
  9021. } else {
  9022. precincts[precinctNumber] = precinct = {
  9023. cbxMin: i,
  9024. cbyMin: j,
  9025. cbxMax: i,
  9026. cbyMax: j
  9027. };
  9028. }
  9029. codeblock.precinct = precinct;
  9030. }
  9031. }
  9032. subband.codeblockParameters = {
  9033. codeblockWidth: xcb_,
  9034. codeblockHeight: ycb_,
  9035. numcodeblockwide: cbx1 - cbx0 + 1,
  9036. numcodeblockhigh: cby1 - cby0 + 1
  9037. };
  9038. subband.codeblocks = codeblocks;
  9039. subband.precincts = precincts;
  9040. }
  9041. function createPacket(resolution, precinctNumber, layerNumber) {
  9042. var precinctCodeblocks = [];
  9043. var subbands = resolution.subbands;
  9044. for (var i = 0, ii = subbands.length; i < ii; i++) {
  9045. var subband = subbands[i];
  9046. var codeblocks = subband.codeblocks;
  9047. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  9048. var codeblock = codeblocks[j];
  9049. if (codeblock.precinctNumber !== precinctNumber) {
  9050. continue;
  9051. }
  9052. precinctCodeblocks.push(codeblock);
  9053. }
  9054. }
  9055. return {
  9056. layerNumber: layerNumber,
  9057. codeblocks: precinctCodeblocks
  9058. };
  9059. }
  9060. function LayerResolutionComponentPositionIterator(context) {
  9061. var siz = context.SIZ;
  9062. var tileIndex = context.currentTile.index;
  9063. var tile = context.tiles[tileIndex];
  9064. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  9065. var componentsCount = siz.Csiz;
  9066. var maxDecompositionLevelsCount = 0;
  9067. for (var q = 0; q < componentsCount; q++) {
  9068. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  9069. }
  9070. var l = 0,
  9071. r = 0,
  9072. i = 0,
  9073. k = 0;
  9074. this.nextPacket = function JpxImage_nextPacket() {
  9075. for (; l < layersCount; l++) {
  9076. for (; r <= maxDecompositionLevelsCount; r++) {
  9077. for (; i < componentsCount; i++) {
  9078. var component = tile.components[i];
  9079. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  9080. continue;
  9081. }
  9082. var resolution = component.resolutions[r];
  9083. var numprecincts = resolution.precinctParameters.numprecincts;
  9084. for (; k < numprecincts;) {
  9085. var packet = createPacket(resolution, k, l);
  9086. k++;
  9087. return packet;
  9088. }
  9089. k = 0;
  9090. }
  9091. i = 0;
  9092. }
  9093. r = 0;
  9094. }
  9095. throw new JpxError("Out of packets");
  9096. };
  9097. }
  9098. function ResolutionLayerComponentPositionIterator(context) {
  9099. var siz = context.SIZ;
  9100. var tileIndex = context.currentTile.index;
  9101. var tile = context.tiles[tileIndex];
  9102. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  9103. var componentsCount = siz.Csiz;
  9104. var maxDecompositionLevelsCount = 0;
  9105. for (var q = 0; q < componentsCount; q++) {
  9106. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  9107. }
  9108. var r = 0,
  9109. l = 0,
  9110. i = 0,
  9111. k = 0;
  9112. this.nextPacket = function JpxImage_nextPacket() {
  9113. for (; r <= maxDecompositionLevelsCount; r++) {
  9114. for (; l < layersCount; l++) {
  9115. for (; i < componentsCount; i++) {
  9116. var component = tile.components[i];
  9117. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  9118. continue;
  9119. }
  9120. var resolution = component.resolutions[r];
  9121. var numprecincts = resolution.precinctParameters.numprecincts;
  9122. for (; k < numprecincts;) {
  9123. var packet = createPacket(resolution, k, l);
  9124. k++;
  9125. return packet;
  9126. }
  9127. k = 0;
  9128. }
  9129. i = 0;
  9130. }
  9131. l = 0;
  9132. }
  9133. throw new JpxError("Out of packets");
  9134. };
  9135. }
  9136. function ResolutionPositionComponentLayerIterator(context) {
  9137. var siz = context.SIZ;
  9138. var tileIndex = context.currentTile.index;
  9139. var tile = context.tiles[tileIndex];
  9140. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  9141. var componentsCount = siz.Csiz;
  9142. var l, r, c, p;
  9143. var maxDecompositionLevelsCount = 0;
  9144. for (c = 0; c < componentsCount; c++) {
  9145. var component = tile.components[c];
  9146. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  9147. }
  9148. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  9149. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  9150. var maxNumPrecincts = 0;
  9151. for (c = 0; c < componentsCount; ++c) {
  9152. var resolutions = tile.components[c].resolutions;
  9153. if (r < resolutions.length) {
  9154. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  9155. }
  9156. }
  9157. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  9158. }
  9159. l = 0;
  9160. r = 0;
  9161. c = 0;
  9162. p = 0;
  9163. this.nextPacket = function JpxImage_nextPacket() {
  9164. for (; r <= maxDecompositionLevelsCount; r++) {
  9165. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  9166. for (; c < componentsCount; c++) {
  9167. var _component = tile.components[c];
  9168. if (r > _component.codingStyleParameters.decompositionLevelsCount) {
  9169. continue;
  9170. }
  9171. var resolution = _component.resolutions[r];
  9172. var numprecincts = resolution.precinctParameters.numprecincts;
  9173. if (p >= numprecincts) {
  9174. continue;
  9175. }
  9176. for (; l < layersCount;) {
  9177. var packet = createPacket(resolution, p, l);
  9178. l++;
  9179. return packet;
  9180. }
  9181. l = 0;
  9182. }
  9183. c = 0;
  9184. }
  9185. p = 0;
  9186. }
  9187. throw new JpxError("Out of packets");
  9188. };
  9189. }
  9190. function PositionComponentResolutionLayerIterator(context) {
  9191. var siz = context.SIZ;
  9192. var tileIndex = context.currentTile.index;
  9193. var tile = context.tiles[tileIndex];
  9194. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  9195. var componentsCount = siz.Csiz;
  9196. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  9197. var precinctsIterationSizes = precinctsSizes;
  9198. var l = 0,
  9199. r = 0,
  9200. c = 0,
  9201. px = 0,
  9202. py = 0;
  9203. this.nextPacket = function JpxImage_nextPacket() {
  9204. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  9205. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  9206. for (; c < componentsCount; c++) {
  9207. var component = tile.components[c];
  9208. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  9209. for (; r <= decompositionLevelsCount; r++) {
  9210. var resolution = component.resolutions[r];
  9211. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  9212. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  9213. if (k === null) {
  9214. continue;
  9215. }
  9216. for (; l < layersCount;) {
  9217. var packet = createPacket(resolution, k, l);
  9218. l++;
  9219. return packet;
  9220. }
  9221. l = 0;
  9222. }
  9223. r = 0;
  9224. }
  9225. c = 0;
  9226. }
  9227. px = 0;
  9228. }
  9229. throw new JpxError("Out of packets");
  9230. };
  9231. }
  9232. function ComponentPositionResolutionLayerIterator(context) {
  9233. var siz = context.SIZ;
  9234. var tileIndex = context.currentTile.index;
  9235. var tile = context.tiles[tileIndex];
  9236. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  9237. var componentsCount = siz.Csiz;
  9238. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  9239. var l = 0,
  9240. r = 0,
  9241. c = 0,
  9242. px = 0,
  9243. py = 0;
  9244. this.nextPacket = function JpxImage_nextPacket() {
  9245. for (; c < componentsCount; ++c) {
  9246. var component = tile.components[c];
  9247. var precinctsIterationSizes = precinctsSizes.components[c];
  9248. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  9249. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  9250. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  9251. for (; r <= decompositionLevelsCount; r++) {
  9252. var resolution = component.resolutions[r];
  9253. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  9254. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  9255. if (k === null) {
  9256. continue;
  9257. }
  9258. for (; l < layersCount;) {
  9259. var packet = createPacket(resolution, k, l);
  9260. l++;
  9261. return packet;
  9262. }
  9263. l = 0;
  9264. }
  9265. r = 0;
  9266. }
  9267. px = 0;
  9268. }
  9269. py = 0;
  9270. }
  9271. throw new JpxError("Out of packets");
  9272. };
  9273. }
  9274. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  9275. var posX = pxIndex * precinctIterationSizes.minWidth;
  9276. var posY = pyIndex * precinctIterationSizes.minHeight;
  9277. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  9278. return null;
  9279. }
  9280. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  9281. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  9282. }
  9283. function getPrecinctSizesInImageScale(tile) {
  9284. var componentsCount = tile.components.length;
  9285. var minWidth = Number.MAX_VALUE;
  9286. var minHeight = Number.MAX_VALUE;
  9287. var maxNumWide = 0;
  9288. var maxNumHigh = 0;
  9289. var sizePerComponent = new Array(componentsCount);
  9290. for (var c = 0; c < componentsCount; c++) {
  9291. var component = tile.components[c];
  9292. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  9293. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  9294. var minWidthCurrentComponent = Number.MAX_VALUE;
  9295. var minHeightCurrentComponent = Number.MAX_VALUE;
  9296. var maxNumWideCurrentComponent = 0;
  9297. var maxNumHighCurrentComponent = 0;
  9298. var scale = 1;
  9299. for (var r = decompositionLevelsCount; r >= 0; --r) {
  9300. var resolution = component.resolutions[r];
  9301. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  9302. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  9303. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  9304. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  9305. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  9306. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  9307. sizePerResolution[r] = {
  9308. width: widthCurrentResolution,
  9309. height: heightCurrentResolution
  9310. };
  9311. scale <<= 1;
  9312. }
  9313. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  9314. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  9315. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  9316. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  9317. sizePerComponent[c] = {
  9318. resolutions: sizePerResolution,
  9319. minWidth: minWidthCurrentComponent,
  9320. minHeight: minHeightCurrentComponent,
  9321. maxNumWide: maxNumWideCurrentComponent,
  9322. maxNumHigh: maxNumHighCurrentComponent
  9323. };
  9324. }
  9325. return {
  9326. components: sizePerComponent,
  9327. minWidth: minWidth,
  9328. minHeight: minHeight,
  9329. maxNumWide: maxNumWide,
  9330. maxNumHigh: maxNumHigh
  9331. };
  9332. }
  9333. function buildPackets(context) {
  9334. var siz = context.SIZ;
  9335. var tileIndex = context.currentTile.index;
  9336. var tile = context.tiles[tileIndex];
  9337. var componentsCount = siz.Csiz;
  9338. for (var c = 0; c < componentsCount; c++) {
  9339. var component = tile.components[c];
  9340. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  9341. var resolutions = [];
  9342. var subbands = [];
  9343. for (var r = 0; r <= decompositionLevelsCount; r++) {
  9344. var blocksDimensions = getBlocksDimensions(context, component, r);
  9345. var resolution = {};
  9346. var scale = 1 << decompositionLevelsCount - r;
  9347. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  9348. resolution.try0 = Math.ceil(component.tcy0 / scale);
  9349. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  9350. resolution.try1 = Math.ceil(component.tcy1 / scale);
  9351. resolution.resLevel = r;
  9352. buildPrecincts(context, resolution, blocksDimensions);
  9353. resolutions.push(resolution);
  9354. var subband = void 0;
  9355. if (r === 0) {
  9356. subband = {};
  9357. subband.type = "LL";
  9358. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  9359. subband.tby0 = Math.ceil(component.tcy0 / scale);
  9360. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  9361. subband.tby1 = Math.ceil(component.tcy1 / scale);
  9362. subband.resolution = resolution;
  9363. buildCodeblocks(context, subband, blocksDimensions);
  9364. subbands.push(subband);
  9365. resolution.subbands = [subband];
  9366. } else {
  9367. var bscale = 1 << decompositionLevelsCount - r + 1;
  9368. var resolutionSubbands = [];
  9369. subband = {};
  9370. subband.type = "HL";
  9371. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  9372. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  9373. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  9374. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  9375. subband.resolution = resolution;
  9376. buildCodeblocks(context, subband, blocksDimensions);
  9377. subbands.push(subband);
  9378. resolutionSubbands.push(subband);
  9379. subband = {};
  9380. subband.type = "LH";
  9381. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  9382. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  9383. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  9384. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  9385. subband.resolution = resolution;
  9386. buildCodeblocks(context, subband, blocksDimensions);
  9387. subbands.push(subband);
  9388. resolutionSubbands.push(subband);
  9389. subband = {};
  9390. subband.type = "HH";
  9391. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  9392. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  9393. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  9394. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  9395. subband.resolution = resolution;
  9396. buildCodeblocks(context, subband, blocksDimensions);
  9397. subbands.push(subband);
  9398. resolutionSubbands.push(subband);
  9399. resolution.subbands = resolutionSubbands;
  9400. }
  9401. }
  9402. component.resolutions = resolutions;
  9403. component.subbands = subbands;
  9404. }
  9405. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  9406. switch (progressionOrder) {
  9407. case 0:
  9408. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  9409. break;
  9410. case 1:
  9411. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  9412. break;
  9413. case 2:
  9414. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  9415. break;
  9416. case 3:
  9417. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  9418. break;
  9419. case 4:
  9420. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  9421. break;
  9422. default:
  9423. throw new JpxError("Unsupported progression order ".concat(progressionOrder));
  9424. }
  9425. }
  9426. function parseTilePackets(context, data, offset, dataLength) {
  9427. var position = 0;
  9428. var buffer,
  9429. bufferSize = 0,
  9430. skipNextBit = false;
  9431. function readBits(count) {
  9432. while (bufferSize < count) {
  9433. var b = data[offset + position];
  9434. position++;
  9435. if (skipNextBit) {
  9436. buffer = buffer << 7 | b;
  9437. bufferSize += 7;
  9438. skipNextBit = false;
  9439. } else {
  9440. buffer = buffer << 8 | b;
  9441. bufferSize += 8;
  9442. }
  9443. if (b === 0xff) {
  9444. skipNextBit = true;
  9445. }
  9446. }
  9447. bufferSize -= count;
  9448. return buffer >>> bufferSize & (1 << count) - 1;
  9449. }
  9450. function skipMarkerIfEqual(value) {
  9451. if (data[offset + position - 1] === 0xff && data[offset + position] === value) {
  9452. skipBytes(1);
  9453. return true;
  9454. } else if (data[offset + position] === 0xff && data[offset + position + 1] === value) {
  9455. skipBytes(2);
  9456. return true;
  9457. }
  9458. return false;
  9459. }
  9460. function skipBytes(count) {
  9461. position += count;
  9462. }
  9463. function alignToByte() {
  9464. bufferSize = 0;
  9465. if (skipNextBit) {
  9466. position++;
  9467. skipNextBit = false;
  9468. }
  9469. }
  9470. function readCodingpasses() {
  9471. if (readBits(1) === 0) {
  9472. return 1;
  9473. }
  9474. if (readBits(1) === 0) {
  9475. return 2;
  9476. }
  9477. var value = readBits(2);
  9478. if (value < 3) {
  9479. return value + 3;
  9480. }
  9481. value = readBits(5);
  9482. if (value < 31) {
  9483. return value + 6;
  9484. }
  9485. value = readBits(7);
  9486. return value + 37;
  9487. }
  9488. var tileIndex = context.currentTile.index;
  9489. var tile = context.tiles[tileIndex];
  9490. var sopMarkerUsed = context.COD.sopMarkerUsed;
  9491. var ephMarkerUsed = context.COD.ephMarkerUsed;
  9492. var packetsIterator = tile.packetsIterator;
  9493. while (position < dataLength) {
  9494. alignToByte();
  9495. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  9496. skipBytes(4);
  9497. }
  9498. var packet = packetsIterator.nextPacket();
  9499. if (!readBits(1)) {
  9500. continue;
  9501. }
  9502. var layerNumber = packet.layerNumber,
  9503. queue = [];
  9504. var codeblock = void 0;
  9505. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  9506. codeblock = packet.codeblocks[i];
  9507. var precinct = codeblock.precinct;
  9508. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  9509. var codeblockRow = codeblock.cby - precinct.cbyMin;
  9510. var codeblockIncluded = false;
  9511. var firstTimeInclusion = false;
  9512. var valueReady = void 0,
  9513. zeroBitPlanesTree = void 0;
  9514. if (codeblock.included !== undefined) {
  9515. codeblockIncluded = !!readBits(1);
  9516. } else {
  9517. precinct = codeblock.precinct;
  9518. var inclusionTree = void 0;
  9519. if (precinct.inclusionTree !== undefined) {
  9520. inclusionTree = precinct.inclusionTree;
  9521. } else {
  9522. var width = precinct.cbxMax - precinct.cbxMin + 1;
  9523. var height = precinct.cbyMax - precinct.cbyMin + 1;
  9524. inclusionTree = new InclusionTree(width, height, layerNumber);
  9525. zeroBitPlanesTree = new TagTree(width, height);
  9526. precinct.inclusionTree = inclusionTree;
  9527. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  9528. for (var l = 0; l < layerNumber; l++) {
  9529. if (readBits(1) !== 0) {
  9530. throw new JpxError("Invalid tag tree");
  9531. }
  9532. }
  9533. }
  9534. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  9535. while (true) {
  9536. if (readBits(1)) {
  9537. valueReady = !inclusionTree.nextLevel();
  9538. if (valueReady) {
  9539. codeblock.included = true;
  9540. codeblockIncluded = firstTimeInclusion = true;
  9541. break;
  9542. }
  9543. } else {
  9544. inclusionTree.incrementValue(layerNumber);
  9545. break;
  9546. }
  9547. }
  9548. }
  9549. }
  9550. if (!codeblockIncluded) {
  9551. continue;
  9552. }
  9553. if (firstTimeInclusion) {
  9554. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  9555. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  9556. while (true) {
  9557. if (readBits(1)) {
  9558. valueReady = !zeroBitPlanesTree.nextLevel();
  9559. if (valueReady) {
  9560. break;
  9561. }
  9562. } else {
  9563. zeroBitPlanesTree.incrementValue();
  9564. }
  9565. }
  9566. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  9567. }
  9568. var codingpasses = readCodingpasses();
  9569. while (readBits(1)) {
  9570. codeblock.Lblock++;
  9571. }
  9572. var codingpassesLog2 = (0, _core_utils.log2)(codingpasses);
  9573. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  9574. var codedDataLength = readBits(bits);
  9575. queue.push({
  9576. codeblock: codeblock,
  9577. codingpasses: codingpasses,
  9578. dataLength: codedDataLength
  9579. });
  9580. }
  9581. alignToByte();
  9582. if (ephMarkerUsed) {
  9583. skipMarkerIfEqual(0x92);
  9584. }
  9585. while (queue.length > 0) {
  9586. var packetItem = queue.shift();
  9587. codeblock = packetItem.codeblock;
  9588. if (codeblock.data === undefined) {
  9589. codeblock.data = [];
  9590. }
  9591. codeblock.data.push({
  9592. data: data,
  9593. start: offset + position,
  9594. end: offset + position + packetItem.dataLength,
  9595. codingpasses: packetItem.codingpasses
  9596. });
  9597. position += packetItem.dataLength;
  9598. }
  9599. }
  9600. return position;
  9601. }
  9602. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  9603. var x0 = subband.tbx0;
  9604. var y0 = subband.tby0;
  9605. var width = subband.tbx1 - subband.tbx0;
  9606. var codeblocks = subband.codeblocks;
  9607. var right = subband.type.charAt(0) === "H" ? 1 : 0;
  9608. var bottom = subband.type.charAt(1) === "H" ? levelWidth : 0;
  9609. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  9610. var codeblock = codeblocks[i];
  9611. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  9612. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  9613. if (blockWidth === 0 || blockHeight === 0) {
  9614. continue;
  9615. }
  9616. if (codeblock.data === undefined) {
  9617. continue;
  9618. }
  9619. var bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  9620. var currentCodingpassType = 2;
  9621. var data = codeblock.data;
  9622. var totalLength = 0,
  9623. codingpasses = 0;
  9624. var j = void 0,
  9625. jj = void 0,
  9626. dataItem = void 0;
  9627. for (j = 0, jj = data.length; j < jj; j++) {
  9628. dataItem = data[j];
  9629. totalLength += dataItem.end - dataItem.start;
  9630. codingpasses += dataItem.codingpasses;
  9631. }
  9632. var encodedData = new Uint8Array(totalLength);
  9633. var position = 0;
  9634. for (j = 0, jj = data.length; j < jj; j++) {
  9635. dataItem = data[j];
  9636. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  9637. encodedData.set(chunk, position);
  9638. position += chunk.length;
  9639. }
  9640. var decoder = new _arithmetic_decoder.ArithmeticDecoder(encodedData, 0, totalLength);
  9641. bitModel.setDecoder(decoder);
  9642. for (j = 0; j < codingpasses; j++) {
  9643. switch (currentCodingpassType) {
  9644. case 0:
  9645. bitModel.runSignificancePropagationPass();
  9646. break;
  9647. case 1:
  9648. bitModel.runMagnitudeRefinementPass();
  9649. break;
  9650. case 2:
  9651. bitModel.runCleanupPass();
  9652. if (segmentationSymbolUsed) {
  9653. bitModel.checkSegmentationSymbol();
  9654. }
  9655. break;
  9656. }
  9657. currentCodingpassType = (currentCodingpassType + 1) % 3;
  9658. }
  9659. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  9660. var sign = bitModel.coefficentsSign;
  9661. var magnitude = bitModel.coefficentsMagnitude;
  9662. var bitsDecoded = bitModel.bitsDecoded;
  9663. var magnitudeCorrection = reversible ? 0 : 0.5;
  9664. var k = void 0,
  9665. n = void 0,
  9666. nb = void 0;
  9667. position = 0;
  9668. var interleave = subband.type !== "LL";
  9669. for (j = 0; j < blockHeight; j++) {
  9670. var row = offset / width | 0;
  9671. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  9672. for (k = 0; k < blockWidth; k++) {
  9673. n = magnitude[position];
  9674. if (n !== 0) {
  9675. n = (n + magnitudeCorrection) * delta;
  9676. if (sign[position] !== 0) {
  9677. n = -n;
  9678. }
  9679. nb = bitsDecoded[position];
  9680. var pos = interleave ? levelOffset + (offset << 1) : offset;
  9681. if (reversible && nb >= mb) {
  9682. coefficients[pos] = n;
  9683. } else {
  9684. coefficients[pos] = n * (1 << mb - nb);
  9685. }
  9686. }
  9687. offset++;
  9688. position++;
  9689. }
  9690. offset += width - blockWidth;
  9691. }
  9692. }
  9693. }
  9694. function transformTile(context, tile, c) {
  9695. var component = tile.components[c];
  9696. var codingStyleParameters = component.codingStyleParameters;
  9697. var quantizationParameters = component.quantizationParameters;
  9698. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  9699. var spqcds = quantizationParameters.SPqcds;
  9700. var scalarExpounded = quantizationParameters.scalarExpounded;
  9701. var guardBits = quantizationParameters.guardBits;
  9702. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  9703. var precision = context.components[c].precision;
  9704. var reversible = codingStyleParameters.reversibleTransformation;
  9705. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  9706. var subbandCoefficients = [];
  9707. var b = 0;
  9708. for (var i = 0; i <= decompositionLevelsCount; i++) {
  9709. var resolution = component.resolutions[i];
  9710. var width = resolution.trx1 - resolution.trx0;
  9711. var height = resolution.try1 - resolution.try0;
  9712. var coefficients = new Float32Array(width * height);
  9713. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  9714. var mu = void 0,
  9715. epsilon = void 0;
  9716. if (!scalarExpounded) {
  9717. mu = spqcds[0].mu;
  9718. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  9719. } else {
  9720. mu = spqcds[b].mu;
  9721. epsilon = spqcds[b].epsilon;
  9722. b++;
  9723. }
  9724. var subband = resolution.subbands[j];
  9725. var gainLog2 = SubbandsGainLog2[subband.type];
  9726. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  9727. var mb = guardBits + epsilon - 1;
  9728. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  9729. }
  9730. subbandCoefficients.push({
  9731. width: width,
  9732. height: height,
  9733. items: coefficients
  9734. });
  9735. }
  9736. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  9737. return {
  9738. left: component.tcx0,
  9739. top: component.tcy0,
  9740. width: result.width,
  9741. height: result.height,
  9742. items: result.items
  9743. };
  9744. }
  9745. function transformComponents(context) {
  9746. var siz = context.SIZ;
  9747. var components = context.components;
  9748. var componentsCount = siz.Csiz;
  9749. var resultImages = [];
  9750. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  9751. var tile = context.tiles[i];
  9752. var transformedTiles = [];
  9753. for (var c = 0; c < componentsCount; c++) {
  9754. transformedTiles[c] = transformTile(context, tile, c);
  9755. }
  9756. var tile0 = transformedTiles[0];
  9757. var out = new Uint8ClampedArray(tile0.items.length * componentsCount);
  9758. var result = {
  9759. left: tile0.left,
  9760. top: tile0.top,
  9761. width: tile0.width,
  9762. height: tile0.height,
  9763. items: out
  9764. };
  9765. var shift = void 0,
  9766. offset = void 0;
  9767. var pos = 0,
  9768. j = void 0,
  9769. jj = void 0,
  9770. y0 = void 0,
  9771. y1 = void 0,
  9772. y2 = void 0;
  9773. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  9774. var fourComponents = componentsCount === 4;
  9775. var y0items = transformedTiles[0].items;
  9776. var y1items = transformedTiles[1].items;
  9777. var y2items = transformedTiles[2].items;
  9778. var y3items = fourComponents ? transformedTiles[3].items : null;
  9779. shift = components[0].precision - 8;
  9780. offset = (128 << shift) + 0.5;
  9781. var component0 = tile.components[0];
  9782. var alpha01 = componentsCount - 3;
  9783. jj = y0items.length;
  9784. if (!component0.codingStyleParameters.reversibleTransformation) {
  9785. for (j = 0; j < jj; j++, pos += alpha01) {
  9786. y0 = y0items[j] + offset;
  9787. y1 = y1items[j];
  9788. y2 = y2items[j];
  9789. out[pos++] = y0 + 1.402 * y2 >> shift;
  9790. out[pos++] = y0 - 0.34413 * y1 - 0.71414 * y2 >> shift;
  9791. out[pos++] = y0 + 1.772 * y1 >> shift;
  9792. }
  9793. } else {
  9794. for (j = 0; j < jj; j++, pos += alpha01) {
  9795. y0 = y0items[j] + offset;
  9796. y1 = y1items[j];
  9797. y2 = y2items[j];
  9798. var g = y0 - (y2 + y1 >> 2);
  9799. out[pos++] = g + y2 >> shift;
  9800. out[pos++] = g >> shift;
  9801. out[pos++] = g + y1 >> shift;
  9802. }
  9803. }
  9804. if (fourComponents) {
  9805. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  9806. out[pos] = y3items[j] + offset >> shift;
  9807. }
  9808. }
  9809. } else {
  9810. for (var _c = 0; _c < componentsCount; _c++) {
  9811. var items = transformedTiles[_c].items;
  9812. shift = components[_c].precision - 8;
  9813. offset = (128 << shift) + 0.5;
  9814. for (pos = _c, j = 0, jj = items.length; j < jj; j++) {
  9815. out[pos] = items[j] + offset >> shift;
  9816. pos += componentsCount;
  9817. }
  9818. }
  9819. }
  9820. resultImages.push(result);
  9821. }
  9822. return resultImages;
  9823. }
  9824. function initializeTile(context, tileIndex) {
  9825. var siz = context.SIZ;
  9826. var componentsCount = siz.Csiz;
  9827. var tile = context.tiles[tileIndex];
  9828. for (var c = 0; c < componentsCount; c++) {
  9829. var component = tile.components[c];
  9830. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  9831. component.quantizationParameters = qcdOrQcc;
  9832. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  9833. component.codingStyleParameters = codOrCoc;
  9834. }
  9835. tile.codingStyleDefaultParameters = context.currentTile.COD;
  9836. }
  9837. var TagTree = /*#__PURE__*/function () {
  9838. function TagTree(width, height) {
  9839. _classCallCheck(this, TagTree);
  9840. var levelsLength = (0, _core_utils.log2)(Math.max(width, height)) + 1;
  9841. this.levels = [];
  9842. for (var i = 0; i < levelsLength; i++) {
  9843. var level = {
  9844. width: width,
  9845. height: height,
  9846. items: []
  9847. };
  9848. this.levels.push(level);
  9849. width = Math.ceil(width / 2);
  9850. height = Math.ceil(height / 2);
  9851. }
  9852. }
  9853. _createClass(TagTree, [{
  9854. key: "reset",
  9855. value: function reset(i, j) {
  9856. var currentLevel = 0,
  9857. value = 0,
  9858. level;
  9859. while (currentLevel < this.levels.length) {
  9860. level = this.levels[currentLevel];
  9861. var index = i + j * level.width;
  9862. if (level.items[index] !== undefined) {
  9863. value = level.items[index];
  9864. break;
  9865. }
  9866. level.index = index;
  9867. i >>= 1;
  9868. j >>= 1;
  9869. currentLevel++;
  9870. }
  9871. currentLevel--;
  9872. level = this.levels[currentLevel];
  9873. level.items[level.index] = value;
  9874. this.currentLevel = currentLevel;
  9875. delete this.value;
  9876. }
  9877. }, {
  9878. key: "incrementValue",
  9879. value: function incrementValue() {
  9880. var level = this.levels[this.currentLevel];
  9881. level.items[level.index]++;
  9882. }
  9883. }, {
  9884. key: "nextLevel",
  9885. value: function nextLevel() {
  9886. var currentLevel = this.currentLevel;
  9887. var level = this.levels[currentLevel];
  9888. var value = level.items[level.index];
  9889. currentLevel--;
  9890. if (currentLevel < 0) {
  9891. this.value = value;
  9892. return false;
  9893. }
  9894. this.currentLevel = currentLevel;
  9895. level = this.levels[currentLevel];
  9896. level.items[level.index] = value;
  9897. return true;
  9898. }
  9899. }]);
  9900. return TagTree;
  9901. }();
  9902. var InclusionTree = /*#__PURE__*/function () {
  9903. function InclusionTree(width, height, defaultValue) {
  9904. _classCallCheck(this, InclusionTree);
  9905. var levelsLength = (0, _core_utils.log2)(Math.max(width, height)) + 1;
  9906. this.levels = [];
  9907. for (var i = 0; i < levelsLength; i++) {
  9908. var items = new Uint8Array(width * height);
  9909. for (var j = 0, jj = items.length; j < jj; j++) {
  9910. items[j] = defaultValue;
  9911. }
  9912. var level = {
  9913. width: width,
  9914. height: height,
  9915. items: items
  9916. };
  9917. this.levels.push(level);
  9918. width = Math.ceil(width / 2);
  9919. height = Math.ceil(height / 2);
  9920. }
  9921. }
  9922. _createClass(InclusionTree, [{
  9923. key: "reset",
  9924. value: function reset(i, j, stopValue) {
  9925. var currentLevel = 0;
  9926. while (currentLevel < this.levels.length) {
  9927. var level = this.levels[currentLevel];
  9928. var index = i + j * level.width;
  9929. level.index = index;
  9930. var value = level.items[index];
  9931. if (value === 0xff) {
  9932. break;
  9933. }
  9934. if (value > stopValue) {
  9935. this.currentLevel = currentLevel;
  9936. this.propagateValues();
  9937. return false;
  9938. }
  9939. i >>= 1;
  9940. j >>= 1;
  9941. currentLevel++;
  9942. }
  9943. this.currentLevel = currentLevel - 1;
  9944. return true;
  9945. }
  9946. }, {
  9947. key: "incrementValue",
  9948. value: function incrementValue(stopValue) {
  9949. var level = this.levels[this.currentLevel];
  9950. level.items[level.index] = stopValue + 1;
  9951. this.propagateValues();
  9952. }
  9953. }, {
  9954. key: "propagateValues",
  9955. value: function propagateValues() {
  9956. var levelIndex = this.currentLevel;
  9957. var level = this.levels[levelIndex];
  9958. var currentValue = level.items[level.index];
  9959. while (--levelIndex >= 0) {
  9960. level = this.levels[levelIndex];
  9961. level.items[level.index] = currentValue;
  9962. }
  9963. }
  9964. }, {
  9965. key: "nextLevel",
  9966. value: function nextLevel() {
  9967. var currentLevel = this.currentLevel;
  9968. var level = this.levels[currentLevel];
  9969. var value = level.items[level.index];
  9970. level.items[level.index] = 0xff;
  9971. currentLevel--;
  9972. if (currentLevel < 0) {
  9973. return false;
  9974. }
  9975. this.currentLevel = currentLevel;
  9976. level = this.levels[currentLevel];
  9977. level.items[level.index] = value;
  9978. return true;
  9979. }
  9980. }]);
  9981. return InclusionTree;
  9982. }();
  9983. var BitModel = function BitModelClosure() {
  9984. var UNIFORM_CONTEXT = 17;
  9985. var RUNLENGTH_CONTEXT = 18;
  9986. var LLAndLHContextsLabel = new Uint8Array([0, 5, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 1, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8]);
  9987. var HLContextLabel = new Uint8Array([0, 3, 4, 0, 5, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 1, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8]);
  9988. var HHContextLabel = new Uint8Array([0, 1, 2, 0, 1, 2, 2, 0, 2, 2, 2, 0, 0, 0, 0, 0, 3, 4, 5, 0, 4, 5, 5, 0, 5, 5, 5, 0, 0, 0, 0, 0, 6, 7, 7, 0, 7, 7, 7, 0, 7, 7, 7, 0, 0, 0, 0, 0, 8, 8, 8, 0, 8, 8, 8, 0, 8, 8, 8, 0, 0, 0, 0, 0, 8, 8, 8, 0, 8, 8, 8, 0, 8, 8, 8]);
  9989. var BitModel = /*#__PURE__*/function () {
  9990. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  9991. _classCallCheck(this, BitModel);
  9992. this.width = width;
  9993. this.height = height;
  9994. var contextLabelTable;
  9995. if (subband === "HH") {
  9996. contextLabelTable = HHContextLabel;
  9997. } else if (subband === "HL") {
  9998. contextLabelTable = HLContextLabel;
  9999. } else {
  10000. contextLabelTable = LLAndLHContextsLabel;
  10001. }
  10002. this.contextLabelTable = contextLabelTable;
  10003. var coefficientCount = width * height;
  10004. this.neighborsSignificance = new Uint8Array(coefficientCount);
  10005. this.coefficentsSign = new Uint8Array(coefficientCount);
  10006. var coefficentsMagnitude;
  10007. if (mb > 14) {
  10008. coefficentsMagnitude = new Uint32Array(coefficientCount);
  10009. } else if (mb > 6) {
  10010. coefficentsMagnitude = new Uint16Array(coefficientCount);
  10011. } else {
  10012. coefficentsMagnitude = new Uint8Array(coefficientCount);
  10013. }
  10014. this.coefficentsMagnitude = coefficentsMagnitude;
  10015. this.processingFlags = new Uint8Array(coefficientCount);
  10016. var bitsDecoded = new Uint8Array(coefficientCount);
  10017. if (zeroBitPlanes !== 0) {
  10018. for (var i = 0; i < coefficientCount; i++) {
  10019. bitsDecoded[i] = zeroBitPlanes;
  10020. }
  10021. }
  10022. this.bitsDecoded = bitsDecoded;
  10023. this.reset();
  10024. }
  10025. _createClass(BitModel, [{
  10026. key: "setDecoder",
  10027. value: function setDecoder(decoder) {
  10028. this.decoder = decoder;
  10029. }
  10030. }, {
  10031. key: "reset",
  10032. value: function reset() {
  10033. this.contexts = new Int8Array(19);
  10034. this.contexts[0] = 4 << 1 | 0;
  10035. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  10036. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  10037. }
  10038. }, {
  10039. key: "setNeighborsSignificance",
  10040. value: function setNeighborsSignificance(row, column, index) {
  10041. var neighborsSignificance = this.neighborsSignificance;
  10042. var width = this.width,
  10043. height = this.height;
  10044. var left = column > 0;
  10045. var right = column + 1 < width;
  10046. var i;
  10047. if (row > 0) {
  10048. i = index - width;
  10049. if (left) {
  10050. neighborsSignificance[i - 1] += 0x10;
  10051. }
  10052. if (right) {
  10053. neighborsSignificance[i + 1] += 0x10;
  10054. }
  10055. neighborsSignificance[i] += 0x04;
  10056. }
  10057. if (row + 1 < height) {
  10058. i = index + width;
  10059. if (left) {
  10060. neighborsSignificance[i - 1] += 0x10;
  10061. }
  10062. if (right) {
  10063. neighborsSignificance[i + 1] += 0x10;
  10064. }
  10065. neighborsSignificance[i] += 0x04;
  10066. }
  10067. if (left) {
  10068. neighborsSignificance[index - 1] += 0x01;
  10069. }
  10070. if (right) {
  10071. neighborsSignificance[index + 1] += 0x01;
  10072. }
  10073. neighborsSignificance[index] |= 0x80;
  10074. }
  10075. }, {
  10076. key: "runSignificancePropagationPass",
  10077. value: function runSignificancePropagationPass() {
  10078. var decoder = this.decoder;
  10079. var width = this.width,
  10080. height = this.height;
  10081. var coefficentsMagnitude = this.coefficentsMagnitude;
  10082. var coefficentsSign = this.coefficentsSign;
  10083. var neighborsSignificance = this.neighborsSignificance;
  10084. var processingFlags = this.processingFlags;
  10085. var contexts = this.contexts;
  10086. var labels = this.contextLabelTable;
  10087. var bitsDecoded = this.bitsDecoded;
  10088. var processedInverseMask = ~1;
  10089. var processedMask = 1;
  10090. var firstMagnitudeBitMask = 2;
  10091. for (var i0 = 0; i0 < height; i0 += 4) {
  10092. for (var j = 0; j < width; j++) {
  10093. var index = i0 * width + j;
  10094. for (var i1 = 0; i1 < 4; i1++, index += width) {
  10095. var i = i0 + i1;
  10096. if (i >= height) {
  10097. break;
  10098. }
  10099. processingFlags[index] &= processedInverseMask;
  10100. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  10101. continue;
  10102. }
  10103. var contextLabel = labels[neighborsSignificance[index]];
  10104. var decision = decoder.readBit(contexts, contextLabel);
  10105. if (decision) {
  10106. var sign = this.decodeSignBit(i, j, index);
  10107. coefficentsSign[index] = sign;
  10108. coefficentsMagnitude[index] = 1;
  10109. this.setNeighborsSignificance(i, j, index);
  10110. processingFlags[index] |= firstMagnitudeBitMask;
  10111. }
  10112. bitsDecoded[index]++;
  10113. processingFlags[index] |= processedMask;
  10114. }
  10115. }
  10116. }
  10117. }
  10118. }, {
  10119. key: "decodeSignBit",
  10120. value: function decodeSignBit(row, column, index) {
  10121. var width = this.width,
  10122. height = this.height;
  10123. var coefficentsMagnitude = this.coefficentsMagnitude;
  10124. var coefficentsSign = this.coefficentsSign;
  10125. var contribution, sign0, sign1, significance1;
  10126. var contextLabel, decoded;
  10127. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  10128. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  10129. sign1 = coefficentsSign[index + 1];
  10130. if (significance1) {
  10131. sign0 = coefficentsSign[index - 1];
  10132. contribution = 1 - sign1 - sign0;
  10133. } else {
  10134. contribution = 1 - sign1 - sign1;
  10135. }
  10136. } else if (significance1) {
  10137. sign0 = coefficentsSign[index - 1];
  10138. contribution = 1 - sign0 - sign0;
  10139. } else {
  10140. contribution = 0;
  10141. }
  10142. var horizontalContribution = 3 * contribution;
  10143. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  10144. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  10145. sign1 = coefficentsSign[index + width];
  10146. if (significance1) {
  10147. sign0 = coefficentsSign[index - width];
  10148. contribution = 1 - sign1 - sign0 + horizontalContribution;
  10149. } else {
  10150. contribution = 1 - sign1 - sign1 + horizontalContribution;
  10151. }
  10152. } else if (significance1) {
  10153. sign0 = coefficentsSign[index - width];
  10154. contribution = 1 - sign0 - sign0 + horizontalContribution;
  10155. } else {
  10156. contribution = horizontalContribution;
  10157. }
  10158. if (contribution >= 0) {
  10159. contextLabel = 9 + contribution;
  10160. decoded = this.decoder.readBit(this.contexts, contextLabel);
  10161. } else {
  10162. contextLabel = 9 - contribution;
  10163. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  10164. }
  10165. return decoded;
  10166. }
  10167. }, {
  10168. key: "runMagnitudeRefinementPass",
  10169. value: function runMagnitudeRefinementPass() {
  10170. var decoder = this.decoder;
  10171. var width = this.width,
  10172. height = this.height;
  10173. var coefficentsMagnitude = this.coefficentsMagnitude;
  10174. var neighborsSignificance = this.neighborsSignificance;
  10175. var contexts = this.contexts;
  10176. var bitsDecoded = this.bitsDecoded;
  10177. var processingFlags = this.processingFlags;
  10178. var processedMask = 1;
  10179. var firstMagnitudeBitMask = 2;
  10180. var length = width * height;
  10181. var width4 = width * 4;
  10182. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  10183. indexNext = Math.min(length, index0 + width4);
  10184. for (var j = 0; j < width; j++) {
  10185. for (var index = index0 + j; index < indexNext; index += width) {
  10186. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  10187. continue;
  10188. }
  10189. var contextLabel = 16;
  10190. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  10191. processingFlags[index] ^= firstMagnitudeBitMask;
  10192. var significance = neighborsSignificance[index] & 127;
  10193. contextLabel = significance === 0 ? 15 : 14;
  10194. }
  10195. var bit = decoder.readBit(contexts, contextLabel);
  10196. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  10197. bitsDecoded[index]++;
  10198. processingFlags[index] |= processedMask;
  10199. }
  10200. }
  10201. }
  10202. }
  10203. }, {
  10204. key: "runCleanupPass",
  10205. value: function runCleanupPass() {
  10206. var decoder = this.decoder;
  10207. var width = this.width,
  10208. height = this.height;
  10209. var neighborsSignificance = this.neighborsSignificance;
  10210. var coefficentsMagnitude = this.coefficentsMagnitude;
  10211. var coefficentsSign = this.coefficentsSign;
  10212. var contexts = this.contexts;
  10213. var labels = this.contextLabelTable;
  10214. var bitsDecoded = this.bitsDecoded;
  10215. var processingFlags = this.processingFlags;
  10216. var processedMask = 1;
  10217. var firstMagnitudeBitMask = 2;
  10218. var oneRowDown = width;
  10219. var twoRowsDown = width * 2;
  10220. var threeRowsDown = width * 3;
  10221. var iNext;
  10222. for (var i0 = 0; i0 < height; i0 = iNext) {
  10223. iNext = Math.min(i0 + 4, height);
  10224. var indexBase = i0 * width;
  10225. var checkAllEmpty = i0 + 3 < height;
  10226. for (var j = 0; j < width; j++) {
  10227. var index0 = indexBase + j;
  10228. var allEmpty = checkAllEmpty && processingFlags[index0] === 0 && processingFlags[index0 + oneRowDown] === 0 && processingFlags[index0 + twoRowsDown] === 0 && processingFlags[index0 + threeRowsDown] === 0 && neighborsSignificance[index0] === 0 && neighborsSignificance[index0 + oneRowDown] === 0 && neighborsSignificance[index0 + twoRowsDown] === 0 && neighborsSignificance[index0 + threeRowsDown] === 0;
  10229. var i1 = 0,
  10230. index = index0;
  10231. var i = i0,
  10232. sign = void 0;
  10233. if (allEmpty) {
  10234. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  10235. if (!hasSignificantCoefficent) {
  10236. bitsDecoded[index0]++;
  10237. bitsDecoded[index0 + oneRowDown]++;
  10238. bitsDecoded[index0 + twoRowsDown]++;
  10239. bitsDecoded[index0 + threeRowsDown]++;
  10240. continue;
  10241. }
  10242. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  10243. if (i1 !== 0) {
  10244. i = i0 + i1;
  10245. index += i1 * width;
  10246. }
  10247. sign = this.decodeSignBit(i, j, index);
  10248. coefficentsSign[index] = sign;
  10249. coefficentsMagnitude[index] = 1;
  10250. this.setNeighborsSignificance(i, j, index);
  10251. processingFlags[index] |= firstMagnitudeBitMask;
  10252. index = index0;
  10253. for (var i2 = i0; i2 <= i; i2++, index += width) {
  10254. bitsDecoded[index]++;
  10255. }
  10256. i1++;
  10257. }
  10258. for (i = i0 + i1; i < iNext; i++, index += width) {
  10259. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  10260. continue;
  10261. }
  10262. var contextLabel = labels[neighborsSignificance[index]];
  10263. var decision = decoder.readBit(contexts, contextLabel);
  10264. if (decision === 1) {
  10265. sign = this.decodeSignBit(i, j, index);
  10266. coefficentsSign[index] = sign;
  10267. coefficentsMagnitude[index] = 1;
  10268. this.setNeighborsSignificance(i, j, index);
  10269. processingFlags[index] |= firstMagnitudeBitMask;
  10270. }
  10271. bitsDecoded[index]++;
  10272. }
  10273. }
  10274. }
  10275. }
  10276. }, {
  10277. key: "checkSegmentationSymbol",
  10278. value: function checkSegmentationSymbol() {
  10279. var decoder = this.decoder;
  10280. var contexts = this.contexts;
  10281. var symbol = decoder.readBit(contexts, UNIFORM_CONTEXT) << 3 | decoder.readBit(contexts, UNIFORM_CONTEXT) << 2 | decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  10282. if (symbol !== 0xa) {
  10283. throw new JpxError("Invalid segmentation symbol");
  10284. }
  10285. }
  10286. }]);
  10287. return BitModel;
  10288. }();
  10289. return BitModel;
  10290. }();
  10291. var Transform = /*#__PURE__*/function () {
  10292. function Transform() {
  10293. _classCallCheck(this, Transform);
  10294. if (this.constructor === Transform) {
  10295. (0, _util.unreachable)("Cannot initialize Transform.");
  10296. }
  10297. }
  10298. _createClass(Transform, [{
  10299. key: "calculate",
  10300. value: function calculate(subbands, u0, v0) {
  10301. var ll = subbands[0];
  10302. for (var i = 1, ii = subbands.length; i < ii; i++) {
  10303. ll = this.iterate(ll, subbands[i], u0, v0);
  10304. }
  10305. return ll;
  10306. }
  10307. }, {
  10308. key: "extend",
  10309. value: function extend(buffer, offset, size) {
  10310. var i1 = offset - 1,
  10311. j1 = offset + 1;
  10312. var i2 = offset + size - 2,
  10313. j2 = offset + size;
  10314. buffer[i1--] = buffer[j1++];
  10315. buffer[j2++] = buffer[i2--];
  10316. buffer[i1--] = buffer[j1++];
  10317. buffer[j2++] = buffer[i2--];
  10318. buffer[i1--] = buffer[j1++];
  10319. buffer[j2++] = buffer[i2--];
  10320. buffer[i1] = buffer[j1];
  10321. buffer[j2] = buffer[i2];
  10322. }
  10323. }, {
  10324. key: "filter",
  10325. value: function filter(x, offset, length) {
  10326. (0, _util.unreachable)("Abstract method `filter` called");
  10327. }
  10328. }, {
  10329. key: "iterate",
  10330. value: function iterate(ll, hl_lh_hh, u0, v0) {
  10331. var llWidth = ll.width,
  10332. llHeight = ll.height;
  10333. var llItems = ll.items;
  10334. var width = hl_lh_hh.width;
  10335. var height = hl_lh_hh.height;
  10336. var items = hl_lh_hh.items;
  10337. var i, j, k, l, u, v;
  10338. for (k = 0, i = 0; i < llHeight; i++) {
  10339. l = i * 2 * width;
  10340. for (j = 0; j < llWidth; j++, k++, l += 2) {
  10341. items[l] = llItems[k];
  10342. }
  10343. }
  10344. llItems = ll.items = null;
  10345. var bufferPadding = 4;
  10346. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  10347. if (width === 1) {
  10348. if ((u0 & 1) !== 0) {
  10349. for (v = 0, k = 0; v < height; v++, k += width) {
  10350. items[k] *= 0.5;
  10351. }
  10352. }
  10353. } else {
  10354. for (v = 0, k = 0; v < height; v++, k += width) {
  10355. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  10356. this.extend(rowBuffer, bufferPadding, width);
  10357. this.filter(rowBuffer, bufferPadding, width);
  10358. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  10359. }
  10360. }
  10361. var numBuffers = 16;
  10362. var colBuffers = [];
  10363. for (i = 0; i < numBuffers; i++) {
  10364. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  10365. }
  10366. var b,
  10367. currentBuffer = 0;
  10368. ll = bufferPadding + height;
  10369. if (height === 1) {
  10370. if ((v0 & 1) !== 0) {
  10371. for (u = 0; u < width; u++) {
  10372. items[u] *= 0.5;
  10373. }
  10374. }
  10375. } else {
  10376. for (u = 0; u < width; u++) {
  10377. if (currentBuffer === 0) {
  10378. numBuffers = Math.min(width - u, numBuffers);
  10379. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  10380. for (b = 0; b < numBuffers; b++) {
  10381. colBuffers[b][l] = items[k + b];
  10382. }
  10383. }
  10384. currentBuffer = numBuffers;
  10385. }
  10386. currentBuffer--;
  10387. var buffer = colBuffers[currentBuffer];
  10388. this.extend(buffer, bufferPadding, height);
  10389. this.filter(buffer, bufferPadding, height);
  10390. if (currentBuffer === 0) {
  10391. k = u - numBuffers + 1;
  10392. for (l = bufferPadding; l < ll; k += width, l++) {
  10393. for (b = 0; b < numBuffers; b++) {
  10394. items[k + b] = colBuffers[b][l];
  10395. }
  10396. }
  10397. }
  10398. }
  10399. }
  10400. return {
  10401. width: width,
  10402. height: height,
  10403. items: items
  10404. };
  10405. }
  10406. }]);
  10407. return Transform;
  10408. }();
  10409. var IrreversibleTransform = /*#__PURE__*/function (_Transform) {
  10410. _inherits(IrreversibleTransform, _Transform);
  10411. var _super2 = _createSuper(IrreversibleTransform);
  10412. function IrreversibleTransform() {
  10413. _classCallCheck(this, IrreversibleTransform);
  10414. return _super2.apply(this, arguments);
  10415. }
  10416. _createClass(IrreversibleTransform, [{
  10417. key: "filter",
  10418. value: function filter(x, offset, length) {
  10419. var len = length >> 1;
  10420. offset |= 0;
  10421. var j, n, current, next;
  10422. var alpha = -1.586134342059924;
  10423. var beta = -0.052980118572961;
  10424. var gamma = 0.882911075530934;
  10425. var delta = 0.443506852043971;
  10426. var K = 1.230174104914001;
  10427. var K_ = 1 / K;
  10428. j = offset - 3;
  10429. for (n = len + 4; n--; j += 2) {
  10430. x[j] *= K_;
  10431. }
  10432. j = offset - 2;
  10433. current = delta * x[j - 1];
  10434. for (n = len + 3; n--; j += 2) {
  10435. next = delta * x[j + 1];
  10436. x[j] = K * x[j] - current - next;
  10437. if (n--) {
  10438. j += 2;
  10439. current = delta * x[j + 1];
  10440. x[j] = K * x[j] - current - next;
  10441. } else {
  10442. break;
  10443. }
  10444. }
  10445. j = offset - 1;
  10446. current = gamma * x[j - 1];
  10447. for (n = len + 2; n--; j += 2) {
  10448. next = gamma * x[j + 1];
  10449. x[j] -= current + next;
  10450. if (n--) {
  10451. j += 2;
  10452. current = gamma * x[j + 1];
  10453. x[j] -= current + next;
  10454. } else {
  10455. break;
  10456. }
  10457. }
  10458. j = offset;
  10459. current = beta * x[j - 1];
  10460. for (n = len + 1; n--; j += 2) {
  10461. next = beta * x[j + 1];
  10462. x[j] -= current + next;
  10463. if (n--) {
  10464. j += 2;
  10465. current = beta * x[j + 1];
  10466. x[j] -= current + next;
  10467. } else {
  10468. break;
  10469. }
  10470. }
  10471. if (len !== 0) {
  10472. j = offset + 1;
  10473. current = alpha * x[j - 1];
  10474. for (n = len; n--; j += 2) {
  10475. next = alpha * x[j + 1];
  10476. x[j] -= current + next;
  10477. if (n--) {
  10478. j += 2;
  10479. current = alpha * x[j + 1];
  10480. x[j] -= current + next;
  10481. } else {
  10482. break;
  10483. }
  10484. }
  10485. }
  10486. }
  10487. }]);
  10488. return IrreversibleTransform;
  10489. }(Transform);
  10490. var ReversibleTransform = /*#__PURE__*/function (_Transform2) {
  10491. _inherits(ReversibleTransform, _Transform2);
  10492. var _super3 = _createSuper(ReversibleTransform);
  10493. function ReversibleTransform() {
  10494. _classCallCheck(this, ReversibleTransform);
  10495. return _super3.apply(this, arguments);
  10496. }
  10497. _createClass(ReversibleTransform, [{
  10498. key: "filter",
  10499. value: function filter(x, offset, length) {
  10500. var len = length >> 1;
  10501. offset |= 0;
  10502. var j, n;
  10503. for (j = offset, n = len + 1; n--; j += 2) {
  10504. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  10505. }
  10506. for (j = offset + 1, n = len; n--; j += 2) {
  10507. x[j] += x[j - 1] + x[j + 1] >> 1;
  10508. }
  10509. }
  10510. }]);
  10511. return ReversibleTransform;
  10512. }(Transform);
  10513. /***/ })
  10514. /******/ ]);
  10515. /************************************************************************/
  10516. /******/ // The module cache
  10517. /******/ var __webpack_module_cache__ = {};
  10518. /******/
  10519. /******/ // The require function
  10520. /******/ function __w_pdfjs_require__(moduleId) {
  10521. /******/ // Check if module is in cache
  10522. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  10523. /******/ if (cachedModule !== undefined) {
  10524. /******/ return cachedModule.exports;
  10525. /******/ }
  10526. /******/ // Create a new module (and put it into the cache)
  10527. /******/ var module = __webpack_module_cache__[moduleId] = {
  10528. /******/ id: moduleId,
  10529. /******/ loaded: false,
  10530. /******/ exports: {}
  10531. /******/ };
  10532. /******/
  10533. /******/ // Execute the module function
  10534. /******/ __webpack_modules__[moduleId](module, module.exports, __w_pdfjs_require__);
  10535. /******/
  10536. /******/ // Flag the module as loaded
  10537. /******/ module.loaded = true;
  10538. /******/
  10539. /******/ // Return the exports of the module
  10540. /******/ return module.exports;
  10541. /******/ }
  10542. /******/
  10543. /************************************************************************/
  10544. /******/ /* webpack/runtime/node module decorator */
  10545. /******/ (() => {
  10546. /******/ __w_pdfjs_require__.nmd = (module) => {
  10547. /******/ module.paths = [];
  10548. /******/ if (!module.children) module.children = [];
  10549. /******/ return module;
  10550. /******/ };
  10551. /******/ })();
  10552. /******/
  10553. /************************************************************************/
  10554. var __webpack_exports__ = {};
  10555. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  10556. (() => {
  10557. "use strict";
  10558. var exports = __webpack_exports__;
  10559. Object.defineProperty(exports, "__esModule", ({
  10560. value: true
  10561. }));
  10562. Object.defineProperty(exports, "Jbig2Image", ({
  10563. enumerable: true,
  10564. get: function get() {
  10565. return _jbig.Jbig2Image;
  10566. }
  10567. }));
  10568. Object.defineProperty(exports, "JpegImage", ({
  10569. enumerable: true,
  10570. get: function get() {
  10571. return _jpg.JpegImage;
  10572. }
  10573. }));
  10574. Object.defineProperty(exports, "JpxImage", ({
  10575. enumerable: true,
  10576. get: function get() {
  10577. return _jpx.JpxImage;
  10578. }
  10579. }));
  10580. Object.defineProperty(exports, "getVerbosityLevel", ({
  10581. enumerable: true,
  10582. get: function get() {
  10583. return _util.getVerbosityLevel;
  10584. }
  10585. }));
  10586. Object.defineProperty(exports, "setVerbosityLevel", ({
  10587. enumerable: true,
  10588. get: function get() {
  10589. return _util.setVerbosityLevel;
  10590. }
  10591. }));
  10592. var _util = __w_pdfjs_require__(1);
  10593. var _jbig = __w_pdfjs_require__(94);
  10594. var _jpg = __w_pdfjs_require__(102);
  10595. var _jpx = __w_pdfjs_require__(103);
  10596. var pdfjsVersion = '2.12.313';
  10597. var pdfjsBuild = 'a2ae56f39';
  10598. })();
  10599. /******/ return __webpack_exports__;
  10600. /******/ })()
  10601. ;
  10602. });
  10603. //# sourceMappingURL=pdf.image_decoders.js.map